ng-primitives 0.93.0 → 0.94.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 (55) hide show
  1. package/a11y/index.d.ts +2 -0
  2. package/accordion/index.d.ts +22 -0
  3. package/autofill/index.d.ts +2 -0
  4. package/avatar/index.d.ts +6 -0
  5. package/breadcrumbs/index.d.ts +14 -0
  6. package/button/index.d.ts +21 -3
  7. package/checkbox/index.d.ts +14 -0
  8. package/fesm2022/ng-primitives-accordion.mjs +24 -0
  9. package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
  10. package/fesm2022/ng-primitives-button.mjs +18 -4
  11. package/fesm2022/ng-primitives-button.mjs.map +1 -1
  12. package/fesm2022/ng-primitives-checkbox.mjs +18 -0
  13. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  14. package/fesm2022/ng-primitives-file-upload.mjs +2 -2
  15. package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
  16. package/fesm2022/ng-primitives-input.mjs +10 -2
  17. package/fesm2022/ng-primitives-input.mjs.map +1 -1
  18. package/fesm2022/ng-primitives-menu.mjs +313 -352
  19. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  20. package/fesm2022/ng-primitives-roving-focus.mjs +1 -1
  21. package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
  22. package/fesm2022/ng-primitives-separator.mjs +15 -7
  23. package/fesm2022/ng-primitives-separator.mjs.map +1 -1
  24. package/fesm2022/ng-primitives-slider.mjs +22 -4
  25. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  26. package/fesm2022/ng-primitives-state.mjs +12 -6
  27. package/fesm2022/ng-primitives-state.mjs.map +1 -1
  28. package/fesm2022/ng-primitives-switch.mjs +12 -0
  29. package/fesm2022/ng-primitives-switch.mjs.map +1 -1
  30. package/fesm2022/ng-primitives-tabs.mjs +6 -0
  31. package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
  32. package/fesm2022/ng-primitives-textarea.mjs +7 -0
  33. package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
  34. package/fesm2022/ng-primitives-toggle-group.mjs +18 -0
  35. package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
  36. package/fesm2022/ng-primitives-toggle.mjs +12 -0
  37. package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
  38. package/fesm2022/ng-primitives-toolbar.mjs +2 -2
  39. package/fesm2022/ng-primitives-toolbar.mjs.map +1 -1
  40. package/file-upload/index.d.ts +12 -8
  41. package/focus-trap/index.d.ts +2 -0
  42. package/form-field/index.d.ts +8 -0
  43. package/input/index.d.ts +13 -0
  44. package/menu/index.d.ts +247 -120
  45. package/package.json +1 -1
  46. package/roving-focus/index.d.ts +82 -10
  47. package/separator/index.d.ts +1 -0
  48. package/slider/index.d.ts +20 -0
  49. package/state/index.d.ts +9 -0
  50. package/switch/index.d.ts +12 -0
  51. package/tabs/index.d.ts +12 -0
  52. package/textarea/index.d.ts +7 -0
  53. package/toggle/index.d.ts +7 -0
  54. package/toggle-group/index.d.ts +16 -0
  55. package/toolbar/index.d.ts +2 -0
package/input/index.d.ts CHANGED
@@ -19,6 +19,7 @@ declare class NgpInput {
19
19
  id: _angular_core.Signal<string>;
20
20
  disabled: _angular_core.WritableSignal<boolean>;
21
21
  status: _angular_core.Signal<ng_primitives_utils.NgpControlStatus>;
22
+ setDisabled: (value: boolean) => void;
22
23
  };
23
24
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpInput, never>;
24
25
  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,6 +37,11 @@ interface NgpInputState {
36
37
  * Whether the input is disabled.
37
38
  */
38
39
  readonly disabled: WritableSignal<boolean>;
40
+ /**
41
+ * Set the disabled state of the input.
42
+ * @param value The disabled state.
43
+ */
44
+ setDisabled(value: boolean): void;
39
45
  }
40
46
  /**
41
47
  * Inputs for configuring the Input primitive.
@@ -54,32 +60,39 @@ declare const ngpInput: ({ id, disabled: _disabled }: NgpInputProps) => {
54
60
  id: Signal<string>;
55
61
  disabled: WritableSignal<boolean>;
56
62
  status: Signal<ng_primitives_utils.NgpControlStatus>;
63
+ setDisabled: (value: boolean) => void;
57
64
  };
58
65
  declare const injectInputState: {
59
66
  (): Signal<{
60
67
  id: Signal<string>;
61
68
  disabled: WritableSignal<boolean>;
62
69
  status: Signal<ng_primitives_utils.NgpControlStatus>;
70
+ setDisabled: (value: boolean) => void;
63
71
  }>;
64
72
  (options: {
65
73
  hoisted: true;
66
74
  optional?: boolean;
75
+ skipSelf?: boolean;
67
76
  }): Signal<{
68
77
  id: Signal<string>;
69
78
  disabled: WritableSignal<boolean>;
70
79
  status: Signal<ng_primitives_utils.NgpControlStatus>;
80
+ setDisabled: (value: boolean) => void;
71
81
  } | null>;
72
82
  (options?: {
73
83
  hoisted?: boolean;
74
84
  optional?: boolean;
85
+ skipSelf?: boolean;
75
86
  }): Signal<{
76
87
  id: Signal<string>;
77
88
  disabled: WritableSignal<boolean>;
78
89
  status: Signal<ng_primitives_utils.NgpControlStatus>;
90
+ setDisabled: (value: boolean) => void;
79
91
  }> | Signal<{
80
92
  id: Signal<string>;
81
93
  disabled: WritableSignal<boolean>;
82
94
  status: Signal<ng_primitives_utils.NgpControlStatus>;
95
+ setDisabled: (value: boolean) => void;
83
96
  } | null>;
84
97
  };
85
98
  declare const provideInputState: (opts?: {
package/menu/index.d.ts CHANGED
@@ -1,31 +1,15 @@
1
- import * as ng_primitives_portal from 'ng-primitives/portal';
2
- import { NgpOverlayContent, NgpOffset, NgpOffsetInput, NgpOverlay } from 'ng-primitives/portal';
1
+ import { NgpOverlayContent, NgpOffset, NgpOffsetInput } from 'ng-primitives/portal';
3
2
  export { injectOverlayContext as injectMenuContext } from 'ng-primitives/portal';
4
3
  import * as _angular_core from '@angular/core';
5
- import { OnDestroy, Provider, InjectionToken } from '@angular/core';
6
- import * as ng_primitives_state from 'ng-primitives/state';
4
+ import { Provider, Signal } from '@angular/core';
7
5
  import { FocusOrigin } from '@angular/cdk/a11y';
8
6
  import { BooleanInput } from '@angular/cdk/coercion';
9
- import * as i1 from 'ng-primitives/roving-focus';
10
7
  import { Subject } from 'rxjs';
11
- import * as i2 from 'ng-primitives/focus-trap';
12
8
 
13
9
  /**
14
10
  * The `NgpMenuTrigger` directive allows you to turn an element into a menu trigger.
15
11
  */
16
- declare class NgpMenuTrigger<T = unknown> implements OnDestroy {
17
- /**
18
- * Access the trigger element
19
- */
20
- private readonly trigger;
21
- /**
22
- * Access the injector.
23
- */
24
- private readonly injector;
25
- /**
26
- * Access the view container reference.
27
- */
28
- private readonly viewContainerRef;
12
+ declare class NgpMenuTrigger<T = unknown> {
29
13
  /**
30
14
  * Access the global menu configuration.
31
15
  */
@@ -69,36 +53,25 @@ declare class NgpMenuTrigger<T = unknown> implements OnDestroy {
69
53
  * Provide context to the menu. This can be used to pass data to the menu content.
70
54
  */
71
55
  readonly context: _angular_core.InputSignal<T | undefined>;
72
- /**
73
- * The overlay that manages the menu
74
- * @internal
75
- */
76
- readonly overlay: _angular_core.WritableSignal<NgpOverlay<T> | null>;
77
- /**
78
- * The open state of the menu.
79
- * @internal
80
- */
81
- readonly open: _angular_core.Signal<boolean>;
82
56
  /**
83
57
  * The menu trigger state.
84
58
  */
85
- readonly state: ng_primitives_state.CreatedState<NgpMenuTrigger<T>>;
86
- ngOnDestroy(): void;
87
- protected onClick(event: MouseEvent): void;
88
- toggle(event: MouseEvent): void;
59
+ private readonly state;
89
60
  /**
90
61
  * Show the menu.
91
62
  */
92
63
  show(): void;
93
64
  /**
94
- * @internal
95
65
  * Hide the menu.
66
+ * @param origin - The focus origin
67
+ * @internal
96
68
  */
97
69
  hide(origin?: FocusOrigin): void;
98
70
  /**
99
- * Create the overlay that will contain the menu
71
+ * Toggle the menu.
72
+ * @param event - The mouse event
100
73
  */
101
- private createOverlay;
74
+ toggle(event: MouseEvent): void;
102
75
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpMenuTrigger<any>, never>;
103
76
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMenuTrigger<any>, "[ngpMenuTrigger]", ["ngpMenuTrigger"], { "menu": { "alias": "ngpMenuTrigger"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpMenuTriggerDisabled"; "required": false; "isSignal": true; }; "placement": { "alias": "ngpMenuTriggerPlacement"; "required": false; "isSignal": true; }; "offset": { "alias": "ngpMenuTriggerOffset"; "required": false; "isSignal": true; }; "flip": { "alias": "ngpMenuTriggerFlip"; "required": false; "isSignal": true; }; "container": { "alias": "ngpMenuTriggerContainer"; "required": false; "isSignal": true; }; "scrollBehavior": { "alias": "ngpMenuTriggerScrollBehavior"; "required": false; "isSignal": true; }; "context": { "alias": "ngpMenuTriggerContext"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
104
77
  }
@@ -143,78 +116,186 @@ declare function provideMenuConfig(config: Partial<NgpMenuConfig>): Provider[];
143
116
  * The `NgpMenuItem` directive represents a menu item.
144
117
  */
145
118
  declare class NgpMenuItem {
146
- /** Access the injector */
147
- private readonly injector;
148
- /** Access the button element */
149
- private readonly elementRef;
150
- /** Access the parent menu */
151
- private readonly parentMenu;
152
119
  /** Whether the menu item is disabled */
153
120
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
154
121
  constructor();
155
- /** Close the menu when the item is clicked */
156
- protected onClick(event: MouseEvent): void;
122
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpMenuItem, never>;
123
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMenuItem, "[ngpMenuItem]", ["ngpMenuItem"], { "disabled": { "alias": "ngpMenuItemDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
124
+ }
125
+
126
+ interface NgpMenuItemState {
127
+ }
128
+ interface NgpMenuItemProps {
157
129
  /**
158
- * If the user presses the left arrow key (in LTR) and there is a parent menu,
159
- * we want to close the menu and focus the parent menu item.
130
+ * Whether the menu item is disabled.
160
131
  */
161
- protected handleArrowKey(event: Event): void;
132
+ readonly disabled?: Signal<boolean>;
133
+ }
134
+ declare const injectMenuItemState: {
135
+ (): Signal<{}>;
136
+ (options: {
137
+ hoisted: true;
138
+ optional?: boolean;
139
+ skipSelf?: boolean;
140
+ }): Signal<{} | null>;
141
+ (options?: {
142
+ hoisted?: boolean;
143
+ optional?: boolean;
144
+ skipSelf?: boolean;
145
+ }): Signal<{}> | Signal<{} | null>;
146
+ };
147
+ declare const provideMenuItemState: (opts?: {
148
+ inherit?: boolean;
149
+ }) => _angular_core.FactoryProvider;
150
+
151
+ interface NgpMenuTriggerState {
162
152
  /**
163
- * If the user hovers over the trigger, we want to open the submenu
153
+ * The computed placement of the menu.
164
154
  */
165
- protected showSubmenuOnHover(): void;
166
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpMenuItem, never>;
167
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMenuItem, "[ngpMenuItem]", ["ngpMenuItem"], { "disabled": { "alias": "ngpMenuItemDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.NgpRovingFocusItem; inputs: { "ngpRovingFocusItemDisabled": "ngpMenuItemDisabled"; }; outputs: {}; }]>;
155
+ readonly placement: Signal<NgpMenuPlacement>;
156
+ /**
157
+ * Show the menu.
158
+ */
159
+ show(): void;
160
+ /**
161
+ * Hide the menu.
162
+ * @param origin - The focus origin
163
+ * @internal
164
+ */
165
+ hide(origin?: FocusOrigin): void;
166
+ /**
167
+ * Toggle the menu.
168
+ * @param event - The mouse event
169
+ */
170
+ toggle(event: MouseEvent): void;
168
171
  }
169
-
170
- /**
171
- * Provides the MenuTrigger state.
172
- */
173
- declare const provideMenuTriggerState: (options?: ng_primitives_state.CreateStateProviderOptions) => _angular_core.FactoryProvider;
174
- /**
175
- * Injects the MenuTrigger state.
176
- */
177
- declare const injectMenuTriggerState: <U = NgpMenuTrigger<unknown>>(injectOptions?: _angular_core.InjectOptions) => _angular_core.Signal<ng_primitives_state.State<U>>;
172
+ interface NgpMenuTriggerProps<T = unknown> {
173
+ /**
174
+ * Whether the trigger is disabled.
175
+ */
176
+ readonly disabled?: Signal<boolean>;
177
+ /**
178
+ * The menu template or component.
179
+ */
180
+ readonly menu?: Signal<NgpOverlayContent<T> | undefined>;
181
+ /**
182
+ * The placement of the menu.
183
+ */
184
+ readonly placement?: Signal<NgpMenuPlacement>;
185
+ /**
186
+ * The offset of the menu.
187
+ */
188
+ readonly offset?: Signal<NgpOffset>;
189
+ /**
190
+ * Whether the menu should flip when there is not enough space.
191
+ */
192
+ readonly flip?: Signal<boolean>;
193
+ /**
194
+ * The container in which the menu should be attached.
195
+ */
196
+ readonly container?: Signal<HTMLElement | string | null>;
197
+ /**
198
+ * How the menu behaves when the window is scrolled.
199
+ */
200
+ readonly scrollBehavior?: Signal<'reposition' | 'block'>;
201
+ /**
202
+ * Context to provide to the menu.
203
+ */
204
+ readonly context?: Signal<T | undefined>;
205
+ }
206
+ declare const injectMenuTriggerState: {
207
+ (): Signal<{
208
+ placement: Signal<NgpMenuPlacement>;
209
+ show: () => void;
210
+ hide: (origin?: FocusOrigin) => void;
211
+ toggle: (event: MouseEvent) => void;
212
+ }>;
213
+ (options: {
214
+ hoisted: true;
215
+ optional?: boolean;
216
+ skipSelf?: boolean;
217
+ }): Signal<{
218
+ placement: Signal<NgpMenuPlacement>;
219
+ show: () => void;
220
+ hide: (origin?: FocusOrigin) => void;
221
+ toggle: (event: MouseEvent) => void;
222
+ } | null>;
223
+ (options?: {
224
+ hoisted?: boolean;
225
+ optional?: boolean;
226
+ skipSelf?: boolean;
227
+ }): Signal<{
228
+ placement: Signal<NgpMenuPlacement>;
229
+ show: () => void;
230
+ hide: (origin?: FocusOrigin) => void;
231
+ toggle: (event: MouseEvent) => void;
232
+ }> | Signal<{
233
+ placement: Signal<NgpMenuPlacement>;
234
+ show: () => void;
235
+ hide: (origin?: FocusOrigin) => void;
236
+ toggle: (event: MouseEvent) => void;
237
+ } | null>;
238
+ };
239
+ declare const provideMenuTriggerState: (opts?: {
240
+ inherit?: boolean;
241
+ }) => _angular_core.FactoryProvider;
178
242
 
179
243
  /**
180
244
  * The `NgpMenu` is a container for menu items.
181
245
  */
182
246
  declare class NgpMenu {
183
- /** Access the overlay. */
184
- protected readonly overlay: ng_primitives_portal.NgpOverlay<unknown>;
185
- /** Access the menu trigger state */
186
- private readonly menuTrigger;
187
- /** Access any parent menus */
188
- private readonly parentMenu;
189
- /** @internal Whether we should close submenus */
190
- readonly closeSubmenus: Subject<HTMLElement>;
247
+ private readonly state;
248
+ constructor();
191
249
  /** @internal Close the menu and any parent menus */
192
250
  closeAllMenus(origin: FocusOrigin): void;
193
251
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpMenu, never>;
194
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMenu, "[ngpMenu]", ["ngpMenu"], {}, {}, never, never, true, [{ directive: typeof i1.NgpRovingFocusGroup; inputs: {}; outputs: {}; }, { directive: typeof i2.NgpFocusTrap; inputs: {}; outputs: {}; }]>;
252
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpMenu, "[ngpMenu]", ["ngpMenu"], {}, {}, never, never, true, never>;
195
253
  }
196
254
 
197
- declare const NgpMenuToken: InjectionToken<NgpMenu>;
198
- /**
199
- * Inject the Menu directive instance
200
- */
201
- declare function injectMenu(): NgpMenu;
202
-
203
- declare class NgpSubmenuTrigger<T = unknown> {
255
+ interface NgpMenuState {
204
256
  /**
205
- * Access the menu trigger element.
257
+ * Close the menu and any parent menus.
258
+ * @param origin - The focus origin
206
259
  */
207
- private readonly trigger;
208
- /**
209
- * Access the injector.
210
- */
211
- private readonly injector;
260
+ closeAllMenus(origin: FocusOrigin): void;
212
261
  /**
213
- * Access the view container reference.
262
+ * Subject that emits when submenus should be closed.
263
+ * @internal
214
264
  */
215
- private readonly viewContainerRef;
216
- /** Access the parent menu */
217
- private readonly parentMenu;
265
+ readonly closeSubmenus: Subject<HTMLElement>;
266
+ }
267
+ interface NgpMenuProps {
268
+ }
269
+ declare const injectMenuState: {
270
+ (): _angular_core.Signal<{
271
+ closeAllMenus: (origin: FocusOrigin) => void;
272
+ closeSubmenus: Subject<HTMLElement>;
273
+ }>;
274
+ (options: {
275
+ hoisted: true;
276
+ optional?: boolean;
277
+ skipSelf?: boolean;
278
+ }): _angular_core.Signal<{
279
+ closeAllMenus: (origin: FocusOrigin) => void;
280
+ closeSubmenus: Subject<HTMLElement>;
281
+ } | null>;
282
+ (options?: {
283
+ hoisted?: boolean;
284
+ optional?: boolean;
285
+ skipSelf?: boolean;
286
+ }): _angular_core.Signal<{
287
+ closeAllMenus: (origin: FocusOrigin) => void;
288
+ closeSubmenus: Subject<HTMLElement>;
289
+ }> | _angular_core.Signal<{
290
+ closeAllMenus: (origin: FocusOrigin) => void;
291
+ closeSubmenus: Subject<HTMLElement>;
292
+ } | null>;
293
+ };
294
+ declare const provideMenuState: (opts?: {
295
+ inherit?: boolean;
296
+ }) => _angular_core.FactoryProvider;
297
+
298
+ declare class NgpSubmenuTrigger<T = unknown> {
218
299
  /**
219
300
  * Access the submenu template ref.
220
301
  */
@@ -241,58 +322,104 @@ declare class NgpSubmenuTrigger<T = unknown> {
241
322
  */
242
323
  readonly flip: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
243
324
  /**
244
- * The overlay that manages the menu
245
- * @internal
325
+ * Access the menu trigger state.
246
326
  */
247
- readonly overlay: _angular_core.WritableSignal<NgpOverlay<T> | null>;
327
+ private readonly state;
248
328
  /**
249
- * The open state of the menu.
250
- * @internal
329
+ * Show the menu.
251
330
  */
252
- readonly open: _angular_core.Signal<boolean>;
331
+ show(): void;
253
332
  /**
254
- * Access the menu trigger state.
333
+ * Hide the menu.
255
334
  */
256
- readonly state: ng_primitives_state.CreatedState<NgpSubmenuTrigger<T>>;
257
- constructor();
258
- protected toggle(event: MouseEvent): void;
335
+ hide(origin?: FocusOrigin): void;
336
+ /**
337
+ * Toggle the menu.
338
+ * @param event - The mouse event
339
+ */
340
+ toggle(event: MouseEvent): void;
341
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpSubmenuTrigger<any>, never>;
342
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpSubmenuTrigger<any>, "[ngpSubmenuTrigger]", ["ngpSubmenuTrigger"], { "menu": { "alias": "ngpSubmenuTrigger"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpSubmenuTriggerDisabled"; "required": false; "isSignal": true; }; "placement": { "alias": "ngpSubmenuTriggerPlacement"; "required": false; "isSignal": true; }; "offset": { "alias": "ngpSubmenuTriggerOffset"; "required": false; "isSignal": true; }; "flip": { "alias": "ngpSubmenuTriggerFlip"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
343
+ }
344
+
345
+ interface NgpSubmenuTriggerState {
346
+ /**
347
+ * The computed placement of the menu.
348
+ */
349
+ readonly placement: Signal<NgpMenuPlacement>;
259
350
  /**
260
351
  * Show the menu.
261
352
  */
262
353
  show(): void;
263
354
  /**
264
- * @internal
265
355
  * Hide the menu.
356
+ * @param origin - The focus origin
266
357
  */
267
358
  hide(origin?: FocusOrigin): void;
268
359
  /**
269
- * Create the overlay that will contain the menu
360
+ * Toggle the menu.
361
+ * @param event - The mouse event
362
+ */
363
+ toggle(event: MouseEvent): void;
364
+ }
365
+ interface NgpSubmenuTriggerProps<T = unknown> {
366
+ /**
367
+ * Whether the trigger is disabled.
270
368
  */
271
- private createOverlay;
369
+ readonly disabled?: Signal<boolean>;
272
370
  /**
273
- * If the user presses the right arrow key, we want to open the submenu
274
- * and focus the first item in the submenu.
275
- * If the user presses the left arrow key, we want to close the submenu.
276
- * This behavior will be inverted if the direction is RTL.
277
- * @param event
371
+ * The menu template or component.
278
372
  */
279
- protected handleArrowKey(event: Event): void;
373
+ readonly menu?: Signal<NgpOverlayContent<T> | undefined>;
280
374
  /**
281
- * If the user hovers over the trigger, we want to open the submenu
375
+ * The placement of the menu.
282
376
  */
283
- protected showSubmenuOnHover(event: PointerEvent): void;
284
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpSubmenuTrigger<any>, never>;
285
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpSubmenuTrigger<any>, "[ngpSubmenuTrigger]", ["ngpSubmenuTrigger"], { "menu": { "alias": "ngpSubmenuTrigger"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpSubmenuTriggerDisabled"; "required": false; "isSignal": true; }; "placement": { "alias": "ngpSubmenuTriggerPlacement"; "required": false; "isSignal": true; }; "offset": { "alias": "ngpSubmenuTriggerOffset"; "required": false; "isSignal": true; }; "flip": { "alias": "ngpSubmenuTriggerFlip"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
377
+ readonly placement?: Signal<NgpMenuPlacement>;
378
+ /**
379
+ * The offset of the menu.
380
+ */
381
+ readonly offset?: Signal<NgpOffset>;
382
+ /**
383
+ * Whether the menu should flip when there is not enough space.
384
+ */
385
+ readonly flip?: Signal<boolean>;
286
386
  }
387
+ declare const injectSubmenuTriggerState: {
388
+ (): Signal<{
389
+ placement: Signal<NgpMenuPlacement>;
390
+ show: () => void;
391
+ hide: (origin?: FocusOrigin) => void;
392
+ toggle: (event: MouseEvent) => void;
393
+ }>;
394
+ (options: {
395
+ hoisted: true;
396
+ optional?: boolean;
397
+ skipSelf?: boolean;
398
+ }): Signal<{
399
+ placement: Signal<NgpMenuPlacement>;
400
+ show: () => void;
401
+ hide: (origin?: FocusOrigin) => void;
402
+ toggle: (event: MouseEvent) => void;
403
+ } | null>;
404
+ (options?: {
405
+ hoisted?: boolean;
406
+ optional?: boolean;
407
+ skipSelf?: boolean;
408
+ }): Signal<{
409
+ placement: Signal<NgpMenuPlacement>;
410
+ show: () => void;
411
+ hide: (origin?: FocusOrigin) => void;
412
+ toggle: (event: MouseEvent) => void;
413
+ }> | Signal<{
414
+ placement: Signal<NgpMenuPlacement>;
415
+ show: () => void;
416
+ hide: (origin?: FocusOrigin) => void;
417
+ toggle: (event: MouseEvent) => void;
418
+ } | null>;
419
+ };
420
+ declare const provideSubmenuTriggerState: (opts?: {
421
+ inherit?: boolean;
422
+ }) => _angular_core.FactoryProvider;
287
423
 
288
- /**
289
- * Provides the SubmenuTrigger state.
290
- */
291
- declare const provideSubmenuTriggerState: (options?: ng_primitives_state.CreateStateProviderOptions) => _angular_core.FactoryProvider;
292
- /**
293
- * Injects the SubmenuTrigger state.
294
- */
295
- declare const injectSubmenuTriggerState: <U = NgpSubmenuTrigger<unknown>>(injectOptions?: _angular_core.InjectOptions) => _angular_core.Signal<ng_primitives_state.State<U>>;
296
-
297
- export { NgpMenu, NgpMenuItem, NgpMenuToken, NgpMenuTrigger, NgpSubmenuTrigger, injectMenu, injectMenuTriggerState, injectSubmenuTriggerState, provideMenuConfig, provideMenuTriggerState, provideSubmenuTriggerState };
298
- export type { NgpMenuConfig, NgpMenuPlacement };
424
+ export { NgpMenu, NgpMenuItem, NgpMenuTrigger, NgpSubmenuTrigger, injectMenuItemState, injectMenuState, injectMenuTriggerState, injectSubmenuTriggerState, provideMenuConfig, provideMenuItemState, provideMenuState, provideMenuTriggerState, provideSubmenuTriggerState };
425
+ export type { NgpMenuConfig, NgpMenuItemProps, NgpMenuItemState, NgpMenuPlacement, NgpMenuProps, NgpMenuState, NgpMenuTriggerProps, NgpMenuTriggerState, NgpSubmenuTriggerProps, NgpSubmenuTriggerState };
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.93.0",
5
+ "version": "0.94.0",
6
6
  "keywords": [
7
7
  "angular",
8
8
  "primitives",
@@ -8,10 +8,26 @@ import { BooleanInput } from '@angular/cdk/coercion';
8
8
  * The state interface for the RovingFocusItem pattern.
9
9
  */
10
10
  interface NgpRovingFocusItemState {
11
+ /**
12
+ * The unique id of the roving focus item.
13
+ */
11
14
  readonly id: Signal<string>;
15
+ /**
16
+ * Whether the item is disabled.
17
+ */
12
18
  readonly disabled: Signal<boolean>;
19
+ /**
20
+ * The tabindex of the roving focus item.
21
+ */
13
22
  readonly tabindex: Signal<number>;
23
+ /**
24
+ * The element reference of the roving focus item.
25
+ */
14
26
  readonly element: ElementRef<HTMLElement>;
27
+ /**
28
+ * Focus the roving focus item.
29
+ * @param origin The focus origin
30
+ */
15
31
  focus(origin: FocusOrigin): void;
16
32
  }
17
33
  /**
@@ -30,10 +46,12 @@ declare const injectRovingFocusItemState: {
30
46
  (options: {
31
47
  hoisted: true;
32
48
  optional?: boolean;
49
+ skipSelf?: boolean;
33
50
  }): Signal<NgpRovingFocusItemState | null>;
34
51
  (options?: {
35
52
  hoisted?: boolean;
36
53
  optional?: boolean;
54
+ skipSelf?: boolean;
37
55
  }): Signal<NgpRovingFocusItemState> | Signal<NgpRovingFocusItemState | null>;
38
56
  };
39
57
  declare const provideRovingFocusItemState: (opts?: {
@@ -41,23 +59,75 @@ declare const provideRovingFocusItemState: (opts?: {
41
59
  }) => _angular_core.FactoryProvider;
42
60
 
43
61
  interface NgpRovingFocusGroupState {
44
- orientation: Signal<NgpOrientation>;
45
- wrap: Signal<boolean>;
46
- homeEnd: Signal<boolean>;
47
- disabled: Signal<boolean>;
48
- activeItem: Signal<string | null>;
62
+ /**
63
+ * The orientation of the roving focus group.
64
+ */
65
+ readonly orientation: Signal<NgpOrientation>;
66
+ /**
67
+ * Whether the roving focus group should wrap around.
68
+ */
69
+ readonly wrap: Signal<boolean>;
70
+ /**
71
+ * Whether the Home and End keys are enabled.
72
+ */
73
+ readonly homeEnd: Signal<boolean>;
74
+ /**
75
+ * Whether the roving focus group is disabled.
76
+ */
77
+ readonly disabled: Signal<boolean>;
78
+ /**
79
+ * The id of the currently active item.
80
+ */
81
+ readonly activeItem: Signal<string | null>;
82
+ /**
83
+ * Handle keyboard navigation.
84
+ * @param event The keyboard event
85
+ */
49
86
  onKeydown(event: KeyboardEvent): void;
87
+ /**
88
+ * Set the active item by id.
89
+ * @param id The id of the item to activate
90
+ * @param origin The origin of the focus change
91
+ */
50
92
  setActiveItem(id: string | null, origin?: FocusOrigin): void;
93
+ /**
94
+ * Register an item with the roving focus group.
95
+ * @param item The item to register
96
+ */
51
97
  register(item: NgpRovingFocusItemState): void;
98
+ /**
99
+ * Unregister an item from the roving focus group.
100
+ * @param item The item to unregister
101
+ * @internal
102
+ */
52
103
  unregister(item: NgpRovingFocusItemState): void;
104
+ /**
105
+ * Set the orientation of the roving focus group.
106
+ * @param orientation The orientation value
107
+ */
53
108
  setOrientation(orientation: NgpOrientation): void;
54
109
  }
55
110
  interface NgpRovingFocusGroupProps {
56
- orientation?: Signal<NgpOrientation>;
57
- wrap?: Signal<boolean>;
58
- homeEnd?: Signal<boolean>;
59
- disabled?: Signal<boolean>;
60
- inherit?: boolean;
111
+ /**
112
+ * The orientation of the roving focus group.
113
+ */
114
+ readonly orientation?: Signal<NgpOrientation>;
115
+ /**
116
+ * Whether the roving focus group should wrap around.
117
+ */
118
+ readonly wrap?: Signal<boolean>;
119
+ /**
120
+ * Whether the Home and End keys are enabled.
121
+ */
122
+ readonly homeEnd?: Signal<boolean>;
123
+ /**
124
+ * Whether the roving focus group is disabled.
125
+ */
126
+ readonly disabled?: Signal<boolean>;
127
+ /**
128
+ * Whether to inherit state from a parent roving focus group.
129
+ */
130
+ readonly inherit?: boolean;
61
131
  }
62
132
  declare const NgpRovingFocusGroupStateToken: _angular_core.InjectionToken<_angular_core.WritableSignal<NgpRovingFocusGroupState>>;
63
133
  declare const ngpRovingFocusGroup: ({ orientation: _orientation, wrap, homeEnd, disabled, inherit, }: NgpRovingFocusGroupProps) => NgpRovingFocusGroupState;
@@ -66,10 +136,12 @@ declare const injectRovingFocusGroupState: {
66
136
  (options: {
67
137
  hoisted: true;
68
138
  optional?: boolean;
139
+ skipSelf?: boolean;
69
140
  }): Signal<NgpRovingFocusGroupState | null>;
70
141
  (options?: {
71
142
  hoisted?: boolean;
72
143
  optional?: boolean;
144
+ skipSelf?: boolean;
73
145
  }): Signal<NgpRovingFocusGroupState> | Signal<NgpRovingFocusGroupState | null>;
74
146
  };
75
147
  declare const provideRovingFocusGroupState: (opts?: {
@@ -22,6 +22,7 @@ declare class NgpSeparator {
22
22
  * The orientation of the separator.
23
23
  */
24
24
  readonly orientation: i0.InputSignal<NgpOrientation>;
25
+ constructor();
25
26
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpSeparator, never>;
26
27
  static ɵdir: i0.ɵɵDirectiveDeclaration<NgpSeparator, "[ngpSeparator]", ["ngpSeparator"], { "orientation": { "alias": "ngpSeparatorOrientation"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
27
28
  }