@jobber/components 8.20.2 → 8.21.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 (55) hide show
  1. package/dist/BottomSheet-cjs.js +9 -58
  2. package/dist/BottomSheet-es.js +2 -47
  3. package/dist/Card/index.cjs +4 -0
  4. package/dist/Card/index.mjs +4 -0
  5. package/dist/ComboboxChipRemove-cjs.js +3418 -0
  6. package/dist/ComboboxChipRemove-es.js +3366 -0
  7. package/dist/ComboboxPrimitive-cjs.js +170 -0
  8. package/dist/ComboboxPrimitive-es.js +168 -0
  9. package/dist/DataDump/index.cjs +4 -0
  10. package/dist/DataDump/index.mjs +4 -0
  11. package/dist/InputNumberExperimental-cjs.js +45 -44
  12. package/dist/InputNumberExperimental-es.js +3 -2
  13. package/dist/InternalBackdrop-cjs.js +4278 -0
  14. package/dist/InternalBackdrop-es.js +4204 -0
  15. package/dist/Menu/index.cjs +4 -0
  16. package/dist/Menu/index.mjs +4 -0
  17. package/dist/Menu-cjs.js +9 -8
  18. package/dist/Menu-es.js +2 -1
  19. package/dist/MenuSubmenuTrigger-cjs.js +208 -1969
  20. package/dist/MenuSubmenuTrigger-es.js +7 -1759
  21. package/dist/NumberFieldInput-cjs.js +56 -439
  22. package/dist/NumberFieldInput-es.js +6 -376
  23. package/dist/Page/index.cjs +4 -0
  24. package/dist/Page/index.mjs +4 -0
  25. package/dist/ScrollAreaViewport-cjs.js +108 -4356
  26. package/dist/ScrollAreaViewport-es.js +6 -4201
  27. package/dist/buttonRenderAdapter-cjs.js +56 -0
  28. package/dist/buttonRenderAdapter-es.js +51 -0
  29. package/dist/clamp-cjs.js +0 -1194
  30. package/dist/clamp-es.js +1 -1091
  31. package/dist/docs/empty-states/empty-states.md +29 -0
  32. package/dist/index.cjs +4 -0
  33. package/dist/index.mjs +4 -0
  34. package/dist/primitives/BottomSheet/index.cjs +5 -2
  35. package/dist/primitives/BottomSheet/index.mjs +5 -2
  36. package/dist/primitives/ComboboxPrimitive/ComboboxPrimitive.d.ts +32 -0
  37. package/dist/primitives/ComboboxPrimitive/ComboboxPrimitive.types.d.ts +30 -0
  38. package/dist/primitives/ComboboxPrimitive/index.cjs +28 -0
  39. package/dist/primitives/ComboboxPrimitive/index.d.ts +2 -0
  40. package/dist/primitives/ComboboxPrimitive/index.mjs +22 -0
  41. package/dist/primitives/InputNumberExperimental/index.cjs +4 -2
  42. package/dist/primitives/InputNumberExperimental/index.mjs +4 -2
  43. package/dist/primitives/index.cjs +11 -2
  44. package/dist/primitives/index.d.ts +1 -0
  45. package/dist/primitives/index.mjs +10 -2
  46. package/dist/styles.css +767 -0
  47. package/dist/unstyledPrimitives/index.cjs +237 -3588
  48. package/dist/unstyledPrimitives/index.mjs +96 -3447
  49. package/dist/useButton-cjs.js +1196 -0
  50. package/dist/useButton-es.js +1091 -0
  51. package/dist/useCompositeListItem-cjs.js +1792 -0
  52. package/dist/useCompositeListItem-es.js +1762 -0
  53. package/dist/useLabel-cjs.js +411 -0
  54. package/dist/useLabel-es.js +378 -0
  55. package/package.json +2 -2
@@ -0,0 +1,411 @@
1
+ 'use strict';
2
+
3
+ var ReactDOM = require('react-dom');
4
+ var useButton = require('./useButton-cjs.js');
5
+ var React = require('react');
6
+ var useRenderElement = require('./useRenderElement-cjs.js');
7
+ var floatingUi_utils_dom = require('./floating-ui.utils.dom-cjs.js');
8
+
9
+ function _interopNamespaceDefault(e) {
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
27
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
28
+
29
+ let FieldControlDataAttributes = /*#__PURE__*/function (FieldControlDataAttributes) {
30
+ /**
31
+ * Present when the field is disabled.
32
+ */
33
+ FieldControlDataAttributes["disabled"] = "data-disabled";
34
+ /**
35
+ * Present when the field is in valid state.
36
+ */
37
+ FieldControlDataAttributes["valid"] = "data-valid";
38
+ /**
39
+ * Present when the field is in invalid state.
40
+ */
41
+ FieldControlDataAttributes["invalid"] = "data-invalid";
42
+ /**
43
+ * Present when the field has been touched.
44
+ */
45
+ FieldControlDataAttributes["touched"] = "data-touched";
46
+ /**
47
+ * Present when the field's value has changed.
48
+ */
49
+ FieldControlDataAttributes["dirty"] = "data-dirty";
50
+ /**
51
+ * Present when the field is filled.
52
+ */
53
+ FieldControlDataAttributes["filled"] = "data-filled";
54
+ /**
55
+ * Present when the field control is focused.
56
+ */
57
+ FieldControlDataAttributes["focused"] = "data-focused";
58
+ return FieldControlDataAttributes;
59
+ }({});
60
+
61
+ const DEFAULT_VALIDITY_STATE = {
62
+ badInput: false,
63
+ customError: false,
64
+ patternMismatch: false,
65
+ rangeOverflow: false,
66
+ rangeUnderflow: false,
67
+ stepMismatch: false,
68
+ tooLong: false,
69
+ tooShort: false,
70
+ typeMismatch: false,
71
+ valid: null,
72
+ valueMissing: false
73
+ };
74
+ const DEFAULT_FIELD_STATE_ATTRIBUTES = {
75
+ valid: null,
76
+ touched: false,
77
+ dirty: false,
78
+ filled: false,
79
+ focused: false
80
+ };
81
+ const DEFAULT_FIELD_ROOT_STATE = {
82
+ disabled: false,
83
+ ...DEFAULT_FIELD_STATE_ATTRIBUTES
84
+ };
85
+ const fieldValidityMapping = {
86
+ valid(value) {
87
+ if (value === null) {
88
+ return null;
89
+ }
90
+ if (value) {
91
+ return {
92
+ [FieldControlDataAttributes.valid]: ''
93
+ };
94
+ }
95
+ return {
96
+ [FieldControlDataAttributes.invalid]: ''
97
+ };
98
+ }
99
+ };
100
+
101
+ const FieldRootContext = /*#__PURE__*/React__namespace.createContext({
102
+ invalid: undefined,
103
+ name: undefined,
104
+ validityData: {
105
+ state: DEFAULT_VALIDITY_STATE,
106
+ errors: [],
107
+ error: '',
108
+ value: '',
109
+ initialValue: null
110
+ },
111
+ setValidityData: useRenderElement.NOOP,
112
+ disabled: undefined,
113
+ touched: DEFAULT_FIELD_STATE_ATTRIBUTES.touched,
114
+ setTouched: useRenderElement.NOOP,
115
+ dirty: DEFAULT_FIELD_STATE_ATTRIBUTES.dirty,
116
+ setDirty: useRenderElement.NOOP,
117
+ filled: DEFAULT_FIELD_STATE_ATTRIBUTES.filled,
118
+ setFilled: useRenderElement.NOOP,
119
+ focused: DEFAULT_FIELD_STATE_ATTRIBUTES.focused,
120
+ setFocused: useRenderElement.NOOP,
121
+ validate: () => null,
122
+ validationMode: 'onSubmit',
123
+ validationDebounceTime: 0,
124
+ shouldValidateOnChange: () => false,
125
+ state: DEFAULT_FIELD_ROOT_STATE,
126
+ markedDirtyRef: {
127
+ current: false
128
+ },
129
+ validation: {
130
+ getValidationProps: (props = useRenderElement.EMPTY_OBJECT) => props,
131
+ getInputValidationProps: (props = useRenderElement.EMPTY_OBJECT) => props,
132
+ inputRef: {
133
+ current: null
134
+ },
135
+ commit: async () => {}
136
+ }
137
+ });
138
+ if (process.env.NODE_ENV !== "production") FieldRootContext.displayName = "FieldRootContext";
139
+ function useFieldRootContext(optional = true) {
140
+ const context = React__namespace.useContext(FieldRootContext);
141
+ if (context.setValidityData === useRenderElement.NOOP && !optional) {
142
+ throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>.' : useRenderElement.formatErrorMessage(28));
143
+ }
144
+ return context;
145
+ }
146
+
147
+ /**
148
+ * Combines the field's client-side, stateful validity data with the external invalid state to
149
+ * determine the field's true validity.
150
+ */
151
+ function getCombinedFieldValidityData(validityData, invalid) {
152
+ return {
153
+ ...validityData,
154
+ state: {
155
+ ...validityData.state,
156
+ valid: !invalid && validityData.state.valid
157
+ }
158
+ };
159
+ }
160
+
161
+ const FormContext = /*#__PURE__*/React__namespace.createContext({
162
+ formRef: {
163
+ current: {
164
+ fields: new Map()
165
+ }
166
+ },
167
+ errors: {},
168
+ clearErrors: useRenderElement.NOOP,
169
+ validationMode: 'onSubmit',
170
+ submitAttemptedRef: {
171
+ current: false
172
+ }
173
+ });
174
+ if (process.env.NODE_ENV !== "production") FormContext.displayName = "FormContext";
175
+ function useFormContext() {
176
+ return React__namespace.useContext(FormContext);
177
+ }
178
+
179
+ function useField(params) {
180
+ const {
181
+ enabled = true,
182
+ value,
183
+ id,
184
+ name,
185
+ controlRef,
186
+ commit
187
+ } = params;
188
+ const {
189
+ formRef
190
+ } = useFormContext();
191
+ const {
192
+ invalid,
193
+ markedDirtyRef,
194
+ validityData,
195
+ setValidityData
196
+ } = useFieldRootContext();
197
+ const getValue = useButton.useStableCallback(params.getValue);
198
+ useButton.useIsoLayoutEffect(() => {
199
+ if (!enabled) {
200
+ return;
201
+ }
202
+ let initialValue = value;
203
+ if (initialValue === undefined) {
204
+ initialValue = getValue();
205
+ }
206
+ if (validityData.initialValue === null && initialValue !== null) {
207
+ setValidityData(prev => ({
208
+ ...prev,
209
+ initialValue
210
+ }));
211
+ }
212
+ }, [enabled, setValidityData, value, validityData.initialValue, getValue]);
213
+ useButton.useIsoLayoutEffect(() => {
214
+ if (!enabled || !id) {
215
+ return;
216
+ }
217
+ formRef.current.fields.set(id, {
218
+ getValue,
219
+ name,
220
+ controlRef,
221
+ validityData: getCombinedFieldValidityData(validityData, invalid),
222
+ validate(flushSync = true) {
223
+ let nextValue = value;
224
+ if (nextValue === undefined) {
225
+ nextValue = getValue();
226
+ }
227
+ markedDirtyRef.current = true;
228
+ if (!flushSync) {
229
+ commit(nextValue);
230
+ } else {
231
+ // Synchronously update the validity state so the submit event can be prevented.
232
+ ReactDOM__namespace.flushSync(() => commit(nextValue));
233
+ }
234
+ }
235
+ });
236
+ }, [commit, controlRef, enabled, formRef, getValue, id, invalid, markedDirtyRef, name, validityData, value]);
237
+ useButton.useIsoLayoutEffect(() => {
238
+ const fields = formRef.current.fields;
239
+ return () => {
240
+ if (id) {
241
+ fields.delete(id);
242
+ }
243
+ };
244
+ }, [formRef, id]);
245
+ }
246
+
247
+ /**
248
+ * A context for providing [labelable elements](https://html.spec.whatwg.org/multipage/forms.html#category-label)\
249
+ * with an accessible name (label) and description.
250
+ */
251
+ const LabelableContext = /*#__PURE__*/React__namespace.createContext({
252
+ controlId: undefined,
253
+ registerControlId: useRenderElement.NOOP,
254
+ labelId: undefined,
255
+ setLabelId: useRenderElement.NOOP,
256
+ messageIds: [],
257
+ setMessageIds: useRenderElement.NOOP,
258
+ getDescriptionProps: externalProps => externalProps
259
+ });
260
+ if (process.env.NODE_ENV !== "production") LabelableContext.displayName = "LabelableContext";
261
+ function useLabelableContext() {
262
+ return React__namespace.useContext(LabelableContext);
263
+ }
264
+
265
+ function useLabelableId(params = {}) {
266
+ const {
267
+ id,
268
+ implicit = false,
269
+ controlRef
270
+ } = params;
271
+ const {
272
+ controlId,
273
+ registerControlId
274
+ } = useLabelableContext();
275
+ const defaultId = useButton.useBaseUiId(id);
276
+ const controlIdForEffect = implicit ? controlId : undefined;
277
+ const controlSourceRef = useRenderElement.useRefWithInit(() => Symbol('labelable-control'));
278
+ const hasRegisteredRef = React__namespace.useRef(false);
279
+ const hadExplicitIdRef = React__namespace.useRef(id != null);
280
+ const unregisterControlId = useButton.useStableCallback(() => {
281
+ if (!hasRegisteredRef.current || registerControlId === useRenderElement.NOOP) {
282
+ return;
283
+ }
284
+ hasRegisteredRef.current = false;
285
+ registerControlId(controlSourceRef.current, undefined);
286
+ });
287
+ useButton.useIsoLayoutEffect(() => {
288
+ if (registerControlId === useRenderElement.NOOP) {
289
+ return undefined;
290
+ }
291
+ let nextId;
292
+ if (implicit) {
293
+ const elem = controlRef?.current;
294
+ if (floatingUi_utils_dom.isElement(elem) && elem.closest('label') != null) {
295
+ nextId = id ?? null;
296
+ } else {
297
+ nextId = controlIdForEffect ?? defaultId;
298
+ }
299
+ } else if (id != null) {
300
+ hadExplicitIdRef.current = true;
301
+ nextId = id;
302
+ } else if (hadExplicitIdRef.current) {
303
+ nextId = defaultId;
304
+ } else {
305
+ unregisterControlId();
306
+ return undefined;
307
+ }
308
+ if (nextId === undefined) {
309
+ unregisterControlId();
310
+ return undefined;
311
+ }
312
+ hasRegisteredRef.current = true;
313
+ registerControlId(controlSourceRef.current, nextId);
314
+ return undefined;
315
+ }, [id, controlRef, controlIdForEffect, registerControlId, implicit, defaultId, controlSourceRef, unregisterControlId]);
316
+ React__namespace.useEffect(() => {
317
+ return unregisterControlId;
318
+ }, [unregisterControlId]);
319
+ return controlId ?? defaultId;
320
+ }
321
+
322
+ function useRegisteredLabelId(idProp, setLabelId) {
323
+ const id = useButton.useBaseUiId(idProp);
324
+ useButton.useIsoLayoutEffect(() => {
325
+ setLabelId(id);
326
+ return () => {
327
+ setLabelId(undefined);
328
+ };
329
+ }, [id, setLabelId]);
330
+ return id;
331
+ }
332
+
333
+ function useLabel(params = {}) {
334
+ const {
335
+ id: idProp,
336
+ fallbackControlId,
337
+ native = false,
338
+ setLabelId: setLabelIdProp,
339
+ focusControl: focusControlProp
340
+ } = params;
341
+ const {
342
+ controlId: contextControlId,
343
+ setLabelId: setContextLabelId
344
+ } = useLabelableContext();
345
+ const syncLabelId = useButton.useStableCallback(nextLabelId => {
346
+ setContextLabelId(nextLabelId);
347
+ setLabelIdProp?.(nextLabelId);
348
+ });
349
+ const id = useRegisteredLabelId(idProp, syncLabelId);
350
+ const resolvedControlId = contextControlId ?? fallbackControlId;
351
+ function focusControl(event) {
352
+ if (focusControlProp) {
353
+ focusControlProp(event, resolvedControlId);
354
+ return;
355
+ }
356
+ if (!resolvedControlId) {
357
+ return;
358
+ }
359
+ const controlElement = useButton.ownerDocument(event.currentTarget).getElementById(resolvedControlId);
360
+ if (floatingUi_utils_dom.isHTMLElement(controlElement)) {
361
+ focusElementWithVisible(controlElement);
362
+ }
363
+ }
364
+ function handleInteraction(event) {
365
+ const target = useButton.getTarget(event.nativeEvent);
366
+ if (target?.closest('button,input,select,textarea')) {
367
+ return;
368
+ }
369
+
370
+ // Prevent text selection when double clicking label.
371
+ if (!event.defaultPrevented && event.detail > 1) {
372
+ event.preventDefault();
373
+ }
374
+ if (native) {
375
+ return;
376
+ }
377
+ focusControl(event);
378
+ }
379
+ return native ? {
380
+ id,
381
+ htmlFor: resolvedControlId ?? undefined,
382
+ onMouseDown: handleInteraction
383
+ } : {
384
+ id,
385
+ onClick: handleInteraction,
386
+ onPointerDown(event) {
387
+ event.preventDefault();
388
+ }
389
+ };
390
+ }
391
+ function focusElementWithVisible(element) {
392
+ element.focus({
393
+ // Available from Chrome 144+ (January 2026).
394
+ // Safari and Firefox already support it.
395
+ // @ts-expect-error not available in types yet
396
+ focusVisible: true
397
+ });
398
+ }
399
+
400
+ exports.DEFAULT_FIELD_STATE_ATTRIBUTES = DEFAULT_FIELD_STATE_ATTRIBUTES;
401
+ exports.DEFAULT_VALIDITY_STATE = DEFAULT_VALIDITY_STATE;
402
+ exports.FieldRootContext = FieldRootContext;
403
+ exports.LabelableContext = LabelableContext;
404
+ exports.fieldValidityMapping = fieldValidityMapping;
405
+ exports.getCombinedFieldValidityData = getCombinedFieldValidityData;
406
+ exports.useField = useField;
407
+ exports.useFieldRootContext = useFieldRootContext;
408
+ exports.useFormContext = useFormContext;
409
+ exports.useLabel = useLabel;
410
+ exports.useLabelableContext = useLabelableContext;
411
+ exports.useLabelableId = useLabelableId;