@jobber/components 7.8.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/Autocomplete/index.mjs +1 -1
  2. package/dist/Button/buttonRenderAdapter.d.ts +304 -0
  3. package/dist/Card/index.cjs +7 -4
  4. package/dist/Card/index.mjs +7 -4
  5. package/dist/Countdown/index.cjs +1 -1
  6. package/dist/Countdown/index.mjs +1 -1
  7. package/dist/Countdown-cjs.js +1 -1
  8. package/dist/Countdown-es.js +1 -1
  9. package/dist/DataDump/index.cjs +7 -4
  10. package/dist/DataDump/index.mjs +7 -4
  11. package/dist/DrawerRoot-cjs.js +2634 -2142
  12. package/dist/DrawerRoot-es.js +2523 -2065
  13. package/dist/InputAvatar/index.cjs +1 -1
  14. package/dist/InputAvatar/index.mjs +1 -1
  15. package/dist/InputFile/index.cjs +1 -1
  16. package/dist/InputFile/index.mjs +1 -1
  17. package/dist/InputFile-cjs.js +1 -1
  18. package/dist/InputFile-es.js +1 -1
  19. package/dist/InputNumber/index.cjs +2441 -186
  20. package/dist/InputNumber/index.mjs +2361 -106
  21. package/dist/Menu/Menu.Legacy.d.ts +3 -0
  22. package/dist/Menu/Menu.d.ts +66 -24
  23. package/dist/Menu/Menu.types.d.ts +8 -108
  24. package/dist/Menu/MenuBottomSheet.d.ts +29 -0
  25. package/dist/Menu/MenuDropdown.d.ts +29 -0
  26. package/dist/Menu/index.cjs +7 -4
  27. package/dist/Menu/index.mjs +7 -4
  28. package/dist/Menu/menuComposableShared.d.ts +27 -0
  29. package/dist/Menu/menuComposableTypes.d.ts +99 -0
  30. package/dist/Menu-cjs.js +828 -8419
  31. package/dist/Menu-es.js +823 -8414
  32. package/dist/MenuSubmenuTrigger-cjs.js +5283 -0
  33. package/dist/MenuSubmenuTrigger-es.js +5224 -0
  34. package/dist/Modal/index.mjs +1 -1
  35. package/dist/Page/index.cjs +6 -3
  36. package/dist/Page/index.mjs +6 -3
  37. package/dist/Page-cjs.js +1 -1
  38. package/dist/Page-es.js +1 -1
  39. package/dist/RecurringSelect/index.cjs +0 -1
  40. package/dist/RecurringSelect/index.mjs +0 -1
  41. package/dist/docs/Menu/Menu.md +7 -62
  42. package/dist/floating-ui.react-dom-es.js +1 -1
  43. package/dist/floating-ui.react-es.js +2 -2
  44. package/dist/index-cjs.js +1161 -166
  45. package/dist/index-es.js +1160 -166
  46. package/dist/index.cjs +7 -3
  47. package/dist/index.esm-es.js +1 -1
  48. package/dist/index.mjs +7 -3
  49. package/dist/primitives/BottomSheet/index.cjs +0 -1
  50. package/dist/primitives/BottomSheet/index.mjs +0 -1
  51. package/dist/primitives/index.cjs +0 -1
  52. package/dist/primitives/index.mjs +0 -1
  53. package/dist/styles.css +540 -31
  54. package/dist/unstyledPrimitives/index.cjs +6662 -8039
  55. package/dist/unstyledPrimitives/index.d.ts +2 -1
  56. package/dist/unstyledPrimitives/index.mjs +6733 -8111
  57. package/dist/useRenderElement-cjs.js +212 -212
  58. package/dist/useRenderElement-es.js +213 -213
  59. package/dist/utils/meta/meta.json +9 -0
  60. package/package.json +2 -2
  61. package/dist/Text-cjs2.js +0 -2484
  62. package/dist/Text-es2.js +0 -2417
  63. package/dist/index-cjs2.js +0 -1189
  64. package/dist/index-es2.js +0 -1186
@@ -21,36 +21,200 @@ function _interopNamespaceDefault(e) {
21
21
 
22
22
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
23
23
 
24
- const UNINITIALIZED = {};
24
+ function mergeObjects(a, b) {
25
+ if (a && !b) {
26
+ return a;
27
+ }
28
+ if (!a && b) {
29
+ return b;
30
+ }
31
+ if (a || b) {
32
+ return {
33
+ ...a,
34
+ ...b
35
+ };
36
+ }
37
+ return undefined;
38
+ }
39
+
40
+ const EMPTY_PROPS = {};
25
41
 
42
+ /* eslint-disable id-denylist */
26
43
  /**
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.
44
+ * Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
45
+ * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
29
46
  *
30
- * @usage
31
- * const ref = useRefWithInit(sortColumns, columns)
47
+ * Event handlers are merged and called in right-to-left order (rightmost handler executes first, leftmost last).
48
+ * For React synthetic events, the rightmost handler can prevent prior (left-positioned) handlers from executing
49
+ * by calling `event.preventBaseUIHandler()`. For non-synthetic events (custom events with primitive/object values),
50
+ * all handlers always execute without prevention capability.
51
+ *
52
+ * The `className` prop is merged by concatenating classes in right-to-left order (rightmost class appears first in the string).
53
+ * The `style` prop is merged with rightmost styles overwriting the prior ones.
54
+ *
55
+ * Props can either be provided as objects or as functions that take the previous props as an argument.
56
+ * The function will receive the merged props up to that point (going from left to right):
57
+ * so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
58
+ * The function is responsible for chaining event handlers if needed (i.e. we don't run the merge logic).
59
+ *
60
+ * Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
61
+ * They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
62
+ *
63
+ * @important **`ref` is not merged.**
64
+ * @param a Props object to merge.
65
+ * @param b Props object to merge. The function will overwrite conflicting props from `a`.
66
+ * @param c Props object to merge. The function will overwrite conflicting props from previous parameters.
67
+ * @param d Props object to merge. The function will overwrite conflicting props from previous parameters.
68
+ * @param e Props object to merge. The function will overwrite conflicting props from previous parameters.
69
+ * @returns The merged props.
70
+ * @public
32
71
  */
33
72
 
34
- function useRefWithInit(init, initArg) {
35
- const ref = React__namespace.useRef(UNINITIALIZED);
36
- if (ref.current === UNINITIALIZED) {
37
- ref.current = init(initArg);
73
+ function mergeProps(a, b, c, d, e) {
74
+ // We need to mutably own `merged`
75
+ let merged = {
76
+ ...resolvePropsGetter(a, EMPTY_PROPS)
77
+ };
78
+ if (b) {
79
+ merged = mergeOne(merged, b);
38
80
  }
39
- return ref;
81
+ if (c) {
82
+ merged = mergeOne(merged, c);
83
+ }
84
+ if (d) {
85
+ merged = mergeOne(merged, d);
86
+ }
87
+ return merged;
40
88
  }
89
+ /* eslint-enable id-denylist */
41
90
 
42
- let set;
43
- if (process.env.NODE_ENV !== 'production') {
44
- set = new Set();
91
+ /**
92
+ * Merges an arbitrary number of React props using the same logic as {@link mergeProps}.
93
+ * This function accepts an array of props instead of individual arguments.
94
+ *
95
+ * This has slightly lower performance than {@link mergeProps} due to accepting an array
96
+ * instead of a fixed number of arguments. Prefer {@link mergeProps} when merging 5 or
97
+ * fewer prop sets for better performance.
98
+ *
99
+ * @param props Array of props to merge.
100
+ * @returns The merged props.
101
+ * @see mergeProps
102
+ * @public
103
+ */
104
+ function mergePropsN(props) {
105
+ if (props.length === 0) {
106
+ return EMPTY_PROPS;
107
+ }
108
+ if (props.length === 1) {
109
+ return resolvePropsGetter(props[0], EMPTY_PROPS);
110
+ }
111
+
112
+ // We need to mutably own `merged`
113
+ let merged = {
114
+ ...resolvePropsGetter(props[0], EMPTY_PROPS)
115
+ };
116
+ for (let i = 1; i < props.length; i += 1) {
117
+ merged = mergeOne(merged, props[i]);
118
+ }
119
+ return merged;
45
120
  }
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}`);
121
+ function mergeOne(merged, inputProps) {
122
+ if (isPropsGetter(inputProps)) {
123
+ return inputProps(merged);
124
+ }
125
+ return mutablyMergeInto(merged, inputProps);
126
+ }
127
+
128
+ /**
129
+ * Merges two sets of props. In case of conflicts, the external props take precedence.
130
+ */
131
+ function mutablyMergeInto(mergedProps, externalProps) {
132
+ if (!externalProps) {
133
+ return mergedProps;
134
+ }
135
+
136
+ // eslint-disable-next-line guard-for-in
137
+ for (const propName in externalProps) {
138
+ const externalPropValue = externalProps[propName];
139
+ switch (propName) {
140
+ case 'style':
141
+ {
142
+ mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
143
+ break;
144
+ }
145
+ case 'className':
146
+ {
147
+ mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
148
+ break;
149
+ }
150
+ default:
151
+ {
152
+ if (isEventHandler(propName, externalPropValue)) {
153
+ mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
154
+ } else {
155
+ mergedProps[propName] = externalPropValue;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return mergedProps;
161
+ }
162
+ function isEventHandler(key, value) {
163
+ // This approach is more efficient than using a regex.
164
+ const code0 = key.charCodeAt(0);
165
+ const code1 = key.charCodeAt(1);
166
+ const code2 = key.charCodeAt(2);
167
+ return code0 === 111 /* o */ && code1 === 110 /* n */ && code2 >= 65 /* A */ && code2 <= 90 /* Z */ && (typeof value === 'function' || typeof value === 'undefined');
168
+ }
169
+ function isPropsGetter(inputProps) {
170
+ return typeof inputProps === 'function';
171
+ }
172
+ function resolvePropsGetter(inputProps, previousProps) {
173
+ if (isPropsGetter(inputProps)) {
174
+ return inputProps(previousProps);
175
+ }
176
+ return inputProps ?? EMPTY_PROPS;
177
+ }
178
+ function mergeEventHandlers(ourHandler, theirHandler) {
179
+ if (!theirHandler) {
180
+ return ourHandler;
181
+ }
182
+ if (!ourHandler) {
183
+ return theirHandler;
184
+ }
185
+ return event => {
186
+ if (isSyntheticEvent(event)) {
187
+ const baseUIEvent = event;
188
+ makeEventPreventable(baseUIEvent);
189
+ const result = theirHandler(baseUIEvent);
190
+ if (!baseUIEvent.baseUIHandlerPrevented) {
191
+ ourHandler?.(baseUIEvent);
192
+ }
193
+ return result;
52
194
  }
195
+ const result = theirHandler(event);
196
+ ourHandler?.(event);
197
+ return result;
198
+ };
199
+ }
200
+ function makeEventPreventable(event) {
201
+ event.preventBaseUIHandler = () => {
202
+ event.baseUIHandlerPrevented = true;
203
+ };
204
+ return event;
205
+ }
206
+ function mergeClassNames(ourClassName, theirClassName) {
207
+ if (theirClassName) {
208
+ if (ourClassName) {
209
+ // eslint-disable-next-line prefer-template
210
+ return theirClassName + ' ' + ourClassName;
211
+ }
212
+ return theirClassName;
53
213
  }
214
+ return ourClassName;
215
+ }
216
+ function isSyntheticEvent(event) {
217
+ return event != null && typeof event === 'object' && 'nativeEvent' in event;
54
218
  }
55
219
 
56
220
  /**
@@ -79,6 +243,24 @@ function createFormatErrorMessage(baseUrl, prefix) {
79
243
  */
80
244
  const formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
81
245
 
246
+ const UNINITIALIZED = {};
247
+
248
+ /**
249
+ * A React.useRef() that is initialized with a function. Note that it accepts an optional
250
+ * initialization argument, so the initialization function doesn't need to be an inline closure.
251
+ *
252
+ * @usage
253
+ * const ref = useRefWithInit(sortColumns, columns)
254
+ */
255
+
256
+ function useRefWithInit(init, initArg) {
257
+ const ref = React__namespace.useRef(UNINITIALIZED);
258
+ if (ref.current === UNINITIALIZED) {
259
+ ref.current = init(initArg);
260
+ }
261
+ return ref;
262
+ }
263
+
82
264
  /**
83
265
  * Merges refs into a single memoized callback ref or `null`.
84
266
  * This makes sure multiple refs are updated together and have the same value.
@@ -201,20 +383,18 @@ function getReactElementRef(element) {
201
383
  return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
202
384
  }
203
385
 
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
- };
386
+ let set;
387
+ if (process.env.NODE_ENV !== 'production') {
388
+ set = new Set();
389
+ }
390
+ function warn(...messages) {
391
+ if (process.env.NODE_ENV !== 'production') {
392
+ const messageKey = messages.join(' ');
393
+ if (!set.has(messageKey)) {
394
+ set.add(messageKey);
395
+ console.warn(`Base UI: ${messageKey}`);
396
+ }
216
397
  }
217
- return undefined;
218
398
  }
219
399
 
220
400
  function getStateAttributesProps(state, customMapping) {
@@ -261,186 +441,6 @@ function resolveStyle(style, state) {
261
441
  return typeof style === 'function' ? style(state) : style;
262
442
  }
263
443
 
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
444
  function NOOP() {}
445
445
  const EMPTY_ARRAY = Object.freeze([]);
446
446
  const EMPTY_OBJECT = Object.freeze({});