npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ngx-popovers/core

v18.2.0

Published

A core package for the floating elements based on Angular and Floating-ui

Downloads

1,552

Readme

core

This library was generated with Nx and floating-ui for Angular applications.

To see a demo, click on the link provided.

FloatingService

Before use, ensure this service is added to the providers list.

You can import the FloatingService from '@ngx-popovers/core'.

Example usage:

import { FloatingService } from '@ngx-popovers/core';

@Component({
  standalone: true,
  providers: [FloatingService],
  template: '',
  styles: ''
})
export class AppComponent {
}

| Method | Description | Type | |-------------------|-------------------------------------------------------------------------------|-------------------------| | computePosition | The computePosition method is a proxy for computePositionfrom floating-ui | ComputePositionReturn | | autoUpdate | The autoUpdate method is a proxy for autoUpdate from floating-ui | cleanup function |

floatingService = inject(FloatingService);

this.floatingService.computePosition(trigger, floating);

You can also import all types and methods from floating-ui from this package:

import {
  Derivable,
  FlipOptions,
  OffsetOptions,
  Placement,
  ShiftOptions
} from '@ngx-popovers/core';

portal

To see a demo, click on the link provided.

Usage

The <ngx-portal/> component displays content on the body.

You can also display portal content within an element of your choice:


<div #portalWillBeInsideMe>
  <p>Portal content will be rendered after this tag</p>
  <!-- Here -->
</div>

<ngx-portal [bindTo]="portalWillBeInsideMe">
  <p>It will be displayed as the last child of the div</p>
</ngx-portal>

This component is essential for displaying tooltips correctly without overlapping with other elements on the page.

ClickOutside directive

The click outside directive manages clicks inside and outside HTMLElements. This directive is used by the ngx-floating component.

To see a demo, click on the link provided.

Usage

import { ClickOutsideDirective, ClickOutsideEvent } from '@ngx-popovers/core';

@Component({
  selector: 'ngx-click-outside-example',
  standalone: true,
  imports: [ClickOutsideDirective],
  template: `
    <div
      (ngxClickOutside)="onClick($event)"
      (inside)="onInsideClicked($event)"
      (outside)="onOutsideClicked($event)"
    ></div>
  `
})
export class ClickOutsideExample {
  onClick(event: ClickOutsideEvent) {
    console.log('Click!', el);
  }

  onInsideClicked(el: EventTarget) {
    console.log('Inside click!', el);
  }

  onOutsideClicked(el: EventTarget) {
    console.log('Outside click!', el);
  }
}

floating

The Floating component implements the floating-ui library for Angular

To see a demo, click on the link provided.

Usage

For more information about the properties, refer to the official documentation for floating-ui.


<div #reference>
  <p>Reference content</p>
</div>

<ngx-floating
  [reference]="reference"
  [placement]="'bottom'"
  [middleware]="middleware"
>
  <div class="floating">
    <p>Floating content</p>
  </div>
</ngx-floating>

API

Inputs

| Input | Description | Type | Default | |--------------|---------------------------------------------------------------|--------------------------------------|---------------------| | placement | controls the position of the floating relative to the trigger | Placement | bottom | | middleware | list of middleware from floating-ui | MiddlewareList | offset(4), flip() | | autoUpdate | updates floating element automatically | boolean | true | | bindTo | renders floating element as last child of bindTo | string | HTMLElement | .body | | strategy | This is the type of CSS position property to use | absolute | fixed | undefined | undefined |

Outputs

| Output | Description | Type | |-------------------------|----------------------------------------------------------------------|-------------------------| | clickedOutside | emits when user clicks outside the floating element | Element | | clickedInside | emits when user clicks inside the floating element | Element | | computePositionReturn | emits every time when the floating component calls computePosition | ComputePositionReturn |

Configuration

There is a configuration token NGX_FLOATING_CONFIG. Please use the NgxFloatingConfig class to change the default floating properties.

export const FloatingConfigProvider: Provider = {
  provide: NGX_FLOATING_CONFIG,
  useValue: new NgxFloatingConfig({
    placement: 'top-end',
    arrow: true
  })
};

Arrow

The arrow component adds an arrow to the floating component.


<div #trigger>Trigger</div>

<ngx-floating
  [reference]="trigger"
>
  <p>Floating content</p>

  <ngx-arrow padding="10" />
</ngx-floating>

To see a demo, click on the link provided.

You can provide your own component for arrow visualization:

@Component({
  standalone: true,
  template: `
    <div
      style="
        width: 5px;
        height: 5px;
        transform: rotate(45deg);
        background: indianred;
      "
    ></div>
  `
})
export class CustomArrow extends FloatingArrowBase {
}

export const ArrowProvider: Provider = {
  provide: NGX_ARROW_COMPONENT,
  useValue: CustomArrow
};

Any module:

@Component({
  standalone: true,
  selector: 'app',
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss',
  providers: [ArrowProvider]
})

Sources

This package is a major dependency for other npm packages: