ng-primitives 0.43.1 → 0.45.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.
Files changed (63) hide show
  1. package/a11y/active-descendant/active-descendant.d.ts +38 -0
  2. package/a11y/index.d.ts +2 -1
  3. package/combobox/README.md +3 -0
  4. package/combobox/combobox/combobox-state.d.ts +60 -0
  5. package/combobox/combobox/combobox.d.ts +182 -0
  6. package/combobox/combobox-button/combobox-button.d.ts +61 -0
  7. package/combobox/combobox-dropdown/combobox-dropdown.d.ts +65 -0
  8. package/combobox/combobox-input/combobox-input.d.ts +79 -0
  9. package/combobox/combobox-option/combobox-option.d.ts +94 -0
  10. package/combobox/combobox-portal/combobox-portal.d.ts +35 -0
  11. package/combobox/index.d.ts +7 -0
  12. package/dialog/config/dialog-config.d.ts +2 -0
  13. package/dialog/dialog/dialog-ref.d.ts +2 -0
  14. package/dialog/dialog-trigger/dialog-trigger.d.ts +8 -1
  15. package/example-theme/index.css +1 -0
  16. package/fesm2022/ng-primitives-a11y.mjs +100 -1
  17. package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
  18. package/fesm2022/ng-primitives-combobox.mjs +783 -0
  19. package/fesm2022/ng-primitives-combobox.mjs.map +1 -0
  20. package/fesm2022/ng-primitives-dialog.mjs +19 -3
  21. package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
  22. package/fesm2022/ng-primitives-focus-trap.mjs +9 -1
  23. package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
  24. package/fesm2022/ng-primitives-listbox.mjs +1 -1
  25. package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
  26. package/fesm2022/ng-primitives-menu.mjs +372 -63
  27. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  28. package/fesm2022/ng-primitives-popover.mjs +62 -332
  29. package/fesm2022/ng-primitives-popover.mjs.map +1 -1
  30. package/fesm2022/ng-primitives-portal.mjs +359 -2
  31. package/fesm2022/ng-primitives-portal.mjs.map +1 -1
  32. package/fesm2022/ng-primitives-resize.mjs +21 -2
  33. package/fesm2022/ng-primitives-resize.mjs.map +1 -1
  34. package/fesm2022/ng-primitives-tooltip.mjs +51 -176
  35. package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
  36. package/focus-trap/focus-trap/focus-trap-state.d.ts +1 -0
  37. package/focus-trap/focus-trap/focus-trap.d.ts +5 -0
  38. package/menu/config/menu-config.d.ts +42 -0
  39. package/menu/index.d.ts +5 -1
  40. package/menu/menu/menu.d.ts +6 -2
  41. package/menu/menu-trigger/menu-trigger-state.d.ts +37 -0
  42. package/menu/menu-trigger/menu-trigger.d.ts +87 -13
  43. package/menu/submenu-trigger/submenu-trigger-state.d.ts +56 -0
  44. package/menu/submenu-trigger/submenu-trigger.d.ts +62 -10
  45. package/package.json +17 -13
  46. package/popover/index.d.ts +1 -2
  47. package/popover/popover/popover.d.ts +2 -43
  48. package/popover/popover-trigger/popover-trigger.d.ts +13 -107
  49. package/portal/index.d.ts +2 -0
  50. package/portal/overlay-token.d.ts +12 -0
  51. package/portal/overlay.d.ts +170 -0
  52. package/resize/index.d.ts +1 -1
  53. package/resize/utils/resize.d.ts +5 -0
  54. package/schematics/ng-generate/schema.d.ts +2 -1
  55. package/schematics/ng-generate/schema.json +1 -0
  56. package/schematics/ng-generate/templates/combobox/combobox.__fileSuffix@dasherize__.ts.template +264 -0
  57. package/schematics/ng-generate/templates/listbox/listbox.__fileSuffix@dasherize__.ts.template +2 -0
  58. package/tooltip/index.d.ts +1 -1
  59. package/tooltip/tooltip/tooltip.d.ts +3 -25
  60. package/tooltip/tooltip-trigger/tooltip-trigger.d.ts +12 -63
  61. package/popover/popover/popover-token.d.ts +0 -10
  62. package/popover/utils/transform-origin.d.ts +0 -2
  63. package/tooltip/tooltip/tooltip-token.d.ts +0 -10
@@ -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/popover-token.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/utils/transform-origin.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 { inject, InjectionToken, ValueProvider } from '@angular/core';\n\nexport const NgpPopoverContextToken = new InjectionToken<unknown>('NgpPopoverContextToken');\n\n/**\n * Inject the Popover context\n */\nexport function injectPopoverContext<T>(): T {\n return inject(NgpPopoverContextToken) as T;\n}\n\n/**\n * Provide the Popover context\n */\nexport function providePopoverContext<T>(context: T): ValueProvider {\n return { provide: NgpPopoverContextToken, useValue: context };\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 { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { BlockScrollStrategy, NoopScrollStrategy, ViewportRuler } from '@angular/cdk/overlay';\nimport { DOCUMENT } from '@angular/common';\nimport {\n booleanAttribute,\n computed,\n Directive,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n signal,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n autoUpdate,\n computePosition,\n flip,\n Middleware,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport {\n injectElementRef,\n injectExitAnimationManager,\n provideExitAnimationManager,\n} from 'ng-primitives/internal';\nimport { createPortal, NgpPortal } from 'ng-primitives/portal';\nimport { fromResizeEvent } from 'ng-primitives/resize';\nimport { injectDisposables } from 'ng-primitives/utils';\nimport { injectPopoverConfig } from '../config/popover-config';\nimport type { NgpPopover } from '../popover/popover';\nimport { providePopoverContext } from '../popover/popover-token';\nimport {\n injectPopoverTriggerState,\n popoverTriggerState,\n providePopoverTriggerState,\n} 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 }), provideExitAnimationManager()],\n host: {\n '[attr.aria-expanded]': 'open() ? \"true\" : \"false\"',\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-placement]': 'state.placement()',\n '(click)': 'toggleOpenState($event)',\n '(document:keydown.escape)': 'handleEscapeKey()',\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 exit animation state.\n */\n private readonly exitAnimationState = injectExitAnimationManager();\n\n /**\n * Inject the parent popover trigger if available.\n */\n private readonly parentTrigger = injectPopoverTriggerState<T>({\n skipSelf: true,\n optional: true,\n });\n\n /**\n * Access the view container ref.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Access the viewport ruler.\n */\n private readonly viewportRuler = inject(ViewportRuler);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the global popover configuration.\n */\n private readonly config = injectPopoverConfig();\n\n /**\n * Access the disposable utilities\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the popover template ref.\n */\n readonly popover = input<NgpPopoverContent<T> | null>(null, {\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.\n * @default null\n */\n readonly context = input<T | null>(null, {\n alias: 'ngpPopoverTriggerContext',\n });\n\n /**\n * Store the popover view ref.\n */\n protected readonly viewRef = signal<NgpPortal | undefined>(undefined);\n\n /**\n * Determines if the popover is open.\n */\n readonly open = computed(() => this.viewRef()?.getAttached() ?? false);\n\n /**\n * Derive the popover middleware from the provided configuration.\n */\n private readonly middleware = computed(() => {\n const middleware: Middleware[] = [offset(this.state.offset()), shift()];\n\n if (this.state.flip()) {\n middleware.push(flip());\n }\n\n return middleware;\n });\n\n /**\n * Store the computed position of the popover.\n * @internal\n */\n readonly position = signal<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n\n /**\n * @internal\n * Store the trigger width.\n */\n readonly width = signal<number | null>(null);\n\n /**\n * The dispose function to stop computing the position of the popover.\n */\n private dispose?: () => void;\n\n /**\n * A document-wide click listener that checks if the click\n * occurred outside of the popover and trigger elements.\n */\n private documentClickListener?: (event: MouseEvent) => void;\n\n /**\n * Store the popover instance.\n * @internal\n */\n private popoverInstance: NgpPopover | null = null;\n\n /**\n * Get the scroll strategy based on the configuration.\n */\n private readonly scrollStrategy = computed(() =>\n this.state.scrollBehavior() === 'block'\n ? new BlockScrollStrategy(this.viewportRuler, this.document)\n : new NoopScrollStrategy(),\n );\n\n /**\n * @internal\n * Register any child popover to the stack.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly stack: NgpPopoverTrigger<any>[] = [];\n\n /**\n * @internal\n * The timeout to open the popover.\n */\n private openTimeout?: () => void;\n\n /**\n * @internal\n * The timeout to close the popover.\n */\n private closeTimeout?: () => void;\n\n /**\n * The popover trigger state.\n */\n readonly state = popoverTriggerState<NgpPopoverTrigger<T>>(this);\n\n constructor() {\n // if the trigger has a parent trigger then register it to the stack\n this.parentTrigger()?.stack.push(this);\n\n // update the width of the trigger when it resizes\n fromResizeEvent(this.trigger.nativeElement)\n .pipe(takeUntilDestroyed())\n .subscribe(() => this.width.set(this.trigger.nativeElement.offsetWidth));\n }\n\n ngOnDestroy(): void {\n // remove the trigger from the parent trigger's stack\n this.parentTrigger()?.stack.splice(this.parentTrigger()?.stack.indexOf(this), 1);\n\n this.destroyPopover();\n }\n\n protected toggleOpenState(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(origin);\n }\n }\n\n /**\n * Show the popover.\n */\n show(origin: FocusOrigin): void {\n // if closing is in progress then clear the timeout to stop the popover from closing\n this.closeTimeout?.();\n\n // if the trigger is disabled or the popover is already open then do not show the popover\n if (this.state.disabled() || this.openTimeout) {\n return;\n }\n\n this.openTimeout = this.disposables.setTimeout(() => {\n this.openTimeout = undefined;\n this.createPopover(origin);\n }, this.state.showDelay());\n\n // Add document click listener to detect outside clicks\n if (this.state.closeOnOutsideClick()) {\n this.documentClickListener = this.onDocumentClick.bind(this);\n this.document.addEventListener('mouseup', this.documentClickListener, true);\n }\n }\n\n /**\n * @internal\n * Hide the popover.\n */\n hide(origin: FocusOrigin = 'program'): void {\n // if opening is in progress then clear the timeout to stop the popover from opening\n this.openTimeout?.();\n\n // if the trigger is disabled or the popover is not open then do not hide the popover\n if (this.state.disabled() || this.closeTimeout || !this.open()) {\n return;\n }\n\n // we must disable the focus trap before closing the popover, otherwise\n // focus will be moved back to the popover rather than the trigger\n this.popoverInstance?.disableFocusTrap();\n\n // close all child popovers\n for (const child of this.stack) {\n child.hide(origin);\n }\n\n // ensure the trigger is focused after closing the popover\n this.focusTrigger(origin);\n\n this.closeTimeout = this.disposables.setTimeout(async () => {\n this.closeTimeout = undefined;\n\n await this.destroyPopover();\n }, this.state.hideDelay());\n }\n\n private onDocumentClick(event: MouseEvent): void {\n const target = event.target as HTMLElement;\n\n const viewRef = this.viewRef();\n\n // get the popover element\n const popoverElement = viewRef?.getElements()[0] as HTMLElement | null;\n\n // Check if the click is outside the trigger or the popover\n const isOutside =\n !this.trigger.nativeElement.contains(target) && !popoverElement?.contains(target);\n\n // Determine if this is a click inside another popover\n\n if (isOutside) {\n // Close the popover\n this.hide('mouse');\n }\n }\n\n private createPopover(origin: FocusOrigin): void {\n // clear the open timeout\n this.openTimeout = undefined;\n\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 a new inject with the tooltip context\n const injector = Injector.create({\n parent: this.injector,\n providers: [providePopoverContext(this.state.context())],\n });\n\n const portal = createPortal(popover, this.viewContainerRef, injector, {\n $implicit: this.state.context(),\n } as NgpPopoverTemplateContext<T>);\n const viewRef = portal.attach(this.state.container() ?? this.document.body);\n\n this.viewRef.set(viewRef);\n viewRef.detectChanges();\n\n const outletElement = viewRef.getElements()[0] as HTMLElement | null;\n\n if (!outletElement) {\n throw new Error('Outlet element is not available.');\n }\n\n if (viewRef.getElements().length > 1) {\n throw new Error('Popover must have only one root element.');\n }\n\n // determine if the popover is fixed or absolute\n const strategy = getComputedStyle(outletElement).position === 'fixed' ? 'fixed' : 'absolute';\n\n this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {\n const position = await computePosition(this.trigger.nativeElement, outletElement, {\n placement: this.state.placement(),\n middleware: this.middleware(),\n strategy,\n });\n\n this.position.set({ x: position.x, y: position.y });\n viewRef?.detectChanges();\n });\n\n // activate the scroll strategy\n this.scrollStrategy().enable();\n\n // set the initial focus to the first tabbable element in the popover\n this.popoverInstance?.setInitialFocus(origin);\n }\n\n private async destroyPopover(): Promise<void> {\n // clear the close timeout\n this.closeTimeout = undefined;\n\n const viewRef = this.viewRef();\n\n if (!viewRef) {\n return;\n }\n\n // we remove this to prevent the popover from being destroyed twice\n // because ngOnDestroy will be called on the viewRef\n // when the popover is destroyed triggering this method again\n this.viewRef.set(undefined);\n\n // destroy the view ref\n viewRef.detach();\n\n this.dispose?.();\n\n // deactivate the scroll strategy\n this.scrollStrategy().disable();\n\n // Remove the document click listener when the popover is hidden\n if (this.documentClickListener) {\n this.document.removeEventListener('mouseup', this.documentClickListener, true);\n }\n }\n\n /**\n * @internal\n * Handle escape key press to close the popover.\n */\n protected handleEscapeKey(): void {\n if (this.state.closeOnEscape()) {\n this.hide('keyboard');\n }\n }\n\n private focusTrigger(origin: FocusOrigin): void {\n this.focusMonitor.focusVia(this.trigger.nativeElement, origin);\n }\n\n /**\n * Set the popover instance.\n * @internal\n */\n setPopover(instance: NgpPopover): void {\n this.popoverInstance = instance;\n }\n}\n\ntype NgpPopoverTemplateContext<T> = {\n $implicit: T;\n};\ntype NgpPopoverContent<T> = TemplateRef<NgpPopoverTemplateContext<T>> | Type<unknown>;\n","import type { Placement } from '@floating-ui/dom';\n\nexport function getTransformOrigin(placement: Placement): string {\n const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n const map: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n };\n\n let x = 'center';\n let y = 'center';\n\n if (basePlacement === 'top' || basePlacement === 'bottom') {\n y = map[basePlacement];\n if (alignment === 'start') x = 'left';\n else if (alignment === 'end') x = 'right';\n } else {\n x = map[basePlacement];\n if (alignment === 'start') y = 'top';\n else if (alignment === 'end') y = 'bottom';\n }\n\n return `${y} ${x}`;\n}\n","import { FocusMonitor, FocusOrigin, InteractivityChecker } from '@angular/cdk/a11y';\nimport { computed, Directive, inject } from '@angular/core';\nimport { injectFocusTrapState, NgpFocusTrap } from 'ng-primitives/focus-trap';\nimport { injectElementRef, NgpExitAnimation } from 'ng-primitives/internal';\nimport { injectPopoverTriggerState } from '../popover-trigger/popover-trigger-state';\nimport { getTransformOrigin } from '../utils/transform-origin';\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, NgpExitAnimation],\n host: {\n role: 'menu',\n '[style.left.px]': 'x()',\n '[style.top.px]': 'y()',\n '[style.--ngp-popover-trigger-width.px]': 'trigger().width()',\n '[style.--ngp-popover-transform-origin]': 'transformOrigin()',\n '(keydown.escape)': 'trigger().handleEscapeKey()',\n },\n})\nexport class NgpPopover {\n /**\n * Access the popover element.\n */\n private readonly popover = injectElementRef();\n\n /**\n * Access the focus trap.\n */\n private readonly focusTrap = injectFocusTrapState();\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivity = inject(InteractivityChecker);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the trigger instance.\n */\n protected readonly trigger = injectPopoverTriggerState();\n\n /**\n * Compute the x position of the popover.\n */\n protected readonly x = computed(() => this.trigger().position().x);\n\n /**\n * Compute the y position of the popover.\n */\n protected readonly y = computed(() => this.trigger().position().y);\n\n /**\n * Derive the transform origin of the popover.\n */\n protected readonly transformOrigin = computed(() =>\n getTransformOrigin(this.trigger().placement()),\n );\n\n constructor() {\n this.trigger().setPopover(this);\n }\n\n /**\n * Focus the first tabbable element inside the popover.\n * If no tabbable element is found, focus the popover itself.\n * @internal\n */\n setInitialFocus(origin: FocusOrigin): void {\n // use a tree walker to find the first tabbable child\n const treeWalker = document.createTreeWalker(\n this.popover.nativeElement,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode: node =>\n node instanceof HTMLElement && this.interactivity.isTabbable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n },\n );\n\n const tabbableNode = treeWalker.nextNode() as HTMLElement | null;\n\n if (tabbableNode) {\n this.focusMonitor.focusVia(tabbableNode, origin);\n } else {\n // if no tabbable child is found, focus the popover element itself\n this.popover.nativeElement.focus();\n }\n }\n\n /**\n * Disable the focus trap.\n * @internal\n */\n disableFocusTrap(): void {\n this.focusTrap().disabled.set(true);\n }\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,GAAG,IAAI,cAAc,CAAmB,uBAAuB,CAAC;AAElG;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAAiC,EAAA;IACpE,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,EAAE;AACjD,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,mBAAmB,GAAA;AACjC,IAAA,OAAO,MAAM,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,oBAAoB;AAClF;;MC3Fa,sBAAsB,GAAG,IAAI,cAAc,CAAU,wBAAwB;AAE1F;;AAEG;SACa,oBAAoB,GAAA;AAClC,IAAA,OAAO,MAAM,CAAC,sBAAsB,CAAM;AAC5C;AAEA;;AAEG;AACG,SAAU,qBAAqB,CAAI,OAAU,EAAA;IACjD,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC/D;;ACNA;;AAEG;AACI,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CAAC,IAAI,CAAC;;+GAhF1B,UAAU,EAAA,IAAA,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,MAAA,EAAA,EAAA,SAAA,EAAA,EAAA,gBAAA,EAAA,6BAAA,EAAA,EAAA,UAAA,EAAA,EAAA,eAAA,EAAA,KAAA,EAAA,cAAA,EAAA,KAAA,EAAA,sCAAA,EAAA,mBAAA,EAAA,sCAAA,EAAA,mBAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,YAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,YAAA,EAAA,EAAA,EAAA,SAAA,EAAA,EAAA,CAAA,gBAAA,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;AACtB,oBAAA,cAAc,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC;AAChD,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,MAAM;AACZ,wBAAA,iBAAiB,EAAE,KAAK;AACxB,wBAAA,gBAAgB,EAAE,KAAK;AACvB,wBAAA,wCAAwC,EAAE,mBAAmB;AAC7D,wBAAA,wCAAwC,EAAE,mBAAmB;AAC7D,wBAAA,kBAAkB,EAAE,6BAA6B;AAClD,qBAAA;AACF,iBAAA;;;ACtBD;;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-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 { 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} from '@angular/core';\nimport { Placement } from '@floating-ui/dom';\nimport { injectElementRef, provideExitAnimationManager } 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 }), provideExitAnimationManager()],\n host: {\n '[attr.aria-expanded]': 'open() ? \"true\" : \"false\"',\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-placement]': 'state.placement()',\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 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 };\n\n this.overlay.set(createOverlay(config));\n }\n}\n","import { Directive } from '@angular/core';\nimport { NgpFocusTrap } from 'ng-primitives/focus-trap';\nimport { NgpExitAnimation } from 'ng-primitives/internal';\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, NgpExitAnimation],\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 },\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,q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AAV,UAAU,EAAA,UAAA,EAAA,CAAA;kBAZtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,cAAc,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC;AAChD,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;AACtE,qBAAA;AACF,iBAAA;;;ACnBD;;AAEG;;;;"}
@@ -1,7 +1,32 @@
1
+ import { FocusMonitor } from '@angular/cdk/a11y';
2
+ import { ViewportRuler, NoopScrollStrategy, BlockScrollStrategy } from '@angular/cdk/overlay';
3
+ import { DOCUMENT } from '@angular/common';
4
+ import { InjectionToken, inject, TemplateRef, DestroyRef, ViewContainerRef, signal, Injector, runInInjectionContext } from '@angular/core';
5
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
+ import { autoUpdate, offset, shift, flip, computePosition } from '@floating-ui/dom';
7
+ import { fromResizeEvent } from 'ng-primitives/resize';
8
+ import { injectDisposables } from 'ng-primitives/utils';
9
+ import { Subject, fromEvent } from 'rxjs';
1
10
  import { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';
2
- import { TemplateRef } from '@angular/core';
3
11
  import { NgpExitAnimationManager } from 'ng-primitives/internal';
4
12
 
13
+ const NgpOverlayContextToken = new InjectionToken('NgpOverlayContextToken');
14
+ /**
15
+ * Injects the context for the overlay.
16
+ * @internal
17
+ */
18
+ function injectOverlayContext() {
19
+ return inject(NgpOverlayContextToken);
20
+ }
21
+ /**
22
+ * Provides the context for the overlay.
23
+ * @param value The value to provide as the context.
24
+ * @internal
25
+ */
26
+ function provideOverlayContext(value) {
27
+ return { provide: NgpOverlayContextToken, useValue: value };
28
+ }
29
+
5
30
  class NgpPortal {
6
31
  constructor(viewContainerRef, injector) {
7
32
  this.viewContainerRef = viewContainerRef;
@@ -123,9 +148,341 @@ function createPortal(componentOrTemplate, viewContainerRef, injector, context)
123
148
  }
124
149
  }
125
150
 
151
+ /**
152
+ * NgpOverlay manages the lifecycle and positioning of overlay UI elements.
153
+ * It abstracts the common behavior shared by tooltips, popovers, menus, etc.
154
+ * @internal
155
+ */
156
+ class NgpOverlay {
157
+ /**
158
+ * Creates a new overlay instance
159
+ * @param config Initial configuration for the overlay
160
+ * @param destroyRef Reference for automatic cleanup
161
+ */
162
+ constructor(config) {
163
+ this.config = config;
164
+ this.disposables = injectDisposables();
165
+ this.document = inject(DOCUMENT);
166
+ this.destroyRef = inject(DestroyRef);
167
+ this.viewContainerRef = inject(ViewContainerRef);
168
+ this.viewportRuler = inject(ViewportRuler);
169
+ this.focusMonitor = inject(FocusMonitor);
170
+ /** Access any parent overlays */
171
+ this.parentOverlay = inject(NgpOverlay, { optional: true });
172
+ /** Signal tracking the portal instance */
173
+ this.portal = signal(null);
174
+ /** Signal tracking the overlay position */
175
+ this.position = signal({ x: 0, y: 0 });
176
+ /** Signal tracking the trigger element width */
177
+ this.triggerWidth = signal(null);
178
+ /** The transform origin for the overlay */
179
+ this.transformOrigin = signal('center center');
180
+ /** Signal tracking whether the overlay is open */
181
+ this.isOpen = signal(false);
182
+ /** The scroll strategy */
183
+ this.scrollStrategy = new NoopScrollStrategy();
184
+ /** An observable that emits when the overlay is closing */
185
+ this.closing = new Subject();
186
+ // this must be done after the config is set
187
+ this.transformOrigin.set(this.getTransformOrigin());
188
+ // Monitor trigger element resize
189
+ fromResizeEvent(this.config.triggerElement)
190
+ .pipe(takeUntilDestroyed(this.destroyRef))
191
+ .subscribe(() => {
192
+ this.triggerWidth.set(this.config.triggerElement.offsetWidth);
193
+ });
194
+ // if there is a parent overlay and it is closed, close this overlay
195
+ this.parentOverlay?.closing.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
196
+ if (this.isOpen()) {
197
+ this.hideImmediate();
198
+ }
199
+ });
200
+ // If closeOnOutsideClick is enabled, set up a click listener
201
+ fromEvent(this.document, 'mouseup', { capture: true })
202
+ .pipe(takeUntilDestroyed(this.destroyRef))
203
+ .subscribe(event => {
204
+ if (!this.config.closeOnOutsideClick) {
205
+ return;
206
+ }
207
+ const overlay = this.portal();
208
+ if (!overlay || !this.isOpen()) {
209
+ return;
210
+ }
211
+ const path = event.composedPath();
212
+ const isInsideOverlay = overlay.getElements().some(el => path.includes(el));
213
+ const isInsideTrigger = path.includes(this.config.triggerElement);
214
+ if (!isInsideOverlay && !isInsideTrigger) {
215
+ this.hide();
216
+ }
217
+ });
218
+ // If closeOnEscape is enabled, set up a keydown listener
219
+ fromEvent(this.document, 'keydown', { capture: true })
220
+ .pipe(takeUntilDestroyed(this.destroyRef))
221
+ .subscribe(event => {
222
+ if (!this.config.closeOnEscape)
223
+ return;
224
+ if (event.key === 'Escape' && this.isOpen()) {
225
+ this.hide({ origin: 'keyboard', immediate: true });
226
+ }
227
+ });
228
+ // Ensure cleanup on destroy
229
+ this.destroyRef.onDestroy(() => this.destroy());
230
+ }
231
+ /**
232
+ * Show the overlay with the specified delay
233
+ * @param showDelay Optional delay to override the configured showDelay
234
+ */
235
+ show() {
236
+ return new Promise(resolve => {
237
+ // If closing is in progress, cancel it
238
+ if (this.closeTimeout) {
239
+ this.closeTimeout();
240
+ this.closeTimeout = undefined;
241
+ }
242
+ // Don't proceed if already opening or open
243
+ if (this.openTimeout || this.isOpen()) {
244
+ return;
245
+ }
246
+ // Use the provided delay or fall back to config
247
+ const delay = this.config.showDelay ?? 0;
248
+ this.openTimeout = this.disposables.setTimeout(() => {
249
+ this.openTimeout = undefined;
250
+ this.createOverlay();
251
+ resolve();
252
+ }, delay);
253
+ });
254
+ }
255
+ /**
256
+ * Hide the overlay with the specified delay
257
+ * @param options Optional options for hiding the overlay
258
+ */
259
+ hide(options) {
260
+ // If opening is in progress, cancel it
261
+ if (this.openTimeout) {
262
+ this.openTimeout();
263
+ this.openTimeout = undefined;
264
+ }
265
+ // Don't proceed if already closing or closed
266
+ if (this.closeTimeout || !this.isOpen()) {
267
+ return;
268
+ }
269
+ this.closing.next();
270
+ // Use the provided delay or fall back to config
271
+ const delay = options?.immediate ? 0 : (this.config.hideDelay ?? 0);
272
+ this.closeTimeout = this.disposables.setTimeout(async () => {
273
+ this.closeTimeout = undefined;
274
+ if (this.config.restoreFocus) {
275
+ this.focusMonitor.focusVia(this.config.triggerElement, options?.origin ?? 'program');
276
+ }
277
+ await this.destroyOverlay();
278
+ }, delay);
279
+ }
280
+ /**
281
+ * Update the configuration of this overlay
282
+ * @param config New configuration (partial)
283
+ */
284
+ updateConfig(config) {
285
+ this.config = { ...this.config, ...config };
286
+ // If the overlay is already open, update its position
287
+ if (this.isOpen()) {
288
+ this.updatePosition();
289
+ }
290
+ }
291
+ /**
292
+ * Immediately hide the overlay without any delay
293
+ */
294
+ hideImmediate() {
295
+ this.hide({ immediate: true });
296
+ }
297
+ /**
298
+ * Toggle the overlay open/closed state
299
+ */
300
+ toggle() {
301
+ if (this.isOpen()) {
302
+ this.hide();
303
+ }
304
+ else {
305
+ this.show();
306
+ }
307
+ }
308
+ /**
309
+ * Force update the position of the overlay
310
+ */
311
+ updatePosition() {
312
+ const portal = this.portal();
313
+ if (!portal) {
314
+ return;
315
+ }
316
+ const elements = portal.getElements();
317
+ if (elements.length === 0) {
318
+ return;
319
+ }
320
+ const overlayElement = elements[0];
321
+ // Compute new position
322
+ this.computePosition(overlayElement);
323
+ }
324
+ /**
325
+ * Completely destroy this overlay instance
326
+ */
327
+ destroy() {
328
+ this.hideImmediate();
329
+ this.disposePositioning?.();
330
+ this.scrollStrategy.disable();
331
+ }
332
+ /**
333
+ * Get the elements of the overlay
334
+ */
335
+ getElements() {
336
+ return this.portal()?.getElements() ?? [];
337
+ }
338
+ /**
339
+ * Internal method to create the overlay
340
+ */
341
+ createOverlay() {
342
+ if (!this.config.content) {
343
+ throw new Error('Overlay content must be provided');
344
+ }
345
+ // Create a new portal with context
346
+ const portal = createPortal(this.config.content, this.viewContainerRef, Injector.create({
347
+ parent: this.config.injector,
348
+ providers: [
349
+ ...(this.config.providers || []),
350
+ { provide: NgpOverlay, useValue: this },
351
+ provideOverlayContext(this.config.context),
352
+ ],
353
+ }), { $implicit: this.config.context });
354
+ // Attach portal to container
355
+ const container = this.config.container || this.document.body;
356
+ portal.attach(container);
357
+ // Update portal signal
358
+ this.portal.set(portal);
359
+ // Ensure view is up to date
360
+ portal.detectChanges();
361
+ const outletElement = portal.getElements()[0];
362
+ if (!outletElement) {
363
+ throw new Error('Overlay element is not available.');
364
+ }
365
+ if (portal.getElements().length > 1) {
366
+ throw new Error('Overlay must have only one root element.');
367
+ }
368
+ // Set up positioning
369
+ this.setupPositioning(outletElement);
370
+ // Mark as open
371
+ this.isOpen.set(true);
372
+ this.scrollStrategy =
373
+ this.config.scrollBehaviour === 'block'
374
+ ? new BlockScrollStrategy(this.viewportRuler, this.document)
375
+ : new NoopScrollStrategy();
376
+ this.scrollStrategy.enable();
377
+ }
378
+ /**
379
+ * Internal method to setup positioning of the overlay
380
+ */
381
+ setupPositioning(overlayElement) {
382
+ // Determine positioning strategy based on overlay element's CSS
383
+ const strategy = getComputedStyle(overlayElement).position === 'fixed'
384
+ ? 'fixed'
385
+ : this.config.strategy || 'absolute';
386
+ // Setup auto-update for positioning
387
+ this.disposePositioning = autoUpdate(this.config.triggerElement, overlayElement, () => this.computePosition(overlayElement, strategy));
388
+ }
389
+ /**
390
+ * Compute the overlay position using floating-ui
391
+ */
392
+ async computePosition(overlayElement, strategy = 'absolute') {
393
+ // Create middleware array
394
+ const middleware = [offset(this.config.offset || 0), shift()];
395
+ // Add flip middleware if requested
396
+ if (this.config.flip !== false) {
397
+ middleware.push(flip());
398
+ }
399
+ // Add any additional middleware
400
+ if (this.config.additionalMiddleware) {
401
+ middleware.push(...this.config.additionalMiddleware);
402
+ }
403
+ // Compute the position
404
+ const position = await computePosition(this.config.triggerElement, overlayElement, {
405
+ placement: this.config.placement || 'top',
406
+ middleware,
407
+ strategy,
408
+ });
409
+ // Update position signal
410
+ this.position.set({ x: position.x, y: position.y });
411
+ // Ensure view is updated
412
+ this.portal()?.detectChanges();
413
+ }
414
+ /**
415
+ * Internal method to destroy the overlay portal
416
+ */
417
+ async destroyOverlay() {
418
+ const portal = this.portal();
419
+ if (!portal) {
420
+ return;
421
+ }
422
+ // Clear portal reference to prevent double destruction
423
+ this.portal.set(null);
424
+ // Clean up positioning
425
+ this.disposePositioning?.();
426
+ this.disposePositioning = undefined;
427
+ // Detach the portal
428
+ await portal.detach();
429
+ // Mark as closed
430
+ this.isOpen.set(false);
431
+ // disable scroll strategy
432
+ this.scrollStrategy.disable();
433
+ this.scrollStrategy = new NoopScrollStrategy();
434
+ }
435
+ /**
436
+ * Get the transform origin for the overlay
437
+ */
438
+ getTransformOrigin() {
439
+ const placement = this.config.placement ?? 'top';
440
+ const basePlacement = placement.split('-')[0]; // Extract "top", "bottom", etc.
441
+ const alignment = placement.split('-')[1]; // Extract "start" or "end"
442
+ const map = {
443
+ top: 'bottom',
444
+ bottom: 'top',
445
+ left: 'right',
446
+ right: 'left',
447
+ };
448
+ let x = 'center';
449
+ let y = 'center';
450
+ if (basePlacement === 'top' || basePlacement === 'bottom') {
451
+ y = map[basePlacement];
452
+ if (alignment === 'start')
453
+ x = 'left';
454
+ else if (alignment === 'end')
455
+ x = 'right';
456
+ }
457
+ else {
458
+ x = map[basePlacement];
459
+ if (alignment === 'start')
460
+ y = 'top';
461
+ else if (alignment === 'end')
462
+ y = 'bottom';
463
+ }
464
+ return `${y} ${x}`;
465
+ }
466
+ }
467
+ /**
468
+ * Helper function to create an overlay in a single call
469
+ * @internal
470
+ */
471
+ function createOverlay(config) {
472
+ // we run the overlay creation in the injector context to ensure that it can call the inject function
473
+ return runInInjectionContext(config.injector, () => new NgpOverlay(config));
474
+ }
475
+ /**
476
+ * Helper function to inject the NgpOverlay instance
477
+ * @internal
478
+ */
479
+ function injectOverlay() {
480
+ return inject(NgpOverlay);
481
+ }
482
+
126
483
  /**
127
484
  * Generated bundle index. Do not edit.
128
485
  */
129
486
 
130
- export { NgpComponentPortal, NgpPortal, NgpTemplatePortal, createPortal };
487
+ export { NgpComponentPortal, NgpOverlay, NgpPortal, NgpTemplatePortal, createOverlay, createPortal, injectOverlay, injectOverlayContext, provideOverlayContext };
131
488
  //# sourceMappingURL=ng-primitives-portal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-portal.mjs","sources":["../../../../packages/ng-primitives/portal/src/portal.ts","../../../../packages/ng-primitives/portal/src/ng-primitives-portal.ts"],"sourcesContent":["import { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n ComponentRef,\n EmbeddedViewRef,\n Injector,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { NgpExitAnimationManager } from 'ng-primitives/internal';\n\nexport abstract class NgpPortal {\n constructor(\n protected readonly viewContainerRef: ViewContainerRef,\n protected readonly injector: Injector,\n ) {}\n\n /**\n * Get the elements of the portal.\n */\n abstract getElements(): HTMLElement[];\n\n /**\n * Detect changes in the portal.\n */\n abstract detectChanges(): void;\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n abstract getAttached(): boolean;\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n abstract attach(container: HTMLElement): this;\n\n /**\n * Detach the portal from the DOM.\n */\n abstract detach(): Promise<void>;\n}\n\nexport class NgpComponentPortal<T> extends NgpPortal {\n private readonly componentPortal: ComponentPortal<T>;\n private viewRef: ComponentRef<T> | null = null;\n private isDestroying = false;\n\n constructor(component: Type<T>, viewContainerRef: ViewContainerRef, injector: Injector) {\n super(viewContainerRef, injector);\n this.componentPortal = new ComponentPortal(component, viewContainerRef, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(container, undefined, undefined, this.injector);\n this.viewRef = domOutlet.attach(this.componentPortal);\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? [this.viewRef.location.nativeElement] : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.changeDetectorRef.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && (this.viewRef.location.nativeElement as HTMLElement).isConnected;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n const exitAnimationManager = this.injector.get(NgpExitAnimationManager, null, {\n optional: true,\n });\n\n await exitAnimationManager?.exit();\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport class NgpTemplatePortal<T> extends NgpPortal {\n private readonly templatePortal: TemplatePortal<T>;\n private viewRef: EmbeddedViewRef<T> | null = null;\n private isDestroying = false;\n\n constructor(\n template: TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n ) {\n super(viewContainerRef, injector);\n this.templatePortal = new TemplatePortal(template, viewContainerRef, context, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(container, undefined, undefined, this.injector);\n this.viewRef = domOutlet.attach(this.templatePortal);\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? this.viewRef.rootNodes : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && this.viewRef.rootNodes.length > 0;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n const exitAnimationManager = this.injector.get(NgpExitAnimationManager, null, {\n optional: true,\n });\n\n await exitAnimationManager?.exit();\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport function createPortal<T>(\n componentOrTemplate: Type<T> | TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n): NgpPortal {\n if (componentOrTemplate instanceof TemplateRef) {\n return new NgpTemplatePortal(componentOrTemplate, viewContainerRef, injector, context);\n } else {\n return new NgpComponentPortal(componentOrTemplate, viewContainerRef, injector);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAWsB,SAAS,CAAA;IAC7B,WACqB,CAAA,gBAAkC,EAClC,QAAkB,EAAA;QADlB,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB;QAChB,IAAQ,CAAA,QAAA,GAAR,QAAQ;;AA4B9B;AAEK,MAAO,kBAAsB,SAAQ,SAAS,CAAA;AAKlD,IAAA,WAAA,CAAY,SAAkB,EAAE,gBAAkC,EAAE,QAAkB,EAAA;AACpF,QAAA,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC;QAJ3B,IAAO,CAAA,OAAA,GAA2B,IAAI;QACtC,IAAY,CAAA,YAAA,GAAG,KAAK;AAI1B,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,CAAC;;AAGnF;;;AAGG;AACH,IAAA,MAAM,CAAC,SAAsB,EAAA;AAC3B,QAAA,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;QACrF,IAAI,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AE;QAC9C,OAAO,IAAI,iBAAiB,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,CAAC;;SACjF;QACL,OAAO,IAAI,kBAAkB,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,QAAQ,CAAC;;AAElF;;AC7LA;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-portal.mjs","sources":["../../../../packages/ng-primitives/portal/src/overlay-token.ts","../../../../packages/ng-primitives/portal/src/portal.ts","../../../../packages/ng-primitives/portal/src/overlay.ts","../../../../packages/ng-primitives/portal/src/ng-primitives-portal.ts"],"sourcesContent":["import { inject, InjectionToken, ValueProvider } from '@angular/core';\n\nconst NgpOverlayContextToken = new InjectionToken<unknown>('NgpOverlayContextToken');\n\n/**\n * Injects the context for the overlay.\n * @internal\n */\nexport function injectOverlayContext<T>(): T {\n return inject(NgpOverlayContextToken) as T;\n}\n\n/**\n * Provides the context for the overlay.\n * @param value The value to provide as the context.\n * @internal\n */\nexport function provideOverlayContext<T>(value: T): ValueProvider {\n return { provide: NgpOverlayContextToken, useValue: value };\n}\n","import { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n ComponentRef,\n EmbeddedViewRef,\n Injector,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { NgpExitAnimationManager } from 'ng-primitives/internal';\n\nexport abstract class NgpPortal {\n constructor(\n protected readonly viewContainerRef: ViewContainerRef,\n protected readonly injector: Injector,\n ) {}\n\n /**\n * Get the elements of the portal.\n */\n abstract getElements(): HTMLElement[];\n\n /**\n * Detect changes in the portal.\n */\n abstract detectChanges(): void;\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n abstract getAttached(): boolean;\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n abstract attach(container: HTMLElement): this;\n\n /**\n * Detach the portal from the DOM.\n */\n abstract detach(): Promise<void>;\n}\n\nexport class NgpComponentPortal<T> extends NgpPortal {\n private readonly componentPortal: ComponentPortal<T>;\n private viewRef: ComponentRef<T> | null = null;\n private isDestroying = false;\n\n constructor(component: Type<T>, viewContainerRef: ViewContainerRef, injector: Injector) {\n super(viewContainerRef, injector);\n this.componentPortal = new ComponentPortal(component, viewContainerRef, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(container, undefined, undefined, this.injector);\n this.viewRef = domOutlet.attach(this.componentPortal);\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? [this.viewRef.location.nativeElement] : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.changeDetectorRef.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && (this.viewRef.location.nativeElement as HTMLElement).isConnected;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n const exitAnimationManager = this.injector.get(NgpExitAnimationManager, null, {\n optional: true,\n });\n\n await exitAnimationManager?.exit();\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport class NgpTemplatePortal<T> extends NgpPortal {\n private readonly templatePortal: TemplatePortal<T>;\n private viewRef: EmbeddedViewRef<T> | null = null;\n private isDestroying = false;\n\n constructor(\n template: TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n ) {\n super(viewContainerRef, injector);\n this.templatePortal = new TemplatePortal(template, viewContainerRef, context, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(container, undefined, undefined, this.injector);\n this.viewRef = domOutlet.attach(this.templatePortal);\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? this.viewRef.rootNodes : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && this.viewRef.rootNodes.length > 0;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n const exitAnimationManager = this.injector.get(NgpExitAnimationManager, null, {\n optional: true,\n });\n\n await exitAnimationManager?.exit();\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport function createPortal<T>(\n componentOrTemplate: Type<T> | TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n): NgpPortal {\n if (componentOrTemplate instanceof TemplateRef) {\n return new NgpTemplatePortal(componentOrTemplate, viewContainerRef, injector, context);\n } else {\n return new NgpComponentPortal(componentOrTemplate, viewContainerRef, injector);\n }\n}\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { BlockScrollStrategy, NoopScrollStrategy, ViewportRuler } from '@angular/cdk/overlay';\nimport { DOCUMENT } from '@angular/common';\nimport {\n DestroyRef,\n Injector,\n Provider,\n TemplateRef,\n Type,\n ViewContainerRef,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n Middleware,\n Placement,\n Strategy,\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n} from '@floating-ui/dom';\nimport { fromResizeEvent } from 'ng-primitives/resize';\nimport { injectDisposables } from 'ng-primitives/utils';\nimport { Subject, fromEvent } from 'rxjs';\nimport { provideOverlayContext } from './overlay-token';\nimport { NgpPortal, createPortal } from './portal';\n\n/**\n * Configuration options for creating an overlay\n * @internal\n */\nexport interface NgpOverlayConfig<T = unknown> {\n /** Content to display in the overlay (component or template) */\n content: NgpOverlayContent<T>;\n\n /** The element that triggers the overlay */\n triggerElement: HTMLElement;\n\n /** The injector to use for creating the portal */\n injector: Injector;\n\n /** Context data to pass to the overlay content */\n context?: T | null;\n\n /** Container element to attach the overlay to (defaults to document.body) */\n container?: HTMLElement | null;\n\n /** Preferred placement of the overlay relative to the trigger */\n placement?: Placement;\n\n /** Offset distance between the overlay and trigger in pixels */\n offset?: number;\n\n /** Whether to enable flip behavior when space is limited */\n flip?: boolean;\n\n /** Delay before showing the overlay in milliseconds */\n showDelay?: number;\n\n /** Delay before hiding the overlay in milliseconds */\n hideDelay?: number;\n\n /** Whether the overlay should be positioned with fixed or absolute strategy */\n strategy?: Strategy;\n\n /** The scroll strategy to use for the overlay */\n scrollBehaviour?: 'reposition' | 'block';\n /** Whether to close the overlay when clicking outside */\n closeOnOutsideClick?: boolean;\n /** Whether to close the overlay when pressing escape */\n closeOnEscape?: boolean;\n /** Whether to restore focus to the trigger element when hiding the overlay */\n restoreFocus?: boolean;\n /** Additional middleware for floating UI positioning */\n additionalMiddleware?: Middleware[];\n\n /** Additional providers */\n providers?: Provider[];\n}\n\n/** Type for overlay content which can be either a template or component */\nexport type NgpOverlayContent<T> = TemplateRef<NgpOverlayTemplateContext<T>> | Type<unknown>;\n\n/** Context for template-based overlays */\nexport type NgpOverlayTemplateContext<T> = {\n $implicit: T;\n};\n\n/**\n * NgpOverlay manages the lifecycle and positioning of overlay UI elements.\n * It abstracts the common behavior shared by tooltips, popovers, menus, etc.\n * @internal\n */\nexport class NgpOverlay<T = unknown> {\n private readonly disposables = injectDisposables();\n private readonly document = inject(DOCUMENT);\n private readonly destroyRef = inject(DestroyRef);\n private readonly viewContainerRef = inject(ViewContainerRef);\n private readonly viewportRuler = inject(ViewportRuler);\n private readonly focusMonitor = inject(FocusMonitor);\n /** Access any parent overlays */\n private readonly parentOverlay = inject(NgpOverlay, { optional: true });\n /** Signal tracking the portal instance */\n private readonly portal = signal<NgpPortal | null>(null);\n\n /** Signal tracking the overlay position */\n readonly position = signal<{ x: number; y: number }>({ x: 0, y: 0 });\n\n /** Signal tracking the trigger element width */\n readonly triggerWidth = signal<number | null>(null);\n\n /** The transform origin for the overlay */\n readonly transformOrigin = signal<string>('center center');\n\n /** Function to dispose the positioning auto-update */\n private disposePositioning?: () => void;\n\n /** Timeout handle for showing the overlay */\n private openTimeout?: () => void;\n\n /** Timeout handle for hiding the overlay */\n private closeTimeout?: () => void;\n\n /** Signal tracking whether the overlay is open */\n readonly isOpen = signal(false);\n\n /** The scroll strategy */\n private scrollStrategy = new NoopScrollStrategy();\n\n /** An observable that emits when the overlay is closing */\n readonly closing = new Subject<void>();\n\n /**\n * Creates a new overlay instance\n * @param config Initial configuration for the overlay\n * @param destroyRef Reference for automatic cleanup\n */\n constructor(private config: NgpOverlayConfig<T>) {\n // this must be done after the config is set\n this.transformOrigin.set(this.getTransformOrigin());\n\n // Monitor trigger element resize\n fromResizeEvent(this.config.triggerElement)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => {\n this.triggerWidth.set(this.config.triggerElement.offsetWidth);\n });\n\n // if there is a parent overlay and it is closed, close this overlay\n this.parentOverlay?.closing.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n if (this.isOpen()) {\n this.hideImmediate();\n }\n });\n\n // If closeOnOutsideClick is enabled, set up a click listener\n fromEvent<MouseEvent>(this.document, 'mouseup', { capture: true })\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (!this.config.closeOnOutsideClick) {\n return;\n }\n\n const overlay = this.portal();\n\n if (!overlay || !this.isOpen()) {\n return;\n }\n\n const path = event.composedPath();\n const isInsideOverlay = overlay.getElements().some(el => path.includes(el));\n const isInsideTrigger = path.includes(this.config.triggerElement);\n\n if (!isInsideOverlay && !isInsideTrigger) {\n this.hide();\n }\n });\n\n // If closeOnEscape is enabled, set up a keydown listener\n fromEvent<KeyboardEvent>(this.document, 'keydown', { capture: true })\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (!this.config.closeOnEscape) return;\n if (event.key === 'Escape' && this.isOpen()) {\n this.hide({ origin: 'keyboard', immediate: true });\n }\n });\n\n // Ensure cleanup on destroy\n this.destroyRef.onDestroy(() => this.destroy());\n }\n\n /**\n * Show the overlay with the specified delay\n * @param showDelay Optional delay to override the configured showDelay\n */\n show(): Promise<void> {\n return new Promise<void>(resolve => {\n // If closing is in progress, cancel it\n if (this.closeTimeout) {\n this.closeTimeout();\n this.closeTimeout = undefined;\n }\n\n // Don't proceed if already opening or open\n if (this.openTimeout || this.isOpen()) {\n return;\n }\n\n // Use the provided delay or fall back to config\n const delay = this.config.showDelay ?? 0;\n\n this.openTimeout = this.disposables.setTimeout(() => {\n this.openTimeout = undefined;\n this.createOverlay();\n resolve();\n }, delay);\n });\n }\n\n /**\n * Hide the overlay with the specified delay\n * @param options Optional options for hiding the overlay\n */\n hide(options?: OverlayTriggerOptions): void {\n // If opening is in progress, cancel it\n if (this.openTimeout) {\n this.openTimeout();\n this.openTimeout = undefined;\n }\n\n // Don't proceed if already closing or closed\n if (this.closeTimeout || !this.isOpen()) {\n return;\n }\n\n this.closing.next();\n\n // Use the provided delay or fall back to config\n const delay = options?.immediate ? 0 : (this.config.hideDelay ?? 0);\n\n this.closeTimeout = this.disposables.setTimeout(async () => {\n this.closeTimeout = undefined;\n\n if (this.config.restoreFocus) {\n this.focusMonitor.focusVia(this.config.triggerElement, options?.origin ?? 'program');\n }\n\n await this.destroyOverlay();\n }, delay);\n }\n\n /**\n * Update the configuration of this overlay\n * @param config New configuration (partial)\n */\n updateConfig(config: Partial<NgpOverlayConfig<T>>): void {\n this.config = { ...this.config, ...config };\n\n // If the overlay is already open, update its position\n if (this.isOpen()) {\n this.updatePosition();\n }\n }\n\n /**\n * Immediately hide the overlay without any delay\n */\n hideImmediate(): void {\n this.hide({ immediate: true });\n }\n\n /**\n * Toggle the overlay open/closed state\n */\n toggle(): void {\n if (this.isOpen()) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n /**\n * Force update the position of the overlay\n */\n updatePosition(): void {\n const portal = this.portal();\n\n if (!portal) {\n return;\n }\n\n const elements = portal.getElements();\n\n if (elements.length === 0) {\n return;\n }\n\n const overlayElement = elements[0] as HTMLElement;\n\n // Compute new position\n this.computePosition(overlayElement);\n }\n\n /**\n * Completely destroy this overlay instance\n */\n destroy(): void {\n this.hideImmediate();\n this.disposePositioning?.();\n this.scrollStrategy.disable();\n }\n\n /**\n * Get the elements of the overlay\n */\n getElements(): HTMLElement[] {\n return this.portal()?.getElements() ?? [];\n }\n\n /**\n * Internal method to create the overlay\n */\n private createOverlay(): void {\n if (!this.config.content) {\n throw new Error('Overlay content must be provided');\n }\n\n // Create a new portal with context\n const portal = createPortal(\n this.config.content,\n this.viewContainerRef,\n Injector.create({\n parent: this.config.injector,\n providers: [\n ...(this.config.providers || []),\n { provide: NgpOverlay, useValue: this },\n provideOverlayContext<T>(this.config.context as T),\n ],\n }),\n { $implicit: this.config.context } as NgpOverlayTemplateContext<T>,\n );\n\n // Attach portal to container\n const container = this.config.container || this.document.body;\n portal.attach(container);\n\n // Update portal signal\n this.portal.set(portal);\n\n // Ensure view is up to date\n portal.detectChanges();\n\n const outletElement = portal.getElements()[0] as HTMLElement | null;\n\n if (!outletElement) {\n throw new Error('Overlay element is not available.');\n }\n\n if (portal.getElements().length > 1) {\n throw new Error('Overlay must have only one root element.');\n }\n\n // Set up positioning\n this.setupPositioning(outletElement);\n\n // Mark as open\n this.isOpen.set(true);\n\n this.scrollStrategy =\n this.config.scrollBehaviour === 'block'\n ? new BlockScrollStrategy(this.viewportRuler, this.document)\n : new NoopScrollStrategy();\n\n this.scrollStrategy.enable();\n }\n\n /**\n * Internal method to setup positioning of the overlay\n */\n private setupPositioning(overlayElement: HTMLElement): void {\n // Determine positioning strategy based on overlay element's CSS\n const strategy =\n getComputedStyle(overlayElement).position === 'fixed'\n ? 'fixed'\n : this.config.strategy || 'absolute';\n\n // Setup auto-update for positioning\n this.disposePositioning = autoUpdate(this.config.triggerElement, overlayElement, () =>\n this.computePosition(overlayElement, strategy),\n );\n }\n\n /**\n * Compute the overlay position using floating-ui\n */\n private async computePosition(\n overlayElement: HTMLElement,\n strategy: Strategy = 'absolute',\n ): Promise<void> {\n // Create middleware array\n const middleware: Middleware[] = [offset(this.config.offset || 0), shift()];\n\n // Add flip middleware if requested\n if (this.config.flip !== false) {\n middleware.push(flip());\n }\n\n // Add any additional middleware\n if (this.config.additionalMiddleware) {\n middleware.push(...this.config.additionalMiddleware);\n }\n\n // Compute the position\n const position = await computePosition(this.config.triggerElement, overlayElement, {\n placement: this.config.placement || 'top',\n middleware,\n strategy,\n });\n\n // Update position signal\n this.position.set({ x: position.x, y: position.y });\n\n // Ensure view is updated\n this.portal()?.detectChanges();\n }\n\n /**\n * Internal method to destroy the overlay portal\n */\n private async destroyOverlay(): Promise<void> {\n const portal = this.portal();\n\n if (!portal) {\n return;\n }\n\n // Clear portal reference to prevent double destruction\n this.portal.set(null);\n\n // Clean up positioning\n this.disposePositioning?.();\n this.disposePositioning = undefined;\n\n // Detach the portal\n await portal.detach();\n\n // Mark as closed\n this.isOpen.set(false);\n\n // disable scroll strategy\n this.scrollStrategy.disable();\n this.scrollStrategy = new NoopScrollStrategy();\n }\n\n /**\n * Get the transform origin for the overlay\n */\n private getTransformOrigin(): string {\n const placement = this.config.placement ?? 'top';\n\n const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n const map: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n };\n\n let x = 'center';\n let y = 'center';\n\n if (basePlacement === 'top' || basePlacement === 'bottom') {\n y = map[basePlacement];\n if (alignment === 'start') x = 'left';\n else if (alignment === 'end') x = 'right';\n } else {\n x = map[basePlacement];\n if (alignment === 'start') y = 'top';\n else if (alignment === 'end') y = 'bottom';\n }\n\n return `${y} ${x}`;\n }\n}\n\n/**\n * Helper function to create an overlay in a single call\n * @internal\n */\nexport function createOverlay<T>(config: NgpOverlayConfig<T>): NgpOverlay<T> {\n // we run the overlay creation in the injector context to ensure that it can call the inject function\n return runInInjectionContext(config.injector, () => new NgpOverlay<T>(config));\n}\n\n/**\n * Helper function to inject the NgpOverlay instance\n * @internal\n */\nexport function injectOverlay<T>(): NgpOverlay<T> {\n return inject(NgpOverlay);\n}\n\nexport interface OverlayTriggerOptions {\n /**\n * Whether the visibility change should be immediate.\n */\n immediate?: boolean;\n /**\n * The origin of the focus event that triggered the visibility change.\n */\n origin?: FocusOrigin;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAM,sBAAsB,GAAG,IAAI,cAAc,CAAU,wBAAwB,CAAC;AAEpF;;;AAGG;SACa,oBAAoB,GAAA;AAClC,IAAA,OAAO,MAAM,CAAC,sBAAsB,CAAM;AAC5C;AAEA;;;;AAIG;AACG,SAAU,qBAAqB,CAAI,KAAQ,EAAA;IAC/C,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC7D;;MCRsB,SAAS,CAAA;IAC7B,WACqB,CAAA,gBAAkC,EAClC,QAAkB,EAAA;QADlB,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB;QAChB,IAAQ,CAAA,QAAA,GAAR,QAAQ;;AA4B9B;AAEK,MAAO,kBAAsB,SAAQ,SAAS,CAAA;AAKlD,IAAA,WAAA,CAAY,SAAkB,EAAE,gBAAkC,EAAE,QAAkB,EAAA;AACpF,QAAA,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC;QAJ3B,IAAO,CAAA,OAAA,GAA2B,IAAI;QACtC,IAAY,CAAA,YAAA,GAAG,KAAK;AAI1B,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe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