@wix/site-ui 1.347.0 → 1.349.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 (226) hide show
  1. package/dist/{6706.js → 1093.js} +3 -3
  2. package/dist/{8724.js → 1219.js} +2 -2
  3. package/dist/{7373.js → 1288.js} +8 -2
  4. package/dist/{5299.js → 1381.js} +98 -127
  5. package/dist/{3056.js → 1607.js} +32 -34
  6. package/dist/1629.js +2 -0
  7. package/dist/1669.js +75 -0
  8. package/dist/1718.js +26 -0
  9. package/dist/{1477.js → 201.js} +17 -26
  10. package/dist/2221.js +9 -0
  11. package/dist/{2445.js → 226.js} +12 -48
  12. package/dist/2387.js +7 -0
  13. package/dist/2580.js +6 -0
  14. package/dist/{1500.js → 2859.js} +10 -34
  15. package/dist/3014.js +178 -0
  16. package/dist/{6247.js → 3054.js} +3 -3
  17. package/dist/{7642.js → 3093.js} +1 -1
  18. package/dist/3189.js +5 -0
  19. package/dist/{7564.js → 331.js} +2 -2
  20. package/dist/3357.js +7 -0
  21. package/dist/{487.js → 3398.js} +38 -39
  22. package/dist/3502.js +224 -0
  23. package/dist/3695.js +50 -0
  24. package/dist/3829.js +1 -1
  25. package/dist/{6588.js → 3859.js} +115 -92
  26. package/dist/{3670.js → 3910.js} +28 -21
  27. package/dist/392.js +7 -0
  28. package/dist/{4549.js → 4155.js} +11 -3
  29. package/dist/4226.js +7 -0
  30. package/dist/{6329.js → 4229.js} +1 -1
  31. package/dist/4293.js +3 -0
  32. package/dist/4346.js +853 -2
  33. package/dist/{285.js → 4472.js} +3 -3
  34. package/dist/4605.js +207 -0
  35. package/dist/{7366.js → 488.js} +60 -7
  36. package/dist/{8750.js → 497.js} +190 -375
  37. package/dist/4989.js +35 -0
  38. package/dist/{6270.js → 510.js} +157 -196
  39. package/dist/5258.js +26 -0
  40. package/dist/{5036.js → 5275.js} +0 -3
  41. package/dist/{8171.js → 5298.js} +90 -102
  42. package/dist/5473.js +11 -0
  43. package/dist/{4745.js → 5490.js} +3 -1
  44. package/dist/{6089.js → 5561.js} +869 -786
  45. package/dist/{8996.js → 5595.js} +4 -3
  46. package/dist/5890.js +25 -0
  47. package/dist/{6046.js → 5969.js} +1 -1
  48. package/dist/5984.js +38 -0
  49. package/dist/{8527.js → 6006.js} +3 -3
  50. package/dist/6040.js +97 -0
  51. package/dist/{8758.js → 6137.js} +10 -8
  52. package/dist/{4281.js → 6140.js} +18 -10
  53. package/dist/{8960.js → 6191.js} +2 -2
  54. package/dist/6240.js +121 -0
  55. package/dist/{4490.js → 6373.js} +7 -5
  56. package/dist/{904.js → 6487.js} +19 -17
  57. package/dist/{9635.js → 6498.js} +1 -1
  58. package/dist/6499.js +4 -7
  59. package/dist/6508.js +7 -0
  60. package/dist/{8225.js → 6540.js} +1 -0
  61. package/dist/6551.js +46 -0
  62. package/dist/{9369.js → 6620.js} +35 -34
  63. package/dist/{4143.js → 6838.js} +19 -10
  64. package/dist/6902.js +48 -0
  65. package/dist/6904.js +51 -0
  66. package/dist/70.js +24 -0
  67. package/dist/7024.js +39 -0
  68. package/dist/{6882.js → 721.js} +737 -362
  69. package/dist/{951.js → 7270.js} +4 -4
  70. package/dist/{3485.js → 7323.js} +143 -111
  71. package/dist/{7541.js → 7488.js} +2 -2
  72. package/dist/{4863.js → 7542.js} +7 -6
  73. package/dist/7551.js +28 -0
  74. package/dist/{7021.js → 7640.js} +1 -1
  75. package/dist/{353.js → 7692.js} +3 -7
  76. package/dist/{4707.js → 7930.js} +2 -2
  77. package/dist/{8052.js → 8.js} +80 -64
  78. package/dist/{6914.js → 8129.js} +3 -15
  79. package/dist/{3319.js → 8358.js} +62 -63
  80. package/dist/{5864.js → 8407.js} +13 -13
  81. package/dist/8488.js +15 -0
  82. package/dist/{4768.js → 8495.js} +1 -1
  83. package/dist/8734.js +171 -0
  84. package/dist/{1763.js → 9018.js} +205 -331
  85. package/dist/9053.js +29 -0
  86. package/dist/9067.js +41 -0
  87. package/dist/{2861.js → 9120.js} +2 -2
  88. package/dist/{42.js → 9197.js} +2 -2
  89. package/dist/{9189.js → 9248.js} +36 -17
  90. package/dist/{2801.js → 9252.js} +4 -9
  91. package/dist/9295.js +7 -0
  92. package/dist/9303.js +8 -0
  93. package/dist/{167.js → 9374.js} +1 -1
  94. package/dist/{9352.js → 9540.js} +17 -47
  95. package/dist/9576.js +51 -0
  96. package/dist/{8272.js → 9591.js} +36 -46
  97. package/dist/{6107.js → 9770.js} +2 -2
  98. package/dist/{5085.js → 9880.js} +6 -3
  99. package/dist/Accordion/index.d.ts +207 -41
  100. package/dist/Accordion/index.js +75 -177
  101. package/dist/AlertDialog/index.d.ts +440 -140
  102. package/dist/AlertDialog/index.js +3 -13
  103. package/dist/Autocomplete/index.d.ts +722 -150
  104. package/dist/Autocomplete/index.js +16 -29
  105. package/dist/Avatar/index.d.ts +38 -3
  106. package/dist/Avatar/index.js +82 -28
  107. package/dist/Breadcrumbs/index.d.ts +63 -91
  108. package/dist/Breadcrumbs/index.js +1 -1
  109. package/dist/Button/index.d.ts +11 -0
  110. package/dist/Button/index.js +2 -2
  111. package/dist/Checkbox/index.d.ts +206 -36
  112. package/dist/Checkbox/index.js +293 -8
  113. package/dist/CheckboxField/index.css +1 -1
  114. package/dist/CheckboxField/index.d.ts +40 -36
  115. package/dist/CheckboxGroup/index.d.ts +50 -36
  116. package/dist/CheckboxGroup/index.js +87 -58
  117. package/dist/CheckboxGroupField/index.css +1 -1
  118. package/dist/Collapsible/index.d.ts +128 -36
  119. package/dist/Collapsible/index.js +21 -25
  120. package/dist/Combobox/index.d.ts +801 -158
  121. package/dist/Combobox/index.js +70 -114
  122. package/dist/ContextMenu/index.d.ts +1162 -195
  123. package/dist/ContextMenu/index.js +46 -36
  124. package/dist/Dialog/index.d.ts +425 -133
  125. package/dist/Dialog/index.js +8 -4
  126. package/dist/Drawer/index.d.ts +589 -144
  127. package/dist/Drawer/index.js +482 -562
  128. package/dist/Field/index.css +1 -1
  129. package/dist/Field/index.d.ts +341 -42
  130. package/dist/Field/index.js +123 -273
  131. package/dist/Fieldset/index.d.ts +11 -0
  132. package/dist/Fieldset/index.js +10 -17
  133. package/dist/Form/index.d.ts +43 -39
  134. package/dist/Form/index.js +58 -50
  135. package/dist/Input/index.css +1 -1
  136. package/dist/Input/index.d.ts +94 -42
  137. package/dist/Input/index.js +1 -1
  138. package/dist/Menu/index.d.ts +1140 -175
  139. package/dist/Menu/index.js +51 -67
  140. package/dist/Menubar/index.d.ts +651 -173
  141. package/dist/Menubar/index.js +12 -16
  142. package/dist/Meter/index.js +21 -18
  143. package/dist/NavigationMenu/index.d.ts +370 -86
  144. package/dist/NavigationMenu/index.js +144 -178
  145. package/dist/NumberField/index.css +1 -1
  146. package/dist/NumberField/index.d.ts +507 -47
  147. package/dist/NumberField/index.js +434 -718
  148. package/dist/Popover/index.d.ts +561 -142
  149. package/dist/Popover/index.js +181 -252
  150. package/dist/PreviewCard/index.d.ts +507 -143
  151. package/dist/PreviewCard/index.js +97 -151
  152. package/dist/Progress/index.d.ts +117 -3
  153. package/dist/Progress/index.js +37 -36
  154. package/dist/Radio/index.d.ts +177 -7
  155. package/dist/Radio/index.js +54 -70
  156. package/dist/RadioField/index.css +1 -1
  157. package/dist/RadioField/index.d.ts +23 -7
  158. package/dist/RadioGroup/index.d.ts +51 -37
  159. package/dist/RadioGroup/index.js +60 -51
  160. package/dist/RadioGroupField/index.css +1 -1
  161. package/dist/RadioGroupField/index.d.ts +40 -37
  162. package/dist/ScrollArea/index.d.ts +295 -1
  163. package/dist/ScrollArea/index.js +256 -324
  164. package/dist/Select/index.d.ts +516 -123
  165. package/dist/Select/index.js +513 -635
  166. package/dist/SelectField/index.css +1 -1
  167. package/dist/SelectField/index.d.ts +109 -134
  168. package/dist/SelectField/index.js +5 -1
  169. package/dist/Separator/index.d.ts +12 -0
  170. package/dist/Separator/index.js +1 -1
  171. package/dist/Slider/index.d.ts +383 -64
  172. package/dist/Slider/index.js +298 -374
  173. package/dist/Switch/index.d.ts +184 -37
  174. package/dist/Switch/index.js +44 -58
  175. package/dist/Tabs/index.d.ts +220 -35
  176. package/dist/Tabs/index.js +199 -193
  177. package/dist/Toast/index.d.ts +280 -64
  178. package/dist/Toast/index.js +299 -374
  179. package/dist/Toggle/index.d.ts +55 -35
  180. package/dist/Toggle/index.js +19 -13
  181. package/dist/ToggleGroup/index.d.ts +62 -35
  182. package/dist/ToggleGroup/index.js +13 -31
  183. package/dist/Toolbar/index.d.ts +117 -2
  184. package/dist/Toolbar/index.js +31 -43
  185. package/dist/Tooltip/index.d.ts +507 -150
  186. package/dist/Tooltip/index.js +163 -213
  187. package/dist/index.d.ts +12912 -5382
  188. package/package.json +3 -3
  189. package/dist/2205.js +0 -26
  190. package/dist/2274.js +0 -34
  191. package/dist/2287.js +0 -17
  192. package/dist/3020.js +0 -7
  193. package/dist/3021.js +0 -72
  194. package/dist/3140.js +0 -4
  195. package/dist/3248.js +0 -307
  196. package/dist/4026.js +0 -12
  197. package/dist/4922.js +0 -15
  198. package/dist/5659.js +0 -4
  199. package/dist/5992.js +0 -447
  200. package/dist/6330.js +0 -30
  201. package/dist/6535.js +0 -72
  202. package/dist/6917.js +0 -55
  203. package/dist/7725.js +0 -10
  204. package/dist/7871.js +0 -38
  205. package/dist/8106.js +0 -239
  206. package/dist/8685.js +0 -102
  207. package/dist/8935.js +0 -8
  208. package/dist/8971.js +0 -40
  209. package/dist/8979.js +0 -10
  210. package/dist/9048.js +0 -52
  211. package/dist/9087.js +0 -256
  212. package/dist/9255.js +0 -136
  213. /package/dist/{1457.js → 1068.js} +0 -0
  214. /package/dist/{6003.js → 1234.js} +0 -0
  215. /package/dist/{4723.js → 1282.js} +0 -0
  216. /package/dist/{6825.js → 1876.js} +0 -0
  217. /package/dist/{5778.js → 1885.js} +0 -0
  218. /package/dist/{2445.js.LICENSE.txt → 226.js.LICENSE.txt} +0 -0
  219. /package/dist/{1279.js → 3278.js} +0 -0
  220. /package/dist/{3296.js → 5568.js} +0 -0
  221. /package/dist/{8685.css → 6240.css} +0 -0
  222. /package/dist/{9829.js → 6488.js} +0 -0
  223. /package/dist/{9863.js → 6534.js} +0 -0
  224. /package/dist/{4495.js → 7718.js} +0 -0
  225. /package/dist/{3395.js → 8866.js} +0 -0
  226. /package/dist/{2418.js → 9837.js} +0 -0
@@ -67,15 +67,25 @@ declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E &
67
67
  readonly baseUIHandlerPrevented?: boolean | undefined;
68
68
  };
69
69
 
70
- declare const cancelOpen: "cancel-open";
70
+ declare const cancelOpen: 'cancel-open';
71
71
 
72
- declare const chipRemovePress: "chip-remove-press";
72
+ /**
73
+ * Present when the switch is checked.
74
+ */
75
+ declare const checked = "data-checked";
76
+
77
+ /**
78
+ * Present when the switch is checked.
79
+ */
80
+ declare const checked_2 = "data-checked";
73
81
 
74
- declare const clearPress: "clear-press";
82
+ declare const chipRemovePress: 'chip-remove-press';
75
83
 
76
- declare const closePress: "close-press";
84
+ declare const clearPress: 'clear-press';
77
85
 
78
- declare const closeWatcher: "close-watcher";
86
+ declare const closePress: 'close-press';
87
+
88
+ declare const closeWatcher: 'close-watcher';
79
89
 
80
90
  /**
81
91
  * Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element.
@@ -85,13 +95,33 @@ declare const closeWatcher: "close-watcher";
85
95
  */
86
96
  declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
87
97
 
88
- declare const decrementPress: "decrement-press";
98
+ declare const decrementPress: 'decrement-press';
99
+
100
+ /**
101
+ * Present when the switch's value has changed (when wrapped in Field.Root).
102
+ */
103
+ declare const dirty = "data-dirty";
104
+
105
+ /**
106
+ * Present when the switch's value has changed (when wrapped in Field.Root).
107
+ */
108
+ declare const dirty_2 = "data-dirty";
109
+
110
+ /**
111
+ * Present when the switch is disabled.
112
+ */
113
+ declare const disabled = "data-disabled";
89
114
 
90
- declare const disabled: "disabled";
115
+ /**
116
+ * Present when the switch is disabled.
117
+ */
118
+ declare const disabled_2 = "data-disabled";
119
+
120
+ declare const disabled_3: 'disabled';
91
121
 
92
- declare const drag: "drag";
122
+ declare const drag: 'drag';
93
123
 
94
- declare const escapeKey: "escape-key";
124
+ declare const escapeKey: 'escape-key';
95
125
 
96
126
  declare interface FieldRootState {
97
127
  /**
@@ -120,39 +150,69 @@ declare interface FieldRootState {
120
150
  focused: boolean;
121
151
  }
122
152
 
123
- declare const focusOut: "focus-out";
153
+ /**
154
+ * Present when the switch is active (when wrapped in Field.Root).
155
+ */
156
+ declare const filled = "data-filled";
157
+
158
+ /**
159
+ * Present when the switch is active (when wrapped in Field.Root).
160
+ */
161
+ declare const filled_2 = "data-filled";
162
+
163
+ /**
164
+ * Present when the switch is focused (when wrapped in Field.Root).
165
+ */
166
+ declare const focused = "data-focused";
167
+
168
+ /**
169
+ * Present when the switch is focused (when wrapped in Field.Root).
170
+ */
171
+ declare const focused_2 = "data-focused";
172
+
173
+ declare const focusOut: 'focus-out';
124
174
 
125
175
  declare type HTMLProps<T = any> = React_2.HTMLAttributes<T> & {
126
176
  ref?: React_2.Ref<T> | undefined;
127
177
  };
128
178
 
129
- declare const imperativeAction: "imperative-action";
179
+ declare const imperativeAction: 'imperative-action';
130
180
 
131
- declare const incrementPress: "increment-press";
181
+ declare const incrementPress: 'increment-press';
132
182
 
133
- declare const initial: "initial";
183
+ declare const initial: 'initial';
134
184
 
135
- declare const inputBlur: "input-blur";
185
+ declare const inputBlur: 'input-blur';
136
186
 
137
- declare const inputChange: "input-change";
187
+ declare const inputChange: 'input-change';
138
188
 
139
- declare const inputClear: "input-clear";
189
+ declare const inputClear: 'input-clear';
140
190
 
141
- declare const inputPaste: "input-paste";
191
+ declare const inputPaste: 'input-paste';
142
192
 
143
- declare const inputPress: "input-press";
193
+ declare const inputPress: 'input-press';
144
194
 
145
- declare const itemPress: "item-press";
195
+ /**
196
+ * Present when the switch is in an invalid state (when wrapped in Field.Root).
197
+ */
198
+ declare const invalid = "data-invalid";
199
+
200
+ /**
201
+ * Present when the switch is in an invalid state (when wrapped in Field.Root).
202
+ */
203
+ declare const invalid_2 = "data-invalid";
146
204
 
147
- declare const keyboard: "keyboard";
205
+ declare const itemPress: 'item-press';
148
206
 
149
- declare const linkPress: "link-press";
207
+ declare const keyboard: 'keyboard';
150
208
 
151
- declare const listNavigation: "list-navigation";
209
+ declare const linkPress: 'link-press';
152
210
 
153
- declare const missing: "missing";
211
+ declare const listNavigation: 'list-navigation';
154
212
 
155
- declare const none: "none";
213
+ declare const missing: 'missing';
214
+
215
+ declare const none: 'none';
156
216
 
157
217
  declare interface NonNativeButtonProps {
158
218
  /**
@@ -164,9 +224,21 @@ declare interface NonNativeButtonProps {
164
224
  nativeButton?: boolean | undefined;
165
225
  }
166
226
 
167
- declare const outsidePress: "outside-press";
227
+ declare const outsidePress: 'outside-press';
228
+
229
+ declare const pointer: 'pointer';
230
+
231
+ declare const popupClose: 'popup-close';
232
+
233
+ /**
234
+ * Present when the switch is readonly.
235
+ */
236
+ declare const readonly = "data-readonly";
168
237
 
169
- declare const pointer: "pointer";
238
+ /**
239
+ * Present when the switch is readonly.
240
+ */
241
+ declare const readonly_2 = "data-readonly";
170
242
 
171
243
  declare namespace REASONS {
172
244
  export {
@@ -197,9 +269,10 @@ declare namespace REASONS {
197
269
  drag,
198
270
  wheel,
199
271
  scrub,
272
+ popupClose,
200
273
  cancelOpen,
201
274
  siblingOpen,
202
- disabled,
275
+ disabled_3 as disabled,
203
276
  missing,
204
277
  initial,
205
278
  imperativeAction,
@@ -251,11 +324,21 @@ declare interface ReasonToEventMap {
251
324
  [REASONS.windowResize]: UIEvent;
252
325
  }
253
326
 
254
- declare const scrub: "scrub";
327
+ /**
328
+ * Present when the switch is required.
329
+ */
330
+ declare const required = "data-required";
331
+
332
+ /**
333
+ * Present when the switch is required.
334
+ */
335
+ declare const required_2 = "data-required";
336
+
337
+ declare const scrub: 'scrub';
255
338
 
256
- declare const siblingOpen: "sibling-open";
339
+ declare const siblingOpen: 'sibling-open';
257
340
 
258
- declare const swipe: "swipe";
341
+ declare const swipe: 'swipe';
259
342
 
260
343
  export declare const Switch: {
261
344
  Root: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SwitchRootProps_2, "ref"> & React_2.RefAttributes<HTMLElement>, "ref">, "className"> & {
@@ -288,9 +371,27 @@ export declare type SwitchRootChangeEventDetails = BaseUIChangeEventDetails<Swit
288
371
 
289
372
  export declare type SwitchRootChangeEventReason = typeof REASONS.none;
290
373
 
374
+ export declare namespace SwitchRootDataAttributes {
375
+ export {
376
+ checked,
377
+ unchecked,
378
+ disabled,
379
+ readonly,
380
+ required,
381
+ valid,
382
+ invalid,
383
+ touched,
384
+ dirty,
385
+ filled,
386
+ focused
387
+ }
388
+ }
389
+
291
390
  export declare interface SwitchRootProps extends NonNativeButtonProps, Omit<BaseUIComponentProps<'span', SwitchRootState>, 'onChange'> {
292
391
  /**
293
- * The id of the switch element.
392
+ * The id of the hidden input element.
393
+ *
394
+ * When `nativeButton` is `true`, the id is applied to the root element.
294
395
  */
295
396
  id?: string | undefined;
296
397
  /**
@@ -397,21 +498,67 @@ export declare namespace SwitchThumb {
397
498
  export type State = SwitchThumbState;
398
499
  }
399
500
 
501
+ export declare namespace SwitchThumbDataAttributes {
502
+ export {
503
+ checked_2 as checked,
504
+ unchecked_2 as unchecked,
505
+ disabled_2 as disabled,
506
+ readonly_2 as readonly,
507
+ required_2 as required,
508
+ valid_2 as valid,
509
+ invalid_2 as invalid,
510
+ touched_2 as touched,
511
+ dirty_2 as dirty,
512
+ filled_2 as filled,
513
+ focused_2 as focused
514
+ }
515
+ }
516
+
400
517
  export declare interface SwitchThumbProps extends BaseUIComponentProps<'span', SwitchThumbState> {}
401
518
 
402
519
  export declare interface SwitchThumbState extends SwitchRootState {}
403
520
 
404
- declare const trackPress: "track-press";
521
+ /**
522
+ * Present when the switch has been touched (when wrapped in Field.Root).
523
+ */
524
+ declare const touched = "data-touched";
525
+
526
+ /**
527
+ * Present when the switch has been touched (when wrapped in Field.Root).
528
+ */
529
+ declare const touched_2 = "data-touched";
530
+
531
+ declare const trackPress: 'track-press';
532
+
533
+ declare const triggerFocus: 'trigger-focus';
405
534
 
406
- declare const triggerFocus: "trigger-focus";
535
+ declare const triggerHover: 'trigger-hover';
407
536
 
408
- declare const triggerHover: "trigger-hover";
537
+ declare const triggerPress: 'trigger-press';
409
538
 
410
- declare const triggerPress: "trigger-press";
539
+ /**
540
+ * Present when the switch is not checked.
541
+ */
542
+ declare const unchecked = "data-unchecked";
543
+
544
+ /**
545
+ * Present when the switch is not checked.
546
+ */
547
+ declare const unchecked_2 = "data-unchecked";
548
+
549
+ /**
550
+ * Present when the switch is in a valid state (when wrapped in Field.Root).
551
+ */
552
+ declare const valid = "data-valid";
553
+
554
+ /**
555
+ * Present when the switch is in a valid state (when wrapped in Field.Root).
556
+ */
557
+ declare const valid_2 = "data-valid";
411
558
 
412
- declare const wheel: "wheel";
559
+ declare const wheel: 'wheel';
413
560
 
414
- declare const windowResize: "window-resize";
561
+ declare const windowResize: 'window-resize';
415
562
 
416
563
  /**
417
564
  * Adds a `preventBaseUIHandler` method to all event handlers.
@@ -1,66 +1,54 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { EMPTY_OBJECT, mergeProps, useMergedRefs, useRenderElement, esm_formatErrorMessage } from "../8272.js";
3
- import { useLabelableContext, fieldValidityMapping, useFieldRootContext } from "../1477.js";
4
- import { useFormContext } from "../5085.js";
5
- import { useBaseUiId } from "../6046.js";
6
- import { useLabelableId } from "../9048.js";
7
- import { useControlled } from "../8527.js";
8
- import { useRegisterFieldControl } from "../4281.js";
9
- import { useIsoLayoutEffect } from "../6499.js";
10
- import { useValueChanged } from "../2801.js";
11
- import { useButton } from "../9189.js";
12
- import { useAriaLabelledBy } from "../4490.js";
13
- import { getWindow } from "../3829.js";
14
- import { visuallyHiddenInput, visuallyHidden } from "../8225.js";
15
- import { createChangeEventDetails } from "../4768.js";
2
+ import { utils_formatErrorMessage } from "../5473.js";
3
+ import { useLabelableContext, fieldValidityMapping, useFieldRootContext } from "../201.js";
4
+ import { useFormContext } from "../9880.js";
5
+ import { useMergedRefs, useRenderElement, EMPTY_OBJECT } from "../9591.js";
6
+ import { useSetFieldFocused } from "../5890.js";
7
+ import { useBaseUiId } from "../5969.js";
8
+ import { useLabelableId } from "../6551.js";
9
+ import { useControlled } from "../6006.js";
10
+ import { useRegisterFieldControl } from "../6140.js";
11
+ import { useIsoLayoutEffect } from "../3357.js";
12
+ import { useValueChanged } from "../9252.js";
13
+ import { dispatchClickWithModifiers, useButton } from "../9248.js";
14
+ import { useAriaLabelledBy } from "../6373.js";
15
+ import { visuallyHiddenInput, visuallyHidden } from "../6540.js";
16
+ import { createChangeEventDetails } from "../8495.js";
16
17
  import * as __rspack_external_react from "react";
17
18
  const SwitchRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
18
19
  if ("production" !== process.env.NODE_ENV) SwitchRootContext.displayName = "SwitchRootContext";
19
20
  function useSwitchRootContext() {
20
21
  const context = __rspack_external_react.useContext(SwitchRootContext);
21
- if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SwitchRootContext is missing. Switch parts must be placed within <Switch.Root>.' : esm_formatErrorMessage(63));
22
+ if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SwitchRootContext is missing. Switch parts must be placed within <Switch.Root>.' : utils_formatErrorMessage(63));
22
23
  return context;
23
24
  }
24
- let SwitchRootDataAttributes_SwitchRootDataAttributes = /*#__PURE__*/ function(SwitchRootDataAttributes) {
25
- SwitchRootDataAttributes["checked"] = "data-checked";
26
- SwitchRootDataAttributes["unchecked"] = "data-unchecked";
27
- SwitchRootDataAttributes["disabled"] = "data-disabled";
28
- SwitchRootDataAttributes["readonly"] = "data-readonly";
29
- SwitchRootDataAttributes["required"] = "data-required";
30
- SwitchRootDataAttributes["valid"] = "data-valid";
31
- SwitchRootDataAttributes["invalid"] = "data-invalid";
32
- SwitchRootDataAttributes["touched"] = "data-touched";
33
- SwitchRootDataAttributes["dirty"] = "data-dirty";
34
- SwitchRootDataAttributes["filled"] = "data-filled";
35
- SwitchRootDataAttributes["focused"] = "data-focused";
36
- return SwitchRootDataAttributes;
37
- }({});
25
+ const SwitchRootDataAttributes_checked = 'data-checked';
26
+ const unchecked = 'data-unchecked';
38
27
  const stateAttributesMapping = {
39
28
  ...fieldValidityMapping,
40
29
  checked (value) {
41
30
  if (value) return {
42
- [SwitchRootDataAttributes_SwitchRootDataAttributes.checked]: ''
31
+ [SwitchRootDataAttributes_checked]: ''
43
32
  };
44
33
  return {
45
- [SwitchRootDataAttributes_SwitchRootDataAttributes.unchecked]: ''
34
+ [unchecked]: ''
46
35
  };
47
36
  }
48
37
  };
49
38
  const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
50
39
  const { checked: checkedProp, className, defaultChecked, 'aria-labelledby': ariaLabelledByProp, form, id: idProp, inputRef: externalInputRef, name: nameProp, nativeButton = false, onCheckedChange, readOnly = false, required = false, disabled: disabledProp = false, render, uncheckedValue, value, style, ...elementProps } = componentProps;
51
40
  const { clearErrors } = useFormContext();
52
- const { state: fieldState, setTouched, setDirty, validityData, setFilled, setFocused, shouldValidateOnChange, validationMode, disabled: fieldDisabled, name: fieldName, validation } = useFieldRootContext();
41
+ const { state: fieldState, setTouched, setDirty, validityData, setFilled, validationMode, disabled: fieldDisabled, name: fieldName, validation } = useFieldRootContext();
53
42
  const { labelId } = useLabelableContext();
54
43
  const disabled = fieldDisabled || disabledProp;
55
44
  const name = fieldName ?? nameProp;
56
45
  const inputRef = __rspack_external_react.useRef(null);
57
46
  const handleInputRef = useMergedRefs(inputRef, externalInputRef, validation.inputRef);
58
47
  const switchRef = __rspack_external_react.useRef(null);
48
+ const setFocused = useSetFieldFocused(disabled, switchRef);
59
49
  const id = useBaseUiId();
60
50
  const controlId = useLabelableId({
61
- id: idProp,
62
- implicit: false,
63
- controlRef: switchRef
51
+ id: idProp
64
52
  });
65
53
  const hiddenInputId = nativeButton ? void 0 : controlId;
66
54
  const [checked, setCheckedState] = useControlled({
@@ -69,25 +57,23 @@ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
69
57
  name: 'Switch',
70
58
  state: 'checked'
71
59
  });
72
- useRegisterFieldControl(switchRef, id, checked);
60
+ useRegisterFieldControl(switchRef, id, checked, void 0, !disabled, nameProp);
73
61
  useIsoLayoutEffect(()=>{
74
- if (inputRef.current) setFilled(inputRef.current.checked);
62
+ setFilled(checked);
75
63
  }, [
76
- inputRef,
64
+ checked,
77
65
  setFilled
78
66
  ]);
79
67
  useValueChanged(checked, ()=>{
80
68
  clearErrors(name);
81
69
  setDirty(checked !== validityData.initialValue);
82
- setFilled(checked);
83
- if (shouldValidateOnChange()) validation.commit(checked);
84
- else validation.commit(checked, true);
70
+ validation.change(checked);
85
71
  });
86
72
  const { getButtonProps, buttonRef } = useButton({
87
73
  disabled,
88
74
  native: nativeButton
89
75
  });
90
- const ariaLabelledBy = useAriaLabelledBy(ariaLabelledByProp, labelId, inputRef, !nativeButton, hiddenInputId);
76
+ const ariaLabelledBy = useAriaLabelledBy(ariaLabelledByProp, labelId, inputRef, !nativeButton, hiddenInputId, elementProps['aria-label']);
91
77
  const rootProps = {
92
78
  id: nativeButton ? controlId : id,
93
79
  role: 'switch',
@@ -96,7 +82,7 @@ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
96
82
  'aria-required': required || void 0,
97
83
  'aria-labelledby': ariaLabelledBy,
98
84
  onFocus () {
99
- if (!disabled) setFocused(true);
85
+ setFocused(true);
100
86
  },
101
87
  onBlur () {
102
88
  const element = inputRef.current;
@@ -110,16 +96,11 @@ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
110
96
  event.preventDefault();
111
97
  const input = inputRef.current;
112
98
  if (!input) return;
113
- input.dispatchEvent(new (getWindow(input)).PointerEvent('click', {
114
- bubbles: true,
115
- shiftKey: event.shiftKey,
116
- ctrlKey: event.ctrlKey,
117
- altKey: event.altKey,
118
- metaKey: event.metaKey
119
- }));
99
+ dispatchClickWithModifiers(input, event);
120
100
  }
121
101
  };
122
- const inputProps = mergeProps({
102
+ const inputProps = {
103
+ ...validation.getValidationProps(disabled),
123
104
  checked,
124
105
  disabled,
125
106
  form,
@@ -140,12 +121,16 @@ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
140
121
  if (eventDetails.isCanceled) return;
141
122
  setCheckedState(nextChecked);
142
123
  },
124
+ onClick (event) {
125
+ event.stopPropagation();
126
+ },
143
127
  onFocus () {
144
128
  switchRef.current?.focus();
145
- }
146
- }, validation.getInputValidationProps, void 0 !== value ? {
147
- value
148
- } : EMPTY_OBJECT);
129
+ },
130
+ ...void 0 !== value ? {
131
+ value
132
+ } : EMPTY_OBJECT
133
+ };
149
134
  const state = __rspack_external_react.useMemo(()=>({
150
135
  ...fieldState,
151
136
  checked,
@@ -168,9 +153,9 @@ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
168
153
  ],
169
154
  props: [
170
155
  rootProps,
171
- validation.getValidationProps,
172
156
  elementProps,
173
- getButtonProps
157
+ getButtonProps,
158
+ (props)=>validation.getValidationProps(disabled, props)
174
159
  ],
175
160
  stateAttributesMapping: stateAttributesMapping
176
161
  });
@@ -182,7 +167,8 @@ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
182
167
  type: "hidden",
183
168
  form: form,
184
169
  name: name,
185
- value: uncheckedValue
170
+ value: uncheckedValue,
171
+ disabled: disabled
186
172
  }),
187
173
  /*#__PURE__*/ jsx("input", {
188
174
  ...inputProps,