ng-primitives 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/index.d.ts +1 -1
- package/a11y/visually-hidden/visually-hidden.token.d.ts +1 -1
- package/accordion/accordion/accordion.directive.d.ts +2 -2
- package/accordion/accordion/accordion.token.d.ts +1 -1
- package/accordion/accordion-content/accordion-content.token.d.ts +1 -1
- package/accordion/accordion-item/accordion-item.directive.d.ts +1 -1
- package/accordion/accordion-item/accordion-item.token.d.ts +1 -1
- package/accordion/accordion-trigger/accordion-trigger.token.d.ts +1 -1
- package/accordion/config/accordion.config.d.ts +1 -1
- package/accordion/index.d.ts +1 -1
- package/autofill/autofill/autofill.token.d.ts +1 -1
- package/autofill/index.d.ts +1 -1
- package/avatar/avatar/avatar.token.d.ts +1 -1
- package/avatar/avatar-fallback/avatar-fallback.directive.d.ts +1 -1
- package/avatar/avatar-image/avatar-image.directive.d.ts +1 -1
- package/avatar/config/avatar.config.d.ts +1 -1
- package/avatar/index.d.ts +1 -1
- package/button/button/button.directive.d.ts +1 -1
- package/button/button/button.token.d.ts +1 -1
- package/button/index.d.ts +1 -1
- package/checkbox/checkbox/checkbox.directive.d.ts +1 -1
- package/checkbox/checkbox/checkbox.token.d.ts +1 -1
- package/checkbox/index.d.ts +1 -1
- package/esm2022/a11y/index.mjs +2 -2
- package/esm2022/a11y/visually-hidden/visually-hidden.directive.mjs +2 -2
- package/esm2022/a11y/visually-hidden/visually-hidden.token.mjs +2 -2
- package/esm2022/accordion/accordion/accordion.directive.mjs +1 -1
- package/esm2022/accordion/accordion/accordion.token.mjs +2 -2
- package/esm2022/accordion/accordion-content/accordion-content.directive.mjs +2 -2
- package/esm2022/accordion/accordion-content/accordion-content.token.mjs +2 -2
- package/esm2022/accordion/accordion-item/accordion-item.directive.mjs +1 -1
- package/esm2022/accordion/accordion-item/accordion-item.token.mjs +2 -2
- package/esm2022/accordion/accordion-trigger/accordion-trigger.directive.mjs +2 -2
- package/esm2022/accordion/accordion-trigger/accordion-trigger.token.mjs +2 -2
- package/esm2022/accordion/config/accordion.config.mjs +2 -2
- package/esm2022/accordion/index.mjs +2 -2
- package/esm2022/autofill/autofill/autofill.directive.mjs +2 -2
- package/esm2022/autofill/autofill/autofill.token.mjs +2 -2
- package/esm2022/autofill/index.mjs +2 -2
- package/esm2022/avatar/avatar/avatar.directive.mjs +2 -2
- package/esm2022/avatar/avatar/avatar.token.mjs +2 -2
- package/esm2022/avatar/avatar-fallback/avatar-fallback.directive.mjs +1 -1
- package/esm2022/avatar/avatar-image/avatar-image.directive.mjs +2 -2
- package/esm2022/avatar/config/avatar.config.mjs +2 -2
- package/esm2022/avatar/index.mjs +2 -2
- package/esm2022/button/button/button.directive.mjs +1 -1
- package/esm2022/button/button/button.token.mjs +2 -2
- package/esm2022/button/index.mjs +2 -2
- package/esm2022/checkbox/checkbox/checkbox.directive.mjs +1 -1
- package/esm2022/checkbox/checkbox/checkbox.token.mjs +2 -2
- package/esm2022/checkbox/index.mjs +2 -2
- package/esm2022/file-upload/file-upload/file-upload.directive.mjs +2 -2
- package/esm2022/file-upload/file-upload/file-upload.token.mjs +2 -2
- package/esm2022/file-upload/index.mjs +2 -2
- package/esm2022/focus-trap/focus-trap/focus-trap.directive.mjs +2 -2
- package/esm2022/focus-trap/focus-trap/focus-trap.token.mjs +2 -2
- package/esm2022/focus-trap/index.mjs +2 -2
- package/esm2022/form-field/description/description.directive.mjs +2 -2
- package/esm2022/form-field/description/description.token.mjs +2 -2
- package/esm2022/form-field/error/error.directive.mjs +2 -2
- package/esm2022/form-field/error/error.token.mjs +2 -2
- package/esm2022/form-field/form-control/form-control.directive.mjs +2 -2
- package/esm2022/form-field/form-control/form-control.token.mjs +2 -2
- package/esm2022/form-field/form-field/form-field.directive.mjs +2 -2
- package/esm2022/form-field/form-field/form-field.token.mjs +2 -2
- package/esm2022/form-field/index.mjs +2 -2
- package/esm2022/form-field/label/label.directive.mjs +2 -2
- package/esm2022/form-field/label/label.token.mjs +2 -2
- package/esm2022/index.mjs +2 -2
- package/esm2022/input/index.mjs +2 -2
- package/esm2022/input/input/input.directive.mjs +1 -1
- package/esm2022/input/input/input.token.mjs +2 -2
- package/esm2022/interactions/focus/focus.directive.mjs +1 -1
- package/esm2022/interactions/focus/focus.token.mjs +2 -2
- package/esm2022/interactions/focus-visible/focus-visible.directive.mjs +2 -2
- package/esm2022/interactions/focus-visible/focus-visible.token.mjs +2 -2
- package/esm2022/interactions/hover/hover.directive.mjs +1 -1
- package/esm2022/interactions/hover/hover.token.mjs +2 -2
- package/esm2022/interactions/index.mjs +2 -2
- package/esm2022/interactions/move/move.directive.mjs +1 -1
- package/esm2022/interactions/move/move.token.mjs +2 -2
- package/esm2022/interactions/press/press.directive.mjs +1 -1
- package/esm2022/interactions/press/press.token.mjs +2 -2
- package/esm2022/internal/disabled/disabled.mjs +2 -2
- package/esm2022/internal/index.mjs +2 -2
- package/esm2022/internal/orientation/orientation.mjs +2 -2
- package/esm2022/internal/style-injector/style-injector.mjs +2 -2
- package/esm2022/progress/index.mjs +2 -2
- package/esm2022/progress/progress/progress.directive.mjs +1 -1
- package/esm2022/progress/progress/progress.token.mjs +2 -2
- package/esm2022/progress/progress-indicator/progress-indicator.directive.mjs +2 -2
- package/esm2022/radio/index.mjs +2 -2
- package/esm2022/radio/radio-group/radio-group.directive.mjs +1 -1
- package/esm2022/radio/radio-group/radio-group.token.mjs +2 -2
- package/esm2022/radio/radio-indicator/radio-indicator.directive.mjs +2 -2
- package/esm2022/radio/radio-item/radio-item.directive.mjs +1 -1
- package/esm2022/radio/radio-item/radio-item.token.mjs +2 -2
- package/esm2022/resize/index.mjs +2 -2
- package/esm2022/resize/resize/resize.directive.mjs +2 -2
- package/esm2022/resize/utils/resize.mjs +2 -2
- package/esm2022/roving-focus/index.mjs +2 -2
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.directive.mjs +1 -1
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.token.mjs +2 -2
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.directive.mjs +2 -2
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.token.mjs +2 -2
- package/esm2022/search/index.mjs +2 -2
- package/esm2022/search/search-field/search-field.directive.mjs +2 -2
- package/esm2022/search/search-field/search-field.token.mjs +2 -2
- package/esm2022/select/index.mjs +2 -2
- package/esm2022/select/select/select.directive.mjs +1 -1
- package/esm2022/select/select/select.token.mjs +2 -2
- package/esm2022/slider/index.mjs +2 -2
- package/esm2022/slider/slider/slider.directive.mjs +1 -1
- package/esm2022/slider/slider/slider.token.mjs +2 -2
- package/esm2022/slider/slider-range/slider-range.directive.mjs +2 -2
- package/esm2022/slider/slider-range/slider-range.token.mjs +2 -2
- package/esm2022/slider/slider-thumb/slider-thumb.directive.mjs +2 -2
- package/esm2022/slider/slider-thumb/slider-thumb.token.mjs +2 -2
- package/esm2022/slider/slider-track/slider-track.directive.mjs +2 -2
- package/esm2022/slider/slider-track/slider-track.token.mjs +2 -2
- package/esm2022/switch/index.mjs +2 -2
- package/esm2022/switch/switch/switch.directive.mjs +1 -1
- package/esm2022/switch/switch/switch.token.mjs +2 -2
- package/esm2022/switch/switch-thumb/switch-thumb.directive.mjs +2 -2
- package/esm2022/tabs/config/tabs.config.mjs +2 -2
- package/esm2022/tabs/index.mjs +2 -2
- package/esm2022/tabs/tab-button/tab-button.directive.mjs +1 -1
- package/esm2022/tabs/tab-list/tab-list.directive.mjs +2 -2
- package/esm2022/tabs/tab-panel/tab-panel.directive.mjs +2 -2
- package/esm2022/tabs/tab-panel/tab-panel.token.mjs +2 -2
- package/esm2022/tabs/tabset/tabset.directive.mjs +1 -1
- package/esm2022/tabs/tabset/tabset.token.mjs +2 -2
- package/esm2022/textarea/index.mjs +2 -2
- package/esm2022/textarea/textarea/textarea.directive.mjs +1 -1
- package/esm2022/textarea/textarea/textarea.token.mjs +2 -2
- package/esm2022/toggle/index.mjs +2 -2
- package/esm2022/toggle/toggle/toggle.directive.mjs +1 -1
- package/esm2022/tooltip/config/tooltip.config.mjs +2 -2
- package/esm2022/tooltip/index.mjs +2 -2
- package/esm2022/tooltip/tooltip/tooltip.directive.mjs +2 -2
- package/esm2022/tooltip/tooltip/tooltip.token.mjs +2 -2
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.directive.mjs +1 -1
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.token.mjs +2 -2
- package/esm2022/utils/helpers/disposables.mjs +2 -2
- package/esm2022/utils/helpers/focus-manager.mjs +1 -1
- package/esm2022/utils/helpers/unique-id.mjs +2 -2
- package/esm2022/utils/index.mjs +2 -2
- package/esm2022/utils/signals/async.mjs +2 -2
- package/esm2022/utils/ui/dimensions.mjs +2 -2
- package/fesm2022/ng-primitives-a11y.mjs +3 -3
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
- package/fesm2022/ng-primitives-accordion.mjs +8 -8
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/ng-primitives-autofill.mjs +3 -3
- package/fesm2022/ng-primitives-autofill.mjs.map +1 -1
- package/fesm2022/ng-primitives-avatar.mjs +5 -5
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/ng-primitives-button.mjs +2 -2
- package/fesm2022/ng-primitives-button.mjs.map +1 -1
- package/fesm2022/ng-primitives-checkbox.mjs +2 -2
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs +3 -3
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-focus-trap.mjs +3 -3
- package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
- package/fesm2022/ng-primitives-form-field.mjs +11 -11
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-input.mjs +2 -2
- package/fesm2022/ng-primitives-input.mjs.map +1 -1
- package/fesm2022/ng-primitives-interactions.mjs +7 -7
- package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +4 -4
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-progress.mjs +3 -3
- package/fesm2022/ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/ng-primitives-radio.mjs +4 -4
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-resize.mjs +3 -3
- package/fesm2022/ng-primitives-resize.mjs.map +1 -1
- package/fesm2022/ng-primitives-roving-focus.mjs +4 -4
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/ng-primitives-search.mjs +3 -3
- package/fesm2022/ng-primitives-search.mjs.map +1 -1
- package/fesm2022/ng-primitives-select.mjs +2 -2
- package/fesm2022/ng-primitives-select.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs +8 -8
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/ng-primitives-switch.mjs +3 -3
- package/fesm2022/ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs +6 -6
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-textarea.mjs +2 -2
- package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
- package/fesm2022/ng-primitives-toggle.mjs +1 -1
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +5 -5
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +5 -5
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/fesm2022/ng-primitives.mjs +1 -1
- package/fesm2022/ng-primitives.mjs.map +1 -1
- package/file-upload/file-upload/file-upload.directive.d.ts +1 -1
- package/file-upload/file-upload/file-upload.token.d.ts +1 -1
- package/file-upload/index.d.ts +1 -1
- package/focus-trap/focus-trap/focus-trap.token.d.ts +1 -1
- package/focus-trap/index.d.ts +1 -1
- package/form-field/description/description.token.d.ts +1 -1
- package/form-field/error/error.directive.d.ts +1 -1
- package/form-field/error/error.token.d.ts +1 -1
- package/form-field/form-control/form-control.token.d.ts +1 -1
- package/form-field/form-field/form-field.directive.d.ts +1 -1
- package/form-field/form-field/form-field.token.d.ts +1 -1
- package/form-field/index.d.ts +1 -1
- package/form-field/label/label.token.d.ts +1 -1
- package/index.d.ts +1 -1
- package/input/index.d.ts +1 -1
- package/input/input/input.directive.d.ts +1 -1
- package/input/input/input.token.d.ts +1 -1
- package/interactions/focus/focus.directive.d.ts +1 -1
- package/interactions/focus/focus.token.d.ts +1 -1
- package/interactions/focus-visible/focus-visible.token.d.ts +1 -1
- package/interactions/hover/hover.directive.d.ts +1 -1
- package/interactions/hover/hover.token.d.ts +1 -1
- package/interactions/index.d.ts +1 -1
- package/interactions/move/move.directive.d.ts +1 -1
- package/interactions/move/move.token.d.ts +1 -1
- package/interactions/press/press.directive.d.ts +1 -1
- package/interactions/press/press.token.d.ts +1 -1
- package/internal/disabled/disabled.d.ts +1 -1
- package/internal/index.d.ts +1 -1
- package/internal/orientation/orientation.d.ts +1 -1
- package/package.json +19 -19
- package/progress/index.d.ts +1 -1
- package/progress/progress/progress.directive.d.ts +1 -1
- package/progress/progress/progress.token.d.ts +1 -1
- package/radio/index.d.ts +1 -1
- package/radio/radio-group/radio-group.directive.d.ts +1 -1
- package/radio/radio-group/radio-group.token.d.ts +1 -1
- package/radio/radio-item/radio-item.directive.d.ts +1 -1
- package/radio/radio-item/radio-item.token.d.ts +1 -1
- package/resize/index.d.ts +1 -1
- package/resize/resize/resize.directive.d.ts +1 -1
- package/resize/utils/resize.d.ts +1 -1
- package/roving-focus/index.d.ts +1 -1
- package/roving-focus/roving-focus-group/roving-focus-group.directive.d.ts +1 -1
- package/roving-focus/roving-focus-group/roving-focus-group.token.d.ts +1 -1
- package/roving-focus/roving-focus-item/roving-focus-item.directive.d.ts +1 -1
- package/roving-focus/roving-focus-item/roving-focus-item.token.d.ts +1 -1
- package/search/index.d.ts +1 -1
- package/search/search-field/search-field.token.d.ts +1 -1
- package/select/index.d.ts +1 -1
- package/select/select/select.directive.d.ts +1 -1
- package/select/select/select.token.d.ts +1 -1
- package/slider/index.d.ts +1 -1
- package/slider/slider/slider.directive.d.ts +1 -1
- package/slider/slider/slider.token.d.ts +1 -1
- package/slider/slider-range/slider-range.token.d.ts +1 -1
- package/slider/slider-thumb/slider-thumb.token.d.ts +1 -1
- package/slider/slider-track/slider-track.directive.d.ts +1 -1
- package/slider/slider-track/slider-track.token.d.ts +1 -1
- package/switch/index.d.ts +1 -1
- package/switch/switch/switch.directive.d.ts +1 -1
- package/switch/switch/switch.token.d.ts +1 -1
- package/tabs/config/tabs.config.d.ts +1 -1
- package/tabs/index.d.ts +1 -1
- package/tabs/tab-button/tab-button.directive.d.ts +1 -1
- package/tabs/tab-panel/tab-panel.token.d.ts +1 -1
- package/tabs/tabset/tabset.directive.d.ts +1 -1
- package/tabs/tabset/tabset.token.d.ts +1 -1
- package/textarea/index.d.ts +1 -1
- package/textarea/textarea/textarea.directive.d.ts +1 -1
- package/textarea/textarea/textarea.token.d.ts +1 -1
- package/toggle/index.d.ts +1 -1
- package/toggle/toggle/toggle.directive.d.ts +1 -1
- package/tooltip/config/tooltip.config.d.ts +1 -1
- package/tooltip/index.d.ts +1 -1
- package/tooltip/tooltip/tooltip.directive.d.ts +1 -1
- package/tooltip/tooltip/tooltip.token.d.ts +1 -1
- package/tooltip/tooltip-trigger/tooltip-trigger.directive.d.ts +1 -1
- package/tooltip/tooltip-trigger/tooltip-trigger.token.d.ts +1 -1
- package/utils/helpers/focus-manager.d.ts +1 -1
- package/utils/helpers/unique-id.d.ts +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/signals/async.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-focus-trap.mjs","sources":["../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.token.ts","../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.directive.ts","../../../../packages/ng-primitives/focus-trap/src/index.ts","../../../../packages/ng-primitives/focus-trap/src/ng-primitives-focus-trap.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpFocusTrap } from './focus-trap.directive';\n\nexport const NgpFocusTrapToken = new InjectionToken<NgpFocusTrap>('NgpFocusTrapToken');\n\n/**\n * Inject the FocusTrap directive instance\n */\nexport function injectFocusTrap(): NgpFocusTrap {\n return inject(NgpFocusTrapToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InteractivityChecker } from '@angular/cdk/a11y';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n NgZone,\n OnDestroy,\n OnInit,\n} from '@angular/core';\nimport { NgpFocusTrapToken } from './focus-trap.token';\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@Directive({\n standalone: true,\n selector: '[ngpFocusTrap]',\n exportAs: 'ngpFocusTrap',\n providers: [{ provide: NgpFocusTrapToken, useExisting: NgpFocusTrap }],\n host: {\n '[attr.tabindex]': '-1',\n '[attr.data-focus-trap]': '!disabled()',\n },\n})\nexport class NgpFocusTrap implements OnInit, OnDestroy {\n /**\n * Create a new focus trap.\n */\n private readonly focusTrap = new FocusTrap();\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(false, {\n alias: 'ngpFocusTrapDisabled',\n transform: booleanAttribute,\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 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\n ngOnDestroy(): void {\n focusTrapStack.remove(this.focusTrap);\n this.mutationObserver?.disconnect();\n }\n\n private handleFocusIn(event: FocusEvent): void {\n if (!this.focusTrap.active || this.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.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.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) {\n element?.focus({ preventScroll: true });\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 * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpFocusTrap } from './focus-trap/focus-trap.directive';\nexport { NgpFocusTrapToken } from './focus-trap/focus-trap.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMG;MAIU,iBAAiB,GAAG,IAAI,cAAc,CAAe,mBAAmB,EAAE;AAEvF;;AAEG;SACa,eAAe,GAAA;AAC7B,IAAA,OAAO,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACnC;;ACjBA;;;;;;AA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AE,CAAC,EAAA,QAAA,EAAA,CAAA,cAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FAM3D,YAAY,EAAA,UAAA,EAAA,CAAA;kBAVxB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,QAAQ,EAAE,cAAc;oBACxB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAc,YAAA,EAAE,CAAC;AACtE,oBAAA,IAAI,EAAE;AACJ,wBAAA,iBAAiB,EAAE,IAAI;AACvB,wBAAA,wBAAwB,EAAE,aAAa;AACxC,qBAAA;AACF,iBAAA,CAAA;8BA4HW,aAAa,EAAA,CAAA;sBADtB,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAA;;;AC5NrC;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-focus-trap.mjs","sources":["../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.token.ts","../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.directive.ts","../../../../packages/ng-primitives/focus-trap/src/index.ts","../../../../packages/ng-primitives/focus-trap/src/ng-primitives-focus-trap.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpFocusTrap } from './focus-trap.directive';\n\nexport const NgpFocusTrapToken = new InjectionToken<NgpFocusTrap>('NgpFocusTrapToken');\n\n/**\n * Inject the FocusTrap directive instance\n */\nexport function injectFocusTrap(): NgpFocusTrap {\n return inject(NgpFocusTrapToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InteractivityChecker } from '@angular/cdk/a11y';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n NgZone,\n OnDestroy,\n OnInit,\n} from '@angular/core';\nimport { NgpFocusTrapToken } from './focus-trap.token';\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@Directive({\n standalone: true,\n selector: '[ngpFocusTrap]',\n exportAs: 'ngpFocusTrap',\n providers: [{ provide: NgpFocusTrapToken, useExisting: NgpFocusTrap }],\n host: {\n '[attr.tabindex]': '-1',\n '[attr.data-focus-trap]': '!disabled()',\n },\n})\nexport class NgpFocusTrap implements OnInit, OnDestroy {\n /**\n * Create a new focus trap.\n */\n private readonly focusTrap = new FocusTrap();\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(false, {\n alias: 'ngpFocusTrapDisabled',\n transform: booleanAttribute,\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 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\n ngOnDestroy(): void {\n focusTrapStack.remove(this.focusTrap);\n this.mutationObserver?.disconnect();\n }\n\n private handleFocusIn(event: FocusEvent): void {\n if (!this.focusTrap.active || this.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.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.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) {\n element?.focus({ preventScroll: true });\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 * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpFocusTrap } from './focus-trap/focus-trap.directive';\nexport { NgpFocusTrapToken } from './focus-trap/focus-trap.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMG;MAIU,iBAAiB,GAAG,IAAI,cAAc,CAAe,mBAAmB,EAAE;AAEvF;;AAEG;SACa,eAAe,GAAA;AAC7B,IAAA,OAAO,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACnC;;ACjBA;;;;;;AAMG;AAeH;;;AAGG;AAEH,MAAM,SAAS,CAAA;AAAf,IAAA,WAAA,GAAA;AACE;;AAEG;QACH,IAAM,CAAA,MAAA,GAAY,KAAK,CAAC;KAezB;AAbC;;AAEG;IACH,QAAQ,GAAA;AACN,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;KACpB;AAED;;AAEG;IACH,UAAU,GAAA;AACR,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;KACrB;AACF,CAAA;AAED,MAAM,cAAc,CAAA;AAApB,IAAA,WAAA,GAAA;AACE;;AAEG;QACc,IAAK,CAAA,KAAA,GAAgB,EAAE,CAAC;KAgC1C;AA9BC;;AAEG;AACH,IAAA,GAAG,CAAC,SAAoB,EAAA;;AAEtB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAA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,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAA;;;AC5NrC;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -8,7 +8,7 @@ import { injectDisabled } from 'ng-primitives/internal';
|
|
|
8
8
|
* Copyright © 2024 Angular Primitives.
|
|
9
9
|
* https://github.com/ng-primitives/ng-primitives
|
|
10
10
|
*
|
|
11
|
-
* This source code is licensed under the
|
|
11
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
12
12
|
* LICENSE file in the root directory of this source tree.
|
|
13
13
|
*/
|
|
14
14
|
const NgpFormFieldToken = new InjectionToken('NgpFormFieldToken');
|
|
@@ -24,7 +24,7 @@ function injectFormField() {
|
|
|
24
24
|
* Copyright © 2024 Angular Primitives.
|
|
25
25
|
* https://github.com/ng-primitives/ng-primitives
|
|
26
26
|
*
|
|
27
|
-
* This source code is licensed under the
|
|
27
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
28
28
|
* LICENSE file in the root directory of this source tree.
|
|
29
29
|
*/
|
|
30
30
|
class NgpFormField {
|
|
@@ -193,7 +193,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
193
193
|
* Copyright © 2024 Angular Primitives.
|
|
194
194
|
* https://github.com/ng-primitives/ng-primitives
|
|
195
195
|
*
|
|
196
|
-
* This source code is licensed under the
|
|
196
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
197
197
|
* LICENSE file in the root directory of this source tree.
|
|
198
198
|
*/
|
|
199
199
|
const NgpLabelToken = new InjectionToken('NgpLabelToken');
|
|
@@ -208,7 +208,7 @@ function injectLabel() {
|
|
|
208
208
|
* Copyright © 2024 Angular Primitives.
|
|
209
209
|
* https://github.com/ng-primitives/ng-primitives
|
|
210
210
|
*
|
|
211
|
-
* This source code is licensed under the
|
|
211
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
212
212
|
* LICENSE file in the root directory of this source tree.
|
|
213
213
|
*/
|
|
214
214
|
class NgpLabel {
|
|
@@ -305,7 +305,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
305
305
|
* Copyright © 2024 Angular Primitives.
|
|
306
306
|
* https://github.com/ng-primitives/ng-primitives
|
|
307
307
|
*
|
|
308
|
-
* This source code is licensed under the
|
|
308
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
309
309
|
* LICENSE file in the root directory of this source tree.
|
|
310
310
|
*/
|
|
311
311
|
const NgpDescriptionToken = new InjectionToken('NgpDescriptionToken');
|
|
@@ -320,7 +320,7 @@ function injectDescription() {
|
|
|
320
320
|
* Copyright © 2024 Angular Primitives.
|
|
321
321
|
* https://github.com/ng-primitives/ng-primitives
|
|
322
322
|
*
|
|
323
|
-
* This source code is licensed under the
|
|
323
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
324
324
|
* LICENSE file in the root directory of this source tree.
|
|
325
325
|
*/
|
|
326
326
|
class NgpDescription {
|
|
@@ -365,7 +365,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
365
365
|
* Copyright © 2024 Angular Primitives.
|
|
366
366
|
* https://github.com/ng-primitives/ng-primitives
|
|
367
367
|
*
|
|
368
|
-
* This source code is licensed under the
|
|
368
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
369
369
|
* LICENSE file in the root directory of this source tree.
|
|
370
370
|
*/
|
|
371
371
|
const NgpFormControlToken = new InjectionToken('NgpFormControlToken');
|
|
@@ -380,7 +380,7 @@ function injectFormControl() {
|
|
|
380
380
|
* Copyright © 2024 Angular Primitives.
|
|
381
381
|
* https://github.com/ng-primitives/ng-primitives
|
|
382
382
|
*
|
|
383
|
-
* This source code is licensed under the
|
|
383
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
384
384
|
* LICENSE file in the root directory of this source tree.
|
|
385
385
|
*/
|
|
386
386
|
class NgpFormControl {
|
|
@@ -439,7 +439,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
439
439
|
* Copyright © 2024 Angular Primitives.
|
|
440
440
|
* https://github.com/ng-primitives/ng-primitives
|
|
441
441
|
*
|
|
442
|
-
* This source code is licensed under the
|
|
442
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
443
443
|
* LICENSE file in the root directory of this source tree.
|
|
444
444
|
*/
|
|
445
445
|
const NgpErrorToken = new InjectionToken('NgpErrorToken');
|
|
@@ -454,7 +454,7 @@ function injectError() {
|
|
|
454
454
|
* Copyright © 2024 Angular Primitives.
|
|
455
455
|
* https://github.com/ng-primitives/ng-primitives
|
|
456
456
|
*
|
|
457
|
-
* This source code is licensed under the
|
|
457
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
458
458
|
* LICENSE file in the root directory of this source tree.
|
|
459
459
|
*/
|
|
460
460
|
class NgpError {
|
|
@@ -524,7 +524,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
524
524
|
* Copyright © 2024 Angular Primitives.
|
|
525
525
|
* https://github.com/ng-primitives/ng-primitives
|
|
526
526
|
*
|
|
527
|
-
* This source code is licensed under the
|
|
527
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
528
528
|
* LICENSE file in the root directory of this source tree.
|
|
529
529
|
*/
|
|
530
530
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-form-field.mjs","sources":["../../../../packages/ng-primitives/form-field/src/form-field/form-field.token.ts","../../../../packages/ng-primitives/form-field/src/form-field/form-field.directive.ts","../../../../packages/ng-primitives/form-field/src/label/label.token.ts","../../../../packages/ng-primitives/form-field/src/label/label.directive.ts","../../../../packages/ng-primitives/form-field/src/description/description.token.ts","../../../../packages/ng-primitives/form-field/src/description/description.directive.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.token.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.directive.ts","../../../../packages/ng-primitives/form-field/src/error/error.token.ts","../../../../packages/ng-primitives/form-field/src/error/error.directive.ts","../../../../packages/ng-primitives/form-field/src/index.ts","../../../../packages/ng-primitives/form-field/src/ng-primitives-form-field.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpFormField } from './form-field.directive';\n\nexport const NgpFormFieldToken = new InjectionToken<NgpFormField>('NgpFormFieldToken');\n\n/**\n * Inject the FormField directive instance\n * @param primitive\n */\nexport function injectFormField(): NgpFormField | null {\n return inject(NgpFormFieldToken, { optional: true });\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, OnDestroy, contentChild, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { onChange } from 'ng-primitives/utils';\nimport { Subscription } from 'rxjs';\nimport { NgpFormFieldToken } from './form-field.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpFormField]',\n exportAs: 'ngpFormField',\n providers: [{ provide: NgpFormFieldToken, useExisting: NgpFormField }],\n host: {\n '[attr.data-invalid]': 'invalid()',\n '[attr.data-valid]': 'valid()',\n '[attr.data-touched]': 'touched()',\n '[attr.data-pristine]': 'pristine()',\n '[attr.data-dirty]': 'dirty()',\n '[attr.data-pending]': 'pending()',\n '[attr.data-disabled]': 'disabled()',\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 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 // Listen for changes to the form control.\n this.subscription = control?.valueChanges?.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","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpLabel } from './label.directive';\n\nexport const NgpLabelToken = new InjectionToken<NgpLabel>('NgpLabelToken');\n\n/**\n * Inject the Label directive instance\n */\nexport function injectLabel(): NgpLabel {\n return inject(NgpLabelToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport {\n Directive,\n ElementRef,\n HostListener,\n computed,\n effect,\n inject,\n input,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpLabelToken } from './label.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpLabel]',\n exportAs: 'ngpLabel',\n providers: [{ provide: NgpLabelToken, useExisting: NgpLabel }],\n host: {\n '[attr.id]': 'id()',\n '[attr.for]': 'htmlFor()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled()',\n },\n})\nexport class NgpLabel {\n /**\n * Access the element that the label is associated with.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the form field that the label is associated with.\n */\n protected readonly formField = injectFormField();\n\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 /**\n * Determine if the label is an HTML label element.\n */\n protected readonly isLabel = this.elementRef.nativeElement instanceof HTMLLabelElement;\n\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 constructor() {\n effect(\n onCleanup => {\n this.formField?.addLabel(this.id());\n onCleanup(() => this.formField?.removeLabel(this.id()));\n },\n { allowSignalWrites: true },\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 * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpDescription } from './description.directive';\n\nexport const NgpDescriptionToken = new InjectionToken<NgpDescription>('NgpDescriptionToken');\n\n/**\n * Inject the Description directive instance\n */\nexport function injectDescription(): NgpDescription {\n return inject(NgpDescriptionToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, effect, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpDescriptionToken } from './description.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpDescription]',\n exportAs: 'ngpDescription',\n providers: [{ provide: NgpDescriptionToken, useExisting: NgpDescription }],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled()',\n },\n})\nexport class NgpDescription {\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormField();\n\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 constructor() {\n effect(\n onCleanup => {\n this.formField?.addDescription(this.id());\n onCleanup(() => this.formField?.removeDescription(this.id()));\n },\n { allowSignalWrites: true },\n );\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpFormControl } from './form-control.directive';\n\nexport const NgpFormControlToken = new InjectionToken<NgpFormControl>('NgpFormControlToken');\n\n/**\n * Inject the FormControl directive instance\n */\nexport function injectFormControl(): NgpFormControl {\n return inject(NgpFormControlToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, computed, effect, input } from '@angular/core';\nimport { injectDisabled } from 'ng-primitives/internal';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpFormControlToken } from './form-control.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpFormControl]',\n exportAs: 'ngpFormControl',\n providers: [{ provide: NgpFormControlToken, useExisting: NgpFormControl }],\n host: {\n '[id]': 'id()',\n '[attr.aria-labelledby]': 'ariaLabelledBy()',\n '[attr.aria-describedby]': 'ariaDescribedBy()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled() || disabled()',\n },\n})\nexport class NgpFormControl {\n /**\n * Access the form field that the form control is associated with.\n */\n protected readonly formField = injectFormField();\n\n /**\n * Whether the form control is disabled by a parent.\n */\n protected readonly disabled = injectDisabled();\n\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 * Determine the aria-labelledby attribute value.\n */\n protected readonly ariaLabelledBy = computed(() => this.formField?.labels().join(' '));\n\n /**\n * Determine the aria-describedby attribute value.\n */\n protected readonly ariaDescribedBy = computed(() => this.formField?.descriptions().join(' '));\n\n constructor() {\n effect(\n onCleanup => {\n this.formField?.setFormControl(this.id());\n onCleanup(() => this.formField?.removeFormControl());\n },\n { allowSignalWrites: true },\n );\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpError } from './error.directive';\n\nexport const NgpErrorToken = new InjectionToken<NgpError>('NgpErrorToken');\n\n/**\n * Inject the Error directive instance\n */\nexport function injectError(): NgpError {\n return inject(NgpErrorToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, OnChanges, OnDestroy, SimpleChanges, computed, input } from '@angular/core';\nimport { onBooleanChange, uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpErrorToken } from './error.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpError]',\n exportAs: 'ngpError',\n providers: [{ provide: NgpErrorToken, useExisting: NgpError }],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled()',\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 = injectFormField();\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","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpFormField } from './form-field/form-field.directive';\nexport { NgpFormFieldToken } from './form-field/form-field.token';\nexport { NgpLabel } from './label/label.directive';\nexport { NgpLabelToken } from './label/label.token';\nexport { NgpDescription } from './description/description.directive';\nexport { NgpDescriptionToken } from './description/description.token';\nexport { NgpFormControl } from './form-control/form-control.directive';\nexport { NgpFormControlToken } from './form-control/form-control.token';\nexport { NgpError } from './error/error.directive';\nexport { NgpErrorToken } from './error/error.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;MAIU,iBAAiB,GAAG,IAAI,cAAc,CAAe,mBAAmB,EAAE;AAEvF;;;AAGG;SACa,eAAe,GAAA;IAC7B,OAAO,MAAM,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD;;AClBA;;;;;;AAMG;MAsBU,YAAY,CAAA;AA6EvB,IAAA,WAAA,GAAA;AA5EA;;;AAGG;AACM,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAW,EAAE,CAAC,CAAC;AAEvC;;;AAGG;AACM,QAAA,IAAA,CAA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,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,UAAA,CAAA,EAAA,aAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FAanD,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAjBpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;oBACpB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAU,QAAA,EAAE,CAAC;AAC9D,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,qBAAqB,EAAE,sBAAsB;AAC7C,wBAAA,mBAAmB,EAAE,oBAAoB;AACzC,wBAAA,qBAAqB,EAAE,sBAAsB;AAC7C,wBAAA,sBAAsB,EAAE,uBAAuB;AAC/C,wBAAA,mBAAmB,EAAE,oBAAoB;AACzC,wBAAA,qBAAqB,EAAE,sBAAsB;AAC7C,wBAAA,sBAAsB,EAAE,uBAAuB;AAC/C,wBAAA,uBAAuB,EAAE,SAAS;AACnC,qBAAA;AACF,iBAAA,CAAA;;;AC5BD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-form-field.mjs","sources":["../../../../packages/ng-primitives/form-field/src/form-field/form-field.token.ts","../../../../packages/ng-primitives/form-field/src/form-field/form-field.directive.ts","../../../../packages/ng-primitives/form-field/src/label/label.token.ts","../../../../packages/ng-primitives/form-field/src/label/label.directive.ts","../../../../packages/ng-primitives/form-field/src/description/description.token.ts","../../../../packages/ng-primitives/form-field/src/description/description.directive.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.token.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.directive.ts","../../../../packages/ng-primitives/form-field/src/error/error.token.ts","../../../../packages/ng-primitives/form-field/src/error/error.directive.ts","../../../../packages/ng-primitives/form-field/src/index.ts","../../../../packages/ng-primitives/form-field/src/ng-primitives-form-field.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpFormField } from './form-field.directive';\n\nexport const NgpFormFieldToken = new InjectionToken<NgpFormField>('NgpFormFieldToken');\n\n/**\n * Inject the FormField directive instance\n * @param primitive\n */\nexport function injectFormField(): NgpFormField | null {\n return inject(NgpFormFieldToken, { optional: true });\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, OnDestroy, contentChild, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { onChange } from 'ng-primitives/utils';\nimport { Subscription } from 'rxjs';\nimport { NgpFormFieldToken } from './form-field.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpFormField]',\n exportAs: 'ngpFormField',\n providers: [{ provide: NgpFormFieldToken, useExisting: NgpFormField }],\n host: {\n '[attr.data-invalid]': 'invalid()',\n '[attr.data-valid]': 'valid()',\n '[attr.data-touched]': 'touched()',\n '[attr.data-pristine]': 'pristine()',\n '[attr.data-dirty]': 'dirty()',\n '[attr.data-pending]': 'pending()',\n '[attr.data-disabled]': 'disabled()',\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 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 // Listen for changes to the form control.\n this.subscription = control?.valueChanges?.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","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpLabel } from './label.directive';\n\nexport const NgpLabelToken = new InjectionToken<NgpLabel>('NgpLabelToken');\n\n/**\n * Inject the Label directive instance\n */\nexport function injectLabel(): NgpLabel {\n return inject(NgpLabelToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport {\n Directive,\n ElementRef,\n HostListener,\n computed,\n effect,\n inject,\n input,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpLabelToken } from './label.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpLabel]',\n exportAs: 'ngpLabel',\n providers: [{ provide: NgpLabelToken, useExisting: NgpLabel }],\n host: {\n '[attr.id]': 'id()',\n '[attr.for]': 'htmlFor()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled()',\n },\n})\nexport class NgpLabel {\n /**\n * Access the element that the label is associated with.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the form field that the label is associated with.\n */\n protected readonly formField = injectFormField();\n\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 /**\n * Determine if the label is an HTML label element.\n */\n protected readonly isLabel = this.elementRef.nativeElement instanceof HTMLLabelElement;\n\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 constructor() {\n effect(\n onCleanup => {\n this.formField?.addLabel(this.id());\n onCleanup(() => this.formField?.removeLabel(this.id()));\n },\n { allowSignalWrites: true },\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 * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpDescription } from './description.directive';\n\nexport const NgpDescriptionToken = new InjectionToken<NgpDescription>('NgpDescriptionToken');\n\n/**\n * Inject the Description directive instance\n */\nexport function injectDescription(): NgpDescription {\n return inject(NgpDescriptionToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, effect, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpDescriptionToken } from './description.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpDescription]',\n exportAs: 'ngpDescription',\n providers: [{ provide: NgpDescriptionToken, useExisting: NgpDescription }],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled()',\n },\n})\nexport class NgpDescription {\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormField();\n\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 constructor() {\n effect(\n onCleanup => {\n this.formField?.addDescription(this.id());\n onCleanup(() => this.formField?.removeDescription(this.id()));\n },\n { allowSignalWrites: true },\n );\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpFormControl } from './form-control.directive';\n\nexport const NgpFormControlToken = new InjectionToken<NgpFormControl>('NgpFormControlToken');\n\n/**\n * Inject the FormControl directive instance\n */\nexport function injectFormControl(): NgpFormControl {\n return inject(NgpFormControlToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, computed, effect, input } from '@angular/core';\nimport { injectDisabled } from 'ng-primitives/internal';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpFormControlToken } from './form-control.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpFormControl]',\n exportAs: 'ngpFormControl',\n providers: [{ provide: NgpFormControlToken, useExisting: NgpFormControl }],\n host: {\n '[id]': 'id()',\n '[attr.aria-labelledby]': 'ariaLabelledBy()',\n '[attr.aria-describedby]': 'ariaDescribedBy()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled() || disabled()',\n },\n})\nexport class NgpFormControl {\n /**\n * Access the form field that the form control is associated with.\n */\n protected readonly formField = injectFormField();\n\n /**\n * Whether the form control is disabled by a parent.\n */\n protected readonly disabled = injectDisabled();\n\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 * Determine the aria-labelledby attribute value.\n */\n protected readonly ariaLabelledBy = computed(() => this.formField?.labels().join(' '));\n\n /**\n * Determine the aria-describedby attribute value.\n */\n protected readonly ariaDescribedBy = computed(() => this.formField?.descriptions().join(' '));\n\n constructor() {\n effect(\n onCleanup => {\n this.formField?.setFormControl(this.id());\n onCleanup(() => this.formField?.removeFormControl());\n },\n { allowSignalWrites: true },\n );\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpError } from './error.directive';\n\nexport const NgpErrorToken = new InjectionToken<NgpError>('NgpErrorToken');\n\n/**\n * Inject the Error directive instance\n */\nexport function injectError(): NgpError {\n return inject(NgpErrorToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, OnChanges, OnDestroy, SimpleChanges, computed, input } from '@angular/core';\nimport { onBooleanChange, uniqueId } from 'ng-primitives/utils';\nimport { injectFormField } from '../form-field/form-field.token';\nimport { NgpErrorToken } from './error.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpError]',\n exportAs: 'ngpError',\n providers: [{ provide: NgpErrorToken, useExisting: NgpError }],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField?.invalid()',\n '[attr.data-valid]': 'formField?.valid()',\n '[attr.data-touched]': 'formField?.touched()',\n '[attr.data-pristine]': 'formField?.pristine()',\n '[attr.data-dirty]': 'formField?.dirty()',\n '[attr.data-pending]': 'formField?.pending()',\n '[attr.data-disabled]': 'formField?.disabled()',\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 = injectFormField();\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","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpFormField } from './form-field/form-field.directive';\nexport { NgpFormFieldToken } from './form-field/form-field.token';\nexport { NgpLabel } from './label/label.directive';\nexport { NgpLabelToken } from './label/label.token';\nexport { NgpDescription } from './description/description.directive';\nexport { NgpDescriptionToken } from './description/description.token';\nexport { NgpFormControl } from './form-control/form-control.directive';\nexport { NgpFormControlToken } from './form-control/form-control.token';\nexport { NgpError } from './error/error.directive';\nexport { NgpErrorToken } from './error/error.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;MAIU,iBAAiB,GAAG,IAAI,cAAc,CAAe,mBAAmB,EAAE;AAEvF;;;AAGG;SACa,eAAe,GAAA;IAC7B,OAAO,MAAM,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD;;AClBA;;;;;;AAMG;MAsBU,YAAY,CAAA;AA6EvB,IAAA,WAAA,GAAA;AA5EA;;;AAGG;AACM,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAW,EAAE,CAAC,CAAC;AAEvC;;;AAGG;AACM,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAW,EAAE,CAAC,CAAC;AAE7C;;;AAGG;AACM,QAAA,IAAA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AAA,EAAA,CAAA,UAAA,CAAA,EAAA,aAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FAanD,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAjBpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;oBACpB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAU,QAAA,EAAE,CAAC;AAC9D,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,qBAAqB,EAAE,sBAAsB;AAC7C,wBAAA,mBAAmB,EAAE,oBAAoB;AACzC,wBAAA,qBAAqB,EAAE,sBAAsB;AAC7C,wBAAA,sBAAsB,EAAE,uBAAuB;AAC/C,wBAAA,mBAAmB,EAAE,oBAAoB;AACzC,wBAAA,qBAAqB,EAAE,sBAAsB;AAC7C,wBAAA,sBAAsB,EAAE,uBAAuB;AAC/C,wBAAA,uBAAuB,EAAE,SAAS;AACnC,qBAAA;AACF,iBAAA,CAAA;;;AC5BD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -12,7 +12,7 @@ import { NgpDisabledToken } from 'ng-primitives/internal';
|
|
|
12
12
|
* Copyright © 2024 Angular Primitives.
|
|
13
13
|
* https://github.com/ng-primitives/ng-primitives
|
|
14
14
|
*
|
|
15
|
-
* This source code is licensed under the
|
|
15
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*/
|
|
18
18
|
const NgpInputToken = new InjectionToken('NgpInputToken');
|
|
@@ -72,7 +72,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
72
72
|
* Copyright © 2024 Angular Primitives.
|
|
73
73
|
* https://github.com/ng-primitives/ng-primitives
|
|
74
74
|
*
|
|
75
|
-
* This source code is licensed under the
|
|
75
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
76
76
|
* LICENSE file in the root directory of this source tree.
|
|
77
77
|
*/
|
|
78
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-input.mjs","sources":["../../../../packages/ng-primitives/input/src/input/input.token.ts","../../../../packages/ng-primitives/input/src/input/input.directive.ts","../../../../packages/ng-primitives/input/src/index.ts","../../../../packages/ng-primitives/input/src/ng-primitives-input.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the
|
|
1
|
+
{"version":3,"file":"ng-primitives-input.mjs","sources":["../../../../packages/ng-primitives/input/src/input/input.token.ts","../../../../packages/ng-primitives/input/src/input/input.directive.ts","../../../../packages/ng-primitives/input/src/index.ts","../../../../packages/ng-primitives/input/src/ng-primitives-input.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpInput } from './input.directive';\n\nexport const NgpInputToken = new InjectionToken<NgpInput>('NgpInputToken');\n\n/**\n * Inject the Input directive instance\n */\nexport function injectInput(): NgpInput {\n return inject(NgpInputToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { NgpAutofill } from 'ng-primitives/autofill';\nimport { NgpFormControl } from 'ng-primitives/form-field';\nimport { NgpFocus, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpCanDisable, NgpDisabledToken } from 'ng-primitives/internal';\nimport { NgpInputToken } from './input.token';\n\n@Directive({\n standalone: true,\n selector: 'input[ngpInput]',\n exportAs: 'ngpInput',\n providers: [\n { provide: NgpInputToken, useExisting: NgpInput },\n { provide: NgpDisabledToken, useExisting: NgpInput },\n ],\n hostDirectives: [NgpFormControl, NgpHover, NgpFocus, NgpPress, NgpAutofill],\n})\nexport class NgpInput implements NgpCanDisable {\n /**\n * Access the underlying input element.\n * @internal\n */\n readonly element = inject<ElementRef<HTMLInputElement>>(ElementRef);\n\n /**\n * Whether the element is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\n });\n\n /**\n * Sync the input value.\n * @internal\n */\n readonly value = signal<string>(this.element.nativeElement.value);\n\n @HostListener('input')\n protected valueDidChange(): void {\n this.value.set(this.element.nativeElement.value);\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpInput } from './input/input.directive';\nexport { NgpInputToken } from './input/input.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;AAMG;MAIU,aAAa,GAAG,IAAI,cAAc,CAAW,eAAe,EAAE;AAE3E;;AAEG;SACa,WAAW,GAAA;AACzB,IAAA,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC;AAC/B;;MCgBa,QAAQ,CAAA;AAVrB,IAAA,WAAA,GAAA;AAWE;;;AAGG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAA+B,UAAU,CAAC,CAAC;AAEpE;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC,CAAC;AAEH;;;AAGG;QACM,I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A,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FAGU,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAVpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,iBAAiB;AAC3B,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,SAAS,EAAE;AACT,wBAAA,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,UAAU,EAAE;AACjD,wBAAA,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,UAAU,EAAE;AACrD,qBAAA;oBACD,cAAc,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC;AAC5E,iBAAA,CAAA;8BAsBW,cAAc,EAAA,CAAA;sBADvB,YAAY;uBAAC,OAAO,CAAA;;;ACrDvB;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -10,7 +10,7 @@ import { injectDisposables } from 'ng-primitives/utils';
|
|
|
10
10
|
* Copyright © 2024 Angular Primitives.
|
|
11
11
|
* https://github.com/ng-primitives/ng-primitives
|
|
12
12
|
*
|
|
13
|
-
* This source code is licensed under the
|
|
13
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
16
|
const NgpHoverToken = new InjectionToken('NgpHoverToken');
|
|
@@ -212,7 +212,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
212
212
|
* Copyright © 2024 Angular Primitives.
|
|
213
213
|
* https://github.com/ng-primitives/ng-primitives
|
|
214
214
|
*
|
|
215
|
-
* This source code is licensed under the
|
|
215
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
216
216
|
* LICENSE file in the root directory of this source tree.
|
|
217
217
|
*/
|
|
218
218
|
const NgpFocusToken = new InjectionToken('NgpFocusToken');
|
|
@@ -303,7 +303,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
303
303
|
* Copyright © 2024 Angular Primitives.
|
|
304
304
|
* https://github.com/ng-primitives/ng-primitives
|
|
305
305
|
*
|
|
306
|
-
* This source code is licensed under the
|
|
306
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
307
307
|
* LICENSE file in the root directory of this source tree.
|
|
308
308
|
*/
|
|
309
309
|
const NgpFocusVisibleToken = new InjectionToken('NgpFocusVisibleToken');
|
|
@@ -318,7 +318,7 @@ function injectFocusVisible() {
|
|
|
318
318
|
* Copyright © 2024 Angular Primitives.
|
|
319
319
|
* https://github.com/ng-primitives/ng-primitives
|
|
320
320
|
*
|
|
321
|
-
* This source code is licensed under the
|
|
321
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
322
322
|
* LICENSE file in the root directory of this source tree.
|
|
323
323
|
*/
|
|
324
324
|
class NgpFocusVisible {
|
|
@@ -435,7 +435,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
435
435
|
* Copyright © 2024 Angular Primitives.
|
|
436
436
|
* https://github.com/ng-primitives/ng-primitives
|
|
437
437
|
*
|
|
438
|
-
* This source code is licensed under the
|
|
438
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
439
439
|
* LICENSE file in the root directory of this source tree.
|
|
440
440
|
*/
|
|
441
441
|
const NgpPressToken = new InjectionToken('NgpPressToken');
|
|
@@ -563,7 +563,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
563
563
|
* Copyright © 2024 Angular Primitives.
|
|
564
564
|
* https://github.com/ng-primitives/ng-primitives
|
|
565
565
|
*
|
|
566
|
-
* This source code is licensed under the
|
|
566
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
567
567
|
* LICENSE file in the root directory of this source tree.
|
|
568
568
|
*/
|
|
569
569
|
const NgpMoveToken = new InjectionToken('NgpMoveToken');
|
|
@@ -789,7 +789,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImpor
|
|
|
789
789
|
* Copyright © 2024 Angular Primitives.
|
|
790
790
|
* https://github.com/ng-primitives/ng-primitives
|
|
791
791
|
*
|
|
792
|
-
* This source code is licensed under the
|
|
792
|
+
* This source code is licensed under the Apache 2.0 license found in the
|
|
793
793
|
* LICENSE file in the root directory of this source tree.
|
|
794
794
|
*/
|
|
795
795
|
|