@wix/site-ui 1.29.0 → 1.31.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 (177) hide show
  1. package/dist/1268.js +99 -0
  2. package/dist/1279.js +7 -0
  3. package/dist/1457.js +10 -0
  4. package/dist/1477.js +106 -0
  5. package/dist/1500.js +111 -0
  6. package/dist/167.js +6 -0
  7. package/dist/2274.js +34 -0
  8. package/dist/2287.js +17 -0
  9. package/dist/2418.js +31 -0
  10. package/dist/2801.js +20 -0
  11. package/dist/285.js +86 -0
  12. package/dist/2861.js +6 -0
  13. package/dist/3020.js +7 -0
  14. package/dist/3021.js +72 -0
  15. package/dist/3056.js +229 -0
  16. package/dist/3140.js +4 -0
  17. package/dist/3248.js +307 -0
  18. package/dist/3296.js +4 -0
  19. package/dist/3319.js +400 -0
  20. package/dist/3395.js +4 -0
  21. package/dist/3485.js +854 -0
  22. package/dist/353.js +14 -0
  23. package/dist/3670.js +418 -0
  24. package/dist/3829.js +113 -0
  25. package/dist/4026.js +12 -0
  26. package/dist/4143.js +46 -0
  27. package/dist/42.js +32 -0
  28. package/dist/4281.js +30 -0
  29. package/dist/4346.js +2 -0
  30. package/dist/4388.js +418 -0
  31. package/dist/4490.js +32 -0
  32. package/dist/4495.js +9 -0
  33. package/dist/4549.js +24 -0
  34. package/dist/4586.js +41 -0
  35. package/dist/4586.js.LICENSE.txt +19 -0
  36. package/dist/4707.js +19 -0
  37. package/dist/4723.js +7 -0
  38. package/dist/4745.js +7 -0
  39. package/dist/4768.js +35 -0
  40. package/dist/4922.js +15 -0
  41. package/dist/5036.js +17 -0
  42. package/dist/5085.js +20 -0
  43. package/dist/5299.js +597 -0
  44. package/dist/5659.js +4 -0
  45. package/dist/5778.js +10 -0
  46. package/dist/5864.js +86 -0
  47. package/dist/5992.js +913 -0
  48. package/dist/5992.js.LICENSE.txt +19 -0
  49. package/dist/6003.js +10 -0
  50. package/dist/6046.js +29 -0
  51. package/dist/6089.js +2355 -0
  52. package/dist/6107.js +10 -0
  53. package/dist/6247.js +20 -0
  54. package/dist/6270.js +487 -0
  55. package/dist/6329.js +32 -0
  56. package/dist/6330.js +30 -0
  57. package/dist/6499.js +7 -0
  58. package/dist/6535.js +71 -0
  59. package/dist/6588.js +382 -0
  60. package/dist/6706.js +16 -0
  61. package/dist/6825.js +7 -0
  62. package/dist/6882.js +1562 -0
  63. package/dist/6914.js +30 -0
  64. package/dist/7021.js +13 -0
  65. package/dist/7366.js +83 -0
  66. package/dist/7373.js +25 -0
  67. package/dist/7541.js +25 -0
  68. package/dist/7564.js +10 -0
  69. package/dist/7642.js +20 -0
  70. package/dist/7725.js +10 -0
  71. package/dist/7871.js +38 -0
  72. package/dist/8052.js +352 -0
  73. package/dist/8106.js +238 -0
  74. package/dist/8171.js +346 -0
  75. package/dist/8225.js +21 -0
  76. package/dist/8272.js +333 -0
  77. package/dist/8527.js +58 -0
  78. package/dist/8724.js +10 -0
  79. package/dist/8750.js +1920 -0
  80. package/dist/8758.js +43 -0
  81. package/dist/880.js +149 -0
  82. package/dist/8935.js +8 -0
  83. package/dist/8960.js +22 -0
  84. package/dist/8971.js +40 -0
  85. package/dist/8979.js +10 -0
  86. package/dist/8996.js +71 -0
  87. package/dist/904.js +121 -0
  88. package/dist/9048.js +52 -0
  89. package/dist/9087.js +256 -0
  90. package/dist/9189.js +158 -0
  91. package/dist/9255.js +136 -0
  92. package/dist/9352.js +148 -0
  93. package/dist/951.js +22 -0
  94. package/dist/9635.js +22 -0
  95. package/dist/9829.js +4 -0
  96. package/dist/9863.js +8 -0
  97. package/dist/Accordion/index.d.ts +569 -12
  98. package/dist/Accordion/index.js +423 -8
  99. package/dist/AlertDialog/index.d.ts +1417 -18
  100. package/dist/AlertDialog/index.js +34 -14
  101. package/dist/Autocomplete/index.d.ts +1861 -38
  102. package/dist/Autocomplete/index.js +98 -24
  103. package/dist/Avatar/index.d.ts +129 -7
  104. package/dist/Avatar/index.js +149 -6
  105. package/dist/Badge/index.css +44 -0
  106. package/dist/Badge/index.d.ts +22 -0
  107. package/dist/Badge/index.js +23 -0
  108. package/dist/Breadcrumbs/index.d.ts +960 -7
  109. package/dist/Breadcrumbs/index.js +5 -5
  110. package/dist/Button/index.d.ts +88 -6
  111. package/dist/Button/index.js +27 -3
  112. package/dist/Checkbox/index.d.ts +425 -5
  113. package/dist/Checkbox/index.js +45 -5
  114. package/dist/CheckboxGroup/index.d.ts +318 -3
  115. package/dist/CheckboxGroup/index.js +166 -3
  116. package/dist/Collapsible/index.d.ts +377 -7
  117. package/dist/Collapsible/index.js +160 -6
  118. package/dist/Combobox/index.d.ts +1984 -48
  119. package/dist/Combobox/index.js +352 -29
  120. package/dist/ContextMenu/index.d.ts +2340 -36
  121. package/dist/ContextMenu/index.js +197 -22
  122. package/dist/Dialog/index.d.ts +1355 -18
  123. package/dist/Dialog/index.js +16 -14
  124. package/dist/Drawer/index.d.ts +1653 -18
  125. package/dist/Drawer/index.js +2797 -20
  126. package/dist/Field/index.d.ts +655 -15
  127. package/dist/Field/index.js +677 -10
  128. package/dist/Fieldset/index.d.ts +94 -5
  129. package/dist/Fieldset/index.js +68 -5
  130. package/dist/Form/index.d.ts +331 -2
  131. package/dist/Form/index.js +106 -3
  132. package/dist/Input/index.d.ts +692 -3
  133. package/dist/Input/index.js +10 -3
  134. package/dist/Menu/index.d.ts +2301 -36
  135. package/dist/Menu/index.js +365 -26
  136. package/dist/Menubar/index.d.ts +2301 -3
  137. package/dist/Menubar/index.js +105 -3
  138. package/dist/Meter/index.d.ts +175 -11
  139. package/dist/Meter/index.js +129 -9
  140. package/dist/NavigationMenu/index.d.ts +978 -28
  141. package/dist/NavigationMenu/index.js +1034 -17
  142. package/dist/NumberField/index.d.ts +612 -15
  143. package/dist/NumberField/index.js +1409 -11
  144. package/dist/Popover/index.d.ts +1655 -20
  145. package/dist/Popover/index.js +792 -17
  146. package/dist/PreviewCard/index.d.ts +1523 -14
  147. package/dist/PreviewCard/index.js +679 -14
  148. package/dist/Progress/index.d.ts +183 -11
  149. package/dist/Progress/index.js +181 -9
  150. package/dist/Radio/index.d.ts +185 -6
  151. package/dist/Radio/index.js +253 -6
  152. package/dist/RadioGroup/index.d.ts +341 -2
  153. package/dist/RadioGroup/index.js +154 -3
  154. package/dist/ScrollArea/index.d.ts +265 -13
  155. package/dist/ScrollArea/index.js +892 -10
  156. package/dist/Select/index.d.ts +1493 -38
  157. package/dist/Select/index.js +1824 -23
  158. package/dist/Separator/index.d.ts +80 -6
  159. package/dist/Separator/index.js +3 -3
  160. package/dist/Slider/index.d.ts +678 -16
  161. package/dist/Slider/index.js +1199 -11
  162. package/dist/Switch/index.d.ts +393 -5
  163. package/dist/Switch/index.js +208 -6
  164. package/dist/Tabs/index.d.ts +523 -12
  165. package/dist/Tabs/index.js +685 -9
  166. package/dist/Toggle/index.d.ts +305 -2
  167. package/dist/Toggle/index.js +76 -3
  168. package/dist/ToggleGroup/index.d.ts +316 -2
  169. package/dist/ToggleGroup/index.js +102 -3
  170. package/dist/Toolbar/index.d.ts +282 -13
  171. package/dist/Toolbar/index.js +230 -9
  172. package/dist/Tooltip/index.d.ts +1572 -14
  173. package/dist/Tooltip/index.js +965 -14
  174. package/dist/index.d.ts +12758 -646
  175. package/dist/index.js +1 -0
  176. package/dist/rslib-runtime.js +18 -0
  177. package/package.json +3 -3
@@ -1,19 +1,374 @@
1
1
  import * as React_2 from 'react';
2
- import { SwitchRootProps } from '@base-ui/react/switch';
3
- import { SwitchThumbProps } from '@base-ui/react/switch';
2
+ import { SwitchRootProps as SwitchRootProps_2 } from '@base-ui/react/switch';
3
+ import { SwitchThumbProps as SwitchThumbProps_2 } from '@base-ui/react/switch';
4
+
5
+ declare type BaseUIChangeEventDetail<Reason extends string, CustomProperties extends object> = {
6
+ /**
7
+ * The reason for the event.
8
+ */
9
+ reason: Reason;
10
+ /**
11
+ * The native event associated with the custom event.
12
+ */
13
+ event: ReasonToEvent<Reason>;
14
+ /**
15
+ * Cancels Base UI from handling the event.
16
+ */
17
+ cancel: () => void;
18
+ /**
19
+ * Allows the event to propagate in cases where Base UI will stop the propagation.
20
+ */
21
+ allowPropagation: () => void;
22
+ /**
23
+ * Indicates whether the event has been canceled.
24
+ */
25
+ isCanceled: boolean;
26
+ /**
27
+ * Indicates whether the event is allowed to propagate.
28
+ */
29
+ isPropagationAllowed: boolean;
30
+ /**
31
+ * The element that triggered the event, if applicable.
32
+ */
33
+ trigger: Element | undefined;
34
+ } & CustomProperties;
35
+
36
+ /**
37
+ * Details of custom change events emitted by Base UI components.
38
+ */
39
+ declare type BaseUIChangeEventDetails<Reason extends string, CustomProperties extends object = {}> = Reason extends string ? BaseUIChangeEventDetail<Reason, CustomProperties> & {} : never;
40
+
41
+ /**
42
+ * Props shared by all Base UI components.
43
+ * Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering).
44
+ */
45
+ declare type BaseUIComponentProps<ElementType extends React_2.ElementType, State, RenderFunctionProps = HTMLProps> = Omit<WithBaseUIEvent<React_2.ComponentPropsWithRef<ElementType>>, 'className' | 'color' | 'defaultValue' | 'defaultChecked' | 'style'> & {
46
+ /**
47
+ * CSS class applied to the element, or a function that
48
+ * returns a class based on the component's state.
49
+ */
50
+ className?: string | ((state: State) => string | undefined) | undefined;
51
+ /**
52
+ * Allows you to replace the component's HTML element
53
+ * with a different tag, or compose it with another component.
54
+ *
55
+ * Accepts a `ReactElement` or a function that returns the element to render.
56
+ */
57
+ render?: React_2.ReactElement | ComponentRenderFn<RenderFunctionProps, State> | undefined;
58
+ /**
59
+ * Style applied to the element, or a function that
60
+ * returns a style object based on the component's state.
61
+ */
62
+ style?: React_2.CSSProperties | ((state: State) => React_2.CSSProperties | undefined) | undefined;
63
+ };
64
+
65
+ declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E & {
66
+ preventBaseUIHandler: () => void;
67
+ readonly baseUIHandlerPrevented?: boolean | undefined;
68
+ };
69
+
70
+ declare const cancelOpen: "cancel-open";
71
+
72
+ declare const chipRemovePress: "chip-remove-press";
73
+
74
+ declare const clearPress: "clear-press";
75
+
76
+ declare const closePress: "close-press";
77
+
78
+ declare const closeWatcher: "close-watcher";
79
+
80
+ /**
81
+ * 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.
82
+ *
83
+ * @template Props Props to be spread on the rendered element.
84
+ * @template State Component's internal state.
85
+ */
86
+ declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
87
+
88
+ declare const decrementPress: "decrement-press";
89
+
90
+ declare const disabled: "disabled";
91
+
92
+ declare const drag: "drag";
93
+
94
+ declare const escapeKey: "escape-key";
95
+
96
+ declare interface FieldRootState {
97
+ /**
98
+ * Whether the component should ignore user interaction.
99
+ */
100
+ disabled: boolean;
101
+ /**
102
+ * Whether the field has been touched.
103
+ */
104
+ touched: boolean;
105
+ /**
106
+ * Whether the field value has changed from its initial value.
107
+ */
108
+ dirty: boolean;
109
+ /**
110
+ * Whether the field is valid.
111
+ */
112
+ valid: boolean | null;
113
+ /**
114
+ * Whether the field has a value.
115
+ */
116
+ filled: boolean;
117
+ /**
118
+ * Whether the field is focused.
119
+ */
120
+ focused: boolean;
121
+ }
122
+
123
+ declare const focusOut: "focus-out";
124
+
125
+ declare type HTMLProps<T = any> = React_2.HTMLAttributes<T> & {
126
+ ref?: React_2.Ref<T> | undefined;
127
+ };
128
+
129
+ declare const imperativeAction: "imperative-action";
130
+
131
+ declare const incrementPress: "increment-press";
132
+
133
+ declare const initial: "initial";
134
+
135
+ declare const inputBlur: "input-blur";
136
+
137
+ declare const inputChange: "input-change";
138
+
139
+ declare const inputClear: "input-clear";
140
+
141
+ declare const inputPaste: "input-paste";
142
+
143
+ declare const inputPress: "input-press";
144
+
145
+ declare const itemPress: "item-press";
146
+
147
+ declare const keyboard: "keyboard";
148
+
149
+ declare const linkPress: "link-press";
150
+
151
+ declare const listNavigation: "list-navigation";
152
+
153
+ declare const missing: "missing";
154
+
155
+ declare const none: "none";
156
+
157
+ declare interface NonNativeButtonProps {
158
+ /**
159
+ * Whether the component renders a native `<button>` element when replacing it
160
+ * via the `render` prop.
161
+ * Set to `true` if the rendered element is a native button.
162
+ * @default false
163
+ */
164
+ nativeButton?: boolean | undefined;
165
+ }
166
+
167
+ declare const outsidePress: "outside-press";
168
+
169
+ declare const pointer: "pointer";
170
+
171
+ declare namespace REASONS {
172
+ export {
173
+ none,
174
+ triggerPress,
175
+ triggerHover,
176
+ triggerFocus,
177
+ outsidePress,
178
+ itemPress,
179
+ closePress,
180
+ linkPress,
181
+ clearPress,
182
+ chipRemovePress,
183
+ trackPress,
184
+ incrementPress,
185
+ decrementPress,
186
+ inputChange,
187
+ inputClear,
188
+ inputBlur,
189
+ inputPaste,
190
+ inputPress,
191
+ focusOut,
192
+ escapeKey,
193
+ closeWatcher,
194
+ listNavigation,
195
+ keyboard,
196
+ pointer,
197
+ drag,
198
+ wheel,
199
+ scrub,
200
+ cancelOpen,
201
+ siblingOpen,
202
+ disabled,
203
+ missing,
204
+ initial,
205
+ imperativeAction,
206
+ swipe,
207
+ windowResize
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Maps a change `reason` string to the corresponding native event type.
213
+ */
214
+ declare type ReasonToEvent<Reason extends string> = Reason extends keyof ReasonToEventMap ? ReasonToEventMap[Reason] : Event;
215
+
216
+ declare interface ReasonToEventMap {
217
+ [REASONS.none]: Event;
218
+ [REASONS.triggerPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
219
+ [REASONS.triggerHover]: MouseEvent;
220
+ [REASONS.triggerFocus]: FocusEvent;
221
+ [REASONS.outsidePress]: MouseEvent | PointerEvent | TouchEvent;
222
+ [REASONS.itemPress]: MouseEvent | KeyboardEvent | PointerEvent;
223
+ [REASONS.closePress]: MouseEvent | KeyboardEvent | PointerEvent;
224
+ [REASONS.linkPress]: MouseEvent | PointerEvent;
225
+ [REASONS.clearPress]: PointerEvent | MouseEvent | KeyboardEvent;
226
+ [REASONS.chipRemovePress]: PointerEvent | MouseEvent | KeyboardEvent;
227
+ [REASONS.trackPress]: PointerEvent | MouseEvent | TouchEvent;
228
+ [REASONS.incrementPress]: PointerEvent | MouseEvent | TouchEvent;
229
+ [REASONS.decrementPress]: PointerEvent | MouseEvent | TouchEvent;
230
+ [REASONS.inputChange]: InputEvent | Event;
231
+ [REASONS.inputClear]: InputEvent | FocusEvent | Event;
232
+ [REASONS.inputBlur]: FocusEvent;
233
+ [REASONS.inputPaste]: ClipboardEvent;
234
+ [REASONS.inputPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
235
+ [REASONS.focusOut]: FocusEvent | KeyboardEvent;
236
+ [REASONS.escapeKey]: KeyboardEvent;
237
+ [REASONS.closeWatcher]: Event;
238
+ [REASONS.listNavigation]: KeyboardEvent;
239
+ [REASONS.keyboard]: KeyboardEvent;
240
+ [REASONS.pointer]: PointerEvent;
241
+ [REASONS.drag]: PointerEvent | TouchEvent;
242
+ [REASONS.swipe]: PointerEvent | TouchEvent;
243
+ [REASONS.wheel]: WheelEvent;
244
+ [REASONS.scrub]: PointerEvent;
245
+ [REASONS.cancelOpen]: MouseEvent;
246
+ [REASONS.siblingOpen]: Event;
247
+ [REASONS.disabled]: Event;
248
+ [REASONS.missing]: Event;
249
+ [REASONS.initial]: Event;
250
+ [REASONS.imperativeAction]: Event;
251
+ [REASONS.windowResize]: UIEvent;
252
+ }
253
+
254
+ declare const scrub: "scrub";
255
+
256
+ declare const siblingOpen: "sibling-open";
257
+
258
+ declare const swipe: "swipe";
4
259
 
5
260
  export declare const Switch: {
6
- Root: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SwitchRootProps, "ref"> & React_2.RefAttributes<HTMLElement>, "ref">, "className"> & {
261
+ Root: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SwitchRootProps_2, "ref"> & React_2.RefAttributes<HTMLElement>, "ref">, "className"> & {
7
262
  className?: string | undefined;
8
263
  } & {
9
264
  width?: number | undefined;
10
265
  height?: number | undefined;
11
266
  } & React_2.RefAttributes<HTMLElement>>;
12
- Thumb: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SwitchThumbProps, "ref"> & React_2.RefAttributes<HTMLSpanElement>, "ref">, "className"> & {
267
+ Thumb: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SwitchThumbProps_2, "ref"> & React_2.RefAttributes<HTMLSpanElement>, "ref">, "className"> & {
13
268
  className?: string | undefined;
14
269
  } & React_2.RefAttributes<HTMLSpanElement>>;
15
270
  };
16
271
 
272
+ /**
273
+ * Represents the switch itself.
274
+ * Renders a `<span>` element and a hidden `<input>` beside.
275
+ *
276
+ * Documentation: [Base UI Switch](https://base-ui.com/react/components/switch)
277
+ */
278
+ export declare const SwitchRoot: React_2.ForwardRefExoticComponent<Omit<SwitchRootProps, "ref"> & React_2.RefAttributes<HTMLElement>>;
279
+
280
+ export declare namespace SwitchRoot {
281
+ export type State = SwitchRootState;
282
+ export type Props = SwitchRootProps;
283
+ export type ChangeEventReason = SwitchRootChangeEventReason;
284
+ export type ChangeEventDetails = SwitchRootChangeEventDetails;
285
+ }
286
+
287
+ export declare type SwitchRootChangeEventDetails = BaseUIChangeEventDetails<SwitchRoot.ChangeEventReason>;
288
+
289
+ export declare type SwitchRootChangeEventReason = typeof REASONS.none;
290
+
291
+ export declare interface SwitchRootProps extends NonNativeButtonProps, Omit<BaseUIComponentProps<'span', SwitchRootState>, 'onChange'> {
292
+ /**
293
+ * The id of the switch element.
294
+ */
295
+ id?: string | undefined;
296
+ /**
297
+ * Whether the switch is currently active.
298
+ *
299
+ * To render an uncontrolled switch, use the `defaultChecked` prop instead.
300
+ */
301
+ checked?: boolean | undefined;
302
+ /**
303
+ * Whether the switch is initially active.
304
+ *
305
+ * To render a controlled switch, use the `checked` prop instead.
306
+ * @default false
307
+ */
308
+ defaultChecked?: boolean | undefined;
309
+ /**
310
+ * Whether the component should ignore user interaction.
311
+ * @default false
312
+ */
313
+ disabled?: boolean | undefined;
314
+ /**
315
+ * A ref to access the hidden `<input>` element.
316
+ */
317
+ inputRef?: React_2.Ref<HTMLInputElement> | undefined;
318
+ /**
319
+ * Identifies the field when a form is submitted.
320
+ */
321
+ name?: string | undefined;
322
+ /**
323
+ * Identifies the form that owns the hidden input.
324
+ * Useful when the switch is rendered outside the form.
325
+ */
326
+ form?: string | undefined;
327
+ /**
328
+ * Event handler called when the switch is activated or deactivated.
329
+ */
330
+ onCheckedChange?: ((checked: boolean, eventDetails: SwitchRoot.ChangeEventDetails) => void) | undefined;
331
+ /**
332
+ * Whether the user should be unable to activate or deactivate the switch.
333
+ * @default false
334
+ */
335
+ readOnly?: boolean | undefined;
336
+ /**
337
+ * Whether the user must activate the switch before submitting a form.
338
+ * @default false
339
+ */
340
+ required?: boolean | undefined;
341
+ /**
342
+ * The value submitted with the form when the switch is on.
343
+ * By default, switch submits the "on" value, matching native checkbox behavior.
344
+ */
345
+ value?: string | undefined;
346
+ /**
347
+ * The value submitted with the form when the switch is off.
348
+ * By default, unchecked switches do not submit any value, matching native checkbox behavior.
349
+ */
350
+ uncheckedValue?: string | undefined;
351
+ }
352
+
353
+ export declare interface SwitchRootState extends FieldRootState {
354
+ /**
355
+ * Whether the switch is currently active.
356
+ */
357
+ checked: boolean;
358
+ /**
359
+ * Whether the component should ignore user interaction.
360
+ */
361
+ disabled: boolean;
362
+ /**
363
+ * Whether the user should be unable to activate or deactivate the switch.
364
+ */
365
+ readOnly: boolean;
366
+ /**
367
+ * Whether the user must activate the switch before submitting a form.
368
+ */
369
+ required: boolean;
370
+ }
371
+
17
372
  export declare const SwitchSize: {
18
373
  readonly small: {
19
374
  readonly width: 36;
@@ -29,7 +384,40 @@ export declare const SwitchSize: {
29
384
  };
30
385
  };
31
386
 
387
+ /**
388
+ * The movable part of the switch that indicates whether the switch is on or off.
389
+ * Renders a `<span>`.
390
+ *
391
+ * Documentation: [Base UI Switch](https://base-ui.com/react/components/switch)
392
+ */
393
+ export declare const SwitchThumb: React_2.ForwardRefExoticComponent<Omit<SwitchThumbProps, "ref"> & React_2.RefAttributes<HTMLSpanElement>>;
394
+
395
+ export declare namespace SwitchThumb {
396
+ export type Props = SwitchThumbProps;
397
+ export type State = SwitchThumbState;
398
+ }
399
+
400
+ export declare interface SwitchThumbProps extends BaseUIComponentProps<'span', SwitchThumbState> {}
401
+
402
+ export declare interface SwitchThumbState extends SwitchRootState {}
403
+
404
+ declare const trackPress: "track-press";
405
+
406
+ declare const triggerFocus: "trigger-focus";
407
+
408
+ declare const triggerHover: "trigger-hover";
409
+
410
+ declare const triggerPress: "trigger-press";
411
+
412
+ declare const wheel: "wheel";
413
+
414
+ declare const windowResize: "window-resize";
415
+
416
+ /**
417
+ * Adds a `preventBaseUIHandler` method to all event handlers.
418
+ */
419
+ declare type WithBaseUIEvent<T> = { [K in keyof T]: WithPreventBaseUIHandler<T[K]> };
32
420
 
33
- export * from "@base-ui/react/switch";
421
+ declare type WithPreventBaseUIHandler<T> = T extends ((event: infer E) => any) ? E extends React_2.SyntheticEvent<Element, Event> ? (event: BaseUIEvent<E>) => ReturnType<T> : T : T extends undefined ? undefined : T;
34
422
 
35
423
  export { }
@@ -1,7 +1,209 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Switch } from "@base-ui/react/switch";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
3
2
  import clsx from "clsx";
3
+ import { EMPTY_OBJECT, mergeProps, useMergedRefs, useRenderElement, esm_formatErrorMessage } from "../8272.js";
4
+ import { useLabelableContext, fieldValidityMapping, useFieldRootContext } from "../1477.js";
5
+ import { useFormContext } from "../5085.js";
6
+ import { useBaseUiId } from "../6046.js";
7
+ import { useLabelableId } from "../9048.js";
8
+ import { useControlled } from "../8527.js";
9
+ import { useRegisterFieldControl } from "../4281.js";
10
+ import { useIsoLayoutEffect } from "../6499.js";
11
+ import { useValueChanged } from "../2801.js";
12
+ import { useButton } from "../9189.js";
13
+ import { useAriaLabelledBy } from "../4490.js";
14
+ import { getWindow } from "../3829.js";
15
+ import { visuallyHiddenInput, visuallyHidden } from "../8225.js";
16
+ import { createChangeEventDetails } from "../4768.js";
4
17
  import * as __rspack_external_react from "react";
18
+ const SwitchRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
19
+ if ("production" !== process.env.NODE_ENV) SwitchRootContext.displayName = "SwitchRootContext";
20
+ function useSwitchRootContext() {
21
+ const context = __rspack_external_react.useContext(SwitchRootContext);
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>.' : esm_formatErrorMessage(63));
23
+ return context;
24
+ }
25
+ let SwitchRootDataAttributes_SwitchRootDataAttributes = /*#__PURE__*/ function(SwitchRootDataAttributes) {
26
+ SwitchRootDataAttributes["checked"] = "data-checked";
27
+ SwitchRootDataAttributes["unchecked"] = "data-unchecked";
28
+ SwitchRootDataAttributes["disabled"] = "data-disabled";
29
+ SwitchRootDataAttributes["readonly"] = "data-readonly";
30
+ SwitchRootDataAttributes["required"] = "data-required";
31
+ SwitchRootDataAttributes["valid"] = "data-valid";
32
+ SwitchRootDataAttributes["invalid"] = "data-invalid";
33
+ SwitchRootDataAttributes["touched"] = "data-touched";
34
+ SwitchRootDataAttributes["dirty"] = "data-dirty";
35
+ SwitchRootDataAttributes["filled"] = "data-filled";
36
+ SwitchRootDataAttributes["focused"] = "data-focused";
37
+ return SwitchRootDataAttributes;
38
+ }({});
39
+ const stateAttributesMapping = {
40
+ ...fieldValidityMapping,
41
+ checked (value) {
42
+ if (value) return {
43
+ [SwitchRootDataAttributes_SwitchRootDataAttributes.checked]: ''
44
+ };
45
+ return {
46
+ [SwitchRootDataAttributes_SwitchRootDataAttributes.unchecked]: ''
47
+ };
48
+ }
49
+ };
50
+ const SwitchRoot_SwitchRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
51
+ 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;
52
+ const { clearErrors } = useFormContext();
53
+ const { state: fieldState, setTouched, setDirty, validityData, setFilled, setFocused, shouldValidateOnChange, validationMode, disabled: fieldDisabled, name: fieldName, validation } = useFieldRootContext();
54
+ const { labelId } = useLabelableContext();
55
+ const disabled = fieldDisabled || disabledProp;
56
+ const name = fieldName ?? nameProp;
57
+ const inputRef = __rspack_external_react.useRef(null);
58
+ const handleInputRef = useMergedRefs(inputRef, externalInputRef, validation.inputRef);
59
+ const switchRef = __rspack_external_react.useRef(null);
60
+ const id = useBaseUiId();
61
+ const controlId = useLabelableId({
62
+ id: idProp,
63
+ implicit: false,
64
+ controlRef: switchRef
65
+ });
66
+ const hiddenInputId = nativeButton ? void 0 : controlId;
67
+ const [checked, setCheckedState] = useControlled({
68
+ controlled: checkedProp,
69
+ default: Boolean(defaultChecked),
70
+ name: 'Switch',
71
+ state: 'checked'
72
+ });
73
+ useRegisterFieldControl(switchRef, id, checked);
74
+ useIsoLayoutEffect(()=>{
75
+ if (inputRef.current) setFilled(inputRef.current.checked);
76
+ }, [
77
+ inputRef,
78
+ setFilled
79
+ ]);
80
+ useValueChanged(checked, ()=>{
81
+ clearErrors(name);
82
+ setDirty(checked !== validityData.initialValue);
83
+ setFilled(checked);
84
+ if (shouldValidateOnChange()) validation.commit(checked);
85
+ else validation.commit(checked, true);
86
+ });
87
+ const { getButtonProps, buttonRef } = useButton({
88
+ disabled,
89
+ native: nativeButton
90
+ });
91
+ const ariaLabelledBy = useAriaLabelledBy(ariaLabelledByProp, labelId, inputRef, !nativeButton, hiddenInputId);
92
+ const rootProps = {
93
+ id: nativeButton ? controlId : id,
94
+ role: 'switch',
95
+ 'aria-checked': checked,
96
+ 'aria-readonly': readOnly || void 0,
97
+ 'aria-required': required || void 0,
98
+ 'aria-labelledby': ariaLabelledBy,
99
+ onFocus () {
100
+ if (!disabled) setFocused(true);
101
+ },
102
+ onBlur () {
103
+ const element = inputRef.current;
104
+ if (!element || disabled) return;
105
+ setTouched(true);
106
+ setFocused(false);
107
+ if ('onBlur' === validationMode) validation.commit(element.checked);
108
+ },
109
+ onClick (event) {
110
+ if (readOnly || disabled) return;
111
+ event.preventDefault();
112
+ const input = inputRef.current;
113
+ if (!input) return;
114
+ input.dispatchEvent(new (getWindow(input)).PointerEvent('click', {
115
+ bubbles: true,
116
+ shiftKey: event.shiftKey,
117
+ ctrlKey: event.ctrlKey,
118
+ altKey: event.altKey,
119
+ metaKey: event.metaKey
120
+ }));
121
+ }
122
+ };
123
+ const inputProps = mergeProps({
124
+ checked,
125
+ disabled,
126
+ form,
127
+ id: hiddenInputId,
128
+ name,
129
+ required,
130
+ style: name ? visuallyHiddenInput : visuallyHidden,
131
+ tabIndex: -1,
132
+ type: 'checkbox',
133
+ 'aria-hidden': true,
134
+ ref: handleInputRef,
135
+ onChange (event) {
136
+ if (event.nativeEvent.defaultPrevented) return;
137
+ if (readOnly) return void event.preventDefault();
138
+ const nextChecked = event.currentTarget.checked;
139
+ const eventDetails = createChangeEventDetails("none", event.nativeEvent);
140
+ onCheckedChange?.(nextChecked, eventDetails);
141
+ if (eventDetails.isCanceled) return;
142
+ setCheckedState(nextChecked);
143
+ },
144
+ onFocus () {
145
+ switchRef.current?.focus();
146
+ }
147
+ }, validation.getInputValidationProps, void 0 !== value ? {
148
+ value
149
+ } : EMPTY_OBJECT);
150
+ const state = __rspack_external_react.useMemo(()=>({
151
+ ...fieldState,
152
+ checked,
153
+ disabled,
154
+ readOnly,
155
+ required
156
+ }), [
157
+ fieldState,
158
+ checked,
159
+ disabled,
160
+ readOnly,
161
+ required
162
+ ]);
163
+ const element = useRenderElement('span', componentProps, {
164
+ state,
165
+ ref: [
166
+ forwardedRef,
167
+ switchRef,
168
+ buttonRef
169
+ ],
170
+ props: [
171
+ rootProps,
172
+ validation.getValidationProps,
173
+ elementProps,
174
+ getButtonProps
175
+ ],
176
+ stateAttributesMapping: stateAttributesMapping
177
+ });
178
+ return /*#__PURE__*/ jsxs(SwitchRootContext.Provider, {
179
+ value: state,
180
+ children: [
181
+ element,
182
+ !checked && name && void 0 !== uncheckedValue && /*#__PURE__*/ jsx("input", {
183
+ type: "hidden",
184
+ form: form,
185
+ name: name,
186
+ value: uncheckedValue
187
+ }),
188
+ /*#__PURE__*/ jsx("input", {
189
+ ...inputProps,
190
+ suppressHydrationWarning: true
191
+ })
192
+ ]
193
+ });
194
+ });
195
+ if ("production" !== process.env.NODE_ENV) SwitchRoot_SwitchRoot.displayName = "SwitchRoot";
196
+ const SwitchThumb_SwitchThumb = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
197
+ const { render, className, style, ...elementProps } = componentProps;
198
+ const state = useSwitchRootContext();
199
+ return useRenderElement('span', componentProps, {
200
+ state,
201
+ ref: forwardedRef,
202
+ stateAttributesMapping: stateAttributesMapping,
203
+ props: elementProps
204
+ });
205
+ });
206
+ if ("production" !== process.env.NODE_ENV) SwitchThumb_SwitchThumb.displayName = "SwitchThumb";
5
207
  const Switch_module = {
6
208
  root: "root-jFySXM",
7
209
  thumb: "thumb-aDkgmk"
@@ -20,7 +222,7 @@ const SwitchSize = {
20
222
  height: 32
21
223
  }
22
224
  };
23
- const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, width = SwitchSize.medium.width, height = SwitchSize.medium.height, style, ...props }, ref)=>/*#__PURE__*/ jsx(Switch.Root, {
225
+ const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, width = SwitchSize.medium.width, height = SwitchSize.medium.height, style, ...props }, ref)=>/*#__PURE__*/ jsx(SwitchRoot_SwitchRoot, {
24
226
  ref: ref,
25
227
  className: clsx(Switch_module.root, className),
26
228
  style: {
@@ -31,13 +233,13 @@ const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, widt
31
233
  },
32
234
  ...props
33
235
  }));
34
- const Thumb = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Switch.Thumb, {
236
+ const Thumb = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SwitchThumb_SwitchThumb, {
35
237
  ref: ref,
36
238
  className: clsx(Switch_module.thumb, className),
37
239
  ...props
38
240
  }));
39
- const Switch_Switch = {
241
+ const Switch = {
40
242
  Root: Root,
41
243
  Thumb: Thumb
42
244
  };
43
- export { SwitchSize, Switch_Switch as Switch };
245
+ export { Switch, SwitchSize };