ng-primitives 0.91.2 → 0.93.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 +3 -1
  2. package/accordion/index.d.ts +8 -1
  3. package/autofill/index.d.ts +4 -0
  4. package/avatar/index.d.ts +11 -2
  5. package/breadcrumbs/index.d.ts +21 -7
  6. package/button/index.d.ts +3 -1
  7. package/checkbox/index.d.ts +3 -1
  8. package/fesm2022/ng-primitives-checkbox.mjs +7 -8
  9. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  10. package/fesm2022/ng-primitives-file-upload.mjs +209 -202
  11. package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
  12. package/fesm2022/ng-primitives-focus-trap.mjs +107 -138
  13. package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
  14. package/fesm2022/ng-primitives-form-field.mjs +323 -399
  15. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  16. package/fesm2022/ng-primitives-interactions.mjs +57 -58
  17. package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
  18. package/fesm2022/ng-primitives-listbox.mjs +2 -2
  19. package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
  20. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  21. package/fesm2022/ng-primitives-portal.mjs +5 -1
  22. package/fesm2022/ng-primitives-portal.mjs.map +1 -1
  23. package/fesm2022/ng-primitives-slider.mjs +4 -5
  24. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  25. package/fesm2022/ng-primitives-state.mjs +36 -8
  26. package/fesm2022/ng-primitives-state.mjs.map +1 -1
  27. package/fesm2022/ng-primitives-switch.mjs +4 -5
  28. package/fesm2022/ng-primitives-switch.mjs.map +1 -1
  29. package/fesm2022/ng-primitives-tabs.mjs +194 -192
  30. package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
  31. package/fesm2022/ng-primitives-toggle-group.mjs +4 -5
  32. package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
  33. package/fesm2022/ng-primitives-toggle.mjs +4 -5
  34. package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
  35. package/fesm2022/ng-primitives-tooltip.mjs +4 -4
  36. package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
  37. package/fesm2022/ng-primitives-utils.mjs +23 -14
  38. package/fesm2022/ng-primitives-utils.mjs.map +1 -1
  39. package/file-upload/index.d.ts +100 -52
  40. package/focus-trap/index.d.ts +33 -75
  41. package/form-field/index.d.ts +320 -123
  42. package/input/index.d.ts +6 -0
  43. package/interactions/index.d.ts +16 -16
  44. package/package.json +1 -1
  45. package/roving-focus/index.d.ts +6 -2
  46. package/schematics/ng-generate/templates/tabs/tabs.__fileSuffix@dasherize__.ts.template +2 -2
  47. package/slider/index.d.ts +14 -6
  48. package/state/index.d.ts +23 -8
  49. package/switch/index.d.ts +8 -4
  50. package/tabs/index.d.ts +333 -84
  51. package/textarea/index.d.ts +6 -0
  52. package/toggle/index.d.ts +5 -3
  53. package/toggle-group/index.d.ts +6 -2
  54. package/toolbar/index.d.ts +5 -0
  55. package/utils/index.d.ts +1 -1
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.91.2",
5
+ "version": "0.93.0",
6
6
  "keywords": [
7
7
  "angular",
8
8
  "primitives",
@@ -29,10 +29,12 @@ declare const injectRovingFocusItemState: {
29
29
  (): Signal<NgpRovingFocusItemState>;
30
30
  (options: {
31
31
  hoisted: true;
32
+ optional?: boolean;
32
33
  }): Signal<NgpRovingFocusItemState | null>;
33
34
  (options?: {
34
35
  hoisted?: boolean;
35
- }): Signal<NgpRovingFocusItemState | null>;
36
+ optional?: boolean;
37
+ }): Signal<NgpRovingFocusItemState> | Signal<NgpRovingFocusItemState | null>;
36
38
  };
37
39
  declare const provideRovingFocusItemState: (opts?: {
38
40
  inherit?: boolean;
@@ -63,10 +65,12 @@ declare const injectRovingFocusGroupState: {
63
65
  (): Signal<NgpRovingFocusGroupState>;
64
66
  (options: {
65
67
  hoisted: true;
68
+ optional?: boolean;
66
69
  }): Signal<NgpRovingFocusGroupState | null>;
67
70
  (options?: {
68
71
  hoisted?: boolean;
69
- }): Signal<NgpRovingFocusGroupState | null>;
72
+ optional?: boolean;
73
+ }): Signal<NgpRovingFocusGroupState> | Signal<NgpRovingFocusGroupState | null>;
70
74
  };
71
75
  declare const provideRovingFocusGroupState: (opts?: {
72
76
  inherit?: boolean;
@@ -9,12 +9,12 @@ import { Tab } from './tab';
9
9
  template: `
10
10
  <div [(ngpTabsetValue)]="value" ngpTabset>
11
11
  <div ngpTabList>
12
- @for (tab of tabs(); track tab.label) {
12
+ @for (tab of tabs(); track tab.label()) {
13
13
  <button [ngpTabButtonValue]="tab.value()" ngpTabButton>{{ tab.label() }}</button>
14
14
  }
15
15
  </div>
16
16
 
17
- @for (tab of tabs(); track tab.label) {
17
+ @for (tab of tabs(); track tab.label()) {
18
18
  <div [ngpTabPanelValue]="tab.value()" ngpTabPanel>
19
19
  <ng-container [ngTemplateOutlet]="tab.content()" />
20
20
  </div>
package/slider/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Signal, WritableSignal, ElementRef, OnDestroy } from '@angular/core';
3
3
  import { NgpOrientation } from 'ng-primitives/common';
4
- import { Subject } from 'rxjs';
4
+ import { Observable } from 'rxjs';
5
5
  import { NumberInput, BooleanInput } from '@angular/cdk/coercion';
6
6
  import * as ng_primitives_state from 'ng-primitives/state';
7
7
  import * as ng_primitives_slider from 'ng-primitives/slider';
@@ -30,10 +30,12 @@ declare const injectSliderRangeState: {
30
30
  (): _angular_core.Signal<NgpSliderRangeState>;
31
31
  (options: {
32
32
  hoisted: true;
33
+ optional?: boolean;
33
34
  }): _angular_core.Signal<NgpSliderRangeState | null>;
34
35
  (options?: {
35
36
  hoisted?: boolean;
36
- }): _angular_core.Signal<NgpSliderRangeState | null>;
37
+ optional?: boolean;
38
+ }): _angular_core.Signal<NgpSliderRangeState> | _angular_core.Signal<NgpSliderRangeState | null>;
37
39
  };
38
40
  declare const provideSliderRangeState: (opts?: {
39
41
  inherit?: boolean;
@@ -71,10 +73,12 @@ declare const injectSliderThumbState: {
71
73
  (): Signal<NgpSliderThumbState>;
72
74
  (options: {
73
75
  hoisted: true;
76
+ optional?: boolean;
74
77
  }): Signal<NgpSliderThumbState | null>;
75
78
  (options?: {
76
79
  hoisted?: boolean;
77
- }): Signal<NgpSliderThumbState | null>;
80
+ optional?: boolean;
81
+ }): Signal<NgpSliderThumbState> | Signal<NgpSliderThumbState | null>;
78
82
  };
79
83
  declare const provideSliderThumbState: (opts?: {
80
84
  inherit?: boolean;
@@ -104,10 +108,12 @@ declare const injectSliderTrackState: {
104
108
  (): _angular_core.Signal<NgpSliderTrackState>;
105
109
  (options: {
106
110
  hoisted: true;
111
+ optional?: boolean;
107
112
  }): _angular_core.Signal<NgpSliderTrackState | null>;
108
113
  (options?: {
109
114
  hoisted?: boolean;
110
- }): _angular_core.Signal<NgpSliderTrackState | null>;
115
+ optional?: boolean;
116
+ }): _angular_core.Signal<NgpSliderTrackState> | _angular_core.Signal<NgpSliderTrackState | null>;
111
117
  };
112
118
  declare const provideSliderTrackState: (opts?: {
113
119
  inherit?: boolean;
@@ -156,7 +162,7 @@ interface NgpSliderState {
156
162
  /**
157
163
  * Emit when the value changes.
158
164
  */
159
- readonly valueChange: Subject<number>;
165
+ readonly valueChange: Observable<number>;
160
166
  /**
161
167
  * Set the current value (clamped).
162
168
  */
@@ -216,10 +222,12 @@ declare const injectSliderState: {
216
222
  (): Signal<NgpSliderState>;
217
223
  (options: {
218
224
  hoisted: true;
225
+ optional?: boolean;
219
226
  }): Signal<NgpSliderState | null>;
220
227
  (options?: {
221
228
  hoisted?: boolean;
222
- }): Signal<NgpSliderState | null>;
229
+ optional?: boolean;
230
+ }): Signal<NgpSliderState> | Signal<NgpSliderState | null>;
223
231
  };
224
232
  declare const provideSliderState: (opts?: {
225
233
  inherit?: boolean;
package/state/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { InputSignalWithTransform, WritableSignal, InputSignal, Signal, InjectionToken, ProviderToken, FactoryProvider, InjectOptions, Injector, ElementRef } from '@angular/core';
2
+ import { Observable } from 'rxjs';
2
3
 
3
4
  /**
4
5
  * This converts the state object to a writable state object.
@@ -61,19 +62,23 @@ type BasePrimitiveInjectionFn<TState> = {
61
62
  (): Signal<TState>;
62
63
  (options: {
63
64
  hoisted: true;
65
+ optional?: boolean;
64
66
  }): Signal<TState | null>;
65
67
  (options?: {
66
68
  hoisted?: boolean;
67
- }): Signal<TState | null>;
69
+ optional?: boolean;
70
+ }): Signal<TState | null> | Signal<TState>;
68
71
  };
69
72
  type PrimitiveInjectionFn<TFactory extends (...args: any[]) => unknown> = TFactory extends (props: unknown) => infer R ? {
70
73
  (): Signal<R>;
71
74
  (options: {
72
75
  hoisted: true;
76
+ optional?: boolean;
73
77
  }): Signal<R | null>;
74
78
  (options?: {
75
79
  hoisted?: boolean;
76
- }): Signal<R | null>;
80
+ optional?: boolean;
81
+ }): Signal<R | null> | Signal<R>;
77
82
  } : BasePrimitiveInjectionFn<PrimitiveState<TFactory>>;
78
83
  declare function createPrimitive<TFactory extends (...args: any[]) => unknown>(name: string, fn: TFactory, options?: CreatePrimitiveOptions): [
79
84
  InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,
@@ -87,12 +92,15 @@ declare function controlled<T>(value: Signal<T>): WritableSignal<T>;
87
92
  declare function attrBinding(element: ElementRef<HTMLElement>, attr: string, value: (() => string | number | boolean | null | undefined) | string | number | boolean | null | undefined): void;
88
93
  declare function styleBinding(element: ElementRef<HTMLElement>, style: string, value: (() => string | number | null) | string | number | null): void;
89
94
  declare function dataBinding(element: ElementRef<HTMLElement>, attr: string, value: (() => string | boolean | null) | string | boolean | null): void;
90
- declare function listener<K extends keyof HTMLElementEventMap>(element: HTMLElement | ElementRef<HTMLElement>, event: K, handler: (event: HTMLElementEventMap[K]) => void, options?: {
95
+ declare function listener<K extends keyof HTMLElementEventMap>(element: HTMLElement | ElementRef<HTMLElement> | Document, event: K, handler: (event: HTMLElementEventMap[K]) => void, options?: {
91
96
  injector?: Injector;
92
- }): void;
93
- declare function listener(element: HTMLElement | ElementRef<HTMLElement>, event: string, handler: (event: Event) => void, options?: {
97
+ config?: AddEventListenerOptions | boolean;
98
+ }): () => void;
99
+ declare function listener(element: HTMLElement | ElementRef<HTMLElement> | Document, event: string, handler: (event: Event) => void, options?: {
94
100
  injector?: Injector;
95
- }): void;
101
+ config?: AddEventListenerOptions | boolean;
102
+ }): () => void;
103
+ declare function onMount(callback: () => void): void;
96
104
  declare function onDestroy(callback: () => void): void;
97
105
  /**
98
106
  * Previously, with our state approach, we allowed signals to be written directly using their setters.
@@ -106,6 +114,13 @@ declare function deprecatedSetter<T>(signal: WritableSignal<T>, methodName: stri
106
114
  * We could use inject with a forwardRef, but forwardRef returns an any - no thanks...
107
115
  */
108
116
  declare function injectInheritedState<T>(token: () => InjectionToken<T>, injectOptions?: InjectOptions): T | null;
117
+ interface Emitter<T> {
118
+ emit(value: T): void;
119
+ asObservable(): Observable<T>;
120
+ }
121
+ declare function emitter<T>({ injector, }?: {
122
+ injector?: Injector;
123
+ }): Emitter<T>;
109
124
 
110
- export { attrBinding, controlled, createPrimitive, createState, createStateInjector, createStateProvider, createStateToken, dataBinding, deprecatedSetter, injectInheritedState, listener, onDestroy, styleBinding };
111
- export type { CreatePrimitiveOptions, CreateStateProviderOptions, CreatedState, InjectedState, State };
125
+ export { attrBinding, controlled, createPrimitive, createState, createStateInjector, createStateProvider, createStateToken, dataBinding, deprecatedSetter, emitter, injectInheritedState, listener, onDestroy, onMount, styleBinding };
126
+ export type { CreatePrimitiveOptions, CreateStateProviderOptions, CreatedState, Emitter, InjectedState, State };
package/switch/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Signal, WritableSignal } from '@angular/core';
3
- import { Subject } from 'rxjs/internal/Subject';
3
+ import { Observable } from 'rxjs';
4
4
  import { BooleanInput } from '@angular/cdk/coercion';
5
5
 
6
6
  /**
@@ -35,10 +35,12 @@ declare const injectSwitchThumbState: {
35
35
  (): Signal<NgpSwitchThumbState>;
36
36
  (options: {
37
37
  hoisted: true;
38
+ optional?: boolean;
38
39
  }): Signal<NgpSwitchThumbState | null>;
39
40
  (options?: {
40
41
  hoisted?: boolean;
41
- }): Signal<NgpSwitchThumbState | null>;
42
+ optional?: boolean;
43
+ }): Signal<NgpSwitchThumbState> | Signal<NgpSwitchThumbState | null>;
42
44
  };
43
45
  declare const provideSwitchThumbState: (opts?: {
44
46
  inherit?: boolean;
@@ -63,7 +65,7 @@ interface NgpSwitchState {
63
65
  /**
64
66
  * Emits when the checked state changes.
65
67
  */
66
- readonly checkedChange: Subject<boolean>;
68
+ readonly checkedChange: Observable<boolean>;
67
69
  /**
68
70
  * Toggle the switch state.
69
71
  */
@@ -103,10 +105,12 @@ declare const injectSwitchState: {
103
105
  (): Signal<NgpSwitchState>;
104
106
  (options: {
105
107
  hoisted: true;
108
+ optional?: boolean;
106
109
  }): Signal<NgpSwitchState | null>;
107
110
  (options?: {
108
111
  hoisted?: boolean;
109
- }): Signal<NgpSwitchState | null>;
112
+ optional?: boolean;
113
+ }): Signal<NgpSwitchState> | Signal<NgpSwitchState | null>;
110
114
  };
111
115
  declare const provideSwitchState: (opts?: {
112
116
  inherit?: boolean;