@radix-ng/primitives 0.51.0 → 1.0.0-beta.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 (178) hide show
  1. package/fesm2022/radix-ng-primitives-accordion.mjs +105 -38
  2. package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
  3. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +221 -129
  4. package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
  5. package/fesm2022/radix-ng-primitives-arrow.mjs +20 -4
  6. package/fesm2022/radix-ng-primitives-arrow.mjs.map +1 -1
  7. package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
  8. package/fesm2022/radix-ng-primitives-avatar.mjs +54 -61
  9. package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
  10. package/fesm2022/radix-ng-primitives-button.mjs +123 -0
  11. package/fesm2022/radix-ng-primitives-button.mjs.map +1 -0
  12. package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
  13. package/fesm2022/radix-ng-primitives-checkbox.mjs +378 -54
  14. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
  15. package/fesm2022/radix-ng-primitives-collapsible.mjs +182 -81
  16. package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
  17. package/fesm2022/radix-ng-primitives-collection.mjs +40 -57
  18. package/fesm2022/radix-ng-primitives-collection.mjs.map +1 -1
  19. package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
  20. package/fesm2022/radix-ng-primitives-context-menu.mjs +140 -424
  21. package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
  22. package/fesm2022/radix-ng-primitives-core.mjs +735 -744
  23. package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
  24. package/fesm2022/radix-ng-primitives-cropper.mjs +1 -0
  25. package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
  26. package/fesm2022/radix-ng-primitives-date-field.mjs +51 -45
  27. package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
  28. package/fesm2022/radix-ng-primitives-dialog.mjs +655 -327
  29. package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
  30. package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +70 -46
  31. package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
  32. package/fesm2022/radix-ng-primitives-drawer.mjs +1059 -0
  33. package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -0
  34. package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
  35. package/fesm2022/radix-ng-primitives-field.mjs +363 -0
  36. package/fesm2022/radix-ng-primitives-field.mjs.map +1 -0
  37. package/fesm2022/radix-ng-primitives-fieldset.mjs +79 -0
  38. package/fesm2022/radix-ng-primitives-fieldset.mjs.map +1 -0
  39. package/fesm2022/radix-ng-primitives-focus-scope.mjs +23 -8
  40. package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
  41. package/fesm2022/radix-ng-primitives-input.mjs +172 -0
  42. package/fesm2022/radix-ng-primitives-input.mjs.map +1 -0
  43. package/fesm2022/radix-ng-primitives-label.mjs +6 -6
  44. package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
  45. package/fesm2022/radix-ng-primitives-menu.mjs +1480 -344
  46. package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
  47. package/fesm2022/radix-ng-primitives-menubar.mjs +290 -162
  48. package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
  49. package/fesm2022/radix-ng-primitives-meter.mjs +271 -0
  50. package/fesm2022/radix-ng-primitives-meter.mjs.map +1 -0
  51. package/fesm2022/radix-ng-primitives-navigation-menu.mjs +1052 -1553
  52. package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
  53. package/fesm2022/radix-ng-primitives-number-field.mjs +1102 -367
  54. package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
  55. package/fesm2022/radix-ng-primitives-pagination.mjs.map +1 -1
  56. package/fesm2022/radix-ng-primitives-popover.mjs +978 -989
  57. package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
  58. package/fesm2022/radix-ng-primitives-popper.mjs +91 -41
  59. package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
  60. package/fesm2022/radix-ng-primitives-portal.mjs +34 -10
  61. package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
  62. package/fesm2022/radix-ng-primitives-presence.mjs +134 -246
  63. package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
  64. package/fesm2022/radix-ng-primitives-preview-card.mjs +997 -0
  65. package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -0
  66. package/fesm2022/radix-ng-primitives-progress.mjs +223 -84
  67. package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
  68. package/fesm2022/radix-ng-primitives-radio.mjs +191 -51
  69. package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
  70. package/fesm2022/radix-ng-primitives-roving-focus.mjs +96 -50
  71. package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
  72. package/fesm2022/radix-ng-primitives-select.mjs +791 -509
  73. package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
  74. package/fesm2022/radix-ng-primitives-separator.mjs +12 -35
  75. package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
  76. package/fesm2022/radix-ng-primitives-slider.mjs +969 -717
  77. package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
  78. package/fesm2022/radix-ng-primitives-stepper.mjs +15 -19
  79. package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
  80. package/fesm2022/radix-ng-primitives-switch.mjs +125 -113
  81. package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
  82. package/fesm2022/radix-ng-primitives-tabs.mjs +381 -108
  83. package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
  84. package/fesm2022/radix-ng-primitives-time-field.mjs +55 -46
  85. package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
  86. package/fesm2022/radix-ng-primitives-toggle-group.mjs +121 -247
  87. package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
  88. package/fesm2022/radix-ng-primitives-toggle.mjs +98 -61
  89. package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
  90. package/fesm2022/radix-ng-primitives-toolbar.mjs +303 -92
  91. package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
  92. package/fesm2022/radix-ng-primitives-tooltip.mjs +690 -1071
  93. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
  94. package/fesm2022/radix-ng-primitives-visually-hidden.mjs +25 -66
  95. package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
  96. package/meter/README.md +3 -0
  97. package/navigation-menu/README.md +2 -1
  98. package/package.json +31 -18
  99. package/portal/README.md +2 -0
  100. package/preview-card/README.md +3 -0
  101. package/schematics/collection.json +1 -0
  102. package/schematics/ng-add/index.d.ts +3 -2
  103. package/schematics/ng-add/index.js +62 -31
  104. package/schematics/ng-add/index.js.map +1 -1
  105. package/schematics/ng-add/package-config.d.ts +4 -2
  106. package/schematics/ng-add/package-config.js +10 -2
  107. package/schematics/ng-add/package-config.js.map +1 -1
  108. package/schematics/ng-add/schema.d.ts +3 -0
  109. package/schematics/ng-add/schema.js +3 -0
  110. package/schematics/ng-add/schema.js.map +1 -0
  111. package/schematics/ng-add/schema.json +14 -0
  112. package/select/README.md +2 -0
  113. package/types/radix-ng-primitives-accordion.d.ts +48 -14
  114. package/types/radix-ng-primitives-alert-dialog.d.ts +95 -38
  115. package/types/radix-ng-primitives-arrow.d.ts +1 -1
  116. package/types/radix-ng-primitives-aspect-ratio.d.ts +1 -1
  117. package/types/radix-ng-primitives-avatar.d.ts +7 -11
  118. package/types/radix-ng-primitives-button.d.ts +73 -0
  119. package/types/radix-ng-primitives-calendar.d.ts +1 -2
  120. package/types/radix-ng-primitives-checkbox.d.ts +201 -32
  121. package/types/radix-ng-primitives-collapsible.d.ts +112 -39
  122. package/types/radix-ng-primitives-collection.d.ts +38 -34
  123. package/types/radix-ng-primitives-config.d.ts +1 -1
  124. package/types/radix-ng-primitives-context-menu.d.ts +60 -116
  125. package/types/radix-ng-primitives-core.d.ts +307 -236
  126. package/types/radix-ng-primitives-cropper.d.ts +2 -2
  127. package/types/radix-ng-primitives-date-field.d.ts +38 -23
  128. package/types/radix-ng-primitives-dialog.d.ts +282 -165
  129. package/types/radix-ng-primitives-dismissable-layer.d.ts +15 -7
  130. package/types/radix-ng-primitives-drawer.d.ts +448 -0
  131. package/types/radix-ng-primitives-editable.d.ts +1 -1
  132. package/types/radix-ng-primitives-field.d.ts +373 -0
  133. package/types/radix-ng-primitives-fieldset.d.ts +48 -0
  134. package/types/radix-ng-primitives-focus-scope.d.ts +13 -5
  135. package/types/radix-ng-primitives-input.d.ts +87 -0
  136. package/types/radix-ng-primitives-label.d.ts +0 -1
  137. package/types/radix-ng-primitives-menu.d.ts +572 -99
  138. package/types/radix-ng-primitives-menubar.d.ts +60 -50
  139. package/types/radix-ng-primitives-meter.d.ts +193 -0
  140. package/types/radix-ng-primitives-navigation-menu.d.ts +422 -340
  141. package/types/radix-ng-primitives-number-field.d.ts +405 -145
  142. package/types/radix-ng-primitives-pagination.d.ts +2 -2
  143. package/types/radix-ng-primitives-popover.d.ts +365 -351
  144. package/types/radix-ng-primitives-popper.d.ts +49 -9
  145. package/types/radix-ng-primitives-portal.d.ts +14 -6
  146. package/types/radix-ng-primitives-presence.d.ts +28 -76
  147. package/types/radix-ng-primitives-preview-card.d.ts +359 -0
  148. package/types/radix-ng-primitives-progress.d.ts +174 -48
  149. package/types/radix-ng-primitives-radio.d.ts +55 -25
  150. package/types/radix-ng-primitives-roving-focus.d.ts +30 -21
  151. package/types/radix-ng-primitives-select.d.ts +475 -177
  152. package/types/radix-ng-primitives-separator.d.ts +7 -32
  153. package/types/radix-ng-primitives-slider.d.ts +315 -201
  154. package/types/radix-ng-primitives-stepper.d.ts +5 -7
  155. package/types/radix-ng-primitives-switch.d.ts +86 -71
  156. package/types/radix-ng-primitives-tabs.d.ts +213 -79
  157. package/types/radix-ng-primitives-time-field.d.ts +42 -27
  158. package/types/radix-ng-primitives-toggle-group.d.ts +85 -164
  159. package/types/radix-ng-primitives-toggle.d.ts +43 -53
  160. package/types/radix-ng-primitives-toolbar.d.ts +163 -38
  161. package/types/radix-ng-primitives-tooltip.d.ts +347 -384
  162. package/types/radix-ng-primitives-visually-hidden.d.ts +19 -19
  163. package/dropdown-menu/README.md +0 -1
  164. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -581
  165. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
  166. package/fesm2022/radix-ng-primitives-hover-card.mjs +0 -1238
  167. package/fesm2022/radix-ng-primitives-hover-card.mjs.map +0 -1
  168. package/fesm2022/radix-ng-primitives-select2.mjs +0 -897
  169. package/fesm2022/radix-ng-primitives-select2.mjs.map +0 -1
  170. package/fesm2022/radix-ng-primitives-tooltip2.mjs +0 -735
  171. package/fesm2022/radix-ng-primitives-tooltip2.mjs.map +0 -1
  172. package/hover-card/README.md +0 -3
  173. package/select2/README.md +0 -3
  174. package/tooltip2/README.md +0 -3
  175. package/types/radix-ng-primitives-dropdown-menu.d.ts +0 -171
  176. package/types/radix-ng-primitives-hover-card.d.ts +0 -471
  177. package/types/radix-ng-primitives-select2.d.ts +0 -511
  178. package/types/radix-ng-primitives-tooltip2.d.ts +0 -325
@@ -1,13 +1,10 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { OnInit, AfterViewInit, WritableSignal, InputSignal, ModelSignal, Signal, InjectionToken } from '@angular/core';
2
+ import { Signal, WritableSignal, InjectionToken, InputSignal, ModelSignal } from '@angular/core';
3
3
  import * as _radix_ng_primitives_core from '@radix-ng/primitives/core';
4
- import { TimeValue, HourCycle, Granularity, DateStep, Formatter, SegmentValueObj, SegmentPart } from '@radix-ng/primitives/core';
4
+ import { TimeValue, HourCycle, Granularity, Direction, BooleanInput, DateStep, Formatter, SegmentValueObj, SegmentPart } from '@radix-ng/primitives/core';
5
5
  import * as _internationalized_date from '@internationalized/date';
6
- import { Direction } from '@angular/cdk/bidi';
7
- import { BooleanInput } from '@angular/cdk/coercion';
8
6
 
9
- declare class RdxTimeFieldRootDirective implements OnInit, AfterViewInit {
10
- private readonly elementRef;
7
+ declare class RdxTimeFieldRootDirective {
11
8
  /**
12
9
  * The controlled checked state of the calendar.
13
10
  */
@@ -47,47 +44,61 @@ declare class RdxTimeFieldRootDirective implements OnInit, AfterViewInit {
47
44
  * The stepping interval for the time fields. Defaults to 1
48
45
  */
49
46
  readonly step: _angular_core.InputSignal<DateStep | undefined>;
50
- readonly step$: _angular_core.Signal<DateStep>;
47
+ readonly step$: Signal<DateStep>;
51
48
  /**
49
+ * Locale- and hour-cycle-aware formatter. Recomputed whenever `locale` or
50
+ * `hourCycle` change so segments always render with the current settings.
52
51
  * @ignore
53
52
  */
54
- readonly defaultDate: _angular_core.Signal<TimeValue>;
53
+ readonly formatter: Signal<Formatter>;
54
+ /**
55
+ * @ignore
56
+ */
57
+ readonly defaultDate: Signal<TimeValue>;
55
58
  /**
56
59
  * The placeholder date, which is used to determine what month to display when no date is selected. This updates as the user navigates the calendar and can be used to programmatically control the calendar view
57
60
  */
58
61
  readonly placeholder: _angular_core.ModelSignal<TimeValue | undefined>;
59
62
  /**
63
+ * Segment input parts, collected from the projected content in DOM order. This
64
+ * stays in sync with `segmentContents()` (granularity / locale / value changes
65
+ * add or remove segments) instead of being captured once after view init.
60
66
  * @ignore
61
67
  */
62
- readonly segmentElements: _angular_core.WritableSignal<Set<HTMLElement>>;
68
+ private readonly segmentInputs;
63
69
  /**
70
+ * The focusable (non-literal) segment elements, in DOM order.
64
71
  * @ignore
65
72
  */
66
- readonly currentFocusedElement: _angular_core.WritableSignal<HTMLElement | null>;
73
+ readonly segmentElements: Signal<HTMLElement[]>;
67
74
  /**
68
75
  * @ignore
69
76
  */
70
- formatter: Formatter;
77
+ readonly currentFocusedElement: _angular_core.WritableSignal<HTMLElement | null>;
71
78
  /**
72
79
  * @ignore
73
80
  */
74
- readonly segmentValues: _angular_core.WritableSignal<SegmentValueObj>;
81
+ readonly inferredGranularity: Signal<Granularity>;
82
+ readonly convertedMinValue: Signal<_internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime | undefined>;
83
+ readonly convertedMaxValue: Signal<_internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime | undefined>;
84
+ readonly convertedModelValue: _angular_core.WritableSignal<TimeValue | undefined>;
85
+ readonly convertedPlaceholder: _angular_core.WritableSignal<TimeValue>;
75
86
  /**
87
+ * The per-segment values. Writable so segment editing (via `useDateField`) can
88
+ * update individual parts, but re-synced from the model whenever the value,
89
+ * granularity or formatter change — so a controlled `value` set after init is
90
+ * reflected, and an empty field re-initializes when granularity changes.
76
91
  * @ignore
77
92
  */
78
- readonly inferredGranularity: _angular_core.Signal<Granularity | undefined>;
79
- readonly convertedMinValue: _angular_core.Signal<_internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime | undefined>;
80
- readonly convertedMaxValue: _angular_core.Signal<_internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime | undefined>;
81
- readonly convertedModelValue: _angular_core.WritableSignal<TimeValue | undefined>;
82
- readonly convertedPlaceholder: _angular_core.WritableSignal<TimeValue>;
93
+ readonly segmentValues: _angular_core.WritableSignal<SegmentValueObj>;
83
94
  /**
84
95
  * @ignore
85
96
  */
86
- readonly isInvalid: _angular_core.Signal<boolean>;
97
+ readonly isInvalid: Signal<boolean>;
87
98
  /**
88
99
  * @ignore
89
100
  */
90
- readonly allSegmentContent: _angular_core.Signal<{
101
+ readonly allSegmentContent: Signal<{
91
102
  obj: _radix_ng_primitives_core.SegmentContentObj;
92
103
  arr: {
93
104
  part: _radix_ng_primitives_core.SegmentPart;
@@ -97,29 +108,27 @@ declare class RdxTimeFieldRootDirective implements OnInit, AfterViewInit {
97
108
  /**
98
109
  * An array of segments that should be readonly, which prevent user input on them.
99
110
  */
100
- readonly segmentContents: _angular_core.Signal<{
111
+ readonly segmentContents: Signal<{
101
112
  part: _radix_ng_primitives_core.SegmentPart;
102
113
  value: string;
103
114
  }[]>;
104
115
  /**
105
116
  * @ignore
106
117
  */
107
- readonly currentSegmentIndex: _angular_core.Signal<number>;
118
+ readonly currentSegmentIndex: Signal<number>;
108
119
  /**
109
120
  * @ignore
110
121
  */
111
- readonly prevFocusableSegment: _angular_core.Signal<HTMLElement | null>;
122
+ readonly prevFocusableSegment: Signal<HTMLElement | null>;
112
123
  /**
113
124
  * @ignore
114
125
  */
115
- readonly nextFocusableSegment: _angular_core.Signal<HTMLElement | null>;
126
+ readonly nextFocusableSegment: Signal<HTMLElement | null>;
116
127
  /**
117
128
  * @ignore
118
129
  */
119
130
  readonly focusNext: () => void;
120
131
  constructor();
121
- ngOnInit(): void;
122
- ngAfterViewInit(): void;
123
132
  /**
124
133
  * @ignore
125
134
  */
@@ -129,11 +138,17 @@ declare class RdxTimeFieldRootDirective implements OnInit, AfterViewInit {
129
138
  */
130
139
  setFocusedElement(el: HTMLElement): void;
131
140
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxTimeFieldRootDirective, never>;
132
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxTimeFieldRootDirective, "[rdxTimeFieldRoot]", ["rdxTimeFieldRoot"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "hourCycle": { "alias": "hourCycle"; "required": false; "isSignal": true; }; "granularity": { "alias": "granularity"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; "dir": { "alias": "dir"; "required": false; "isSignal": true; }; "minValue": { "alias": "minValue"; "required": false; "isSignal": true; }; "maxValue": { "alias": "maxValue"; "required": false; "isSignal": true; }; "hideTimeZone": { "alias": "hideTimeZone"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "step": { "alias": "step"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "placeholder": "placeholderChange"; }, never, never, true, never>;
141
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxTimeFieldRootDirective, "[rdxTimeFieldRoot]", ["rdxTimeFieldRoot"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "hourCycle": { "alias": "hourCycle"; "required": false; "isSignal": true; }; "granularity": { "alias": "granularity"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; "dir": { "alias": "dir"; "required": false; "isSignal": true; }; "minValue": { "alias": "minValue"; "required": false; "isSignal": true; }; "maxValue": { "alias": "maxValue"; "required": false; "isSignal": true; }; "hideTimeZone": { "alias": "hideTimeZone"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "step": { "alias": "step"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "placeholder": "placeholderChange"; }, ["segmentInputs"], never, true, never>;
133
142
  }
134
143
 
135
144
  declare class RdxTimeFieldInputDirective {
136
145
  private readonly el;
146
+ /**
147
+ * The host element of this segment. Consumed by the root to collect focusable
148
+ * segments in DOM order.
149
+ * @ignore
150
+ */
151
+ readonly element: HTMLElement;
137
152
  private readonly rootContext;
138
153
  /**
139
154
  * The part of the date to render
@@ -190,7 +205,7 @@ interface TimeFieldContextToken {
190
205
  isInvalid: Signal<boolean>;
191
206
  disabled: InputSignal<boolean>;
192
207
  readonly: InputSignal<boolean>;
193
- formatter: Formatter;
208
+ formatter: Signal<Formatter>;
194
209
  hourCycle: InputSignal<HourCycle>;
195
210
  segmentValues: WritableSignal<SegmentValueObj>;
196
211
  focusNext: () => void;
@@ -1,195 +1,116 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { InjectionToken } from '@angular/core';
3
- import * as _radix_ng_primitives_toggle_group from '@radix-ng/primitives/toggle-group';
4
- import { BooleanInput } from '@angular/cdk/coercion';
2
+ import { Signal } from '@angular/core';
3
+ import { DataOrientation, BooleanInput } from '@radix-ng/primitives/core';
5
4
  import * as i1 from '@radix-ng/primitives/roving-focus';
6
- import * as i2 from '@radix-ng/primitives/toggle';
5
+ import { Direction } from '@radix-ng/primitives/roving-focus';
7
6
  import { ControlValueAccessor } from '@angular/forms';
8
- import { AcceptableValue } from '@radix-ng/primitives/core';
9
7
 
10
8
  /**
11
- * @group Components
9
+ * Shared state a {@link RdxToggle} reads when it participates in a toggle group.
12
10
  */
13
- declare class RdxToggleGroupItemDirective {
14
- private readonly rdxToggleDirective;
15
- private readonly rdxRovingFocusItemDirective;
16
- /**
17
- * Access the toggle group.
18
- * @ignore
19
- */
20
- protected readonly rootContext: _radix_ng_primitives_toggle_group.IRdxToggleGroup;
21
- /**
22
- * The value of this toggle button.
23
- *
24
- * @group Props
25
- */
26
- readonly value: _angular_core.InputSignal<string>;
27
- /**
28
- * Whether this toggle button is disabled.
29
- * @defaultValue false
30
- * @group Props
31
- */
32
- readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
33
- private readonly isPressed;
34
- private readonly isDisabled;
35
- constructor();
36
- /**
37
- * @ignore
38
- */
39
- toggle(): void;
40
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleGroupItemDirective, never>;
41
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleGroupItemDirective, "[rdxToggleGroupItem]", ["rdxToggleGroupItem"], { "value": { "alias": "value"; "required": true; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.RdxRovingFocusItemDirective; inputs: { "focusable": "focusable"; "active": "active"; "allowShiftKey": "allowShiftKey"; }; outputs: {}; }, { directive: typeof i2.RdxToggleDirective; inputs: { "pressed": "pressed"; "disabled": "disabled"; }; outputs: {}; }]>;
11
+ interface RdxToggleGroupContext {
12
+ /** The currently pressed values. */
13
+ readonly value: Signal<string[]>;
14
+ /** Whether the whole group is disabled. */
15
+ readonly disabled: Signal<boolean>;
16
+ /** Whether more than one item can be pressed at a time. */
17
+ readonly multiple: Signal<boolean>;
18
+ /** The orientation of the group. */
19
+ readonly orientation: Signal<DataOrientation>;
20
+ /** Toggle the pressed state of `value` within the group. */
21
+ toggle(value: string): void;
42
22
  }
23
+ declare const injectToggleGroupContext: (optional?: boolean) => RdxToggleGroupContext | null;
24
+ declare const provideToggleGroupContext: (useFactory: () => RdxToggleGroupContext) => _angular_core.Provider;
43
25
 
44
- declare const RdxToggleGroupItemToken: InjectionToken<RdxToggleGroupItemDirective>;
45
- declare function injectToggleGroupItem(): RdxToggleGroupItemDirective;
46
-
47
- declare class RdxToggleGroupWithoutFocusDirective implements ControlValueAccessor {
48
- /**
49
- * @ignore
50
- */
51
- readonly id: string;
26
+ /** Builds the shared context a {@link RdxToggle} reads when it belongs to this group. */
27
+ declare function toggleGroupContext(instance: RdxToggleGroupBase): RdxToggleGroupContext;
28
+ /**
29
+ * Shared state and behavior for the toggle group. Concrete directives add the roving-focus group
30
+ * ({@link RdxToggleGroup}) or omit it when an ancestor already owns focus, e.g. a toolbar
31
+ * ({@link RdxToggleGroupWithoutFocus}).
32
+ */
33
+ declare abstract class RdxToggleGroupBase implements ControlValueAccessor {
52
34
  /**
53
- * @group Props
35
+ * The pressed values. Always an array — a single value is `[value]`. Use with `(onValueChange)`
36
+ * for controlled state.
54
37
  */
55
- readonly value: _angular_core.ModelSignal<string | string[] | undefined>;
38
+ readonly value: _angular_core.ModelSignal<string[] | undefined>;
39
+ /** The values pressed when the group is initially rendered (uncontrolled). */
40
+ readonly defaultValue: _angular_core.InputSignal<string[] | undefined>;
56
41
  /**
57
- * @group Props
42
+ * Whether multiple items can be pressed at the same time.
43
+ *
44
+ * @default false
58
45
  */
59
- readonly type: _angular_core.InputSignal<"single" | "multiple">;
46
+ readonly multiple: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
60
47
  /**
61
- * Whether the toggle group is disabled.
62
- * @defaultValue false
63
- * @group Props
48
+ * Whether the whole group is disabled.
49
+ *
50
+ * @default false
64
51
  */
65
52
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
66
53
  /**
67
- * Event emitted when the selected toggle button changes.
68
- * @group Emits
69
- */
70
- readonly onValueChange: _angular_core.OutputEmitterRef<string | string[] | undefined>;
71
- /**
72
- * The value change callback.
73
- */
54
+ * The orientation of the group, controlling arrow-key navigation.
55
+ *
56
+ * @default 'horizontal'
57
+ */
58
+ readonly orientation: _angular_core.InputSignal<DataOrientation>;
59
+ /** Event emitted when the pressed values change. */
60
+ readonly onValueChange: _angular_core.OutputEmitterRef<string[]>;
61
+ /** @ignore */
62
+ readonly pressedValues: _angular_core.Signal<string[]>;
63
+ protected readonly accessorDisabled: _angular_core.WritableSignal<boolean>;
64
+ /** @ignore */
65
+ readonly isDisabled: _angular_core.Signal<boolean>;
74
66
  private onChange?;
75
- /**
76
- * onTouch function registered via registerOnTouch (ControlValueAccessor).
77
- */
78
67
  protected onTouched?: () => void;
79
- /**
80
- * Toggle a value.
81
- * @param value The value to toggle.
82
- * @ignore
83
- */
68
+ constructor();
69
+ /** @ignore */
84
70
  toggle(value: string): void;
85
- /**
86
- * Select a value from Angular forms.
87
- * @param value The value to select.
88
- * @ignore
89
- */
90
- writeValue(value: string): void;
91
- /**
92
- * Register a callback to be called when the value changes.
93
- * @param fn The callback to register.
94
- * @ignore
95
- */
96
- registerOnChange(fn: (value: string | string[] | undefined) => void): void;
97
- /**
98
- * Register a callback to be called when the toggle group is touched.
99
- * @param fn The callback to register.
100
- * @ignore
101
- */
71
+ /** @ignore */
72
+ writeValue(value: string[] | string | null): void;
73
+ /** @ignore */
74
+ registerOnChange(fn: (value: string[]) => void): void;
75
+ /** @ignore */
102
76
  registerOnTouched(fn: () => void): void;
103
- private readonly accessorDisabled;
104
- /**
105
- * Set the disabled state of the toggle group.
106
- * @param isDisabled Whether the toggle group is disabled.
107
- * @ignore
108
- */
77
+ /** @ignore */
109
78
  setDisabledState(isDisabled: boolean): void;
110
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleGroupWithoutFocusDirective, never>;
111
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleGroupWithoutFocusDirective, "[rdxToggleGroupWithoutFocus]", ["rdxToggleGroupWithoutFocus"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "onValueChange": "onValueChange"; }, never, never, true, never>;
79
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleGroupBase, never>;
80
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleGroupBase, never, never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; "defaultValue": { "alias": "defaultValue"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "onValueChange": "onValueChange"; }, never, never, true, never>;
112
81
  }
113
82
 
114
83
  /**
115
- * @group Components
84
+ * A set of two-state buttons that can be toggled on or off. Owns roving keyboard focus over its
85
+ * `[rdxToggle]` children.
86
+ *
87
+ * @see https://base-ui.com/react/components/toggle-group
116
88
  */
117
- declare class RdxToggleGroupDirective implements ControlValueAccessor {
118
- /**
119
- * @ignore
120
- */
121
- readonly id: string;
122
- /**
123
- * @group Props
124
- */
125
- readonly value: _angular_core.ModelSignal<AcceptableValue | AcceptableValue[] | undefined>;
126
- /**
127
- * @group Props
128
- */
129
- readonly type: _angular_core.InputSignal<"single" | "multiple">;
130
- /**
131
- * Whether the toggle group is disabled.
132
- * @defaultValue false
133
- * @group Props
134
- */
135
- readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
136
- /**
137
- * Event emitted when the selected toggle button changes.
138
- * @group Emits
139
- */
140
- readonly onValueChange: _angular_core.OutputEmitterRef<AcceptableValue | AcceptableValue[] | undefined>;
141
- /**
142
- * The value change callback.
143
- */
144
- private onChange?;
145
- /**
146
- * onTouch function registered via registerOnTouch (ControlValueAccessor).
147
- */
148
- protected onTouched?: () => void;
89
+ declare class RdxToggleGroup extends RdxToggleGroupBase {
90
+ /** Text direction for arrow-key navigation. */
91
+ readonly dir: _angular_core.InputSignal<Direction>;
149
92
  /**
150
- * Toggle a value.
151
- * @param value The value to toggle.
152
- * @ignore
153
- */
154
- toggle(value: AcceptableValue): void;
155
- /**
156
- * Select a value from Angular forms.
157
- * @param value The value to select.
158
- * @ignore
159
- */
160
- writeValue(value: string): void;
161
- /**
162
- * Register a callback to be called when the value changes.
163
- * @param fn The callback to register.
164
- * @ignore
165
- */
166
- registerOnChange(fn: (value: AcceptableValue | AcceptableValue[] | undefined) => void): void;
167
- /**
168
- * Register a callback to be called when the toggle group is touched.
169
- * @param fn The callback to register.
170
- * @ignore
171
- */
172
- registerOnTouched(fn: () => void): void;
173
- readonly accessorDisabled: _angular_core.WritableSignal<boolean>;
174
- /**
175
- * Set the disabled state of the toggle group.
176
- * @param isDisabled Whether the toggle group is disabled.
177
- * @ignore
93
+ * Whether keyboard navigation should loop from the last item back to the first.
94
+ *
95
+ * @default true
178
96
  */
179
- setDisabledState(isDisabled: boolean): void;
180
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleGroupDirective, never>;
181
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleGroupDirective, "[rdxToggleGroup]", ["rdxToggleGroup"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "onValueChange": "onValueChange"; }, never, never, true, [{ directive: typeof i1.RdxRovingFocusGroupDirective; inputs: { "dir": "dir"; "orientation": "orientation"; "loop": "loop"; }; outputs: {}; }]>;
97
+ readonly loopFocus: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
98
+ private readonly rovingFocusGroup;
99
+ constructor();
100
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleGroup, never>;
101
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleGroup, "[rdxToggleGroup]", ["rdxToggleGroup"], { "dir": { "alias": "dir"; "required": false; "isSignal": true; }; "loopFocus": { "alias": "loopFocus"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.RdxRovingFocusGroupDirective; inputs: {}; outputs: {}; }]>;
182
102
  }
183
103
 
184
- interface IRdxToggleGroup {
185
- toggle(value: string): void;
186
- disabled: any;
187
- value: any;
188
- type: any;
189
- accessorDisabled: any;
104
+ /**
105
+ * A toggle group that does NOT create its own roving-focus group, for use inside a container that
106
+ * already owns keyboard focus (e.g. a toolbar). The `[rdxToggle]` children register with the nearest
107
+ * ancestor roving-focus group instead. Mirrors Base UI's behavior of skipping its composite root
108
+ * when nested in a toolbar.
109
+ */
110
+ declare class RdxToggleGroupWithoutFocus extends RdxToggleGroupBase {
111
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleGroupWithoutFocus, never>;
112
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleGroupWithoutFocus, "[rdxToggleGroupWithoutFocus]", ["rdxToggleGroupWithoutFocus"], {}, {}, never, never, true, never>;
190
113
  }
191
- declare const RdxToggleGroupToken: InjectionToken<IRdxToggleGroup>;
192
- declare function injectToggleGroup(): IRdxToggleGroup;
193
114
 
194
- export { RdxToggleGroupDirective, RdxToggleGroupItemDirective, RdxToggleGroupItemToken, RdxToggleGroupToken, RdxToggleGroupWithoutFocusDirective, injectToggleGroup, injectToggleGroupItem };
195
- export type { IRdxToggleGroup };
115
+ export { RdxToggleGroup, RdxToggleGroupBase, RdxToggleGroupWithoutFocus, injectToggleGroupContext, provideToggleGroupContext, toggleGroupContext };
116
+ export type { RdxToggleGroupContext };
@@ -1,75 +1,65 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { OutputEmitterRef } from '@angular/core';
3
- import * as i1 from '@radix-ng/primitives/visually-hidden';
4
- import { BooleanInput } from '@angular/cdk/coercion';
5
- import * as i1$1 from '@radix-ng/primitives/core';
6
- import { RdxControlValueAccessor } from '@radix-ng/primitives/core';
2
+ import { BooleanInput } from '@radix-ng/primitives/core';
3
+ import * as i1 from '@radix-ng/primitives/roving-focus';
4
+ import * as i1$1 from '@radix-ng/primitives/visually-hidden';
7
5
 
8
- declare class RdxToggleVisuallyHiddenInputDirective {
9
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleVisuallyHiddenInputDirective, never>;
10
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleVisuallyHiddenInputDirective, "input[rdxToggleVisuallyHiddenInput]", ["rdxToggleVisuallyHiddenInput"], {}, {}, never, never, true, [{ directive: typeof i1.RdxVisuallyHiddenInputDirective; inputs: { "name": "name"; "required": "required"; "value": "value"; "disabled": "disabled"; }; outputs: {}; }]>;
11
- }
12
-
13
- interface ToggleProps {
14
- /**
15
- * The controlled state of the toggle.
16
- */
17
- pressed?: boolean;
18
- /**
19
- * The state of the toggle when initially rendered. Use `defaultPressed`
20
- * if you do not need to control the state of the toggle.
21
- * @defaultValue false
22
- */
23
- defaultPressed?: boolean;
24
- /**
25
- * The callback that fires when the state of the toggle changes.
26
- */
27
- onPressedChange?: OutputEmitterRef<boolean>;
28
- /**
29
- * Whether the toggle is disabled.
30
- * @defaultValue false
31
- */
32
- disabled?: boolean;
33
- }
34
- type DataState = 'on' | 'off';
35
6
  /**
36
- * @group Components
7
+ * A two-state button that can be either on (pressed) or off.
8
+ *
9
+ * Works standalone or as an item of a `[rdxToggleGroup]`: inside a group it derives its pressed
10
+ * state from the group's value (matched by `value`) and participates in the group's roving focus.
11
+ *
12
+ * @see https://base-ui.com/react/components/toggle
37
13
  */
38
- declare class RdxToggleDirective {
14
+ declare class RdxToggle {
15
+ private readonly group;
16
+ private readonly rovingItem;
39
17
  /**
40
- * @ignore
18
+ * A value identifying this toggle inside a `[rdxToggleGroup]`. Required when used in a group.
41
19
  */
42
- readonly cva: RdxControlValueAccessor<any>;
20
+ readonly value: _angular_core.InputSignal<string | undefined>;
43
21
  /**
44
- * The pressed state of the toggle when it is initially rendered.
45
- * Use when you do not need to control its pressed state.
22
+ * The pressed state when initially rendered (uncontrolled, standalone only).
46
23
  *
47
- * @group Props
24
+ * @default false
48
25
  */
49
26
  readonly defaultPressed: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
50
27
  /**
51
- * The controlled pressed state of the toggle.
52
- * Must be used in conjunction with `onPressedChange`.
53
- *
54
- * @group Props
28
+ * The controlled pressed state (standalone). Use with `(onPressedChange)` or two-way `[(pressed)]`.
55
29
  */
56
- readonly pressed: _angular_core.ModelSignal<boolean>;
30
+ readonly pressed: _angular_core.ModelSignal<boolean | undefined>;
57
31
  /**
58
- * When true, prevents the user from interacting with the toggle.
32
+ * Whether the toggle is disabled.
59
33
  *
60
- * @group Props
34
+ * @default false
61
35
  */
62
36
  readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
63
37
  /**
64
- * Event handler called when the pressed state of the toggle changes.
38
+ * Whether the host is a native `<button>`. When `false`, the toggle adds `role="button"` and
39
+ * handles Enter/Space itself.
65
40
  *
66
- * @group Emits
41
+ * @default true
67
42
  */
68
- readonly onPressedChange: _angular_core.OutputRef<any>;
43
+ readonly nativeButton: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
44
+ /** Event emitted when the pressed state changes (standalone). */
45
+ readonly onPressedChange: _angular_core.OutputEmitterRef<boolean>;
46
+ private readonly internalPressed;
47
+ /** @ignore Whether the toggle is currently pressed (from the group when grouped). */
48
+ readonly pressedState: _angular_core.Signal<boolean>;
49
+ /** @ignore */
50
+ readonly isDisabled: _angular_core.Signal<boolean>;
51
+ constructor();
52
+ /** @ignore */
69
53
  protected onClick(): void;
70
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleDirective, never>;
71
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleDirective, "[rdxToggle]", ["rdxToggle"], { "defaultPressed": { "alias": "defaultPressed"; "required": false; "isSignal": true; }; "pressed": { "alias": "pressed"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "pressed": "pressedChange"; "onPressedChange": "onPressedChange"; }, never, never, true, [{ directive: typeof i1$1.RdxControlValueAccessor; inputs: { "value": "pressed"; "disabled": "disabled"; }; outputs: {}; }]>;
54
+ /** @ignore */
55
+ protected onKeyDown(event: KeyboardEvent): void;
56
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggle, never>;
57
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggle, "[rdxToggle]", ["rdxToggle"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "defaultPressed": { "alias": "defaultPressed"; "required": false; "isSignal": true; }; "pressed": { "alias": "pressed"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "nativeButton": { "alias": "nativeButton"; "required": false; "isSignal": true; }; }, { "pressed": "pressedChange"; "onPressedChange": "onPressedChange"; }, never, never, true, [{ directive: typeof i1.RdxRovingFocusItemDirective; inputs: {}; outputs: {}; }]>;
58
+ }
59
+
60
+ declare class RdxToggleVisuallyHiddenInputDirective {
61
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxToggleVisuallyHiddenInputDirective, never>;
62
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxToggleVisuallyHiddenInputDirective, "input[rdxToggleVisuallyHiddenInput]", ["rdxToggleVisuallyHiddenInput"], {}, {}, never, never, true, [{ directive: typeof i1$1.RdxVisuallyHiddenInputBubbleDirective; inputs: { "name": "name"; "required": "required"; "value": "value"; "disabled": "disabled"; }; outputs: {}; }]>;
72
63
  }
73
64
 
74
- export { RdxToggleDirective, RdxToggleVisuallyHiddenInputDirective };
75
- export type { DataState, ToggleProps };
65
+ export { RdxToggle, RdxToggleVisuallyHiddenInputDirective };