@wix/site-ui 1.30.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.
- 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/Toggle/index.d.ts
CHANGED
|
@@ -1,11 +1,314 @@
|
|
|
1
1
|
import * as React_2 from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
declare type BaseUIChangeEventDetail<Reason extends string, CustomProperties extends object> = {
|
|
4
|
+
/**
|
|
5
|
+
* The reason for the event.
|
|
6
|
+
*/
|
|
7
|
+
reason: Reason;
|
|
8
|
+
/**
|
|
9
|
+
* The native event associated with the custom event.
|
|
10
|
+
*/
|
|
11
|
+
event: ReasonToEvent<Reason>;
|
|
12
|
+
/**
|
|
13
|
+
* Cancels Base UI from handling the event.
|
|
14
|
+
*/
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Allows the event to propagate in cases where Base UI will stop the propagation.
|
|
18
|
+
*/
|
|
19
|
+
allowPropagation: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether the event has been canceled.
|
|
22
|
+
*/
|
|
23
|
+
isCanceled: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates whether the event is allowed to propagate.
|
|
26
|
+
*/
|
|
27
|
+
isPropagationAllowed: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The element that triggered the event, if applicable.
|
|
30
|
+
*/
|
|
31
|
+
trigger: Element | undefined;
|
|
32
|
+
} & CustomProperties;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Details of custom change events emitted by Base UI components.
|
|
36
|
+
*/
|
|
37
|
+
declare type BaseUIChangeEventDetails<Reason extends string, CustomProperties extends object = {}> = Reason extends string ? BaseUIChangeEventDetail<Reason, CustomProperties> & {} : never;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Props shared by all Base UI components.
|
|
41
|
+
* Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering).
|
|
42
|
+
*/
|
|
43
|
+
declare type BaseUIComponentProps<ElementType extends React_2.ElementType, State, RenderFunctionProps = HTMLProps> = Omit<WithBaseUIEvent<React_2.ComponentPropsWithRef<ElementType>>, 'className' | 'color' | 'defaultValue' | 'defaultChecked' | 'style'> & {
|
|
44
|
+
/**
|
|
45
|
+
* CSS class applied to the element, or a function that
|
|
46
|
+
* returns a class based on the component's state.
|
|
47
|
+
*/
|
|
48
|
+
className?: string | ((state: State) => string | undefined) | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Allows you to replace the component's HTML element
|
|
51
|
+
* with a different tag, or compose it with another component.
|
|
52
|
+
*
|
|
53
|
+
* Accepts a `ReactElement` or a function that returns the element to render.
|
|
54
|
+
*/
|
|
55
|
+
render?: React_2.ReactElement | ComponentRenderFn<RenderFunctionProps, State> | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Style applied to the element, or a function that
|
|
58
|
+
* returns a style object based on the component's state.
|
|
59
|
+
*/
|
|
60
|
+
style?: React_2.CSSProperties | ((state: State) => React_2.CSSProperties | undefined) | undefined;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E & {
|
|
64
|
+
preventBaseUIHandler: () => void;
|
|
65
|
+
readonly baseUIHandlerPrevented?: boolean | undefined;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
declare const cancelOpen: "cancel-open";
|
|
69
|
+
|
|
70
|
+
declare const chipRemovePress: "chip-remove-press";
|
|
71
|
+
|
|
72
|
+
declare const clearPress: "clear-press";
|
|
73
|
+
|
|
74
|
+
declare const closePress: "close-press";
|
|
75
|
+
|
|
76
|
+
declare const closeWatcher: "close-watcher";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 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.
|
|
80
|
+
*
|
|
81
|
+
* @template Props Props to be spread on the rendered element.
|
|
82
|
+
* @template State Component's internal state.
|
|
83
|
+
*/
|
|
84
|
+
declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
|
|
85
|
+
|
|
86
|
+
declare const decrementPress: "decrement-press";
|
|
87
|
+
|
|
88
|
+
declare const disabled: "disabled";
|
|
89
|
+
|
|
90
|
+
declare const drag: "drag";
|
|
91
|
+
|
|
92
|
+
declare const escapeKey: "escape-key";
|
|
93
|
+
|
|
94
|
+
declare const focusOut: "focus-out";
|
|
95
|
+
|
|
96
|
+
declare type HTMLProps<T = any> = React_2.HTMLAttributes<T> & {
|
|
97
|
+
ref?: React_2.Ref<T> | undefined;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
declare const imperativeAction: "imperative-action";
|
|
101
|
+
|
|
102
|
+
declare const incrementPress: "increment-press";
|
|
103
|
+
|
|
104
|
+
declare const initial: "initial";
|
|
105
|
+
|
|
106
|
+
declare const inputBlur: "input-blur";
|
|
107
|
+
|
|
108
|
+
declare const inputChange: "input-change";
|
|
109
|
+
|
|
110
|
+
declare const inputClear: "input-clear";
|
|
111
|
+
|
|
112
|
+
declare const inputPaste: "input-paste";
|
|
113
|
+
|
|
114
|
+
declare const inputPress: "input-press";
|
|
115
|
+
|
|
116
|
+
declare const itemPress: "item-press";
|
|
117
|
+
|
|
118
|
+
declare const keyboard: "keyboard";
|
|
119
|
+
|
|
120
|
+
declare const linkPress: "link-press";
|
|
121
|
+
|
|
122
|
+
declare const listNavigation: "list-navigation";
|
|
123
|
+
|
|
124
|
+
declare const missing: "missing";
|
|
125
|
+
|
|
126
|
+
declare interface NativeButtonProps {
|
|
127
|
+
/**
|
|
128
|
+
* Whether the component renders a native `<button>` element when replacing it
|
|
129
|
+
* via the `render` prop.
|
|
130
|
+
* Set to `false` if the rendered element is not a button (for example, `<div>`).
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
133
|
+
nativeButton?: boolean | undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare const none: "none";
|
|
137
|
+
|
|
138
|
+
declare const outsidePress: "outside-press";
|
|
139
|
+
|
|
140
|
+
declare const pointer: "pointer";
|
|
141
|
+
|
|
142
|
+
declare namespace REASONS {
|
|
143
|
+
export {
|
|
144
|
+
none,
|
|
145
|
+
triggerPress,
|
|
146
|
+
triggerHover,
|
|
147
|
+
triggerFocus,
|
|
148
|
+
outsidePress,
|
|
149
|
+
itemPress,
|
|
150
|
+
closePress,
|
|
151
|
+
linkPress,
|
|
152
|
+
clearPress,
|
|
153
|
+
chipRemovePress,
|
|
154
|
+
trackPress,
|
|
155
|
+
incrementPress,
|
|
156
|
+
decrementPress,
|
|
157
|
+
inputChange,
|
|
158
|
+
inputClear,
|
|
159
|
+
inputBlur,
|
|
160
|
+
inputPaste,
|
|
161
|
+
inputPress,
|
|
162
|
+
focusOut,
|
|
163
|
+
escapeKey,
|
|
164
|
+
closeWatcher,
|
|
165
|
+
listNavigation,
|
|
166
|
+
keyboard,
|
|
167
|
+
pointer,
|
|
168
|
+
drag,
|
|
169
|
+
wheel,
|
|
170
|
+
scrub,
|
|
171
|
+
cancelOpen,
|
|
172
|
+
siblingOpen,
|
|
173
|
+
disabled,
|
|
174
|
+
missing,
|
|
175
|
+
initial,
|
|
176
|
+
imperativeAction,
|
|
177
|
+
swipe,
|
|
178
|
+
windowResize
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Maps a change `reason` string to the corresponding native event type.
|
|
184
|
+
*/
|
|
185
|
+
declare type ReasonToEvent<Reason extends string> = Reason extends keyof ReasonToEventMap ? ReasonToEventMap[Reason] : Event;
|
|
186
|
+
|
|
187
|
+
declare interface ReasonToEventMap {
|
|
188
|
+
[REASONS.none]: Event;
|
|
189
|
+
[REASONS.triggerPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
|
|
190
|
+
[REASONS.triggerHover]: MouseEvent;
|
|
191
|
+
[REASONS.triggerFocus]: FocusEvent;
|
|
192
|
+
[REASONS.outsidePress]: MouseEvent | PointerEvent | TouchEvent;
|
|
193
|
+
[REASONS.itemPress]: MouseEvent | KeyboardEvent | PointerEvent;
|
|
194
|
+
[REASONS.closePress]: MouseEvent | KeyboardEvent | PointerEvent;
|
|
195
|
+
[REASONS.linkPress]: MouseEvent | PointerEvent;
|
|
196
|
+
[REASONS.clearPress]: PointerEvent | MouseEvent | KeyboardEvent;
|
|
197
|
+
[REASONS.chipRemovePress]: PointerEvent | MouseEvent | KeyboardEvent;
|
|
198
|
+
[REASONS.trackPress]: PointerEvent | MouseEvent | TouchEvent;
|
|
199
|
+
[REASONS.incrementPress]: PointerEvent | MouseEvent | TouchEvent;
|
|
200
|
+
[REASONS.decrementPress]: PointerEvent | MouseEvent | TouchEvent;
|
|
201
|
+
[REASONS.inputChange]: InputEvent | Event;
|
|
202
|
+
[REASONS.inputClear]: InputEvent | FocusEvent | Event;
|
|
203
|
+
[REASONS.inputBlur]: FocusEvent;
|
|
204
|
+
[REASONS.inputPaste]: ClipboardEvent;
|
|
205
|
+
[REASONS.inputPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
|
|
206
|
+
[REASONS.focusOut]: FocusEvent | KeyboardEvent;
|
|
207
|
+
[REASONS.escapeKey]: KeyboardEvent;
|
|
208
|
+
[REASONS.closeWatcher]: Event;
|
|
209
|
+
[REASONS.listNavigation]: KeyboardEvent;
|
|
210
|
+
[REASONS.keyboard]: KeyboardEvent;
|
|
211
|
+
[REASONS.pointer]: PointerEvent;
|
|
212
|
+
[REASONS.drag]: PointerEvent | TouchEvent;
|
|
213
|
+
[REASONS.swipe]: PointerEvent | TouchEvent;
|
|
214
|
+
[REASONS.wheel]: WheelEvent;
|
|
215
|
+
[REASONS.scrub]: PointerEvent;
|
|
216
|
+
[REASONS.cancelOpen]: MouseEvent;
|
|
217
|
+
[REASONS.siblingOpen]: Event;
|
|
218
|
+
[REASONS.disabled]: Event;
|
|
219
|
+
[REASONS.missing]: Event;
|
|
220
|
+
[REASONS.initial]: Event;
|
|
221
|
+
[REASONS.imperativeAction]: Event;
|
|
222
|
+
[REASONS.windowResize]: UIEvent;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
declare const scrub: "scrub";
|
|
226
|
+
|
|
227
|
+
declare const siblingOpen: "sibling-open";
|
|
228
|
+
|
|
229
|
+
declare const swipe: "swipe";
|
|
3
230
|
|
|
4
231
|
export declare const Toggle: React_2.ForwardRefExoticComponent<Omit<Omit<Toggle_2.Props<string> & React_2.RefAttributes<HTMLButtonElement>, "ref">, "className"> & {
|
|
5
232
|
className?: string | undefined;
|
|
6
233
|
} & React_2.RefAttributes<HTMLButtonElement>>;
|
|
7
234
|
|
|
235
|
+
/**
|
|
236
|
+
* A two-state button that can be on or off.
|
|
237
|
+
* Renders a `<button>` element.
|
|
238
|
+
*
|
|
239
|
+
* Documentation: [Base UI Toggle](https://base-ui.com/react/components/toggle)
|
|
240
|
+
*/
|
|
241
|
+
declare const Toggle_2: {
|
|
242
|
+
<Value extends string>(props: Toggle_2.Props<Value> & React_2.RefAttributes<HTMLButtonElement>): React_2.JSX.Element;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
declare namespace Toggle_2 {
|
|
246
|
+
type State = ToggleState;
|
|
247
|
+
type Props<TValue extends string = string> = ToggleProps<TValue>;
|
|
248
|
+
type ChangeEventReason = ToggleChangeEventReason;
|
|
249
|
+
type ChangeEventDetails = ToggleChangeEventDetails;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare type ToggleChangeEventDetails = BaseUIChangeEventDetails<Toggle_2.ChangeEventReason>;
|
|
253
|
+
|
|
254
|
+
export declare type ToggleChangeEventReason = typeof REASONS.none;
|
|
255
|
+
|
|
256
|
+
export declare interface ToggleProps<Value extends string> extends NativeButtonProps, BaseUIComponentProps<'button', ToggleState> {
|
|
257
|
+
/**
|
|
258
|
+
* Whether the toggle button is currently pressed.
|
|
259
|
+
* This is the controlled counterpart of `defaultPressed`.
|
|
260
|
+
*/
|
|
261
|
+
pressed?: boolean | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the toggle button is currently pressed.
|
|
264
|
+
* This is the uncontrolled counterpart of `pressed`.
|
|
265
|
+
* @default false
|
|
266
|
+
*/
|
|
267
|
+
defaultPressed?: boolean | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* Whether the component should ignore user interaction.
|
|
270
|
+
* @default false
|
|
271
|
+
*/
|
|
272
|
+
disabled?: boolean | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* Callback fired when the pressed state is changed.
|
|
275
|
+
*/
|
|
276
|
+
onPressedChange?: ((pressed: boolean, eventDetails: Toggle_2.ChangeEventDetails) => void) | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* A unique string that identifies the toggle when used
|
|
279
|
+
* inside a toggle group.
|
|
280
|
+
*/
|
|
281
|
+
value?: Value | undefined;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export declare interface ToggleState {
|
|
285
|
+
/**
|
|
286
|
+
* Whether the toggle is currently pressed.
|
|
287
|
+
*/
|
|
288
|
+
pressed: boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Whether the toggle should ignore user interaction.
|
|
291
|
+
*/
|
|
292
|
+
disabled: boolean;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare const trackPress: "track-press";
|
|
296
|
+
|
|
297
|
+
declare const triggerFocus: "trigger-focus";
|
|
298
|
+
|
|
299
|
+
declare const triggerHover: "trigger-hover";
|
|
300
|
+
|
|
301
|
+
declare const triggerPress: "trigger-press";
|
|
302
|
+
|
|
303
|
+
declare const wheel: "wheel";
|
|
304
|
+
|
|
305
|
+
declare const windowResize: "window-resize";
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Adds a `preventBaseUIHandler` method to all event handlers.
|
|
309
|
+
*/
|
|
310
|
+
declare type WithBaseUIEvent<T> = { [K in keyof T]: WithPreventBaseUIHandler<T[K]> };
|
|
8
311
|
|
|
9
|
-
|
|
312
|
+
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;
|
|
10
313
|
|
|
11
314
|
export { }
|
package/dist/Toggle/index.js
CHANGED
|
@@ -1,15 +1,88 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Toggle } from "@base-ui/react/toggle";
|
|
3
2
|
import clsx from "clsx";
|
|
3
|
+
import { useBaseUiId } from "../6046.js";
|
|
4
|
+
import { useToggleGroupContext } from "../7725.js";
|
|
5
|
+
import { useIsoLayoutEffect } from "../6499.js";
|
|
6
|
+
import { error } from "../4026.js";
|
|
7
|
+
import { useControlled } from "../8527.js";
|
|
8
|
+
import { useButton } from "../9189.js";
|
|
9
|
+
import { createChangeEventDetails } from "../4768.js";
|
|
10
|
+
import { useRenderElement } from "../8272.js";
|
|
11
|
+
import { CompositeItem } from "../951.js";
|
|
4
12
|
import * as __rspack_external_react from "react";
|
|
13
|
+
const Toggle_Toggle = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
14
|
+
const { className, defaultPressed: defaultPressedProp = false, disabled: disabledProp = false, form, onPressedChange, pressed: pressedProp, render, type, value: valueProp, nativeButton = true, style, ...elementProps } = componentProps;
|
|
15
|
+
const value = useBaseUiId(valueProp || void 0);
|
|
16
|
+
const groupContext = useToggleGroupContext();
|
|
17
|
+
const groupValue = groupContext?.value ?? [];
|
|
18
|
+
const defaultPressed = groupContext ? void 0 : defaultPressedProp;
|
|
19
|
+
const disabled = (disabledProp || groupContext?.disabled) ?? false;
|
|
20
|
+
if ('production' !== process.env.NODE_ENV) useIsoLayoutEffect(()=>{
|
|
21
|
+
if (groupContext && void 0 === valueProp && groupContext.isValueInitialized) error('A `<Toggle>` component rendered in a `<ToggleGroup>` has no explicit `value` prop.', 'This will cause issues between the Toggle Group and Toggle values.', 'Provide the `<Toggle>` with a `value` prop matching the `<ToggleGroup>` values prop type.');
|
|
22
|
+
}, [
|
|
23
|
+
groupContext,
|
|
24
|
+
valueProp,
|
|
25
|
+
groupContext?.isValueInitialized
|
|
26
|
+
]);
|
|
27
|
+
const [pressed, setPressedState] = useControlled({
|
|
28
|
+
controlled: groupContext ? void 0 !== value && groupValue.indexOf(value) > -1 : pressedProp,
|
|
29
|
+
default: defaultPressed,
|
|
30
|
+
name: 'Toggle',
|
|
31
|
+
state: 'pressed'
|
|
32
|
+
});
|
|
33
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
34
|
+
disabled,
|
|
35
|
+
native: nativeButton
|
|
36
|
+
});
|
|
37
|
+
const state = {
|
|
38
|
+
disabled,
|
|
39
|
+
pressed
|
|
40
|
+
};
|
|
41
|
+
const refs = [
|
|
42
|
+
buttonRef,
|
|
43
|
+
forwardedRef
|
|
44
|
+
];
|
|
45
|
+
const props = [
|
|
46
|
+
{
|
|
47
|
+
'aria-pressed': pressed,
|
|
48
|
+
onClick (event) {
|
|
49
|
+
const nextPressed = !pressed;
|
|
50
|
+
const details = createChangeEventDetails("none", event.nativeEvent);
|
|
51
|
+
if (value) groupContext?.setGroupValue?.(value, nextPressed, details);
|
|
52
|
+
onPressedChange?.(nextPressed, details);
|
|
53
|
+
if (details.isCanceled) return;
|
|
54
|
+
setPressedState(nextPressed);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
elementProps,
|
|
58
|
+
getButtonProps
|
|
59
|
+
];
|
|
60
|
+
const element = useRenderElement('button', componentProps, {
|
|
61
|
+
enabled: !groupContext,
|
|
62
|
+
state,
|
|
63
|
+
ref: refs,
|
|
64
|
+
props
|
|
65
|
+
});
|
|
66
|
+
if (groupContext) return /*#__PURE__*/ jsx(CompositeItem, {
|
|
67
|
+
tag: "button",
|
|
68
|
+
render: render,
|
|
69
|
+
className: className,
|
|
70
|
+
style: style,
|
|
71
|
+
state: state,
|
|
72
|
+
refs: refs,
|
|
73
|
+
props: props
|
|
74
|
+
});
|
|
75
|
+
return element;
|
|
76
|
+
});
|
|
77
|
+
if ("production" !== process.env.NODE_ENV) Toggle_Toggle.displayName = "Toggle";
|
|
5
78
|
const Toggle_module = {
|
|
6
79
|
root: "root-b5XZrV",
|
|
7
80
|
"toggle-pop-in": "toggle-pop-in-YeDB_9",
|
|
8
81
|
togglePopIn: "toggle-pop-in-YeDB_9"
|
|
9
82
|
};
|
|
10
|
-
const
|
|
83
|
+
const Toggle_Toggle_Toggle = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Toggle_Toggle, {
|
|
11
84
|
ref: ref,
|
|
12
85
|
className: clsx(Toggle_module.root, className),
|
|
13
86
|
...props
|
|
14
87
|
}));
|
|
15
|
-
export {
|
|
88
|
+
export { Toggle_Toggle_Toggle as Toggle };
|