ng-primitives 0.90.0 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/a11y/index.d.ts +38 -46
  2. package/accordion/index.d.ts +252 -104
  3. package/ai/index.d.ts +1 -1
  4. package/autofill/index.d.ts +49 -9
  5. package/avatar/index.d.ts +96 -61
  6. package/breadcrumbs/index.d.ts +156 -16
  7. package/button/index.d.ts +23 -28
  8. package/checkbox/index.d.ts +93 -14
  9. package/combobox/index.d.ts +1 -1
  10. package/date-picker/index.d.ts +12 -11
  11. package/fesm2022/ng-primitives-a11y.mjs +36 -52
  12. package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
  13. package/fesm2022/ng-primitives-accordion.mjs +210 -189
  14. package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
  15. package/fesm2022/ng-primitives-ai.mjs +4 -4
  16. package/fesm2022/ng-primitives-ai.mjs.map +1 -1
  17. package/fesm2022/ng-primitives-autofill.mjs +53 -36
  18. package/fesm2022/ng-primitives-autofill.mjs.map +1 -1
  19. package/fesm2022/ng-primitives-avatar.mjs +97 -138
  20. package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
  21. package/fesm2022/ng-primitives-breadcrumbs.mjs +92 -35
  22. package/fesm2022/ng-primitives-breadcrumbs.mjs.map +1 -1
  23. package/fesm2022/ng-primitives-button.mjs +14 -36
  24. package/fesm2022/ng-primitives-button.mjs.map +1 -1
  25. package/fesm2022/ng-primitives-checkbox.mjs +87 -65
  26. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  27. package/fesm2022/ng-primitives-combobox.mjs +9 -9
  28. package/fesm2022/ng-primitives-combobox.mjs.map +1 -1
  29. package/fesm2022/ng-primitives-date-picker.mjs +5 -4
  30. package/fesm2022/ng-primitives-date-picker.mjs.map +1 -1
  31. package/fesm2022/ng-primitives-form-field.mjs +48 -16
  32. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  33. package/fesm2022/ng-primitives-input.mjs +32 -48
  34. package/fesm2022/ng-primitives-input.mjs.map +1 -1
  35. package/fesm2022/ng-primitives-interactions.mjs +4 -4
  36. package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
  37. package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
  38. package/fesm2022/ng-primitives-menu.mjs +13 -6
  39. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  40. package/fesm2022/ng-primitives-pagination.mjs +6 -6
  41. package/fesm2022/ng-primitives-pagination.mjs.map +1 -1
  42. package/fesm2022/ng-primitives-progress.mjs +2 -2
  43. package/fesm2022/ng-primitives-progress.mjs.map +1 -1
  44. package/fesm2022/ng-primitives-radio.mjs +3 -3
  45. package/fesm2022/ng-primitives-radio.mjs.map +1 -1
  46. package/fesm2022/ng-primitives-roving-focus.mjs +259 -236
  47. package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
  48. package/fesm2022/ng-primitives-search.mjs.map +1 -1
  49. package/fesm2022/ng-primitives-select.mjs +8 -8
  50. package/fesm2022/ng-primitives-select.mjs.map +1 -1
  51. package/fesm2022/ng-primitives-slider.mjs +195 -172
  52. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  53. package/fesm2022/ng-primitives-state.mjs +172 -2
  54. package/fesm2022/ng-primitives-state.mjs.map +1 -1
  55. package/fesm2022/ng-primitives-switch.mjs +90 -88
  56. package/fesm2022/ng-primitives-switch.mjs.map +1 -1
  57. package/fesm2022/ng-primitives-tabs.mjs +4 -1
  58. package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
  59. package/fesm2022/ng-primitives-textarea.mjs +27 -35
  60. package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
  61. package/fesm2022/ng-primitives-toggle-group.mjs +134 -136
  62. package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
  63. package/fesm2022/ng-primitives-toggle.mjs +69 -58
  64. package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
  65. package/fesm2022/ng-primitives-toolbar.mjs +26 -35
  66. package/fesm2022/ng-primitives-toolbar.mjs.map +1 -1
  67. package/fesm2022/ng-primitives-utils.mjs +48 -35
  68. package/fesm2022/ng-primitives-utils.mjs.map +1 -1
  69. package/form-field/index.d.ts +7 -3
  70. package/input/index.d.ts +61 -24
  71. package/interactions/index.d.ts +5 -5
  72. package/listbox/index.d.ts +1 -1
  73. package/menu/index.d.ts +3 -2
  74. package/package.json +1 -1
  75. package/pagination/index.d.ts +7 -7
  76. package/roving-focus/index.d.ts +77 -101
  77. package/schematics/ng-add/schema.d.ts +0 -1
  78. package/schematics/ng-generate/templates/checkbox/checkbox.__fileSuffix@dasherize__.ts.template +2 -2
  79. package/schematics/ng-generate/templates/slider/slider.__fileSuffix@dasherize__.ts.template +6 -3
  80. package/schematics/ng-generate/templates/switch/switch.__fileSuffix@dasherize__.ts.template +2 -2
  81. package/schematics/ng-generate/templates/toggle/toggle.__fileSuffix@dasherize__.ts.template +2 -2
  82. package/schematics/ng-generate/templates/toggle-group/toggle-group.__fileSuffix@dasherize__.ts.template +2 -2
  83. package/schematics/ng-generate/templates/toolbar/toolbar.__fileSuffix@dasherize__.ts.template +1 -1
  84. package/search/index.d.ts +1 -1
  85. package/select/index.d.ts +2 -2
  86. package/slider/index.d.ts +195 -56
  87. package/state/index.d.ts +57 -3
  88. package/switch/index.d.ts +103 -28
  89. package/textarea/index.d.ts +63 -8
  90. package/toggle/index.d.ts +65 -24
  91. package/toggle-group/index.d.ts +79 -54
  92. package/toolbar/index.d.ts +27 -17
  93. package/utils/index.d.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-toggle.mjs","sources":["../../../../packages/ng-primitives/toggle/src/toggle/toggle-state.ts","../../../../packages/ng-primitives/toggle/src/toggle/toggle.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggle } from './toggle';\n\n/**\n * The state token for the Toggle primitive.\n */\nexport const NgpToggleStateToken = createStateToken<NgpToggle>('Toggle');\n\n/**\n * Provides the Toggle state.\n */\nexport const provideToggleState = createStateProvider(NgpToggleStateToken);\n\n/**\n * Injects the Toggle state.\n */\nexport const injectToggleState = createStateInjector<NgpToggle>(NgpToggleStateToken);\n\n/**\n * The Toggle state registration function.\n */\nexport const toggleState = createState(NgpToggleStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n ElementRef,\n HostListener,\n booleanAttribute,\n inject,\n input,\n output,\n} from '@angular/core';\nimport { provideToggleState, toggleState } from './toggle-state';\n\n/**\n * Apply the `ngpToggle` directive to an element to manage the toggle state. This must be applied to a `button` element.\n */\n@Directive({\n selector: '[ngpToggle]',\n exportAs: 'ngpToggle',\n providers: [provideToggleState()],\n host: {\n '[attr.type]': 'isButton ? \"button\" : null',\n '[attr.aria-pressed]': 'state.selected()',\n '[attr.data-selected]': 'state.selected() ? \"\" : null',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\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 = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleSelected',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the selected state changes.\n */\n readonly selectedChange = output<boolean>({\n alias: 'ngpToggleSelectedChange',\n });\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 * The state for the toggle primitive.\n * @internal\n */\n protected readonly state = toggleState<NgpToggle>(this);\n\n /**\n * Toggle the selected state.\n */\n @HostListener('click')\n toggle(): void {\n if (this.state.disabled()) {\n return;\n }\n\n const isSelected = !this.state.selected();\n\n this.state.selected.set(isSelected);\n this.selectedChange.emit(isSelected);\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 * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAQA;;AAEG;AACI,MAAM,mBAAmB,GAAG,gBAAgB,CAAY,QAAQ,CAAC;AAExE;;AAEG;MACU,kBAAkB,GAAG,mBAAmB,CAAC,mBAAmB;AAEzE;;AAEG;MACU,iBAAiB,GAAG,mBAAmB,CAAY,mBAAmB;AAEnF;;AAEG;AACI,MAAM,WAAW,GAAG,WAAW,CAAC,mBAAmB,CAAC;;ACd3D;;AAEG;MAYU,SAAS,CAAA;AAXtB,IAAA,WAAA,GAAA;AAYE;;AAEG;AACc,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAA0B,UAAU,CAAC;AAEtE;;;AAGG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,UAAA,EACpD,KAAK,EAAE,mBAAmB;gBAC1B,SAAS,EAAE,gBAAgB,EAAA,CAAA,GAAA,CAF2B;AACtD,gBAAA,KAAK,EAAE,mBAAmB;AAC1B,gBAAA,SAAS,EAAE,gBAAgB;AAC5B,aAAA,CAAA,CAAA,CAAC;AAEF;;AAEG;QACM,IAAA,CAAA,cAAc,GAAG,MAAM,CAAU;AACxC,YAAA,KAAK,EAAE,yBAAyB;AACjC,SAAA,CAAC;AAEF;;;AAGG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,UAAA,EACpD,KAAK,EAAE,mBAAmB;gBAC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../../../packages/ng-primitives/toggle/src/toggle/toggle.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.ts"],"sourcesContent":["import { computed, Signal, signal, WritableSignal } from '@angular/core';\nimport { ngpInteractions } from 'ng-primitives/interactions';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport {\n attrBinding,\n controlled,\n createPrimitive,\n dataBinding,\n deprecatedSetter,\n listener,\n} from 'ng-primitives/state';\nimport { Subject } from 'rxjs';\n\n/**\n * Public state surface for the Toggle primitive.\n */\nexport interface NgpToggleState {\n /**\n * Whether the toggle is selected.\n */\n readonly selected: WritableSignal<boolean>;\n /**\n * Whether the toggle is disabled.\n */\n readonly disabled: WritableSignal<boolean>;\n /**\n * Emits when the selected state changes.\n */\n readonly selectedChange: Subject<boolean>;\n /**\n * Toggle the selected state.\n */\n toggle(event?: Event): void;\n /**\n * Set the selected state.\n */\n setSelected(value: boolean): void;\n /**\n * Set the disabled state.\n */\n setDisabled(value: boolean): void;\n}\n\n/**\n * Inputs for configuring the Toggle primitive.\n */\nexport interface NgpToggleProps {\n /**\n * Whether the toggle is selected.\n */\n readonly selected?: Signal<boolean>;\n /**\n * Whether the toggle is disabled.\n */\n readonly disabled?: Signal<boolean>;\n /**\n * Callback fired when the selected state changes.\n */\n readonly onSelectedChange?: (selected: boolean) => void;\n}\n\nexport const [NgpToggleStateToken, ngpToggle, injectToggleState, provideToggleState] =\n createPrimitive(\n 'NgpToggle',\n ({\n selected: _selected = signal(false),\n disabled: _disabled = signal(false),\n onSelectedChange,\n }: NgpToggleProps): NgpToggleState => {\n const element = injectElementRef<HTMLElement>();\n const selected = controlled(_selected);\n const disabled = controlled(_disabled);\n const isButton = element.nativeElement.tagName.toLowerCase() === 'button';\n\n const selectedChange = new Subject<boolean>();\n\n ngpInteractions({\n hover: true,\n press: true,\n focusVisible: true,\n disabled,\n });\n\n const tabindex = computed(() => (disabled() ? -1 : 0));\n\n // Host bindings\n attrBinding(element, 'type', () => (isButton ? 'button' : null));\n attrBinding(element, 'aria-pressed', selected);\n dataBinding(element, 'data-selected', selected);\n dataBinding(element, 'data-disabled', disabled);\n attrBinding(element, 'aria-disabled', disabled);\n attrBinding(element, 'tabindex', () => tabindex().toString());\n\n // Listeners\n listener(element, 'click', event => toggle(event));\n listener(element, 'keydown', (event: KeyboardEvent) => {\n if (event.key === ' ' || event.key === 'Spacebar') {\n if (!isButton && element.nativeElement.tagName !== 'a') {\n event.preventDefault();\n toggle(event);\n }\n }\n });\n\n function toggle(event?: Event): void {\n if (disabled()) {\n return;\n }\n\n event?.preventDefault?.();\n setSelected(!selected());\n }\n\n function setSelected(value: boolean): void {\n selected.set(value);\n onSelectedChange?.(value);\n selectedChange.next(value);\n }\n\n function setDisabled(value: boolean): void {\n disabled.set(value);\n }\n\n return {\n selected: deprecatedSetter(selected, 'setSelected'),\n disabled: deprecatedSetter(disabled, 'setDisabled'),\n selectedChange,\n toggle,\n setSelected,\n setDisabled,\n };\n },\n );\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, output } from '@angular/core';\nimport { provideToggleState, ngpToggle } from './toggle-state';\n\n/**\n * Apply the `ngpToggle` directive to an element to manage the toggle state. This must be applied to a `button` element.\n */\n@Directive({\n selector: '[ngpToggle]',\n exportAs: 'ngpToggle',\n providers: [provideToggleState({ inherit: false })],\n})\nexport class NgpToggle {\n /**\n * Whether the toggle is selected.\n * @default false\n */\n readonly selected = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleSelected',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the selected state changes.\n */\n readonly selectedChange = output<boolean>({\n alias: 'ngpToggleSelectedChange',\n });\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 * The state for the toggle primitive.\n * @internal\n */\n protected readonly state = ngpToggle({\n selected: this.selected,\n disabled: this.disabled,\n onSelectedChange: value => this.selectedChange.emit(value),\n });\n\n /**\n * Toggle the selected state.\n */\n toggle(): void {\n this.state.toggle();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AA6DO,MAAM,CAAC,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,GAClF,eAAe,CACb,WAAW,EACX,CAAC,EACC,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,EACnC,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,EACnC,gBAAgB,GACD,KAAoB;AACnC,IAAA,MAAM,OAAO,GAAG,gBAAgB,EAAe;AAC/C,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC;AACtC,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC;AACtC,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,QAAQ;AAEzE,IAAA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAW;AAE7C,IAAA,eAAe,CAAC;AACd,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,YAAY,EAAE,IAAI;QAClB,QAAQ;AACT,KAAA,CAAC;IAEF,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,UAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAC;;IAGtD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC;AAChE,IAAA,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC;AAC9C,IAAA,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC;AAC/C,I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A,EAAA,CAAA,CAAA;kGAAT,SAAS,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,aAAA,EAAA,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,cAAA,EAAA,yBAAA,EAAA,EAAA,SAAA,EAFT,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAExC,SAAS,EAAA,UAAA,EAAA,CAAA;kBALrB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,QAAQ,EAAE,WAAW;oBACrB,SAAS,EAAE,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACpD,iBAAA;;;ACXD;;AAEG;;;;"}
@@ -1,33 +1,28 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { input, Directive } from '@angular/core';
3
- import { explicitEffect } from 'ng-primitives/internal';
4
- import * as i1 from 'ng-primitives/roving-focus';
5
- import { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';
6
- import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
3
+ import { ngpRovingFocusGroup, provideRovingFocusGroupState } from 'ng-primitives/roving-focus';
4
+ import { injectElementRef } from 'ng-primitives/internal';
5
+ import { createPrimitive, controlled, attrBinding, dataBinding, deprecatedSetter } from 'ng-primitives/state';
7
6
 
8
- /**
9
- * The state token for the Toolbar primitive.
10
- */
11
- const NgpToolbarStateToken = createStateToken('Toolbar');
12
- /**
13
- * Provides the Toolbar state.
14
- */
15
- const provideToolbarState = createStateProvider(NgpToolbarStateToken);
16
- /**
17
- * Injects the Toolbar state.
18
- */
19
- const injectToolbarState = createStateInjector(NgpToolbarStateToken);
20
- /**
21
- * The Toolbar state registration function.
22
- */
23
- const toolbarState = createState(NgpToolbarStateToken);
7
+ const [NgpToolbarStateToken, ngpToolbar, injectToolbarState, provideToolbarState] = createPrimitive('NgpToolbar', ({ rovingFocusGroup, orientation: _orientation }) => {
8
+ const element = injectElementRef();
9
+ const orientation = controlled(_orientation);
10
+ // Setup host attribute bindings
11
+ attrBinding(element, 'role', () => 'toolbar');
12
+ attrBinding(element, 'aria-orientation', () => orientation());
13
+ dataBinding(element, 'data-orientation', orientation);
14
+ function setOrientation(value) {
15
+ orientation.set(value);
16
+ rovingFocusGroup.setOrientation(value);
17
+ }
18
+ return {
19
+ orientation: deprecatedSetter(orientation, 'setOrientation'),
20
+ setOrientation,
21
+ };
22
+ });
24
23
 
25
24
  class NgpToolbar {
26
25
  constructor() {
27
- /**
28
- * Access the roving focus group state.
29
- */
30
- this.rovingFocusGroup = injectRovingFocusGroupState();
31
26
  /**
32
27
  * The orientation of the toolbar.
33
28
  */
@@ -37,26 +32,22 @@ class NgpToolbar {
37
32
  /**
38
33
  * The toolbar state.
39
34
  */
40
- this.state = toolbarState(this);
41
- explicitEffect([this.state.orientation], ([orientation]) => this.rovingFocusGroup().orientation.set(orientation));
35
+ this.state = ngpToolbar({
36
+ rovingFocusGroup: ngpRovingFocusGroup({ orientation: this.orientation }),
37
+ orientation: this.orientation,
38
+ });
42
39
  }
43
40
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpToolbar, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
44
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpToolbar, isStandalone: true, selector: "[ngpToolbar]", inputs: { orientation: { classPropertyName: "orientation", publicName: "ngpToolbarOrientation", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "toolbar" }, properties: { "attr.aria-orientation": "state.orientation()", "attr.data-orientation": "state.orientation()" } }, providers: [provideToolbarState()], exportAs: ["ngpToolbar"], hostDirectives: [{ directive: i1.NgpRovingFocusGroup }], ngImport: i0 }); }
41
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpToolbar, isStandalone: true, selector: "[ngpToolbar]", inputs: { orientation: { classPropertyName: "orientation", publicName: "ngpToolbarOrientation", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideToolbarState(), provideRovingFocusGroupState()], exportAs: ["ngpToolbar"], ngImport: i0 }); }
45
42
  }
46
43
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpToolbar, decorators: [{
47
44
  type: Directive,
48
45
  args: [{
49
46
  selector: '[ngpToolbar]',
50
47
  exportAs: 'ngpToolbar',
51
- providers: [provideToolbarState()],
52
- hostDirectives: [NgpRovingFocusGroup],
53
- host: {
54
- role: 'toolbar',
55
- '[attr.aria-orientation]': 'state.orientation()',
56
- '[attr.data-orientation]': 'state.orientation()',
57
- },
48
+ providers: [provideToolbarState(), provideRovingFocusGroupState()],
58
49
  }]
59
- }], ctorParameters: () => [], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToolbarOrientation", required: false }] }] } });
50
+ }], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToolbarOrientation", required: false }] }] } });
60
51
 
61
52
  /**
62
53
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-toolbar.mjs","sources":["../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar-state.ts","../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar.ts","../../../../packages/ng-primitives/toolbar/src/ng-primitives-toolbar.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToolbar } from './toolbar';\n\n/**\n * The state token for the Toolbar primitive.\n */\nexport const NgpToolbarStateToken = createStateToken<NgpToolbar>('Toolbar');\n\n/**\n * Provides the Toolbar state.\n */\nexport const provideToolbarState = createStateProvider(NgpToolbarStateToken);\n\n/**\n * Injects the Toolbar state.\n */\nexport const injectToolbarState = createStateInjector<NgpToolbar>(NgpToolbarStateToken);\n\n/**\n * The Toolbar state registration function.\n */\nexport const toolbarState = createState(NgpToolbarStateToken);\n","import { Directive, input } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { explicitEffect } from 'ng-primitives/internal';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { provideToolbarState, toolbarState } from './toolbar-state';\n\n@Directive({\n selector: '[ngpToolbar]',\n exportAs: 'ngpToolbar',\n providers: [provideToolbarState()],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n role: 'toolbar',\n '[attr.aria-orientation]': 'state.orientation()',\n '[attr.data-orientation]': 'state.orientation()',\n },\n})\nexport class NgpToolbar {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroup = injectRovingFocusGroupState();\n\n /**\n * The orientation of the toolbar.\n */\n readonly orientation = input<NgpOrientation>('horizontal', {\n alias: 'ngpToolbarOrientation',\n });\n\n /**\n * The toolbar state.\n */\n protected readonly state = toolbarState<NgpToolbar>(this);\n\n constructor() {\n explicitEffect([this.state.orientation], ([orientation]) =>\n this.rovingFocusGroup().orientation.set(orientation),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,oBAAoB,GAAG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AA,UAAA,EAAA,EAAA,MAAA,EAAA,SAAA,EAAA,EAAA,UAAA,EAAA,EAAA,uBAAA,EAAA,qBAAA,EAAA,uBAAA,EAAA,qBAAA,EAAA,EAAA,EAAA,SAAA,EARV,CAAC,mBAAmB,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,YAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,mBAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAQvB,UAAU,EAAA,UAAA,EAAA,CAAA;kBAXtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,SAAS,EAAE,CAAC,mBAAmB,EAAE,CAAC;oBAClC,cAAc,EAAE,CAAC,mBAAmB,CAAC;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,yBAAyB,EAAE,qBAAqB;AAChD,wBAAA,yBAAyB,EAAE,qBAAqB;AACjD,qBAAA;AACF,iBAAA;;;AChBD;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-toolbar.mjs","sources":["../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar-state.ts","../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar.ts","../../../../packages/ng-primitives/toolbar/src/ng-primitives-toolbar.ts"],"sourcesContent":["import { Signal, WritableSignal } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { NgpRovingFocusGroupState } from 'ng-primitives/roving-focus';\nimport {\n attrBinding,\n controlled,\n createPrimitive,\n dataBinding,\n deprecatedSetter,\n} from 'ng-primitives/state';\n\nexport interface NgpToolbarState {\n orientation: WritableSignal<NgpOrientation>;\n setOrientation(value: NgpOrientation): void;\n}\n\nexport interface NgpToolbarProps {\n rovingFocusGroup: NgpRovingFocusGroupState;\n orientation: Signal<NgpOrientation>;\n}\n\nexport const [NgpToolbarStateToken, ngpToolbar, injectToolbarState, provideToolbarState] =\n createPrimitive(\n 'NgpToolbar',\n ({ rovingFocusGroup, orientation: _orientation }: NgpToolbarProps) => {\n const element = injectElementRef();\n const orientation = controlled(_orientation);\n\n // Setup host attribute bindings\n attrBinding(element, 'role', () => 'toolbar');\n attrBinding(element, 'aria-orientation', () => orientation());\n dataBinding(element, 'data-orientation', orientation);\n\n function setOrientation(value: NgpOrientation) {\n orientation.set(value);\n rovingFocusGroup.setOrientation(value);\n }\n\n return {\n orientation: deprecatedSetter(orientation, 'setOrientation'),\n setOrientation,\n };\n },\n );\n","import { Directive, input } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { ngpRovingFocusGroup, provideRovingFocusGroupState } from 'ng-primitives/roving-focus';\nimport { ngpToolbar, provideToolbarState } from './toolbar-state';\n\n@Directive({\n selector: '[ngpToolbar]',\n exportAs: 'ngpToolbar',\n providers: [provideToolbarState(), provideRovingFocusGroupState()],\n})\nexport class NgpToolbar {\n /**\n * The orientation of the toolbar.\n */\n readonly orientation = input<NgpOrientation>('horizontal', {\n alias: 'ngpToolbarOrientation',\n });\n\n /**\n * The toolbar state.\n */\n protected readonly state = ngpToolbar({\n rovingFocusGroup: ngpRovingFocusGroup({ orientation: this.orientation }),\n orientation: this.orientation,\n });\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAsBO,MAAM,CAAC,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,GACtF,eAAe,CACb,YAAY,EACZ,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,YAAY,EAAmB,KAAI;AACnE,IAAA,MAAM,OAAO,GAAG,gBAAgB,EAAE;AAClC,IAAA,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;;IAG5C,WAAW,CAAC,OAAO,EAAE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EAAA,UAAA,EAAA,CAAA;kBALtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,SAAS,EAAE,CAAC,mBAAmB,EAAE,EAAE,4BAA4B,EAAE,CAAC;AACnE,iBAAA;;;ACTD;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
2
- import { inject, DestroyRef, signal, afterNextRender, afterRenderEffect, effect, untracked } from '@angular/core';
2
+ import { untracked, inject, DestroyRef, signal, effect, afterRenderEffect } from '@angular/core';
3
3
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
4
  import { pipe, NEVER, EMPTY } from 'rxjs';
5
5
  import { takeUntil, catchError, defaultIfEmpty } from 'rxjs/operators';
@@ -23,31 +23,44 @@ function safeTakeUntilDestroyed(destroyRef) {
23
23
  return pipe(takeUntil(NEVER.pipe(takeUntilDestroyed(destroyRef), catchError(() => EMPTY), defaultIfEmpty(null))));
24
24
  }
25
25
 
26
- function setStatusSignal(control, status) {
27
- if (!control?.control) {
28
- return;
29
- }
30
- status.set({
31
- valid: control?.control?.valid ?? null,
32
- invalid: control?.control?.invalid ?? null,
33
- pristine: control?.control?.pristine ?? null,
34
- dirty: control?.control?.dirty ?? null,
35
- touched: control?.control?.touched ?? null,
36
- pending: control?.control?.pending ?? null,
37
- disabled: control?.control?.disabled ?? null,
38
- });
26
+ /**
27
+ * Detects an Angular signal-forms interop control without importing any of the new
28
+ * signal-form types. Interop controls expose a `field()` method which returns the
29
+ * underlying FieldState.
30
+ */
31
+ function isInteropControl(control) {
32
+ return !!control && typeof control.field === 'function';
39
33
  }
40
- function subscribeToControlStatus(control, status, destroyRef) {
41
- if (!control?.control) {
42
- return;
34
+ /**
35
+ * Reads status from a control and updates the status signal.
36
+ * Wrapped in try-catch to handle signal-forms interop controls where
37
+ * the `field` input may not be available yet (throws NG0950).
38
+ */
39
+ function updateStatus(control, status) {
40
+ try {
41
+ // For interop controls, read directly from the control (which has signal getters).
42
+ // For classic controls, read from the underlying AbstractControl.
43
+ const source = isInteropControl(control) ? control : (control.control ?? control);
44
+ const newStatus = {
45
+ valid: source.valid ?? null,
46
+ invalid: source.invalid ?? null,
47
+ pristine: source.pristine ?? null,
48
+ dirty: source.dirty ?? null,
49
+ touched: source.touched ?? null,
50
+ pending: source.pending ?? null,
51
+ disabled: source.disabled ?? null,
52
+ };
53
+ untracked(() => status.set(newStatus));
54
+ }
55
+ catch {
56
+ // NG0950: Required input not available yet. The effect will re-run
57
+ // when the signal input becomes available.
43
58
  }
44
- control.control.events
45
- .pipe(safeTakeUntilDestroyed(destroyRef))
46
- .subscribe(() => setStatusSignal(control, status));
47
59
  }
48
60
  /**
49
61
  * A utility function to get the status of an Angular form control as a reactive signal.
50
62
  * This function injects the NgControl and returns a signal that reflects the control's status.
63
+ * It supports both classic reactive forms controls and signal-forms interop controls.
51
64
  * @internal
52
65
  */
53
66
  function controlStatus() {
@@ -62,23 +75,23 @@ function controlStatus() {
62
75
  pending: null,
63
76
  disabled: null,
64
77
  }, ...(ngDevMode ? [{ debugName: "status" }] : []));
65
- // Fallback if control is not yet available
66
- if (!control?.control) {
67
- // There is still a chance that the control will be available i.e. after executing OnInit lifecycle hook
68
- // in `formControlName` directive, so we set up an effect to subscribe to the control status
69
- afterNextRender({
70
- write: () => {
71
- // If control is still not available, we do nothing, otherwise we subscribe to the control status
72
- if (control?.control) {
73
- subscribeToControlStatus(control, status, destroyRef);
74
- // We re-set the status to ensure it reflects the current state on initialization
75
- setStatusSignal(control, status);
76
- }
77
- },
78
- });
78
+ if (!control) {
79
79
  return status;
80
80
  }
81
- subscribeToControlStatus(control, status);
81
+ // Use an effect to reactively track status changes.
82
+ // For signal-forms interop controls, the status properties are signals.
83
+ // For classic controls, this will read the current values and establish
84
+ // no signal dependencies, but we also subscribe to events below.
85
+ effect(() => {
86
+ updateStatus(control, status);
87
+ });
88
+ // For classic controls, also subscribe to the events observable.
89
+ const underlyingControl = control.control;
90
+ if (underlyingControl?.events) {
91
+ underlyingControl.events
92
+ .pipe(safeTakeUntilDestroyed(destroyRef))
93
+ .subscribe(() => updateStatus(control, status));
94
+ }
82
95
  return status;
83
96
  }
84
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-utils.mjs","sources":["../../../../packages/ng-primitives/utils/src/forms/providers.ts","../../../../packages/ng-primitives/utils/src/observables/take-until-destroyed.ts","../../../../packages/ng-primitives/utils/src/forms/status.ts","../../../../packages/ng-primitives/utils/src/helpers/attributes.ts","../../../../packages/ng-primitives/utils/src/helpers/disposables.ts","../../../../packages/ng-primitives/utils/src/helpers/unique-id.ts","../../../../packages/ng-primitives/utils/src/helpers/validators.ts","../../../../packages/ng-primitives/utils/src/signals/index.ts","../../../../packages/ng-primitives/utils/src/ng-primitives-utils.ts"],"sourcesContent":["import { ExistingProvider, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\n/**\n * A simple helper function to provide a value accessor for a given type.\n * @param type The type to provide the value accessor for\n */\nexport function provideValueAccessor<T>(type: Type<T>): ExistingProvider {\n return { provide: NG_VALUE_ACCESSOR, useExisting: type, multi: true };\n}\n","/* eslint-disable @nx/workspace-take-until-destroyed */\nimport { DestroyRef } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { EMPTY, MonoTypeOperatorFunction, NEVER, pipe } from 'rxjs';\nimport { catchError, defaultIfEmpty, takeUntil } from 'rxjs/operators';\n\n/**\n * The built-in `takeUntilDestroyed` operator does not handle the case when the component is destroyed before the source observable emits.\n * This operator ensures that the source observable completes gracefully without throwing an error.\n * https://github.com/angular/angular/issues/54527#issuecomment-2098254508\n *\n * @internal\n */\nexport function safeTakeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {\n return pipe(\n takeUntil(\n NEVER.pipe(\n takeUntilDestroyed(destroyRef),\n catchError(() => EMPTY),\n defaultIfEmpty(null),\n ),\n ),\n );\n}\n","import { DestroyRef, Signal, WritableSignal, afterNextRender, inject, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { safeTakeUntilDestroyed } from '../observables/take-until-destroyed';\n\nexport interface NgpControlStatus {\n valid: boolean | null;\n invalid: boolean | null;\n pristine: boolean | null;\n dirty: boolean | null;\n touched: boolean | null;\n pending: boolean | null;\n disabled: boolean | null;\n}\n\nfunction setStatusSignal(\n control: NgControl | null,\n status: WritableSignal<NgpControlStatus>,\n): void {\n if (!control?.control) {\n return;\n }\n\n status.set({\n valid: control?.control?.valid ?? null,\n invalid: control?.control?.invalid ?? null,\n pristine: control?.control?.pristine ?? null,\n dirty: control?.control?.dirty ?? null,\n touched: control?.control?.touched ?? null,\n pending: control?.control?.pending ?? null,\n disabled: control?.control?.disabled ?? null,\n });\n}\n\nfunction subscribeToControlStatus(\n control: NgControl | null,\n status: WritableSignal<NgpControlStatus>,\n destroyRef?: DestroyRef,\n): void {\n if (!control?.control) {\n return;\n }\n\n control.control.events\n .pipe(safeTakeUntilDestroyed(destroyRef))\n .subscribe(() => setStatusSignal(control, status));\n}\n\n/**\n * A utility function to get the status of an Angular form control as a reactive signal.\n * This function injects the NgControl and returns a signal that reflects the control's status.\n * @internal\n */\nexport function controlStatus(): Signal<NgpControlStatus> {\n const control = inject(NgControl, { optional: true });\n const destroyRef = inject(DestroyRef);\n\n const status = signal<NgpControlStatus>({\n valid: null,\n invalid: null,\n pristine: null,\n dirty: null,\n touched: null,\n pending: null,\n disabled: null,\n });\n\n // Fallback if control is not yet available\n if (!control?.control) {\n // There is still a chance that the control will be available i.e. after executing OnInit lifecycle hook\n // in `formControlName` directive, so we set up an effect to subscribe to the control status\n afterNextRender({\n write: () => {\n // If control is still not available, we do nothing, otherwise we subscribe to the control status\n if (control?.control) {\n subscribeToControlStatus(control, status, destroyRef);\n // We re-set the status to ensure it reflects the current state on initialization\n setStatusSignal(control, status);\n }\n },\n });\n return status;\n }\n\n subscribeToControlStatus(control, status);\n\n return status;\n}\n","import { afterRenderEffect, Signal } from '@angular/core';\n\nexport function booleanAttributeBinding(\n element: HTMLElement,\n attribute: string,\n value: Signal<boolean> | undefined,\n): void {\n if (!value) {\n return;\n }\n\n afterRenderEffect({\n write: () =>\n value() ? element.setAttribute(attribute, '') : element.removeAttribute(attribute),\n });\n}\n","import { 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 let isDestroyed = false;\n\n destroyRef.onDestroy(() => (isDestroyed = true));\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 if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\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: <K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions,\n ) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n target.addEventListener(type, listener as EventListenerOrEventListenerObject, options);\n const cleanup = () =>\n target.removeEventListener(type, listener as EventListenerOrEventListenerObject, 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 if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\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 if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = requestAnimationFrame(callback);\n const cleanup = () => cancelAnimationFrame(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\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 * Type validation utilities\n */\n\n/**\n * Checks if a value is a string\n * @param value - The value to check\n * @returns true if the value is a string, false otherwise\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number\n * @param value - The value to check\n * @returns true if the value is a number, false otherwise\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\n/**\n * Checks if a value is a boolean\n * @param value - The value to check\n * @returns true if the value is a boolean, false otherwise\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is a function\n * @param value - The value to check\n * @returns true if the value is a function, false otherwise\n */\nexport function isFunction(value: unknown): value is CallableFunction {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a plain object (but not null or array)\n * @param value - The value to check\n * @returns true if the value is a plain object, false otherwise\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Checks if a value is undefined\n * @param value - The value to check\n * @returns true if the value is undefined, false otherwise\n */\nexport function isUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\n/**\n * Checks if a value is null or undefined\n * @param value - The value to check\n * @returns true if the value is null or undefined, false otherwise\n */\nexport function isNil(value: unknown): value is null | undefined {\n return isUndefined(value) || value === null;\n}\n\n/**\n * Checks if a value is not null and not undefined\n * @param value - The value to check\n * @returns true if the value is not null and not undefined, false otherwise\n */\nexport function notNil<T>(value: T | null | undefined): value is T {\n return !isNil(value);\n}\n","import { effect, Injector, Signal, signal, untracked } 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 untracked(() => fn(value, previousValue()));\n previousValue.set(value);\n }\n },\n { injector: options?.injector },\n );\n\n // call the fn with the initial value\n fn(source(), null);\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 * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;AAGG;AACG,SAAU,oBAAoB,CAAI,IAAa,EAAA;AACnD,IAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE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,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AACtE;AAEA;;;;AAIG;AACG,SAAU,WAAW,CAAC,KAAc,EAAA;AACxC,IAAA,OAAO,OAAO,KAAK,KAAK,WAAW;AACrC;AAEA;;;;AAIG;AACG,SAAU,KAAK,CAAC,KAAc,EAAA;IAClC,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI;AAC7C;AAEA;;;;AAIG;AACG,SAAU,MAAM,CAAI,KAA2B,EAAA;AACnD,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACtB;;ACxEA;;;;;;;AAOG;SACa,QAAQ,CACtB,MAAoC,EACpC,EAA8E,EAC9E,OAAgC,EAAA;AAEhC,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,yDAAC;IAEtC,MAAM,CACJ,MAAK;AACH,QAAA,MAAM,KAAK,GAAG,MAAM,EAAE;AACtB,QAAA,IAAI,KAAK,KAAK,aAAa,EAAE,EAAE;AAC7B,YAAA,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;AAC3C,YAAA,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1B;IACF,CAAC,EACD,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAChC;;AAGD,IAAA,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC;AACpB;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAC7B,MAAuB,EACvB,MAAmB,EACnB,OAAoB,EACpB,OAAgC,EAAA;IAEhC,QAAQ,CAAC,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC;AACxE;;AC9CA;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-utils.mjs","sources":["../../../../packages/ng-primitives/utils/src/forms/providers.ts","../../../../packages/ng-primitives/utils/src/observables/take-until-destroyed.ts","../../../../packages/ng-primitives/utils/src/forms/status.ts","../../../../packages/ng-primitives/utils/src/helpers/attributes.ts","../../../../packages/ng-primitives/utils/src/helpers/disposables.ts","../../../../packages/ng-primitives/utils/src/helpers/unique-id.ts","../../../../packages/ng-primitives/utils/src/helpers/validators.ts","../../../../packages/ng-primitives/utils/src/signals/index.ts","../../../../packages/ng-primitives/utils/src/ng-primitives-utils.ts"],"sourcesContent":["import { ExistingProvider, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\n/**\n * A simple helper function to provide a value accessor for a given type.\n * @param type The type to provide the value accessor for\n */\nexport function provideValueAccessor<T>(type: Type<T>): ExistingProvider {\n return { provide: NG_VALUE_ACCESSOR, useExisting: type, multi: true };\n}\n","/* eslint-disable @nx/workspace-take-until-destroyed */\nimport { DestroyRef } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { EMPTY, MonoTypeOperatorFunction, NEVER, pipe } from 'rxjs';\nimport { catchError, defaultIfEmpty, takeUntil } from 'rxjs/operators';\n\n/**\n * The built-in `takeUntilDestroyed` operator does not handle the case when the component is destroyed before the source observable emits.\n * This operator ensures that the source observable completes gracefully without throwing an error.\n * https://github.com/angular/angular/issues/54527#issuecomment-2098254508\n *\n * @internal\n */\nexport function safeTakeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {\n return pipe(\n takeUntil(\n NEVER.pipe(\n takeUntilDestroyed(destroyRef),\n catchError(() => EMPTY),\n defaultIfEmpty(null),\n ),\n ),\n );\n}\n","import {\n DestroyRef,\n Signal,\n WritableSignal,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { safeTakeUntilDestroyed } from '../observables/take-until-destroyed';\n\nexport interface NgpControlStatus {\n valid: boolean | null;\n invalid: boolean | null;\n pristine: boolean | null;\n dirty: boolean | null;\n touched: boolean | null;\n pending: boolean | null;\n disabled: boolean | null;\n}\n\n/**\n * Detects an Angular signal-forms interop control without importing any of the new\n * signal-form types. Interop controls expose a `field()` method which returns the\n * underlying FieldState.\n */\nfunction isInteropControl(control: NgControl | null | undefined): boolean {\n return !!control && typeof (control as any).field === 'function';\n}\n\n/**\n * Reads status from a control and updates the status signal.\n * Wrapped in try-catch to handle signal-forms interop controls where\n * the `field` input may not be available yet (throws NG0950).\n */\nfunction updateStatus(control: NgControl, status: WritableSignal<NgpControlStatus>): void {\n try {\n // For interop controls, read directly from the control (which has signal getters).\n // For classic controls, read from the underlying AbstractControl.\n const source = isInteropControl(control) ? control : ((control as any).control ?? control);\n\n const newStatus: NgpControlStatus = {\n valid: source.valid ?? null,\n invalid: source.invalid ?? null,\n pristine: source.pristine ?? null,\n dirty: source.dirty ?? null,\n touched: source.touched ?? null,\n pending: source.pending ?? null,\n disabled: source.disabled ?? null,\n };\n\n untracked(() => status.set(newStatus));\n } catch {\n // NG0950: Required input not available yet. The effect will re-run\n // when the signal input becomes available.\n }\n}\n\n/**\n * A utility function to get the status of an Angular form control as a reactive signal.\n * This function injects the NgControl and returns a signal that reflects the control's status.\n * It supports both classic reactive forms controls and signal-forms interop controls.\n * @internal\n */\nexport function controlStatus(): Signal<NgpControlStatus> {\n const control = inject(NgControl, { optional: true });\n const destroyRef = inject(DestroyRef);\n\n const status = signal<NgpControlStatus>({\n valid: null,\n invalid: null,\n pristine: null,\n dirty: null,\n touched: null,\n pending: null,\n disabled: null,\n });\n\n if (!control) {\n return status;\n }\n\n // Use an effect to reactively track status changes.\n // For signal-forms interop controls, the status properties are signals.\n // For classic controls, this will read the current values and establish\n // no signal dependencies, but we also subscribe to events below.\n effect(() => {\n updateStatus(control, status);\n });\n\n // For classic controls, also subscribe to the events observable.\n const underlyingControl = (control as any).control;\n if (underlyingControl?.events) {\n underlyingControl.events\n .pipe(safeTakeUntilDestroyed(destroyRef))\n .subscribe(() => updateStatus(control, status));\n }\n\n return status;\n}\n","import { afterRenderEffect, Signal } from '@angular/core';\n\nexport function booleanAttributeBinding(\n element: HTMLElement,\n attribute: string,\n value: Signal<boolean> | undefined,\n): void {\n if (!value) {\n return;\n }\n\n afterRenderEffect({\n write: () =>\n value() ? element.setAttribute(attribute, '') : element.removeAttribute(attribute),\n });\n}\n","import { 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 let isDestroyed = false;\n\n destroyRef.onDestroy(() => (isDestroyed = true));\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 if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\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: <K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions,\n ) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n target.addEventListener(type, listener as EventListenerOrEventListenerObject, options);\n const cleanup = () =>\n target.removeEventListener(type, listener as EventListenerOrEventListenerObject, 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 if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\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 if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = requestAnimationFrame(callback);\n const cleanup = () => cancelAnimationFrame(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\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 * Type validation utilities\n */\n\n/**\n * Checks if a value is a string\n * @param value - The value to check\n * @returns true if the value is a string, false otherwise\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number\n * @param value - The value to check\n * @returns true if the value is a number, false otherwise\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\n/**\n * Checks if a value is a boolean\n * @param value - The value to check\n * @returns true if the value is a boolean, false otherwise\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is a function\n * @param value - The value to check\n * @returns true if the value is a function, false otherwise\n */\nexport function isFunction(value: unknown): value is CallableFunction {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a plain object (but not null or array)\n * @param value - The value to check\n * @returns true if the value is a plain object, false otherwise\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Checks if a value is undefined\n * @param value - The value to check\n * @returns true if the value is undefined, false otherwise\n */\nexport function isUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\n/**\n * Checks if a value is null or undefined\n * @param value - The value to check\n * @returns true if the value is null or undefined, false otherwise\n */\nexport function isNil(value: unknown): value is null | undefined {\n return isUndefined(value) || value === null;\n}\n\n/**\n * Checks if a value is not null and not undefined\n * @param value - The value to check\n * @returns true if the value is not null and not undefined, false otherwise\n */\nexport function notNil<T>(value: T | null | undefined): value is T {\n return !isNil(value);\n}\n","import { effect, Injector, Signal, signal, untracked } 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 untracked(() => fn(value, previousValue()));\n previousValue.set(value);\n }\n },\n { injector: options?.injector },\n );\n\n // call the fn with the initial value\n fn(source(), null);\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 * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;AAGG;AACG,SAAU,oBAAoB,CAAI,IAAa,EAAA;AACnD,IAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACvE;;ACHA;;;;;;AAMG;AACG,SAAU,sB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A,OAAO,OAAO,KAAK,KAAK,WAAW;AACrC;AAEA;;;;AAIG;AACG,SAAU,KAAK,CAAC,KAAc,EAAA;IAClC,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI;AAC7C;AAEA;;;;AAIG;AACG,SAAU,MAAM,CAAI,KAA2B,EAAA;AACnD,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACtB;;ACxEA;;;;;;;AAOG;SACa,QAAQ,CACtB,MAAoC,EACpC,EAA8E,EAC9E,OAAgC,EAAA;AAEhC,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,yDAAC;IAEtC,MAAM,CACJ,MAAK;AACH,QAAA,MAAM,KAAK,GAAG,MAAM,EAAE;AACtB,QAAA,IAAI,KAAK,KAAK,aAAa,EAAE,EAAE;AAC7B,YAAA,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;AAC3C,YAAA,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1B;IACF,CAAC,EACD,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAChC;;AAGD,IAAA,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC;AACpB;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAC7B,MAAuB,EACvB,MAAmB,EACnB,OAAoB,EACpB,OAAgC,EAAA;IAEhC,QAAQ,CAAC,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC;AACxE;;AC9CA;;AAEG;;;;"}
@@ -87,11 +87,11 @@ declare class NgpFormControl {
87
87
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpFormControl, never>;
88
88
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpFormControl, "[ngpFormControl]", ["ngpFormControl"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpFormControlDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
89
89
  }
90
- interface FormControlState {
90
+ interface NgpFormControlProps {
91
91
  id: Signal<string>;
92
92
  disabled?: Signal<boolean>;
93
93
  }
94
- declare function setupFormControl({ id, disabled, }: FormControlState): Signal<NgpControlStatus>;
94
+ declare function ngpFormControl({ id, disabled, }: NgpFormControlProps): Signal<NgpControlStatus>;
95
95
 
96
96
  /**
97
97
  * Provides the FormControl state.
@@ -169,6 +169,10 @@ declare class NgpFormField implements OnDestroy {
169
169
  * Store the current status subscription.
170
170
  */
171
171
  private subscription?;
172
+ /**
173
+ * Injector for creating effects outside the constructor.
174
+ */
175
+ private readonly injector;
172
176
  /**
173
177
  * The form field state.
174
178
  */
@@ -259,4 +263,4 @@ declare class NgpLabel {
259
263
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpLabel, "[ngpLabel]", ["ngpLabel"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
260
264
  }
261
265
 
262
- export { NgpDescription, NgpError, NgpFormControl, NgpFormField, NgpLabel, injectFormControlState, injectFormFieldState, provideFormControlState, provideFormFieldState, setupFormControl };
266
+ export { NgpDescription, NgpError, NgpFormControl, NgpFormField, NgpLabel, injectFormControlState, injectFormFieldState, ngpFormControl, provideFormControlState, provideFormFieldState };
package/input/index.d.ts CHANGED
@@ -1,47 +1,84 @@
1
- import * as ng_primitives_state from 'ng-primitives/state';
1
+ import * as ng_primitives_utils from 'ng-primitives/utils';
2
2
  import * as _angular_core from '@angular/core';
3
- import { Signal } from '@angular/core';
3
+ import { Signal, WritableSignal } from '@angular/core';
4
4
  import { BooleanInput } from '@angular/cdk/coercion';
5
- import { NgpControlStatus } from 'ng-primitives/utils';
6
- import * as i1 from 'ng-primitives/autofill';
7
5
 
8
6
  declare class NgpInput {
9
7
  /**
10
8
  * The id of the input.
11
9
  */
12
10
  readonly id: _angular_core.InputSignal<string>;
13
- /**
14
- * The input may be used within a search field, if so we need to register it.
15
- */
16
- private readonly searchState;
17
- /**
18
- * Access the element reference.
19
- */
20
- private readonly elementRef;
21
11
  /**
22
12
  * Whether the element is disabled.
23
13
  */
24
14
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
25
- /**
26
- * The form control status.
27
- */
28
- protected readonly status: Signal<NgpControlStatus>;
29
15
  /**
30
16
  * The input state.
31
17
  */
32
- protected readonly state: ng_primitives_state.CreatedState<NgpInput>;
33
- constructor();
18
+ protected readonly state: {
19
+ id: _angular_core.Signal<string>;
20
+ disabled: _angular_core.WritableSignal<boolean>;
21
+ status: _angular_core.Signal<ng_primitives_utils.NgpControlStatus>;
22
+ };
34
23
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpInput, never>;
35
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpInput, "input[ngpInput]", ["ngpInput"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.NgpAutofill; inputs: {}; outputs: {}; }]>;
24
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpInput, "input[ngpInput]", ["ngpInput"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
36
25
  }
37
26
 
38
27
  /**
39
- * Provides the Input state.
28
+ * Public state surface for the Input primitive.
40
29
  */
41
- declare const provideInputState: (options?: ng_primitives_state.CreateStateProviderOptions) => _angular_core.FactoryProvider;
30
+ interface NgpInputState {
31
+ /**
32
+ * The id of the input.
33
+ */
34
+ readonly id: Signal<string>;
35
+ /**
36
+ * Whether the input is disabled.
37
+ */
38
+ readonly disabled: WritableSignal<boolean>;
39
+ }
42
40
  /**
43
- * Injects the Input state.
41
+ * Inputs for configuring the Input primitive.
44
42
  */
45
- declare const injectInputState: <U = NgpInput>(injectOptions?: _angular_core.InjectOptions) => _angular_core.Signal<ng_primitives_state.State<U>>;
43
+ interface NgpInputProps {
44
+ /**
45
+ * The id of the input.
46
+ */
47
+ readonly id?: Signal<string>;
48
+ /**
49
+ * Whether the input is disabled.
50
+ */
51
+ readonly disabled?: Signal<boolean>;
52
+ }
53
+ declare const ngpInput: ({ id, disabled: _disabled }: NgpInputProps) => {
54
+ id: Signal<string>;
55
+ disabled: WritableSignal<boolean>;
56
+ status: Signal<ng_primitives_utils.NgpControlStatus>;
57
+ };
58
+ declare const injectInputState: {
59
+ (): Signal<{
60
+ id: Signal<string>;
61
+ disabled: WritableSignal<boolean>;
62
+ status: Signal<ng_primitives_utils.NgpControlStatus>;
63
+ }>;
64
+ (options: {
65
+ hoisted: true;
66
+ }): Signal<{
67
+ id: Signal<string>;
68
+ disabled: WritableSignal<boolean>;
69
+ status: Signal<ng_primitives_utils.NgpControlStatus>;
70
+ } | null>;
71
+ (options?: {
72
+ hoisted?: boolean;
73
+ }): Signal<{
74
+ id: Signal<string>;
75
+ disabled: WritableSignal<boolean>;
76
+ status: Signal<ng_primitives_utils.NgpControlStatus>;
77
+ } | null>;
78
+ };
79
+ declare const provideInputState: (opts?: {
80
+ inherit?: boolean;
81
+ }) => _angular_core.FactoryProvider;
46
82
 
47
- export { NgpInput, injectInputState, provideInputState };
83
+ export { NgpInput, injectInputState, ngpInput, provideInputState };
84
+ export type { NgpInputProps, NgpInputState };
@@ -170,7 +170,7 @@ declare class NgpMove {
170
170
  /**
171
171
  * Whether the element is currently being moved.
172
172
  */
173
- private isMoving;
173
+ protected isMoving: _angular_core.WritableSignal<boolean>;
174
174
  /**
175
175
  * Store the last x position of the element.
176
176
  */
@@ -212,10 +212,10 @@ declare class NgpMove {
212
212
  */
213
213
  protected onPointerMove(event: PointerEvent): void;
214
214
  private triggerKeyboardMove;
215
- protected onArrowUp(event: KeyboardEvent): void;
216
- protected onArrowDown(event: KeyboardEvent): void;
217
- protected onArrowLeft(event: KeyboardEvent): void;
218
- protected onArrowRight(event: KeyboardEvent): void;
215
+ protected onArrowUp(event: Event): void;
216
+ protected onArrowDown(event: Event): void;
217
+ protected onArrowLeft(event: Event): void;
218
+ protected onArrowRight(event: Event): void;
219
219
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpMove, never>;
220
220
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMove, "[ngpMove]", ["ngpMove"], { "disabled": { "alias": "ngpMoveDisabled"; "required": false; "isSignal": true; }; }, { "start": "ngpMoveStart"; "move": "ngpMove"; "end": "ngpMoveEnd"; }, never, never, true, never>;
221
221
  }
@@ -77,7 +77,7 @@ declare class NgpListbox<T> implements AfterContentInit {
77
77
  /**
78
78
  * The listbox state
79
79
  */
80
- private readonly state;
80
+ protected readonly state: ng_primitives_state.CreatedState<NgpListbox<T>>;
81
81
  constructor();
82
82
  ngAfterContentInit(): void;
83
83
  private updateActiveItem;
package/menu/index.d.ts CHANGED
@@ -158,7 +158,7 @@ declare class NgpMenuItem {
158
158
  * If the user presses the left arrow key (in LTR) and there is a parent menu,
159
159
  * we want to close the menu and focus the parent menu item.
160
160
  */
161
- protected handleArrowKey(event: KeyboardEvent): void;
161
+ protected handleArrowKey(event: Event): void;
162
162
  /**
163
163
  * If the user hovers over the trigger, we want to open the submenu
164
164
  */
@@ -272,10 +272,11 @@ declare class NgpSubmenuTrigger<T = unknown> {
272
272
  /**
273
273
  * If the user presses the right arrow key, we want to open the submenu
274
274
  * and focus the first item in the submenu.
275
+ * If the user presses the left arrow key, we want to close the submenu.
275
276
  * This behavior will be inverted if the direction is RTL.
276
277
  * @param event
277
278
  */
278
- protected showSubmenuOnArrow(event: KeyboardEvent): void;
279
+ protected handleArrowKey(event: Event): void;
279
280
  /**
280
281
  * If the user hovers over the trigger, we want to open the submenu
281
282
  */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ng-primitives",
3
3
  "description": "Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. ",
4
4
  "license": "Apache-2.0",
5
- "version": "0.90.0",
5
+ "version": "0.91.0",
6
6
  "keywords": [
7
7
  "angular",
8
8
  "primitives",