@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.
- package/Dialog.d.ts +1 -0
- package/Dialog.js +17 -0
- package/dist/BottomSheet-cjs.js +34 -7
- package/dist/BottomSheet-es.js +34 -8
- package/dist/CSPContext-cjs.js +69 -0
- package/dist/CSPContext-es.js +46 -0
- package/dist/Card/index.cjs +3 -0
- package/dist/Card/index.mjs +3 -0
- package/dist/ComboboxChipRemove-cjs.js +54 -211
- package/dist/ComboboxChipRemove-es.js +8 -164
- package/dist/DataDump/index.cjs +3 -0
- package/dist/DataDump/index.mjs +3 -0
- package/dist/Dialog/Dialog.d.ts +3 -0
- package/dist/Dialog/Dialog.types.d.ts +205 -0
- package/dist/Dialog/DialogBottomSheet.d.ts +28 -0
- package/dist/Dialog/DialogModal.d.ts +20 -0
- package/dist/Dialog/constants.d.ts +1 -0
- package/dist/Dialog/dialogComposableShared.d.ts +53 -0
- package/dist/Dialog/dialogReturnFocus.d.ts +43 -0
- package/dist/Dialog/index.cjs +33 -0
- package/dist/Dialog/index.d.ts +4 -0
- package/dist/Dialog/index.mjs +25 -0
- package/dist/DrawerDescription-cjs.js +410 -0
- package/dist/DrawerDescription-es.js +383 -0
- package/dist/DrawerTitle-cjs.js +116 -0
- package/dist/DrawerTitle-es.js +92 -0
- package/dist/InputNumberExperimental-cjs.js +24 -23
- package/dist/InputNumberExperimental-es.js +3 -2
- package/dist/InternalBackdrop-es.js +3 -3
- package/dist/Menu/index.cjs +3 -0
- package/dist/Menu/index.mjs +3 -0
- package/dist/Menu-cjs.js +6 -4
- package/dist/Menu-es.js +6 -4
- package/dist/MenuSubmenuTrigger-cjs.js +53 -103
- package/dist/MenuSubmenuTrigger-es.js +55 -103
- package/dist/NumberFieldInput-cjs.js +9 -9
- package/dist/NumberFieldInput-es.js +3 -3
- package/dist/Page/index.cjs +3 -0
- package/dist/Page/index.mjs +3 -0
- package/dist/ScrollAreaViewport-cjs.js +921 -960
- package/dist/ScrollAreaViewport-es.js +917 -958
- package/dist/SelectGroupLabel-cjs.js +1924 -0
- package/dist/SelectGroupLabel-es.js +1888 -0
- package/dist/SelectPrimitive-cjs.js +112 -0
- package/dist/SelectPrimitive-es.js +110 -0
- package/dist/ToolbarRootContext-cjs.js +35 -0
- package/dist/ToolbarRootContext-es.js +14 -0
- package/dist/dialogReturnFocus-cjs.js +427 -0
- package/dist/dialogReturnFocus-es.js +423 -0
- package/dist/docs/SelectPrimitive/SelectPrimitive.md +326 -0
- package/dist/docs/index.md +1 -0
- package/dist/floating-ui.react-dom-cjs.js +1 -0
- package/dist/floating-ui.react-dom-es.js +2 -2
- package/dist/floating-ui.utils.dom-es.js +1 -1
- package/dist/index.cjs +15 -7
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +12 -7
- package/dist/primitives/BottomSheet/BottomSheet.d.ts +19 -1
- package/dist/primitives/BottomSheet/BottomSheet.types.d.ts +8 -0
- package/dist/primitives/BottomSheet/index.cjs +2 -0
- package/dist/primitives/BottomSheet/index.d.ts +1 -1
- package/dist/primitives/BottomSheet/index.mjs +2 -1
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -1
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -1
- package/dist/primitives/InputNumberExperimental/index.cjs +2 -1
- package/dist/primitives/InputNumberExperimental/index.mjs +2 -1
- package/dist/primitives/SelectPrimitive/SelectPrimitive.d.ts +63 -0
- package/dist/primitives/SelectPrimitive/index.cjs +29 -0
- package/dist/primitives/SelectPrimitive/index.d.ts +2 -0
- package/dist/primitives/SelectPrimitive/index.mjs +23 -0
- package/dist/primitives/SelectPrimitive/types.d.ts +16 -0
- package/dist/primitives/index.cjs +9 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.mjs +8 -2
- package/dist/primitives/mergeClassName.d.ts +12 -0
- package/dist/resolveAriaLabelledBy-cjs.js +195 -0
- package/dist/resolveAriaLabelledBy-es.js +162 -0
- package/dist/styles.css +685 -0
- package/dist/unstyledPrimitives/index.cjs +434 -259
- package/dist/unstyledPrimitives/index.d.ts +2 -0
- package/dist/unstyledPrimitives/index.mjs +425 -252
- package/dist/useButton-cjs.js +2 -0
- package/dist/useButton-es.js +3 -2
- package/dist/useCompositeListItem-es.js +4 -4
- package/dist/useLabel-cjs.js +3 -329
- package/dist/useLabel-es.js +4 -299
- package/dist/useLabelableId-cjs.js +332 -0
- package/dist/useLabelableId-es.js +300 -0
- package/dist/useRenderElement-cjs.js +3 -0
- package/dist/useRenderElement-es.js +4 -1
- package/dist/utils/meta/meta.json +11 -1
- package/package.json +2 -2
package/dist/useButton-cjs.js
CHANGED
|
@@ -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;
|
package/dist/useButton-es.js
CHANGED
|
@@ -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,
|
|
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 {
|
|
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,
|
|
3
|
-
import {
|
|
4
|
-
import { u as useFloatingParentNodeId,
|
|
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,
|
|
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 };
|
package/dist/useLabel-cjs.js
CHANGED
|
@@ -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
|
-
|
|
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;
|