ng-primitives 0.124.0 → 0.125.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 (72) hide show
  1. package/date-time-date-fns/README.md +3 -0
  2. package/fesm2022/ng-primitives-avatar.mjs +4 -2
  3. package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
  4. package/fesm2022/ng-primitives-checkbox.mjs +4 -2
  5. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  6. package/fesm2022/ng-primitives-date-picker.mjs +42 -44
  7. package/fesm2022/ng-primitives-date-picker.mjs.map +1 -1
  8. package/fesm2022/ng-primitives-date-time-date-fns.mjs +95 -0
  9. package/fesm2022/ng-primitives-date-time-date-fns.mjs.map +1 -0
  10. package/fesm2022/ng-primitives-date-time-luxon.mjs +21 -3
  11. package/fesm2022/ng-primitives-date-time-luxon.mjs.map +1 -1
  12. package/fesm2022/ng-primitives-date-time.mjs +18 -3
  13. package/fesm2022/ng-primitives-date-time.mjs.map +1 -1
  14. package/fesm2022/ng-primitives-dialog.mjs +11 -4
  15. package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
  16. package/fesm2022/ng-primitives-form-field.mjs +3 -0
  17. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  18. package/fesm2022/ng-primitives-input-otp.mjs +15 -7
  19. package/fesm2022/ng-primitives-input-otp.mjs.map +1 -1
  20. package/fesm2022/ng-primitives-listbox.mjs +5 -4
  21. package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
  22. package/fesm2022/ng-primitives-menu.mjs +8 -0
  23. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  24. package/fesm2022/ng-primitives-meter.mjs +20 -5
  25. package/fesm2022/ng-primitives-meter.mjs.map +1 -1
  26. package/fesm2022/ng-primitives-number-field.mjs +10 -0
  27. package/fesm2022/ng-primitives-number-field.mjs.map +1 -1
  28. package/fesm2022/ng-primitives-pagination.mjs +16 -6
  29. package/fesm2022/ng-primitives-pagination.mjs.map +1 -1
  30. package/fesm2022/ng-primitives-popover.mjs +4 -0
  31. package/fesm2022/ng-primitives-popover.mjs.map +1 -1
  32. package/fesm2022/ng-primitives-progress.mjs +36 -11
  33. package/fesm2022/ng-primitives-progress.mjs.map +1 -1
  34. package/fesm2022/ng-primitives-roving-focus.mjs +13 -2
  35. package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
  36. package/fesm2022/ng-primitives-search.mjs +2 -1
  37. package/fesm2022/ng-primitives-search.mjs.map +1 -1
  38. package/fesm2022/ng-primitives-slider.mjs +38 -18
  39. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  40. package/fesm2022/ng-primitives-switch.mjs +18 -8
  41. package/fesm2022/ng-primitives-switch.mjs.map +1 -1
  42. package/fesm2022/ng-primitives-tabs.mjs +22 -6
  43. package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
  44. package/fesm2022/ng-primitives-textarea.mjs +10 -8
  45. package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
  46. package/fesm2022/ng-primitives-toast.mjs +3 -0
  47. package/fesm2022/ng-primitives-toast.mjs.map +1 -1
  48. package/fesm2022/ng-primitives-toggle-group.mjs +31 -8
  49. package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
  50. package/package.json +8 -1
  51. package/schematics/ng-generate/templates/checkbox/checkbox.__fileSuffix@dasherize__.ts.template +2 -1
  52. package/schematics/ng-generate/templates/combobox/combobox.__fileSuffix@dasherize__.ts.template +3 -2
  53. package/schematics/ng-generate/templates/date-picker/date-picker.__fileSuffix@dasherize__.ts.template +2 -1
  54. package/schematics/ng-generate/templates/listbox/listbox.__fileSuffix@dasherize__.ts.template +9 -4
  55. package/schematics/ng-generate/templates/pagination/pagination.__fileSuffix@dasherize__.ts.template +7 -1
  56. package/schematics/ng-generate/templates/range-slider/range-slider.__fileSuffix@dasherize__.ts.template +4 -3
  57. package/schematics/ng-generate/templates/slider/slider.__fileSuffix@dasherize__.ts.template +2 -1
  58. package/schematics/ng-generate/templates/switch/switch.__fileSuffix@dasherize__.ts.template +2 -1
  59. package/types/ng-primitives-checkbox.d.ts +5 -1
  60. package/types/ng-primitives-date-picker.d.ts +7 -9
  61. package/types/ng-primitives-date-time-date-fns.d.ts +30 -0
  62. package/types/ng-primitives-date-time.d.ts +15 -3
  63. package/types/ng-primitives-dialog.d.ts +4 -0
  64. package/types/ng-primitives-input-otp.d.ts +5 -5
  65. package/types/ng-primitives-meter.d.ts +9 -2
  66. package/types/ng-primitives-pagination.d.ts +34 -8
  67. package/types/ng-primitives-progress.d.ts +4 -2
  68. package/types/ng-primitives-roving-focus.d.ts +7 -0
  69. package/types/ng-primitives-slider.d.ts +5 -4
  70. package/types/ng-primitives-switch.d.ts +14 -4
  71. package/types/ng-primitives-tabs.d.ts +6 -1
  72. package/types/ng-primitives-toggle-group.d.ts +51 -37
@@ -24,19 +24,26 @@ declare class NgpMeter {
24
24
  * Define a function that returns the meter value label.
25
25
  * @param value The current value
26
26
  * @param max The maximum value
27
+ * @param min The minimum value
27
28
  * @returns The value label
28
29
  */
29
30
  readonly valueLabel: _angular_core.InputSignal<NgpMeterValueTextFn>;
30
31
  /** @internal Store the label instance */
31
32
  readonly label: _angular_core.WritableSignal<NgpMeterLabel | null>;
32
- /** @internal The percentage of the meter. */
33
+ /** @internal The percentage of the meter, used for the visual indicator width. */
33
34
  readonly percentage: _angular_core.Signal<number>;
35
+ /**
36
+ * @internal
37
+ * The raw value exposed via `aria-valuenow`, clamped to the [min, max] range.
38
+ * Per the ARIA meter pattern, `aria-valuenow` is the actual value, not a percentage.
39
+ */
40
+ readonly valueNow: _angular_core.Signal<number>;
34
41
  /** The state of the meter. */
35
42
  private readonly state;
36
43
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpMeter, never>;
37
44
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMeter, "[ngpMeter]", ["ngpMeter"], { "value": { "alias": "ngpMeterValue"; "required": false; "isSignal": true; }; "min": { "alias": "ngpMeterMin"; "required": false; "isSignal": true; }; "max": { "alias": "ngpMeterMax"; "required": false; "isSignal": true; }; "valueLabel": { "alias": "ngpMeterValueLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
38
45
  }
39
- type NgpMeterValueTextFn = (value: number, max: number) => string;
46
+ type NgpMeterValueTextFn = (value: number, max: number, min: number) => string;
40
47
 
41
48
  /**
42
49
  * Provides the Meter state.
@@ -1,9 +1,10 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { WritableSignal, Signal } from '@angular/core';
3
3
  import { NumberInput, BooleanInput } from '@angular/cdk/coercion';
4
+ import * as ng_primitives_state from 'ng-primitives/state';
5
+ import { SetterOptions } from 'ng-primitives/state';
4
6
  import * as rxjs from 'rxjs';
5
7
  import { Observable } from 'rxjs';
6
- import * as ng_primitives_state from 'ng-primitives/state';
7
8
 
8
9
  /**
9
10
  * The `NgpPaginationButton` directive is used to create a pagination button.
@@ -144,9 +145,11 @@ declare class NgpPagination {
144
145
  page: _angular_core.WritableSignal<number>;
145
146
  pageCount: _angular_core.Signal<number>;
146
147
  pageChange: rxjs.Observable<number>;
147
- disabled: _angular_core.Signal<boolean>;
148
+ disabled: _angular_core.WritableSignal<boolean>;
149
+ setDisabled: (value: boolean) => void;
148
150
  firstPage: _angular_core.Signal<boolean>;
149
151
  lastPage: _angular_core.Signal<boolean>;
152
+ setPage: (value: number, options?: ng_primitives_state.SetterOptions) => void;
150
153
  goToPage: (page: number) => void;
151
154
  };
152
155
  /**
@@ -171,6 +174,11 @@ interface NgpPaginationState {
171
174
  * Whether the pagination is disabled.
172
175
  */
173
176
  readonly disabled: Signal<boolean>;
177
+ /**
178
+ * Set the disabled state (e.g. from a form control).
179
+ * @param disabled The disabled state.
180
+ */
181
+ setDisabled: (disabled: boolean) => void;
174
182
  /**
175
183
  * Determine if we are on the first page.
176
184
  * @internal
@@ -185,6 +193,12 @@ interface NgpPaginationState {
185
193
  * The event that is fired when the page changes.
186
194
  */
187
195
  readonly pageChange: Observable<number>;
196
+ /**
197
+ * Set the current page directly (no bounds navigation logic).
198
+ * @param page The page to set.
199
+ * @param options Setter options, e.g. `{ emit: false }` to suppress change emission.
200
+ */
201
+ setPage: (page: number, options?: SetterOptions) => void;
188
202
  /**
189
203
  * Go to the specified page.
190
204
  * @param page The page to go to.
@@ -216,18 +230,22 @@ declare const NgpPaginationStateToken: _angular_core.InjectionToken<WritableSign
216
230
  page: WritableSignal<number>;
217
231
  pageCount: Signal<number>;
218
232
  pageChange: Observable<number>;
219
- disabled: Signal<boolean>;
233
+ disabled: WritableSignal<boolean>;
234
+ setDisabled: (value: boolean) => void;
220
235
  firstPage: Signal<boolean>;
221
236
  lastPage: Signal<boolean>;
237
+ setPage: (value: number, options?: SetterOptions) => void;
222
238
  goToPage: (page: number) => void;
223
239
  }>>;
224
240
  declare const ngpPagination: ({ page: _page, defaultPage: _defaultPage, pageCount: _pageCount, disabled: _disabled, onPageChange, }: NgpPaginationProps) => {
225
241
  page: WritableSignal<number>;
226
242
  pageCount: Signal<number>;
227
243
  pageChange: Observable<number>;
228
- disabled: Signal<boolean>;
244
+ disabled: WritableSignal<boolean>;
245
+ setDisabled: (value: boolean) => void;
229
246
  firstPage: Signal<boolean>;
230
247
  lastPage: Signal<boolean>;
248
+ setPage: (value: number, options?: SetterOptions) => void;
231
249
  goToPage: (page: number) => void;
232
250
  };
233
251
  declare const injectPaginationState: {
@@ -235,35 +253,43 @@ declare const injectPaginationState: {
235
253
  page: WritableSignal<number>;
236
254
  pageCount: Signal<number>;
237
255
  pageChange: Observable<number>;
238
- disabled: Signal<boolean>;
256
+ disabled: WritableSignal<boolean>;
257
+ setDisabled: (value: boolean) => void;
239
258
  firstPage: Signal<boolean>;
240
259
  lastPage: Signal<boolean>;
260
+ setPage: (value: number, options?: SetterOptions) => void;
241
261
  goToPage: (page: number) => void;
242
262
  }>;
243
263
  (options: ng_primitives_state.StateInjectionOptions): Signal<{
244
264
  page: WritableSignal<number>;
245
265
  pageCount: Signal<number>;
246
266
  pageChange: Observable<number>;
247
- disabled: Signal<boolean>;
267
+ disabled: WritableSignal<boolean>;
268
+ setDisabled: (value: boolean) => void;
248
269
  firstPage: Signal<boolean>;
249
270
  lastPage: Signal<boolean>;
271
+ setPage: (value: number, options?: SetterOptions) => void;
250
272
  goToPage: (page: number) => void;
251
273
  } | null>;
252
274
  (options?: ng_primitives_state.StateInjectionOptions): Signal<{
253
275
  page: WritableSignal<number>;
254
276
  pageCount: Signal<number>;
255
277
  pageChange: Observable<number>;
256
- disabled: Signal<boolean>;
278
+ disabled: WritableSignal<boolean>;
279
+ setDisabled: (value: boolean) => void;
257
280
  firstPage: Signal<boolean>;
258
281
  lastPage: Signal<boolean>;
282
+ setPage: (value: number, options?: SetterOptions) => void;
259
283
  goToPage: (page: number) => void;
260
284
  }> | Signal<{
261
285
  page: WritableSignal<number>;
262
286
  pageCount: Signal<number>;
263
287
  pageChange: Observable<number>;
264
- disabled: Signal<boolean>;
288
+ disabled: WritableSignal<boolean>;
289
+ setDisabled: (value: boolean) => void;
265
290
  firstPage: Signal<boolean>;
266
291
  lastPage: Signal<boolean>;
292
+ setPage: (value: number, options?: SetterOptions) => void;
267
293
  goToPage: (page: number) => void;
268
294
  } | null>;
269
295
  };
@@ -81,6 +81,7 @@ declare class NgpProgress {
81
81
  * Define a function that returns the progress value label.
82
82
  * @param value The current value
83
83
  * @param max The maximum value
84
+ * @param min The minimum value
84
85
  * @returns The value label
85
86
  */
86
87
  readonly valueLabel: _angular_core.InputSignal<NgpProgressValueTextFn>;
@@ -100,7 +101,7 @@ declare class NgpProgress {
100
101
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpProgress, never>;
101
102
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpProgress, "[ngpProgress]", never, { "value": { "alias": "ngpProgressValue"; "required": false; "isSignal": true; }; "min": { "alias": "ngpProgressMin"; "required": false; "isSignal": true; }; "max": { "alias": "ngpProgressMax"; "required": false; "isSignal": true; }; "valueLabel": { "alias": "ngpProgressValueLabel"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
102
103
  }
103
- type NgpProgressValueTextFn = (value: number, max: number) => string;
104
+ type NgpProgressValueTextFn = (value: number, max: number, min: number) => string;
104
105
 
105
106
  interface NgpProgressProps {
106
107
  /**
@@ -149,7 +150,8 @@ interface NgpProgressState {
149
150
  */
150
151
  readonly max: WritableSignal<number>;
151
152
  /**
152
- * Get the progress value text.
153
+ * Get the progress value text. An empty string while the progress is
154
+ * indeterminate (the `aria-valuetext` attribute is omitted in that case).
153
155
  */
154
156
  readonly valueText: Signal<string>;
155
157
  /**
@@ -142,6 +142,13 @@ interface NgpRovingFocusGroupState {
142
142
  * @param origin The origin of the focus change
143
143
  */
144
144
  setActiveItem(id: string | null, origin?: FocusOrigin): void;
145
+ /**
146
+ * Set which item holds the tab stop without moving focus. Used by items that
147
+ * declare themselves active (e.g. the selected tab) to claim the tab stop
148
+ * without stealing focus.
149
+ * @param id The id of the item that should hold the tab stop.
150
+ */
151
+ setTabStop(id: string | null): void;
145
152
  /**
146
153
  * Register an item with the roving focus group.
147
154
  * @param item The item to register
@@ -1,6 +1,7 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Signal, WritableSignal, ElementRef } from '@angular/core';
3
3
  import * as ng_primitives_state from 'ng-primitives/state';
4
+ import { SetterOptions } from 'ng-primitives/state';
4
5
  import { FocusOrigin } from '@angular/cdk/a11y';
5
6
  import * as ng_primitives_slider from 'ng-primitives/slider';
6
7
  import { NumberInput, BooleanInput } from '@angular/cdk/coercion';
@@ -162,7 +163,7 @@ declare class NgpSlider {
162
163
  /**
163
164
  * Set the value of the slider.
164
165
  */
165
- setValue(value: number): void;
166
+ setValue(value: number, options?: SetterOptions): void;
166
167
  /**
167
168
  * Set the disabled state.
168
169
  */
@@ -226,7 +227,7 @@ interface NgpSliderState {
226
227
  /**
227
228
  * Set the current value (clamped).
228
229
  */
229
- setValue(value: number): void;
230
+ setValue(value: number, options?: SetterOptions): void;
230
231
  /**
231
232
  * Register the track element.
232
233
  */
@@ -598,11 +599,11 @@ interface NgpRangeSliderState {
598
599
  /**
599
600
  * Updates the low value, ensuring it doesn't exceed the high value.
600
601
  */
601
- setLowValue(value: number): void;
602
+ setLowValue(value: number, options?: SetterOptions): void;
602
603
  /**
603
604
  * Updates the high value, ensuring it doesn't go below the low value.
604
605
  */
605
- setHighValue(value: number): void;
606
+ setHighValue(value: number, options?: SetterOptions): void;
606
607
  /**
607
608
  * Determines which thumb should be moved based on the position clicked.
608
609
  */
@@ -1,6 +1,7 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Signal, WritableSignal } from '@angular/core';
3
3
  import * as ng_primitives_state from 'ng-primitives/state';
4
+ import { SetterOptions } from 'ng-primitives/state';
4
5
  import * as ng_primitives_switch from 'ng-primitives/switch';
5
6
  import { BooleanInput } from '@angular/cdk/coercion';
6
7
  import { Observable } from 'rxjs';
@@ -64,6 +65,11 @@ declare class NgpSwitch {
64
65
  * @default false
65
66
  */
66
67
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
68
+ /**
69
+ * Whether the switch is required.
70
+ * @default false
71
+ */
72
+ readonly required: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
67
73
  /**
68
74
  * The switch state.
69
75
  * @internal
@@ -76,13 +82,13 @@ declare class NgpSwitch {
76
82
  /**
77
83
  * Update the checked value.
78
84
  */
79
- setChecked(value: boolean): void;
85
+ setChecked(value: boolean, options?: SetterOptions): void;
80
86
  /**
81
87
  * Update the disabled value.
82
88
  */
83
89
  setDisabled(value: boolean): void;
84
90
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpSwitch, never>;
85
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpSwitch, "[ngpSwitch]", ["ngpSwitch"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "checked": { "alias": "ngpSwitchChecked"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpSwitchDisabled"; "required": false; "isSignal": true; }; }, { "checkedChange": "ngpSwitchCheckedChange"; }, never, never, true, never>;
91
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpSwitch, "[ngpSwitch]", ["ngpSwitch"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "checked": { "alias": "ngpSwitchChecked"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpSwitchDisabled"; "required": false; "isSignal": true; }; "required": { "alias": "ngpSwitchRequired"; "required": false; "isSignal": true; }; }, { "checkedChange": "ngpSwitchCheckedChange"; }, never, never, true, never>;
86
92
  }
87
93
 
88
94
  /**
@@ -112,7 +118,7 @@ interface NgpSwitchState {
112
118
  /**
113
119
  * Update the checked value.
114
120
  */
115
- setChecked(value: boolean): void;
121
+ setChecked(value: boolean, options?: SetterOptions): void;
116
122
  /**
117
123
  * Update the disabled value.
118
124
  */
@@ -134,12 +140,16 @@ interface NgpSwitchProps {
134
140
  * Whether the switch is disabled.
135
141
  */
136
142
  readonly disabled?: Signal<boolean>;
143
+ /**
144
+ * Whether the switch is required.
145
+ */
146
+ readonly required?: Signal<boolean>;
137
147
  /**
138
148
  * Callback fired when the checked state changes.
139
149
  */
140
150
  readonly onCheckedChange?: (checked: boolean) => void;
141
151
  }
142
- declare const ngpSwitch: ({ id, checked: _checked, disabled: _disabled, onCheckedChange, }: NgpSwitchProps) => NgpSwitchState;
152
+ declare const ngpSwitch: ({ id, checked: _checked, disabled: _disabled, required: _required, onCheckedChange, }: NgpSwitchProps) => NgpSwitchState;
143
153
  declare const injectSwitchState: {
144
154
  (): Signal<NgpSwitchState>;
145
155
  (options: ng_primitives_state.StateInjectionOptions): Signal<NgpSwitchState | null>;
@@ -277,6 +277,11 @@ declare class NgpTabset {
277
277
  * Whether tabs should activate on focus
278
278
  */
279
279
  readonly activateOnFocus: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
280
+ /**
281
+ * Whether keyboard focus should wrap around the tab list.
282
+ * @default true (from the global tabs config)
283
+ */
284
+ readonly wrap: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
280
285
  private readonly state;
281
286
  /**
282
287
  * @internal
@@ -294,7 +299,7 @@ declare class NgpTabset {
294
299
  */
295
300
  setOrientation(orientation: NgpOrientation): void;
296
301
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpTabset, never>;
297
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpTabset, "[ngpTabset]", ["ngpTabset"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "value": { "alias": "ngpTabsetValue"; "required": false; "isSignal": true; }; "orientation": { "alias": "ngpTabsetOrientation"; "required": false; "isSignal": true; }; "activateOnFocus": { "alias": "ngpTabsetActivateOnFocus"; "required": false; "isSignal": true; }; }, { "valueChange": "ngpTabsetValueChange"; }, never, never, true, never>;
302
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpTabset, "[ngpTabset]", ["ngpTabset"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "value": { "alias": "ngpTabsetValue"; "required": false; "isSignal": true; }; "orientation": { "alias": "ngpTabsetOrientation"; "required": false; "isSignal": true; }; "activateOnFocus": { "alias": "ngpTabsetActivateOnFocus"; "required": false; "isSignal": true; }; "wrap": { "alias": "ngpTabsetWrap"; "required": false; "isSignal": true; }; }, { "valueChange": "ngpTabsetValueChange"; }, never, never, true, never>;
298
303
  }
299
304
 
300
305
  /**
@@ -3,7 +3,7 @@ import { Provider, OnInit, Signal, WritableSignal } from '@angular/core';
3
3
  import { NgpOrientation } from 'ng-primitives/common';
4
4
  import { BooleanInput } from '@angular/cdk/coercion';
5
5
  import * as ng_primitives_state from 'ng-primitives/state';
6
- import { SetterOptions } from 'ng-primitives/state';
6
+ import { SetterOptions, StateInjectionOptions } from 'ng-primitives/state';
7
7
  import * as ng_primitives_toggle_group from 'ng-primitives/toggle-group';
8
8
  import { Observable } from 'rxjs';
9
9
 
@@ -36,20 +36,20 @@ interface NgpToggleGroupConfig {
36
36
  */
37
37
  declare function provideToggleGroupConfig(config: Partial<NgpToggleGroupConfig>): Provider[];
38
38
 
39
- declare class NgpToggleGroupItem implements OnInit {
39
+ declare class NgpToggleGroupItem<T = string> implements OnInit {
40
40
  /**
41
41
  * The value of the item.
42
42
  * @required
43
43
  */
44
- readonly value: _angular_core.InputSignal<string | undefined>;
44
+ readonly value: _angular_core.InputSignal<T | undefined>;
45
45
  /**
46
46
  * Whether the item is disabled.
47
47
  */
48
48
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
49
49
  constructor();
50
50
  ngOnInit(): void;
51
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpToggleGroupItem, never>;
52
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpToggleGroupItem, "[ngpToggleGroupItem]", ["ngpToggleGroupItem"], { "value": { "alias": "ngpToggleGroupItemValue"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpToggleGroupItemDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
51
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpToggleGroupItem<any>, never>;
52
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpToggleGroupItem<any>, "[ngpToggleGroupItem]", ["ngpToggleGroupItem"], { "value": { "alias": "ngpToggleGroupItemValue"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpToggleGroupItemDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
53
53
  }
54
54
 
55
55
  /**
@@ -62,17 +62,17 @@ interface NgpToggleGroupItemState {
62
62
  /**
63
63
  * The props interface for the ToggleGroupItem pattern.
64
64
  */
65
- interface NgpToggleGroupItemProps {
65
+ interface NgpToggleGroupItemProps<T = string> {
66
66
  /**
67
67
  * The value of the toggle group item.
68
68
  */
69
- value: Signal<string>;
69
+ value: Signal<T>;
70
70
  /**
71
71
  * Whether the toggle group item is disabled.
72
72
  */
73
73
  disabled?: Signal<boolean>;
74
74
  }
75
- declare const ngpToggleGroupItem: ({ value, disabled }: NgpToggleGroupItemProps) => NgpToggleGroupItemState;
75
+ declare const ngpToggleGroupItem: <T = string>({ value, disabled, }: NgpToggleGroupItemProps<T>) => NgpToggleGroupItemState;
76
76
  declare const injectToggleGroupItemState: {
77
77
  (): Signal<NgpToggleGroupItemState>;
78
78
  (options: ng_primitives_state.StateInjectionOptions): Signal<NgpToggleGroupItemState | null>;
@@ -82,7 +82,7 @@ declare const provideToggleGroupItemState: (opts?: {
82
82
  inherit?: boolean;
83
83
  }) => _angular_core.FactoryProvider;
84
84
 
85
- declare class NgpToggleGroup {
85
+ declare class NgpToggleGroup<T = string> {
86
86
  /**
87
87
  * Access the global toggle group configuration.
88
88
  */
@@ -108,16 +108,22 @@ declare class NgpToggleGroup {
108
108
  /**
109
109
  * The selected value(s) of the toggle group.
110
110
  */
111
- readonly value: _angular_core.InputSignal<string[] | undefined>;
111
+ readonly value: _angular_core.InputSignal<T[] | undefined>;
112
112
  /**
113
113
  * The default selected value(s) for uncontrolled usage.
114
114
  * @default []
115
115
  */
116
- readonly defaultValue: _angular_core.InputSignal<string[]>;
116
+ readonly defaultValue: _angular_core.InputSignal<T[]>;
117
117
  /**
118
118
  * Emits when the value of the toggle group changes.
119
119
  */
120
- readonly valueChange: _angular_core.OutputEmitterRef<string[]>;
120
+ readonly valueChange: _angular_core.OutputEmitterRef<T[]>;
121
+ /**
122
+ * The comparator used to determine whether two values are equal.
123
+ * Useful when values are objects and equality should be checked by value rather than by reference.
124
+ * @default (a, b) => a === b
125
+ */
126
+ readonly compareWith: _angular_core.InputSignal<(a: T, b: T) => boolean>;
121
127
  /**
122
128
  * Whether the toggle group is disabled.
123
129
  */
@@ -125,19 +131,19 @@ declare class NgpToggleGroup {
125
131
  /**
126
132
  * The state of the toggle group.
127
133
  */
128
- protected readonly state: ng_primitives_toggle_group.NgpToggleGroupState;
134
+ protected readonly state: ng_primitives_toggle_group.NgpToggleGroupState<T>;
129
135
  /**
130
136
  * Toggle a value in the toggle group.
131
137
  */
132
- toggle(value: string): void;
138
+ toggle(value: T): void;
133
139
  /**
134
140
  * Set the value(s) of the toggle group.
135
141
  */
136
- setValue(newValue: string[], options?: SetterOptions): void;
142
+ setValue(newValue: T[], options?: SetterOptions): void;
137
143
  /**
138
144
  * Set the default value(s) of the toggle group.
139
145
  */
140
- setDefaultValue(defaultValue: string[]): void;
146
+ setDefaultValue(defaultValue: T[]): void;
141
147
  /**
142
148
  * Set the disabled state of the toggle group.
143
149
  */
@@ -146,22 +152,22 @@ declare class NgpToggleGroup {
146
152
  * Set the orientation of the toggle group.
147
153
  */
148
154
  setOrientation(newOrientation: NgpOrientation): void;
149
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpToggleGroup, never>;
150
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpToggleGroup, "[ngpToggleGroup]", ["ngpToggleGroup"], { "orientation": { "alias": "ngpToggleGroupOrientation"; "required": false; "isSignal": true; }; "wrap": { "alias": "ngpToggleGroupWrap"; "required": false; "isSignal": true; }; "allowDeselection": { "alias": "ngpToggleGroupAllowDeselection"; "required": false; "isSignal": true; }; "type": { "alias": "ngpToggleGroupType"; "required": false; "isSignal": true; }; "value": { "alias": "ngpToggleGroupValue"; "required": false; "isSignal": true; }; "defaultValue": { "alias": "ngpToggleGroupDefaultValue"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpToggleGroupDisabled"; "required": false; "isSignal": true; }; }, { "valueChange": "ngpToggleGroupValueChange"; }, never, never, true, never>;
155
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpToggleGroup<any>, never>;
156
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpToggleGroup<any>, "[ngpToggleGroup]", ["ngpToggleGroup"], { "orientation": { "alias": "ngpToggleGroupOrientation"; "required": false; "isSignal": true; }; "wrap": { "alias": "ngpToggleGroupWrap"; "required": false; "isSignal": true; }; "allowDeselection": { "alias": "ngpToggleGroupAllowDeselection"; "required": false; "isSignal": true; }; "type": { "alias": "ngpToggleGroupType"; "required": false; "isSignal": true; }; "value": { "alias": "ngpToggleGroupValue"; "required": false; "isSignal": true; }; "defaultValue": { "alias": "ngpToggleGroupDefaultValue"; "required": false; "isSignal": true; }; "compareWith": { "alias": "ngpToggleGroupCompareWith"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpToggleGroupDisabled"; "required": false; "isSignal": true; }; }, { "valueChange": "ngpToggleGroupValueChange"; }, never, never, true, never>;
151
157
  }
152
158
 
153
159
  /**
154
160
  * The state interface for the ToggleGroup pattern.
155
161
  */
156
- interface NgpToggleGroupState {
162
+ interface NgpToggleGroupState<T = string> {
157
163
  /**
158
164
  * The current value(s) of the toggle group.
159
165
  */
160
- readonly value: WritableSignal<string[]>;
166
+ readonly value: WritableSignal<T[]>;
161
167
  /**
162
168
  * Emit when the value changes.
163
169
  */
164
- readonly valueChange: Observable<string[]>;
170
+ readonly valueChange: Observable<T[]>;
165
171
  /**
166
172
  * Whether the toggle group is disabled.
167
173
  */
@@ -170,30 +176,34 @@ interface NgpToggleGroupState {
170
176
  * The orientation of the toggle group.
171
177
  */
172
178
  readonly orientation: WritableSignal<NgpOrientation>;
179
+ /**
180
+ * The type of the toggle group, whether only one item can be selected or multiple.
181
+ */
182
+ readonly type: Signal<'single' | 'multiple'>;
173
183
  /**
174
184
  * Select a value in the toggle group.
175
185
  */
176
- select(selection: string): void;
186
+ select(selection: T): void;
177
187
  /**
178
188
  * De-select a value in the toggle group.
179
189
  */
180
- deselect(selection: string): void;
190
+ deselect(selection: T): void;
181
191
  /**
182
192
  * Check if a value is selected in the toggle group.
183
193
  */
184
- isSelected(selection: string): boolean;
194
+ isSelected(selection: T): boolean;
185
195
  /**
186
196
  * Toggle a value in the toggle group.
187
197
  */
188
- toggle(selection: string): void;
198
+ toggle(selection: T): void;
189
199
  /**
190
200
  * Set the value(s) of the toggle group.
191
201
  */
192
- setValue(newValue: string[], options?: SetterOptions): void;
202
+ setValue(newValue: T[], options?: SetterOptions): void;
193
203
  /**
194
204
  * Set the default value(s) of the toggle group.
195
205
  */
196
- setDefaultValue(defaultValue: string[]): void;
206
+ setDefaultValue(defaultValue: T[]): void;
197
207
  /**
198
208
  * Set the disabled state of the toggle group.
199
209
  */
@@ -206,7 +216,7 @@ interface NgpToggleGroupState {
206
216
  /**
207
217
  * The props interface for the ToggleGroup pattern.
208
218
  */
209
- interface NgpToggleGroupProps {
219
+ interface NgpToggleGroupProps<T = string> {
210
220
  /**
211
221
  * The orientation of the toggle-group.
212
222
  */
@@ -226,29 +236,33 @@ interface NgpToggleGroupProps {
226
236
  /**
227
237
  * The value(s) of the toggle-group.
228
238
  */
229
- readonly value: Signal<string[] | undefined>;
239
+ readonly value: Signal<T[] | undefined>;
230
240
  /**
231
241
  * The default value(s) of the toggle-group for uncontrolled usage.
232
242
  */
233
- readonly defaultValue?: Signal<string[]>;
243
+ readonly defaultValue?: Signal<T[]>;
234
244
  /**
235
245
  * Whether the toggle-group is disabled.
236
246
  */
237
247
  readonly disabled?: Signal<boolean>;
248
+ /**
249
+ * The comparator used to determine whether two values are equal.
250
+ * @default (a, b) => a === b
251
+ */
252
+ readonly compareWith?: Signal<(a: T, b: T) => boolean>;
238
253
  /**
239
254
  * Emit when the value changes.
240
255
  */
241
- readonly onValueChange?: (value: string[]) => void;
256
+ readonly onValueChange?: (value: T[]) => void;
242
257
  }
243
- declare const ngpToggleGroup: ({ orientation: _orientation, wrap: _wrap, allowDeselection: _allowDeselection, type: _type, value: _value, defaultValue: _defaultValue, disabled: _disabled, onValueChange, }: NgpToggleGroupProps) => NgpToggleGroupState;
244
- declare const injectToggleGroupState: {
245
- (): Signal<NgpToggleGroupState>;
246
- (options: ng_primitives_state.StateInjectionOptions): Signal<NgpToggleGroupState | null>;
247
- (options?: ng_primitives_state.StateInjectionOptions): Signal<NgpToggleGroupState> | Signal<NgpToggleGroupState | null>;
248
- };
258
+ declare const ngpToggleGroup: <T = string>({ orientation: _orientation, wrap: _wrap, allowDeselection: _allowDeselection, type: _type, value: _value, defaultValue: _defaultValue, disabled: _disabled, compareWith: _compareWith, onValueChange, }: NgpToggleGroupProps<T>) => NgpToggleGroupState<T>;
249
259
  declare const provideToggleGroupState: (opts?: {
250
260
  inherit?: boolean;
251
261
  }) => _angular_core.FactoryProvider;
262
+ /**
263
+ * Injects the ToggleGroup state, typed to the value type `T`.
264
+ */
265
+ declare function injectToggleGroupState<T = string>(options?: StateInjectionOptions): Signal<NgpToggleGroupState<T>>;
252
266
 
253
267
  export { NgpToggleGroup, NgpToggleGroupItem, injectToggleGroupItemState, injectToggleGroupState, ngpToggleGroup, ngpToggleGroupItem, provideToggleGroupConfig, provideToggleGroupItemState, provideToggleGroupState };
254
268
  export type { NgpToggleGroupConfig, NgpToggleGroupItemProps, NgpToggleGroupItemState, NgpToggleGroupProps, NgpToggleGroupState };