@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/8272.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import * as __rspack_external_react from "react";
|
|
2
|
+
const UNINITIALIZED = {};
|
|
3
|
+
function useRefWithInit(init, initArg) {
|
|
4
|
+
const ref = __rspack_external_react.useRef(UNINITIALIZED);
|
|
5
|
+
if (ref.current === UNINITIALIZED) ref.current = init(initArg);
|
|
6
|
+
return ref;
|
|
7
|
+
}
|
|
8
|
+
function useMergedRefs(a, b, c, d) {
|
|
9
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
10
|
+
if (didChange(forkRef, a, b, c, d)) update(forkRef, [
|
|
11
|
+
a,
|
|
12
|
+
b,
|
|
13
|
+
c,
|
|
14
|
+
d
|
|
15
|
+
]);
|
|
16
|
+
return forkRef.callback;
|
|
17
|
+
}
|
|
18
|
+
function useMergedRefsN(refs) {
|
|
19
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
20
|
+
if (didChangeN(forkRef, refs)) update(forkRef, refs);
|
|
21
|
+
return forkRef.callback;
|
|
22
|
+
}
|
|
23
|
+
function createForkRef() {
|
|
24
|
+
return {
|
|
25
|
+
callback: null,
|
|
26
|
+
cleanup: null,
|
|
27
|
+
refs: []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function didChange(forkRef, a, b, c, d) {
|
|
31
|
+
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
|
|
32
|
+
}
|
|
33
|
+
function didChangeN(forkRef, newRefs) {
|
|
34
|
+
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index)=>ref !== newRefs[index]);
|
|
35
|
+
}
|
|
36
|
+
function update(forkRef, refs) {
|
|
37
|
+
forkRef.refs = refs;
|
|
38
|
+
if (refs.every((ref)=>null == ref)) {
|
|
39
|
+
forkRef.callback = null;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
forkRef.callback = (instance)=>{
|
|
43
|
+
if (forkRef.cleanup) {
|
|
44
|
+
forkRef.cleanup();
|
|
45
|
+
forkRef.cleanup = null;
|
|
46
|
+
}
|
|
47
|
+
if (null != instance) {
|
|
48
|
+
const cleanupCallbacks = Array(refs.length).fill(null);
|
|
49
|
+
for(let i = 0; i < refs.length; i += 1){
|
|
50
|
+
const ref = refs[i];
|
|
51
|
+
if (null != ref) switch(typeof ref){
|
|
52
|
+
case 'function':
|
|
53
|
+
{
|
|
54
|
+
const refCleanup = ref(instance);
|
|
55
|
+
if ('function' == typeof refCleanup) cleanupCallbacks[i] = refCleanup;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'object':
|
|
59
|
+
ref.current = instance;
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
forkRef.cleanup = ()=>{
|
|
65
|
+
for(let i = 0; i < refs.length; i += 1){
|
|
66
|
+
const ref = refs[i];
|
|
67
|
+
if (null != ref) switch(typeof ref){
|
|
68
|
+
case 'function':
|
|
69
|
+
{
|
|
70
|
+
const cleanupCallback = cleanupCallbacks[i];
|
|
71
|
+
if ('function' == typeof cleanupCallback) cleanupCallback();
|
|
72
|
+
else ref(null);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 'object':
|
|
76
|
+
ref.current = null;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function NOOP() {}
|
|
86
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
87
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
88
|
+
function createFormatErrorMessage(baseUrl, prefix) {
|
|
89
|
+
return function(code, ...args) {
|
|
90
|
+
const url = new URL(baseUrl);
|
|
91
|
+
url.searchParams.set('code', code.toString());
|
|
92
|
+
args.forEach((arg)=>url.searchParams.append('args[]', arg));
|
|
93
|
+
return `${prefix} error #${code}; visit ${url} for the full message.`;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const formatErrorMessage_formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
|
|
97
|
+
const esm_formatErrorMessage = formatErrorMessage_formatErrorMessage;
|
|
98
|
+
const majorVersion = parseInt(__rspack_external_react.version, 10);
|
|
99
|
+
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
100
|
+
return majorVersion >= reactVersionToCheck;
|
|
101
|
+
}
|
|
102
|
+
function getReactElementRef(element) {
|
|
103
|
+
if (!/*#__PURE__*/ __rspack_external_react.isValidElement(element)) return null;
|
|
104
|
+
const reactElement = element;
|
|
105
|
+
const propsWithRef = reactElement.props;
|
|
106
|
+
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
|
|
107
|
+
}
|
|
108
|
+
function mergeObjects(a, b) {
|
|
109
|
+
if (a && !b) return a;
|
|
110
|
+
if (!a && b) return b;
|
|
111
|
+
if (a || b) return {
|
|
112
|
+
...a,
|
|
113
|
+
...b
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
let set;
|
|
117
|
+
if ('production' !== process.env.NODE_ENV) set = new Set();
|
|
118
|
+
function warn(...messages) {
|
|
119
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
120
|
+
const messageKey = messages.join(' ');
|
|
121
|
+
if (!set.has(messageKey)) {
|
|
122
|
+
set.add(messageKey);
|
|
123
|
+
console.warn(`Base UI: ${messageKey}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getStateAttributesProps(state, customMapping) {
|
|
128
|
+
const props = {};
|
|
129
|
+
for(const key in state){
|
|
130
|
+
const value = state[key];
|
|
131
|
+
if (customMapping?.hasOwnProperty(key)) {
|
|
132
|
+
const customProps = customMapping[key](value);
|
|
133
|
+
if (null != customProps) Object.assign(props, customProps);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (true === value) props[`data-${key.toLowerCase()}`] = '';
|
|
137
|
+
else if (value) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
138
|
+
}
|
|
139
|
+
return props;
|
|
140
|
+
}
|
|
141
|
+
function resolveClassName(className, state) {
|
|
142
|
+
return 'function' == typeof className ? className(state) : className;
|
|
143
|
+
}
|
|
144
|
+
function resolveStyle(style, state) {
|
|
145
|
+
return 'function' == typeof style ? style(state) : style;
|
|
146
|
+
}
|
|
147
|
+
const EMPTY_PROPS = {};
|
|
148
|
+
function mergeProps(a, b, c, d, e) {
|
|
149
|
+
if (!c && !d && !e && !a) return createInitialMergedProps(b);
|
|
150
|
+
let merged = createInitialMergedProps(a);
|
|
151
|
+
if (b) merged = mergeInto(merged, b);
|
|
152
|
+
if (c) merged = mergeInto(merged, c);
|
|
153
|
+
if (d) merged = mergeInto(merged, d);
|
|
154
|
+
if (e) merged = mergeInto(merged, e);
|
|
155
|
+
return merged;
|
|
156
|
+
}
|
|
157
|
+
function mergePropsN(props) {
|
|
158
|
+
if (0 === props.length) return EMPTY_PROPS;
|
|
159
|
+
if (1 === props.length) return createInitialMergedProps(props[0]);
|
|
160
|
+
let merged = createInitialMergedProps(props[0]);
|
|
161
|
+
for(let i = 1; i < props.length; i += 1)merged = mergeInto(merged, props[i]);
|
|
162
|
+
return merged;
|
|
163
|
+
}
|
|
164
|
+
function createInitialMergedProps(inputProps) {
|
|
165
|
+
if (isPropsGetter(inputProps)) return {
|
|
166
|
+
...resolvePropsGetter(inputProps, EMPTY_PROPS)
|
|
167
|
+
};
|
|
168
|
+
return copyInitialProps(inputProps);
|
|
169
|
+
}
|
|
170
|
+
function mergeInto(merged, inputProps) {
|
|
171
|
+
if (isPropsGetter(inputProps)) return resolvePropsGetter(inputProps, merged);
|
|
172
|
+
return mutablyMergeInto(merged, inputProps);
|
|
173
|
+
}
|
|
174
|
+
function copyInitialProps(inputProps) {
|
|
175
|
+
const copiedProps = {
|
|
176
|
+
...inputProps
|
|
177
|
+
};
|
|
178
|
+
for(const propName in copiedProps){
|
|
179
|
+
const propValue = copiedProps[propName];
|
|
180
|
+
if (isEventHandler(propName, propValue)) copiedProps[propName] = wrapEventHandler(propValue);
|
|
181
|
+
}
|
|
182
|
+
return copiedProps;
|
|
183
|
+
}
|
|
184
|
+
function mutablyMergeInto(mergedProps, externalProps) {
|
|
185
|
+
if (!externalProps) return mergedProps;
|
|
186
|
+
for(const propName in externalProps){
|
|
187
|
+
const externalPropValue = externalProps[propName];
|
|
188
|
+
switch(propName){
|
|
189
|
+
case 'style':
|
|
190
|
+
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
|
|
191
|
+
break;
|
|
192
|
+
case 'className':
|
|
193
|
+
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
|
|
194
|
+
break;
|
|
195
|
+
default:
|
|
196
|
+
if (isEventHandler(propName, externalPropValue)) mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
|
|
197
|
+
else mergedProps[propName] = externalPropValue;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return mergedProps;
|
|
201
|
+
}
|
|
202
|
+
function isEventHandler(key, value) {
|
|
203
|
+
const code0 = key.charCodeAt(0);
|
|
204
|
+
const code1 = key.charCodeAt(1);
|
|
205
|
+
const code2 = key.charCodeAt(2);
|
|
206
|
+
return 111 === code0 && 110 === code1 && code2 >= 65 && code2 <= 90 && ('function' == typeof value || void 0 === value);
|
|
207
|
+
}
|
|
208
|
+
function isPropsGetter(inputProps) {
|
|
209
|
+
return 'function' == typeof inputProps;
|
|
210
|
+
}
|
|
211
|
+
function resolvePropsGetter(inputProps, previousProps) {
|
|
212
|
+
if (isPropsGetter(inputProps)) return inputProps(previousProps);
|
|
213
|
+
return inputProps ?? EMPTY_PROPS;
|
|
214
|
+
}
|
|
215
|
+
function mergeEventHandlers(ourHandler, theirHandler) {
|
|
216
|
+
if (!theirHandler) return ourHandler;
|
|
217
|
+
if (!ourHandler) return wrapEventHandler(theirHandler);
|
|
218
|
+
return (...args)=>{
|
|
219
|
+
const event = args[0];
|
|
220
|
+
if (isSyntheticEvent(event)) {
|
|
221
|
+
const baseUIEvent = event;
|
|
222
|
+
makeEventPreventable(baseUIEvent);
|
|
223
|
+
const result = theirHandler(...args);
|
|
224
|
+
if (!baseUIEvent.baseUIHandlerPrevented) ourHandler?.(...args);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
const result = theirHandler(...args);
|
|
228
|
+
ourHandler?.(...args);
|
|
229
|
+
return result;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function wrapEventHandler(handler) {
|
|
233
|
+
if (!handler) return handler;
|
|
234
|
+
return (...args)=>{
|
|
235
|
+
const event = args[0];
|
|
236
|
+
if (isSyntheticEvent(event)) makeEventPreventable(event);
|
|
237
|
+
return handler(...args);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function makeEventPreventable(event) {
|
|
241
|
+
event.preventBaseUIHandler = ()=>{
|
|
242
|
+
event.baseUIHandlerPrevented = true;
|
|
243
|
+
};
|
|
244
|
+
return event;
|
|
245
|
+
}
|
|
246
|
+
function mergeClassNames(ourClassName, theirClassName) {
|
|
247
|
+
if (theirClassName) {
|
|
248
|
+
if (ourClassName) return theirClassName + ' ' + ourClassName;
|
|
249
|
+
return theirClassName;
|
|
250
|
+
}
|
|
251
|
+
return ourClassName;
|
|
252
|
+
}
|
|
253
|
+
function isSyntheticEvent(event) {
|
|
254
|
+
return null != event && 'object' == typeof event && 'nativeEvent' in event;
|
|
255
|
+
}
|
|
256
|
+
function useRenderElement(element, componentProps, params = {}) {
|
|
257
|
+
const renderProp = componentProps.render;
|
|
258
|
+
const outProps = useRenderElementProps(componentProps, params);
|
|
259
|
+
if (false === params.enabled) return null;
|
|
260
|
+
const state = params.state ?? EMPTY_OBJECT;
|
|
261
|
+
return evaluateRenderProp(element, renderProp, outProps, state);
|
|
262
|
+
}
|
|
263
|
+
function useRenderElementProps(componentProps, params = {}) {
|
|
264
|
+
const { className: classNameProp, style: styleProp, render: renderProp } = componentProps;
|
|
265
|
+
const { state = EMPTY_OBJECT, ref, props, stateAttributesMapping, enabled = true } = params;
|
|
266
|
+
const className = enabled ? resolveClassName(classNameProp, state) : void 0;
|
|
267
|
+
const style = enabled ? resolveStyle(styleProp, state) : void 0;
|
|
268
|
+
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
269
|
+
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
|
|
270
|
+
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
|
|
271
|
+
if ("u" > typeof document) if (enabled) if (Array.isArray(ref)) outProps.ref = useMergedRefsN([
|
|
272
|
+
outProps.ref,
|
|
273
|
+
getReactElementRef(renderProp),
|
|
274
|
+
...ref
|
|
275
|
+
]);
|
|
276
|
+
else outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
|
|
277
|
+
else useMergedRefs(null, null);
|
|
278
|
+
if (!enabled) return EMPTY_OBJECT;
|
|
279
|
+
if (void 0 !== className) outProps.className = mergeClassNames(outProps.className, className);
|
|
280
|
+
if (void 0 !== style) outProps.style = mergeObjects(outProps.style, style);
|
|
281
|
+
return outProps;
|
|
282
|
+
}
|
|
283
|
+
function resolveRenderFunctionProps(props) {
|
|
284
|
+
if (Array.isArray(props)) return mergePropsN(props);
|
|
285
|
+
return mergeProps(void 0, props);
|
|
286
|
+
}
|
|
287
|
+
const REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
288
|
+
const COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
|
|
289
|
+
const LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
|
|
290
|
+
function evaluateRenderProp(element, render, props, state) {
|
|
291
|
+
if (render) {
|
|
292
|
+
if ('function' == typeof render) {
|
|
293
|
+
if ('production' !== process.env.NODE_ENV) warnIfRenderPropLooksLikeComponent(render);
|
|
294
|
+
return render(props, state);
|
|
295
|
+
}
|
|
296
|
+
const mergedProps = mergeProps(props, render.props);
|
|
297
|
+
mergedProps.ref = props.ref;
|
|
298
|
+
let newElement = render;
|
|
299
|
+
if (newElement?.$$typeof === REACT_LAZY_TYPE) {
|
|
300
|
+
const children = __rspack_external_react.Children.toArray(render);
|
|
301
|
+
newElement = children[0];
|
|
302
|
+
}
|
|
303
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
304
|
+
if (!/*#__PURE__*/ __rspack_external_react.isValidElement(newElement)) throw new Error("Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.\nA valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.\nhttps://base-ui.com/r/invalid-render-prop");
|
|
305
|
+
}
|
|
306
|
+
return /*#__PURE__*/ __rspack_external_react.cloneElement(newElement, mergedProps);
|
|
307
|
+
}
|
|
308
|
+
if (element) {
|
|
309
|
+
if ('string' == typeof element) return renderTag(element, props);
|
|
310
|
+
}
|
|
311
|
+
throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: Render element or function are not defined.' : esm_formatErrorMessage(8));
|
|
312
|
+
}
|
|
313
|
+
function warnIfRenderPropLooksLikeComponent(renderFn) {
|
|
314
|
+
const functionName = renderFn.name;
|
|
315
|
+
if (0 === functionName.length) return;
|
|
316
|
+
if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) return;
|
|
317
|
+
if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) return;
|
|
318
|
+
warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, 'This usually means a React component was passed directly as `render={Component}`.', 'Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.', 'If this is an intentional render callback, rename it to start with a lowercase letter.', 'Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.', 'https://base-ui.com/r/invalid-render-prop');
|
|
319
|
+
}
|
|
320
|
+
function renderTag(Tag, props) {
|
|
321
|
+
if ('button' === Tag) return /*#__PURE__*/ (0, __rspack_external_react.createElement)("button", {
|
|
322
|
+
type: "button",
|
|
323
|
+
...props,
|
|
324
|
+
key: props.key
|
|
325
|
+
});
|
|
326
|
+
if ('img' === Tag) return /*#__PURE__*/ (0, __rspack_external_react.createElement)("img", {
|
|
327
|
+
alt: "",
|
|
328
|
+
...props,
|
|
329
|
+
key: props.key
|
|
330
|
+
});
|
|
331
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Tag, props);
|
|
332
|
+
}
|
|
333
|
+
export { EMPTY_ARRAY, EMPTY_OBJECT, NOOP, esm_formatErrorMessage, isReactVersionAtLeast, makeEventPreventable, mergeProps, resolveStyle, useMergedRefs, useRefWithInit, useRenderElement, warn };
|
package/dist/8527.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { error } from "./4026.js";
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
function useControlled({ controlled, default: defaultProp, name, state = 'value' }) {
|
|
4
|
+
const { current: isControlled } = __rspack_external_react.useRef(void 0 !== controlled);
|
|
5
|
+
const [valueState, setValue] = __rspack_external_react.useState(defaultProp);
|
|
6
|
+
const value = isControlled ? controlled : valueState;
|
|
7
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
8
|
+
__rspack_external_react.useEffect(()=>{
|
|
9
|
+
if (isControlled !== (void 0 !== controlled)) error([
|
|
10
|
+
`A component is changing the ${isControlled ? '' : 'un'}controlled ${state} state of ${name} to be ${isControlled ? 'un' : ''}controlled.`,
|
|
11
|
+
'Elements should not switch from uncontrolled to controlled (or vice versa).',
|
|
12
|
+
`Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`,
|
|
13
|
+
"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.",
|
|
14
|
+
'More info: https://fb.me/react-controlled-components'
|
|
15
|
+
].join('\n'));
|
|
16
|
+
}, [
|
|
17
|
+
state,
|
|
18
|
+
name,
|
|
19
|
+
controlled
|
|
20
|
+
]);
|
|
21
|
+
const { current: defaultValue } = __rspack_external_react.useRef(defaultProp);
|
|
22
|
+
__rspack_external_react.useEffect(()=>{
|
|
23
|
+
if (!isControlled && serializeToDevModeString(defaultValue) !== serializeToDevModeString(defaultProp)) error([
|
|
24
|
+
`A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. To suppress this warning opt to use a controlled ${name}.`
|
|
25
|
+
].join('\n'));
|
|
26
|
+
}, [
|
|
27
|
+
defaultProp
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
const setValueIfUncontrolled = __rspack_external_react.useCallback((newValue)=>{
|
|
31
|
+
if (!isControlled) setValue(newValue);
|
|
32
|
+
}, []);
|
|
33
|
+
return [
|
|
34
|
+
value,
|
|
35
|
+
setValueIfUncontrolled
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function serializeToDevModeString(input) {
|
|
39
|
+
let nextId = 0;
|
|
40
|
+
const seen = new WeakMap();
|
|
41
|
+
try {
|
|
42
|
+
const result = JSON.stringify(input, function(key, value) {
|
|
43
|
+
if ('_owner' === key && this != null && 'object' == typeof this && '$$typeof' in this) return;
|
|
44
|
+
if ('bigint' == typeof value) return `__bigint__:${value}`;
|
|
45
|
+
if (null !== value && 'object' == typeof value) {
|
|
46
|
+
const id = seen.get(value);
|
|
47
|
+
if (void 0 !== id) return `__object__:${id}`;
|
|
48
|
+
seen.set(value, nextId);
|
|
49
|
+
nextId += 1;
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
});
|
|
53
|
+
return result ?? `__top__:${typeof input}`;
|
|
54
|
+
} catch {
|
|
55
|
+
return '__unserializable__';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export { useControlled };
|
package/dist/8724.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { esm_formatErrorMessage } from "./8272.js";
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
const CompositeRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
4
|
+
if ("production" !== process.env.NODE_ENV) CompositeRootContext.displayName = "CompositeRootContext";
|
|
5
|
+
function useCompositeRootContext(optional = false) {
|
|
6
|
+
const context = __rspack_external_react.useContext(CompositeRootContext);
|
|
7
|
+
if (void 0 === context && !optional) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.' : esm_formatErrorMessage(16));
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
export { CompositeRootContext, useCompositeRootContext };
|