@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
@@ -1,36 +1,200 @@
1
1
  import * as React from 'react';
2
2
  import { createElement } from 'react';
3
3
 
4
- const UNINITIALIZED = {};
4
+ function mergeObjects(a, b) {
5
+ if (a && !b) {
6
+ return a;
7
+ }
8
+ if (!a && b) {
9
+ return b;
10
+ }
11
+ if (a || b) {
12
+ return {
13
+ ...a,
14
+ ...b
15
+ };
16
+ }
17
+ return undefined;
18
+ }
19
+
20
+ const EMPTY_PROPS = {};
5
21
 
22
+ /* eslint-disable id-denylist */
6
23
  /**
7
- * A React.useRef() that is initialized with a function. Note that it accepts an optional
8
- * initialization argument, so the initialization function doesn't need to be an inline closure.
24
+ * Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
25
+ * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
9
26
  *
10
- * @usage
11
- * const ref = useRefWithInit(sortColumns, columns)
27
+ * Event handlers are merged and called in right-to-left order (rightmost handler executes first, leftmost last).
28
+ * For React synthetic events, the rightmost handler can prevent prior (left-positioned) handlers from executing
29
+ * by calling `event.preventBaseUIHandler()`. For non-synthetic events (custom events with primitive/object values),
30
+ * all handlers always execute without prevention capability.
31
+ *
32
+ * The `className` prop is merged by concatenating classes in right-to-left order (rightmost class appears first in the string).
33
+ * The `style` prop is merged with rightmost styles overwriting the prior ones.
34
+ *
35
+ * Props can either be provided as objects or as functions that take the previous props as an argument.
36
+ * The function will receive the merged props up to that point (going from left to right):
37
+ * so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
38
+ * The function is responsible for chaining event handlers if needed (i.e. we don't run the merge logic).
39
+ *
40
+ * Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
41
+ * They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
42
+ *
43
+ * @important **`ref` is not merged.**
44
+ * @param a Props object to merge.
45
+ * @param b Props object to merge. The function will overwrite conflicting props from `a`.
46
+ * @param c Props object to merge. The function will overwrite conflicting props from previous parameters.
47
+ * @param d Props object to merge. The function will overwrite conflicting props from previous parameters.
48
+ * @param e Props object to merge. The function will overwrite conflicting props from previous parameters.
49
+ * @returns The merged props.
50
+ * @public
12
51
  */
13
52
 
14
- function useRefWithInit(init, initArg) {
15
- const ref = React.useRef(UNINITIALIZED);
16
- if (ref.current === UNINITIALIZED) {
17
- ref.current = init(initArg);
53
+ function mergeProps(a, b, c, d, e) {
54
+ // We need to mutably own `merged`
55
+ let merged = {
56
+ ...resolvePropsGetter(a, EMPTY_PROPS)
57
+ };
58
+ if (b) {
59
+ merged = mergeOne(merged, b);
18
60
  }
19
- return ref;
61
+ if (c) {
62
+ merged = mergeOne(merged, c);
63
+ }
64
+ if (d) {
65
+ merged = mergeOne(merged, d);
66
+ }
67
+ return merged;
20
68
  }
69
+ /* eslint-enable id-denylist */
21
70
 
22
- let set;
23
- if (process.env.NODE_ENV !== 'production') {
24
- set = new Set();
71
+ /**
72
+ * Merges an arbitrary number of React props using the same logic as {@link mergeProps}.
73
+ * This function accepts an array of props instead of individual arguments.
74
+ *
75
+ * This has slightly lower performance than {@link mergeProps} due to accepting an array
76
+ * instead of a fixed number of arguments. Prefer {@link mergeProps} when merging 5 or
77
+ * fewer prop sets for better performance.
78
+ *
79
+ * @param props Array of props to merge.
80
+ * @returns The merged props.
81
+ * @see mergeProps
82
+ * @public
83
+ */
84
+ function mergePropsN(props) {
85
+ if (props.length === 0) {
86
+ return EMPTY_PROPS;
87
+ }
88
+ if (props.length === 1) {
89
+ return resolvePropsGetter(props[0], EMPTY_PROPS);
90
+ }
91
+
92
+ // We need to mutably own `merged`
93
+ let merged = {
94
+ ...resolvePropsGetter(props[0], EMPTY_PROPS)
95
+ };
96
+ for (let i = 1; i < props.length; i += 1) {
97
+ merged = mergeOne(merged, props[i]);
98
+ }
99
+ return merged;
25
100
  }
26
- function warn(...messages) {
27
- if (process.env.NODE_ENV !== 'production') {
28
- const messageKey = messages.join(' ');
29
- if (!set.has(messageKey)) {
30
- set.add(messageKey);
31
- console.warn(`Base UI: ${messageKey}`);
101
+ function mergeOne(merged, inputProps) {
102
+ if (isPropsGetter(inputProps)) {
103
+ return inputProps(merged);
104
+ }
105
+ return mutablyMergeInto(merged, inputProps);
106
+ }
107
+
108
+ /**
109
+ * Merges two sets of props. In case of conflicts, the external props take precedence.
110
+ */
111
+ function mutablyMergeInto(mergedProps, externalProps) {
112
+ if (!externalProps) {
113
+ return mergedProps;
114
+ }
115
+
116
+ // eslint-disable-next-line guard-for-in
117
+ for (const propName in externalProps) {
118
+ const externalPropValue = externalProps[propName];
119
+ switch (propName) {
120
+ case 'style':
121
+ {
122
+ mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
123
+ break;
124
+ }
125
+ case 'className':
126
+ {
127
+ mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
128
+ break;
129
+ }
130
+ default:
131
+ {
132
+ if (isEventHandler(propName, externalPropValue)) {
133
+ mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
134
+ } else {
135
+ mergedProps[propName] = externalPropValue;
136
+ }
137
+ }
138
+ }
139
+ }
140
+ return mergedProps;
141
+ }
142
+ function isEventHandler(key, value) {
143
+ // This approach is more efficient than using a regex.
144
+ const code0 = key.charCodeAt(0);
145
+ const code1 = key.charCodeAt(1);
146
+ const code2 = key.charCodeAt(2);
147
+ return code0 === 111 /* o */ && code1 === 110 /* n */ && code2 >= 65 /* A */ && code2 <= 90 /* Z */ && (typeof value === 'function' || typeof value === 'undefined');
148
+ }
149
+ function isPropsGetter(inputProps) {
150
+ return typeof inputProps === 'function';
151
+ }
152
+ function resolvePropsGetter(inputProps, previousProps) {
153
+ if (isPropsGetter(inputProps)) {
154
+ return inputProps(previousProps);
155
+ }
156
+ return inputProps ?? EMPTY_PROPS;
157
+ }
158
+ function mergeEventHandlers(ourHandler, theirHandler) {
159
+ if (!theirHandler) {
160
+ return ourHandler;
161
+ }
162
+ if (!ourHandler) {
163
+ return theirHandler;
164
+ }
165
+ return event => {
166
+ if (isSyntheticEvent(event)) {
167
+ const baseUIEvent = event;
168
+ makeEventPreventable(baseUIEvent);
169
+ const result = theirHandler(baseUIEvent);
170
+ if (!baseUIEvent.baseUIHandlerPrevented) {
171
+ ourHandler?.(baseUIEvent);
172
+ }
173
+ return result;
32
174
  }
175
+ const result = theirHandler(event);
176
+ ourHandler?.(event);
177
+ return result;
178
+ };
179
+ }
180
+ function makeEventPreventable(event) {
181
+ event.preventBaseUIHandler = () => {
182
+ event.baseUIHandlerPrevented = true;
183
+ };
184
+ return event;
185
+ }
186
+ function mergeClassNames(ourClassName, theirClassName) {
187
+ if (theirClassName) {
188
+ if (ourClassName) {
189
+ // eslint-disable-next-line prefer-template
190
+ return theirClassName + ' ' + ourClassName;
191
+ }
192
+ return theirClassName;
33
193
  }
194
+ return ourClassName;
195
+ }
196
+ function isSyntheticEvent(event) {
197
+ return event != null && typeof event === 'object' && 'nativeEvent' in event;
34
198
  }
35
199
 
36
200
  /**
@@ -59,6 +223,24 @@ function createFormatErrorMessage(baseUrl, prefix) {
59
223
  */
60
224
  const formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
61
225
 
226
+ const UNINITIALIZED = {};
227
+
228
+ /**
229
+ * A React.useRef() that is initialized with a function. Note that it accepts an optional
230
+ * initialization argument, so the initialization function doesn't need to be an inline closure.
231
+ *
232
+ * @usage
233
+ * const ref = useRefWithInit(sortColumns, columns)
234
+ */
235
+
236
+ function useRefWithInit(init, initArg) {
237
+ const ref = React.useRef(UNINITIALIZED);
238
+ if (ref.current === UNINITIALIZED) {
239
+ ref.current = init(initArg);
240
+ }
241
+ return ref;
242
+ }
243
+
62
244
  /**
63
245
  * Merges refs into a single memoized callback ref or `null`.
64
246
  * This makes sure multiple refs are updated together and have the same value.
@@ -181,20 +363,18 @@ function getReactElementRef(element) {
181
363
  return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
182
364
  }
183
365
 
184
- function mergeObjects(a, b) {
185
- if (a && !b) {
186
- return a;
187
- }
188
- if (!a && b) {
189
- return b;
190
- }
191
- if (a || b) {
192
- return {
193
- ...a,
194
- ...b
195
- };
366
+ let set;
367
+ if (process.env.NODE_ENV !== 'production') {
368
+ set = new Set();
369
+ }
370
+ function warn(...messages) {
371
+ if (process.env.NODE_ENV !== 'production') {
372
+ const messageKey = messages.join(' ');
373
+ if (!set.has(messageKey)) {
374
+ set.add(messageKey);
375
+ console.warn(`Base UI: ${messageKey}`);
376
+ }
196
377
  }
197
- return undefined;
198
378
  }
199
379
 
200
380
  function getStateAttributesProps(state, customMapping) {
@@ -241,186 +421,6 @@ function resolveStyle(style, state) {
241
421
  return typeof style === 'function' ? style(state) : style;
242
422
  }
243
423
 
244
- const EMPTY_PROPS = {};
245
-
246
- /* eslint-disable id-denylist */
247
- /**
248
- * Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
249
- * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
250
- *
251
- * Event handlers are merged and called in right-to-left order (rightmost handler executes first, leftmost last).
252
- * For React synthetic events, the rightmost handler can prevent prior (left-positioned) handlers from executing
253
- * by calling `event.preventBaseUIHandler()`. For non-synthetic events (custom events with primitive/object values),
254
- * all handlers always execute without prevention capability.
255
- *
256
- * The `className` prop is merged by concatenating classes in right-to-left order (rightmost class appears first in the string).
257
- * The `style` prop is merged with rightmost styles overwriting the prior ones.
258
- *
259
- * Props can either be provided as objects or as functions that take the previous props as an argument.
260
- * The function will receive the merged props up to that point (going from left to right):
261
- * so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
262
- * The function is responsible for chaining event handlers if needed (i.e. we don't run the merge logic).
263
- *
264
- * Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
265
- * They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
266
- *
267
- * @important **`ref` is not merged.**
268
- * @param a Props object to merge.
269
- * @param b Props object to merge. The function will overwrite conflicting props from `a`.
270
- * @param c Props object to merge. The function will overwrite conflicting props from previous parameters.
271
- * @param d Props object to merge. The function will overwrite conflicting props from previous parameters.
272
- * @param e Props object to merge. The function will overwrite conflicting props from previous parameters.
273
- * @returns The merged props.
274
- * @public
275
- */
276
-
277
- function mergeProps(a, b, c, d, e) {
278
- // We need to mutably own `merged`
279
- let merged = {
280
- ...resolvePropsGetter(a, EMPTY_PROPS)
281
- };
282
- if (b) {
283
- merged = mergeOne(merged, b);
284
- }
285
- if (c) {
286
- merged = mergeOne(merged, c);
287
- }
288
- if (d) {
289
- merged = mergeOne(merged, d);
290
- }
291
- return merged;
292
- }
293
- /* eslint-enable id-denylist */
294
-
295
- /**
296
- * Merges an arbitrary number of React props using the same logic as {@link mergeProps}.
297
- * This function accepts an array of props instead of individual arguments.
298
- *
299
- * This has slightly lower performance than {@link mergeProps} due to accepting an array
300
- * instead of a fixed number of arguments. Prefer {@link mergeProps} when merging 5 or
301
- * fewer prop sets for better performance.
302
- *
303
- * @param props Array of props to merge.
304
- * @returns The merged props.
305
- * @see mergeProps
306
- * @public
307
- */
308
- function mergePropsN(props) {
309
- if (props.length === 0) {
310
- return EMPTY_PROPS;
311
- }
312
- if (props.length === 1) {
313
- return resolvePropsGetter(props[0], EMPTY_PROPS);
314
- }
315
-
316
- // We need to mutably own `merged`
317
- let merged = {
318
- ...resolvePropsGetter(props[0], EMPTY_PROPS)
319
- };
320
- for (let i = 1; i < props.length; i += 1) {
321
- merged = mergeOne(merged, props[i]);
322
- }
323
- return merged;
324
- }
325
- function mergeOne(merged, inputProps) {
326
- if (isPropsGetter(inputProps)) {
327
- return inputProps(merged);
328
- }
329
- return mutablyMergeInto(merged, inputProps);
330
- }
331
-
332
- /**
333
- * Merges two sets of props. In case of conflicts, the external props take precedence.
334
- */
335
- function mutablyMergeInto(mergedProps, externalProps) {
336
- if (!externalProps) {
337
- return mergedProps;
338
- }
339
-
340
- // eslint-disable-next-line guard-for-in
341
- for (const propName in externalProps) {
342
- const externalPropValue = externalProps[propName];
343
- switch (propName) {
344
- case 'style':
345
- {
346
- mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
347
- break;
348
- }
349
- case 'className':
350
- {
351
- mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
352
- break;
353
- }
354
- default:
355
- {
356
- if (isEventHandler(propName, externalPropValue)) {
357
- mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
358
- } else {
359
- mergedProps[propName] = externalPropValue;
360
- }
361
- }
362
- }
363
- }
364
- return mergedProps;
365
- }
366
- function isEventHandler(key, value) {
367
- // This approach is more efficient than using a regex.
368
- const code0 = key.charCodeAt(0);
369
- const code1 = key.charCodeAt(1);
370
- const code2 = key.charCodeAt(2);
371
- return code0 === 111 /* o */ && code1 === 110 /* n */ && code2 >= 65 /* A */ && code2 <= 90 /* Z */ && (typeof value === 'function' || typeof value === 'undefined');
372
- }
373
- function isPropsGetter(inputProps) {
374
- return typeof inputProps === 'function';
375
- }
376
- function resolvePropsGetter(inputProps, previousProps) {
377
- if (isPropsGetter(inputProps)) {
378
- return inputProps(previousProps);
379
- }
380
- return inputProps ?? EMPTY_PROPS;
381
- }
382
- function mergeEventHandlers(ourHandler, theirHandler) {
383
- if (!theirHandler) {
384
- return ourHandler;
385
- }
386
- if (!ourHandler) {
387
- return theirHandler;
388
- }
389
- return event => {
390
- if (isSyntheticEvent(event)) {
391
- const baseUIEvent = event;
392
- makeEventPreventable(baseUIEvent);
393
- const result = theirHandler(baseUIEvent);
394
- if (!baseUIEvent.baseUIHandlerPrevented) {
395
- ourHandler?.(baseUIEvent);
396
- }
397
- return result;
398
- }
399
- const result = theirHandler(event);
400
- ourHandler?.(event);
401
- return result;
402
- };
403
- }
404
- function makeEventPreventable(event) {
405
- event.preventBaseUIHandler = () => {
406
- event.baseUIHandlerPrevented = true;
407
- };
408
- return event;
409
- }
410
- function mergeClassNames(ourClassName, theirClassName) {
411
- if (theirClassName) {
412
- if (ourClassName) {
413
- // eslint-disable-next-line prefer-template
414
- return theirClassName + ' ' + ourClassName;
415
- }
416
- return theirClassName;
417
- }
418
- return ourClassName;
419
- }
420
- function isSyntheticEvent(event) {
421
- return event != null && typeof event === 'object' && 'nativeEvent' in event;
422
- }
423
-
424
424
  function NOOP() {}
425
425
  const EMPTY_ARRAY = Object.freeze([]);
426
426
  const EMPTY_OBJECT = Object.freeze({});
@@ -566,4 +566,4 @@ function renderTag(Tag, props) {
566
566
  return /*#__PURE__*/React.createElement(Tag, props);
567
567
  }
568
568
 
569
- export { EMPTY_OBJECT as E, NOOP as N, useRefWithInit as a, useMergedRefs as b, makeEventPreventable as c, EMPTY_ARRAY as d, formatErrorMessage as f, isReactVersionAtLeast as i, mergeProps as m, useRenderElement as u };
569
+ export { EMPTY_OBJECT as E, NOOP as N, makeEventPreventable as a, useRefWithInit as b, useMergedRefs as c, EMPTY_ARRAY as d, formatErrorMessage as f, isReactVersionAtLeast as i, mergeProps as m, useRenderElement as u };
@@ -151,13 +151,22 @@
151
151
  "Markdown",
152
152
  "Menu",
153
153
  "Menu.Content",
154
+ "Menu.Group",
155
+ "Menu.GroupLabel",
154
156
  "Menu.Header",
155
157
  "Menu.HeaderLabel",
156
158
  "Menu.Item",
157
159
  "Menu.ItemIcon",
158
160
  "Menu.ItemLabel",
161
+ "Menu.ItemPrefix",
162
+ "Menu.ItemSuffix",
163
+ "Menu.RadioGroup",
164
+ "Menu.RadioItem",
159
165
  "Menu.Section",
160
166
  "Menu.Separator",
167
+ "Menu.Submenu",
168
+ "Menu.SubmenuContent",
169
+ "Menu.SubmenuTrigger",
161
170
  "Menu.Trigger",
162
171
  "Modal",
163
172
  "Modal.Actions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "7.8.0",
3
+ "version": "7.9.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -583,5 +583,5 @@
583
583
  "> 1%",
584
584
  "IE 10"
585
585
  ],
586
- "gitHead": "0286717f5c0aa2940052d0d6254f4f946be03583"
586
+ "gitHead": "17a48b8f879afe6571af0e2a4065178ddefd7084"
587
587
  }