ng-primitives 0.0.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -4
- package/accordion/accordion-trigger/accordion-trigger.directive.d.ts +2 -1
- package/autofill/README.md +3 -0
- package/autofill/autofill/autofill.directive.d.ts +19 -0
- package/{select/select-button/select-button.token.d.ts → autofill/autofill/autofill.token.d.ts} +4 -4
- package/autofill/index.d.ts +9 -0
- package/avatar/avatar/avatar.directive.d.ts +2 -1
- package/button/README.md +3 -0
- package/button/button/button.directive.d.ts +27 -0
- package/{select/select-option/select-option.token.d.ts → button/button/button.token.d.ts} +4 -4
- package/button/index.d.ts +9 -0
- package/checkbox/checkbox/checkbox.directive.d.ts +11 -61
- package/checkbox/index.d.ts +0 -4
- package/esm2022/a11y/visually-hidden/visually-hidden.directive.mjs +3 -3
- package/esm2022/accordion/accordion/accordion.directive.mjs +5 -4
- package/esm2022/accordion/accordion-content/accordion-content.directive.mjs +5 -6
- package/esm2022/accordion/accordion-item/accordion-item.directive.mjs +5 -5
- package/esm2022/accordion/accordion-trigger/accordion-trigger.directive.mjs +8 -5
- package/esm2022/autofill/autofill/autofill.directive.mjs +71 -0
- package/esm2022/autofill/autofill/autofill.token.mjs +16 -0
- package/esm2022/autofill/index.mjs +10 -0
- package/esm2022/autofill/ng-primitives-autofill.mjs +5 -0
- package/esm2022/avatar/avatar/avatar.directive.mjs +7 -4
- package/esm2022/avatar/avatar-fallback/avatar-fallback.directive.mjs +3 -3
- package/esm2022/avatar/avatar-image/avatar-image.directive.mjs +3 -3
- package/esm2022/button/button/button.directive.mjs +47 -0
- package/esm2022/button/button/button.token.mjs +16 -0
- package/esm2022/button/index.mjs +10 -0
- package/esm2022/button/ng-primitives-button.mjs +5 -0
- package/esm2022/checkbox/checkbox/checkbox.directive.mjs +29 -79
- package/esm2022/checkbox/index.mjs +1 -5
- package/esm2022/file-upload/file-upload/file-upload.directive.mjs +7 -4
- package/esm2022/focus-trap/focus-trap/focus-trap.directive.mjs +262 -0
- package/esm2022/focus-trap/focus-trap/focus-trap.token.mjs +16 -0
- package/esm2022/focus-trap/index.mjs +10 -0
- package/esm2022/focus-trap/ng-primitives-focus-trap.mjs +5 -0
- package/esm2022/form-field/description/description.directive.mjs +14 -14
- package/esm2022/form-field/error/error.directive.mjs +27 -29
- package/esm2022/form-field/form-control/form-control.directive.mjs +22 -16
- package/esm2022/form-field/form-field/form-field.directive.mjs +3 -3
- package/esm2022/form-field/form-field/form-field.token.mjs +3 -7
- package/esm2022/form-field/label/label.directive.mjs +56 -17
- package/esm2022/input/index.mjs +10 -0
- package/esm2022/input/input/input.directive.mjs +55 -0
- package/esm2022/input/input/input.token.mjs +16 -0
- package/esm2022/input/ng-primitives-input.mjs +5 -0
- package/esm2022/interactions/focus/focus.directive.mjs +15 -10
- package/esm2022/interactions/focus-visible/focus-visible.directive.mjs +12 -7
- package/esm2022/interactions/hover/hover.directive.mjs +16 -11
- package/esm2022/interactions/index.mjs +5 -1
- package/esm2022/interactions/move/move.directive.mjs +216 -0
- package/esm2022/interactions/move/move.token.mjs +16 -0
- package/esm2022/interactions/press/press.directive.mjs +118 -0
- package/esm2022/interactions/press/press.token.mjs +16 -0
- package/esm2022/internal/disabled/disabled.mjs +19 -0
- package/esm2022/internal/index.mjs +11 -0
- package/esm2022/internal/ng-primitives-internal.mjs +5 -0
- package/esm2022/internal/orientation/orientation.mjs +19 -0
- package/esm2022/internal/style-injector/style-injector.mjs +81 -0
- package/esm2022/progress/progress/progress.directive.mjs +3 -3
- package/esm2022/progress/progress-indicator/progress-indicator.directive.mjs +3 -3
- package/esm2022/radio/radio-group/radio-group.directive.mjs +14 -54
- package/esm2022/radio/radio-indicator/radio-indicator.directive.mjs +8 -5
- package/esm2022/radio/radio-item/radio-item.directive.mjs +8 -6
- package/esm2022/resize/resize/resize.directive.mjs +3 -3
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.directive.mjs +14 -9
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.directive.mjs +3 -3
- package/esm2022/search/index.mjs +10 -0
- package/esm2022/search/ng-primitives-search.mjs +5 -0
- package/esm2022/search/search-field/search-field.directive.mjs +47 -0
- package/esm2022/search/search-field/search-field.token.mjs +16 -0
- package/esm2022/select/index.mjs +1 -7
- package/esm2022/select/select/select.directive.mjs +23 -36
- package/esm2022/select/select/select.token.mjs +1 -1
- package/esm2022/slider/slider/slider.directive.mjs +18 -5
- package/esm2022/slider/slider-range/slider-range.directive.mjs +6 -5
- package/esm2022/slider/slider-thumb/slider-thumb.directive.mjs +7 -4
- package/esm2022/slider/slider-track/slider-track.directive.mjs +8 -4
- package/esm2022/switch/switch/switch.directive.mjs +18 -58
- package/esm2022/switch/switch-thumb/switch-thumb.directive.mjs +9 -6
- package/esm2022/tabs/tab-button/tab-button.directive.mjs +8 -6
- package/esm2022/tabs/tab-list/tab-list.directive.mjs +3 -3
- package/esm2022/tabs/tab-panel/tab-panel.directive.mjs +5 -6
- package/esm2022/tabs/tabset/tabset.directive.mjs +14 -18
- package/esm2022/textarea/index.mjs +10 -0
- package/esm2022/textarea/ng-primitives-textarea.mjs +5 -0
- package/esm2022/textarea/textarea/textarea.directive.mjs +37 -0
- package/esm2022/textarea/textarea/textarea.token.mjs +16 -0
- package/esm2022/toggle/toggle/toggle.directive.mjs +33 -13
- package/esm2022/tooltip/tooltip/tooltip.directive.mjs +3 -3
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.directive.mjs +7 -7
- package/esm2022/utils/helpers/focus-manager.mjs +3 -3
- package/esm2022/utils/index.mjs +2 -2
- package/esm2022/utils/signals/async.mjs +11 -17
- package/fesm2022/ng-primitives-a11y.mjs +3 -3
- package/fesm2022/ng-primitives-accordion.mjs +19 -16
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/ng-primitives-autofill.mjs +100 -0
- package/fesm2022/ng-primitives-autofill.mjs.map +1 -0
- package/fesm2022/ng-primitives-avatar.mjs +13 -10
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/ng-primitives-button.mjs +76 -0
- package/fesm2022/ng-primitives-button.mjs.map +1 -0
- package/fesm2022/ng-primitives-checkbox.mjs +25 -203
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs +6 -3
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-focus-trap.mjs +291 -0
- package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -0
- package/fesm2022/ng-primitives-form-field.mjs +119 -80
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-input.mjs +84 -0
- package/fesm2022/ng-primitives-input.mjs.map +1 -0
- package/fesm2022/ng-primitives-interactions.mjs +394 -26
- package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +132 -0
- package/fesm2022/ng-primitives-internal.mjs.map +1 -0
- package/fesm2022/ng-primitives-progress.mjs +6 -6
- package/fesm2022/ng-primitives-radio.mjs +25 -62
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-resize.mjs +3 -3
- package/fesm2022/ng-primitives-roving-focus.mjs +15 -10
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/ng-primitives-search.mjs +76 -0
- package/fesm2022/ng-primitives-search.mjs.map +1 -0
- package/fesm2022/ng-primitives-select.mjs +23 -395
- package/fesm2022/ng-primitives-select.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs +35 -14
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/ng-primitives-switch.mjs +23 -62
- package/fesm2022/ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs +27 -30
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-textarea.mjs +66 -0
- package/fesm2022/ng-primitives-textarea.mjs.map +1 -0
- package/fesm2022/ng-primitives-toggle.mjs +32 -12
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +9 -9
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +14 -20
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/file-upload/file-upload/file-upload.directive.d.ts +2 -1
- package/focus-trap/README.md +3 -0
- package/focus-trap/focus-trap/focus-trap.directive.d.ts +64 -0
- package/{select/select-options/select-options.token.d.ts → focus-trap/focus-trap/focus-trap.token.d.ts} +4 -4
- package/focus-trap/index.d.ts +9 -0
- package/form-field/description/description.directive.d.ts +1 -1
- package/form-field/error/error.directive.d.ts +9 -5
- package/form-field/form-control/form-control.directive.d.ts +7 -3
- package/form-field/form-field/form-field.token.d.ts +1 -1
- package/form-field/label/label.directive.d.ts +3 -2
- package/input/README.md +3 -0
- package/input/index.d.ts +9 -0
- package/input/input/input.directive.d.ts +33 -0
- package/input/input/input.token.d.ts +14 -0
- package/interactions/focus/focus.directive.d.ts +6 -2
- package/interactions/focus-visible/focus-visible.directive.d.ts +5 -1
- package/interactions/hover/hover.directive.d.ts +5 -1
- package/interactions/index.d.ts +4 -0
- package/interactions/move/move.directive.d.ts +126 -0
- package/interactions/move/move.token.d.ts +14 -0
- package/interactions/press/press.directive.d.ts +59 -0
- package/interactions/press/press.token.d.ts +14 -0
- package/internal/README.md +3 -0
- package/internal/disabled/disabled.d.ts +21 -0
- package/internal/index.d.ts +10 -0
- package/internal/orientation/orientation.d.ts +22 -0
- package/internal/style-injector/style-injector.d.ts +36 -0
- package/package.json +49 -7
- package/radio/radio-group/radio-group.directive.d.ts +4 -41
- package/radio/radio-indicator/radio-indicator.directive.d.ts +2 -1
- package/radio/radio-item/radio-item.directive.d.ts +2 -1
- package/roving-focus/roving-focus-group/roving-focus-group.directive.d.ts +7 -2
- package/search/README.md +3 -0
- package/search/index.d.ts +9 -0
- package/search/search-field/search-field.directive.d.ts +15 -0
- package/search/search-field/search-field.token.d.ts +14 -0
- package/select/index.d.ts +0 -6
- package/select/select/select.directive.d.ts +7 -22
- package/select/select/select.token.d.ts +2 -2
- package/slider/slider/slider.directive.d.ts +4 -2
- package/slider/slider-thumb/slider-thumb.directive.d.ts +2 -1
- package/slider/slider-track/slider-track.directive.d.ts +1 -1
- package/switch/switch/switch.directive.d.ts +5 -45
- package/switch/switch-thumb/switch-thumb.directive.d.ts +2 -1
- package/tabs/tab-button/tab-button.directive.d.ts +2 -1
- package/tabs/tabset/tabset.directive.d.ts +3 -9
- package/textarea/README.md +3 -0
- package/textarea/index.d.ts +9 -0
- package/textarea/textarea/textarea.directive.d.ts +20 -0
- package/textarea/textarea/textarea.token.d.ts +14 -0
- package/toggle/toggle/toggle.directive.d.ts +16 -4
- package/utils/index.d.ts +1 -1
- package/utils/signals/async.d.ts +10 -12
- package/checkbox/checkbox-indicator/checkbox-indicator.directive.d.ts +0 -19
- package/checkbox/checkbox-indicator/checkbox-indicator.token.d.ts +0 -15
- package/checkbox/checkbox-input/checkbox-input.directive.d.ts +0 -10
- package/checkbox/checkbox-label/checkbox-label.directive.d.ts +0 -9
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.directive.mjs +0 -51
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.token.mjs +0 -17
- package/esm2022/checkbox/checkbox-input/checkbox-input.directive.mjs +0 -40
- package/esm2022/checkbox/checkbox-label/checkbox-label.directive.mjs +0 -32
- package/esm2022/select/select-button/select-button.directive.mjs +0 -84
- package/esm2022/select/select-button/select-button.token.mjs +0 -16
- package/esm2022/select/select-option/select-option.directive.mjs +0 -90
- package/esm2022/select/select-option/select-option.token.mjs +0 -16
- package/esm2022/select/select-options/select-options.directive.mjs +0 -157
- package/esm2022/select/select-options/select-options.token.mjs +0 -16
- package/select/select-button/select-button.directive.d.ts +0 -51
- package/select/select-option/select-option.directive.d.ts +0 -57
- package/select/select-options/select-options.directive.d.ts +0 -65
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-tabs.mjs","sources":["../../../../packages/ng-primitives/tabs/src/config/tabs.config.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.token.ts","../../../../packages/ng-primitives/tabs/src/tab-button/tab-button.directive.ts","../../../../packages/ng-primitives/tabs/src/tab-list/tab-list.directive.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.token.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.directive.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.directive.ts","../../../../packages/ng-primitives/tabs/src/index.ts","../../../../packages/ng-primitives/tabs/src/ng-primitives-tabs.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, Provider, inject } from '@angular/core';\n\nexport interface NgpTabsConfig {\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n orientation: 'horizontal' | 'vertical';\n\n /**\n * Whether tabs should activate on focus\n * @default true\n */\n activateOnFocus: boolean;\n\n /**\n * Whether focus should wrap within the tab list when using the keyboard.\n * @default true\n */\n wrap: boolean;\n}\n\nexport const defaultTabsConfig: NgpTabsConfig = {\n orientation: 'horizontal',\n activateOnFocus: true,\n wrap: true,\n};\n\nexport const NgpTabsConfigToken = new InjectionToken<NgpTabsConfig>('NgpTabsConfigToken');\n\n/**\n * Provide the default Tabs configuration\n * @param config The Tabs configuration\n * @returns The provider\n */\nexport function provideTabsConfig(config: Partial<NgpTabsConfig>): Provider[] {\n return [\n {\n provide: NgpTabsConfigToken,\n useValue: { ...defaultTabsConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tabs configuration\n * @returns The global Tabs configuration\n */\nexport function injectTabsConfig(): NgpTabsConfig {\n return inject(NgpTabsConfigToken, { optional: true }) ?? defaultTabsConfig;\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 { NgpTabset } from './tabset.directive';\n\nexport const NgpTabsetToken = new InjectionToken<NgpTabset>('NgpTabsetToken');\n\n/**\n * Inject the Tabset directive instance\n * @returns The Tabset directive instance\n */\nexport function injectTabset(): NgpTabset {\n return inject(NgpTabsetToken);\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 { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, computed, input } from '@angular/core';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectTabset } from '../tabset/tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabButton]',\n exportAs: 'ngpTabButton',\n host: {\n role: 'tab',\n '[attr.id]': 'id() ?? defaultId()',\n '[attr.aria-controls]': 'ariaControls()',\n '[attr.data-state]': 'active() ? \"active\" : \"inactive\"',\n '[attr.data-disabled]': 'disabled()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n hostDirectives: [NgpRovingFocusItem],\n})\nexport class NgpTabButton {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n\n /**\n * The value of the tab this trigger controls\n */\n readonly value = input.required<string>({ alias: 'ngpTabButtonValue' });\n\n /**\n * Whether the tab is disabled\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTabButtonDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Determine the id of the tab button\n * @internal\n */\n readonly id = input<string>();\n\n /**\n * Determine a unique id for the tab button if not provided\n * @internal\n */\n readonly defaultId = computed(() => `${this.tabset.id()}-button-${this.value()}`);\n\n /**\n * Determine the aria-controls of the tab button\n * @internal\n */\n readonly ariaControls = computed(() => `${this.tabset.id()}-panel-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.tabset.value() === this.value());\n\n /**\n * Select the tab this trigger controls\n */\n @HostListener('click')\n select(): void {\n this.tabset.select(this.value());\n }\n\n /**\n * On focus select the tab this trigger controls if activateOnFocus is true\n */\n @HostListener('focus')\n protected activateOnFocus(): void {\n if (this.tabset.activateOnFocus()) {\n this.select();\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 { Directive } from '@angular/core';\nimport { injectTabset } from '../tabset/tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabList]',\n exportAs: 'ngpTabList',\n host: {\n role: 'tablist',\n '[attr.aria-orientation]': 'tabset.orientation()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n})\nexport class NgpTabList {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\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 { NgpTabPanel } from './tab-panel.directive';\n\nexport const NgpTabPanelToken = new InjectionToken<NgpTabPanel>('NgpTabPanelToken');\n\n/**\n * Inject the TabPanel directive instance\n * @returns The TabPanel directive instance\n */\nexport function injectTabPanel(): NgpTabPanel {\n return inject(NgpTabPanelToken);\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, input } from '@angular/core';\nimport { injectTabset } from '../tabset/tabset.token';\nimport { NgpTabPanelToken } from './tab-panel.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabPanel]',\n exportAs: 'ngpTabPanel',\n providers: [{ provide: NgpTabPanelToken, useExisting: NgpTabPanel }],\n host: {\n role: 'tabpanel',\n tabIndex: '0',\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.data-state]': 'active() ? \"active\" : \"inactive\"',\n '[attr.data-orientation]': 'tabset.orientation()',\n '[hidden]': '!active()',\n },\n})\nexport class NgpTabPanel {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n\n /**\n * The value of the tab\n */\n readonly value = input.required<string>({ alias: 'ngpTabPanelValue' });\n\n /**\n * Determine the id of the tab panel\n * @internal\n */\n readonly id = input<string>();\n\n /**\n * Determine a unique id for the tab panel if not provided\n * @internal\n */\n readonly defaultId = computed(() => `${this.tabset.id()}-panel-${this.value()}`);\n\n /**\n * Determine the aria-labelledby of the tab panel\n * @internal\n */\n readonly labelledBy = computed(() => `${this.tabset.id()}-button-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.tabset.selectedTab() === this.value());\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 { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n OnChanges,\n SimpleChanges,\n booleanAttribute,\n computed,\n contentChildren,\n input,\n model,\n} from '@angular/core';\nimport { NgpRovingFocusGroup, injectRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectTabsConfig } from '../config/tabs.config';\nimport { NgpTabPanelToken } from '../tab-panel/tab-panel.token';\nimport { NgpTabsetToken } from './tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabset]',\n exportAs: 'ngpTabset',\n providers: [{ provide: NgpTabsetToken, useExisting: NgpTabset }],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-orientation]': 'orientation()',\n },\n})\nexport class NgpTabset implements OnChanges {\n /**\n * Access the global tabset configuration\n */\n private readonly config = injectTabsConfig();\n\n /**\n * Access the roving focus group directive\n */\n private readonly rovingFocusGroup = injectRovingFocusGroup();\n\n /**\n * Define the id for the tabset\n */\n readonly id = input<string>(uniqueId('ngp-tabset'));\n\n /**\n * Define the active tab\n */\n readonly value = model<string | null>(null, {\n alias: 'ngpTabsetValue',\n });\n\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>(this.config.orientation, {\n alias: 'ngpTabsetOrientation',\n });\n\n /**\n * Whether tabs should activate on focus\n */\n readonly activateOnFocus = input<boolean, BooleanInput>(this.config.activateOnFocus, {\n alias: 'ngpTabsetActivateOnFocus',\n transform: booleanAttribute,\n });\n\n /**\n * Access the tabs within the tabset\n */\n readonly panels = contentChildren(NgpTabPanelToken, { descendants: true });\n\n /**\n * Get the id of the selected tab\n */\n readonly selectedTab = computed(() => {\n const panels = this.panels();\n\n // if there is a value set and a tab with that value exists, return the value\n if (panels.some(panel => panel.value() === this.value())) {\n return this.value();\n }\n\n // otherwise return the first tab\n return panels[0]?.value();\n });\n\n constructor() {\n // default the orientation to horizontal\n this.rovingFocusGroup.orientation.set(this.orientation());\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ('orientation' in changes) {\n this.rovingFocusGroup.orientation.set(this.orientation());\n }\n }\n\n /**\n * Select a tab by its value\n * @param value The value of the tab to select\n */\n select(value: string): void {\n this.value.set(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 CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpTabsConfig, provideTabsConfig } from './config/tabs.config';\nexport { NgpTabButton } from './tab-button/tab-button.directive';\nexport { NgpTabList } from './tab-list/tab-list.directive';\nexport { NgpTabPanel } from './tab-panel/tab-panel.directive';\nexport { NgpTabPanelToken } from './tab-panel/tab-panel.token';\nexport { NgpTabset } from './tabset/tabset.directive';\nexport { NgpTabsetToken } from './tabset/tabset.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;AAuBI,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,IAAI,EAAE,IAAI;CACX,CAAC;AAEK,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAgB,oBAAoB,CAAC,CAAC;AAE1F;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA8B,EAAA;IAC9D,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,kBAAkB;AAC3B,YAAA,QAAQ,EAAE,EAAE,GAAG,iBAAiB,EAAE,GAAG,MAAM,EAAE;AAC9C,SAAA;KACF,CAAC;AACJ,CAAC;AAED;;;AAGG;SACa,gBAAgB,GAAA;AAC9B,IAAA,OAAO,MAAM,CAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,iBAAiB,CAAC;AAC7E;;ACzDA;;;;;;AAMG;MAIU,cAAc,GAAG,IAAI,cAAc,CAAY,gBAAgB,EAAE;AAE9E;;;AAGG;SACa,YAAY,GAAA;AAC1B,IAAA,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC;AAChC;;MCQa,YAAY,CAAA;AAdzB,IAAA,WAAA,GAAA;AAeE;;AAEG;QACgB,IAAM,CAAA,MAAA,GAAG,YAAY,EAAE,CAAC;AAE3C;;AAEG;QACM,IAAK,CAAA,KAAA,GAAG,KAAK,CAAC,QAAQ,CAAS,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAExE;;;AAGG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,KAAK,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AAC,iDAiD9B,gBAAgB,EAAA,WAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,aAAA,EAAA,IAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,mBAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FA1CvC,SAAS,EAAA,UAAA,EAAA,CAAA;kBAXrB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,QAAQ,EAAE,WAAW;oBACrB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAW,SAAA,EAAE,CAAC;oBAChE,cAAc,EAAE,CAAC,mBAAmB,CAAC;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,MAAM;AACnB,wBAAA,yBAAyB,EAAE,eAAe;AAC3C,qBAAA;AACF,iBAAA,CAAA;;;AClCD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-tabs.mjs","sources":["../../../../packages/ng-primitives/tabs/src/config/tabs.config.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.token.ts","../../../../packages/ng-primitives/tabs/src/tab-button/tab-button.directive.ts","../../../../packages/ng-primitives/tabs/src/tab-list/tab-list.directive.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.token.ts","../../../../packages/ng-primitives/tabs/src/tab-panel/tab-panel.directive.ts","../../../../packages/ng-primitives/tabs/src/tabset/tabset.directive.ts","../../../../packages/ng-primitives/tabs/src/index.ts","../../../../packages/ng-primitives/tabs/src/ng-primitives-tabs.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, Provider, inject } from '@angular/core';\n\nexport interface NgpTabsConfig {\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n orientation: 'horizontal' | 'vertical';\n\n /**\n * Whether tabs should activate on focus\n * @default true\n */\n activateOnFocus: boolean;\n\n /**\n * Whether focus should wrap within the tab list when using the keyboard.\n * @default true\n */\n wrap: boolean;\n}\n\nexport const defaultTabsConfig: NgpTabsConfig = {\n orientation: 'horizontal',\n activateOnFocus: true,\n wrap: true,\n};\n\nexport const NgpTabsConfigToken = new InjectionToken<NgpTabsConfig>('NgpTabsConfigToken');\n\n/**\n * Provide the default Tabs configuration\n * @param config The Tabs configuration\n * @returns The provider\n */\nexport function provideTabsConfig(config: Partial<NgpTabsConfig>): Provider[] {\n return [\n {\n provide: NgpTabsConfigToken,\n useValue: { ...defaultTabsConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tabs configuration\n * @returns The global Tabs configuration\n */\nexport function injectTabsConfig(): NgpTabsConfig {\n return inject(NgpTabsConfigToken, { optional: true }) ?? defaultTabsConfig;\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 { NgpTabset } from './tabset.directive';\n\nexport const NgpTabsetToken = new InjectionToken<NgpTabset>('NgpTabsetToken');\n\n/**\n * Inject the Tabset directive instance\n * @returns The Tabset directive instance\n */\nexport function injectTabset(): NgpTabset {\n return inject(NgpTabsetToken);\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 { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, computed, input } from '@angular/core';\nimport { NgpFocusVisible, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectTabset } from '../tabset/tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabButton]',\n exportAs: 'ngpTabButton',\n host: {\n role: 'tab',\n '[attr.id]': 'id() ?? defaultId()',\n '[attr.aria-controls]': 'ariaControls()',\n '[attr.data-active]': 'active()',\n '[attr.data-disabled]': 'disabled()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n hostDirectives: [NgpRovingFocusItem, NgpHover, NgpFocusVisible, NgpPress],\n})\nexport class NgpTabButton {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n\n /**\n * The value of the tab this trigger controls\n */\n readonly value = input.required<string>({ alias: 'ngpTabButtonValue' });\n\n /**\n * Whether the tab is disabled\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTabButtonDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Determine the id of the tab button\n * @internal\n */\n readonly id = input<string>();\n\n /**\n * Determine a unique id for the tab button if not provided\n * @internal\n */\n readonly defaultId = computed(() => `${this.tabset.id()}-button-${this.value()}`);\n\n /**\n * Determine the aria-controls of the tab button\n * @internal\n */\n readonly ariaControls = computed(() => `${this.tabset.id()}-panel-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.tabset.value() === this.value());\n\n /**\n * Select the tab this trigger controls\n */\n @HostListener('click')\n select(): void {\n this.tabset.select(this.value());\n }\n\n /**\n * On focus select the tab this trigger controls if activateOnFocus is true\n */\n @HostListener('focus')\n protected activateOnFocus(): void {\n if (this.tabset.activateOnFocus()) {\n this.select();\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 { Directive } from '@angular/core';\nimport { injectTabset } from '../tabset/tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabList]',\n exportAs: 'ngpTabList',\n host: {\n role: 'tablist',\n '[attr.aria-orientation]': 'tabset.orientation()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n})\nexport class NgpTabList {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\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 { NgpTabPanel } from './tab-panel.directive';\n\nexport const NgpTabPanelToken = new InjectionToken<NgpTabPanel>('NgpTabPanelToken');\n\n/**\n * Inject the TabPanel directive instance\n * @returns The TabPanel directive instance\n */\nexport function injectTabPanel(): NgpTabPanel {\n return inject(NgpTabPanelToken);\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, input } from '@angular/core';\nimport { injectTabset } from '../tabset/tabset.token';\nimport { NgpTabPanelToken } from './tab-panel.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabPanel]',\n exportAs: 'ngpTabPanel',\n providers: [{ provide: NgpTabPanelToken, useExisting: NgpTabPanel }],\n host: {\n role: 'tabpanel',\n tabIndex: '0',\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.data-active]': 'active()',\n '[attr.data-orientation]': 'tabset.orientation()',\n },\n})\nexport class NgpTabPanel {\n /**\n * Access the tabset\n */\n protected readonly tabset = injectTabset();\n\n /**\n * The value of the tab\n */\n readonly value = input.required<string>({ alias: 'ngpTabPanelValue' });\n\n /**\n * Determine the id of the tab panel\n * @internal\n */\n readonly id = input<string>();\n\n /**\n * Determine a unique id for the tab panel if not provided\n * @internal\n */\n readonly defaultId = computed(() => `${this.tabset.id()}-panel-${this.value()}`);\n\n /**\n * Determine the aria-labelledby of the tab panel\n * @internal\n */\n readonly labelledBy = computed(() => `${this.tabset.id()}-button-${this.value()}`);\n\n /**\n * Whether the tab is active\n */\n readonly active = computed(() => this.tabset.selectedTab() === this.value());\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 { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n booleanAttribute,\n computed,\n contentChildren,\n input,\n model,\n} from '@angular/core';\nimport { NgpCanOrientate, NgpOrientation, NgpOrientationToken } from 'ng-primitives/internal';\nimport { NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectTabsConfig } from '../config/tabs.config';\nimport { NgpTabPanelToken } from '../tab-panel/tab-panel.token';\nimport { NgpTabsetToken } from './tabset.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTabset]',\n exportAs: 'ngpTabset',\n providers: [\n { provide: NgpTabsetToken, useExisting: NgpTabset },\n { provide: NgpOrientationToken, useExisting: NgpTabset },\n ],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n '[attr.id]': 'id()',\n '[attr.data-orientation]': 'orientation()',\n },\n})\nexport class NgpTabset implements NgpCanOrientate {\n /**\n * Access the global tabset configuration\n */\n private readonly config = injectTabsConfig();\n\n /**\n * Define the id for the tabset\n */\n readonly id = input<string>(uniqueId('ngp-tabset'));\n\n /**\n * Define the active tab\n */\n readonly value = model<string | null>(null, {\n alias: 'ngpTabsetValue',\n });\n\n /**\n * The orientation of the tabset\n * @default 'horizontal'\n */\n readonly orientation = input<NgpOrientation>(this.config.orientation, {\n alias: 'ngpTabsetOrientation',\n });\n\n /**\n * Whether tabs should activate on focus\n */\n readonly activateOnFocus = input<boolean, BooleanInput>(this.config.activateOnFocus, {\n alias: 'ngpTabsetActivateOnFocus',\n transform: booleanAttribute,\n });\n\n /**\n * Access the tabs within the tabset\n */\n readonly panels = contentChildren(NgpTabPanelToken, { descendants: true });\n\n /**\n * Get the id of the selected tab\n */\n readonly selectedTab = computed(() => {\n const panels = this.panels();\n\n // if there is a value set and a tab with that value exists, return the value\n if (panels.some(panel => panel.value() === this.value())) {\n return this.value();\n }\n\n // otherwise return the first tab\n return panels[0]?.value();\n });\n\n /**\n * Select a tab by its value\n * @param value The value of the tab to select\n */\n select(value: string): void {\n this.value.set(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 CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpTabsConfig, provideTabsConfig } from './config/tabs.config';\nexport { NgpTabButton } from './tab-button/tab-button.directive';\nexport { NgpTabList } from './tab-list/tab-list.directive';\nexport { NgpTabPanel } from './tab-panel/tab-panel.directive';\nexport { NgpTabPanelToken } from './tab-panel/tab-panel.token';\nexport { NgpTabset } from './tabset/tabset.directive';\nexport { NgpTabsetToken } from './tabset/tabset.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;AAMG;AAuBI,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,IAAI,EAAE,IAAI;CACX,CAAC;AAEK,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAgB,oBAAoB,CAAC,CAAC;AAE1F;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA8B,EAAA;IAC9D,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,kBAAkB;AAC3B,YAAA,QAAQ,EAAE,EAAE,GAAG,iBAAiB,EAAE,GAAG,MAAM,EAAE;AAC9C,SAAA;KACF,CAAC;AACJ,CAAC;AAED;;;AAGG;SACa,gBAAgB,GAAA;AAC9B,IAAA,OAAO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MG;;ACNH;;AAEG;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, booleanAttribute, Directive } from '@angular/core';
|
|
3
|
+
import * as i1 from 'ng-primitives/form-field';
|
|
4
|
+
import { NgpFormControl } from 'ng-primitives/form-field';
|
|
5
|
+
import * as i2 from 'ng-primitives/interactions';
|
|
6
|
+
import { NgpHover, NgpFocus, NgpPress } from 'ng-primitives/interactions';
|
|
7
|
+
import { NgpDisabledToken } from 'ng-primitives/internal';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Copyright © 2024 Angular Primitives.
|
|
11
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
const NgpTextareaToken = new InjectionToken('NgpTextareaToken');
|
|
17
|
+
/**
|
|
18
|
+
* Inject the Textarea directive instance
|
|
19
|
+
*/
|
|
20
|
+
function injectTextarea() {
|
|
21
|
+
return inject(NgpTextareaToken);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class NgpTextarea {
|
|
25
|
+
constructor() {
|
|
26
|
+
/**
|
|
27
|
+
* Whether the element is disabled.
|
|
28
|
+
*/
|
|
29
|
+
this.disabled = input(false, {
|
|
30
|
+
transform: booleanAttribute,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpTextarea, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
34
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.1.1", type: NgpTextarea, isStandalone: true, selector: "[ngpTextarea]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
35
|
+
{ provide: NgpTextareaToken, useExisting: NgpTextarea },
|
|
36
|
+
{ provide: NgpDisabledToken, useExisting: NgpTextarea },
|
|
37
|
+
], exportAs: ["ngpTextarea"], hostDirectives: [{ directive: i1.NgpFormControl }, { directive: i2.NgpHover }, { directive: i2.NgpFocus }, { directive: i2.NgpPress }], ngImport: i0 }); }
|
|
38
|
+
}
|
|
39
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpTextarea, decorators: [{
|
|
40
|
+
type: Directive,
|
|
41
|
+
args: [{
|
|
42
|
+
standalone: true,
|
|
43
|
+
selector: '[ngpTextarea]',
|
|
44
|
+
exportAs: 'ngpTextarea',
|
|
45
|
+
providers: [
|
|
46
|
+
{ provide: NgpTextareaToken, useExisting: NgpTextarea },
|
|
47
|
+
{ provide: NgpDisabledToken, useExisting: NgpTextarea },
|
|
48
|
+
],
|
|
49
|
+
hostDirectives: [NgpFormControl, NgpHover, NgpFocus, NgpPress],
|
|
50
|
+
}]
|
|
51
|
+
}] });
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Copyright © 2024 Angular Primitives.
|
|
55
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
58
|
+
* LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Generated bundle index. Do not edit.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
export { NgpTextarea, NgpTextareaToken };
|
|
66
|
+
//# sourceMappingURL=ng-primitives-textarea.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-primitives-textarea.mjs","sources":["../../../../packages/ng-primitives/textarea/src/textarea/textarea.token.ts","../../../../packages/ng-primitives/textarea/src/textarea/textarea.directive.ts","../../../../packages/ng-primitives/textarea/src/index.ts","../../../../packages/ng-primitives/textarea/src/ng-primitives-textarea.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 { NgpTextarea } from './textarea.directive';\n\nexport const NgpTextareaToken = new InjectionToken<NgpTextarea>('NgpTextareaToken');\n\n/**\n * Inject the Textarea directive instance\n */\nexport function injectTextarea(): NgpTextarea {\n return inject(NgpTextareaToken);\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 { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { NgpFormControl } from 'ng-primitives/form-field';\nimport { NgpFocus, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpCanDisable, NgpDisabledToken } from 'ng-primitives/internal';\nimport { NgpTextareaToken } from './textarea.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTextarea]',\n exportAs: 'ngpTextarea',\n providers: [\n { provide: NgpTextareaToken, useExisting: NgpTextarea },\n { provide: NgpDisabledToken, useExisting: NgpTextarea },\n ],\n hostDirectives: [NgpFormControl, NgpHover, NgpFocus, NgpPress],\n})\nexport class NgpTextarea implements NgpCanDisable {\n /**\n * Whether the element is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\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 { NgpTextarea } from './textarea/textarea.directive';\nexport { NgpTextareaToken } from './textarea/textarea.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[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,QAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FAGU,WAAW,EAAA,UAAA,EAAA,CAAA;kBAVvB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,SAAS,EAAE;AACT,wBAAA,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,aAAa,EAAE;AACvD,wBAAA,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,aAAa,EAAE;AACxD,qBAAA;oBACD,cAAc,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAC/D,iBAAA,CAAA;;;ACvBD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { model, input, booleanAttribute, Directive, HostListener } from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, model, input, booleanAttribute, Directive, HostListener } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
class NgpToggle {
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Access the element.
|
|
8
|
+
*/
|
|
9
|
+
this.element = inject(ElementRef);
|
|
10
|
+
/**
|
|
11
|
+
* Whether the toggle is selected.
|
|
8
12
|
* @default false
|
|
9
13
|
*/
|
|
10
|
-
this.
|
|
14
|
+
this.selected = model(false, { alias: 'ngpToggleSelected' });
|
|
11
15
|
/**
|
|
12
16
|
* Whether the toggle is disabled.
|
|
13
17
|
* @default false
|
|
@@ -16,35 +20,51 @@ class NgpToggle {
|
|
|
16
20
|
alias: 'ngpToggleDisabled',
|
|
17
21
|
transform: booleanAttribute,
|
|
18
22
|
});
|
|
23
|
+
/**
|
|
24
|
+
* Determine if the element is a button.
|
|
25
|
+
*/
|
|
26
|
+
this.isButton = this.element.nativeElement.tagName === 'BUTTON';
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
|
-
* Toggle the
|
|
29
|
+
* Toggle the selected state.
|
|
22
30
|
*/
|
|
23
31
|
toggle() {
|
|
24
32
|
if (this.disabled()) {
|
|
25
33
|
return;
|
|
26
34
|
}
|
|
27
|
-
this.
|
|
35
|
+
this.selected.update(selected => !selected);
|
|
28
36
|
}
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
/**
|
|
38
|
+
* If the element is not a button or a link the space key should toggle the selected state.
|
|
39
|
+
*/
|
|
40
|
+
onKeyDown(event) {
|
|
41
|
+
if (!this.isButton && this.element.nativeElement.tagName !== 'A') {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
this.toggle();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpToggle, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
47
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.1.1", type: NgpToggle, isStandalone: true, selector: "[ngpToggle]", inputs: { selected: { classPropertyName: "selected", publicName: "ngpToggleSelected", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpToggleDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "ngpToggleSelectedChange" }, host: { listeners: { "click": "toggle()", "keydown.space": "onKeyDown($event)" }, properties: { "attr.type": "isButton ? \"button\" : null", "attr.aria-pressed": "selected()", "attr.data-selected": "selected()", "attr.data-disabled": "disabled()" } }, exportAs: ["ngpToggle"], ngImport: i0 }); }
|
|
31
48
|
}
|
|
32
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpToggle, decorators: [{
|
|
33
50
|
type: Directive,
|
|
34
51
|
args: [{
|
|
35
|
-
selector: '
|
|
52
|
+
selector: '[ngpToggle]',
|
|
36
53
|
exportAs: 'ngpToggle',
|
|
37
54
|
standalone: true,
|
|
38
55
|
host: {
|
|
39
|
-
type: 'button',
|
|
40
|
-
'[attr.aria-pressed]': '
|
|
41
|
-
'[attr.data-
|
|
56
|
+
'[attr.type]': 'isButton ? "button" : null',
|
|
57
|
+
'[attr.aria-pressed]': 'selected()',
|
|
58
|
+
'[attr.data-selected]': 'selected()',
|
|
42
59
|
'[attr.data-disabled]': 'disabled()',
|
|
43
60
|
},
|
|
44
61
|
}]
|
|
45
62
|
}], propDecorators: { toggle: [{
|
|
46
63
|
type: HostListener,
|
|
47
64
|
args: ['click']
|
|
65
|
+
}], onKeyDown: [{
|
|
66
|
+
type: HostListener,
|
|
67
|
+
args: ['keydown.space', ['$event']]
|
|
48
68
|
}] } });
|
|
49
69
|
|
|
50
70
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-toggle.mjs","sources":["../../../../packages/ng-primitives/toggle/src/toggle/toggle.directive.ts","../../../../packages/ng-primitives/toggle/src/index.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.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 { BooleanInput } from '@angular/cdk/coercion';\nimport {
|
|
1
|
+
{"version":3,"file":"ng-primitives-toggle.mjs","sources":["../../../../packages/ng-primitives/toggle/src/toggle/toggle.directive.ts","../../../../packages/ng-primitives/toggle/src/index.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.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 { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n ElementRef,\n HostListener,\n booleanAttribute,\n inject,\n input,\n model,\n} from '@angular/core';\n\n@Directive({\n selector: '[ngpToggle]',\n exportAs: 'ngpToggle',\n standalone: true,\n host: {\n '[attr.type]': 'isButton ? \"button\" : null',\n '[attr.aria-pressed]': 'selected()',\n '[attr.data-selected]': 'selected()',\n '[attr.data-disabled]': 'disabled()',\n },\n})\nexport class NgpToggle {\n /**\n * Access the element.\n */\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Whether the toggle is selected.\n * @default false\n */\n readonly selected = model<boolean>(false, { alias: 'ngpToggleSelected' });\n\n /**\n * Whether the toggle is disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Determine if the element is a button.\n */\n protected isButton = this.element.nativeElement.tagName === 'BUTTON';\n\n /**\n * Toggle the selected state.\n */\n @HostListener('click')\n toggle(): void {\n if (this.disabled()) {\n return;\n }\n\n this.selected.update(selected => !selected);\n }\n\n /**\n * If the element is not a button or a link the space key should toggle the selected state.\n */\n @HostListener('keydown.space', ['$event'])\n protected onKeyDown(event: KeyboardEvent): void {\n if (!this.isButton && this.element.nativeElement.tagName !== 'A') {\n event.preventDefault();\n this.toggle();\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 { NgpToggle } from './toggle/toggle.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MA6Ba,SAAS,CAAA;AAXtB,IAAA,WAAA,GAAA;AAYE;;AAEG;AACc,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAA0B,UAAU,CAAC,CAAC;AAEvE;;;A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AAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,QAAA,EAAA,yBAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,UAAA,EAAA,eAAA,EAAA,mBAAA,EAAA,EAAA,UAAA,EAAA,EAAA,WAAA,EAAA,8BAAA,EAAA,mBAAA,EAAA,YAAA,EAAA,oBAAA,EAAA,YAAA,EAAA,oBAAA,EAAA,YAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA;;2FAAT,SAAS,EAAA,UAAA,EAAA,CAAA;kBAXrB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,QAAQ,EAAE,WAAW;AACrB,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE;AACJ,wBAAA,aAAa,EAAE,4BAA4B;AAC3C,wBAAA,qBAAqB,EAAE,YAAY;AACnC,wBAAA,sBAAsB,EAAE,YAAY;AACpC,wBAAA,sBAAsB,EAAE,YAAY;AACrC,qBAAA;AACF,iBAAA,CAAA;8BA+BC,MAAM,EAAA,CAAA;sBADL,YAAY;uBAAC,OAAO,CAAA;gBAaX,SAAS,EAAA,CAAA;sBADlB,YAAY;uBAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,CAAA;;;ACtE3C;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, ElementRef, ViewContainerRef, Injector, input, model, booleanAttribute, numberAttribute, computed, signal,
|
|
2
|
+
import { InjectionToken, inject, ElementRef, ViewContainerRef, Injector, input, model, booleanAttribute, numberAttribute, computed, signal, Directive, isDevMode } from '@angular/core';
|
|
3
3
|
import { TemplatePortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
4
4
|
import { offset, shift, flip, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
5
|
-
import { injectDisposables } from 'ng-primitives/utils';
|
|
5
|
+
import { injectDisposables, onBooleanChange } from 'ng-primitives/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Copyright © 2024 Angular Primitives.
|
|
@@ -180,7 +180,7 @@ class NgpTooltipTrigger {
|
|
|
180
180
|
*/
|
|
181
181
|
this.state = signal('closed');
|
|
182
182
|
// any time the open state changes then show or hide the tooltip
|
|
183
|
-
|
|
183
|
+
onBooleanChange(this.open, this.show.bind(this), this.hide.bind(this));
|
|
184
184
|
}
|
|
185
185
|
ngOnDestroy() {
|
|
186
186
|
this.destroyTooltip();
|
|
@@ -225,10 +225,10 @@ class NgpTooltipTrigger {
|
|
|
225
225
|
this.dispose?.();
|
|
226
226
|
this.state.set('closed');
|
|
227
227
|
}
|
|
228
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.
|
|
229
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.
|
|
228
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpTooltipTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
229
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.1.1", type: NgpTooltipTrigger, isStandalone: true, selector: "[ngpTooltipTrigger]", inputs: { tooltip: { classPropertyName: "tooltip", publicName: "ngpTooltipTrigger", isSignal: true, isRequired: true, transformFunction: null }, open: { classPropertyName: "open", publicName: "ngpTooltipTriggerOpen", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpTooltipTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpTooltipTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpTooltipTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpTooltipTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpTooltipTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpTooltipTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpTooltipTriggerContainer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "ngpTooltipTriggerOpenChange" }, host: { listeners: { "mouseenter": "open.set(true)", "mouseleave": "open.set(false)", "focus": "open.set(true)", "blur": "open.set(false)" }, properties: { "attr.data-state": "state()", "attr.data-disabled": "disabled()" } }, providers: [{ provide: NgpTooltipTriggerToken, useExisting: NgpTooltipTrigger }], exportAs: ["ngpTooltipTrigger"], ngImport: i0 }); }
|
|
230
230
|
}
|
|
231
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpTooltipTrigger, decorators: [{
|
|
232
232
|
type: Directive,
|
|
233
233
|
args: [{
|
|
234
234
|
standalone: true,
|
|
@@ -296,10 +296,10 @@ class NgpTooltip {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.
|
|
300
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.
|
|
299
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
300
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.1", type: NgpTooltip, isStandalone: true, selector: "[ngpTooltip]", host: { attributes: { "role": "tooltip" }, properties: { "style.left.px": "x()", "style.top.px": "y()" } }, providers: [{ provide: NgpTooltipToken, useExisting: NgpTooltip }], exportAs: ["ngpTooltip"], ngImport: i0 }); }
|
|
301
301
|
}
|
|
302
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
302
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpTooltip, decorators: [{
|
|
303
303
|
type: Directive,
|
|
304
304
|
args: [{
|
|
305
305
|
standalone: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-tooltip.mjs","sources":["../../../../packages/ng-primitives/tooltip/src/config/tooltip.config.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.token.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.directive.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.token.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.directive.ts","../../../../packages/ng-primitives/tooltip/src/index.ts","../../../../packages/ng-primitives/tooltip/src/ng-primitives-tooltip.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, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpTooltipConfig {\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n placement: Placement;\n\n /**\n * Define the delay before the tooltip is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the tooltip should be attached.\n * @default document.body\n */\n container: HTMLElement;\n}\n\nexport const defaultTooltipConfig: NgpTooltipConfig = {\n offset: 4,\n placement: 'top',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: document.body,\n};\n\nexport const NgpTooltipConfigToken = new InjectionToken<NgpTooltipConfig>('NgpTooltipConfigToken');\n\n/**\n * Provide the default Tooltip configuration\n * @param config The Tooltip configuration\n * @returns The provider\n */\nexport function provideTooltipConfig(config: Partial<NgpTooltipConfig>): Provider[] {\n return [\n {\n provide: NgpTooltipConfigToken,\n useValue: { ...defaultTooltipConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tooltip configuration\n * @returns The global Tooltip configuration\n */\nexport function injectTooltipConfig(): NgpTooltipConfig {\n return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;\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 { NgpTooltipTrigger } from './tooltip-trigger.directive';\n\nexport const NgpTooltipTriggerToken = new InjectionToken<NgpTooltipTrigger>(\n 'NgpTooltipTriggerToken',\n);\n\n/**\n * Inject the TooltipTrigger directive instance\n */\nexport function injectTooltipTrigger(): NgpTooltipTrigger {\n return inject(NgpTooltipTriggerToken);\n}\n\n/**\n * Provides the TooltipTrigger directive instance\n * @param trigger\n */\nexport function provideTooltipTrigger(trigger: NgpTooltipTrigger) {\n return { provide: NgpTooltipTriggerToken, useValue: trigger };\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 { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n Directive,\n ElementRef,\n EmbeddedViewRef,\n Injector,\n OnDestroy,\n TemplateRef,\n ViewContainerRef,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n model,\n numberAttribute,\n signal,\n} from '@angular/core';\nimport {\n Middleware,\n Placement,\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n} from '@floating-ui/dom';\nimport { injectDisposables } from 'ng-primitives/utils';\nimport { injectTooltipConfig } from '../config/tooltip.config';\nimport { NgpTooltipTriggerToken, provideTooltipTrigger } from './tooltip-trigger.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTooltipTrigger]',\n exportAs: 'ngpTooltipTrigger',\n providers: [{ provide: NgpTooltipTriggerToken, useExisting: NgpTooltipTrigger }],\n host: {\n '[attr.data-state]': 'state()',\n '[attr.data-disabled]': 'disabled()',\n '(mouseenter)': 'open.set(true)',\n '(mouseleave)': 'open.set(false)',\n '(focus)': 'open.set(true)',\n '(blur)': 'open.set(false)',\n },\n})\nexport class NgpTooltipTrigger implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the view container ref.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the global tooltip configuration.\n */\n private readonly config = injectTooltipConfig();\n\n /**\n * Access the disposable utilities\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the tooltip template ref.\n */\n readonly tooltip = input.required<TemplateRef<void>>({\n alias: 'ngpTooltipTrigger',\n });\n\n /**\n * The open state of the tooltip.\n * @default false\n */\n readonly open = model<boolean>(false, {\n alias: 'ngpTooltipTriggerOpen',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTooltipTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpTooltipTriggerPlacement',\n });\n\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpTooltipTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpTooltipTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpTooltipTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpTooltipTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the tooltip should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement>(this.config.container, {\n alias: 'ngpTooltipTriggerContainer',\n });\n\n /**\n * Store the tooltip view ref.\n */\n private viewRef: EmbeddedViewRef<void> | null = null;\n\n /**\n * Derive the tooltip middleware from the provided configuration.\n */\n private readonly middleware = computed(() => {\n const middleware: Middleware[] = [offset(this.offset()), shift()];\n\n if (this.flip()) {\n middleware.push(flip());\n }\n\n return middleware;\n });\n\n /**\n * Store the computed position of the tooltip.\n * @internal\n */\n readonly position = signal<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n\n /**\n * Store the state of the tooltip.\n * @internal\n */\n readonly state = signal<TooltipState>('closed');\n\n /**\n * The dispose function to stop computing the position of the tooltip.\n */\n private dispose?: () => void;\n\n constructor() {\n // any time the open state changes then show or hide the tooltip\n effect(() => (this.open() ? this.show() : this.hide()), { allowSignalWrites: true });\n }\n\n ngOnDestroy(): void {\n this.destroyTooltip();\n }\n\n private show(): void {\n // if the trigger is disabled or the tooltip is already open then do not show the tooltip\n if (this.disabled() || this.state() === 'open' || this.state() === 'opening') {\n return;\n }\n\n this.state.set('opening');\n this.disposables.setTimeout(() => this.createTooltip(), this.showDelay());\n }\n\n private hide(): void {\n // if the trigger is disabled or the tooltip is already closed then do not hide the tooltip\n if (this.disabled() || this.state() === 'closed' || this.state() === 'closing') {\n return;\n }\n\n this.state.set('closing');\n this.disposables.setTimeout(() => this.destroyTooltip(), this.hideDelay());\n }\n\n private createTooltip(): void {\n const portal = new TemplatePortal(\n this.tooltip(),\n this.viewContainerRef,\n undefined,\n this.injector,\n );\n\n const domOutlet = new DomPortalOutlet(\n this.container(),\n undefined,\n undefined,\n Injector.create({\n parent: this.injector,\n providers: [provideTooltipTrigger(this)],\n }),\n );\n\n this.viewRef = domOutlet.attach(portal);\n this.viewRef.detectChanges();\n\n const outletElement = this.viewRef.rootNodes[0];\n\n this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {\n const position = await computePosition(this.trigger.nativeElement, outletElement, {\n placement: this.placement(),\n middleware: this.middleware(),\n });\n\n this.position.set({ x: position.x, y: position.y });\n });\n\n this.state.set('open');\n }\n\n private destroyTooltip(): void {\n this.viewRef?.destroy();\n this.viewRef = null;\n this.dispose?.();\n this.state.set('closed');\n }\n}\n\nexport type TooltipState = 'closed' | 'opening' | 'open' | 'closing';\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 { NgpTooltip } from './tooltip.directive';\n\nexport const NgpTooltipToken = new InjectionToken<NgpTooltip>('NgpTooltipToken');\n\n/**\n * Inject the Tooltip directive instance\n */\nexport function injectTooltip(): NgpTooltip {\n return inject(NgpTooltipToken);\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, ElementRef, OnInit, computed, inject, isDevMode } from '@angular/core';\nimport { injectTooltipTrigger } from '../tooltip-trigger/tooltip-trigger.token';\nimport { NgpTooltipToken } from './tooltip.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTooltip]',\n exportAs: 'ngpTooltip',\n providers: [{ provide: NgpTooltipToken, useExisting: NgpTooltip }],\n host: {\n role: 'tooltip',\n '[style.left.px]': 'x()',\n '[style.top.px]': 'y()',\n },\n})\nexport class NgpTooltip implements OnInit {\n /**\n * Access the tooltip element.\n */\n private readonly tooltip = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the trigger instance.\n */\n private readonly trigger = injectTooltipTrigger();\n\n /**\n * Compute the x position of the tooltip.\n */\n protected readonly x = computed(() => this.trigger.position().x);\n\n /**\n * Compute the y position of the tooltip.\n */\n protected readonly y = computed(() => this.trigger.position().y);\n\n ngOnInit(): void {\n // if the element does not have a fixed position then throw a warning in dev mode\n if (isDevMode()) {\n const { position } = getComputedStyle(this.tooltip.nativeElement);\n\n if (position !== 'absolute') {\n console.warn(\n `The tooltip element must have an absolute position. The current position is ${position}.`,\n );\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 { NgpTooltipConfig, provideTooltipConfig } from './config/tooltip.config';\nexport { NgpTooltipTrigger } from './tooltip-trigger/tooltip-trigger.directive';\nexport { NgpTooltipTriggerToken } from './tooltip-trigger/tooltip-trigger.token';\nexport { NgpTooltip } from './tooltip/tooltip.directive';\nexport { NgpTooltipToken } from './tooltip/tooltip.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG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,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;oBACtB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAY,UAAA,EAAE,CAAC;AAClE,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,iBAAiB,EAAE,KAAK;AACxB,wBAAA,gBAAgB,EAAE,KAAK;AACxB,qBAAA;AACF,iBAAA,CAAA;;;ACrBD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-tooltip.mjs","sources":["../../../../packages/ng-primitives/tooltip/src/config/tooltip.config.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.token.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.directive.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.token.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.directive.ts","../../../../packages/ng-primitives/tooltip/src/index.ts","../../../../packages/ng-primitives/tooltip/src/ng-primitives-tooltip.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, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpTooltipConfig {\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n placement: Placement;\n\n /**\n * Define the delay before the tooltip is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the tooltip should be attached.\n * @default document.body\n */\n container: HTMLElement;\n}\n\nexport const defaultTooltipConfig: NgpTooltipConfig = {\n offset: 4,\n placement: 'top',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: document.body,\n};\n\nexport const NgpTooltipConfigToken = new InjectionToken<NgpTooltipConfig>('NgpTooltipConfigToken');\n\n/**\n * Provide the default Tooltip configuration\n * @param config The Tooltip configuration\n * @returns The provider\n */\nexport function provideTooltipConfig(config: Partial<NgpTooltipConfig>): Provider[] {\n return [\n {\n provide: NgpTooltipConfigToken,\n useValue: { ...defaultTooltipConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tooltip configuration\n * @returns The global Tooltip configuration\n */\nexport function injectTooltipConfig(): NgpTooltipConfig {\n return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;\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 { NgpTooltipTrigger } from './tooltip-trigger.directive';\n\nexport const NgpTooltipTriggerToken = new InjectionToken<NgpTooltipTrigger>(\n 'NgpTooltipTriggerToken',\n);\n\n/**\n * Inject the TooltipTrigger directive instance\n */\nexport function injectTooltipTrigger(): NgpTooltipTrigger {\n return inject(NgpTooltipTriggerToken);\n}\n\n/**\n * Provides the TooltipTrigger directive instance\n * @param trigger\n */\nexport function provideTooltipTrigger(trigger: NgpTooltipTrigger) {\n return { provide: NgpTooltipTriggerToken, useValue: trigger };\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 { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n Directive,\n ElementRef,\n EmbeddedViewRef,\n Injector,\n OnDestroy,\n TemplateRef,\n ViewContainerRef,\n booleanAttribute,\n computed,\n inject,\n input,\n model,\n numberAttribute,\n signal,\n} from '@angular/core';\nimport {\n Middleware,\n Placement,\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n} from '@floating-ui/dom';\nimport { injectDisposables, onBooleanChange } from 'ng-primitives/utils';\nimport { injectTooltipConfig } from '../config/tooltip.config';\nimport { NgpTooltipTriggerToken, provideTooltipTrigger } from './tooltip-trigger.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTooltipTrigger]',\n exportAs: 'ngpTooltipTrigger',\n providers: [{ provide: NgpTooltipTriggerToken, useExisting: NgpTooltipTrigger }],\n host: {\n '[attr.data-state]': 'state()',\n '[attr.data-disabled]': 'disabled()',\n '(mouseenter)': 'open.set(true)',\n '(mouseleave)': 'open.set(false)',\n '(focus)': 'open.set(true)',\n '(blur)': 'open.set(false)',\n },\n})\nexport class NgpTooltipTrigger implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the view container ref.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the global tooltip configuration.\n */\n private readonly config = injectTooltipConfig();\n\n /**\n * Access the disposable utilities\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the tooltip template ref.\n */\n readonly tooltip = input.required<TemplateRef<void>>({\n alias: 'ngpTooltipTrigger',\n });\n\n /**\n * The open state of the tooltip.\n * @default false\n */\n readonly open = model<boolean>(false, {\n alias: 'ngpTooltipTriggerOpen',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTooltipTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpTooltipTriggerPlacement',\n });\n\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpTooltipTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpTooltipTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpTooltipTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpTooltipTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the tooltip should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement>(this.config.container, {\n alias: 'ngpTooltipTriggerContainer',\n });\n\n /**\n * Store the tooltip view ref.\n */\n private viewRef: EmbeddedViewRef<void> | null = null;\n\n /**\n * Derive the tooltip middleware from the provided configuration.\n */\n private readonly middleware = computed(() => {\n const middleware: Middleware[] = [offset(this.offset()), shift()];\n\n if (this.flip()) {\n middleware.push(flip());\n }\n\n return middleware;\n });\n\n /**\n * Store the computed position of the tooltip.\n * @internal\n */\n readonly position = signal<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n\n /**\n * Store the state of the tooltip.\n * @internal\n */\n readonly state = signal<TooltipState>('closed');\n\n /**\n * The dispose function to stop computing the position of the tooltip.\n */\n private dispose?: () => void;\n\n constructor() {\n // any time the open state changes then show or hide the tooltip\n onBooleanChange(this.open, this.show.bind(this), this.hide.bind(this));\n }\n\n ngOnDestroy(): void {\n this.destroyTooltip();\n }\n\n private show(): void {\n // if the trigger is disabled or the tooltip is already open then do not show the tooltip\n if (this.disabled() || this.state() === 'open' || this.state() === 'opening') {\n return;\n }\n\n this.state.set('opening');\n this.disposables.setTimeout(() => this.createTooltip(), this.showDelay());\n }\n\n private hide(): void {\n // if the trigger is disabled or the tooltip is already closed then do not hide the tooltip\n if (this.disabled() || this.state() === 'closed' || this.state() === 'closing') {\n return;\n }\n\n this.state.set('closing');\n this.disposables.setTimeout(() => this.destroyTooltip(), this.hideDelay());\n }\n\n private createTooltip(): void {\n const portal = new TemplatePortal(\n this.tooltip(),\n this.viewContainerRef,\n undefined,\n this.injector,\n );\n\n const domOutlet = new DomPortalOutlet(\n this.container(),\n undefined,\n undefined,\n Injector.create({\n parent: this.injector,\n providers: [provideTooltipTrigger(this)],\n }),\n );\n\n this.viewRef = domOutlet.attach(portal);\n this.viewRef.detectChanges();\n\n const outletElement = this.viewRef.rootNodes[0];\n\n this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {\n const position = await computePosition(this.trigger.nativeElement, outletElement, {\n placement: this.placement(),\n middleware: this.middleware(),\n });\n\n this.position.set({ x: position.x, y: position.y });\n });\n\n this.state.set('open');\n }\n\n private destroyTooltip(): void {\n this.viewRef?.destroy();\n this.viewRef = null;\n this.dispose?.();\n this.state.set('closed');\n }\n}\n\nexport type TooltipState = 'closed' | 'opening' | 'open' | 'closing';\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 { NgpTooltip } from './tooltip.directive';\n\nexport const NgpTooltipToken = new InjectionToken<NgpTooltip>('NgpTooltipToken');\n\n/**\n * Inject the Tooltip directive instance\n */\nexport function injectTooltip(): NgpTooltip {\n return inject(NgpTooltipToken);\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, ElementRef, OnInit, computed, inject, isDevMode } from '@angular/core';\nimport { injectTooltipTrigger } from '../tooltip-trigger/tooltip-trigger.token';\nimport { NgpTooltipToken } from './tooltip.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTooltip]',\n exportAs: 'ngpTooltip',\n providers: [{ provide: NgpTooltipToken, useExisting: NgpTooltip }],\n host: {\n role: 'tooltip',\n '[style.left.px]': 'x()',\n '[style.top.px]': 'y()',\n },\n})\nexport class NgpTooltip implements OnInit {\n /**\n * Access the tooltip element.\n */\n private readonly tooltip = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the trigger instance.\n */\n private readonly trigger = injectTooltipTrigger();\n\n /**\n * Compute the x position of the tooltip.\n */\n protected readonly x = computed(() => this.trigger.position().x);\n\n /**\n * Compute the y position of the tooltip.\n */\n protected readonly y = computed(() => this.trigger.position().y);\n\n ngOnInit(): void {\n // if the element does not have a fixed position then throw a warning in dev mode\n if (isDevMode()) {\n const { position } = getComputedStyle(this.tooltip.nativeElement);\n\n if (position !== 'absolute') {\n console.warn(\n `The tooltip element must have an absolute position. The current position is ${position}.`,\n );\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 { NgpTooltipConfig, provideTooltipConfig } from './config/tooltip.config';\nexport { NgpTooltipTrigger } from './tooltip-trigger/tooltip-trigger.directive';\nexport { NgpTooltipTriggerToken } from './tooltip-trigger/tooltip-trigger.token';\nexport { NgpTooltip } from './tooltip/tooltip.directive';\nexport { NgpTooltipToken } from './tooltip/tooltip.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;AA0CI,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,SA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S,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAY,UAAA,EAAE,CAAC;AAClE,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,iBAAiB,EAAE,KAAK;AACxB,wBAAA,gBAAgB,EAAE,KAAK;AACxB,qBAAA;AACF,iBAAA,CAAA;;;ACrBD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
@@ -88,10 +88,10 @@ class FocusManager {
|
|
|
88
88
|
break;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.
|
|
92
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.
|
|
91
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: FocusManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
92
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: FocusManager, providedIn: 'root' }); }
|
|
93
93
|
}
|
|
94
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
94
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: FocusManager, decorators: [{
|
|
95
95
|
type: Injectable,
|
|
96
96
|
args: [{
|
|
97
97
|
providedIn: 'root',
|
|
@@ -127,22 +127,6 @@ function uniqueId(prefix) {
|
|
|
127
127
|
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
128
128
|
* LICENSE file in the root directory of this source tree.
|
|
129
129
|
*/
|
|
130
|
-
/**
|
|
131
|
-
* Create a signal from an observable that is updated asynchronously.
|
|
132
|
-
* @param fn The function that returns an observable.
|
|
133
|
-
* @param options Options for the effect.
|
|
134
|
-
* @param options.injector
|
|
135
|
-
* @returns A signal that emits the value of the observable.
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
function computedAsync(fn, options) {
|
|
139
|
-
const value = signal(null);
|
|
140
|
-
effect(onCleanup => {
|
|
141
|
-
const subscription = fn()?.subscribe(value.set);
|
|
142
|
-
onCleanup(() => subscription?.unsubscribe());
|
|
143
|
-
}, { allowSignalWrites: true, injector: options?.injector });
|
|
144
|
-
return value;
|
|
145
|
-
}
|
|
146
130
|
/**
|
|
147
131
|
* Listen for changes to a signal and call a function when the signal changes.
|
|
148
132
|
* @param source
|
|
@@ -161,6 +145,16 @@ function onChange(source, fn, options) {
|
|
|
161
145
|
}
|
|
162
146
|
}, { allowSignalWrites: true, injector: options?.injector });
|
|
163
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Listen for changes to a boolean signal and call one of two functions when the signal changes.
|
|
150
|
+
* @param source
|
|
151
|
+
* @param onTrue
|
|
152
|
+
* @param onFalse
|
|
153
|
+
* @param options
|
|
154
|
+
*/
|
|
155
|
+
function onBooleanChange(source, onTrue, onFalse, options) {
|
|
156
|
+
onChange(source, value => (value ? onTrue() : onFalse()), options);
|
|
157
|
+
}
|
|
164
158
|
|
|
165
159
|
/**
|
|
166
160
|
* Copyright © 2024 Angular Primitives.
|
|
@@ -213,5 +207,5 @@ function injectDimensions() {
|
|
|
213
207
|
* Generated bundle index. Do not edit.
|
|
214
208
|
*/
|
|
215
209
|
|
|
216
|
-
export { FocusManager,
|
|
210
|
+
export { FocusManager, injectDimensions, injectDisposables, onBooleanChange, onChange, uniqueId };
|
|
217
211
|
//# sourceMappingURL=ng-primitives-utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-utils.mjs","sources":["../../../../packages/ng-primitives/utils/src/helpers/disposables.ts","../../../../packages/ng-primitives/utils/src/helpers/focus-manager.ts","../../../../packages/ng-primitives/utils/src/helpers/unique-id.ts","../../../../packages/ng-primitives/utils/src/signals/async.ts","../../../../packages/ng-primitives/utils/src/ui/dimensions.ts","../../../../packages/ng-primitives/utils/src/index.ts","../../../../packages/ng-primitives/utils/src/ng-primitives-utils.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 { DestroyRef, inject } from '@angular/core';\n\n/**\n * Disposable functions are a way to manage timers, intervals, and event listeners\n * that should be cleared when a component is destroyed.\n *\n * This is heavily inspired by Headless UI disposables:\n * https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/utils/disposables.ts\n */\nexport function injectDisposables() {\n const destroyRef = inject(DestroyRef);\n\n return {\n /**\n * Set a timeout that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the timeout\n */\n setTimeout: (callback: () => void, delay: number) => {\n const id = setTimeout(callback, delay);\n const cleanup = () => clearTimeout(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @param target\n * @param type\n * @param listener\n * @param options\n * @returns A function to clear the interval\n */\n addEventListener: (\n target: EventTarget,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) => {\n target.addEventListener(type, listener, options);\n const cleanup = () => target.removeEventListener(type, listener, options);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the interval\n */\n setInterval: (callback: () => void, delay: number) => {\n const id = setInterval(callback, delay);\n const cleanup = () => clearInterval(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set a requestAnimationFrame that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @returns A function to clear the requestAnimationFrame\n */\n requestAnimationFrame: (callback: FrameRequestCallback) => {\n const id = requestAnimationFrame(callback);\n const cleanup = () => cancelAnimationFrame(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\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 { FocusOrigin } from '@angular/cdk/a11y';\nimport { coerceElement } from '@angular/cdk/coercion';\nimport { ElementRef, Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class FocusManager {\n /**\n * Focus an element with an optional origin.\n */\n focus(element: ElementRef<HTMLElement>, origin?: FocusOrigin): void;\n focus(element: HTMLElement, origin?: FocusOrigin): void;\n focus(element: ElementRef<HTMLElement> | HTMLElement, origin: FocusOrigin = 'program'): void {\n element = coerceElement(element);\n\n switch (origin) {\n case 'keyboard':\n // trigger the focus-visible state for keyboard users\n element.contentEditable = 'true';\n element.focus({ preventScroll: true });\n element.contentEditable = 'false';\n break;\n default:\n element.focus();\n break;\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\n/**\n * Store a map of unique ids for elements so that there are no collisions.\n */\nconst uniqueIdMap = new Map<string, number>();\n\n/**\n * Generate a unique id for an element\n * @param prefix - The prefix to use for the id\n * @returns The generated id\n */\nexport function uniqueId(prefix: string): string {\n const id = uniqueIdMap.get(prefix) ?? 0;\n uniqueIdMap.set(prefix, id + 1);\n return `${prefix}-${id}`;\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 { Injector, Signal, effect, signal } from '@angular/core';\nimport { Observable } from 'rxjs';\n\n/**\n * Create a signal from an observable that is updated asynchronously.\n * @param fn The function that returns an observable.\n * @param options Options for the effect.\n * @param options.injector\n * @returns A signal that emits the value of the observable.\n * @internal\n */\nexport function computedAsync<T>(\n fn: () => Observable<T> | null | undefined,\n options?: { injector: Injector },\n): Signal<T | null> {\n const value = signal<T | null>(null);\n\n effect(\n onCleanup => {\n const subscription = fn()?.subscribe(value.set);\n onCleanup(() => subscription?.unsubscribe());\n },\n { allowSignalWrites: true, injector: options?.injector },\n );\n\n return value;\n}\n\n/**\n * Listen for changes to a signal and call a function when the signal changes.\n * @param source\n * @param fn\n * @param options\n * @param options.injector\n * @internal\n */\nexport function onChange<T>(\n source: Signal<T | null | undefined>,\n fn: (value: T | null | undefined, previousValue: T | null | undefined) => void,\n options?: { injector: Injector },\n): void {\n const previousValue = signal(source());\n\n effect(\n () => {\n const value = source();\n if (value !== previousValue()) {\n fn(value, previousValue());\n previousValue.set(value);\n }\n },\n { allowSignalWrites: true, injector: options?.injector },\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 {\n AfterRenderPhase,\n ElementRef,\n Renderer2,\n afterNextRender,\n inject,\n signal,\n} from '@angular/core';\n\n/**\n * Injects the dimensions of the element\n * @returns The dimensions of the element\n */\nexport function injectDimensions() {\n const renderer = inject(Renderer2);\n const element = inject<ElementRef<HTMLElement>>(ElementRef);\n const size = signal<{ width: number; height: number; mounted: boolean }>({\n width: 0,\n height: 0,\n mounted: false,\n });\n let transitionDuration: string | undefined, animationName: string | undefined;\n\n afterNextRender(\n () => {\n transitionDuration = element.nativeElement.style.transitionDuration;\n animationName = element.nativeElement.style.animationName;\n },\n { phase: AfterRenderPhase.EarlyRead },\n );\n\n afterNextRender(\n () => {\n // block any animations/transitions so the element renders at its full dimensions\n renderer.setStyle(element.nativeElement, 'transitionDuration', '0s');\n renderer.setStyle(element.nativeElement, 'animationName', 'none');\n },\n { phase: AfterRenderPhase.Write },\n );\n\n afterNextRender(\n () => {\n const { width, height } = element.nativeElement.getBoundingClientRect();\n size.set({ width, height, mounted: true });\n\n // restore the original transition duration and animation name\n renderer.setStyle(element.nativeElement, 'transitionDuration', transitionDuration);\n renderer.setStyle(element.nativeElement, 'animationName', animationName);\n },\n { phase: AfterRenderPhase.Read },\n );\n\n return size;\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 { injectDisposables } from './helpers/disposables';\nexport { FocusManager } from './helpers/focus-manager';\nexport { uniqueId } from './helpers/unique-id';\nexport { computedAsync, onChange } from './signals/async';\nexport { injectDimensions } from './ui/dimensions';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMG;AAGH;;;;;;AAMG;SACa,iBAAiB,GAAA;AAC/B,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAEtC,OAAO;AACL;;;;;AAKG;AACH,QAAA,UAAU,EAAE,CAAC,QAAoB,EAAE,KAAa,KAAI;YAClD,MAAM,EAAE,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACvC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,EAAE,CAAC,CAAC;AACvC,YAAA,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC9B,YAAA,OAAO,OAAO,CAAC;SAChB;AACD;;;;;;;;;AASG;QACH,gBAAgB,EAAE,CAChB,MAAmB,EACnB,IAAY,EACZ,QAA4C,EAC5C,OAA2C,KACzC;YACF,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjD,YAAA,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,E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CAAC;KACnE,EACD,EAAE,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAClC,CAAC;IAEF,eAAe,CACb,MAAK;AACH,QAAA,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC;AACxE,QAAA,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;;QAG3C,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACnF,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;KAC1E,EACD,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,CACjC,CAAC;AAEF,IAAA,OAAO,IAAI,CAAC;AACd;;AC5DA;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-utils.mjs","sources":["../../../../packages/ng-primitives/utils/src/helpers/disposables.ts","../../../../packages/ng-primitives/utils/src/helpers/focus-manager.ts","../../../../packages/ng-primitives/utils/src/helpers/unique-id.ts","../../../../packages/ng-primitives/utils/src/signals/async.ts","../../../../packages/ng-primitives/utils/src/ui/dimensions.ts","../../../../packages/ng-primitives/utils/src/index.ts","../../../../packages/ng-primitives/utils/src/ng-primitives-utils.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 { DestroyRef, inject } from '@angular/core';\n\n/**\n * Disposable functions are a way to manage timers, intervals, and event listeners\n * that should be cleared when a component is destroyed.\n *\n * This is heavily inspired by Headless UI disposables:\n * https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/utils/disposables.ts\n */\nexport function injectDisposables() {\n const destroyRef = inject(DestroyRef);\n\n return {\n /**\n * Set a timeout that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the timeout\n */\n setTimeout: (callback: () => void, delay: number) => {\n const id = setTimeout(callback, delay);\n const cleanup = () => clearTimeout(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @param target\n * @param type\n * @param listener\n * @param options\n * @returns A function to clear the interval\n */\n addEventListener: (\n target: EventTarget,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) => {\n target.addEventListener(type, listener, options);\n const cleanup = () => target.removeEventListener(type, listener, options);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the interval\n */\n setInterval: (callback: () => void, delay: number) => {\n const id = setInterval(callback, delay);\n const cleanup = () => clearInterval(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set a requestAnimationFrame that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @returns A function to clear the requestAnimationFrame\n */\n requestAnimationFrame: (callback: FrameRequestCallback) => {\n const id = requestAnimationFrame(callback);\n const cleanup = () => cancelAnimationFrame(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\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 { FocusOrigin } from '@angular/cdk/a11y';\nimport { coerceElement } from '@angular/cdk/coercion';\nimport { ElementRef, Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class FocusManager {\n /**\n * Focus an element with an optional origin.\n */\n focus(element: ElementRef<HTMLElement>, origin?: FocusOrigin): void;\n focus(element: HTMLElement, origin?: FocusOrigin): void;\n focus(element: ElementRef<HTMLElement> | HTMLElement, origin: FocusOrigin = 'program'): void {\n element = coerceElement(element);\n\n switch (origin) {\n case 'keyboard':\n // trigger the focus-visible state for keyboard users\n element.contentEditable = 'true';\n element.focus({ preventScroll: true });\n element.contentEditable = 'false';\n break;\n default:\n element.focus();\n break;\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\n/**\n * Store a map of unique ids for elements so that there are no collisions.\n */\nconst uniqueIdMap = new Map<string, number>();\n\n/**\n * Generate a unique id for an element\n * @param prefix - The prefix to use for the id\n * @returns The generated id\n */\nexport function uniqueId(prefix: string): string {\n const id = uniqueIdMap.get(prefix) ?? 0;\n uniqueIdMap.set(prefix, id + 1);\n return `${prefix}-${id}`;\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 { Injector, Signal, effect, signal } from '@angular/core';\n\n/**\n * Listen for changes to a signal and call a function when the signal changes.\n * @param source\n * @param fn\n * @param options\n * @param options.injector\n * @internal\n */\nexport function onChange<T>(\n source: Signal<T | null | undefined>,\n fn: (value: T | null | undefined, previousValue: T | null | undefined) => void,\n options?: { injector: Injector },\n): void {\n const previousValue = signal(source());\n\n effect(\n () => {\n const value = source();\n if (value !== previousValue()) {\n fn(value, previousValue());\n previousValue.set(value);\n }\n },\n { allowSignalWrites: true, injector: options?.injector },\n );\n}\n\n/**\n * Listen for changes to a boolean signal and call one of two functions when the signal changes.\n * @param source\n * @param onTrue\n * @param onFalse\n * @param options\n */\nexport function onBooleanChange(\n source: Signal<boolean>,\n onTrue: () => void,\n onFalse: () => void,\n options?: { injector: Injector },\n): void {\n onChange(source, value => (value ? onTrue() : onFalse()), options);\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 AfterRenderPhase,\n ElementRef,\n Renderer2,\n afterNextRender,\n inject,\n signal,\n} from '@angular/core';\n\n/**\n * Injects the dimensions of the element\n * @returns The dimensions of the element\n */\nexport function injectDimensions() {\n const renderer = inject(Renderer2);\n const element = inject<ElementRef<HTMLElement>>(ElementRef);\n const size = signal<{ width: number; height: number; mounted: boolean }>({\n width: 0,\n height: 0,\n mounted: false,\n });\n let transitionDuration: string | undefined, animationName: string | undefined;\n\n afterNextRender(\n () => {\n transitionDuration = element.nativeElement.style.transitionDuration;\n animationName = element.nativeElement.style.animationName;\n },\n { phase: AfterRenderPhase.EarlyRead },\n );\n\n afterNextRender(\n () => {\n // block any animations/transitions so the element renders at its full dimensions\n renderer.setStyle(element.nativeElement, 'transitionDuration', '0s');\n renderer.setStyle(element.nativeElement, 'animationName', 'none');\n },\n { phase: AfterRenderPhase.Write },\n );\n\n afterNextRender(\n () => {\n const { width, height } = element.nativeElement.getBoundingClientRect();\n size.set({ width, height, mounted: true });\n\n // restore the original transition duration and animation name\n renderer.setStyle(element.nativeElement, 'transitionDuration', transitionDuration);\n renderer.setStyle(element.nativeElement, 'animationName', animationName);\n },\n { phase: AfterRenderPhase.Read },\n );\n\n return size;\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 { injectDisposables } from './helpers/disposables';\nexport { FocusManager } from './helpers/focus-manager';\nexport { uniqueId } from './helpers/unique-id';\nexport { onBooleanChange, onChange } from './signals/async';\nexport { injectDimensions } from './ui/dimensions';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"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