ng-primitives 0.59.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ng-primitives-a11y.mjs +3 -3
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +1 -1
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-popover.mjs +18 -6
- package/fesm2022/ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/ng-primitives-toast.mjs +405 -160
- package/fesm2022/ng-primitives-toast.mjs.map +1 -1
- package/package.json +27 -27
- package/popover/popover-trigger/popover-trigger.d.ts +9 -3
- package/schematics/ng-generate/templates/toast/toast.__fileSuffix@dasherize__.ts.template +104 -36
- package/toast/config/toast-config.d.ts +36 -7
- package/toast/index.d.ts +2 -1
- package/toast/toast/toast-context.d.ts +3 -0
- package/toast/toast/toast-manager.d.ts +50 -0
- package/toast/toast/toast-options.d.ts +34 -0
- package/toast/toast/toast-timer.d.ts +14 -0
- package/toast/toast/toast.d.ts +60 -37
- package/toast/toast/toast-ref.d.ts +0 -49
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, computed,
|
|
2
|
+
import { signal, computed, Directive } from '@angular/core';
|
|
3
|
+
import { explicitEffect } from 'ng-primitives/internal';
|
|
3
4
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
4
5
|
|
|
5
6
|
function activeDescendantManager(options) {
|
|
@@ -17,8 +18,7 @@ function activeDescendantManager(options) {
|
|
|
17
18
|
const activeItem = computed(() => sortedOptions()?.[activeIndex()]);
|
|
18
19
|
const disabled = computed(() => options.disabled?.() || options.items().every(item => item.disabled?.()));
|
|
19
20
|
// any time the item list changes, check if the active index is still valid
|
|
20
|
-
|
|
21
|
-
const items = sortedOptions();
|
|
21
|
+
explicitEffect([sortedOptions], ([items]) => {
|
|
22
22
|
if (activeIndex() >= items.length || activeIndex() < 0) {
|
|
23
23
|
activeIndex.set(items.findIndex(item => !item.disabled?.()));
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-a11y.mjs","sources":["../../../../packages/ng-primitives/a11y/src/active-descendant/active-descendant.ts","../../../../packages/ng-primitives/a11y/src/visually-hidden/visually-hidden-state.ts","../../../../packages/ng-primitives/a11y/src/visually-hidden/visually-hidden.ts","../../../../packages/ng-primitives/a11y/src/ng-primitives-a11y.ts"],"sourcesContent":["import { computed, effect, ElementRef, Signal, signal } from '@angular/core';\n\ninterface ActiveDescendantManagerOptions<T extends NgpActivatable> {\n /**\n * The disabled state of the active descendant group.\n * @default false\n */\n disabled?: Signal<boolean>;\n /**\n * The items in the active descendant group.\n */\n items: Signal<T[]>;\n /**\n * Whether active descendant should wrap around.\n * @default false\n */\n wrap?: Signal<boolean>;\n}\n\nexport interface NgpActivatable {\n /**\n * The id of the item.\n */\n id: Signal<string>;\n /**\n * Whether the item is disabled.\n */\n disabled?: Signal<boolean>;\n /**\n * The element that represents the item.\n */\n elementRef: ElementRef<HTMLElement>;\n}\n\nexport function activeDescendantManager<T extends NgpActivatable>(\n options: ActiveDescendantManagerOptions<T>,\n) {\n const sortedOptions = () =>\n options\n .items()\n .slice()\n .sort((a, b) => {\n const aElement = a.elementRef.nativeElement;\n const bElement = b.elementRef.nativeElement;\n return aElement.compareDocumentPosition(bElement) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1;\n });\n\n const activeIndex = signal<number>(0);\n const activeItem = computed<T | undefined>(() => sortedOptions()?.[activeIndex()]);\n const disabled = computed(\n () => options.disabled?.() || options.items().every(item => item.disabled?.()),\n );\n\n // any time the item list changes, check if the active index is still valid\n effect(() => {\n const items = sortedOptions();\n if (activeIndex() >= items.length || activeIndex() < 0) {\n activeIndex.set(items.findIndex(item => !item.disabled?.()));\n }\n if (activeIndex() === -1 && items.length > 0) {\n activeIndex.set(0);\n }\n if (disabled() || items.length === 0) {\n activeIndex.set(-1);\n }\n });\n\n const activeDescendant = computed(() => {\n const item = activeItem();\n\n if (disabled() || !item) {\n return undefined;\n }\n\n return item.id();\n });\n\n /**\n * Activate an item in the active descendant group.\n * @param item The item to activate.\n */\n const activate = (item: T | undefined) => {\n if (item === undefined) {\n activeIndex.set(-1);\n return;\n }\n\n if (disabled() || item.disabled?.()) {\n return;\n }\n\n activeIndex.set(sortedOptions().indexOf(item));\n };\n\n /**\n * Activate the first enabled item in the active descendant group.\n */\n const first = () => {\n const item = sortedOptions().findIndex(item => !item.disabled?.());\n\n if (item) {\n activeIndex.set(item);\n }\n };\n\n /**\n * Activate the last enabled item in the active descendant group.\n */\n const last = () => {\n const item = sortedOptions()\n .reverse()\n .findIndex(item => !item.disabled?.());\n\n if (item !== -1) {\n activeIndex.set(sortedOptions().length - 1 - item);\n }\n };\n\n const findNextIndex = (\n items: NgpActivatable[],\n currentIndex: number,\n direction: 1 | -1,\n wrap: boolean,\n ): number | undefined => {\n let index = (currentIndex + direction + items.length) % items.length;\n\n while (index !== currentIndex) {\n const item = items[index];\n if (item && !item.disabled?.()) {\n return index;\n }\n index = (index + direction + items.length) % items.length;\n\n if (\n !wrap &&\n ((direction === 1 && index === 0) || (direction === -1 && index === items.length - 1))\n ) {\n break;\n }\n }\n\n return undefined;\n };\n\n /**\n * Activate the next enabled item in the active descendant group.\n */\n const next = () => {\n const items = sortedOptions();\n const nextIndex = findNextIndex(items, activeIndex(), 1, options.wrap?.() ?? false);\n\n if (nextIndex !== undefined) {\n activeIndex.set(nextIndex);\n }\n };\n\n /**\n * Activate the previous enabled item in the active descendant group.\n */\n const previous = () => {\n const items = sortedOptions();\n const prevIndex = findNextIndex(items, activeIndex(), -1, options.wrap?.() ?? false);\n\n if (prevIndex !== undefined) {\n activeIndex.set(prevIndex);\n }\n };\n\n /**\n * Reset the active descendant group, clearing the active index.\n */\n const reset = () => {\n activeIndex.set(-1);\n };\n\n return {\n activeDescendant,\n activeItem,\n activate,\n first,\n last,\n next,\n previous,\n reset,\n };\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpVisuallyHidden } from './visually-hidden';\n\n/**\n * The state token for the VisuallyHidden primitive.\n */\nexport const NgpVisuallyHiddenStateToken = createStateToken<NgpVisuallyHidden>('VisuallyHidden');\n\n/**\n * Provides the VisuallyHidden state.\n */\nexport const provideVisuallyHiddenState = createStateProvider(NgpVisuallyHiddenStateToken);\n\n/**\n * Injects the VisuallyHidden state.\n */\nexport const injectVisuallyHiddenState = createStateInjector<NgpVisuallyHidden>(\n NgpVisuallyHiddenStateToken,\n);\n\n/**\n * The VisuallyHidden state registration function.\n */\nexport const visuallyHiddenState = createState(NgpVisuallyHiddenStateToken);\n","import { Directive, computed, signal } from '@angular/core';\nimport { provideVisuallyHiddenState, visuallyHiddenState } from './visually-hidden-state';\n\n/**\n * Hide an element visually while keeping it present in the DOM.\n */\n@Directive({\n selector: '[ngpVisuallyHidden]',\n exportAs: 'ngpVisuallyHidden',\n providers: [provideVisuallyHiddenState()],\n host: {\n '[style]': 'style()',\n },\n})\nexport class NgpVisuallyHidden {\n /**\n * Whether the element is hidden.\n */\n protected readonly hidden = signal<boolean>(true);\n\n protected readonly style = computed(() => {\n if (!this.hidden()) {\n return {};\n }\n\n return {\n position: 'absolute',\n width: '1px',\n height: '1px',\n margin: '-1px',\n padding: '0',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: '0',\n wordWrap: 'normal',\n outline: '0',\n '-webkit-appearance': 'none',\n '-moz-appearance': 'none',\n 'inset-inline-start': '0',\n };\n });\n\n protected readonly state = visuallyHiddenState<NgpVisuallyHidden>(this);\n\n /**\n * Set the element visibility.\n * @param visible\n */\n setVisibility(visible: boolean): void {\n this.hidden.set(!visible);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"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descendant/active-descendant.ts","../../../../packages/ng-primitives/a11y/src/visually-hidden/visually-hidden-state.ts","../../../../packages/ng-primitives/a11y/src/visually-hidden/visually-hidden.ts","../../../../packages/ng-primitives/a11y/src/ng-primitives-a11y.ts"],"sourcesContent":["import { computed, ElementRef, Signal, signal } from '@angular/core';\nimport { explicitEffect } from 'ng-primitives/internal';\n\ninterface ActiveDescendantManagerOptions<T extends NgpActivatable> {\n /**\n * The disabled state of the active descendant group.\n * @default false\n */\n disabled?: Signal<boolean>;\n /**\n * The items in the active descendant group.\n */\n items: Signal<T[]>;\n /**\n * Whether active descendant should wrap around.\n * @default false\n */\n wrap?: Signal<boolean>;\n}\n\nexport interface NgpActivatable {\n /**\n * The id of the item.\n */\n id: Signal<string>;\n /**\n * Whether the item is disabled.\n */\n disabled?: Signal<boolean>;\n /**\n * The element that represents the item.\n */\n elementRef: ElementRef<HTMLElement>;\n}\n\nexport function activeDescendantManager<T extends NgpActivatable>(\n options: ActiveDescendantManagerOptions<T>,\n) {\n const sortedOptions = () =>\n options\n .items()\n .slice()\n .sort((a, b) => {\n const aElement = a.elementRef.nativeElement;\n const bElement = b.elementRef.nativeElement;\n return aElement.compareDocumentPosition(bElement) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1;\n });\n\n const activeIndex = signal<number>(0);\n const activeItem = computed<T | undefined>(() => sortedOptions()?.[activeIndex()]);\n const disabled = computed(\n () => options.disabled?.() || options.items().every(item => item.disabled?.()),\n );\n\n // any time the item list changes, check if the active index is still valid\n explicitEffect([sortedOptions], ([items]) => {\n if (activeIndex() >= items.length || activeIndex() < 0) {\n activeIndex.set(items.findIndex(item => !item.disabled?.()));\n }\n if (activeIndex() === -1 && items.length > 0) {\n activeIndex.set(0);\n }\n if (disabled() || items.length === 0) {\n activeIndex.set(-1);\n }\n });\n\n const activeDescendant = computed(() => {\n const item = activeItem();\n\n if (disabled() || !item) {\n return undefined;\n }\n\n return item.id();\n });\n\n /**\n * Activate an item in the active descendant group.\n * @param item The item to activate.\n */\n const activate = (item: T | undefined) => {\n if (item === undefined) {\n activeIndex.set(-1);\n return;\n }\n\n if (disabled() || item.disabled?.()) {\n return;\n }\n\n activeIndex.set(sortedOptions().indexOf(item));\n };\n\n /**\n * Activate the first enabled item in the active descendant group.\n */\n const first = () => {\n const item = sortedOptions().findIndex(item => !item.disabled?.());\n\n if (item) {\n activeIndex.set(item);\n }\n };\n\n /**\n * Activate the last enabled item in the active descendant group.\n */\n const last = () => {\n const item = sortedOptions()\n .reverse()\n .findIndex(item => !item.disabled?.());\n\n if (item !== -1) {\n activeIndex.set(sortedOptions().length - 1 - item);\n }\n };\n\n const findNextIndex = (\n items: NgpActivatable[],\n currentIndex: number,\n direction: 1 | -1,\n wrap: boolean,\n ): number | undefined => {\n let index = (currentIndex + direction + items.length) % items.length;\n\n while (index !== currentIndex) {\n const item = items[index];\n if (item && !item.disabled?.()) {\n return index;\n }\n index = (index + direction + items.length) % items.length;\n\n if (\n !wrap &&\n ((direction === 1 && index === 0) || (direction === -1 && index === items.length - 1))\n ) {\n break;\n }\n }\n\n return undefined;\n };\n\n /**\n * Activate the next enabled item in the active descendant group.\n */\n const next = () => {\n const items = sortedOptions();\n const nextIndex = findNextIndex(items, activeIndex(), 1, options.wrap?.() ?? false);\n\n if (nextIndex !== undefined) {\n activeIndex.set(nextIndex);\n }\n };\n\n /**\n * Activate the previous enabled item in the active descendant group.\n */\n const previous = () => {\n const items = sortedOptions();\n const prevIndex = findNextIndex(items, activeIndex(), -1, options.wrap?.() ?? false);\n\n if (prevIndex !== undefined) {\n activeIndex.set(prevIndex);\n }\n };\n\n /**\n * Reset the active descendant group, clearing the active index.\n */\n const reset = () => {\n activeIndex.set(-1);\n };\n\n return {\n activeDescendant,\n activeItem,\n activate,\n first,\n last,\n next,\n previous,\n reset,\n };\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpVisuallyHidden } from './visually-hidden';\n\n/**\n * The state token for the VisuallyHidden primitive.\n */\nexport const NgpVisuallyHiddenStateToken = createStateToken<NgpVisuallyHidden>('VisuallyHidden');\n\n/**\n * Provides the VisuallyHidden state.\n */\nexport const provideVisuallyHiddenState = createStateProvider(NgpVisuallyHiddenStateToken);\n\n/**\n * Injects the VisuallyHidden state.\n */\nexport const injectVisuallyHiddenState = createStateInjector<NgpVisuallyHidden>(\n NgpVisuallyHiddenStateToken,\n);\n\n/**\n * The VisuallyHidden state registration function.\n */\nexport const visuallyHiddenState = createState(NgpVisuallyHiddenStateToken);\n","import { Directive, computed, signal } from '@angular/core';\nimport { provideVisuallyHiddenState, visuallyHiddenState } from './visually-hidden-state';\n\n/**\n * Hide an element visually while keeping it present in the DOM.\n */\n@Directive({\n selector: '[ngpVisuallyHidden]',\n exportAs: 'ngpVisuallyHidden',\n providers: [provideVisuallyHiddenState()],\n host: {\n '[style]': 'style()',\n },\n})\nexport class NgpVisuallyHidden {\n /**\n * Whether the element is hidden.\n */\n protected readonly hidden = signal<boolean>(true);\n\n protected readonly style = computed(() => {\n if (!this.hidden()) {\n return {};\n }\n\n return {\n position: 'absolute',\n width: '1px',\n height: '1px',\n margin: '-1px',\n padding: '0',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: '0',\n wordWrap: 'normal',\n outline: '0',\n '-webkit-appearance': 'none',\n '-moz-appearance': 'none',\n 'inset-inline-start': '0',\n };\n });\n\n protected readonly state = visuallyHiddenState<NgpVisuallyHidden>(this);\n\n /**\n * Set the element visibility.\n * @param visible\n */\n setVisibility(visible: boolean): void {\n this.hidden.set(!visible);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAmCM,SAAU,uBAAuB,CACrC,OAA0C,EAAA;AAE1C,IAAA,MAAM,aAAa,GAAG,MACpB;AACG,SAAA,KAAK;AACL,SAAA,KAAK;AACL,SAAA,IAAI,CAAC,CAAC,CAAC,E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B,QAAA,IAAA,CAAA,KAAK,GAAG,mBAAmB,CAAoB,IAAI,CAAC;AASxE,IAAA;AAPC;;;AAGG;AACH,IAAA,aAAa,CAAC,OAAgB,EAAA;QAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;IAC3B;+GArCW,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAjB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,iBAAiB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,qBAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,OAAA,EAAA,SAAA,EAAA,EAAA,EAAA,SAAA,EALjB,CAAC,0BAA0B,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAK9B,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAR7B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,qBAAqB;AAC/B,oBAAA,QAAQ,EAAE,mBAAmB;AAC7B,oBAAA,SAAS,EAAE,CAAC,0BAA0B,EAAE,CAAC;AACzC,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE,SAAS;AACrB,qBAAA;AACF,iBAAA;;;ACbD;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-internal.mjs","sources":["../../../../packages/ng-primitives/internal/src/utilities/element-ref.ts","../../../../packages/ng-primitives/internal/src/exit-animation/exit-animation-manager.ts","../../../../packages/ng-primitives/internal/src/exit-animation/exit-animation.ts","../../../../packages/ng-primitives/internal/src/utilities/interaction.ts","../../../../packages/ng-primitives/internal/src/interactions/focus.ts","../../../../packages/ng-primitives/internal/src/interactions/focus-visible.ts","../../../../packages/ng-primitives/internal/src/signals/explicit-effect.ts","../../../../packages/ng-primitives/internal/src/utilities/resize.ts","../../../../packages/ng-primitives/internal/src/utilities/dom-removal.ts","../../../../packages/ng-primitives/internal/src/interactions/hover.ts","../../../../packages/ng-primitives/internal/src/interactions/press.ts","../../../../packages/ng-primitives/internal/src/interactions/interactions.ts","../../../../packages/ng-primitives/internal/src/interactions/button.ts","../../../../packages/ng-primitives/internal/src/style-injector/style-injector.ts","../../../../packages/ng-primitives/internal/src/utilities/mutation-observer.ts","../../../../packages/ng-primitives/internal/src/utilities/overflow.ts","../../../../packages/ng-primitives/internal/src/utilities/scrolling.ts","../../../../packages/ng-primitives/internal/src/ng-primitives-internal.ts"],"sourcesContent":["import { ElementRef, inject } from '@angular/core';\n\n/**\n * A simple utility function to inject an element reference with less boilerplate.\n * @returns The element reference.\n */\nexport function injectElementRef<T extends HTMLElement>(): ElementRef<T> {\n return inject(ElementRef);\n}\n","import { ClassProvider, inject, Injectable } from '@angular/core';\nimport type { NgpExitAnimation } from './exit-animation';\n\n@Injectable()\nexport class NgpExitAnimationManager {\n /** Store the instances of the exit animation directive. */\n private readonly instances: NgpExitAnimation[] = [];\n\n /** Add an instance to the manager. */\n add(instance: NgpExitAnimation): void {\n this.instances.push(instance);\n }\n\n /** Remove an instance from the manager. */\n remove(instance: NgpExitAnimation): void {\n const index = this.instances.indexOf(instance);\n if (index !== -1) {\n this.instances.splice(index, 1);\n }\n }\n\n /** Exit all instances. */\n async exit(): Promise<void> {\n await Promise.all(this.instances.map(instance => instance.exit()));\n }\n}\n\nexport function provideExitAnimationManager(): ClassProvider {\n return { provide: NgpExitAnimationManager, useClass: NgpExitAnimationManager };\n}\n\nexport function injectExitAnimationManager(): NgpExitAnimationManager {\n return inject(NgpExitAnimationManager);\n}\n","import { Directive, OnDestroy } from '@angular/core';\nimport { injectElementRef } from '../utilities/element-ref';\nimport { injectExitAnimationManager } from './exit-animation-manager';\n\n@Directive({\n selector: '[ngpExitAnimation]',\n exportAs: 'ngpExitAnimation',\n})\nexport class NgpExitAnimation implements OnDestroy {\n /** The animation manager. */\n private readonly animationManager = injectExitAnimationManager();\n /** Access the element reference. */\n protected readonly elementRef = injectElementRef();\n\n /** Exist animation reference. */\n protected readonly ref = setupExitAnimation({ element: this.elementRef.nativeElement });\n\n constructor() {\n this.animationManager.add(this);\n }\n\n ngOnDestroy(): void {\n this.animationManager.remove(this);\n }\n\n /** Mark the element as exiting. */\n async exit(): Promise<void> {\n await this.ref.exit();\n }\n}\n\ninterface NgpExitAnimationOptions {\n /** The element to animate. */\n element: HTMLElement;\n}\n\nexport interface NgpExitAnimationRef {\n /** Mark the element as exiting and wait for the animation to finish. */\n exit: () => Promise<void>;\n}\n\nexport function setupExitAnimation({ element }: NgpExitAnimationOptions): NgpExitAnimationRef {\n let state: 'enter' | 'exit' = 'enter';\n\n function setState(newState: 'enter' | 'exit') {\n state = newState;\n\n // remove all current animation state attributes\n element.removeAttribute('data-enter');\n element.removeAttribute('data-exit');\n element.removeAttribute('inert');\n\n // add the new animation state attribute\n if (state === 'enter') {\n element.setAttribute('data-enter', '');\n } else if (state === 'exit') {\n element.setAttribute('data-exit', '');\n // make the element inert to prevent interaction while exiting\n element.setAttribute('inert', '');\n }\n }\n\n // Set the initial state to 'enter'\n setState('enter');\n\n return {\n exit: () => {\n return new Promise((resolve, reject) => {\n setState('exit');\n\n const animations = element.getAnimations();\n\n // Wait for the exit animations to finish\n if (animations.length > 0) {\n Promise.all(animations.map(anim => anim.finished))\n .then(() => resolve())\n .catch(err => {\n if (err instanceof Error && err.name !== 'AbortError') {\n return reject(err);\n }\n // Ignore abort errors as they are expected when the animation is interrupted\n // by the removal of the element - e.g. when the user navigates away to another page\n resolve();\n });\n } else {\n resolve();\n }\n });\n },\n };\n}\n","/**\n * This function checks to see if a given interaction has already been setup on a given element.\n * If it has, it returns the existing interaction state.\n * If it has not, it sets up the interaction state for future checks.\n */\nexport function hasInteraction(element: HTMLElement, interaction: string): boolean {\n const hasInteraction = `__ngp-${interaction}` in element;\n\n // if the interaction has not been setup, we mark it as setup for future checks\n if (!hasInteraction) {\n (element as unknown as Record<string, unknown>)[`__ngp-${interaction}`] = true;\n }\n\n return hasInteraction;\n}\n","import { FocusMonitor } from '@angular/cdk/a11y';\nimport { ElementRef, Renderer2, Signal, inject, signal } from '@angular/core';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\n\nexport interface NgpFocusOptions {\n disabled?: Signal<boolean>;\n focusWithin?: boolean;\n focus?: () => void;\n blur?: () => void;\n}\n\nexport interface NgpFocusState {\n isFocused: Signal<boolean>;\n}\n\nexport function setupFocus({\n focus,\n blur,\n focusWithin = false,\n disabled = signal(false),\n}: NgpFocusOptions): NgpFocusState {\n /**\n * Access the element reference.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the focus monitor.\n */\n const focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the renderer.\n */\n const renderer = inject(Renderer2);\n\n /**\n * Whether the element is currently focused.\n */\n const isFocused = signal<boolean>(false);\n\n focusMonitor\n .monitor(elementRef, focusWithin)\n .pipe(safeTakeUntilDestroyed())\n .subscribe(focusOrigin => {\n if (disabled()) {\n return;\n }\n\n isFocused.set(focusOrigin !== null);\n if (focusOrigin !== null) {\n if (focus) {\n focus();\n }\n renderer.setAttribute(elementRef.nativeElement, 'data-focus', '');\n } else {\n if (blur) {\n blur();\n }\n renderer.removeAttribute(elementRef.nativeElement, 'data-focus');\n }\n });\n\n return { isFocused };\n}\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { ElementRef, inject, Renderer2, Signal, signal } from '@angular/core';\nimport { onBooleanChange, safeTakeUntilDestroyed } from 'ng-primitives/utils';\n\nexport interface NgpFocusVisibleOptions {\n disabled?: Signal<boolean>;\n focusChange?: (value: boolean) => void;\n}\n\nexport interface NgpFocusVisibleState {\n isFocused: Signal<boolean>;\n}\n\nexport function setupFocusVisible({\n focusChange,\n disabled = signal(false),\n}: NgpFocusVisibleOptions): NgpFocusVisibleState {\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n const renderer = inject(Renderer2);\n const focusMonitor = inject(FocusMonitor);\n\n // Whether the element is currently focused.\n const isFocused = signal<boolean>(false);\n\n // handle focus state\n focusMonitor\n .monitor(elementRef.nativeElement)\n .pipe(safeTakeUntilDestroyed())\n .subscribe(origin =>\n // null indicates the element was blurred\n origin === null ? onBlur() : onFocus(origin),\n );\n\n // if the component becomes disabled and it is focused, hide the focus\n onBooleanChange(disabled, () => focus(false));\n\n function onFocus(origin: FocusOrigin): void {\n if (disabled() || isFocused()) {\n return;\n }\n\n // for some elements the focus visible state should always appear on focus\n if (alwaysShowFocus()) {\n focus(true);\n return;\n }\n\n // if the focus origin is keyboard or program(focused programmatically), then the focus is visible\n if (origin === 'keyboard') {\n focus(true);\n return;\n }\n }\n\n function onBlur(): void {\n if (disabled() || !isFocused()) {\n return;\n }\n\n focus(false);\n }\n\n /**\n * Trigger the focus signal along with the focusChange event.\n */\n function focus(value: boolean) {\n if (isFocused() === value) {\n return;\n }\n\n isFocused.set(value);\n focusChange?.(value);\n\n if (value) {\n renderer.setAttribute(elementRef.nativeElement, 'data-focus-visible', '');\n } else {\n renderer.removeAttribute(elementRef.nativeElement, 'data-focus-visible');\n }\n }\n\n function alwaysShowFocus(): boolean {\n const nonTextInputTypes = [\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset',\n ];\n\n // if this is an input element and it is a text input\n if (\n elementRef.nativeElement instanceof HTMLInputElement &&\n !nonTextInputTypes.includes(elementRef.nativeElement.type)\n ) {\n return true;\n }\n\n // if this is a textarea\n if (elementRef.nativeElement instanceof HTMLTextAreaElement) {\n return true;\n }\n\n // if this is an element with contenteditable\n if (\n elementRef.nativeElement.isContentEditable ||\n elementRef.nativeElement.hasAttribute('contenteditable')\n ) {\n return true;\n }\n\n return false;\n }\n\n return {\n isFocused,\n };\n}\n","/**\n * This implementation is heavily inspired by the great work on ngextension!\n * https://github.com/ngxtension/ngxtension-platform/blob/main/libs/ngxtension/explicit-effect/src/explicit-effect.ts\n */\nimport {\n CreateEffectOptions,\n EffectCleanupRegisterFn,\n EffectRef,\n effect,\n untracked,\n} from '@angular/core';\n\n/**\n * We want to have the Tuple in order to use the types in the function signature\n */\ntype ExplicitEffectValues<T> = {\n [K in keyof T]: () => T[K];\n};\n\n/**\n * This explicit effect function will take the dependencies and the function to run when the dependencies change.\n * @param deps - The dependencies that the effect will run on\n * @param fn - The function to run when the dependencies change\n * @param options - The options for the effect with the addition of defer (it allows the computation to run on first change, not immediately)\n */\nexport function explicitEffect<Input extends readonly unknown[], Params = Input>(\n deps: readonly [...ExplicitEffectValues<Input>],\n fn: (deps: Params, onCleanup: EffectCleanupRegisterFn) => void,\n options?: CreateEffectOptions,\n): EffectRef {\n return effect(onCleanup => {\n const depValues = deps.map(s => s());\n untracked(() => fn(depValues as Params, onCleanup));\n }, options);\n}\n","import { effect, inject, Injector, signal, Signal, untracked } from '@angular/core';\nimport { Observable, Subscription } from 'rxjs';\nimport { explicitEffect } from '../signals/explicit-effect';\n\ninterface NgpResizeObserverOptions {\n /**\n * Whether to listen for events.\n */\n disabled?: Signal<boolean>;\n\n /**\n * The injector to use when called from outside of the injector context.\n */\n injector?: Injector;\n}\n\n/**\n * A simple helper function to create a resize observer as an RxJS Observable.\n * @param element The element to observe for resize events.\n * @returns The resize event as an Observable.\n */\nexport function fromResizeEvent(\n element: HTMLElement,\n { disabled = signal(false), injector }: NgpResizeObserverOptions = {},\n): Observable<Dimensions> {\n return new Observable(observable => {\n // ResizeObserver may not be available in all environments, so check for its existence\n if (typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {\n // ResizeObserver is not available (SSR or unsupported browser)\n // Complete the observable without emitting any values\n observable.complete();\n return;\n }\n\n let observer: ResizeObserver | null = null;\n\n function setupOrTeardownObserver() {\n if (disabled()) {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n return;\n }\n\n if (!observer) {\n observer = new ResizeObserver(entries => {\n // if there are no entries, ignore the event\n if (!entries.length) {\n return;\n }\n\n // otherwise, take the first entry and emit the dimensions\n const entry = entries[0];\n\n if ('borderBoxSize' in entry) {\n const borderSizeEntry = entry['borderBoxSize'];\n // this may be different across browsers so normalize it\n const borderSize = Array.isArray(borderSizeEntry)\n ? borderSizeEntry[0]\n : borderSizeEntry;\n\n observable.next({ width: borderSize['inlineSize'], height: borderSize['blockSize'] });\n } else {\n // fallback for browsers that don't support borderBoxSize\n observable.next({ width: element.offsetWidth, height: element.offsetHeight });\n }\n });\n\n observer.observe(element);\n }\n }\n\n setupOrTeardownObserver();\n\n explicitEffect([disabled], () => setupOrTeardownObserver(), { injector });\n\n return () => observer?.disconnect();\n });\n}\n\n/**\n * A utility function to observe any element for resize events and return the dimensions as a signal.\n */\nexport function observeResize(elementFn: () => HTMLElement | undefined): Signal<Dimensions> {\n const dimensions = signal<Dimensions>({ width: 0, height: 0 });\n const injector = inject(Injector);\n\n // store the subscription to the resize event\n let subscription: Subscription | null = null;\n\n effect(() => {\n const targetElement = elementFn();\n\n untracked(() => {\n if (!targetElement) {\n return;\n }\n\n // if we already have a subscription, unsubscribe from it\n subscription?.unsubscribe();\n\n // create a new subscription to the resize event\n subscription = fromResizeEvent(targetElement, { injector }).subscribe(event =>\n dimensions.set({ width: event.width, height: event.height }),\n );\n });\n });\n\n return dimensions;\n}\n\nexport interface Dimensions {\n width: number;\n height: number;\n}\n","import { isPlatformServer } from '@angular/common';\nimport { inject, PLATFORM_ID } from '@angular/core';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { fromResizeEvent } from './resize';\n\n/**\n * Whenever an element is removed from the DOM, we call the callback.\n * @param element The element to watch for removal.\n * @param callback The callback to call when the element is removed.\n */\nexport function onDomRemoval(element: HTMLElement, callback: () => void): void {\n const platform = inject(PLATFORM_ID);\n\n // Dont run this on the server\n if (isPlatformServer(platform)) {\n return;\n }\n\n // This is a bit of a hack, but it works. If the element dimensions become zero,\n // it's likely that the element has been removed from the DOM.\n fromResizeEvent(element)\n .pipe(safeTakeUntilDestroyed())\n .subscribe(dimensions => {\n // we check the dimensions first to short-circuit the check as it's faster\n if (dimensions.width === 0 && dimensions.height === 0 && !document.body.contains(element)) {\n callback();\n }\n });\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { effect, ElementRef, inject, Injectable, PLATFORM_ID, Signal, signal } from '@angular/core';\nimport { injectDisposables, onBooleanChange } from 'ng-primitives/utils';\nimport { onDomRemoval } from '../utilities/dom-removal';\n\n/**\n * We use a service here as this value is a singleton\n * and allows us to register the dom events once.\n */\n@Injectable({\n providedIn: 'root',\n})\nclass GlobalPointerEvents {\n /**\n * Whether global mouse events should be ignored.\n */\n ignoreEmulatedMouseEvents: boolean = false;\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Determine the platform id.\n */\n private readonly platformId = inject(PLATFORM_ID);\n\n constructor() {\n // we only want to setup events on the client\n if (isPlatformBrowser(this.platformId)) {\n this.setupGlobalTouchEvents();\n }\n }\n\n private setupGlobalTouchEvents(): void {\n this.document.addEventListener('pointerup', this.handleGlobalPointerEvent.bind(this));\n this.document.addEventListener('touchend', this.setGlobalIgnoreEmulatedMouseEvents.bind(this));\n }\n\n private setGlobalIgnoreEmulatedMouseEvents(): void {\n this.ignoreEmulatedMouseEvents = true;\n // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter\n // with pointerType=\"mouse\" immediately after onPointerUp and before onFocus. On other\n // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in\n // the distant future because a user previously touched the element.\n setTimeout(() => (this.ignoreEmulatedMouseEvents = false), 50);\n }\n\n private handleGlobalPointerEvent(event: PointerEvent): void {\n if (event.pointerType === 'touch') {\n this.setGlobalIgnoreEmulatedMouseEvents();\n }\n }\n}\n\ninterface NgpHoverOptions {\n disabled?: Signal<boolean>;\n hoverStart?: () => void;\n hoverEnd?: () => void;\n}\n\nexport interface NgpHoverState {\n hovered: Signal<boolean>;\n}\n\n/**\n * Programatically add the hover functionality to an element.\n * This is useful in cases where we can't necessarily use a HostDirective,\n * because there is a chance the directive has already been used.\n */\nexport function setupHover({\n hoverStart,\n hoverEnd,\n disabled = signal(false),\n}: NgpHoverOptions): NgpHoverState {\n /**\n * Access the element.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the global pointer events handler.\n */\n const globalPointerEvents = inject(GlobalPointerEvents);\n\n /**\n * Access the disposable helper.\n */\n const disposables = injectDisposables();\n\n /**\n * Store the current hover state.\n */\n const hovered = signal<boolean>(false);\n\n /**\n * Whether this element should ignore emulated mouse events.\n */\n let ignoreEmulatedMouseEvents: boolean = false;\n\n /**\n * Setup event listeners.\n */\n disposables.addEventListener(elementRef.nativeElement, 'pointerenter', onPointerEnter);\n disposables.addEventListener(elementRef.nativeElement, 'pointerleave', onPointerLeave);\n disposables.addEventListener(elementRef.nativeElement, 'touchstart', onTouchStart);\n disposables.addEventListener(elementRef.nativeElement, 'mouseenter', onMouseEnter);\n disposables.addEventListener(elementRef.nativeElement, 'mouseleave', onMouseLeave);\n\n // anytime the disabled state changes to true, we must reset the hover state\n if (disabled) {\n onBooleanChange(disabled, reset);\n }\n\n // if the element is removed from the dom, we want to reset the hover state\n onDomRemoval(elementRef.nativeElement, reset);\n\n // anytime the hover state changes we want to update the attribute\n effect(() =>\n hovered()\n ? elementRef.nativeElement.setAttribute('data-hover', '')\n : elementRef.nativeElement.removeAttribute('data-hover'),\n );\n\n /**\n * Reset the hover state.\n */\n function reset(): void {\n onHoverEnd('mouse');\n }\n\n /**\n * Trigger the hover start events.\n * @param event\n * @param pointerType\n */\n function onHoverStart(event: Event, pointerType: string): void {\n if (\n disabled() ||\n pointerType === 'touch' ||\n hovered() ||\n !(event.currentTarget as Element)?.contains(event.target as Element)\n ) {\n return;\n }\n\n hovered.set(true);\n hoverStart?.();\n }\n\n /**\n * Trigger the hover end events.\n * @param pointerType\n */\n function onHoverEnd(pointerType: string): void {\n if (pointerType === 'touch' || !hovered()) {\n return;\n }\n\n hovered.set(false);\n hoverEnd?.();\n }\n\n function onPointerEnter(event: PointerEvent): void {\n if (globalPointerEvents.ignoreEmulatedMouseEvents && event.pointerType === 'mouse') {\n return;\n }\n\n onHoverStart(event, event.pointerType);\n }\n\n function onPointerLeave(event: PointerEvent): void {\n if (!disabled() && (event.currentTarget as Element)?.contains(event.target as Element)) {\n onHoverEnd(event.pointerType);\n }\n }\n\n function onTouchStart(): void {\n ignoreEmulatedMouseEvents = true;\n }\n\n function onMouseEnter(event: MouseEvent): void {\n if (!ignoreEmulatedMouseEvents && !globalPointerEvents.ignoreEmulatedMouseEvents) {\n onHoverStart(event, 'mouse');\n }\n\n ignoreEmulatedMouseEvents = false;\n }\n\n function onMouseLeave(event: MouseEvent): void {\n if (!disabled() && (event.currentTarget as Element)?.contains(event.target as Element)) {\n onHoverEnd('mouse');\n }\n }\n\n return { hovered };\n}\n","import { ElementRef, Signal, effect, inject, signal } from '@angular/core';\nimport { injectDisposables } from 'ng-primitives/utils';\n\ninterface NgpPressState {\n pressed: Signal<boolean>;\n}\n\ninterface NgpPressOptions {\n disabled?: Signal<boolean>;\n pressStart?: () => void;\n pressEnd?: () => void;\n}\n\nexport function setupPress({\n pressStart,\n pressEnd,\n disabled = signal(false),\n}: NgpPressOptions): NgpPressState {\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n const disposables = injectDisposables();\n\n /**\n * Whether the element is currently pressed.\n */\n const pressed = signal<boolean>(false);\n\n // setup event listeners\n disposables.addEventListener(elementRef.nativeElement, 'pointerdown', onPointerDown);\n\n // anytime the press state changes we want to update the attribute\n effect(() =>\n pressed() && !disabled()\n ? elementRef.nativeElement.setAttribute('data-press', '')\n : elementRef.nativeElement.removeAttribute('data-press'),\n );\n\n /**\n * Reset the press state.\n */\n function reset(): void {\n // if we are not pressing, then do nothing\n if (!pressed()) {\n return;\n }\n\n // clear any existing disposables\n disposableListeners.forEach(dispose => dispose());\n pressed.set(false);\n pressEnd?.();\n }\n\n /**\n * Store the list of disposables.\n */\n let disposableListeners: (() => void)[] = [];\n\n function onPointerDown(): void {\n if (disabled()) {\n return;\n }\n\n // clear any existing disposables\n disposableListeners.forEach(dispose => dispose());\n\n // update the press state\n pressed.set(true);\n pressStart?.();\n\n // setup global event listeners to catch events on elements outside the directive\n const ownerDocument = elementRef.nativeElement.ownerDocument ?? document;\n\n // if the pointer up event happens on any elements, then we are no longer pressing on this element\n const pointerUp = disposables.addEventListener(\n ownerDocument,\n 'pointerup',\n () => reset(),\n false,\n );\n\n // Instead of relying on the `pointerleave` event, which is not consistently called on iOS Safari,\n // we use the `pointermove` event to determine if we are still \"pressing\".\n // By checking if the target is still within the element, we can determine if the press is ongoing.\n const pointerMove = disposables.addEventListener(\n ownerDocument,\n 'pointermove',\n () => onPointerMove as EventListener,\n false,\n );\n\n // if the pointer is cancelled, then we are no longer pressing on this element\n const pointerCancel = disposables.addEventListener(\n ownerDocument,\n 'pointercancel',\n () => reset(),\n false,\n );\n\n disposableListeners = [pointerUp, pointerMove, pointerCancel];\n }\n\n function onPointerMove(event: PointerEvent): void {\n if (\n elementRef.nativeElement !== event.target &&\n !elementRef.nativeElement.contains(event.target as Node)\n ) {\n reset();\n }\n }\n\n return { pressed };\n}\n","import { signal, Signal } from '@angular/core';\nimport { injectElementRef } from '../utilities/element-ref';\nimport { hasInteraction } from '../utilities/interaction';\nimport { setupFocus } from './focus';\nimport { setupFocusVisible } from './focus-visible';\nimport { setupHover } from './hover';\nimport { setupPress } from './press';\n\nexport interface NgpInteractionOptions {\n hover?: boolean;\n press?: boolean;\n focus?: boolean;\n focusWithin?: boolean;\n focusVisible?: boolean;\n disabled?: Signal<boolean>;\n}\n\n/**\n * Setup the interactions without relying on HostDirectives.\n */\nexport function setupInteractions({\n focus,\n hover,\n press,\n focusWithin,\n focusVisible,\n disabled = signal(false),\n}: NgpInteractionOptions): void {\n const elementRef = injectElementRef();\n // If the interaction has already been setup, we can skip the setup.\n if (hasInteraction(elementRef.nativeElement, 'interactions')) {\n return;\n }\n\n if (hover) {\n setupHover({ disabled });\n }\n if (press) {\n setupPress({ disabled });\n }\n if (focus) {\n setupFocus({ focusWithin, disabled });\n }\n if (focusVisible) {\n setupFocusVisible({ disabled });\n }\n}\n","import { Signal } from '@angular/core';\nimport { booleanAttributeBinding } from 'ng-primitives/utils';\nimport { injectElementRef } from '../utilities/element-ref';\nimport { setupInteractions } from './interactions';\n\nexport interface NgpButtonOptions {\n /**\n * Whether the button is disabled.\n * @default false\n */\n disabled?: Signal<boolean>;\n}\n\n/**\n * Setup the button interactions and attributes.\n *\n * @param options - The options for the button.\n */\nexport function setupButton({ disabled }: NgpButtonOptions): void {\n const elementRef = injectElementRef();\n const isButton = elementRef.nativeElement.tagName.toLowerCase() === 'button';\n\n setupInteractions({ hover: true, press: true, focusVisible: true, disabled });\n\n // add the `data-disabled` attribute to the element\n booleanAttributeBinding(elementRef.nativeElement, 'data-disabled', disabled);\n\n // add the `disabled` attribute to the element if it is a button\n if (isButton) {\n booleanAttributeBinding(elementRef.nativeElement, 'disabled', disabled);\n }\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { CSP_NONCE, inject, Injectable, PLATFORM_ID } from '@angular/core';\n\n/**\n * A utility service for injecting styles into the document.\n * Angular doesn't allow directives to specify styles, only components.\n * As we ship directives, occasionally we need to associate styles with them.\n * This service allows us to programmatically inject styles into the document.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class StyleInjector {\n /**\n * Access the CSP nonce\n */\n private readonly cspNonce = inject(CSP_NONCE, { optional: true });\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Detect the platform.\n */\n private readonly platformId = inject(PLATFORM_ID);\n\n /**\n * Store the map of style elements with their unique identifiers.\n */\n private readonly styleElements = new Map<string, HTMLStyleElement>();\n\n constructor() {\n if (isPlatformBrowser(this.platformId)) {\n this.collectServerStyles();\n }\n }\n\n /**\n * Inject a style into the document.\n * @param id The unique identifier for the style.\n * @param style The style to inject.\n */\n add(id: string, style: string): void {\n if (this.styleElements.has(id)) {\n return;\n }\n\n const styleElement = this.document.createElement('style');\n styleElement.setAttribute('data-ngp-style', id);\n styleElement.textContent = style;\n\n // If a CSP nonce is provided, set it on the style element\n if (this.cspNonce) {\n styleElement.setAttribute('nonce', this.cspNonce);\n }\n\n this.document.head.appendChild(styleElement);\n this.styleElements.set(id, styleElement);\n }\n\n /**\n * Remove a style from the document.\n * @param id The unique identifier for the style.\n */\n remove(id: string): void {\n const styleElement = this.styleElements.get(id);\n\n if (styleElement) {\n this.document.head.removeChild(styleElement);\n this.styleElements.delete(id);\n }\n }\n\n /**\n * Collect any styles that were rendered by the server.\n */\n private collectServerStyles(): void {\n const styleElements = this.document.querySelectorAll<HTMLStyleElement>('style[data-ngp-style]');\n\n styleElements.forEach(styleElement => {\n const id = styleElement.getAttribute('data-ngp-style');\n\n if (id) {\n this.styleElements.set(id, styleElement);\n }\n });\n }\n}\n\nexport function injectStyleInjector(): StyleInjector {\n return inject(StyleInjector);\n}\n","import { Injector, Signal, signal } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { explicitEffect } from '../signals/explicit-effect';\n\ninterface NgpMutationObserverOptions {\n /**\n * Whether to listen for events.\n */\n disabled?: Signal<boolean>;\n /**\n * The injector to use when called from outside of the injector context.\n */\n injector?: Injector;\n /**\n * Whether the childList should be observed.\n */\n childList?: boolean;\n /**\n * Whether the subtree should be observed.\n */\n subtree?: boolean;\n /**\n * Whether the attributes should be observed.\n */\n attributes?: boolean;\n /**\n * Whether the characterData should be observed.\n */\n characterData?: boolean;\n /**\n * Whether the attributeFilter should be observed.\n */\n attributeFilter?: string[];\n}\n\n/**\n * This function sets up a mutation observer to listen for changes in the DOM.\n * It will stop listening when the `disabled` signal is true, and re-enable when it is false.\n * @param options - Options for the mutation observer\n */\nexport function fromMutationObserver(\n element: HTMLElement,\n {\n childList,\n subtree,\n attributes,\n characterData,\n disabled = signal(false),\n injector,\n }: NgpMutationObserverOptions = {},\n): Observable<MutationRecord[]> {\n return new Observable<MutationRecord[]>(observable => {\n let observer: MutationObserver | null = null;\n\n function setupOrTeardownObserver() {\n if (disabled()) {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n return;\n }\n\n observer = new MutationObserver(mutations => observable.next(mutations));\n observer.observe(element, { childList, subtree, attributes, characterData });\n }\n\n setupOrTeardownObserver();\n\n // any time the disabled state changes, we need to re-evaluate the observer\n explicitEffect([disabled], () => setupOrTeardownObserver(), { injector });\n\n return () => observer?.disconnect();\n });\n}\n","import { DestroyRef, inject, Injector, Signal, signal } from '@angular/core';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { merge } from 'rxjs';\nimport { fromMutationObserver } from './mutation-observer';\nimport { fromResizeEvent } from './resize';\n\ninterface NgpOverflowListenerOptions {\n /**\n * Whether to listen for overflow changes.\n */\n disabled?: Signal<boolean>;\n /**\n * The injector to use when called from outside of the injector context.\n */\n injector?: Injector;\n}\n\nexport function setupOverflowListener(\n element: HTMLElement,\n { disabled = signal(false), injector }: NgpOverflowListenerOptions,\n): Signal<boolean> {\n const hasOverflow = signal<boolean>(false);\n const destroyRef = injector?.get(DestroyRef) ?? inject(DestroyRef);\n\n // Merge both observables and update hasOverflow on any event\n\n merge(\n fromResizeEvent(element, { disabled, injector }),\n fromMutationObserver(element, { disabled, injector, characterData: true }),\n )\n .pipe(safeTakeUntilDestroyed(destroyRef))\n .subscribe(() =>\n hasOverflow.set(\n element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight,\n ),\n );\n\n return hasOverflow;\n}\n","function getScrollableAncestor(element: HTMLElement): HTMLElement | null {\n let parent = element.parentElement;\n while (parent) {\n const style = window.getComputedStyle(parent);\n if (/(auto|scroll)/.test(style.overflowY) || /(auto|scroll)/.test(style.overflowX)) {\n return parent;\n }\n parent = parent.parentElement;\n }\n return null;\n}\n\nexport function scrollIntoViewIfNeeded(element: HTMLElement): void {\n const scrollableAncestor = getScrollableAncestor(element);\n if (!scrollableAncestor) return;\n\n const parentRect = scrollableAncestor.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (elementRect.top < parentRect.top) {\n scrollableAncestor.scrollTop -= parentRect.top - elementRect.top;\n } else if (elementRect.bottom > parentRect.bottom) {\n scrollableAncestor.scrollTop += elementRect.bottom - parentRect.bottom;\n }\n\n if (elementRect.left < parentRect.left) {\n scrollableAncestor.scrollLeft -= parentRect.left - elementRect.left;\n } else if (elementRect.right > parentRect.right) {\n scrollableAncestor.scrollLeft += elementRect.right - parentRect.right;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEA;;;AAGG;SACa,gBAAgB,GAAA;AAC9B,IAAA,OAAO,MAAM,CAAC,UAAU,CAAC;AAC3B;;MCJa,uBAAuB,CAAA;AADpC,IAAA,WAAA,GAAA;;QAGmB,IAAA,CAAA,SAAS,GAAuB,EAAE;AAmBpD,IAAA;;AAhBC,IAAA,GAAG,CAAC,QAA0B,EAAA;AAC5B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC/B;;AAGA,IAAA,MAAM,CAAC,QAA0B,EAAA;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;AAC9C,QAAA,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC;IACF;;AAGA,IAAA,MAAM,IAAI,GAAA;QACR,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,IAAI,QA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AC,KAAK,CAAC,SAAS,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;AAClF,YAAA,OAAO,MAAM;QACf;AACA,QAAA,MAAM,GAAG,MAAM,CAAC,aAAa;IAC/B;AACA,IAAA,OAAO,IAAI;AACb;AAEM,SAAU,sBAAsB,CAAC,OAAoB,EAAA;AACzD,IAAA,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC;AACzD,IAAA,IAAI,CAAC,kBAAkB;QAAE;AAEzB,IAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,qBAAqB,EAAE;AAC7D,IAAA,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,EAAE;IAEnD,IAAI,WAAW,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE;QACpC,kBAAkB,CAAC,SAAS,IAAI,UAAU,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG;IAClE;SAAO,IAAI,WAAW,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE;QACjD,kBAAkB,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM;IACxE;IAEA,IAAI,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE;QACtC,kBAAkB,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI;IACrE;SAAO,IAAI,WAAW,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE;QAC/C,kBAAkB,CAAC,UAAU,IAAI,WAAW,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK;IACvE;AACF;;AC9BA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-internal.mjs","sources":["../../../../packages/ng-primitives/internal/src/utilities/element-ref.ts","../../../../packages/ng-primitives/internal/src/exit-animation/exit-animation-manager.ts","../../../../packages/ng-primitives/internal/src/exit-animation/exit-animation.ts","../../../../packages/ng-primitives/internal/src/utilities/interaction.ts","../../../../packages/ng-primitives/internal/src/interactions/focus.ts","../../../../packages/ng-primitives/internal/src/interactions/focus-visible.ts","../../../../packages/ng-primitives/internal/src/signals/explicit-effect.ts","../../../../packages/ng-primitives/internal/src/utilities/resize.ts","../../../../packages/ng-primitives/internal/src/utilities/dom-removal.ts","../../../../packages/ng-primitives/internal/src/interactions/hover.ts","../../../../packages/ng-primitives/internal/src/interactions/press.ts","../../../../packages/ng-primitives/internal/src/interactions/interactions.ts","../../../../packages/ng-primitives/internal/src/interactions/button.ts","../../../../packages/ng-primitives/internal/src/style-injector/style-injector.ts","../../../../packages/ng-primitives/internal/src/utilities/mutation-observer.ts","../../../../packages/ng-primitives/internal/src/utilities/overflow.ts","../../../../packages/ng-primitives/internal/src/utilities/scrolling.ts","../../../../packages/ng-primitives/internal/src/ng-primitives-internal.ts"],"sourcesContent":["import { ElementRef, inject } from '@angular/core';\n\n/**\n * A simple utility function to inject an element reference with less boilerplate.\n * @returns The element reference.\n */\nexport function injectElementRef<T extends HTMLElement>(): ElementRef<T> {\n return inject(ElementRef);\n}\n","import { ClassProvider, inject, Injectable } from '@angular/core';\nimport type { NgpExitAnimation } from './exit-animation';\n\n@Injectable()\nexport class NgpExitAnimationManager {\n /** Store the instances of the exit animation directive. */\n private readonly instances: NgpExitAnimation[] = [];\n\n /** Add an instance to the manager. */\n add(instance: NgpExitAnimation): void {\n this.instances.push(instance);\n }\n\n /** Remove an instance from the manager. */\n remove(instance: NgpExitAnimation): void {\n const index = this.instances.indexOf(instance);\n if (index !== -1) {\n this.instances.splice(index, 1);\n }\n }\n\n /** Exit all instances. */\n async exit(): Promise<void> {\n await Promise.all(this.instances.map(instance => instance.exit()));\n }\n}\n\nexport function provideExitAnimationManager(): ClassProvider {\n return { provide: NgpExitAnimationManager, useClass: NgpExitAnimationManager };\n}\n\nexport function injectExitAnimationManager(): NgpExitAnimationManager {\n return inject(NgpExitAnimationManager);\n}\n","import { Directive, OnDestroy } from '@angular/core';\nimport { injectElementRef } from '../utilities/element-ref';\nimport { injectExitAnimationManager } from './exit-animation-manager';\n\n@Directive({\n selector: '[ngpExitAnimation]',\n exportAs: 'ngpExitAnimation',\n})\nexport class NgpExitAnimation implements OnDestroy {\n /** The animation manager. */\n private readonly animationManager = injectExitAnimationManager();\n /** Access the element reference. */\n protected readonly elementRef = injectElementRef();\n\n /** Exist animation reference. */\n protected readonly ref = setupExitAnimation({ element: this.elementRef.nativeElement });\n\n constructor() {\n this.animationManager.add(this);\n }\n\n ngOnDestroy(): void {\n this.animationManager.remove(this);\n }\n\n /** Mark the element as exiting. */\n async exit(): Promise<void> {\n await this.ref.exit();\n }\n}\n\ninterface NgpExitAnimationOptions {\n /** The element to animate. */\n element: HTMLElement;\n}\n\nexport interface NgpExitAnimationRef {\n /** Mark the element as exiting and wait for the animation to finish. */\n exit: () => Promise<void>;\n}\n\nexport function setupExitAnimation({ element }: NgpExitAnimationOptions): NgpExitAnimationRef {\n let state: 'enter' | 'exit' = 'enter';\n\n function setState(newState: 'enter' | 'exit') {\n state = newState;\n\n // remove all current animation state attributes\n element.removeAttribute('data-enter');\n element.removeAttribute('data-exit');\n element.removeAttribute('inert');\n\n // add the new animation state attribute\n if (state === 'enter') {\n element.setAttribute('data-enter', '');\n } else if (state === 'exit') {\n element.setAttribute('data-exit', '');\n // make the element inert to prevent interaction while exiting\n element.setAttribute('inert', '');\n }\n }\n\n // Set the initial state to 'enter'\n requestAnimationFrame(() => setState('enter'));\n\n return {\n exit: () => {\n return new Promise((resolve, reject) => {\n setState('exit');\n\n const animations = element.getAnimations();\n\n // Wait for the exit animations to finish\n if (animations.length > 0) {\n Promise.all(animations.map(anim => anim.finished))\n .then(() => resolve())\n .catch(err => {\n if (err instanceof Error && err.name !== 'AbortError') {\n return reject(err);\n }\n // Ignore abort errors as they are expected when the animation is interrupted\n // by the removal of the element - e.g. when the user navigates away to another page\n resolve();\n });\n } else {\n resolve();\n }\n });\n },\n };\n}\n","/**\n * This function checks to see if a given interaction has already been setup on a given element.\n * If it has, it returns the existing interaction state.\n * If it has not, it sets up the interaction state for future checks.\n */\nexport function hasInteraction(element: HTMLElement, interaction: string): boolean {\n const hasInteraction = `__ngp-${interaction}` in element;\n\n // if the interaction has not been setup, we mark it as setup for future checks\n if (!hasInteraction) {\n (element as unknown as Record<string, unknown>)[`__ngp-${interaction}`] = true;\n }\n\n return hasInteraction;\n}\n","import { FocusMonitor } from '@angular/cdk/a11y';\nimport { ElementRef, Renderer2, Signal, inject, signal } from '@angular/core';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\n\nexport interface NgpFocusOptions {\n disabled?: Signal<boolean>;\n focusWithin?: boolean;\n focus?: () => void;\n blur?: () => void;\n}\n\nexport interface NgpFocusState {\n isFocused: Signal<boolean>;\n}\n\nexport function setupFocus({\n focus,\n blur,\n focusWithin = false,\n disabled = signal(false),\n}: NgpFocusOptions): NgpFocusState {\n /**\n * Access the element reference.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the focus monitor.\n */\n const focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the renderer.\n */\n const renderer = inject(Renderer2);\n\n /**\n * Whether the element is currently focused.\n */\n const isFocused = signal<boolean>(false);\n\n focusMonitor\n .monitor(elementRef, focusWithin)\n .pipe(safeTakeUntilDestroyed())\n .subscribe(focusOrigin => {\n if (disabled()) {\n return;\n }\n\n isFocused.set(focusOrigin !== null);\n if (focusOrigin !== null) {\n if (focus) {\n focus();\n }\n renderer.setAttribute(elementRef.nativeElement, 'data-focus', '');\n } else {\n if (blur) {\n blur();\n }\n renderer.removeAttribute(elementRef.nativeElement, 'data-focus');\n }\n });\n\n return { isFocused };\n}\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { ElementRef, inject, Renderer2, Signal, signal } from '@angular/core';\nimport { onBooleanChange, safeTakeUntilDestroyed } from 'ng-primitives/utils';\n\nexport interface NgpFocusVisibleOptions {\n disabled?: Signal<boolean>;\n focusChange?: (value: boolean) => void;\n}\n\nexport interface NgpFocusVisibleState {\n isFocused: Signal<boolean>;\n}\n\nexport function setupFocusVisible({\n focusChange,\n disabled = signal(false),\n}: NgpFocusVisibleOptions): NgpFocusVisibleState {\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n const renderer = inject(Renderer2);\n const focusMonitor = inject(FocusMonitor);\n\n // Whether the element is currently focused.\n const isFocused = signal<boolean>(false);\n\n // handle focus state\n focusMonitor\n .monitor(elementRef.nativeElement)\n .pipe(safeTakeUntilDestroyed())\n .subscribe(origin =>\n // null indicates the element was blurred\n origin === null ? onBlur() : onFocus(origin),\n );\n\n // if the component becomes disabled and it is focused, hide the focus\n onBooleanChange(disabled, () => focus(false));\n\n function onFocus(origin: FocusOrigin): void {\n if (disabled() || isFocused()) {\n return;\n }\n\n // for some elements the focus visible state should always appear on focus\n if (alwaysShowFocus()) {\n focus(true);\n return;\n }\n\n // if the focus origin is keyboard or program(focused programmatically), then the focus is visible\n if (origin === 'keyboard') {\n focus(true);\n return;\n }\n }\n\n function onBlur(): void {\n if (disabled() || !isFocused()) {\n return;\n }\n\n focus(false);\n }\n\n /**\n * Trigger the focus signal along with the focusChange event.\n */\n function focus(value: boolean) {\n if (isFocused() === value) {\n return;\n }\n\n isFocused.set(value);\n focusChange?.(value);\n\n if (value) {\n renderer.setAttribute(elementRef.nativeElement, 'data-focus-visible', '');\n } else {\n renderer.removeAttribute(elementRef.nativeElement, 'data-focus-visible');\n }\n }\n\n function alwaysShowFocus(): boolean {\n const nonTextInputTypes = [\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset',\n ];\n\n // if this is an input element and it is a text input\n if (\n elementRef.nativeElement instanceof HTMLInputElement &&\n !nonTextInputTypes.includes(elementRef.nativeElement.type)\n ) {\n return true;\n }\n\n // if this is a textarea\n if (elementRef.nativeElement instanceof HTMLTextAreaElement) {\n return true;\n }\n\n // if this is an element with contenteditable\n if (\n elementRef.nativeElement.isContentEditable ||\n elementRef.nativeElement.hasAttribute('contenteditable')\n ) {\n return true;\n }\n\n return false;\n }\n\n return {\n isFocused,\n };\n}\n","/**\n * This implementation is heavily inspired by the great work on ngextension!\n * https://github.com/ngxtension/ngxtension-platform/blob/main/libs/ngxtension/explicit-effect/src/explicit-effect.ts\n */\nimport {\n CreateEffectOptions,\n EffectCleanupRegisterFn,\n EffectRef,\n effect,\n untracked,\n} from '@angular/core';\n\n/**\n * We want to have the Tuple in order to use the types in the function signature\n */\ntype ExplicitEffectValues<T> = {\n [K in keyof T]: () => T[K];\n};\n\n/**\n * This explicit effect function will take the dependencies and the function to run when the dependencies change.\n * @param deps - The dependencies that the effect will run on\n * @param fn - The function to run when the dependencies change\n * @param options - The options for the effect with the addition of defer (it allows the computation to run on first change, not immediately)\n */\nexport function explicitEffect<Input extends readonly unknown[], Params = Input>(\n deps: readonly [...ExplicitEffectValues<Input>],\n fn: (deps: Params, onCleanup: EffectCleanupRegisterFn) => void,\n options?: CreateEffectOptions,\n): EffectRef {\n return effect(onCleanup => {\n const depValues = deps.map(s => s());\n untracked(() => fn(depValues as Params, onCleanup));\n }, options);\n}\n","import { effect, inject, Injector, signal, Signal, untracked } from '@angular/core';\nimport { Observable, Subscription } from 'rxjs';\nimport { explicitEffect } from '../signals/explicit-effect';\n\ninterface NgpResizeObserverOptions {\n /**\n * Whether to listen for events.\n */\n disabled?: Signal<boolean>;\n\n /**\n * The injector to use when called from outside of the injector context.\n */\n injector?: Injector;\n}\n\n/**\n * A simple helper function to create a resize observer as an RxJS Observable.\n * @param element The element to observe for resize events.\n * @returns The resize event as an Observable.\n */\nexport function fromResizeEvent(\n element: HTMLElement,\n { disabled = signal(false), injector }: NgpResizeObserverOptions = {},\n): Observable<Dimensions> {\n return new Observable(observable => {\n // ResizeObserver may not be available in all environments, so check for its existence\n if (typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {\n // ResizeObserver is not available (SSR or unsupported browser)\n // Complete the observable without emitting any values\n observable.complete();\n return;\n }\n\n let observer: ResizeObserver | null = null;\n\n function setupOrTeardownObserver() {\n if (disabled()) {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n return;\n }\n\n if (!observer) {\n observer = new ResizeObserver(entries => {\n // if there are no entries, ignore the event\n if (!entries.length) {\n return;\n }\n\n // otherwise, take the first entry and emit the dimensions\n const entry = entries[0];\n\n if ('borderBoxSize' in entry) {\n const borderSizeEntry = entry['borderBoxSize'];\n // this may be different across browsers so normalize it\n const borderSize = Array.isArray(borderSizeEntry)\n ? borderSizeEntry[0]\n : borderSizeEntry;\n\n observable.next({ width: borderSize['inlineSize'], height: borderSize['blockSize'] });\n } else {\n // fallback for browsers that don't support borderBoxSize\n observable.next({ width: element.offsetWidth, height: element.offsetHeight });\n }\n });\n\n observer.observe(element);\n }\n }\n\n setupOrTeardownObserver();\n\n explicitEffect([disabled], () => setupOrTeardownObserver(), { injector });\n\n return () => observer?.disconnect();\n });\n}\n\n/**\n * A utility function to observe any element for resize events and return the dimensions as a signal.\n */\nexport function observeResize(elementFn: () => HTMLElement | undefined): Signal<Dimensions> {\n const dimensions = signal<Dimensions>({ width: 0, height: 0 });\n const injector = inject(Injector);\n\n // store the subscription to the resize event\n let subscription: Subscription | null = null;\n\n effect(() => {\n const targetElement = elementFn();\n\n untracked(() => {\n if (!targetElement) {\n return;\n }\n\n // if we already have a subscription, unsubscribe from it\n subscription?.unsubscribe();\n\n // create a new subscription to the resize event\n subscription = fromResizeEvent(targetElement, { injector }).subscribe(event =>\n dimensions.set({ width: event.width, height: event.height }),\n );\n });\n });\n\n return dimensions;\n}\n\nexport interface Dimensions {\n width: number;\n height: number;\n}\n","import { isPlatformServer } from '@angular/common';\nimport { inject, PLATFORM_ID } from '@angular/core';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { fromResizeEvent } from './resize';\n\n/**\n * Whenever an element is removed from the DOM, we call the callback.\n * @param element The element to watch for removal.\n * @param callback The callback to call when the element is removed.\n */\nexport function onDomRemoval(element: HTMLElement, callback: () => void): void {\n const platform = inject(PLATFORM_ID);\n\n // Dont run this on the server\n if (isPlatformServer(platform)) {\n return;\n }\n\n // This is a bit of a hack, but it works. If the element dimensions become zero,\n // it's likely that the element has been removed from the DOM.\n fromResizeEvent(element)\n .pipe(safeTakeUntilDestroyed())\n .subscribe(dimensions => {\n // we check the dimensions first to short-circuit the check as it's faster\n if (dimensions.width === 0 && dimensions.height === 0 && !document.body.contains(element)) {\n callback();\n }\n });\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { effect, ElementRef, inject, Injectable, PLATFORM_ID, Signal, signal } from '@angular/core';\nimport { injectDisposables, onBooleanChange } from 'ng-primitives/utils';\nimport { onDomRemoval } from '../utilities/dom-removal';\n\n/**\n * We use a service here as this value is a singleton\n * and allows us to register the dom events once.\n */\n@Injectable({\n providedIn: 'root',\n})\nclass GlobalPointerEvents {\n /**\n * Whether global mouse events should be ignored.\n */\n ignoreEmulatedMouseEvents: boolean = false;\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Determine the platform id.\n */\n private readonly platformId = inject(PLATFORM_ID);\n\n constructor() {\n // we only want to setup events on the client\n if (isPlatformBrowser(this.platformId)) {\n this.setupGlobalTouchEvents();\n }\n }\n\n private setupGlobalTouchEvents(): void {\n this.document.addEventListener('pointerup', this.handleGlobalPointerEvent.bind(this));\n this.document.addEventListener('touchend', this.setGlobalIgnoreEmulatedMouseEvents.bind(this));\n }\n\n private setGlobalIgnoreEmulatedMouseEvents(): void {\n this.ignoreEmulatedMouseEvents = true;\n // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter\n // with pointerType=\"mouse\" immediately after onPointerUp and before onFocus. On other\n // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in\n // the distant future because a user previously touched the element.\n setTimeout(() => (this.ignoreEmulatedMouseEvents = false), 50);\n }\n\n private handleGlobalPointerEvent(event: PointerEvent): void {\n if (event.pointerType === 'touch') {\n this.setGlobalIgnoreEmulatedMouseEvents();\n }\n }\n}\n\ninterface NgpHoverOptions {\n disabled?: Signal<boolean>;\n hoverStart?: () => void;\n hoverEnd?: () => void;\n}\n\nexport interface NgpHoverState {\n hovered: Signal<boolean>;\n}\n\n/**\n * Programatically add the hover functionality to an element.\n * This is useful in cases where we can't necessarily use a HostDirective,\n * because there is a chance the directive has already been used.\n */\nexport function setupHover({\n hoverStart,\n hoverEnd,\n disabled = signal(false),\n}: NgpHoverOptions): NgpHoverState {\n /**\n * Access the element.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the global pointer events handler.\n */\n const globalPointerEvents = inject(GlobalPointerEvents);\n\n /**\n * Access the disposable helper.\n */\n const disposables = injectDisposables();\n\n /**\n * Store the current hover state.\n */\n const hovered = signal<boolean>(false);\n\n /**\n * Whether this element should ignore emulated mouse events.\n */\n let ignoreEmulatedMouseEvents: boolean = false;\n\n /**\n * Setup event listeners.\n */\n disposables.addEventListener(elementRef.nativeElement, 'pointerenter', onPointerEnter);\n disposables.addEventListener(elementRef.nativeElement, 'pointerleave', onPointerLeave);\n disposables.addEventListener(elementRef.nativeElement, 'touchstart', onTouchStart);\n disposables.addEventListener(elementRef.nativeElement, 'mouseenter', onMouseEnter);\n disposables.addEventListener(elementRef.nativeElement, 'mouseleave', onMouseLeave);\n\n // anytime the disabled state changes to true, we must reset the hover state\n if (disabled) {\n onBooleanChange(disabled, reset);\n }\n\n // if the element is removed from the dom, we want to reset the hover state\n onDomRemoval(elementRef.nativeElement, reset);\n\n // anytime the hover state changes we want to update the attribute\n effect(() =>\n hovered()\n ? elementRef.nativeElement.setAttribute('data-hover', '')\n : elementRef.nativeElement.removeAttribute('data-hover'),\n );\n\n /**\n * Reset the hover state.\n */\n function reset(): void {\n onHoverEnd('mouse');\n }\n\n /**\n * Trigger the hover start events.\n * @param event\n * @param pointerType\n */\n function onHoverStart(event: Event, pointerType: string): void {\n if (\n disabled() ||\n pointerType === 'touch' ||\n hovered() ||\n !(event.currentTarget as Element)?.contains(event.target as Element)\n ) {\n return;\n }\n\n hovered.set(true);\n hoverStart?.();\n }\n\n /**\n * Trigger the hover end events.\n * @param pointerType\n */\n function onHoverEnd(pointerType: string): void {\n if (pointerType === 'touch' || !hovered()) {\n return;\n }\n\n hovered.set(false);\n hoverEnd?.();\n }\n\n function onPointerEnter(event: PointerEvent): void {\n if (globalPointerEvents.ignoreEmulatedMouseEvents && event.pointerType === 'mouse') {\n return;\n }\n\n onHoverStart(event, event.pointerType);\n }\n\n function onPointerLeave(event: PointerEvent): void {\n if (!disabled() && (event.currentTarget as Element)?.contains(event.target as Element)) {\n onHoverEnd(event.pointerType);\n }\n }\n\n function onTouchStart(): void {\n ignoreEmulatedMouseEvents = true;\n }\n\n function onMouseEnter(event: MouseEvent): void {\n if (!ignoreEmulatedMouseEvents && !globalPointerEvents.ignoreEmulatedMouseEvents) {\n onHoverStart(event, 'mouse');\n }\n\n ignoreEmulatedMouseEvents = false;\n }\n\n function onMouseLeave(event: MouseEvent): void {\n if (!disabled() && (event.currentTarget as Element)?.contains(event.target as Element)) {\n onHoverEnd('mouse');\n }\n }\n\n return { hovered };\n}\n","import { ElementRef, Signal, effect, inject, signal } from '@angular/core';\nimport { injectDisposables } from 'ng-primitives/utils';\n\ninterface NgpPressState {\n pressed: Signal<boolean>;\n}\n\ninterface NgpPressOptions {\n disabled?: Signal<boolean>;\n pressStart?: () => void;\n pressEnd?: () => void;\n}\n\nexport function setupPress({\n pressStart,\n pressEnd,\n disabled = signal(false),\n}: NgpPressOptions): NgpPressState {\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n const disposables = injectDisposables();\n\n /**\n * Whether the element is currently pressed.\n */\n const pressed = signal<boolean>(false);\n\n // setup event listeners\n disposables.addEventListener(elementRef.nativeElement, 'pointerdown', onPointerDown);\n\n // anytime the press state changes we want to update the attribute\n effect(() =>\n pressed() && !disabled()\n ? elementRef.nativeElement.setAttribute('data-press', '')\n : elementRef.nativeElement.removeAttribute('data-press'),\n );\n\n /**\n * Reset the press state.\n */\n function reset(): void {\n // if we are not pressing, then do nothing\n if (!pressed()) {\n return;\n }\n\n // clear any existing disposables\n disposableListeners.forEach(dispose => dispose());\n pressed.set(false);\n pressEnd?.();\n }\n\n /**\n * Store the list of disposables.\n */\n let disposableListeners: (() => void)[] = [];\n\n function onPointerDown(): void {\n if (disabled()) {\n return;\n }\n\n // clear any existing disposables\n disposableListeners.forEach(dispose => dispose());\n\n // update the press state\n pressed.set(true);\n pressStart?.();\n\n // setup global event listeners to catch events on elements outside the directive\n const ownerDocument = elementRef.nativeElement.ownerDocument ?? document;\n\n // if the pointer up event happens on any elements, then we are no longer pressing on this element\n const pointerUp = disposables.addEventListener(\n ownerDocument,\n 'pointerup',\n () => reset(),\n false,\n );\n\n // Instead of relying on the `pointerleave` event, which is not consistently called on iOS Safari,\n // we use the `pointermove` event to determine if we are still \"pressing\".\n // By checking if the target is still within the element, we can determine if the press is ongoing.\n const pointerMove = disposables.addEventListener(\n ownerDocument,\n 'pointermove',\n () => onPointerMove as EventListener,\n false,\n );\n\n // if the pointer is cancelled, then we are no longer pressing on this element\n const pointerCancel = disposables.addEventListener(\n ownerDocument,\n 'pointercancel',\n () => reset(),\n false,\n );\n\n disposableListeners = [pointerUp, pointerMove, pointerCancel];\n }\n\n function onPointerMove(event: PointerEvent): void {\n if (\n elementRef.nativeElement !== event.target &&\n !elementRef.nativeElement.contains(event.target as Node)\n ) {\n reset();\n }\n }\n\n return { pressed };\n}\n","import { signal, Signal } from '@angular/core';\nimport { injectElementRef } from '../utilities/element-ref';\nimport { hasInteraction } from '../utilities/interaction';\nimport { setupFocus } from './focus';\nimport { setupFocusVisible } from './focus-visible';\nimport { setupHover } from './hover';\nimport { setupPress } from './press';\n\nexport interface NgpInteractionOptions {\n hover?: boolean;\n press?: boolean;\n focus?: boolean;\n focusWithin?: boolean;\n focusVisible?: boolean;\n disabled?: Signal<boolean>;\n}\n\n/**\n * Setup the interactions without relying on HostDirectives.\n */\nexport function setupInteractions({\n focus,\n hover,\n press,\n focusWithin,\n focusVisible,\n disabled = signal(false),\n}: NgpInteractionOptions): void {\n const elementRef = injectElementRef();\n // If the interaction has already been setup, we can skip the setup.\n if (hasInteraction(elementRef.nativeElement, 'interactions')) {\n return;\n }\n\n if (hover) {\n setupHover({ disabled });\n }\n if (press) {\n setupPress({ disabled });\n }\n if (focus) {\n setupFocus({ focusWithin, disabled });\n }\n if (focusVisible) {\n setupFocusVisible({ disabled });\n }\n}\n","import { Signal } from '@angular/core';\nimport { booleanAttributeBinding } from 'ng-primitives/utils';\nimport { injectElementRef } from '../utilities/element-ref';\nimport { setupInteractions } from './interactions';\n\nexport interface NgpButtonOptions {\n /**\n * Whether the button is disabled.\n * @default false\n */\n disabled?: Signal<boolean>;\n}\n\n/**\n * Setup the button interactions and attributes.\n *\n * @param options - The options for the button.\n */\nexport function setupButton({ disabled }: NgpButtonOptions): void {\n const elementRef = injectElementRef();\n const isButton = elementRef.nativeElement.tagName.toLowerCase() === 'button';\n\n setupInteractions({ hover: true, press: true, focusVisible: true, disabled });\n\n // add the `data-disabled` attribute to the element\n booleanAttributeBinding(elementRef.nativeElement, 'data-disabled', disabled);\n\n // add the `disabled` attribute to the element if it is a button\n if (isButton) {\n booleanAttributeBinding(elementRef.nativeElement, 'disabled', disabled);\n }\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { CSP_NONCE, inject, Injectable, PLATFORM_ID } from '@angular/core';\n\n/**\n * A utility service for injecting styles into the document.\n * Angular doesn't allow directives to specify styles, only components.\n * As we ship directives, occasionally we need to associate styles with them.\n * This service allows us to programmatically inject styles into the document.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class StyleInjector {\n /**\n * Access the CSP nonce\n */\n private readonly cspNonce = inject(CSP_NONCE, { optional: true });\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Detect the platform.\n */\n private readonly platformId = inject(PLATFORM_ID);\n\n /**\n * Store the map of style elements with their unique identifiers.\n */\n private readonly styleElements = new Map<string, HTMLStyleElement>();\n\n constructor() {\n if (isPlatformBrowser(this.platformId)) {\n this.collectServerStyles();\n }\n }\n\n /**\n * Inject a style into the document.\n * @param id The unique identifier for the style.\n * @param style The style to inject.\n */\n add(id: string, style: string): void {\n if (this.styleElements.has(id)) {\n return;\n }\n\n const styleElement = this.document.createElement('style');\n styleElement.setAttribute('data-ngp-style', id);\n styleElement.textContent = style;\n\n // If a CSP nonce is provided, set it on the style element\n if (this.cspNonce) {\n styleElement.setAttribute('nonce', this.cspNonce);\n }\n\n this.document.head.appendChild(styleElement);\n this.styleElements.set(id, styleElement);\n }\n\n /**\n * Remove a style from the document.\n * @param id The unique identifier for the style.\n */\n remove(id: string): void {\n const styleElement = this.styleElements.get(id);\n\n if (styleElement) {\n this.document.head.removeChild(styleElement);\n this.styleElements.delete(id);\n }\n }\n\n /**\n * Collect any styles that were rendered by the server.\n */\n private collectServerStyles(): void {\n const styleElements = this.document.querySelectorAll<HTMLStyleElement>('style[data-ngp-style]');\n\n styleElements.forEach(styleElement => {\n const id = styleElement.getAttribute('data-ngp-style');\n\n if (id) {\n this.styleElements.set(id, styleElement);\n }\n });\n }\n}\n\nexport function injectStyleInjector(): StyleInjector {\n return inject(StyleInjector);\n}\n","import { Injector, Signal, signal } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { explicitEffect } from '../signals/explicit-effect';\n\ninterface NgpMutationObserverOptions {\n /**\n * Whether to listen for events.\n */\n disabled?: Signal<boolean>;\n /**\n * The injector to use when called from outside of the injector context.\n */\n injector?: Injector;\n /**\n * Whether the childList should be observed.\n */\n childList?: boolean;\n /**\n * Whether the subtree should be observed.\n */\n subtree?: boolean;\n /**\n * Whether the attributes should be observed.\n */\n attributes?: boolean;\n /**\n * Whether the characterData should be observed.\n */\n characterData?: boolean;\n /**\n * Whether the attributeFilter should be observed.\n */\n attributeFilter?: string[];\n}\n\n/**\n * This function sets up a mutation observer to listen for changes in the DOM.\n * It will stop listening when the `disabled` signal is true, and re-enable when it is false.\n * @param options - Options for the mutation observer\n */\nexport function fromMutationObserver(\n element: HTMLElement,\n {\n childList,\n subtree,\n attributes,\n characterData,\n disabled = signal(false),\n injector,\n }: NgpMutationObserverOptions = {},\n): Observable<MutationRecord[]> {\n return new Observable<MutationRecord[]>(observable => {\n let observer: MutationObserver | null = null;\n\n function setupOrTeardownObserver() {\n if (disabled()) {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n return;\n }\n\n observer = new MutationObserver(mutations => observable.next(mutations));\n observer.observe(element, { childList, subtree, attributes, characterData });\n }\n\n setupOrTeardownObserver();\n\n // any time the disabled state changes, we need to re-evaluate the observer\n explicitEffect([disabled], () => setupOrTeardownObserver(), { injector });\n\n return () => observer?.disconnect();\n });\n}\n","import { DestroyRef, inject, Injector, Signal, signal } from '@angular/core';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { merge } from 'rxjs';\nimport { fromMutationObserver } from './mutation-observer';\nimport { fromResizeEvent } from './resize';\n\ninterface NgpOverflowListenerOptions {\n /**\n * Whether to listen for overflow changes.\n */\n disabled?: Signal<boolean>;\n /**\n * The injector to use when called from outside of the injector context.\n */\n injector?: Injector;\n}\n\nexport function setupOverflowListener(\n element: HTMLElement,\n { disabled = signal(false), injector }: NgpOverflowListenerOptions,\n): Signal<boolean> {\n const hasOverflow = signal<boolean>(false);\n const destroyRef = injector?.get(DestroyRef) ?? inject(DestroyRef);\n\n // Merge both observables and update hasOverflow on any event\n\n merge(\n fromResizeEvent(element, { disabled, injector }),\n fromMutationObserver(element, { disabled, injector, characterData: true }),\n )\n .pipe(safeTakeUntilDestroyed(destroyRef))\n .subscribe(() =>\n hasOverflow.set(\n element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight,\n ),\n );\n\n return hasOverflow;\n}\n","function getScrollableAncestor(element: HTMLElement): HTMLElement | null {\n let parent = element.parentElement;\n while (parent) {\n const style = window.getComputedStyle(parent);\n if (/(auto|scroll)/.test(style.overflowY) || /(auto|scroll)/.test(style.overflowX)) {\n return parent;\n }\n parent = parent.parentElement;\n }\n return null;\n}\n\nexport function scrollIntoViewIfNeeded(element: HTMLElement): void {\n const scrollableAncestor = getScrollableAncestor(element);\n if (!scrollableAncestor) return;\n\n const parentRect = scrollableAncestor.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n if (elementRect.top < parentRect.top) {\n scrollableAncestor.scrollTop -= parentRect.top - elementRect.top;\n } else if (elementRect.bottom > parentRect.bottom) {\n scrollableAncestor.scrollTop += elementRect.bottom - parentRect.bottom;\n }\n\n if (elementRect.left < parentRect.left) {\n scrollableAncestor.scrollLeft -= parentRect.left - elementRect.left;\n } else if (elementRect.right > parentRect.right) {\n scrollableAncestor.scrollLeft += elementRect.right - parentRect.right;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEA;;;AAGG;SACa,gBAAgB,GAAA;AAC9B,IAAA,OAAO,MAAM,CAAC,UAAU,CAAC;AAC3B;;MCJa,uBAAuB,CAAA;AADpC,IAAA,WAAA,GAAA;;QAGmB,IAAA,CAAA,SAAS,GAAuB,EAAE;AAmBpD,IAAA;;AAhBC,IAAA,GAAG,CAAC,QAA0B,EAAA;AAC5B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC/B;;AAGA,IAAA,MAAM,CAAC,QAA0B,EAAA;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;AAC9C,QAAA,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC;IACF;;AAGA,IAAA,MAAM,IAAI,GAAA;QACR,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS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gB,CAAC,MAAM,CAAC;AAC7C,QAAA,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;AAClF,YAAA,OAAO,MAAM;QACf;AACA,QAAA,MAAM,GAAG,MAAM,CAAC,aAAa;IAC/B;AACA,IAAA,OAAO,IAAI;AACb;AAEM,SAAU,sBAAsB,CAAC,OAAoB,EAAA;AACzD,IAAA,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC;AACzD,IAAA,IAAI,CAAC,kBAAkB;QAAE;AAEzB,IAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,qBAAqB,EAAE;AAC7D,IAAA,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,EAAE;IAEnD,IAAI,WAAW,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE;QACpC,kBAAkB,CAAC,SAAS,IAAI,UAAU,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG;IAClE;SAAO,IAAI,WAAW,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE;QACjD,kBAAkB,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM;IACxE;IAEA,IAAI,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE;QACtC,kBAAkB,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI;IACrE;SAAO,IAAI,WAAW,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE;QAC/C,kBAAkB,CAAC,UAAU,IAAI,WAAW,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK;IACvE;AACF;;AC9BA;;AAEG;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setupOverlayArrow, createOverlay, injectOverlay } from 'ng-primitives/portal';
|
|
2
2
|
export { injectOverlayContext as injectPopoverContext } from 'ng-primitives/portal';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken, inject, Directive, Injector, ViewContainerRef, input, booleanAttribute, numberAttribute, signal, computed } from '@angular/core';
|
|
4
|
+
import { InjectionToken, inject, Directive, Injector, ViewContainerRef, input, booleanAttribute, numberAttribute, signal, computed, output } from '@angular/core';
|
|
5
5
|
import { injectElementRef } from 'ng-primitives/internal';
|
|
6
6
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
7
7
|
import * as i1 from 'ng-primitives/focus-trap';
|
|
@@ -192,6 +192,12 @@ class NgpPopoverTrigger {
|
|
|
192
192
|
* @internal
|
|
193
193
|
*/
|
|
194
194
|
this.open = computed(() => this.overlay()?.isOpen() ?? false);
|
|
195
|
+
/**
|
|
196
|
+
* Event emitted when the popover open state changes.
|
|
197
|
+
*/
|
|
198
|
+
this.openChange = output({
|
|
199
|
+
alias: 'ngpPopoverTriggerOpenChange',
|
|
200
|
+
});
|
|
195
201
|
/**
|
|
196
202
|
* The popover trigger state.
|
|
197
203
|
*/
|
|
@@ -217,8 +223,9 @@ class NgpPopoverTrigger {
|
|
|
217
223
|
}
|
|
218
224
|
/**
|
|
219
225
|
* Show the popover.
|
|
226
|
+
* @returns A promise that resolves when the popover has been shown
|
|
220
227
|
*/
|
|
221
|
-
show() {
|
|
228
|
+
async show() {
|
|
222
229
|
// If the trigger is disabled, don't show the popover
|
|
223
230
|
if (this.state.disabled()) {
|
|
224
231
|
return;
|
|
@@ -228,19 +235,24 @@ class NgpPopoverTrigger {
|
|
|
228
235
|
this.createOverlay();
|
|
229
236
|
}
|
|
230
237
|
// Show the overlay
|
|
231
|
-
this.overlay()?.show();
|
|
238
|
+
await this.overlay()?.show();
|
|
239
|
+
if (this.open()) {
|
|
240
|
+
this.openChange.emit(true);
|
|
241
|
+
}
|
|
232
242
|
}
|
|
233
243
|
/**
|
|
234
244
|
* @internal
|
|
235
245
|
* Hide the popover.
|
|
246
|
+
* @returns A promise that resolves when the popover has been hidden
|
|
236
247
|
*/
|
|
237
|
-
hide(origin = 'program') {
|
|
248
|
+
async hide(origin = 'program') {
|
|
238
249
|
// If the trigger is disabled or the popover is not open, do nothing
|
|
239
250
|
if (this.state.disabled() || !this.open()) {
|
|
240
251
|
return;
|
|
241
252
|
}
|
|
242
253
|
// Hide the overlay
|
|
243
|
-
this.overlay()?.hide({ origin });
|
|
254
|
+
await this.overlay()?.hide({ origin });
|
|
255
|
+
this.openChange.emit(false);
|
|
244
256
|
}
|
|
245
257
|
/**
|
|
246
258
|
* Create the overlay that will contain the popover
|
|
@@ -271,7 +283,7 @@ class NgpPopoverTrigger {
|
|
|
271
283
|
this.overlay.set(createOverlay(config));
|
|
272
284
|
}
|
|
273
285
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpPopoverTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
274
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpPopoverTrigger, isStandalone: true, selector: "[ngpPopoverTrigger]", inputs: { popover: { classPropertyName: "popover", publicName: "ngpPopoverTrigger", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpPopoverTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpPopoverTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpPopoverTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpPopoverTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpPopoverTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpPopoverTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpPopoverTriggerContainer", isSignal: true, isRequired: false, transformFunction: null }, closeOnOutsideClick: { classPropertyName: "closeOnOutsideClick", publicName: "ngpPopoverTriggerCloseOnOutsideClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "ngpPopoverTriggerCloseOnEscape", isSignal: true, isRequired: false, transformFunction: null }, scrollBehavior: { classPropertyName: "scrollBehavior", publicName: "ngpPopoverTriggerScrollBehavior", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ngpPopoverTriggerContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "toggle($event)" }, properties: { "attr.aria-expanded": "open() ? \"true\" : \"false\"", "attr.data-open": "open() ? \"\" : null", "attr.data-placement": "state.placement()", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [providePopoverTriggerState({ inherit: false })], exportAs: ["ngpPopoverTrigger"], ngImport: i0 }); }
|
|
286
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpPopoverTrigger, isStandalone: true, selector: "[ngpPopoverTrigger]", inputs: { popover: { classPropertyName: "popover", publicName: "ngpPopoverTrigger", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpPopoverTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpPopoverTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpPopoverTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpPopoverTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpPopoverTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpPopoverTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpPopoverTriggerContainer", isSignal: true, isRequired: false, transformFunction: null }, closeOnOutsideClick: { classPropertyName: "closeOnOutsideClick", publicName: "ngpPopoverTriggerCloseOnOutsideClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "ngpPopoverTriggerCloseOnEscape", isSignal: true, isRequired: false, transformFunction: null }, scrollBehavior: { classPropertyName: "scrollBehavior", publicName: "ngpPopoverTriggerScrollBehavior", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ngpPopoverTriggerContext", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { openChange: "ngpPopoverTriggerOpenChange" }, host: { listeners: { "click": "toggle($event)" }, properties: { "attr.aria-expanded": "open() ? \"true\" : \"false\"", "attr.data-open": "open() ? \"\" : null", "attr.data-placement": "state.placement()", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [providePopoverTriggerState({ inherit: false })], exportAs: ["ngpPopoverTrigger"], ngImport: i0 }); }
|
|
275
287
|
}
|
|
276
288
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpPopoverTrigger, decorators: [{
|
|
277
289
|
type: Directive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-popover.mjs","sources":["../../../../packages/ng-primitives/popover/src/config/popover-config.ts","../../../../packages/ng-primitives/popover/src/popover-arrow/popover-arrow.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger-state.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger.ts","../../../../packages/ng-primitives/popover/src/popover/popover.ts","../../../../packages/ng-primitives/popover/src/ng-primitives-popover.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpPopoverConfig {\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'bottom'\n */\n placement: Placement;\n\n /**\n * Define the delay before the popover is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the popover should be attached.\n * @default document.body\n */\n container: HTMLElement | null;\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n closeOnOutsideClick: boolean;\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n closeOnEscape: boolean;\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default scroll\n */\n scrollBehavior: 'reposition' | 'block';\n}\n\nexport const defaultPopoverConfig: NgpPopoverConfig = {\n offset: 4,\n placement: 'bottom',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: null,\n closeOnOutsideClick: true,\n closeOnEscape: true,\n scrollBehavior: 'reposition',\n};\n\nexport const NgpPopoverConfigToken = new InjectionToken<NgpPopoverConfig>('NgpPopoverConfigToken');\n\n/**\n * Provide the default Popover configuration\n * @param config The Popover configuration\n * @returns The provider\n */\nexport function providePopoverConfig(config: Partial<NgpPopoverConfig>): Provider[] {\n return [\n {\n provide: NgpPopoverConfigToken,\n useValue: { ...defaultPopoverConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Popover configuration\n * @returns The global Popover configuration\n */\nexport function injectPopoverConfig(): NgpPopoverConfig {\n return inject(NgpPopoverConfigToken, { optional: true }) ?? defaultPopoverConfig;\n}\n","import { Directive } from '@angular/core';\nimport { setupOverlayArrow } from 'ng-primitives/portal';\n\n@Directive({\n selector: '[ngpPopoverArrow]',\n exportAs: 'ngpPopoverArrow',\n})\nexport class NgpPopoverArrow {\n constructor() {\n setupOverlayArrow();\n }\n}\n","import { InjectOptions, Signal } from '@angular/core';\nimport {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n State,\n} from 'ng-primitives/state';\nimport type { NgpPopoverTrigger } from './popover-trigger';\n\n/**\n * The state token for the PopoverTrigger primitive.\n */\nexport const NgpPopoverTriggerStateToken = createStateToken<NgpPopoverTrigger>('PopoverTrigger');\n\n/**\n * Provides the PopoverTrigger state.\n */\nexport const providePopoverTriggerState = createStateProvider(NgpPopoverTriggerStateToken);\n\n/**\n * Injects the PopoverTrigger state.\n */\nexport const injectPopoverTriggerState = createStateInjector<NgpPopoverTrigger>(\n NgpPopoverTriggerStateToken,\n) as <T>(options?: InjectOptions) => Signal<State<NgpPopoverTrigger<T>>>;\n\n/**\n * The PopoverTrigger state registration function.\n */\nexport const popoverTriggerState = createState(NgpPopoverTriggerStateToken);\n","import { FocusOrigin } from '@angular/cdk/a11y';\nimport { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n signal,\n ViewContainerRef,\n} from '@angular/core';\nimport { Placement } from '@floating-ui/dom';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport {\n createOverlay,\n NgpOverlay,\n NgpOverlayConfig,\n NgpOverlayContent,\n} from 'ng-primitives/portal';\nimport { injectPopoverConfig } from '../config/popover-config';\nimport { popoverTriggerState, providePopoverTriggerState } from './popover-trigger-state';\n\n/**\n * Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.\n */\n@Directive({\n selector: '[ngpPopoverTrigger]',\n exportAs: 'ngpPopoverTrigger',\n providers: [providePopoverTriggerState({ inherit: false })],\n host: {\n '[attr.aria-expanded]': 'open() ? \"true\" : \"false\"',\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-placement]': 'state.placement()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(click)': 'toggle($event)',\n },\n})\nexport class NgpPopoverTrigger<T = null> implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = injectElementRef();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the view container reference.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the global popover configuration.\n */\n private readonly config = injectPopoverConfig();\n\n /**\n * Access the popover template ref.\n */\n readonly popover = input<NgpOverlayContent<T>>(undefined, {\n alias: 'ngpPopoverTrigger',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpPopoverTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpPopoverTriggerPlacement',\n });\n\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpPopoverTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpPopoverTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpPopoverTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpPopoverTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the popover should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement | null>(this.config.container, {\n alias: 'ngpPopoverTriggerContainer',\n });\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n readonly closeOnOutsideClick = input<boolean, BooleanInput>(this.config.closeOnOutsideClick, {\n alias: 'ngpPopoverTriggerCloseOnOutsideClick',\n transform: booleanAttribute,\n });\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n readonly closeOnEscape = input<boolean, BooleanInput>(this.config.closeOnEscape, {\n alias: 'ngpPopoverTriggerCloseOnEscape',\n transform: booleanAttribute,\n });\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default 'reposition'\n */\n readonly scrollBehavior = input<'reposition' | 'block'>(this.config.scrollBehavior, {\n alias: 'ngpPopoverTriggerScrollBehavior',\n });\n\n /**\n * Provide context to the popover. This can be used to pass data to the popover content.\n */\n readonly context = input<T>(undefined, {\n alias: 'ngpPopoverTriggerContext',\n });\n\n /**\n * The overlay that manages the popover\n * @internal\n */\n readonly overlay = signal<NgpOverlay<T> | null>(null);\n\n /**\n * The open state of the popover.\n * @internal\n */\n readonly open = computed(() => this.overlay()?.isOpen() ?? false);\n\n /**\n * The popover trigger state.\n */\n readonly state = popoverTriggerState<NgpPopoverTrigger<T>>(this);\n\n ngOnDestroy(): void {\n this.overlay()?.destroy();\n }\n\n protected toggle(event: MouseEvent): void {\n // if the trigger is disabled then do not toggle the popover\n if (this.state.disabled()) {\n return;\n }\n\n // determine the origin of the event, 0 is keyboard, 1 is mouse\n const origin: FocusOrigin = event.detail === 0 ? 'keyboard' : 'mouse';\n\n // if the popover is open then hide it\n if (this.open()) {\n this.hide(origin);\n } else {\n this.show();\n }\n }\n\n /**\n * Show the popover.\n */\n show(): void {\n // If the trigger is disabled, don't show the popover\n if (this.state.disabled()) {\n return;\n }\n\n // Create the overlay if it doesn't exist yet\n if (!this.overlay()) {\n this.createOverlay();\n }\n\n // Show the overlay\n this.overlay()?.show();\n }\n\n /**\n * @internal\n * Hide the popover.\n */\n hide(origin: FocusOrigin = 'program'): void {\n // If the trigger is disabled or the popover is not open, do nothing\n if (this.state.disabled() || !this.open()) {\n return;\n }\n\n // Hide the overlay\n this.overlay()?.hide({ origin });\n }\n\n /**\n * Create the overlay that will contain the popover\n */\n private createOverlay(): void {\n const popover = this.state.popover();\n\n if (!popover) {\n throw new Error('Popover must be either a TemplateRef or a ComponentType');\n }\n\n // Create config for the overlay\n const config: NgpOverlayConfig<T> = {\n content: popover,\n triggerElement: this.trigger.nativeElement,\n injector: this.injector,\n context: this.state.context,\n container: this.state.container(),\n placement: this.state.placement(),\n offset: this.state.offset(),\n flip: this.state.flip(),\n showDelay: this.state.showDelay(),\n hideDelay: this.state.hideDelay(),\n closeOnOutsideClick: this.state.closeOnOutsideClick(),\n closeOnEscape: this.state.closeOnEscape(),\n restoreFocus: true,\n scrollBehaviour: this.state.scrollBehavior(),\n viewContainerRef: this.viewContainerRef,\n };\n\n this.overlay.set(createOverlay(config));\n }\n}\n","import { Directive } from '@angular/core';\nimport { NgpFocusTrap } from 'ng-primitives/focus-trap';\nimport { injectOverlay } from 'ng-primitives/portal';\n\n/**\n * Apply the `ngpPopover` directive to an element that represents the popover. This typically would be a `div` inside an `ng-template`.\n */\n@Directive({\n selector: '[ngpPopover]',\n exportAs: 'ngpPopover',\n hostDirectives: [NgpFocusTrap],\n host: {\n role: 'dialog',\n '[style.left.px]': 'overlay.position().x',\n '[style.top.px]': 'overlay.position().y',\n '[style.--ngp-popover-trigger-width.px]': 'overlay.triggerWidth()',\n '[style.--ngp-popover-transform-origin]': 'overlay.transformOrigin()',\n '[attr.data-placement]': 'overlay.finalPlacement()',\n },\n})\nexport class NgpPopover {\n /**\n * Access the overlay.\n */\n protected readonly overlay = injectOverlay();\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA2DO,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,SAAS,EAAE,QAAQ;AACnB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,mBAAmB,EAAE,IAAI;AACzB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,cAAc,EAAE,YAAY;CAC7B;AAEM,MAAM,qBAAqB,GA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EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAAV,UAAU,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,cAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,MAAA,EAAA,QAAA,EAAA,EAAA,UAAA,EAAA,EAAA,eAAA,EAAA,sBAAA,EAAA,cAAA,EAAA,sBAAA,EAAA,sCAAA,EAAA,wBAAA,EAAA,sCAAA,EAAA,2BAAA,EAAA,qBAAA,EAAA,0BAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,YAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAV,UAAU,EAAA,UAAA,EAAA,CAAA;kBAbtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;oBACtB,cAAc,EAAE,CAAC,YAAY,CAAC;AAC9B,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,QAAQ;AACd,wBAAA,iBAAiB,EAAE,sBAAsB;AACzC,wBAAA,gBAAgB,EAAE,sBAAsB;AACxC,wBAAA,wCAAwC,EAAE,wBAAwB;AAClE,wBAAA,wCAAwC,EAAE,2BAA2B;AACrE,wBAAA,uBAAuB,EAAE,0BAA0B;AACpD,qBAAA;AACF,iBAAA;;;ACnBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-popover.mjs","sources":["../../../../packages/ng-primitives/popover/src/config/popover-config.ts","../../../../packages/ng-primitives/popover/src/popover-arrow/popover-arrow.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger-state.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger.ts","../../../../packages/ng-primitives/popover/src/popover/popover.ts","../../../../packages/ng-primitives/popover/src/ng-primitives-popover.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpPopoverConfig {\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'bottom'\n */\n placement: Placement;\n\n /**\n * Define the delay before the popover is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the popover should be attached.\n * @default document.body\n */\n container: HTMLElement | null;\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n closeOnOutsideClick: boolean;\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n closeOnEscape: boolean;\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default scroll\n */\n scrollBehavior: 'reposition' | 'block';\n}\n\nexport const defaultPopoverConfig: NgpPopoverConfig = {\n offset: 4,\n placement: 'bottom',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: null,\n closeOnOutsideClick: true,\n closeOnEscape: true,\n scrollBehavior: 'reposition',\n};\n\nexport const NgpPopoverConfigToken = new InjectionToken<NgpPopoverConfig>('NgpPopoverConfigToken');\n\n/**\n * Provide the default Popover configuration\n * @param config The Popover configuration\n * @returns The provider\n */\nexport function providePopoverConfig(config: Partial<NgpPopoverConfig>): Provider[] {\n return [\n {\n provide: NgpPopoverConfigToken,\n useValue: { ...defaultPopoverConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Popover configuration\n * @returns The global Popover configuration\n */\nexport function injectPopoverConfig(): NgpPopoverConfig {\n return inject(NgpPopoverConfigToken, { optional: true }) ?? defaultPopoverConfig;\n}\n","import { Directive } from '@angular/core';\nimport { setupOverlayArrow } from 'ng-primitives/portal';\n\n@Directive({\n selector: '[ngpPopoverArrow]',\n exportAs: 'ngpPopoverArrow',\n})\nexport class NgpPopoverArrow {\n constructor() {\n setupOverlayArrow();\n }\n}\n","import { InjectOptions, Signal } from '@angular/core';\nimport {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n State,\n} from 'ng-primitives/state';\nimport type { NgpPopoverTrigger } from './popover-trigger';\n\n/**\n * The state token for the PopoverTrigger primitive.\n */\nexport const NgpPopoverTriggerStateToken = createStateToken<NgpPopoverTrigger>('PopoverTrigger');\n\n/**\n * Provides the PopoverTrigger state.\n */\nexport const providePopoverTriggerState = createStateProvider(NgpPopoverTriggerStateToken);\n\n/**\n * Injects the PopoverTrigger state.\n */\nexport const injectPopoverTriggerState = createStateInjector<NgpPopoverTrigger>(\n NgpPopoverTriggerStateToken,\n) as <T>(options?: InjectOptions) => Signal<State<NgpPopoverTrigger<T>>>;\n\n/**\n * The PopoverTrigger state registration function.\n */\nexport const popoverTriggerState = createState(NgpPopoverTriggerStateToken);\n","import { FocusOrigin } from '@angular/cdk/a11y';\nimport { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n output,\n signal,\n ViewContainerRef,\n} from '@angular/core';\nimport { Placement } from '@floating-ui/dom';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport {\n createOverlay,\n NgpOverlay,\n NgpOverlayConfig,\n NgpOverlayContent,\n} from 'ng-primitives/portal';\nimport { injectPopoverConfig } from '../config/popover-config';\nimport { popoverTriggerState, providePopoverTriggerState } from './popover-trigger-state';\n\n/**\n * Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.\n */\n@Directive({\n selector: '[ngpPopoverTrigger]',\n exportAs: 'ngpPopoverTrigger',\n providers: [providePopoverTriggerState({ inherit: false })],\n host: {\n '[attr.aria-expanded]': 'open() ? \"true\" : \"false\"',\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-placement]': 'state.placement()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(click)': 'toggle($event)',\n },\n})\nexport class NgpPopoverTrigger<T = null> implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = injectElementRef();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the view container reference.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the global popover configuration.\n */\n private readonly config = injectPopoverConfig();\n\n /**\n * Access the popover template ref.\n */\n readonly popover = input<NgpOverlayContent<T>>(undefined, {\n alias: 'ngpPopoverTrigger',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpPopoverTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpPopoverTriggerPlacement',\n });\n\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpPopoverTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpPopoverTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpPopoverTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpPopoverTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the popover should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement | null>(this.config.container, {\n alias: 'ngpPopoverTriggerContainer',\n });\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n readonly closeOnOutsideClick = input<boolean, BooleanInput>(this.config.closeOnOutsideClick, {\n alias: 'ngpPopoverTriggerCloseOnOutsideClick',\n transform: booleanAttribute,\n });\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n readonly closeOnEscape = input<boolean, BooleanInput>(this.config.closeOnEscape, {\n alias: 'ngpPopoverTriggerCloseOnEscape',\n transform: booleanAttribute,\n });\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default 'reposition'\n */\n readonly scrollBehavior = input<'reposition' | 'block'>(this.config.scrollBehavior, {\n alias: 'ngpPopoverTriggerScrollBehavior',\n });\n\n /**\n * Provide context to the popover. This can be used to pass data to the popover content.\n */\n readonly context = input<T>(undefined, {\n alias: 'ngpPopoverTriggerContext',\n });\n\n /**\n * The overlay that manages the popover\n * @internal\n */\n readonly overlay = signal<NgpOverlay<T> | null>(null);\n\n /**\n * The open state of the popover.\n * @internal\n */\n readonly open = computed(() => this.overlay()?.isOpen() ?? false);\n\n /**\n * Event emitted when the popover open state changes.\n */\n readonly openChange = output<boolean>({\n alias: 'ngpPopoverTriggerOpenChange',\n });\n\n /**\n * The popover trigger state.\n */\n readonly state = popoverTriggerState<NgpPopoverTrigger<T>>(this);\n\n ngOnDestroy(): void {\n this.overlay()?.destroy();\n }\n\n protected toggle(event: MouseEvent): void {\n // if the trigger is disabled then do not toggle the popover\n if (this.state.disabled()) {\n return;\n }\n\n // determine the origin of the event, 0 is keyboard, 1 is mouse\n const origin: FocusOrigin = event.detail === 0 ? 'keyboard' : 'mouse';\n\n // if the popover is open then hide it\n if (this.open()) {\n this.hide(origin);\n } else {\n this.show();\n }\n }\n\n /**\n * Show the popover.\n * @returns A promise that resolves when the popover has been shown\n */\n async show(): Promise<void> {\n // If the trigger is disabled, don't show the popover\n if (this.state.disabled()) {\n return;\n }\n\n // Create the overlay if it doesn't exist yet\n if (!this.overlay()) {\n this.createOverlay();\n }\n\n // Show the overlay\n await this.overlay()?.show();\n\n if (this.open()) {\n this.openChange.emit(true);\n }\n }\n\n /**\n * @internal\n * Hide the popover.\n * @returns A promise that resolves when the popover has been hidden\n */\n async hide(origin: FocusOrigin = 'program'): Promise<void> {\n // If the trigger is disabled or the popover is not open, do nothing\n if (this.state.disabled() || !this.open()) {\n return;\n }\n\n // Hide the overlay\n await this.overlay()?.hide({ origin });\n\n this.openChange.emit(false);\n }\n\n /**\n * Create the overlay that will contain the popover\n */\n private createOverlay(): void {\n const popover = this.state.popover();\n\n if (!popover) {\n throw new Error('Popover must be either a TemplateRef or a ComponentType');\n }\n\n // Create config for the overlay\n const config: NgpOverlayConfig<T> = {\n content: popover,\n triggerElement: this.trigger.nativeElement,\n injector: this.injector,\n context: this.state.context,\n container: this.state.container(),\n placement: this.state.placement(),\n offset: this.state.offset(),\n flip: this.state.flip(),\n showDelay: this.state.showDelay(),\n hideDelay: this.state.hideDelay(),\n closeOnOutsideClick: this.state.closeOnOutsideClick(),\n closeOnEscape: this.state.closeOnEscape(),\n restoreFocus: true,\n scrollBehaviour: this.state.scrollBehavior(),\n viewContainerRef: this.viewContainerRef,\n };\n\n this.overlay.set(createOverlay(config));\n }\n}\n","import { Directive } from '@angular/core';\nimport { NgpFocusTrap } from 'ng-primitives/focus-trap';\nimport { injectOverlay } from 'ng-primitives/portal';\n\n/**\n * Apply the `ngpPopover` directive to an element that represents the popover. This typically would be a `div` inside an `ng-template`.\n */\n@Directive({\n selector: '[ngpPopover]',\n exportAs: 'ngpPopover',\n hostDirectives: [NgpFocusTrap],\n host: {\n role: 'dialog',\n '[style.left.px]': 'overlay.position().x',\n '[style.top.px]': 'overlay.position().y',\n '[style.--ngp-popover-trigger-width.px]': 'overlay.triggerWidth()',\n '[style.--ngp-popover-transform-origin]': 'overlay.transformOrigin()',\n '[attr.data-placement]': 'overlay.finalPlacement()',\n },\n})\nexport class NgpPopover {\n /**\n * Access the overlay.\n */\n protected readonly overlay = injectOverlay();\n}\n","/**\n * Generated bund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