ng-primitives 0.53.0 → 0.54.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 (33) hide show
  1. package/fesm2022/ng-primitives-focus-trap.mjs +4 -2
  2. package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
  3. package/fesm2022/ng-primitives-form-field.mjs +2 -1
  4. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  5. package/fesm2022/ng-primitives-input.mjs +4 -3
  6. package/fesm2022/ng-primitives-input.mjs.map +1 -1
  7. package/fesm2022/ng-primitives-internal.mjs +4 -5
  8. package/fesm2022/ng-primitives-internal.mjs.map +1 -1
  9. package/fesm2022/ng-primitives-listbox.mjs +2 -3
  10. package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
  11. package/fesm2022/ng-primitives-menu.mjs +3 -3
  12. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  13. package/fesm2022/ng-primitives-popover.mjs +1 -1
  14. package/fesm2022/ng-primitives-popover.mjs.map +1 -1
  15. package/fesm2022/ng-primitives-portal.mjs +5 -6
  16. package/fesm2022/ng-primitives-portal.mjs.map +1 -1
  17. package/fesm2022/ng-primitives-resize.mjs +2 -2
  18. package/fesm2022/ng-primitives-resize.mjs.map +1 -1
  19. package/fesm2022/ng-primitives-search.mjs +2 -2
  20. package/fesm2022/ng-primitives-search.mjs.map +1 -1
  21. package/fesm2022/ng-primitives-tooltip.mjs +1 -1
  22. package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
  23. package/fesm2022/ng-primitives-utils.mjs +15 -2
  24. package/fesm2022/ng-primitives-utils.mjs.map +1 -1
  25. package/form-field/form-control/form-control.d.ts +2 -1
  26. package/input/input/input.d.ts +6 -0
  27. package/package.json +5 -5
  28. package/portal/overlay-token.d.ts +3 -3
  29. package/portal/overlay.d.ts +3 -3
  30. package/schematics/ng-generate/templates/popover/popover.__fileSuffix@dasherize__.ts.template +1 -1
  31. package/schematics/ng-generate/templates/tooltip/tooltip.__fileSuffix@dasherize__.ts.template +1 -1
  32. package/utils/index.d.ts +1 -0
  33. package/utils/observables/take-until-destroyed.d.ts +10 -0
@@ -1,8 +1,8 @@
1
1
  import { FocusMonitor, InteractivityChecker } from '@angular/cdk/a11y';
2
2
  import * as i0 from '@angular/core';
3
3
  import { inject, Injector, ElementRef, NgZone, input, booleanAttribute, afterNextRender, HostListener, Directive } from '@angular/core';
4
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
4
  import { NgpOverlay } from 'ng-primitives/portal';
5
+ import { safeTakeUntilDestroyed } from 'ng-primitives/utils';
6
6
  import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
7
7
 
8
8
  /**
@@ -134,7 +134,9 @@ class NgpFocusTrap {
134
134
  */
135
135
  this.state = focusTrapState(this);
136
136
  // if this is used within an overlay we must disable the focus trap as soon as the overlay is closing
137
- this.overlay?.closing.pipe(takeUntilDestroyed()).subscribe(() => this.focusTrap.deactivate());
137
+ this.overlay?.closing
138
+ .pipe(safeTakeUntilDestroyed())
139
+ .subscribe(() => this.focusTrap.deactivate());
138
140
  }
139
141
  ngOnInit() {
140
142
  focusTrapStack.add(this.focusTrap);
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-focus-trap.mjs","sources":["../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap-state.ts","../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.ts","../../../../packages/ng-primitives/focus-trap/src/ng-primitives-focus-trap.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFocusTrap } from './focus-trap';\n\n/**\n * The state token for the FocusTrap primitive.\n */\nexport const NgpFocusTrapStateToken = createStateToken<NgpFocusTrap>('FocusTrap');\n\n/**\n * Provides the FocusTrap state.\n */\nexport const provideFocusTrapState = createStateProvider(NgpFocusTrapStateToken);\n\n/**\n * Injects the FocusTrap state.\n */\nexport const injectFocusTrapState = createStateInjector<NgpFocusTrap>(NgpFocusTrapStateToken);\n\n/**\n * The FocusTrap state registration function.\n */\nexport const focusTrapState = createState(NgpFocusTrapStateToken);\n","import { FocusMonitor, InteractivityChecker } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterNextRender,\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n Injector,\n input,\n NgZone,\n OnDestroy,\n OnInit,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NgpOverlay } from 'ng-primitives/portal';\nimport { focusTrapState, provideFocusTrapState } from './focus-trap-state';\n\n/**\n * This implementation is based on the Radix UI FocusScope:\n * https://github.com/radix-ui/primitives/blob/main/packages/react/focus-scope/src/FocusScope.tsx#L306\n */\n\nclass FocusTrap {\n /**\n * Whether the focus trap is active.\n */\n active: boolean = false;\n\n /**\n * Activates the focus trap.\n */\n activate(): void {\n this.active = true;\n }\n\n /**\n * Deactivates the focus trap.\n */\n deactivate(): void {\n this.active = false;\n }\n}\n\nclass FocusTrapStack {\n /**\n * The stack of focus traps.\n */\n private readonly stack: FocusTrap[] = [];\n\n /**\n * Adds a focus trap to the stack.\n */\n add(focusTrap: FocusTrap): void {\n // deactivate the previous focus trap\n this.stack.forEach(t => t.deactivate());\n\n // add the new focus trap and activate it\n this.stack.push(focusTrap);\n focusTrap.activate();\n }\n\n /**\n * Removes a focus trap from the stack.\n */\n remove(focusTrap: FocusTrap): void {\n // remove the focus trap\n const index = this.stack.indexOf(focusTrap);\n\n if (index >= 0) {\n this.stack.splice(index, 1);\n }\n\n // activate the previous focus trap\n const previous = this.stack[this.stack.length - 1];\n\n if (previous) {\n previous.activate();\n }\n }\n}\n\n// create a global stack of focus traps\nconst focusTrapStack = new FocusTrapStack();\n\n/**\n * The `NgpFocusTrap` directive traps focus within the host element.\n */\n@Directive({\n selector: '[ngpFocusTrap]',\n exportAs: 'ngpFocusTrap',\n providers: [provideFocusTrapState()],\n host: {\n '[attr.tabindex]': '-1',\n '[attr.data-focus-trap]': '!disabled() ? \"\" : null',\n },\n})\nexport class NgpFocusTrap implements OnInit, OnDestroy {\n /**\n * Access any parent overlay.\n */\n private readonly overlay = inject(NgpOverlay, { optional: true });\n\n /**\n * Create a new focus trap.\n */\n private readonly focusTrap = new FocusTrap();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivityChecker = inject(InteractivityChecker);\n\n /**\n * Get the focus trap container element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access NgZone to run the focus trap events outside of Angular's zone.\n */\n private readonly ngZone = inject(NgZone);\n\n /**\n * Store the mutation observer.\n */\n private mutationObserver: MutationObserver | null = null;\n\n /**\n * Store the last focused element.\n */\n private lastFocusedElement: HTMLElement | null = null;\n\n /**\n * Whether the focus trap is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFocusTrapDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The focus trap state.\n */\n protected readonly state = focusTrapState<NgpFocusTrap>(this);\n\n constructor() {\n // if this is used within an overlay we must disable the focus trap as soon as the overlay is closing\n this.overlay?.closing.pipe(takeUntilDestroyed()).subscribe(() => this.focusTrap.deactivate());\n }\n\n ngOnInit(): void {\n focusTrapStack.add(this.focusTrap);\n\n this.mutationObserver = new MutationObserver(this.handleMutations.bind(this));\n\n // setup event listeners\n this.ngZone.runOutsideAngular(() => {\n this.mutationObserver!.observe(this.elementRef.nativeElement, {\n childList: true,\n subtree: true,\n });\n document.addEventListener('focusin', this.handleFocusIn.bind(this));\n document.addEventListener('focusout', this.handleFocusOut.bind(this));\n });\n\n const previouslyFocusedElement = document.activeElement as HTMLElement | null;\n const hasFocusedCandidate = this.elementRef.nativeElement.contains(previouslyFocusedElement);\n\n if (!hasFocusedCandidate) {\n // we do this to ensure the content is rendered before we try to find the first focusable element\n // and focus it\n afterNextRender(\n {\n write: () => {\n this.focusFirst();\n\n // if the focus didn't change, focus the container\n if (document.activeElement === previouslyFocusedElement) {\n this.focus(this.elementRef.nativeElement);\n }\n },\n },\n { injector: this.injector },\n );\n }\n }\n\n ngOnDestroy(): void {\n focusTrapStack.remove(this.focusTrap);\n this.mutationObserver?.disconnect();\n this.mutationObserver = null;\n this.focusTrap.deactivate();\n }\n\n private handleFocusIn(event: FocusEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const target = event.target as HTMLElement | null;\n\n if (this.elementRef.nativeElement.contains(target)) {\n this.lastFocusedElement = target;\n } else {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * Handles the `focusout` event.\n */\n private handleFocusOut(event: FocusEvent) {\n if (!this.focusTrap.active || this.state.disabled() || event.relatedTarget === null) {\n return;\n }\n\n const relatedTarget = event.relatedTarget as HTMLElement;\n\n if (!this.elementRef.nativeElement.contains(relatedTarget)) {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * If the focused element gets removed from the DOM, browsers move focus back to the document.body.\n * We move focus to the container to keep focus trapped correctly.\n */\n private handleMutations(mutations: MutationRecord[]): void {\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (focusedElement !== document.body) {\n return;\n }\n\n for (const mutation of mutations) {\n if (mutation.removedNodes.length > 0) {\n this.focus(this.elementRef.nativeElement);\n }\n }\n }\n\n /**\n * Handles the `keydown` event.\n */\n @HostListener('keydown', ['$event'])\n protected handleKeyDown(event: KeyboardEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (isTabKey && focusedElement) {\n const container = event.currentTarget as HTMLElement;\n const [first, last] = this.getTabbableEdges(container);\n const hasTabbableElementsInside = first && last;\n\n // we can only wrap focus if we have tabbable edges\n if (!hasTabbableElementsInside) {\n if (focusedElement === container) {\n event.preventDefault();\n }\n } else {\n if (!event.shiftKey && focusedElement === last) {\n event.preventDefault();\n this.focus(first);\n } else if (event.shiftKey && focusedElement === first) {\n event.preventDefault();\n this.focus(last);\n }\n }\n }\n }\n\n /**\n * Returns the first and last tabbable elements inside a container.\n */\n private getTabbableEdges(container: HTMLElement) {\n const candidates = this.getTabbableCandidates(container);\n const first = this.findVisible(candidates);\n const last = this.findVisible(candidates.reverse());\n return [first, last] as const;\n }\n\n /**\n * Returns a list of potential focusable elements inside a container.\n */\n private getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: HTMLElement) =>\n this.interactivityChecker.isFocusable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n });\n while (walker.nextNode()) {\n nodes.push(walker.currentNode as HTMLElement);\n }\n return nodes;\n }\n\n /**\n * Returns the first visible element in a list..\n */\n private findVisible(elements: HTMLElement[]) {\n return elements.find(element => this.interactivityChecker.isVisible(element)) ?? null;\n }\n\n private focus(element: HTMLElement | null): void {\n if (!element) {\n return;\n }\n // Its not great that we are relying on an internal API here, but we need to in order to\n // try and best determine the focus origin when it is programmatically closed by the user.\n this.focusMonitor.focusVia(element, (this.focusMonitor as any)._lastFocusOrigin, {\n preventScroll: true,\n });\n }\n\n private focusFirst(): void {\n const previouslyFocusedElement = document.activeElement;\n\n for (const candidate of this.getTabbableCandidates(this.elementRef.nativeElement)) {\n this.focus(candidate);\n\n if (document.activeElement !== previouslyFocusedElement) {\n return;\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAm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AA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,YAAY,EANZ,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,gBAAA,EAAA,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,sBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,SAAA,EAAA,uBAAA,EAAA,EAAA,UAAA,EAAA,EAAA,eAAA,EAAA,IAAA,EAAA,sBAAA,EAAA,2BAAA,EAAA,EAAA,EAAA,SAAA,EAAA,CAAC,qBAAqB,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,cAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAMzB,YAAY,EAAA,UAAA,EAAA,CAAA;kBATxB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,SAAS,EAAE,CAAC,qBAAqB,EAAE,CAAC;AACpC,oBAAA,IAAI,EAAE;AACJ,wBAAA,iBAAiB,EAAE,IAAI;AACvB,wBAAA,wBAAwB,EAAE,yBAAyB;AACpD,qBAAA;AACF,iBAAA;wDAgKW,aAAa,EAAA,CAAA;sBADtB,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;;;AChQrC;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-focus-trap.mjs","sources":["../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap-state.ts","../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.ts","../../../../packages/ng-primitives/focus-trap/src/ng-primitives-focus-trap.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFocusTrap } from './focus-trap';\n\n/**\n * The state token for the FocusTrap primitive.\n */\nexport const NgpFocusTrapStateToken = createStateToken<NgpFocusTrap>('FocusTrap');\n\n/**\n * Provides the FocusTrap state.\n */\nexport const provideFocusTrapState = createStateProvider(NgpFocusTrapStateToken);\n\n/**\n * Injects the FocusTrap state.\n */\nexport const injectFocusTrapState = createStateInjector<NgpFocusTrap>(NgpFocusTrapStateToken);\n\n/**\n * The FocusTrap state registration function.\n */\nexport const focusTrapState = createState(NgpFocusTrapStateToken);\n","import { FocusMonitor, InteractivityChecker } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterNextRender,\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n Injector,\n input,\n NgZone,\n OnDestroy,\n OnInit,\n} from '@angular/core';\nimport { NgpOverlay } from 'ng-primitives/portal';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { focusTrapState, provideFocusTrapState } from './focus-trap-state';\n\n/**\n * This implementation is based on the Radix UI FocusScope:\n * https://github.com/radix-ui/primitives/blob/main/packages/react/focus-scope/src/FocusScope.tsx#L306\n */\n\nclass FocusTrap {\n /**\n * Whether the focus trap is active.\n */\n active: boolean = false;\n\n /**\n * Activates the focus trap.\n */\n activate(): void {\n this.active = true;\n }\n\n /**\n * Deactivates the focus trap.\n */\n deactivate(): void {\n this.active = false;\n }\n}\n\nclass FocusTrapStack {\n /**\n * The stack of focus traps.\n */\n private readonly stack: FocusTrap[] = [];\n\n /**\n * Adds a focus trap to the stack.\n */\n add(focusTrap: FocusTrap): void {\n // deactivate the previous focus trap\n this.stack.forEach(t => t.deactivate());\n\n // add the new focus trap and activate it\n this.stack.push(focusTrap);\n focusTrap.activate();\n }\n\n /**\n * Removes a focus trap from the stack.\n */\n remove(focusTrap: FocusTrap): void {\n // remove the focus trap\n const index = this.stack.indexOf(focusTrap);\n\n if (index >= 0) {\n this.stack.splice(index, 1);\n }\n\n // activate the previous focus trap\n const previous = this.stack[this.stack.length - 1];\n\n if (previous) {\n previous.activate();\n }\n }\n}\n\n// create a global stack of focus traps\nconst focusTrapStack = new FocusTrapStack();\n\n/**\n * The `NgpFocusTrap` directive traps focus within the host element.\n */\n@Directive({\n selector: '[ngpFocusTrap]',\n exportAs: 'ngpFocusTrap',\n providers: [provideFocusTrapState()],\n host: {\n '[attr.tabindex]': '-1',\n '[attr.data-focus-trap]': '!disabled() ? \"\" : null',\n },\n})\nexport class NgpFocusTrap implements OnInit, OnDestroy {\n /**\n * Access any parent overlay.\n */\n private readonly overlay = inject(NgpOverlay, { optional: true });\n\n /**\n * Create a new focus trap.\n */\n private readonly focusTrap = new FocusTrap();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivityChecker = inject(InteractivityChecker);\n\n /**\n * Get the focus trap container element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access NgZone to run the focus trap events outside of Angular's zone.\n */\n private readonly ngZone = inject(NgZone);\n\n /**\n * Store the mutation observer.\n */\n private mutationObserver: MutationObserver | null = null;\n\n /**\n * Store the last focused element.\n */\n private lastFocusedElement: HTMLElement | null = null;\n\n /**\n * Whether the focus trap is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFocusTrapDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The focus trap state.\n */\n protected readonly state = focusTrapState<NgpFocusTrap>(this);\n\n constructor() {\n // if this is used within an overlay we must disable the focus trap as soon as the overlay is closing\n this.overlay?.closing\n .pipe(safeTakeUntilDestroyed())\n .subscribe(() => this.focusTrap.deactivate());\n }\n\n ngOnInit(): void {\n focusTrapStack.add(this.focusTrap);\n\n this.mutationObserver = new MutationObserver(this.handleMutations.bind(this));\n\n // setup event listeners\n this.ngZone.runOutsideAngular(() => {\n this.mutationObserver!.observe(this.elementRef.nativeElement, {\n childList: true,\n subtree: true,\n });\n document.addEventListener('focusin', this.handleFocusIn.bind(this));\n document.addEventListener('focusout', this.handleFocusOut.bind(this));\n });\n\n const previouslyFocusedElement = document.activeElement as HTMLElement | null;\n const hasFocusedCandidate = this.elementRef.nativeElement.contains(previouslyFocusedElement);\n\n if (!hasFocusedCandidate) {\n // we do this to ensure the content is rendered before we try to find the first focusable element\n // and focus it\n afterNextRender(\n {\n write: () => {\n this.focusFirst();\n\n // if the focus didn't change, focus the container\n if (document.activeElement === previouslyFocusedElement) {\n this.focus(this.elementRef.nativeElement);\n }\n },\n },\n { injector: this.injector },\n );\n }\n }\n\n ngOnDestroy(): void {\n focusTrapStack.remove(this.focusTrap);\n this.mutationObserver?.disconnect();\n this.mutationObserver = null;\n this.focusTrap.deactivate();\n }\n\n private handleFocusIn(event: FocusEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const target = event.target as HTMLElement | null;\n\n if (this.elementRef.nativeElement.contains(target)) {\n this.lastFocusedElement = target;\n } else {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * Handles the `focusout` event.\n */\n private handleFocusOut(event: FocusEvent) {\n if (!this.focusTrap.active || this.state.disabled() || event.relatedTarget === null) {\n return;\n }\n\n const relatedTarget = event.relatedTarget as HTMLElement;\n\n if (!this.elementRef.nativeElement.contains(relatedTarget)) {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * If the focused element gets removed from the DOM, browsers move focus back to the document.body.\n * We move focus to the container to keep focus trapped correctly.\n */\n private handleMutations(mutations: MutationRecord[]): void {\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (focusedElement !== document.body) {\n return;\n }\n\n for (const mutation of mutations) {\n if (mutation.removedNodes.length > 0) {\n this.focus(this.elementRef.nativeElement);\n }\n }\n }\n\n /**\n * Handles the `keydown` event.\n */\n @HostListener('keydown', ['$event'])\n protected handleKeyDown(event: KeyboardEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (isTabKey && focusedElement) {\n const container = event.currentTarget as HTMLElement;\n const [first, last] = this.getTabbableEdges(container);\n const hasTabbableElementsInside = first && last;\n\n // we can only wrap focus if we have tabbable edges\n if (!hasTabbableElementsInside) {\n if (focusedElement === container) {\n event.preventDefault();\n }\n } else {\n if (!event.shiftKey && focusedElement === last) {\n event.preventDefault();\n this.focus(first);\n } else if (event.shiftKey && focusedElement === first) {\n event.preventDefault();\n this.focus(last);\n }\n }\n }\n }\n\n /**\n * Returns the first and last tabbable elements inside a container.\n */\n private getTabbableEdges(container: HTMLElement) {\n const candidates = this.getTabbableCandidates(container);\n const first = this.findVisible(candidates);\n const last = this.findVisible(candidates.reverse());\n return [first, last] as const;\n }\n\n /**\n * Returns a list of potential focusable elements inside a container.\n */\n private getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: HTMLElement) =>\n this.interactivityChecker.isFocusable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n });\n while (walker.nextNode()) {\n nodes.push(walker.currentNode as HTMLElement);\n }\n return nodes;\n }\n\n /**\n * Returns the first visible element in a list..\n */\n private findVisible(elements: HTMLElement[]) {\n return elements.find(element => this.interactivityChecker.isVisible(element)) ?? null;\n }\n\n private focus(element: HTMLElement | null): void {\n if (!element) {\n return;\n }\n // Its not great that we are relying on an internal API here, but we need to in order to\n // try and best determine the focus origin when it is programmatically closed by the user.\n this.focusMonitor.focusVia(element, (this.focusMonitor as any)._lastFocusOrigin, {\n preventScroll: true,\n });\n }\n\n private focusFirst(): void {\n const previouslyFocusedElement = document.activeElement;\n\n for (const candidate of this.getTabbableCandidates(this.elementRef.nativeElement)) {\n this.focus(candidate);\n\n if (document.activeElement !== previouslyFocusedElement) {\n return;\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,sBAAsB;AAE/E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAe,sBAAsB;AAE5F;;AAEG;AACI,MAAM,cAAc,GAAG,WAAW,CAAC,sBAAsB,CAAC;;ACPjE;;;AAGG;AAEH,MAAM,SAAS,CAAA;AAAf,IAAA,WAAA,GAAA;AACE;;AAEG;QACH,IAAM,CAAA,MAAA,GAAY,KAAK;;AAEvB;;AAEG;IACH,QAAQ,GAAA;AACN,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI;;AAGpB;;AAEG;IACH,UAAU,GAAA;AACR,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;AAEtB;AAED,MAAM,cAAc,CAAA;AAApB,IAAA,WAAA,GAAA;AACE;;AAEG;QACc,IAAK,CAAA,KAAA,GAAgB,EAAE;;AAExC;;AAEG;AACH,IAAA,GAAG,CAAC,SAAoB,EAAA;;AAEtB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;;AAGvC,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1B,SAAS,CAAC,QAAQ,EAAE;;AAGtB;;AAEG;AACH,IAAA,MAAM,CAAC,SAAoB,EAAA;;QAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAE3C,QAAA,IAAI,KAAK,IAAI,CAAC,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;;;AAI7B,Q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G;;;;"}
@@ -178,7 +178,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
178
178
  providers: [provideFormControlState()],
179
179
  }]
180
180
  }], ctorParameters: () => [] });
181
- function setupFormControl({ id, disabled = signal(false) }) {
181
+ function setupFormControl({ id, disabled = signal(false), }) {
182
182
  const element = injectElementRef().nativeElement;
183
183
  // Access the form field that the form control is associated with.
184
184
  const formField = injectFormFieldState({ optional: true });
@@ -206,6 +206,7 @@ function setupFormControl({ id, disabled = signal(false) }) {
206
206
  setStateAttribute(element, disabled() || status().disabled, 'data-disabled');
207
207
  },
208
208
  });
209
+ return computed(() => ({ ...status(), disabled: status().disabled || disabled() }));
209
210
  }
210
211
  /**
211
212
  * Sets the attribute on the element. If the value is not empty, the attribute is set to the value.
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-form-field.mjs","sources":["../../../../packages/ng-primitives/form-field/src/form-field/form-field-state.ts","../../../../packages/ng-primitives/form-field/src/description/description.ts","../../../../packages/ng-primitives/form-field/src/error/error.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control-state.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.ts","../../../../packages/ng-primitives/form-field/src/form-field/form-field.ts","../../../../packages/ng-primitives/form-field/src/label/label.ts","../../../../packages/ng-primitives/form-field/src/ng-primitives-form-field.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormField } from './form-field';\n\n/**\n * The state token for the FormField primitive.\n */\nexport const NgpFormFieldStateToken = createStateToken<NgpFormField>('FormField');\n\n/**\n * Provides the FormField state.\n */\nexport const provideFormFieldState = createStateProvider(NgpFormFieldStateToken);\n\n/**\n * Injects the FormField state.\n */\nexport const injectFormFieldState = createStateInjector<NgpFormField>(NgpFormFieldStateToken);\n\n/**\n * The FormField state registration function.\n */\nexport const formFieldState = createState(NgpFormFieldStateToken);\n","import { Directive, effect, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpDescription` directive is used to mark a description element within a form field. There may be multiple descriptions associated with a form control.\n */\n@Directive({\n selector: '[ngpDescription]',\n exportAs: 'ngpDescription',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpDescription {\n /**\n * The id of the description. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-description'));\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addDescription(this.id());\n onCleanup(() => this.formField()?.removeDescription(this.id()));\n });\n }\n}\n","import { Directive, OnChanges, OnDestroy, SimpleChanges, computed, input } from '@angular/core';\nimport { onBooleanChange, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpError` directive is used to mark an error message element within a form field. There may be multiple error messages associated with a form control.\n */\n@Directive({\n selector: '[ngpError]',\n exportAs: 'ngpError',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n '[attr.data-validator]': 'state()',\n },\n})\nexport class NgpError implements OnChanges, OnDestroy {\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n /**\n * The id of the error message. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-error'));\n\n /**\n * The validator associated with the error message.\n */\n readonly validator = input<string | null>(null, {\n alias: 'ngpErrorValidator',\n });\n\n /**\n * Determine if there is an error message.\n */\n protected readonly hasError = computed(() => {\n const errors = this.formField()?.errors() ?? [];\n const validator = this.validator();\n\n return validator ? errors?.includes(validator) : errors?.length > 0;\n });\n\n /**\n * Determine whether the validator associated with this error is failing.\n */\n protected readonly state = computed(() => (this.hasError() ? 'fail' : 'pass'));\n\n constructor() {\n // add or remove the error message when the error state changes\n onBooleanChange(\n this.hasError,\n () => this.formField()?.addDescription(this.id()),\n () => this.formField()?.removeDescription(this.id()),\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ('id' in changes) {\n this.formField()?.removeDescription(changes['id'].previousValue);\n }\n }\n\n ngOnDestroy(): void {\n this.formField()?.removeDescription(this.id());\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormControl } from './form-control';\n\n/**\n * The state token for the FormControl primitive.\n */\nexport const NgpFormControlStateToken = createStateToken<NgpFormControl>('FormControl');\n\n/**\n * Provides the FormControl state.\n */\nexport const provideFormControlState = createStateProvider(NgpFormControlStateToken);\n\n/**\n * Injects the FormControl state.\n */\nexport const injectFormControlState = createStateInjector<NgpFormControl>(NgpFormControlStateToken);\n\n/**\n * The FormControl state registration function.\n */\nexport const formControlState = createState(NgpFormControlStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n Directive,\n input,\n signal,\n Signal,\n} from '@angular/core';\nimport { explicitEffect, injectElementRef } from 'ng-primitives/internal';\nimport { controlStatus, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\nimport { formControlState, provideFormControlState } from './form-control-state';\n\n/**\n * Typically this primitive would be not be used directly, but instead a more specific form control primitive would be used (e.g. `ngpInput`). All of our form control primitives use `ngpFormControl` internally so they will have the same accessibility features as described below.\n *\n * The `NgpFormControl` directive is used to mark a form control element within a form field. This element will have an `aria-labelledby` attribute set to the ID of the label element within the form field and an `aria-describedby` attribute set to the ID of the description elements within the form field.\n */\n@Directive({\n selector: '[ngpFormControl]',\n exportAs: 'ngpFormControl',\n providers: [provideFormControlState()],\n})\nexport class NgpFormControl {\n /**\n * The id of the form control. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-form-control'));\n\n /**\n * Whether the form control is disabled by a parent.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFormControlDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the form control.\n */\n private readonly state = formControlState<NgpFormControl>(this);\n\n constructor() {\n // Sync the form control state with the control state.\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n }\n}\n\ninterface FormControlState {\n id: Signal<string>;\n disabled?: Signal<boolean>;\n}\n\nexport function setupFormControl({ id, disabled = signal(false) }: FormControlState) {\n const element = injectElementRef().nativeElement;\n // Access the form field that the form control is associated with.\n const formField = injectFormFieldState({ optional: true });\n // Access the form control status.\n const status = controlStatus();\n // Determine the aria-labelledby attribute value.\n const ariaLabelledBy = computed(() => formField()?.labels().join(' '));\n // Determine the aria-describedby attribute value.\n const ariaDescribedBy = computed(() => formField()?.descriptions().join(' '));\n\n explicitEffect([id], ([id], onCleanup) => {\n formField()?.setFormControl(id);\n onCleanup(() => formField()?.removeFormControl());\n });\n\n afterRenderEffect({\n write: () => {\n setAttribute(element, 'id', id());\n setAttribute(element, 'aria-labelledby', ariaLabelledBy());\n setAttribute(element, 'aria-describedby', ariaDescribedBy());\n\n setStateAttribute(element, status().invalid, 'data-invalid');\n setStateAttribute(element, status().valid, 'data-valid');\n setStateAttribute(element, status().touched, 'data-touched');\n setStateAttribute(element, status().pristine, 'data-pristine');\n setStateAttribute(element, status().dirty, 'data-dirty');\n setStateAttribute(element, status().pending, 'data-pending');\n setStateAttribute(element, disabled() || status().disabled, 'data-disabled');\n },\n });\n}\n\n/**\n * Sets the attribute on the element. If the value is not empty, the attribute is set to the value.\n * If the value is empty, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param attribute The attribute to set on the element.\n * @param value The value to set on the attribute.\n */\nfunction setAttribute(element: HTMLElement, attribute: string, value: string) {\n if (value && value.length > 0) {\n element.setAttribute(attribute, value);\n } else {\n element.removeAttribute(attribute);\n }\n}\n\n/**\n * Sets the attribute on the element based on the state. If the state is true, the attribute\n * is set to an empty string. If the state is false, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param state The state to set the attribute based on.\n * @param attribute The attribute to set on the element.\n */\nfunction setStateAttribute(element: HTMLElement, state: boolean | null, attribute: string) {\n if (state) {\n element.setAttribute(attribute, '');\n } else {\n element.removeAttribute(attribute);\n }\n}\n","import { Directive, OnDestroy, contentChild, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { onChange } from 'ng-primitives/utils';\nimport { Subscription } from 'rxjs';\nimport { formFieldState, provideFormFieldState } from './form-field-state';\n\n/**\n * The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.\n */\n@Directive({\n selector: '[ngpFormField]',\n exportAs: 'ngpFormField',\n providers: [provideFormFieldState()],\n host: {\n '[attr.data-invalid]': 'invalid() ? \"\" : null',\n '[attr.data-valid]': 'valid() ? \"\" : null',\n '[attr.data-touched]': 'touched() ? \"\" : null',\n '[attr.data-pristine]': 'pristine() ? \"\" : null',\n '[attr.data-dirty]': 'dirty() ? \"\" : null',\n '[attr.data-pending]': 'pending() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpFormField implements OnDestroy {\n /**\n * Store the form label.\n * @internal\n */\n readonly labels = signal<string[]>([]);\n\n /**\n * Store the form descriptions.\n * @internal\n */\n readonly descriptions = signal<string[]>([]);\n\n /**\n * Store the id of the associated form control.\n * @internal\n */\n readonly formControl = signal<string | null>(null);\n\n /**\n * Find any NgControl within the form field.\n * @internal\n */\n private readonly ngControl = contentChild(NgControl);\n\n /**\n * Store the validation error messages.\n * @internal\n */\n readonly errors = signal<string[]>([]);\n\n /**\n * Whether the control is pristine.\n * @internal\n */\n readonly pristine = signal<boolean | null>(null);\n\n /**\n * Whether the control is touched.\n * @internal\n */\n readonly touched = signal<boolean | null>(null);\n\n /**\n * Whether the control is dirty.\n * @internal\n */\n readonly dirty = signal<boolean | null>(null);\n\n /**\n * Whether the control is valid.\n */\n readonly valid = signal<boolean | null>(null);\n\n /**\n * Whether the control is invalid.\n * @internal\n */\n readonly invalid = signal<boolean | null>(null);\n\n /**\n * Whether the control is pending.\n * @internal\n */\n readonly pending = signal<boolean | null>(null);\n\n /**\n * Whether the control is disabled.\n * @internal\n */\n readonly disabled = signal<boolean | null>(null);\n\n /**\n * Store the current status subscription.\n */\n private subscription?: Subscription;\n\n /**\n * The form field state.\n */\n protected readonly state = formFieldState<NgpFormField>(this);\n\n constructor() {\n // any time the ngControl changes, setup the subscriptions.\n onChange(this.ngControl, this.setupSubscriptions.bind(this));\n }\n\n ngOnDestroy(): void {\n this.subscription?.unsubscribe();\n }\n\n /**\n * Setup a listener for the form control status.\n * @param control\n */\n private setupSubscriptions(control: NgControl | null | undefined): void {\n // Unsubscribe from the previous subscriptions.\n this.subscription?.unsubscribe();\n\n // set the initial values\n this.updateStatus();\n\n const underlyingControl = control?.control;\n\n // Listen for changes to the underlying control's status.\n this.subscription = underlyingControl?.events?.subscribe(this.updateStatus.bind(this));\n }\n\n private updateStatus(): void {\n const control = this.ngControl();\n\n if (!control) {\n return;\n }\n\n this.pristine.set(control.pristine);\n this.touched.set(control.touched);\n this.dirty.set(control.dirty);\n this.valid.set(control.valid);\n this.invalid.set(control.invalid);\n this.pending.set(control.pending);\n this.disabled.set(control.disabled);\n this.errors.set(control?.errors ? Object.keys(control.errors) : []);\n }\n\n /**\n * Register the id of the associated form control.\n * @param id\n * @internal\n */\n setFormControl(id: string): void {\n this.formControl.set(id);\n }\n\n /**\n * Register a label with the form field.\n * @param label\n * @internal\n */\n addLabel(label: string): void {\n this.labels.update(labels => [...labels, label]);\n }\n\n /**\n * Register a description with the form field.\n * @param description\n * @internal\n */\n addDescription(description: string): void {\n this.descriptions.update(descriptions => [...descriptions, description]);\n }\n\n /**\n * Remove the associated form control.\n * @internal\n */\n removeFormControl(): void {\n this.formControl.set(null);\n }\n\n /**\n * Remove a label from the form field.\n * @param label\n * @internal\n */\n removeLabel(label: string): void {\n this.labels.update(labels => labels.filter(l => l !== label));\n }\n\n /**\n * Remove a description from the form field.\n * @param description\n * @internal\n */\n removeDescription(description: string): void {\n this.descriptions.update(descriptions => descriptions.filter(d => d !== description));\n }\n}\n","import {\n computed,\n Directive,\n effect,\n ElementRef,\n HostListener,\n inject,\n input,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpLabel` directive is used to mark a label element within a form field. Preferably, there should use an HTML `<label>` element.\n */\n@Directive({\n selector: '[ngpLabel]',\n exportAs: 'ngpLabel',\n host: {\n '[attr.id]': 'id()',\n '[attr.for]': 'htmlFor()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpLabel {\n /**\n * The id of the label. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-label'));\n /**\n * Access the form field that the label is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n /**\n * Derive the for attribute value if the label is an HTML label element.\n */\n protected readonly htmlFor = computed(() => this.formField()?.formControl());\n /**\n * Access the element that the label is associated with.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n /**\n * Determine if the label is an HTML label element.\n */\n protected readonly isLabel = this.elementRef.nativeElement instanceof HTMLLabelElement;\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addLabel(this.id());\n onCleanup(() => this.formField()?.removeLabel(this.id()));\n });\n }\n\n @HostListener('click', ['$event'])\n protected onClick(event: MouseEvent): void {\n // by default a label will perform a click on the associated form control, however\n // this only works if the associated form control is an input element which may not always\n // be the case, so we prevent the default behavior and handle the click event ourselves.\n // This was inspired by the HeadlessUI approach:\n // https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/label/label.tsx#L58\n if (this.isLabel) {\n event.preventDefault();\n }\n\n // to find the associated form control we can lookup via the known id\n const targetId = this.htmlFor();\n\n if (!targetId) {\n return;\n }\n\n const target = document.getElementById(targetId);\n\n if (!target) {\n return;\n }\n\n // if the target is disabled then do nothing\n const disabled = target.getAttribute('disabled');\n const ariaDisabled = target.getAttribute('aria-disabled');\n\n if (disabled === '' || disabled === 'true' || ariaDisabled === 'true') {\n return;\n }\n\n // radio buttons, checkboxes and switches should all be clicked immediately as they require state changes\n if (\n (target instanceof HTMLInputElement &&\n (target.type === 'radio' || target.type === 'checkbox')) ||\n target.role === 'radio' ||\n target.role === 'checkbox' ||\n target.role === 'switch'\n ) {\n target.click();\n }\n\n // Move focus to the element, this allows you to start using keyboard shortcuts since the\n // bound element is now focused.\n target.focus({ preventScroll: true });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;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CAAA,CAAA;;4FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAfpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,YAAY,EAAE,WAAW;AACzB,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC7D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC9D,qBAAA;AACF,iBAAA;wDA+BW,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;;;AC3DnC;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-form-field.mjs","sources":["../../../../packages/ng-primitives/form-field/src/form-field/form-field-state.ts","../../../../packages/ng-primitives/form-field/src/description/description.ts","../../../../packages/ng-primitives/form-field/src/error/error.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control-state.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.ts","../../../../packages/ng-primitives/form-field/src/form-field/form-field.ts","../../../../packages/ng-primitives/form-field/src/label/label.ts","../../../../packages/ng-primitives/form-field/src/ng-primitives-form-field.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormField } from './form-field';\n\n/**\n * The state token for the FormField primitive.\n */\nexport const NgpFormFieldStateToken = createStateToken<NgpFormField>('FormField');\n\n/**\n * Provides the FormField state.\n */\nexport const provideFormFieldState = createStateProvider(NgpFormFieldStateToken);\n\n/**\n * Injects the FormField state.\n */\nexport const injectFormFieldState = createStateInjector<NgpFormField>(NgpFormFieldStateToken);\n\n/**\n * The FormField state registration function.\n */\nexport const formFieldState = createState(NgpFormFieldStateToken);\n","import { Directive, effect, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpDescription` directive is used to mark a description element within a form field. There may be multiple descriptions associated with a form control.\n */\n@Directive({\n selector: '[ngpDescription]',\n exportAs: 'ngpDescription',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpDescription {\n /**\n * The id of the description. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-description'));\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addDescription(this.id());\n onCleanup(() => this.formField()?.removeDescription(this.id()));\n });\n }\n}\n","import { Directive, OnChanges, OnDestroy, SimpleChanges, computed, input } from '@angular/core';\nimport { onBooleanChange, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpError` directive is used to mark an error message element within a form field. There may be multiple error messages associated with a form control.\n */\n@Directive({\n selector: '[ngpError]',\n exportAs: 'ngpError',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n '[attr.data-validator]': 'state()',\n },\n})\nexport class NgpError implements OnChanges, OnDestroy {\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n /**\n * The id of the error message. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-error'));\n\n /**\n * The validator associated with the error message.\n */\n readonly validator = input<string | null>(null, {\n alias: 'ngpErrorValidator',\n });\n\n /**\n * Determine if there is an error message.\n */\n protected readonly hasError = computed(() => {\n const errors = this.formField()?.errors() ?? [];\n const validator = this.validator();\n\n return validator ? errors?.includes(validator) : errors?.length > 0;\n });\n\n /**\n * Determine whether the validator associated with this error is failing.\n */\n protected readonly state = computed(() => (this.hasError() ? 'fail' : 'pass'));\n\n constructor() {\n // add or remove the error message when the error state changes\n onBooleanChange(\n this.hasError,\n () => this.formField()?.addDescription(this.id()),\n () => this.formField()?.removeDescription(this.id()),\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ('id' in changes) {\n this.formField()?.removeDescription(changes['id'].previousValue);\n }\n }\n\n ngOnDestroy(): void {\n this.formField()?.removeDescription(this.id());\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormControl } from './form-control';\n\n/**\n * The state token for the FormControl primitive.\n */\nexport const NgpFormControlStateToken = createStateToken<NgpFormControl>('FormControl');\n\n/**\n * Provides the FormControl state.\n */\nexport const provideFormControlState = createStateProvider(NgpFormControlStateToken);\n\n/**\n * Injects the FormControl state.\n */\nexport const injectFormControlState = createStateInjector<NgpFormControl>(NgpFormControlStateToken);\n\n/**\n * The FormControl state registration function.\n */\nexport const formControlState = createState(NgpFormControlStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n Directive,\n input,\n signal,\n Signal,\n} from '@angular/core';\nimport { explicitEffect, injectElementRef } from 'ng-primitives/internal';\nimport { controlStatus, NgpControlStatus, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\nimport { formControlState, provideFormControlState } from './form-control-state';\n\n/**\n * Typically this primitive would be not be used directly, but instead a more specific form control primitive would be used (e.g. `ngpInput`). All of our form control primitives use `ngpFormControl` internally so they will have the same accessibility features as described below.\n *\n * The `NgpFormControl` directive is used to mark a form control element within a form field. This element will have an `aria-labelledby` attribute set to the ID of the label element within the form field and an `aria-describedby` attribute set to the ID of the description elements within the form field.\n */\n@Directive({\n selector: '[ngpFormControl]',\n exportAs: 'ngpFormControl',\n providers: [provideFormControlState()],\n})\nexport class NgpFormControl {\n /**\n * The id of the form control. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-form-control'));\n\n /**\n * Whether the form control is disabled by a parent.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFormControlDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the form control.\n */\n private readonly state = formControlState<NgpFormControl>(this);\n\n constructor() {\n // Sync the form control state with the control state.\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n }\n}\n\ninterface FormControlState {\n id: Signal<string>;\n disabled?: Signal<boolean>;\n}\n\nexport function setupFormControl({\n id,\n disabled = signal(false),\n}: FormControlState): Signal<NgpControlStatus> {\n const element = injectElementRef().nativeElement;\n // Access the form field that the form control is associated with.\n const formField = injectFormFieldState({ optional: true });\n // Access the form control status.\n const status = controlStatus();\n // Determine the aria-labelledby attribute value.\n const ariaLabelledBy = computed(() => formField()?.labels().join(' '));\n // Determine the aria-describedby attribute value.\n const ariaDescribedBy = computed(() => formField()?.descriptions().join(' '));\n\n explicitEffect([id], ([id], onCleanup) => {\n formField()?.setFormControl(id);\n onCleanup(() => formField()?.removeFormControl());\n });\n\n afterRenderEffect({\n write: () => {\n setAttribute(element, 'id', id());\n setAttribute(element, 'aria-labelledby', ariaLabelledBy());\n setAttribute(element, 'aria-describedby', ariaDescribedBy());\n\n setStateAttribute(element, status().invalid, 'data-invalid');\n setStateAttribute(element, status().valid, 'data-valid');\n setStateAttribute(element, status().touched, 'data-touched');\n setStateAttribute(element, status().pristine, 'data-pristine');\n setStateAttribute(element, status().dirty, 'data-dirty');\n setStateAttribute(element, status().pending, 'data-pending');\n setStateAttribute(element, disabled() || status().disabled, 'data-disabled');\n },\n });\n\n return computed(() => ({ ...status(), disabled: status().disabled || disabled() }));\n}\n\n/**\n * Sets the attribute on the element. If the value is not empty, the attribute is set to the value.\n * If the value is empty, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param attribute The attribute to set on the element.\n * @param value The value to set on the attribute.\n */\nfunction setAttribute(element: HTMLElement, attribute: string, value: string) {\n if (value && value.length > 0) {\n element.setAttribute(attribute, value);\n } else {\n element.removeAttribute(attribute);\n }\n}\n\n/**\n * Sets the attribute on the element based on the state. If the state is true, the attribute\n * is set to an empty string. If the state is false, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param state The state to set the attribute based on.\n * @param attribute The attribute to set on the element.\n */\nfunction setStateAttribute(element: HTMLElement, state: boolean | null, attribute: string) {\n if (state) {\n element.setAttribute(attribute, '');\n } else {\n element.removeAttribute(attribute);\n }\n}\n","import { Directive, OnDestroy, contentChild, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { onChange } from 'ng-primitives/utils';\nimport { Subscription } from 'rxjs';\nimport { formFieldState, provideFormFieldState } from './form-field-state';\n\n/**\n * The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.\n */\n@Directive({\n selector: '[ngpFormField]',\n exportAs: 'ngpFormField',\n providers: [provideFormFieldState()],\n host: {\n '[attr.data-invalid]': 'invalid() ? \"\" : null',\n '[attr.data-valid]': 'valid() ? \"\" : null',\n '[attr.data-touched]': 'touched() ? \"\" : null',\n '[attr.data-pristine]': 'pristine() ? \"\" : null',\n '[attr.data-dirty]': 'dirty() ? \"\" : null',\n '[attr.data-pending]': 'pending() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpFormField implements OnDestroy {\n /**\n * Store the form label.\n * @internal\n */\n readonly labels = signal<string[]>([]);\n\n /**\n * Store the form descriptions.\n * @internal\n */\n readonly descriptions = signal<string[]>([]);\n\n /**\n * Store the id of the associated form control.\n * @internal\n */\n readonly formControl = signal<string | null>(null);\n\n /**\n * Find any NgControl within the form field.\n * @internal\n */\n private readonly ngControl = contentChild(NgControl);\n\n /**\n * Store the validation error messages.\n * @internal\n */\n readonly errors = signal<string[]>([]);\n\n /**\n * Whether the control is pristine.\n * @internal\n */\n readonly pristine = signal<boolean | null>(null);\n\n /**\n * Whether the control is touched.\n * @internal\n */\n readonly touched = signal<boolean | null>(null);\n\n /**\n * Whether the control is dirty.\n * @internal\n */\n readonly dirty = signal<boolean | null>(null);\n\n /**\n * Whether the control is valid.\n */\n readonly valid = signal<boolean | null>(null);\n\n /**\n * Whether the control is invalid.\n * @internal\n */\n readonly invalid = signal<boolean | null>(null);\n\n /**\n * Whether the control is pending.\n * @internal\n */\n readonly pending = signal<boolean | null>(null);\n\n /**\n * Whether the control is disabled.\n * @internal\n */\n readonly disabled = signal<boolean | null>(null);\n\n /**\n * Store the current status subscription.\n */\n private subscription?: Subscription;\n\n /**\n * The form field state.\n */\n protected readonly state = formFieldState<NgpFormField>(this);\n\n constructor() {\n // any time the ngControl changes, setup the subscriptions.\n onChange(this.ngControl, this.setupSubscriptions.bind(this));\n }\n\n ngOnDestroy(): void {\n this.subscription?.unsubscribe();\n }\n\n /**\n * Setup a listener for the form control status.\n * @param control\n */\n private setupSubscriptions(control: NgControl | null | undefined): void {\n // Unsubscribe from the previous subscriptions.\n this.subscription?.unsubscribe();\n\n // set the initial values\n this.updateStatus();\n\n const underlyingControl = control?.control;\n\n // Listen for changes to the underlying control's status.\n this.subscription = underlyingControl?.events?.subscribe(this.updateStatus.bind(this));\n }\n\n private updateStatus(): void {\n const control = this.ngControl();\n\n if (!control) {\n return;\n }\n\n this.pristine.set(control.pristine);\n this.touched.set(control.touched);\n this.dirty.set(control.dirty);\n this.valid.set(control.valid);\n this.invalid.set(control.invalid);\n this.pending.set(control.pending);\n this.disabled.set(control.disabled);\n this.errors.set(control?.errors ? Object.keys(control.errors) : []);\n }\n\n /**\n * Register the id of the associated form control.\n * @param id\n * @internal\n */\n setFormControl(id: string): void {\n this.formControl.set(id);\n }\n\n /**\n * Register a label with the form field.\n * @param label\n * @internal\n */\n addLabel(label: string): void {\n this.labels.update(labels => [...labels, label]);\n }\n\n /**\n * Register a description with the form field.\n * @param description\n * @internal\n */\n addDescription(description: string): void {\n this.descriptions.update(descriptions => [...descriptions, description]);\n }\n\n /**\n * Remove the associated form control.\n * @internal\n */\n removeFormControl(): void {\n this.formControl.set(null);\n }\n\n /**\n * Remove a label from the form field.\n * @param label\n * @internal\n */\n removeLabel(label: string): void {\n this.labels.update(labels => labels.filter(l => l !== label));\n }\n\n /**\n * Remove a description from the form field.\n * @param description\n * @internal\n */\n removeDescription(description: string): void {\n this.descriptions.update(descriptions => descriptions.filter(d => d !== description));\n }\n}\n","import {\n computed,\n Directive,\n effect,\n ElementRef,\n HostListener,\n inject,\n input,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpLabel` directive is used to mark a label element within a form field. Preferably, there should use an HTML `<label>` element.\n */\n@Directive({\n selector: '[ngpLabel]',\n exportAs: 'ngpLabel',\n host: {\n '[attr.id]': 'id()',\n '[attr.for]': 'htmlFor()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpLabel {\n /**\n * The id of the label. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-label'));\n /**\n * Access the form field that the label is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n /**\n * Derive the for attribute value if the label is an HTML label element.\n */\n protected readonly htmlFor = computed(() => this.formField()?.formControl());\n /**\n * Access the element that the label is associated with.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n /**\n * Determine if the label is an HTML label element.\n */\n protected readonly isLabel = this.elementRef.nativeElement instanceof HTMLLabelElement;\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addLabel(this.id());\n onCleanup(() => this.formField()?.removeLabel(this.id()));\n });\n }\n\n @HostListener('click', ['$event'])\n protected onClick(event: MouseEvent): void {\n // by default a label will perform a click on the associated form control, however\n // this only works if the associated form control is an input element which may not always\n // be the case, so we prevent the default behavior and handle the click event ourselves.\n // This was inspired by the HeadlessUI approach:\n // https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/label/label.tsx#L58\n if (this.isLabel) {\n event.preventDefault();\n }\n\n // to find the associated form control we can lookup via the known id\n const targetId = this.htmlFor();\n\n if (!targetId) {\n return;\n }\n\n const target = document.getElementById(targetId);\n\n if (!target) {\n return;\n }\n\n // if the target is disabled then do nothing\n const disabled = target.getAttribute('disabled');\n const ariaDisabled = target.getAttribute('aria-disabled');\n\n if (disabled === '' || disabled === 'true' || ariaDisabled === 'true') {\n return;\n }\n\n // radio buttons, checkboxes and switches should all be clicked immediately as they require state changes\n if (\n (target instanceof HTMLInputElement &&\n (target.type === 'radio' || target.type === 'checkbox')) ||\n target.role === 'radio' ||\n target.role === 'checkbox' ||\n target.role === 'switch'\n ) {\n target.click();\n }\n\n // Move focus to the element, this allows you to start using keyboard shortcuts since the\n // bound element is now focused.\n target.focus({ preventScroll: true });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,sBAAsB;AAE/E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAe,sBAAsB;AAE5F;;AAEG;AACI,MAAM,cAAc,GAAG,WAAW,CAAC,sBAAsB,CAAC;;ACtBjE;;AAEG;MAeU,cAAc,CAAA;AAUzB,IAAA,WAAA,GAAA;AATA;;AAEG;QACM,IAAE,CAAA,EAAA,GAAG,KAAK,CAAS,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AACxD;;AAEG;QACgB,IAAS,CAAA,SAAA,GAAG,oBAAoB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAGrE,MAAM,CAAC,SAAS,IAAG;YACjB,IAAI,CAAC,SAAS,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AAC3C,YAAA,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACjE,SAAC,CAAC;;+GAdO,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAAd,cAAc,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,EAAA,EAAA,EAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,SAAA,E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AAA,UAAA,EAAA,EAAA,SAAA,EAAA,MAAA,EAAA,UAAA,EAAA,WAAA,EAAA,mBAAA,EAAA,sCAAA,EAAA,iBAAA,EAAA,oCAAA,EAAA,mBAAA,EAAA,sCAAA,EAAA,oBAAA,EAAA,uCAAA,EAAA,iBAAA,EAAA,oCAAA,EAAA,mBAAA,EAAA,sCAAA,EAAA,oBAAA,EAAA,uCAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,UAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAfpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,YAAY,EAAE,WAAW;AACzB,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC7D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC9D,qBAAA;AACF,iBAAA;wDA+BW,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;;;AC3DnC;;AAEG;;;;"}
@@ -55,11 +55,12 @@ class NgpInput {
55
55
  focus: true,
56
56
  disabled: this.state.disabled,
57
57
  });
58
- setupFormControl({ id: this.state.id, disabled: this.state.disabled });
58
+ // Set up the form control with the id and disabled state.
59
+ this.status = setupFormControl({ id: this.state.id, disabled: this.state.disabled });
59
60
  this.searchState()?.registerInput(this.elementRef.nativeElement);
60
61
  }
61
62
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
62
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpInput, isStandalone: true, selector: "input[ngpInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.id": "id()", "attr.disabled": "disabled() ? \"\" : null" } }, providers: [provideInputState()], exportAs: ["ngpInput"], hostDirectives: [{ directive: i1.NgpAutofill }], ngImport: i0 }); }
63
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpInput, isStandalone: true, selector: "input[ngpInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.id": "id()", "attr.disabled": "status().disabled ? \"\" : null" } }, providers: [provideInputState()], exportAs: ["ngpInput"], hostDirectives: [{ directive: i1.NgpAutofill }], ngImport: i0 }); }
63
64
  }
64
65
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpInput, decorators: [{
65
66
  type: Directive,
@@ -70,7 +71,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
70
71
  hostDirectives: [NgpAutofill],
71
72
  host: {
72
73
  '[attr.id]': 'id()',
73
- '[attr.disabled]': 'disabled() ? "" : null',
74
+ '[attr.disabled]': 'status().disabled ? "" : null',
74
75
  },
75
76
  }]
76
77
  }], ctorParameters: () => [] });
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-input.mjs","sources":["../../../../packages/ng-primitives/input/src/input/input-state.ts","../../../../packages/ng-primitives/input/src/input/input.ts","../../../../packages/ng-primitives/input/src/ng-primitives-input.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpInput } from './input';\n\n/**\n * The state token for the Input primitive.\n */\nexport const NgpInputStateToken = createStateToken<NgpInput>('Input');\n\n/**\n * Provides the Input state.\n */\nexport const provideInputState = createStateProvider(NgpInputStateToken);\n\n/**\n * Injects the Input state.\n */\nexport const injectInputState = createStateInjector<NgpInput>(NgpInputStateToken);\n\n/**\n * The Input state registration function.\n */\nexport const inputState = createState(NgpInputStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { NgpAutofill } from 'ng-primitives/autofill';\nimport { setupFormControl } from 'ng-primitives/form-field';\nimport { injectElementRef, setupInteractions } from 'ng-primitives/internal';\nimport { injectSearchState } from 'ng-primitives/search';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { inputState, provideInputState } from './input-state';\n\n@Directive({\n selector: 'input[ngpInput]',\n exportAs: 'ngpInput',\n providers: [provideInputState()],\n hostDirectives: [NgpAutofill],\n host: {\n '[attr.id]': 'id()',\n '[attr.disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpInput {\n /**\n * The id of the input.\n */\n readonly id = input(uniqueId('ngp-input'));\n\n /**\n * The input may be used within a search field, if so we need to register it.\n */\n private readonly searchState = injectSearchState({ optional: true });\n\n /**\n * Access the element reference.\n */\n private readonly elementRef = injectElementRef<HTMLInputElement>();\n\n /**\n * Whether the element is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\n });\n\n /**\n * The input state.\n */\n protected readonly state = inputState<NgpInput>(this);\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focus: true,\n disabled: this.state.disabled,\n });\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n\n this.searchState()?.registerInput(this.elementRef.nativeElement);\n }\n}\n","/**\n * Generated bundle index. Do not ed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;;AClBD;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-input.mjs","sources":["../../../../packages/ng-primitives/input/src/input/input-state.ts","../../../../packages/ng-primitives/input/src/input/input.ts","../../../../packages/ng-primitives/input/src/ng-primitives-input.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpInput } from './input';\n\n/**\n * The state token for the Input primitive.\n */\nexport const NgpInputStateToken = createStateToken<NgpInput>('Input');\n\n/**\n * Provides the Input state.\n */\nexport const provideInputState = createStateProvider(NgpInputStateToken);\n\n/**\n * Injects the Input state.\n */\nexport const injectInputState = createStateInjector<NgpInput>(NgpInputStateToken);\n\n/**\n * The Input state registration function.\n */\nexport const inputState = createState(NgpInputStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, Signal } from '@angular/core';\nimport { NgpAutofill } from 'ng-primitives/autofill';\nimport { setupFormControl } from 'ng-primitives/form-field';\nimport { injectElementRef, setupInteractions } from 'ng-primitives/internal';\nimport { injectSearchState } from 'ng-primitives/search';\nimport { NgpControlStatus, uniqueId } from 'ng-primitives/utils';\nimport { inputState, provideInputState } from './input-state';\n\n@Directive({\n selector: 'input[ngpInput]',\n exportAs: 'ngpInput',\n providers: [provideInputState()],\n hostDirectives: [NgpAutofill],\n host: {\n '[attr.id]': 'id()',\n '[attr.disabled]': 'status().disabled ? \"\" : null',\n },\n})\nexport class NgpInput {\n /**\n * The id of the input.\n */\n readonly id = input(uniqueId('ngp-input'));\n\n /**\n * The input may be used within a search field, if so we need to register it.\n */\n private readonly searchState = injectSearchState({ optional: true });\n\n /**\n * Access the element reference.\n */\n private readonly elementRef = injectElementRef<HTMLInputElement>();\n\n /**\n * Whether the element is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\n });\n\n /**\n * The form control status.\n */\n protected readonly status: Signal<NgpControlStatus>;\n\n /**\n * The input state.\n */\n protected readonly state = inputState<NgpInput>(this);\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focus: true,\n disabled: this.state.disabled,\n });\n\n // Set up the form control with the id and disabled state.\n this.status = setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n\n this.searchState()?.registerInput(this.elementRef.nativeElement);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAQA;;AAEG;AACI,MAAM,kBAAkB,GAAG,gBAAgB,CAAW,OAAO,CAAC;AAErE;;AAEG;MACU,iBAAiB,GAAG,mBAAmB,CAAC,kBAAkB;AAEvE;;AAEG;MACU,gBAAgB,GAAG,mBAAmB,CAAW,kBAAkB;AAEhF;;AAEG;AACI,MAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC;;MCP5C,QAAQ,CAAA;AAiCnB,IAAA,WAAA,GAAA;AAhCA;;AAEG;QACM,IAAE,CAAA,EAAA,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAE1C;;AAEG;QACc,IAAW,CAAA,WAAA,GAAG,iBAAiB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEpE;;AAEG;QACc,IAAU,CAAA,UAAA,GAAG,gBAAgB,EAAoB;AAElE;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAOF;;AAEG;AACgB,QAAA,IAAA,CAAA,KAAK,GAAG,UAAU,CAAW,IAAI,CAAC;AAGnD,QAAA,iBAAiB,CAAC;AAChB,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;AAC9B,SAAA,CAAC;;QAGF,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,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C3B,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,SAAS,EAAE,CAAC,iBAAiB,EAAE,CAAC;oBAChC,cAAc,EAAE,CAAC,WAAW,CAAC;AAC7B,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,iBAAiB,EAAE,+BAA+B;AACnD,qBAAA;AACF,iBAAA;;;AClBD;;AAEG;;;;"}
@@ -1,8 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { inject, ElementRef, Injectable, Directive, Renderer2, signal, PLATFORM_ID, effect, untracked, CSP_NONCE } from '@angular/core';
3
3
  import { FocusMonitor } from '@angular/cdk/a11y';
4
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
- import { onBooleanChange, injectDisposables } from 'ng-primitives/utils';
4
+ import { safeTakeUntilDestroyed, onBooleanChange, injectDisposables } from 'ng-primitives/utils';
6
5
  import { isPlatformServer, DOCUMENT, isPlatformBrowser } from '@angular/common';
7
6
  import { fromResizeEvent } from 'ng-primitives/resize';
8
7
 
@@ -139,7 +138,7 @@ function setupFocus({ focus, blur, focusWithin = false, disabled = signal(false)
139
138
  const isFocused = signal(false);
140
139
  focusMonitor
141
140
  .monitor(elementRef, focusWithin)
142
- .pipe(takeUntilDestroyed())
141
+ .pipe(safeTakeUntilDestroyed())
143
142
  .subscribe(focusOrigin => {
144
143
  if (disabled()) {
145
144
  return;
@@ -181,7 +180,7 @@ function setupFocusVisible({ focusChange, disabled = signal(false), }) {
181
180
  // handle focus state
182
181
  focusMonitor
183
182
  .monitor(elementRef.nativeElement)
184
- .pipe(takeUntilDestroyed())
183
+ .pipe(safeTakeUntilDestroyed())
185
184
  .subscribe(origin =>
186
185
  // null indicates the element was blurred
187
186
  origin === null ? onBlur() : onFocus(origin));
@@ -271,7 +270,7 @@ function onDomRemoval(element, callback) {
271
270
  // This is a bit of a hack, but it works. If the element dimensions become zero,
272
271
  // it's likely that the element has been removed from the DOM.
273
272
  fromResizeEvent(element)
274
- .pipe(takeUntilDestroyed())
273
+ .pipe(safeTakeUntilDestroyed())
275
274
  .subscribe(dimensions => {
276
275
  // we check the dimensions first to short-circuit the check as it's faster
277
276
  if (dimensions.width === 0 && dimensions.height === 0 && !document.body.contains(element)) {
@@ -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/interactions/focus.ts","../../../../packages/ng-primitives/internal/src/interactions/focus-visible.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/signals/explicit-effect.ts","../../../../packages/ng-primitives/internal/src/signals/sync-state.ts","../../../../packages/ng-primitives/internal/src/style-injector/style-injector.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","import { FocusMonitor } from '@angular/cdk/a11y';\nimport { ElementRef, Renderer2, Signal, inject, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\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(takeUntilDestroyed())\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 { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { onBooleanChange } 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 /**\n * Access the element that the directive is applied to.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the renderer.\n */\n const renderer = inject(Renderer2);\n\n /**\n * Access the focus monitor.\n */\n const focusMonitor = inject(FocusMonitor);\n\n /**\n * Whether the element is currently focused.\n */\n const isFocused = signal<boolean>(false);\n\n // handle focus state\n focusMonitor\n .monitor(elementRef.nativeElement)\n .pipe(takeUntilDestroyed())\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","import { isPlatformServer } from '@angular/common';\nimport { inject, PLATFORM_ID } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { fromResizeEvent } from 'ng-primitives/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(takeUntilDestroyed())\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 /**\n * Access the element reference.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the disposables helper.\n */\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 { 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 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","/**\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, Signal, untracked, WritableSignal } from '@angular/core';\n\nexport function syncState<T>(source: Signal<T>, target: WritableSignal<T>) {\n effect(() => {\n const sourceValue = source();\n untracked(() => target.set(sourceValue));\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","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,IAAS,CAAA,SAAA,GAAuB,EAAE;AAmBpD;;AAhBC,IAAA,GAAG,CAAC,QAA0B,EAAA;AAC5B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;;;AAI/B,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,MAA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;;SAC9D,IAAI,WAAW,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE;QAC/C,kBAAkB,CAAC,UAAU,IAAI,WAAW,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK;;AAEzE;;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/interactions/focus.ts","../../../../packages/ng-primitives/internal/src/interactions/focus-visible.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/signals/explicit-effect.ts","../../../../packages/ng-primitives/internal/src/signals/sync-state.ts","../../../../packages/ng-primitives/internal/src/style-injector/style-injector.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","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 /**\n * Access the element that the directive is applied to.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the renderer.\n */\n const renderer = inject(Renderer2);\n\n /**\n * Access the focus monitor.\n */\n const focusMonitor = inject(FocusMonitor);\n\n /**\n * Whether the element is currently focused.\n */\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","import { isPlatformServer } from '@angular/common';\nimport { inject, PLATFORM_ID } from '@angular/core';\nimport { fromResizeEvent } from 'ng-primitives/resize';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\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 /**\n * Access the element reference.\n */\n const elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the disposables helper.\n */\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 { 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 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","/**\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, Signal, untracked, WritableSignal } from '@angular/core';\n\nexport function syncState<T>(source: Signal<T>, target: WritableSignal<T>) {\n effect(() => {\n const sourceValue = source();\n untracked(() => target.set(sourceValue));\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","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,IAAS,CAAA,SAAA,GAAuB,EAAE;AAmBpD;;AAhBC,IAAA,GAAG,CAAC,QAA0B,EAAA;AAC5B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;;;AAI/B,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,C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