@wix/site-ui 1.30.0 → 1.32.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.
- package/dist/1268.js +99 -0
- package/dist/1279.js +7 -0
- package/dist/1457.js +10 -0
- package/dist/1477.js +106 -0
- package/dist/1500.js +111 -0
- package/dist/167.js +6 -0
- package/dist/2274.js +34 -0
- package/dist/2287.js +17 -0
- package/dist/2418.js +31 -0
- package/dist/2801.js +20 -0
- package/dist/285.js +86 -0
- package/dist/2861.js +6 -0
- package/dist/3020.js +7 -0
- package/dist/3021.js +72 -0
- package/dist/3056.js +229 -0
- package/dist/3140.js +4 -0
- package/dist/3248.js +307 -0
- package/dist/3296.js +4 -0
- package/dist/3319.js +400 -0
- package/dist/3395.js +4 -0
- package/dist/3485.js +854 -0
- package/dist/353.js +14 -0
- package/dist/3670.js +418 -0
- package/dist/3829.js +113 -0
- package/dist/4026.js +12 -0
- package/dist/4143.js +46 -0
- package/dist/42.js +32 -0
- package/dist/4281.js +30 -0
- package/dist/4346.js +2 -0
- package/dist/4388.js +418 -0
- package/dist/4490.js +32 -0
- package/dist/4495.js +9 -0
- package/dist/4549.js +24 -0
- package/dist/4586.js +41 -0
- package/dist/4586.js.LICENSE.txt +19 -0
- package/dist/4707.js +19 -0
- package/dist/4723.js +7 -0
- package/dist/4745.js +7 -0
- package/dist/4768.js +35 -0
- package/dist/4922.js +15 -0
- package/dist/5036.js +17 -0
- package/dist/5085.js +20 -0
- package/dist/5299.js +597 -0
- package/dist/5659.js +4 -0
- package/dist/5778.js +10 -0
- package/dist/5864.js +86 -0
- package/dist/5992.js +913 -0
- package/dist/5992.js.LICENSE.txt +19 -0
- package/dist/6003.js +10 -0
- package/dist/6046.js +29 -0
- package/dist/6089.js +2355 -0
- package/dist/6107.js +10 -0
- package/dist/6247.js +20 -0
- package/dist/6270.js +487 -0
- package/dist/6329.js +32 -0
- package/dist/6330.js +30 -0
- package/dist/6499.js +7 -0
- package/dist/6535.js +71 -0
- package/dist/6588.js +382 -0
- package/dist/6706.js +16 -0
- package/dist/6825.js +7 -0
- package/dist/6882.js +1562 -0
- package/dist/6914.js +30 -0
- package/dist/7021.js +13 -0
- package/dist/7366.js +83 -0
- package/dist/7373.js +25 -0
- package/dist/7541.js +25 -0
- package/dist/7564.js +10 -0
- package/dist/7642.js +20 -0
- package/dist/7725.js +10 -0
- package/dist/7871.js +38 -0
- package/dist/8052.js +352 -0
- package/dist/8106.js +238 -0
- package/dist/8171.js +346 -0
- package/dist/8225.js +21 -0
- package/dist/8272.js +333 -0
- package/dist/8527.js +58 -0
- package/dist/8724.js +10 -0
- package/dist/8750.js +1920 -0
- package/dist/8758.js +43 -0
- package/dist/880.js +149 -0
- package/dist/8935.js +8 -0
- package/dist/8960.js +22 -0
- package/dist/8971.js +40 -0
- package/dist/8979.js +10 -0
- package/dist/8996.js +71 -0
- package/dist/904.js +121 -0
- package/dist/9048.js +52 -0
- package/dist/9087.js +256 -0
- package/dist/9189.js +158 -0
- package/dist/9255.js +136 -0
- package/dist/9352.js +148 -0
- package/dist/951.js +22 -0
- package/dist/9635.js +22 -0
- package/dist/9829.js +4 -0
- package/dist/9863.js +8 -0
- package/dist/Accordion/index.d.ts +569 -12
- package/dist/Accordion/index.js +423 -8
- package/dist/AlertDialog/index.d.ts +1417 -18
- package/dist/AlertDialog/index.js +34 -14
- package/dist/Autocomplete/index.d.ts +1861 -38
- package/dist/Autocomplete/index.js +98 -24
- package/dist/Avatar/index.d.ts +129 -7
- package/dist/Avatar/index.js +149 -6
- package/dist/Breadcrumbs/index.d.ts +960 -7
- package/dist/Breadcrumbs/index.js +5 -5
- package/dist/Button/index.d.ts +88 -6
- package/dist/Button/index.js +27 -3
- package/dist/Checkbox/index.d.ts +425 -5
- package/dist/Checkbox/index.js +45 -5
- package/dist/CheckboxGroup/index.d.ts +318 -3
- package/dist/CheckboxGroup/index.js +166 -3
- package/dist/Collapsible/index.d.ts +377 -7
- package/dist/Collapsible/index.js +160 -6
- package/dist/Combobox/index.d.ts +1984 -48
- package/dist/Combobox/index.js +352 -29
- package/dist/ContextMenu/index.d.ts +2340 -36
- package/dist/ContextMenu/index.js +197 -22
- package/dist/Dialog/index.d.ts +1355 -18
- package/dist/Dialog/index.js +16 -14
- package/dist/Drawer/index.d.ts +1653 -18
- package/dist/Drawer/index.js +2797 -20
- package/dist/Field/index.d.ts +655 -15
- package/dist/Field/index.js +677 -10
- package/dist/Fieldset/index.d.ts +94 -5
- package/dist/Fieldset/index.js +68 -5
- package/dist/Form/index.d.ts +331 -2
- package/dist/Form/index.js +106 -3
- package/dist/Input/index.d.ts +692 -3
- package/dist/Input/index.js +10 -3
- package/dist/Menu/index.d.ts +2301 -36
- package/dist/Menu/index.js +365 -26
- package/dist/Menubar/index.d.ts +2301 -3
- package/dist/Menubar/index.js +105 -3
- package/dist/Meter/index.d.ts +175 -11
- package/dist/Meter/index.js +129 -9
- package/dist/NavigationMenu/index.d.ts +978 -28
- package/dist/NavigationMenu/index.js +1034 -17
- package/dist/NumberField/index.d.ts +612 -15
- package/dist/NumberField/index.js +1409 -11
- package/dist/Popover/index.d.ts +1655 -20
- package/dist/Popover/index.js +792 -17
- package/dist/PreviewCard/index.d.ts +1523 -14
- package/dist/PreviewCard/index.js +679 -14
- package/dist/Progress/index.d.ts +183 -11
- package/dist/Progress/index.js +181 -9
- package/dist/Radio/index.d.ts +185 -6
- package/dist/Radio/index.js +253 -6
- package/dist/RadioGroup/index.d.ts +341 -2
- package/dist/RadioGroup/index.js +154 -3
- package/dist/ScrollArea/index.d.ts +265 -13
- package/dist/ScrollArea/index.js +892 -10
- package/dist/Select/index.d.ts +1493 -38
- package/dist/Select/index.js +1824 -23
- package/dist/Separator/index.d.ts +80 -6
- package/dist/Separator/index.js +3 -3
- package/dist/Slider/index.d.ts +678 -16
- package/dist/Slider/index.js +1199 -11
- package/dist/Switch/index.d.ts +393 -5
- package/dist/Switch/index.js +208 -6
- package/dist/Tabs/index.d.ts +523 -12
- package/dist/Tabs/index.js +685 -9
- package/dist/Toggle/index.d.ts +305 -2
- package/dist/Toggle/index.js +76 -3
- package/dist/ToggleGroup/index.d.ts +316 -2
- package/dist/ToggleGroup/index.js +102 -3
- package/dist/Toolbar/index.d.ts +282 -13
- package/dist/Toolbar/index.js +230 -9
- package/dist/Tooltip/index.d.ts +1572 -14
- package/dist/Tooltip/index.js +965 -14
- package/dist/index.d.ts +12749 -652
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/Switch/index.d.ts
CHANGED
|
@@ -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<
|
|
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<
|
|
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
|
-
|
|
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 { }
|
package/dist/Switch/index.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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
|
|
241
|
+
const Switch = {
|
|
40
242
|
Root: Root,
|
|
41
243
|
Thumb: Thumb
|
|
42
244
|
};
|
|
43
|
-
export {
|
|
245
|
+
export { Switch, SwitchSize };
|