@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
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var floatingUi_utils_dom = require('./floating-ui.utils.dom-cjs.js');
4
- var clamp = require('./clamp-cjs.js');
5
3
  var React = require('react');
4
+ var useButton = require('./useButton-cjs.js');
6
5
  var useRenderElement = require('./useRenderElement-cjs.js');
6
+ var useLabel = require('./useLabel-cjs.js');
7
+ var clamp = require('./clamp-cjs.js');
7
8
  var jsxRuntime = require('react/jsx-runtime');
8
- var ReactDOM = require('react-dom');
9
+ var floatingUi_utils_dom = require('./floating-ui.utils.dom-cjs.js');
9
10
 
10
11
  function _interopNamespaceDefault(e) {
11
12
  var n = Object.create(null);
@@ -25,7 +26,6 @@ function _interopNamespaceDefault(e) {
25
26
  }
26
27
 
27
28
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
28
- var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
29
29
 
30
30
  /**
31
31
  * Returns a function that forces a rerender.
@@ -37,377 +37,6 @@ function useForcedRerendering() {
37
37
  }, []);
38
38
  }
39
39
 
40
- let FieldControlDataAttributes = /*#__PURE__*/function (FieldControlDataAttributes) {
41
- /**
42
- * Present when the field is disabled.
43
- */
44
- FieldControlDataAttributes["disabled"] = "data-disabled";
45
- /**
46
- * Present when the field is in valid state.
47
- */
48
- FieldControlDataAttributes["valid"] = "data-valid";
49
- /**
50
- * Present when the field is in invalid state.
51
- */
52
- FieldControlDataAttributes["invalid"] = "data-invalid";
53
- /**
54
- * Present when the field has been touched.
55
- */
56
- FieldControlDataAttributes["touched"] = "data-touched";
57
- /**
58
- * Present when the field's value has changed.
59
- */
60
- FieldControlDataAttributes["dirty"] = "data-dirty";
61
- /**
62
- * Present when the field is filled.
63
- */
64
- FieldControlDataAttributes["filled"] = "data-filled";
65
- /**
66
- * Present when the field control is focused.
67
- */
68
- FieldControlDataAttributes["focused"] = "data-focused";
69
- return FieldControlDataAttributes;
70
- }({});
71
-
72
- const DEFAULT_VALIDITY_STATE = {
73
- badInput: false,
74
- customError: false,
75
- patternMismatch: false,
76
- rangeOverflow: false,
77
- rangeUnderflow: false,
78
- stepMismatch: false,
79
- tooLong: false,
80
- tooShort: false,
81
- typeMismatch: false,
82
- valid: null,
83
- valueMissing: false
84
- };
85
- const DEFAULT_FIELD_STATE_ATTRIBUTES = {
86
- valid: null,
87
- touched: false,
88
- dirty: false,
89
- filled: false,
90
- focused: false
91
- };
92
- const DEFAULT_FIELD_ROOT_STATE = {
93
- disabled: false,
94
- ...DEFAULT_FIELD_STATE_ATTRIBUTES
95
- };
96
- const fieldValidityMapping = {
97
- valid(value) {
98
- if (value === null) {
99
- return null;
100
- }
101
- if (value) {
102
- return {
103
- [FieldControlDataAttributes.valid]: ''
104
- };
105
- }
106
- return {
107
- [FieldControlDataAttributes.invalid]: ''
108
- };
109
- }
110
- };
111
-
112
- const FieldRootContext = /*#__PURE__*/React__namespace.createContext({
113
- invalid: undefined,
114
- name: undefined,
115
- validityData: {
116
- state: DEFAULT_VALIDITY_STATE,
117
- errors: [],
118
- error: '',
119
- value: '',
120
- initialValue: null
121
- },
122
- setValidityData: useRenderElement.NOOP,
123
- disabled: undefined,
124
- touched: DEFAULT_FIELD_STATE_ATTRIBUTES.touched,
125
- setTouched: useRenderElement.NOOP,
126
- dirty: DEFAULT_FIELD_STATE_ATTRIBUTES.dirty,
127
- setDirty: useRenderElement.NOOP,
128
- filled: DEFAULT_FIELD_STATE_ATTRIBUTES.filled,
129
- setFilled: useRenderElement.NOOP,
130
- focused: DEFAULT_FIELD_STATE_ATTRIBUTES.focused,
131
- setFocused: useRenderElement.NOOP,
132
- validate: () => null,
133
- validationMode: 'onSubmit',
134
- validationDebounceTime: 0,
135
- shouldValidateOnChange: () => false,
136
- state: DEFAULT_FIELD_ROOT_STATE,
137
- markedDirtyRef: {
138
- current: false
139
- },
140
- validation: {
141
- getValidationProps: (props = useRenderElement.EMPTY_OBJECT) => props,
142
- getInputValidationProps: (props = useRenderElement.EMPTY_OBJECT) => props,
143
- inputRef: {
144
- current: null
145
- },
146
- commit: async () => {}
147
- }
148
- });
149
- if (process.env.NODE_ENV !== "production") FieldRootContext.displayName = "FieldRootContext";
150
- function useFieldRootContext(optional = true) {
151
- const context = React__namespace.useContext(FieldRootContext);
152
- if (context.setValidityData === useRenderElement.NOOP && !optional) {
153
- throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>.' : useRenderElement.formatErrorMessage(28));
154
- }
155
- return context;
156
- }
157
-
158
- /**
159
- * Combines the field's client-side, stateful validity data with the external invalid state to
160
- * determine the field's true validity.
161
- */
162
- function getCombinedFieldValidityData(validityData, invalid) {
163
- return {
164
- ...validityData,
165
- state: {
166
- ...validityData.state,
167
- valid: !invalid && validityData.state.valid
168
- }
169
- };
170
- }
171
-
172
- const FormContext = /*#__PURE__*/React__namespace.createContext({
173
- formRef: {
174
- current: {
175
- fields: new Map()
176
- }
177
- },
178
- errors: {},
179
- clearErrors: useRenderElement.NOOP,
180
- validationMode: 'onSubmit',
181
- submitAttemptedRef: {
182
- current: false
183
- }
184
- });
185
- if (process.env.NODE_ENV !== "production") FormContext.displayName = "FormContext";
186
- function useFormContext() {
187
- return React__namespace.useContext(FormContext);
188
- }
189
-
190
- function useField(params) {
191
- const {
192
- enabled = true,
193
- value,
194
- id,
195
- name,
196
- controlRef,
197
- commit
198
- } = params;
199
- const {
200
- formRef
201
- } = useFormContext();
202
- const {
203
- invalid,
204
- markedDirtyRef,
205
- validityData,
206
- setValidityData
207
- } = useFieldRootContext();
208
- const getValue = clamp.useStableCallback(params.getValue);
209
- clamp.useIsoLayoutEffect(() => {
210
- if (!enabled) {
211
- return;
212
- }
213
- let initialValue = value;
214
- if (initialValue === undefined) {
215
- initialValue = getValue();
216
- }
217
- if (validityData.initialValue === null && initialValue !== null) {
218
- setValidityData(prev => ({
219
- ...prev,
220
- initialValue
221
- }));
222
- }
223
- }, [enabled, setValidityData, value, validityData.initialValue, getValue]);
224
- clamp.useIsoLayoutEffect(() => {
225
- if (!enabled || !id) {
226
- return;
227
- }
228
- formRef.current.fields.set(id, {
229
- getValue,
230
- name,
231
- controlRef,
232
- validityData: getCombinedFieldValidityData(validityData, invalid),
233
- validate(flushSync = true) {
234
- let nextValue = value;
235
- if (nextValue === undefined) {
236
- nextValue = getValue();
237
- }
238
- markedDirtyRef.current = true;
239
- if (!flushSync) {
240
- commit(nextValue);
241
- } else {
242
- // Synchronously update the validity state so the submit event can be prevented.
243
- ReactDOM__namespace.flushSync(() => commit(nextValue));
244
- }
245
- }
246
- });
247
- }, [commit, controlRef, enabled, formRef, getValue, id, invalid, markedDirtyRef, name, validityData, value]);
248
- clamp.useIsoLayoutEffect(() => {
249
- const fields = formRef.current.fields;
250
- return () => {
251
- if (id) {
252
- fields.delete(id);
253
- }
254
- };
255
- }, [formRef, id]);
256
- }
257
-
258
- /**
259
- * A context for providing [labelable elements](https://html.spec.whatwg.org/multipage/forms.html#category-label)\
260
- * with an accessible name (label) and description.
261
- */
262
- const LabelableContext = /*#__PURE__*/React__namespace.createContext({
263
- controlId: undefined,
264
- registerControlId: useRenderElement.NOOP,
265
- labelId: undefined,
266
- setLabelId: useRenderElement.NOOP,
267
- messageIds: [],
268
- setMessageIds: useRenderElement.NOOP,
269
- getDescriptionProps: externalProps => externalProps
270
- });
271
- if (process.env.NODE_ENV !== "production") LabelableContext.displayName = "LabelableContext";
272
- function useLabelableContext() {
273
- return React__namespace.useContext(LabelableContext);
274
- }
275
-
276
- function useLabelableId(params = {}) {
277
- const {
278
- id,
279
- implicit = false,
280
- controlRef
281
- } = params;
282
- const {
283
- controlId,
284
- registerControlId
285
- } = useLabelableContext();
286
- const defaultId = clamp.useBaseUiId(id);
287
- const controlIdForEffect = implicit ? controlId : undefined;
288
- const controlSourceRef = useRenderElement.useRefWithInit(() => Symbol('labelable-control'));
289
- const hasRegisteredRef = React__namespace.useRef(false);
290
- const hadExplicitIdRef = React__namespace.useRef(id != null);
291
- const unregisterControlId = clamp.useStableCallback(() => {
292
- if (!hasRegisteredRef.current || registerControlId === useRenderElement.NOOP) {
293
- return;
294
- }
295
- hasRegisteredRef.current = false;
296
- registerControlId(controlSourceRef.current, undefined);
297
- });
298
- clamp.useIsoLayoutEffect(() => {
299
- if (registerControlId === useRenderElement.NOOP) {
300
- return undefined;
301
- }
302
- let nextId;
303
- if (implicit) {
304
- const elem = controlRef?.current;
305
- if (floatingUi_utils_dom.isElement(elem) && elem.closest('label') != null) {
306
- nextId = id ?? null;
307
- } else {
308
- nextId = controlIdForEffect ?? defaultId;
309
- }
310
- } else if (id != null) {
311
- hadExplicitIdRef.current = true;
312
- nextId = id;
313
- } else if (hadExplicitIdRef.current) {
314
- nextId = defaultId;
315
- } else {
316
- unregisterControlId();
317
- return undefined;
318
- }
319
- if (nextId === undefined) {
320
- unregisterControlId();
321
- return undefined;
322
- }
323
- hasRegisteredRef.current = true;
324
- registerControlId(controlSourceRef.current, nextId);
325
- return undefined;
326
- }, [id, controlRef, controlIdForEffect, registerControlId, implicit, defaultId, controlSourceRef, unregisterControlId]);
327
- React__namespace.useEffect(() => {
328
- return unregisterControlId;
329
- }, [unregisterControlId]);
330
- return controlId ?? defaultId;
331
- }
332
-
333
- function useRegisteredLabelId(idProp, setLabelId) {
334
- const id = clamp.useBaseUiId(idProp);
335
- clamp.useIsoLayoutEffect(() => {
336
- setLabelId(id);
337
- return () => {
338
- setLabelId(undefined);
339
- };
340
- }, [id, setLabelId]);
341
- return id;
342
- }
343
-
344
- function useLabel(params = {}) {
345
- const {
346
- id: idProp,
347
- fallbackControlId,
348
- native = false,
349
- setLabelId: setLabelIdProp,
350
- focusControl: focusControlProp
351
- } = params;
352
- const {
353
- controlId: contextControlId,
354
- setLabelId: setContextLabelId
355
- } = useLabelableContext();
356
- const syncLabelId = clamp.useStableCallback(nextLabelId => {
357
- setContextLabelId(nextLabelId);
358
- setLabelIdProp?.(nextLabelId);
359
- });
360
- const id = useRegisteredLabelId(idProp, syncLabelId);
361
- const resolvedControlId = contextControlId ?? fallbackControlId;
362
- function focusControl(event) {
363
- if (focusControlProp) {
364
- focusControlProp(event, resolvedControlId);
365
- return;
366
- }
367
- if (!resolvedControlId) {
368
- return;
369
- }
370
- const controlElement = clamp.ownerDocument(event.currentTarget).getElementById(resolvedControlId);
371
- if (floatingUi_utils_dom.isHTMLElement(controlElement)) {
372
- focusElementWithVisible(controlElement);
373
- }
374
- }
375
- function handleInteraction(event) {
376
- const target = clamp.getTarget(event.nativeEvent);
377
- if (target?.closest('button,input,select,textarea')) {
378
- return;
379
- }
380
-
381
- // Prevent text selection when double clicking label.
382
- if (!event.defaultPrevented && event.detail > 1) {
383
- event.preventDefault();
384
- }
385
- if (native) {
386
- return;
387
- }
388
- focusControl(event);
389
- }
390
- return native ? {
391
- id,
392
- htmlFor: resolvedControlId ?? undefined,
393
- onMouseDown: handleInteraction
394
- } : {
395
- id,
396
- onClick: handleInteraction,
397
- onPointerDown(event) {
398
- event.preventDefault();
399
- }
400
- };
401
- }
402
- function focusElementWithVisible(element) {
403
- element.focus({
404
- // Available from Chrome 144+ (January 2026).
405
- // Safari and Firefox already support it.
406
- // @ts-expect-error not available in types yet
407
- focusVisible: true
408
- });
409
- }
410
-
411
40
  const cache = new Map();
412
41
  function getFormatter(locale, options) {
413
42
  const optionsString = JSON.stringify({
@@ -436,7 +65,7 @@ function formatNumberMaxPrecision(value, locale, options) {
436
65
  }
437
66
 
438
67
  const EMPTY = 0;
439
- class Interval extends clamp.Timeout {
68
+ class Interval extends useButton.Timeout {
440
69
  static create() {
441
70
  return new Interval();
442
71
  }
@@ -463,7 +92,7 @@ class Interval extends clamp.Timeout {
463
92
  */
464
93
  function useInterval() {
465
94
  const timeout = useRenderElement.useRefWithInit(Interval.create).current;
466
- clamp.useOnMount(timeout.disposeEffect);
95
+ useButton.useOnMount(timeout.disposeEffect);
467
96
  return timeout;
468
97
  }
469
98
 
@@ -480,7 +109,7 @@ function useNumberFieldRootContext() {
480
109
  const stateAttributesMapping$1 = {
481
110
  inputValue: () => null,
482
111
  value: () => null,
483
- ...fieldValidityMapping
112
+ ...useLabel.fieldValidityMapping
484
113
  };
485
114
 
486
115
  const HAN_NUMERALS = ['零', '〇', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
@@ -815,7 +444,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
815
444
  state: fieldState,
816
445
  validation,
817
446
  shouldValidateOnChange
818
- } = useFieldRootContext();
447
+ } = useLabel.useFieldRootContext();
819
448
  const disabled = fieldDisabled || disabledProp;
820
449
  const name = fieldName ?? nameProp;
821
450
  const step = stepProp === 'any' ? 1 : stepProp;
@@ -826,30 +455,30 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
826
455
  const formatStyle = format?.style;
827
456
  const inputRef = React__namespace.useRef(null);
828
457
  const hiddenInputRef = useRenderElement.useMergedRefs(inputRefProp, validation.inputRef);
829
- const id = useLabelableId({
458
+ const id = useLabel.useLabelableId({
830
459
  id: idProp
831
460
  });
832
- const [valueUnwrapped, setValueUnwrapped] = clamp.useControlled({
461
+ const [valueUnwrapped, setValueUnwrapped] = useButton.useControlled({
833
462
  controlled: valueProp,
834
463
  default: defaultValue,
835
464
  name: 'NumberField',
836
465
  state: 'value'
837
466
  });
838
467
  const value = valueUnwrapped ?? null;
839
- const valueRef = clamp.useValueAsRef(value);
840
- clamp.useIsoLayoutEffect(() => {
468
+ const valueRef = useButton.useValueAsRef(value);
469
+ useButton.useIsoLayoutEffect(() => {
841
470
  setFilled(value !== null);
842
471
  }, [setFilled, value]);
843
472
  const forceRender = useForcedRerendering();
844
- const formatOptionsRef = clamp.useValueAsRef(format);
473
+ const formatOptionsRef = useButton.useValueAsRef(format);
845
474
  const hasPendingCommitRef = React__namespace.useRef(false);
846
- const onValueCommitted = clamp.useStableCallback((nextValue, eventDetails) => {
475
+ const onValueCommitted = useButton.useStableCallback((nextValue, eventDetails) => {
847
476
  hasPendingCommitRef.current = false;
848
477
  onValueCommittedProp?.(nextValue, eventDetails);
849
478
  });
850
- const startTickTimeout = clamp.useTimeout();
479
+ const startTickTimeout = useButton.useTimeout();
851
480
  const tickInterval = useInterval();
852
- const intentionalTouchCheckTimeout = clamp.useTimeout();
481
+ const intentionalTouchCheckTimeout = useButton.useTimeout();
853
482
  const isPressedRef = React__namespace.useRef(false);
854
483
  const movesAfterTouchRef = React__namespace.useRef(0);
855
484
  const allowInputSyncRef = React__namespace.useRef(true);
@@ -867,7 +496,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
867
496
  return formatNumber(value, locale, format);
868
497
  });
869
498
  const [inputMode, setInputMode] = React__namespace.useState('numeric');
870
- const getAllowedNonNumericKeys = clamp.useStableCallback(() => {
499
+ const getAllowedNonNumericKeys = useButton.useStableCallback(() => {
871
500
  const {
872
501
  decimal,
873
502
  group,
@@ -912,7 +541,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
912
541
  }
913
542
  return keys;
914
543
  });
915
- const getStepAmount = clamp.useStableCallback(event => {
544
+ const getStepAmount = useButton.useStableCallback(event => {
916
545
  if (event?.altKey) {
917
546
  return smallStep;
918
547
  }
@@ -921,13 +550,13 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
921
550
  }
922
551
  return step;
923
552
  });
924
- const setValue = clamp.useStableCallback((unvalidatedValue, details) => {
553
+ const setValue = useButton.useStableCallback((unvalidatedValue, details) => {
925
554
  const eventWithOptionalKeyState = details.event;
926
555
  const dir = details.direction;
927
556
  const reason = details.reason;
928
557
  // Only allow out-of-range values for direct text entry (native-like behavior).
929
558
  // Step-based interactions (keyboard arrows, buttons, wheel, scrub) still clamp to min/max.
930
- const shouldClampValue = !allowOutOfRange || !(reason === clamp.inputChange || reason === clamp.inputBlur || reason === clamp.inputPaste || reason === clamp.inputClear || reason === clamp.none);
559
+ const shouldClampValue = !allowOutOfRange || !(reason === useButton.inputChange || reason === useButton.inputBlur || reason === useButton.inputPaste || reason === useButton.inputClear || reason === useButton.none);
931
560
  const validatedValue = toValidatedNumber(unvalidatedValue, {
932
561
  step: dir ? getStepAmount(eventWithOptionalKeyState) * dir : undefined,
933
562
  format: formatOptionsRef.current,
@@ -942,7 +571,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
942
571
  // Determine whether we should notify about a change even if the numeric value is unchanged.
943
572
  // This is needed when the user input is clamped/snapped to the same current value, or when
944
573
  // the source value differs but validation normalizes to the existing value.
945
- const isInputReason = details.reason === clamp.inputChange || details.reason === clamp.inputClear || details.reason === clamp.inputBlur || details.reason === clamp.inputPaste || details.reason === clamp.none;
574
+ const isInputReason = details.reason === useButton.inputChange || details.reason === useButton.inputClear || details.reason === useButton.inputBlur || details.reason === useButton.inputPaste || details.reason === useButton.none;
946
575
  const shouldFireChange = validatedValue !== value || isInputReason && (unvalidatedValue !== value || allowInputSyncRef.current === false);
947
576
  if (shouldFireChange) {
948
577
  lastChangedValueRef.current = validatedValue;
@@ -967,7 +596,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
967
596
  forceRender();
968
597
  return shouldFireChange;
969
598
  });
970
- const incrementValue = clamp.useStableCallback((amount, {
599
+ const incrementValue = useButton.useStableCallback((amount, {
971
600
  direction,
972
601
  currentValue,
973
602
  event,
@@ -976,18 +605,18 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
976
605
  const prevValue = currentValue == null ? valueRef.current : currentValue;
977
606
  const nextValue = typeof prevValue === 'number' ? prevValue + amount * direction : Math.max(0, min ?? 0);
978
607
  const nativeEvent = event;
979
- return setValue(nextValue, clamp.createChangeEventDetails(reason, nativeEvent, undefined, {
608
+ return setValue(nextValue, useButton.createChangeEventDetails(reason, nativeEvent, undefined, {
980
609
  direction
981
610
  }));
982
611
  });
983
- const stopAutoChange = clamp.useStableCallback(() => {
612
+ const stopAutoChange = useButton.useStableCallback(() => {
984
613
  intentionalTouchCheckTimeout.clear();
985
614
  startTickTimeout.clear();
986
615
  tickInterval.clear();
987
616
  unsubscribeFromGlobalContextMenuRef.current();
988
617
  movesAfterTouchRef.current = 0;
989
618
  });
990
- const startAutoChange = clamp.useStableCallback((isIncrement, triggerEvent) => {
619
+ const startAutoChange = useButton.useStableCallback((isIncrement, triggerEvent) => {
991
620
  stopAutoChange();
992
621
  if (!inputRef.current) {
993
622
  return;
@@ -1007,8 +636,8 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
1007
636
  isPressedRef.current = false;
1008
637
  stopAutoChange();
1009
638
  const committed = lastChangedValueRef.current ?? valueRef.current;
1010
- const commitReason = isIncrement ? clamp.incrementPress : clamp.decrementPress;
1011
- onValueCommitted(committed, clamp.createGenericEventDetails(commitReason, event));
639
+ const commitReason = isIncrement ? useButton.incrementPress : useButton.decrementPress;
640
+ onValueCommitted(committed, useButton.createGenericEventDetails(commitReason, event));
1012
641
  }, {
1013
642
  once: true
1014
643
  });
@@ -1043,7 +672,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
1043
672
  // ESLint is disabled because it needs to run even if the parsed value hasn't changed, since the
1044
673
  // value still can be formatted differently.
1045
674
  // eslint-disable-next-line react-hooks/exhaustive-deps
1046
- clamp.useIsoLayoutEffect(function syncFormattedInputValueOnValueChange() {
675
+ useButton.useIsoLayoutEffect(function syncFormattedInputValueOnValueChange() {
1047
676
  // This ensures the value is only updated on blur rather than every keystroke, but still
1048
677
  // allows the input value to be updated when the value is changed externally.
1049
678
  if (!allowInputSyncRef.current) {
@@ -1054,8 +683,8 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
1054
683
  setInputValue(nextInputValue);
1055
684
  }
1056
685
  });
1057
- clamp.useIsoLayoutEffect(function setDynamicInputModeForIOS() {
1058
- if (!clamp.isIOS) {
686
+ useButton.useIsoLayoutEffect(function setDynamicInputModeForIOS() {
687
+ if (!useButton.isIOS) {
1059
688
  return;
1060
689
  }
1061
690
 
@@ -1082,7 +711,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
1082
711
  function handleWheel(event) {
1083
712
  if (
1084
713
  // Allow pinch-zooming.
1085
- event.ctrlKey || clamp.ownerDocument(inputRef.current).activeElement !== inputRef.current) {
714
+ event.ctrlKey || useButton.ownerDocument(inputRef.current).activeElement !== inputRef.current) {
1086
715
  return;
1087
716
  }
1088
717
 
@@ -1167,7 +796,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
1167
796
  // Handle browser autofill.
1168
797
  const nextValue = event.currentTarget.valueAsNumber;
1169
798
  const parsedValue = Number.isNaN(nextValue) ? null : nextValue;
1170
- const details = clamp.createChangeEventDetails(clamp.none, event.nativeEvent);
799
+ const details = useButton.createChangeEventDetails(useButton.none, event.nativeEvent);
1171
800
  setDirty(parsedValue !== validityData.initialValue);
1172
801
  setValue(parsedValue, details);
1173
802
  if (shouldValidateOnChange()) {
@@ -1189,7 +818,7 @@ const NumberFieldRoot = /*#__PURE__*/React__namespace.forwardRef(function Number
1189
818
  required: required,
1190
819
  "aria-hidden": true,
1191
820
  tabIndex: -1,
1192
- style: name ? clamp.visuallyHiddenInput : clamp.visuallyHidden
821
+ style: name ? useButton.visuallyHiddenInput : useButton.visuallyHidden
1193
822
  })]
1194
823
  });
1195
824
  });
@@ -1272,7 +901,7 @@ function useNumberFieldButton(params) {
1272
901
  // The increment value function needs to know the current input value to increment it
1273
902
  // correctly.
1274
903
  valueRef.current = parsedValue;
1275
- setValue(parsedValue, clamp.createChangeEventDetails(pressReason, nativeEvent, undefined, {
904
+ setValue(parsedValue, useButton.createChangeEventDetails(pressReason, nativeEvent, undefined, {
1276
905
  direction: isIncrement ? 1 : -1
1277
906
  }));
1278
907
  }
@@ -1313,7 +942,7 @@ function useNumberFieldButton(params) {
1313
942
  });
1314
943
  const committed = lastChangedValueRef.current ?? valueRef.current;
1315
944
  if (committed !== prev) {
1316
- onValueCommitted(committed, clamp.createGenericEventDetails(pressReason, event.nativeEvent));
945
+ onValueCommitted(committed, useButton.createGenericEventDetails(pressReason, event.nativeEvent));
1317
946
  }
1318
947
  },
1319
948
  onPointerDown(event) {
@@ -1471,7 +1100,7 @@ const NumberFieldIncrement = /*#__PURE__*/React__namespace.forwardRef(function N
1471
1100
  const {
1472
1101
  getButtonProps,
1473
1102
  buttonRef
1474
- } = clamp.useButton({
1103
+ } = useButton.useButton({
1475
1104
  disabled,
1476
1105
  native: nativeButton,
1477
1106
  focusableWhenDisabled: true
@@ -1555,7 +1184,7 @@ const NumberFieldDecrement = /*#__PURE__*/React__namespace.forwardRef(function N
1555
1184
  const {
1556
1185
  getButtonProps,
1557
1186
  buttonRef
1558
- } = clamp.useButton({
1187
+ } = useButton.useButton({
1559
1188
  disabled,
1560
1189
  native: nativeButton,
1561
1190
  focusableWhenDisabled: true
@@ -1575,7 +1204,7 @@ const NumberFieldDecrement = /*#__PURE__*/React__namespace.forwardRef(function N
1575
1204
  if (process.env.NODE_ENV !== "production") NumberFieldDecrement.displayName = "NumberFieldDecrement";
1576
1205
 
1577
1206
  const stateAttributesMapping = {
1578
- ...fieldValidityMapping,
1207
+ ...useLabel.fieldValidityMapping,
1579
1208
  ...stateAttributesMapping$1
1580
1209
  };
1581
1210
  const NAVIGATE_KEYS = new Set(['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab', 'Enter', 'Escape']);
@@ -1620,7 +1249,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1620
1249
  } = useNumberFieldRootContext();
1621
1250
  const {
1622
1251
  clearErrors
1623
- } = useFormContext();
1252
+ } = useLabel.useFormContext();
1624
1253
  const {
1625
1254
  validationMode,
1626
1255
  setTouched,
@@ -1628,13 +1257,13 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1628
1257
  invalid,
1629
1258
  shouldValidateOnChange,
1630
1259
  validation
1631
- } = useFieldRootContext();
1260
+ } = useLabel.useFieldRootContext();
1632
1261
  const {
1633
1262
  labelId
1634
- } = useLabelableContext();
1263
+ } = useLabel.useLabelableContext();
1635
1264
  const hasTouchedInputRef = React__namespace.useRef(false);
1636
1265
  const blockRevalidationRef = React__namespace.useRef(false);
1637
- useField({
1266
+ useLabel.useField({
1638
1267
  id,
1639
1268
  commit: validation.commit,
1640
1269
  value,
@@ -1642,7 +1271,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1642
1271
  name,
1643
1272
  getValue: () => value ?? null
1644
1273
  });
1645
- clamp.useValueChanged(value, previousValue => {
1274
+ useButton.useValueChanged(value, previousValue => {
1646
1275
  const validateOnChange = shouldValidateOnChange();
1647
1276
  clearErrors(name);
1648
1277
  if (validateOnChange) {
@@ -1700,11 +1329,11 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1700
1329
  const hadPendingProgrammaticChange = hasPendingCommitRef.current;
1701
1330
  allowInputSyncRef.current = true;
1702
1331
  if (inputValue.trim() === '') {
1703
- setValue(null, clamp.createChangeEventDetails(clamp.inputClear, event.nativeEvent));
1332
+ setValue(null, useButton.createChangeEventDetails(useButton.inputClear, event.nativeEvent));
1704
1333
  if (validationMode === 'onBlur') {
1705
1334
  validation.commit(null);
1706
1335
  }
1707
- onValueCommitted(null, clamp.createGenericEventDetails(clamp.inputClear, event.nativeEvent));
1336
+ onValueCommitted(null, useButton.createGenericEventDetails(useButton.inputClear, event.nativeEvent));
1708
1337
  return;
1709
1338
  }
1710
1339
  const formatOptions = formatOptionsRef.current;
@@ -1717,7 +1346,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1717
1346
  const hasExplicitPrecision = formatOptions?.maximumFractionDigits != null || formatOptions?.minimumFractionDigits != null;
1718
1347
  const maxFrac = formatOptions?.maximumFractionDigits;
1719
1348
  const committed = hasExplicitPrecision && typeof maxFrac === 'number' ? Number(parsedValue.toFixed(maxFrac)) : parsedValue;
1720
- const nextEventDetails = clamp.createGenericEventDetails(clamp.inputBlur, event.nativeEvent);
1349
+ const nextEventDetails = useButton.createGenericEventDetails(useButton.inputBlur, event.nativeEvent);
1721
1350
  const shouldUpdateValue = value !== committed;
1722
1351
  const shouldCommit = hadManualInput || shouldUpdateValue || hadPendingProgrammaticChange;
1723
1352
  if (validationMode === 'onBlur') {
@@ -1725,7 +1354,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1725
1354
  }
1726
1355
  if (shouldUpdateValue) {
1727
1356
  blockRevalidationRef.current = true;
1728
- setValue(committed, clamp.createChangeEventDetails(clamp.inputBlur, event.nativeEvent));
1357
+ setValue(committed, useButton.createChangeEventDetails(useButton.inputBlur, event.nativeEvent));
1729
1358
  }
1730
1359
  if (shouldCommit) {
1731
1360
  onValueCommitted(committed, nextEventDetails);
@@ -1748,7 +1377,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1748
1377
  const targetValue = event.target.value;
1749
1378
  if (targetValue.trim() === '') {
1750
1379
  setInputValue(targetValue);
1751
- setValue(null, clamp.createChangeEventDetails(clamp.inputClear, event.nativeEvent));
1380
+ setValue(null, useButton.createChangeEventDetails(useButton.inputClear, event.nativeEvent));
1752
1381
  return;
1753
1382
  }
1754
1383
 
@@ -1771,7 +1400,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1771
1400
  const parsedValue = parseNumber(targetValue, locale, formatOptionsRef.current);
1772
1401
  setInputValue(targetValue);
1773
1402
  if (parsedValue !== null) {
1774
- setValue(parsedValue, clamp.createChangeEventDetails(clamp.inputChange, event.nativeEvent));
1403
+ setValue(parsedValue, useButton.createChangeEventDetails(useButton.inputChange, event.nativeEvent));
1775
1404
  }
1776
1405
  },
1777
1406
  onKeyDown(event) {
@@ -1831,14 +1460,14 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1831
1460
  const amount = getStepAmount(event) ?? DEFAULT_STEP;
1832
1461
 
1833
1462
  // Prevent insertion of text or caret from moving.
1834
- clamp.stopEvent(event);
1835
- const commitDetails = clamp.createGenericEventDetails(clamp.keyboard, nativeEvent);
1463
+ useButton.stopEvent(event);
1464
+ const commitDetails = useButton.createGenericEventDetails(useButton.keyboard, nativeEvent);
1836
1465
  if (event.key === 'ArrowUp') {
1837
1466
  incrementValue(amount, {
1838
1467
  direction: 1,
1839
1468
  currentValue: parsedValue,
1840
1469
  event: nativeEvent,
1841
- reason: clamp.keyboard
1470
+ reason: useButton.keyboard
1842
1471
  });
1843
1472
  onValueCommitted(lastChangedValueRef.current ?? valueRef.current, commitDetails);
1844
1473
  } else if (event.key === 'ArrowDown') {
@@ -1846,14 +1475,14 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1846
1475
  direction: -1,
1847
1476
  currentValue: parsedValue,
1848
1477
  event: nativeEvent,
1849
- reason: clamp.keyboard
1478
+ reason: useButton.keyboard
1850
1479
  });
1851
1480
  onValueCommitted(lastChangedValueRef.current ?? valueRef.current, commitDetails);
1852
1481
  } else if (event.key === 'Home' && min != null) {
1853
- setValue(min, clamp.createChangeEventDetails(clamp.keyboard, nativeEvent));
1482
+ setValue(min, useButton.createChangeEventDetails(useButton.keyboard, nativeEvent));
1854
1483
  onValueCommitted(lastChangedValueRef.current ?? valueRef.current, commitDetails);
1855
1484
  } else if (event.key === 'End' && max != null) {
1856
- setValue(max, clamp.createChangeEventDetails(clamp.keyboard, nativeEvent));
1485
+ setValue(max, useButton.createChangeEventDetails(useButton.keyboard, nativeEvent));
1857
1486
  onValueCommitted(lastChangedValueRef.current ?? valueRef.current, commitDetails);
1858
1487
  }
1859
1488
  },
@@ -1869,7 +1498,7 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1869
1498
  const parsedValue = parseNumber(pastedData, locale, formatOptionsRef.current);
1870
1499
  if (parsedValue !== null) {
1871
1500
  allowInputSyncRef.current = false;
1872
- setValue(parsedValue, clamp.createChangeEventDetails(clamp.inputPaste, event.nativeEvent));
1501
+ setValue(parsedValue, useButton.createChangeEventDetails(useButton.inputPaste, event.nativeEvent));
1873
1502
  setInputValue(pastedData);
1874
1503
  }
1875
1504
  }
@@ -1884,23 +1513,11 @@ const NumberFieldInput = /*#__PURE__*/React__namespace.forwardRef(function Numbe
1884
1513
  });
1885
1514
  if (process.env.NODE_ENV !== "production") NumberFieldInput.displayName = "NumberFieldInput";
1886
1515
 
1887
- exports.DEFAULT_FIELD_STATE_ATTRIBUTES = DEFAULT_FIELD_STATE_ATTRIBUTES;
1888
1516
  exports.DEFAULT_STEP = DEFAULT_STEP;
1889
- exports.DEFAULT_VALIDITY_STATE = DEFAULT_VALIDITY_STATE;
1890
- exports.FieldRootContext = FieldRootContext;
1891
- exports.LabelableContext = LabelableContext;
1892
1517
  exports.NumberFieldDecrement = NumberFieldDecrement;
1893
1518
  exports.NumberFieldGroup = NumberFieldGroup;
1894
1519
  exports.NumberFieldIncrement = NumberFieldIncrement;
1895
1520
  exports.NumberFieldInput = NumberFieldInput;
1896
1521
  exports.NumberFieldRoot = NumberFieldRoot;
1897
- exports.fieldValidityMapping = fieldValidityMapping;
1898
- exports.getCombinedFieldValidityData = getCombinedFieldValidityData;
1899
1522
  exports.stateAttributesMapping = stateAttributesMapping$1;
1900
- exports.useField = useField;
1901
- exports.useFieldRootContext = useFieldRootContext;
1902
- exports.useFormContext = useFormContext;
1903
- exports.useLabel = useLabel;
1904
- exports.useLabelableContext = useLabelableContext;
1905
- exports.useLabelableId = useLabelableId;
1906
1523
  exports.useNumberFieldRootContext = useNumberFieldRootContext;