@jobber/components 6.122.0 → 6.123.1

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 (107) hide show
  1. package/dist/Autocomplete/index.cjs +1 -0
  2. package/dist/Autocomplete/index.mjs +2 -1
  3. package/dist/BottomSheet-cjs.js +96 -0
  4. package/dist/BottomSheet-es.js +94 -0
  5. package/dist/Card/index.cjs +3 -2
  6. package/dist/Card/index.mjs +3 -2
  7. package/dist/Chip/index.cjs +3 -2
  8. package/dist/Chip/index.mjs +3 -2
  9. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +3 -2
  10. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +3 -2
  11. package/dist/Chips/InternalChipDismissible/index.cjs +3 -2
  12. package/dist/Chips/InternalChipDismissible/index.mjs +3 -2
  13. package/dist/Chips/index.cjs +3 -2
  14. package/dist/Chips/index.mjs +3 -2
  15. package/dist/Combobox/components/ComboboxActivator/index.cjs +3 -2
  16. package/dist/Combobox/components/ComboboxActivator/index.mjs +3 -2
  17. package/dist/Combobox/components/ComboboxContent/index.cjs +3 -2
  18. package/dist/Combobox/components/ComboboxContent/index.mjs +3 -2
  19. package/dist/Combobox/components/ComboboxTrigger/index.cjs +3 -2
  20. package/dist/Combobox/components/ComboboxTrigger/index.mjs +3 -2
  21. package/dist/Combobox/index.cjs +3 -2
  22. package/dist/Combobox/index.mjs +3 -2
  23. package/dist/ComboboxContent-es.js +1 -1
  24. package/dist/ConfirmationModal/index.cjs +2 -1
  25. package/dist/ConfirmationModal/index.mjs +2 -1
  26. package/dist/DataDump/index.cjs +3 -2
  27. package/dist/DataDump/index.mjs +3 -2
  28. package/dist/DataList/components/DataListActions/index.cjs +3 -2
  29. package/dist/DataList/components/DataListActions/index.mjs +3 -2
  30. package/dist/DataList/components/DataListBulkActions/index.cjs +3 -2
  31. package/dist/DataList/components/DataListBulkActions/index.mjs +3 -2
  32. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +3 -2
  33. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +3 -2
  34. package/dist/DataList/components/DataListFilters/index.cjs +3 -2
  35. package/dist/DataList/components/DataListFilters/index.mjs +3 -2
  36. package/dist/DataList/components/DataListHeader/index.cjs +3 -2
  37. package/dist/DataList/components/DataListHeader/index.mjs +3 -2
  38. package/dist/DataList/components/DataListItem/index.cjs +3 -2
  39. package/dist/DataList/components/DataListItem/index.mjs +3 -2
  40. package/dist/DataList/components/DataListItemActions/index.cjs +3 -2
  41. package/dist/DataList/components/DataListItemActions/index.mjs +3 -2
  42. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +3 -2
  43. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +3 -2
  44. package/dist/DataList/components/DataListItems/index.cjs +3 -2
  45. package/dist/DataList/components/DataListItems/index.mjs +3 -2
  46. package/dist/DataList/components/DataListLayout/index.cjs +3 -2
  47. package/dist/DataList/components/DataListLayout/index.mjs +3 -2
  48. package/dist/DataList/components/DataListLayoutActions/index.cjs +3 -2
  49. package/dist/DataList/components/DataListLayoutActions/index.mjs +3 -2
  50. package/dist/DataList/index.cjs +3 -2
  51. package/dist/DataList/index.mjs +3 -2
  52. package/dist/DatePicker/index.cjs +3 -2
  53. package/dist/DatePicker/index.mjs +3 -2
  54. package/dist/DatePicker-es.js +1 -1
  55. package/dist/DrawerRoot-cjs.js +6181 -0
  56. package/dist/DrawerRoot-es.js +6056 -0
  57. package/dist/FormatFile/index.cjs +2 -1
  58. package/dist/FormatFile/index.mjs +2 -1
  59. package/dist/Gallery/index.cjs +2 -1
  60. package/dist/Gallery/index.mjs +2 -1
  61. package/dist/InputDate/index.cjs +3 -2
  62. package/dist/InputDate/index.mjs +3 -2
  63. package/dist/LightBox/index.cjs +2 -1
  64. package/dist/LightBox/index.mjs +2 -1
  65. package/dist/Menu/index.cjs +3 -2
  66. package/dist/Menu/index.mjs +3 -2
  67. package/dist/Menu-es.js +1 -1
  68. package/dist/Modal/index.cjs +2 -1
  69. package/dist/Modal/index.mjs +2 -1
  70. package/dist/OverlaySeparator-cjs.js +15 -0
  71. package/dist/OverlaySeparator-es.js +13 -0
  72. package/dist/Page/index.cjs +2 -1
  73. package/dist/Page/index.mjs +2 -1
  74. package/dist/Popover/index.cjs +3 -2
  75. package/dist/Popover/index.mjs +3 -2
  76. package/dist/Popover-es.js +1 -1
  77. package/dist/Separator-cjs.js +53 -0
  78. package/dist/Separator-es.js +32 -0
  79. package/dist/Tooltip/index.cjs +3 -2
  80. package/dist/Tooltip/index.mjs +3 -2
  81. package/dist/Tooltip-es.js +1 -1
  82. package/dist/floating-ui.react-cjs.js +45 -44
  83. package/dist/floating-ui.react-dom-cjs.js +155 -1053
  84. package/dist/floating-ui.react-dom-es.js +2 -876
  85. package/dist/floating-ui.react-es.js +2 -1
  86. package/dist/index.cjs +3 -2
  87. package/dist/index.esm-cjs.js +921 -0
  88. package/dist/index.esm-es.js +876 -0
  89. package/dist/index.mjs +3 -2
  90. package/dist/primitives/BottomSheet/BottomSheet.d.ts +20 -0
  91. package/dist/primitives/BottomSheet/index.cjs +16 -0
  92. package/dist/primitives/BottomSheet/index.d.ts +1 -0
  93. package/dist/primitives/BottomSheet/index.mjs +10 -0
  94. package/dist/primitives/OverlaySeparator/OverlaySeparator.d.ts +6 -0
  95. package/dist/primitives/OverlaySeparator/index.cjs +12 -0
  96. package/dist/primitives/OverlaySeparator/index.d.ts +1 -0
  97. package/dist/primitives/OverlaySeparator/index.mjs +6 -0
  98. package/dist/primitives/index.cjs +17 -0
  99. package/dist/primitives/index.d.ts +2 -0
  100. package/dist/primitives/index.mjs +12 -1
  101. package/dist/unstyledPrimitives/index.cjs +7676 -9833
  102. package/dist/unstyledPrimitives/index.d.ts +6 -9
  103. package/dist/unstyledPrimitives/index.mjs +7551 -9711
  104. package/dist/useRenderElement-cjs.js +598 -0
  105. package/dist/useRenderElement-es.js +569 -0
  106. package/dist/useScrollToActive-es.js +1 -1
  107. package/package.json +2 -2
@@ -0,0 +1,598 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function _interopNamespaceDefault(e) {
6
+ var n = Object.create(null);
7
+ if (e) {
8
+ Object.keys(e).forEach(function (k) {
9
+ if (k !== 'default') {
10
+ var d = Object.getOwnPropertyDescriptor(e, k);
11
+ Object.defineProperty(n, k, d.get ? d : {
12
+ enumerable: true,
13
+ get: function () { return e[k]; }
14
+ });
15
+ }
16
+ });
17
+ }
18
+ n.default = e;
19
+ return Object.freeze(n);
20
+ }
21
+
22
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
23
+
24
+ const UNINITIALIZED = {};
25
+
26
+ /**
27
+ * A React.useRef() that is initialized with a function. Note that it accepts an optional
28
+ * initialization argument, so the initialization function doesn't need to be an inline closure.
29
+ *
30
+ * @usage
31
+ * const ref = useRefWithInit(sortColumns, columns)
32
+ */
33
+
34
+ function useRefWithInit(init, initArg) {
35
+ const ref = React__namespace.useRef(UNINITIALIZED);
36
+ if (ref.current === UNINITIALIZED) {
37
+ ref.current = init(initArg);
38
+ }
39
+ return ref;
40
+ }
41
+
42
+ let set;
43
+ if (process.env.NODE_ENV !== 'production') {
44
+ set = new Set();
45
+ }
46
+ function warn(...messages) {
47
+ if (process.env.NODE_ENV !== 'production') {
48
+ const messageKey = messages.join(' ');
49
+ if (!set.has(messageKey)) {
50
+ set.add(messageKey);
51
+ console.warn(`Base UI: ${messageKey}`);
52
+ }
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Creates a formatErrorMessage function with a custom URL and prefix.
58
+ * @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
59
+ * @param prefix - The prefix for the error message (e.g., 'Base UI')
60
+ * @returns A function that formats error messages with the given URL and prefix
61
+ */
62
+ function createFormatErrorMessage(baseUrl, prefix) {
63
+ return function formatErrorMessage(code, ...args) {
64
+ const url = new URL(baseUrl);
65
+ url.searchParams.set('code', code.toString());
66
+ args.forEach(arg => url.searchParams.append('args[]', arg));
67
+ return `${prefix} error #${code}; visit ${url} for the full message.`;
68
+ };
69
+ }
70
+
71
+ /**
72
+ * WARNING: Don't import this directly. It's imported by the code generated by
73
+ * `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
74
+ * constructors to ensure the plugin works as expected. Supported patterns include:
75
+ * throw new Error('My message');
76
+ * throw new Error(`My message: ${foo}`);
77
+ * throw new Error(`My message: ${foo}` + 'another string');
78
+ * ...
79
+ */
80
+ const formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
81
+
82
+ /**
83
+ * Merges refs into a single memoized callback ref or `null`.
84
+ * This makes sure multiple refs are updated together and have the same value.
85
+ *
86
+ * This function accepts up to four refs. If you need to merge more, or have an unspecified number of refs to merge,
87
+ * use `useMergedRefsN` instead.
88
+ */
89
+
90
+ function useMergedRefs(a, b, c, d) {
91
+ const forkRef = useRefWithInit(createForkRef).current;
92
+ if (didChange(forkRef, a, b, c, d)) {
93
+ update(forkRef, [a, b, c, d]);
94
+ }
95
+ return forkRef.callback;
96
+ }
97
+
98
+ /**
99
+ * Merges an array of refs into a single memoized callback ref or `null`.
100
+ *
101
+ * If you need to merge a fixed number (up to four) of refs, use `useMergedRefs` instead for better performance.
102
+ */
103
+ function useMergedRefsN(refs) {
104
+ const forkRef = useRefWithInit(createForkRef).current;
105
+ if (didChangeN(forkRef, refs)) {
106
+ update(forkRef, refs);
107
+ }
108
+ return forkRef.callback;
109
+ }
110
+ function createForkRef() {
111
+ return {
112
+ callback: null,
113
+ cleanup: null,
114
+ refs: []
115
+ };
116
+ }
117
+ function didChange(forkRef, a, b, c, d) {
118
+ // prettier-ignore
119
+ return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
120
+ }
121
+ function didChangeN(forkRef, newRefs) {
122
+ return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
123
+ }
124
+ function update(forkRef, refs) {
125
+ forkRef.refs = refs;
126
+ if (refs.every(ref => ref == null)) {
127
+ forkRef.callback = null;
128
+ return;
129
+ }
130
+ forkRef.callback = instance => {
131
+ if (forkRef.cleanup) {
132
+ forkRef.cleanup();
133
+ forkRef.cleanup = null;
134
+ }
135
+ if (instance != null) {
136
+ const cleanupCallbacks = Array(refs.length).fill(null);
137
+ for (let i = 0; i < refs.length; i += 1) {
138
+ const ref = refs[i];
139
+ if (ref == null) {
140
+ continue;
141
+ }
142
+ switch (typeof ref) {
143
+ case 'function':
144
+ {
145
+ const refCleanup = ref(instance);
146
+ if (typeof refCleanup === 'function') {
147
+ cleanupCallbacks[i] = refCleanup;
148
+ }
149
+ break;
150
+ }
151
+ case 'object':
152
+ {
153
+ ref.current = instance;
154
+ break;
155
+ }
156
+ }
157
+ }
158
+ forkRef.cleanup = () => {
159
+ for (let i = 0; i < refs.length; i += 1) {
160
+ const ref = refs[i];
161
+ if (ref == null) {
162
+ continue;
163
+ }
164
+ switch (typeof ref) {
165
+ case 'function':
166
+ {
167
+ const cleanupCallback = cleanupCallbacks[i];
168
+ if (typeof cleanupCallback === 'function') {
169
+ cleanupCallback();
170
+ } else {
171
+ ref(null);
172
+ }
173
+ break;
174
+ }
175
+ case 'object':
176
+ {
177
+ ref.current = null;
178
+ break;
179
+ }
180
+ }
181
+ }
182
+ };
183
+ }
184
+ };
185
+ }
186
+
187
+ const majorVersion = parseInt(React__namespace.version, 10);
188
+ function isReactVersionAtLeast(reactVersionToCheck) {
189
+ return majorVersion >= reactVersionToCheck;
190
+ }
191
+
192
+ /**
193
+ * Extracts the `ref` from a React element, handling different React versions.
194
+ */
195
+ function getReactElementRef(element) {
196
+ if (! /*#__PURE__*/React__namespace.isValidElement(element)) {
197
+ return null;
198
+ }
199
+ const reactElement = element;
200
+ const propsWithRef = reactElement.props;
201
+ return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
202
+ }
203
+
204
+ function mergeObjects(a, b) {
205
+ if (a && !b) {
206
+ return a;
207
+ }
208
+ if (!a && b) {
209
+ return b;
210
+ }
211
+ if (a || b) {
212
+ return {
213
+ ...a,
214
+ ...b
215
+ };
216
+ }
217
+ return undefined;
218
+ }
219
+
220
+ function getStateAttributesProps(state, customMapping) {
221
+ const props = {};
222
+
223
+ /* eslint-disable-next-line guard-for-in */
224
+ for (const key in state) {
225
+ const value = state[key];
226
+ if (customMapping?.hasOwnProperty(key)) {
227
+ const customProps = customMapping[key](value);
228
+ if (customProps != null) {
229
+ Object.assign(props, customProps);
230
+ }
231
+ continue;
232
+ }
233
+ if (value === true) {
234
+ props[`data-${key.toLowerCase()}`] = '';
235
+ } else if (value) {
236
+ props[`data-${key.toLowerCase()}`] = value.toString();
237
+ }
238
+ }
239
+ return props;
240
+ }
241
+
242
+ /**
243
+ * If the provided className is a string, it will be returned as is.
244
+ * Otherwise, the function will call the className function with the state as the first argument.
245
+ *
246
+ * @param className
247
+ * @param state
248
+ */
249
+ function resolveClassName(className, state) {
250
+ return typeof className === 'function' ? className(state) : className;
251
+ }
252
+
253
+ /**
254
+ * If the provided style is an object, it will be returned as is.
255
+ * Otherwise, the function will call the style function with the state as the first argument.
256
+ *
257
+ * @param style
258
+ * @param state
259
+ */
260
+ function resolveStyle(style, state) {
261
+ return typeof style === 'function' ? style(state) : style;
262
+ }
263
+
264
+ const EMPTY_PROPS = {};
265
+
266
+ /* eslint-disable id-denylist */
267
+ /**
268
+ * Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
269
+ * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
270
+ *
271
+ * Event handlers are merged and called in right-to-left order (rightmost handler executes first, leftmost last).
272
+ * For React synthetic events, the rightmost handler can prevent prior (left-positioned) handlers from executing
273
+ * by calling `event.preventBaseUIHandler()`. For non-synthetic events (custom events with primitive/object values),
274
+ * all handlers always execute without prevention capability.
275
+ *
276
+ * The `className` prop is merged by concatenating classes in right-to-left order (rightmost class appears first in the string).
277
+ * The `style` prop is merged with rightmost styles overwriting the prior ones.
278
+ *
279
+ * Props can either be provided as objects or as functions that take the previous props as an argument.
280
+ * The function will receive the merged props up to that point (going from left to right):
281
+ * so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
282
+ * The function is responsible for chaining event handlers if needed (i.e. we don't run the merge logic).
283
+ *
284
+ * Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
285
+ * They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
286
+ *
287
+ * @important **`ref` is not merged.**
288
+ * @param a Props object to merge.
289
+ * @param b Props object to merge. The function will overwrite conflicting props from `a`.
290
+ * @param c Props object to merge. The function will overwrite conflicting props from previous parameters.
291
+ * @param d Props object to merge. The function will overwrite conflicting props from previous parameters.
292
+ * @param e Props object to merge. The function will overwrite conflicting props from previous parameters.
293
+ * @returns The merged props.
294
+ * @public
295
+ */
296
+
297
+ function mergeProps(a, b, c, d, e) {
298
+ // We need to mutably own `merged`
299
+ let merged = {
300
+ ...resolvePropsGetter(a, EMPTY_PROPS)
301
+ };
302
+ if (b) {
303
+ merged = mergeOne(merged, b);
304
+ }
305
+ if (c) {
306
+ merged = mergeOne(merged, c);
307
+ }
308
+ if (d) {
309
+ merged = mergeOne(merged, d);
310
+ }
311
+ return merged;
312
+ }
313
+ /* eslint-enable id-denylist */
314
+
315
+ /**
316
+ * Merges an arbitrary number of React props using the same logic as {@link mergeProps}.
317
+ * This function accepts an array of props instead of individual arguments.
318
+ *
319
+ * This has slightly lower performance than {@link mergeProps} due to accepting an array
320
+ * instead of a fixed number of arguments. Prefer {@link mergeProps} when merging 5 or
321
+ * fewer prop sets for better performance.
322
+ *
323
+ * @param props Array of props to merge.
324
+ * @returns The merged props.
325
+ * @see mergeProps
326
+ * @public
327
+ */
328
+ function mergePropsN(props) {
329
+ if (props.length === 0) {
330
+ return EMPTY_PROPS;
331
+ }
332
+ if (props.length === 1) {
333
+ return resolvePropsGetter(props[0], EMPTY_PROPS);
334
+ }
335
+
336
+ // We need to mutably own `merged`
337
+ let merged = {
338
+ ...resolvePropsGetter(props[0], EMPTY_PROPS)
339
+ };
340
+ for (let i = 1; i < props.length; i += 1) {
341
+ merged = mergeOne(merged, props[i]);
342
+ }
343
+ return merged;
344
+ }
345
+ function mergeOne(merged, inputProps) {
346
+ if (isPropsGetter(inputProps)) {
347
+ return inputProps(merged);
348
+ }
349
+ return mutablyMergeInto(merged, inputProps);
350
+ }
351
+
352
+ /**
353
+ * Merges two sets of props. In case of conflicts, the external props take precedence.
354
+ */
355
+ function mutablyMergeInto(mergedProps, externalProps) {
356
+ if (!externalProps) {
357
+ return mergedProps;
358
+ }
359
+
360
+ // eslint-disable-next-line guard-for-in
361
+ for (const propName in externalProps) {
362
+ const externalPropValue = externalProps[propName];
363
+ switch (propName) {
364
+ case 'style':
365
+ {
366
+ mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
367
+ break;
368
+ }
369
+ case 'className':
370
+ {
371
+ mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
372
+ break;
373
+ }
374
+ default:
375
+ {
376
+ if (isEventHandler(propName, externalPropValue)) {
377
+ mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
378
+ } else {
379
+ mergedProps[propName] = externalPropValue;
380
+ }
381
+ }
382
+ }
383
+ }
384
+ return mergedProps;
385
+ }
386
+ function isEventHandler(key, value) {
387
+ // This approach is more efficient than using a regex.
388
+ const code0 = key.charCodeAt(0);
389
+ const code1 = key.charCodeAt(1);
390
+ const code2 = key.charCodeAt(2);
391
+ return code0 === 111 /* o */ && code1 === 110 /* n */ && code2 >= 65 /* A */ && code2 <= 90 /* Z */ && (typeof value === 'function' || typeof value === 'undefined');
392
+ }
393
+ function isPropsGetter(inputProps) {
394
+ return typeof inputProps === 'function';
395
+ }
396
+ function resolvePropsGetter(inputProps, previousProps) {
397
+ if (isPropsGetter(inputProps)) {
398
+ return inputProps(previousProps);
399
+ }
400
+ return inputProps ?? EMPTY_PROPS;
401
+ }
402
+ function mergeEventHandlers(ourHandler, theirHandler) {
403
+ if (!theirHandler) {
404
+ return ourHandler;
405
+ }
406
+ if (!ourHandler) {
407
+ return theirHandler;
408
+ }
409
+ return event => {
410
+ if (isSyntheticEvent(event)) {
411
+ const baseUIEvent = event;
412
+ makeEventPreventable(baseUIEvent);
413
+ const result = theirHandler(baseUIEvent);
414
+ if (!baseUIEvent.baseUIHandlerPrevented) {
415
+ ourHandler?.(baseUIEvent);
416
+ }
417
+ return result;
418
+ }
419
+ const result = theirHandler(event);
420
+ ourHandler?.(event);
421
+ return result;
422
+ };
423
+ }
424
+ function makeEventPreventable(event) {
425
+ event.preventBaseUIHandler = () => {
426
+ event.baseUIHandlerPrevented = true;
427
+ };
428
+ return event;
429
+ }
430
+ function mergeClassNames(ourClassName, theirClassName) {
431
+ if (theirClassName) {
432
+ if (ourClassName) {
433
+ // eslint-disable-next-line prefer-template
434
+ return theirClassName + ' ' + ourClassName;
435
+ }
436
+ return theirClassName;
437
+ }
438
+ return ourClassName;
439
+ }
440
+ function isSyntheticEvent(event) {
441
+ return event != null && typeof event === 'object' && 'nativeEvent' in event;
442
+ }
443
+
444
+ function NOOP() {}
445
+ const EMPTY_ARRAY = Object.freeze([]);
446
+ const EMPTY_OBJECT = Object.freeze({});
447
+
448
+ /**
449
+ * Renders a Base UI element.
450
+ *
451
+ * @param element The default HTML element to render. Can be overridden by the `render` prop.
452
+ * @param componentProps An object containing the `render` and `className` props to be used for element customization. Other props are ignored.
453
+ * @param params Additional parameters for rendering the element.
454
+ */
455
+ function useRenderElement(element, componentProps, params = {}) {
456
+ const renderProp = componentProps.render;
457
+ const outProps = useRenderElementProps(componentProps, params);
458
+ if (params.enabled === false) {
459
+ return null;
460
+ }
461
+ const state = params.state ?? EMPTY_OBJECT;
462
+ return evaluateRenderProp(element, renderProp, outProps, state);
463
+ }
464
+
465
+ /**
466
+ * Computes render element final props.
467
+ */
468
+ function useRenderElementProps(componentProps, params = {}) {
469
+ const {
470
+ className: classNameProp,
471
+ style: styleProp,
472
+ render: renderProp
473
+ } = componentProps;
474
+ const {
475
+ state = EMPTY_OBJECT,
476
+ ref,
477
+ props,
478
+ stateAttributesMapping,
479
+ enabled = true
480
+ } = params;
481
+ const className = enabled ? resolveClassName(classNameProp, state) : undefined;
482
+ const style = enabled ? resolveStyle(styleProp, state) : undefined;
483
+ const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
484
+ const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
485
+
486
+ // SAFETY: The `useMergedRefs` functions use a single hook to store the same value,
487
+ // switching between them at runtime is safe. If this assertion fails, React will
488
+ // throw at runtime anyway.
489
+ // This also skips the `useMergedRefs` call on the server, which is fine because
490
+ // refs are not used on the server side.
491
+ /* eslint-disable react-hooks/rules-of-hooks */
492
+ if (typeof document !== 'undefined') {
493
+ if (!enabled) {
494
+ useMergedRefs(null, null);
495
+ } else if (Array.isArray(ref)) {
496
+ outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
497
+ } else {
498
+ outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
499
+ }
500
+ }
501
+ if (!enabled) {
502
+ return EMPTY_OBJECT;
503
+ }
504
+ if (className !== undefined) {
505
+ outProps.className = mergeClassNames(outProps.className, className);
506
+ }
507
+ if (style !== undefined) {
508
+ outProps.style = mergeObjects(outProps.style, style);
509
+ }
510
+ return outProps;
511
+ }
512
+
513
+ // The symbol React uses internally for lazy components
514
+ // https://github.com/facebook/react/blob/a0566250b210499b4c5677f5ac2eedbd71d51a1b/packages/shared/ReactSymbols.js#L31
515
+ //
516
+ // TODO delete once https://github.com/facebook/react/issues/32392 is fixed
517
+ const REACT_LAZY_TYPE = Symbol.for('react.lazy');
518
+ function evaluateRenderProp(element, render, props, state) {
519
+ if (render) {
520
+ if (typeof render === 'function') {
521
+ if (process.env.NODE_ENV !== 'production') {
522
+ warnIfRenderPropLooksLikeComponent(render);
523
+ }
524
+ return render(props, state);
525
+ }
526
+ const mergedProps = mergeProps(props, render.props);
527
+ mergedProps.ref = props.ref;
528
+ let newElement = render;
529
+
530
+ // Workaround for https://github.com/facebook/react/issues/32392
531
+ // This works because the toArray() logic unwrap lazy element type in
532
+ // https://github.com/facebook/react/blob/a0566250b210499b4c5677f5ac2eedbd71d51a1b/packages/react/src/ReactChildren.js#L186
533
+ if (newElement?.$$typeof === REACT_LAZY_TYPE) {
534
+ const children = React__namespace.Children.toArray(render);
535
+ newElement = children[0];
536
+ }
537
+
538
+ // There is a high number of indirections, the error message thrown by React.cloneElement() is
539
+ // hard to use for developers, this logic provides a better context.
540
+ //
541
+ // Our general guideline is to never change the control flow depending on the environment.
542
+ // However, React.cloneElement() throws if React.isValidElement() is false,
543
+ // so we can throw before with custom message.
544
+ if (process.env.NODE_ENV !== 'production') {
545
+ if (! /*#__PURE__*/React__namespace.isValidElement(newElement)) {
546
+ throw new Error(['Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.', 'A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.', 'https://base-ui.com/r/invalid-render-prop'].join('\n'));
547
+ }
548
+ }
549
+ return /*#__PURE__*/React__namespace.cloneElement(newElement, mergedProps);
550
+ }
551
+ if (element) {
552
+ if (typeof element === 'string') {
553
+ return renderTag(element, props);
554
+ }
555
+ }
556
+ // Unreachable, but the typings on `useRenderElement` need to be reworked
557
+ // to annotate it correctly.
558
+ throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: Render element or function are not defined.' : formatErrorMessage(8));
559
+ }
560
+ function warnIfRenderPropLooksLikeComponent(renderFn) {
561
+ const functionName = renderFn.name;
562
+ if (functionName.length === 0) {
563
+ return;
564
+ }
565
+ const firstCharacterCode = functionName.charCodeAt(0);
566
+ if (firstCharacterCode < 65 || firstCharacterCode > 90) {
567
+ return;
568
+ }
569
+ 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');
570
+ }
571
+ function renderTag(Tag, props) {
572
+ if (Tag === 'button') {
573
+ return /*#__PURE__*/React.createElement("button", {
574
+ type: "button",
575
+ ...props,
576
+ key: props.key
577
+ });
578
+ }
579
+ if (Tag === 'img') {
580
+ return /*#__PURE__*/React.createElement("img", {
581
+ alt: "",
582
+ ...props,
583
+ key: props.key
584
+ });
585
+ }
586
+ return /*#__PURE__*/React__namespace.createElement(Tag, props);
587
+ }
588
+
589
+ exports.EMPTY_ARRAY = EMPTY_ARRAY;
590
+ exports.EMPTY_OBJECT = EMPTY_OBJECT;
591
+ exports.NOOP = NOOP;
592
+ exports.formatErrorMessage = formatErrorMessage;
593
+ exports.isReactVersionAtLeast = isReactVersionAtLeast;
594
+ exports.makeEventPreventable = makeEventPreventable;
595
+ exports.mergeProps = mergeProps;
596
+ exports.useMergedRefs = useMergedRefs;
597
+ exports.useRefWithInit = useRefWithInit;
598
+ exports.useRenderElement = useRenderElement;