@jobber/components 8.21.1 → 8.23.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 (93) hide show
  1. package/Dialog.d.ts +1 -0
  2. package/Dialog.js +17 -0
  3. package/dist/BottomSheet-cjs.js +34 -7
  4. package/dist/BottomSheet-es.js +34 -8
  5. package/dist/CSPContext-cjs.js +69 -0
  6. package/dist/CSPContext-es.js +46 -0
  7. package/dist/Card/index.cjs +3 -0
  8. package/dist/Card/index.mjs +3 -0
  9. package/dist/ComboboxChipRemove-cjs.js +54 -211
  10. package/dist/ComboboxChipRemove-es.js +8 -164
  11. package/dist/DataDump/index.cjs +3 -0
  12. package/dist/DataDump/index.mjs +3 -0
  13. package/dist/Dialog/Dialog.d.ts +3 -0
  14. package/dist/Dialog/Dialog.types.d.ts +205 -0
  15. package/dist/Dialog/DialogBottomSheet.d.ts +28 -0
  16. package/dist/Dialog/DialogModal.d.ts +20 -0
  17. package/dist/Dialog/constants.d.ts +1 -0
  18. package/dist/Dialog/dialogComposableShared.d.ts +53 -0
  19. package/dist/Dialog/dialogReturnFocus.d.ts +43 -0
  20. package/dist/Dialog/index.cjs +33 -0
  21. package/dist/Dialog/index.d.ts +4 -0
  22. package/dist/Dialog/index.mjs +25 -0
  23. package/dist/DrawerDescription-cjs.js +410 -0
  24. package/dist/DrawerDescription-es.js +383 -0
  25. package/dist/DrawerTitle-cjs.js +116 -0
  26. package/dist/DrawerTitle-es.js +92 -0
  27. package/dist/InputNumberExperimental-cjs.js +24 -23
  28. package/dist/InputNumberExperimental-es.js +3 -2
  29. package/dist/InternalBackdrop-es.js +3 -3
  30. package/dist/Menu/index.cjs +3 -0
  31. package/dist/Menu/index.mjs +3 -0
  32. package/dist/Menu-cjs.js +6 -4
  33. package/dist/Menu-es.js +6 -4
  34. package/dist/MenuSubmenuTrigger-cjs.js +53 -103
  35. package/dist/MenuSubmenuTrigger-es.js +55 -103
  36. package/dist/NumberFieldInput-cjs.js +9 -9
  37. package/dist/NumberFieldInput-es.js +3 -3
  38. package/dist/Page/index.cjs +3 -0
  39. package/dist/Page/index.mjs +3 -0
  40. package/dist/ScrollAreaViewport-cjs.js +921 -960
  41. package/dist/ScrollAreaViewport-es.js +917 -958
  42. package/dist/SelectGroupLabel-cjs.js +1924 -0
  43. package/dist/SelectGroupLabel-es.js +1888 -0
  44. package/dist/SelectPrimitive-cjs.js +112 -0
  45. package/dist/SelectPrimitive-es.js +110 -0
  46. package/dist/ToolbarRootContext-cjs.js +35 -0
  47. package/dist/ToolbarRootContext-es.js +14 -0
  48. package/dist/dialogReturnFocus-cjs.js +427 -0
  49. package/dist/dialogReturnFocus-es.js +423 -0
  50. package/dist/docs/SelectPrimitive/SelectPrimitive.md +326 -0
  51. package/dist/docs/index.md +1 -0
  52. package/dist/floating-ui.react-dom-cjs.js +1 -0
  53. package/dist/floating-ui.react-dom-es.js +2 -2
  54. package/dist/floating-ui.utils.dom-es.js +1 -1
  55. package/dist/index.cjs +15 -7
  56. package/dist/index.d.mts +1 -0
  57. package/dist/index.d.ts +1 -0
  58. package/dist/index.mjs +12 -7
  59. package/dist/primitives/BottomSheet/BottomSheet.d.ts +19 -1
  60. package/dist/primitives/BottomSheet/BottomSheet.types.d.ts +8 -0
  61. package/dist/primitives/BottomSheet/index.cjs +2 -0
  62. package/dist/primitives/BottomSheet/index.d.ts +1 -1
  63. package/dist/primitives/BottomSheet/index.mjs +2 -1
  64. package/dist/primitives/ComboboxPrimitive/index.cjs +3 -1
  65. package/dist/primitives/ComboboxPrimitive/index.mjs +3 -1
  66. package/dist/primitives/InputNumberExperimental/index.cjs +2 -1
  67. package/dist/primitives/InputNumberExperimental/index.mjs +2 -1
  68. package/dist/primitives/SelectPrimitive/SelectPrimitive.d.ts +63 -0
  69. package/dist/primitives/SelectPrimitive/index.cjs +29 -0
  70. package/dist/primitives/SelectPrimitive/index.d.ts +2 -0
  71. package/dist/primitives/SelectPrimitive/index.mjs +23 -0
  72. package/dist/primitives/SelectPrimitive/types.d.ts +16 -0
  73. package/dist/primitives/index.cjs +9 -1
  74. package/dist/primitives/index.d.ts +1 -0
  75. package/dist/primitives/index.mjs +8 -2
  76. package/dist/primitives/mergeClassName.d.ts +12 -0
  77. package/dist/resolveAriaLabelledBy-cjs.js +195 -0
  78. package/dist/resolveAriaLabelledBy-es.js +162 -0
  79. package/dist/styles.css +685 -0
  80. package/dist/unstyledPrimitives/index.cjs +434 -259
  81. package/dist/unstyledPrimitives/index.d.ts +2 -0
  82. package/dist/unstyledPrimitives/index.mjs +425 -252
  83. package/dist/useButton-cjs.js +2 -0
  84. package/dist/useButton-es.js +3 -2
  85. package/dist/useCompositeListItem-es.js +4 -4
  86. package/dist/useLabel-cjs.js +3 -329
  87. package/dist/useLabel-es.js +4 -299
  88. package/dist/useLabelableId-cjs.js +332 -0
  89. package/dist/useLabelableId-es.js +300 -0
  90. package/dist/useRenderElement-cjs.js +3 -0
  91. package/dist/useRenderElement-es.js +4 -1
  92. package/dist/utils/meta/meta.json +11 -1
  93. package/package.json +2 -2
@@ -545,6 +545,7 @@ const cancelOpen = 'cancel-open';
545
545
  const siblingOpen = 'sibling-open';
546
546
  const imperativeAction = 'imperative-action';
547
547
  const swipe = 'swipe';
548
+ const windowResize = 'window-resize';
548
549
 
549
550
  /**
550
551
  * Maps a change `reason` string to the corresponding native event type.
@@ -1194,3 +1195,4 @@ exports.useValueAsRef = useValueAsRef;
1194
1195
  exports.useValueChanged = useValueChanged;
1195
1196
  exports.visuallyHidden = visuallyHidden;
1196
1197
  exports.visuallyHiddenInput = visuallyHiddenInput;
1198
+ exports.windowResize = windowResize;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { a as useRefWithInit, E as EMPTY_OBJECT, f as formatErrorMessage, m as mergeProps, c as makeEventPreventable } from './useRenderElement-es.js';
2
+ import { a as useRefWithInit, E as EMPTY_OBJECT, f as formatErrorMessage, m as mergeProps, d as makeEventPreventable } from './useRenderElement-es.js';
3
3
  import { i as isShadowRoot, b as isElement, a as isHTMLElement } from './floating-ui.utils.dom-es.js';
4
4
  import * as ReactDOM from 'react-dom';
5
5
 
@@ -523,6 +523,7 @@ const cancelOpen = 'cancel-open';
523
523
  const siblingOpen = 'sibling-open';
524
524
  const imperativeAction = 'imperative-action';
525
525
  const swipe = 'swipe';
526
+ const windowResize = 'window-resize';
526
527
 
527
528
  /**
528
529
  * Maps a change `reason` string to the corresponding native event type.
@@ -1088,4 +1089,4 @@ function isValidLinkElement(elem) {
1088
1089
  return Boolean(elem?.tagName === 'A' && elem?.href);
1089
1090
  }
1090
1091
 
1091
- export { isMac as $, ARROW_DOWN as A, useControlled as B, isIOS as C, none as D, visuallyHiddenInput as E, visuallyHidden as F, inputChange as G, inputClear as H, inputBlur as I, inputPaste as J, createGenericEventDetails as K, incrementPress as L, decrementPress as M, useButton as N, useValueChanged as O, keyboard as P, imperativeAction as Q, isAndroid as R, SafeReact as S, Timeout as T, closeWatcher as U, isWebKit as V, isMouseLikePointerType as W, isTypeableElement as X, matchesFocusVisible as Y, isTargetInsideEnabledTrigger as Z, triggerFocus as _, useStableCallback as a, isSafari as a0, triggerPress as a1, escapeKey as a2, TYPEABLE_SELECTOR as a3, triggerHover as a4, closePress as a5, itemPress as a6, outsidePress as a7, useAnimationsFinished as a8, siblingOpen as a9, useCompositeRootContext as aa, cancelOpen as ab, useAnimationFrame as ac, resolveRef as ad, isClickLikeEvent as ae, isReactEvent as af, isEventTargetWithin as ag, isRootElement as ah, FOCUSABLE_ATTRIBUTE as ai, ACTIVE_KEY as aj, SELECTED_KEY as ak, TransitionStatusDataAttributes as al, AnimationFrame as am, inputPress as an, isFirefox as ao, clearPress as ap, chipRemovePress as aq, pointer as ar, swipe as as, scrub as at, useTimeout as b, useTransitionStatus as c, useIsoLayoutEffect as d, error as e, useOpenChangeComplete as f, getTarget as g, useId as h, getFloatingFocusElement as i, useValueAsRef as j, isTypeableCombobox as k, activeElement as l, contains as m, createChangeEventDetails as n, ownerDocument as o, listNavigation as p, ARROW_LEFT as q, ARROW_RIGHT as r, stopEvent as s, transitionStatusMapping as t, useBaseUiId as u, focusOut as v, isVirtualClick as w, isVirtualPointerEvent as x, ARROW_UP as y, useOnMount as z };
1092
+ export { closeWatcher as $, ARROW_DOWN as A, isVirtualPointerEvent as B, ARROW_UP as C, useOnMount as D, useControlled as E, isIOS as F, none as G, visuallyHiddenInput as H, visuallyHidden as I, inputChange as J, inputClear as K, inputBlur as L, inputPaste as M, createGenericEventDetails as N, incrementPress as O, decrementPress as P, useValueChanged as Q, keyboard as R, SafeReact as S, Timeout as T, outsidePress as U, cancelOpen as V, useAnimationFrame as W, isWebKit as X, windowResize as Y, itemPress as Z, isAndroid as _, useIsoLayoutEffect as a, isMouseLikePointerType as a0, isTypeableElement as a1, matchesFocusVisible as a2, isTargetInsideEnabledTrigger as a3, triggerFocus as a4, isMac as a5, isSafari as a6, triggerPress as a7, escapeKey as a8, TYPEABLE_SELECTOR as a9, triggerHover as aa, useAnimationsFinished as ab, siblingOpen as ac, useCompositeRootContext as ad, inputPress as ae, isFirefox as af, clearPress as ag, chipRemovePress as ah, resolveRef as ai, isClickLikeEvent as aj, isReactEvent as ak, isEventTargetWithin as al, isRootElement as am, FOCUSABLE_ATTRIBUTE as an, ACTIVE_KEY as ao, SELECTED_KEY as ap, TransitionStatusDataAttributes as aq, AnimationFrame as ar, pointer as as, swipe as at, scrub as au, useStableCallback as b, useButton as c, createChangeEventDetails as d, closePress as e, useOpenChangeComplete as f, getTarget as g, useTimeout as h, imperativeAction as i, error as j, useTransitionStatus as k, useId as l, getFloatingFocusElement as m, useValueAsRef as n, ownerDocument as o, isTypeableCombobox as p, activeElement as q, contains as r, stopEvent as s, transitionStatusMapping as t, useBaseUiId as u, listNavigation as v, ARROW_LEFT as w, ARROW_RIGHT as x, focusOut as y, isVirtualClick as z };
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import { b as isElement, a as isHTMLElement, k as getWindow } from './floating-ui.utils.dom-es.js';
3
- import { h as useId, d as useIsoLayoutEffect, i as getFloatingFocusElement, j as useValueAsRef, k as isTypeableCombobox, a as useStableCallback, l as activeElement, o as ownerDocument, m as contains, s as stopEvent, n as createChangeEventDetails, p as listNavigation, A as ARROW_DOWN, q as ARROW_LEFT, r as ARROW_RIGHT, g as getTarget, v as focusOut, w as isVirtualClick, x as isVirtualPointerEvent, y as ARROW_UP, b as useTimeout } from './useButton-es.js';
4
- import { u as useFloatingParentNodeId, F as FloatingRootStore, P as PopupTriggerMap, a as useFloatingTree, i as isIndexOutOfListBounds, g as getMinListIndex, b as getMaxListIndex, c as createGridCellMap, d as isListIndexDisabled, e as getGridNavigatedIndex, f as getGridCellIndices, h as getGridCellIndexOfCorner, j as findNonDisabledListIndex, k as enqueueFocus, l as isElementVisible, m as useDirection, D as DISABLED_TRANSITIONS_STYLE } from './InternalBackdrop-es.js';
2
+ import { b as isElement, a as isHTMLElement, o as getWindow } from './floating-ui.utils.dom-es.js';
3
+ import { l as useId, a as useIsoLayoutEffect, m as getFloatingFocusElement, n as useValueAsRef, p as isTypeableCombobox, b as useStableCallback, q as activeElement, o as ownerDocument, r as contains, s as stopEvent, d as createChangeEventDetails, v as listNavigation, A as ARROW_DOWN, w as ARROW_LEFT, x as ARROW_RIGHT, g as getTarget, y as focusOut, z as isVirtualClick, B as isVirtualPointerEvent, C as ARROW_UP, h as useTimeout } from './useButton-es.js';
4
+ import { u as useFloatingParentNodeId, a as FloatingRootStore, P as PopupTriggerMap, b as useFloatingTree, i as isIndexOutOfListBounds, g as getMinListIndex, c as getMaxListIndex, d as createGridCellMap, e as isListIndexDisabled, f as getGridNavigatedIndex, h as getGridCellIndices, j as getGridCellIndexOfCorner, k as findNonDisabledListIndex, l as enqueueFocus, m as isElementVisible, n as useDirection, D as DISABLED_TRANSITIONS_STYLE } from './InternalBackdrop-es.js';
5
5
  import { a as useRefWithInit, E as EMPTY_OBJECT } from './useRenderElement-es.js';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
  import { e as evaluate, h as getPaddingObject, b as getAlignmentAxis, d as getAlignment, q as getAxisLength, n as clamp, c as getSide, g as getSideAxis } from './index.esm-es.js';
@@ -1759,4 +1759,4 @@ function useCompositeListItem(params = {}) {
1759
1759
  }), [index, ref]);
1760
1760
  }
1761
1761
 
1762
- export { CompositeList as C, IndexGuessBehavior as I, useAnchorPositioning as a, adaptiveOrigin as b, useListNavigation as c, useTypeahead as d, getPseudoElementBounds as e, useFloatingRootContext as f, getDisabledMountTransitionStyles as g, useCompositeListItem as u };
1762
+ export { CompositeList as C, IndexGuessBehavior as I, useListNavigation as a, useTypeahead as b, useAnchorPositioning as c, getDisabledMountTransitionStyles as d, useCompositeListItem as e, adaptiveOrigin as f, getPseudoElementBounds as g, useFloatingRootContext as u };
@@ -1,323 +1,8 @@
1
1
  'use strict';
2
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
3
  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
- }
4
+ var useButton = require('./useButton-cjs.js');
5
+ var useLabelableId = require('./useLabelableId-cjs.js');
321
6
 
322
7
  function useRegisteredLabelId(idProp, setLabelId) {
323
8
  const id = useButton.useBaseUiId(idProp);
@@ -341,7 +26,7 @@ function useLabel(params = {}) {
341
26
  const {
342
27
  controlId: contextControlId,
343
28
  setLabelId: setContextLabelId
344
- } = useLabelableContext();
29
+ } = useLabelableId.useLabelableContext();
345
30
  const syncLabelId = useButton.useStableCallback(nextLabelId => {
346
31
  setContextLabelId(nextLabelId);
347
32
  setLabelIdProp?.(nextLabelId);
@@ -397,15 +82,4 @@ function focusElementWithVisible(element) {
397
82
  });
398
83
  }
399
84
 
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
85
  exports.useLabel = useLabel;
410
- exports.useLabelableContext = useLabelableContext;
411
- exports.useLabelableId = useLabelableId;