@octanejs/base-ui 0.1.31 → 0.1.33
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/dist/cjs/accordion.cjs +497 -0
- package/dist/cjs/alert-dialog.cjs +65 -0
- package/dist/cjs/avatar.cjs +234 -0
- package/dist/cjs/button.cjs +54 -0
- package/dist/cjs/checkbox-group.cjs +165 -0
- package/dist/cjs/checkbox.cjs +475 -0
- package/dist/cjs/collapsible.cjs +700 -0
- package/dist/cjs/context-menu.cjs +257 -0
- package/dist/cjs/csp-provider.cjs +40 -0
- package/dist/cjs/dialog.cjs +741 -0
- package/dist/cjs/direction-provider.cjs +35 -0
- package/dist/cjs/field.cjs +559 -0
- package/dist/cjs/fieldset.cjs +101 -0
- package/dist/cjs/form.cjs +177 -0
- package/dist/cjs/index.cjs +133 -0
- package/dist/cjs/input.cjs +32 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/menu.cjs +2420 -0
- package/dist/cjs/menubar.cjs +132 -0
- package/dist/cjs/merge-props.cjs +34 -0
- package/dist/cjs/meter.cjs +169 -0
- package/dist/cjs/number-field.cjs +812 -0
- package/dist/cjs/popover.cjs +966 -0
- package/dist/cjs/preview-card.cjs +632 -0
- package/dist/cjs/progress.cjs +206 -0
- package/dist/cjs/radio-group.cjs +264 -0
- package/dist/cjs/radio.cjs +327 -0
- package/dist/cjs/separator.cjs +44 -0
- package/dist/cjs/slider.cjs +1384 -0
- package/dist/cjs/switch.cjs +306 -0
- package/dist/cjs/tabs.cjs +727 -0
- package/dist/cjs/toast.cjs +1766 -0
- package/dist/cjs/toggle-group.cjs +118 -0
- package/dist/cjs/toggle.cjs +121 -0
- package/dist/cjs/tooltip.cjs +835 -0
- package/dist/cjs/unstable-use-media-query.cjs +79 -0
- package/dist/cjs/use-render.cjs +40 -0
- package/dist/cjs/utils/CSPContext.cjs +38 -0
- package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
- package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
- package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
- package/dist/cjs/utils/DirectionContext.cjs +34 -0
- package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
- package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
- package/dist/cjs/utils/MenubarContext.cjs +40 -0
- package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
- package/dist/cjs/utils/RequestQueue.cjs +111 -0
- package/dist/cjs/utils/TimeoutManager.cjs +50 -0
- package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
- package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
- package/dist/cjs/utils/addEventListener.cjs +33 -0
- package/dist/cjs/utils/areArraysEqual.cjs +30 -0
- package/dist/cjs/utils/clamp.cjs +30 -0
- package/dist/cjs/utils/closePart.cjs +70 -0
- package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
- package/dist/cjs/utils/composeRefs.cjs +68 -0
- package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
- package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
- package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
- package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
- package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
- package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
- package/dist/cjs/utils/composite/keys.cjs +174 -0
- package/dist/cjs/utils/composite/list-utils.cjs +90 -0
- package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
- package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
- package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
- package/dist/cjs/utils/constants.cjs +56 -0
- package/dist/cjs/utils/contains.cjs +46 -0
- package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
- package/dist/cjs/utils/dom.cjs +35 -0
- package/dist/cjs/utils/empty.cjs +34 -0
- package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
- package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
- package/dist/cjs/utils/field/FormContext.cjs +41 -0
- package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
- package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
- package/dist/cjs/utils/field/constants.cjs +68 -0
- package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
- package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
- package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
- package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
- package/dist/cjs/utils/field/useLabel.cjs +99 -0
- package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
- package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
- package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
- package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
- package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
- package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
- package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
- package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
- package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
- package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
- package/dist/cjs/utils/floating/composite.cjs +42 -0
- package/dist/cjs/utils/floating/constants.cjs +34 -0
- package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
- package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
- package/dist/cjs/utils/floating/element.cjs +103 -0
- package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
- package/dist/cjs/utils/floating/event.cjs +65 -0
- package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
- package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
- package/dist/cjs/utils/floating/markOthers.cjs +181 -0
- package/dist/cjs/utils/floating/nodes.cjs +48 -0
- package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
- package/dist/cjs/utils/floating/tabbable.cjs +242 -0
- package/dist/cjs/utils/floating/types.cjs +16 -0
- package/dist/cjs/utils/floating/useClick.cjs +153 -0
- package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
- package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
- package/dist/cjs/utils/floating/useFloating.cjs +186 -0
- package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
- package/dist/cjs/utils/floating/useFocus.cjs +184 -0
- package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
- package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
- package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
- package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
- package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
- package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
- package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
- package/dist/cjs/utils/formatNumber.cjs +60 -0
- package/dist/cjs/utils/generateId.cjs +32 -0
- package/dist/cjs/utils/getCssDimensions.cjs +42 -0
- package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
- package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
- package/dist/cjs/utils/getElementRef.cjs +35 -0
- package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
- package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
- package/dist/cjs/utils/hideMiddleware.cjs +42 -0
- package/dist/cjs/utils/inertValue.cjs +30 -0
- package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
- package/dist/cjs/utils/mergeCleanups.cjs +37 -0
- package/dist/cjs/utils/mergeObjects.cjs +39 -0
- package/dist/cjs/utils/mergeProps.cjs +182 -0
- package/dist/cjs/utils/noop.cjs +29 -0
- package/dist/cjs/utils/number/constants.cjs +34 -0
- package/dist/cjs/utils/number/parse.cjs +258 -0
- package/dist/cjs/utils/number/types.cjs +16 -0
- package/dist/cjs/utils/number/validate.cjs +104 -0
- package/dist/cjs/utils/owner.cjs +35 -0
- package/dist/cjs/utils/platform.cjs +83 -0
- package/dist/cjs/utils/popupStateMapping.cjs +74 -0
- package/dist/cjs/utils/popups/index.cjs +39 -0
- package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
- package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
- package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
- package/dist/cjs/utils/popups/store.cjs +118 -0
- package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
- package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
- package/dist/cjs/utils/resolveClassName.cjs +30 -0
- package/dist/cjs/utils/resolveRef.cjs +33 -0
- package/dist/cjs/utils/resolveStyle.cjs +30 -0
- package/dist/cjs/utils/serializeValue.cjs +40 -0
- package/dist/cjs/utils/slider/asc.cjs +30 -0
- package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
- package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
- package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
- package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
- package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
- package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
- package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
- package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
- package/dist/cjs/utils/store/ReactStore.cjs +135 -0
- package/dist/cjs/utils/store/Store.cjs +83 -0
- package/dist/cjs/utils/store/createSelector.cjs +74 -0
- package/dist/cjs/utils/store/useStore.cjs +51 -0
- package/dist/cjs/utils/stringifyLocale.cjs +36 -0
- package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
- package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
- package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
- package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
- package/dist/cjs/utils/useBaseUiId.cjs +36 -0
- package/dist/cjs/utils/useButton.cjs +177 -0
- package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
- package/dist/cjs/utils/useControlled.cjs +47 -0
- package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
- package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
- package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
- package/dist/cjs/utils/useIsHydrating.cjs +44 -0
- package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
- package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
- package/dist/cjs/utils/useOnMount.cjs +36 -0
- package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
- package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
- package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
- package/dist/cjs/utils/usePopupViewport.cjs +283 -0
- package/dist/cjs/utils/usePositioner.cjs +53 -0
- package/dist/cjs/utils/usePressAndHold.cjs +51 -0
- package/dist/cjs/utils/usePreviousValue.cjs +47 -0
- package/dist/cjs/utils/useRefWithInit.cjs +41 -0
- package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
- package/dist/cjs/utils/useRenderElement.cjs +106 -0
- package/dist/cjs/utils/useScrollLock.cjs +232 -0
- package/dist/cjs/utils/useStableCallback.cjs +41 -0
- package/dist/cjs/utils/useTimeout.cjs +66 -0
- package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
- package/dist/cjs/utils/useValueAsRef.cjs +43 -0
- package/dist/cjs/utils/useValueChanged.cjs +55 -0
- package/dist/cjs/utils/valueToPercent.cjs +30 -0
- package/dist/cjs/utils/visuallyHidden.cjs +49 -0
- package/package.json +20 -8
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useAriaLabelledBy_exports = {};
|
|
20
|
+
__export(useAriaLabelledBy_exports, {
|
|
21
|
+
useAriaLabelledBy: () => useAriaLabelledBy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useAriaLabelledBy_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_useBaseUiId = require("../useBaseUiId.cjs");
|
|
27
|
+
function useAriaLabelledBy(...args) {
|
|
28
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
29
|
+
const slot = slotArg ?? (0, import_internal.S)("useAriaLabelledBy");
|
|
30
|
+
const explicitAriaLabelledBy = user[0];
|
|
31
|
+
const labelId = user[1];
|
|
32
|
+
const labelSourceRef = user[2];
|
|
33
|
+
const enableFallback = user[3] ?? true;
|
|
34
|
+
const labelSourceId = user[4];
|
|
35
|
+
const [fallbackAriaLabelledBy, setFallbackAriaLabelledBy] = (0, import_octane.useState)(
|
|
36
|
+
void 0,
|
|
37
|
+
(0, import_internal.subSlot)(slot, "fb")
|
|
38
|
+
);
|
|
39
|
+
const generatedLabelId = (0, import_useBaseUiId.useBaseUiId)(
|
|
40
|
+
labelSourceId ? `${labelSourceId}-label` : void 0,
|
|
41
|
+
(0, import_internal.subSlot)(slot, "gen")
|
|
42
|
+
);
|
|
43
|
+
const ariaLabelledBy = explicitAriaLabelledBy ?? labelId ?? fallbackAriaLabelledBy;
|
|
44
|
+
(0, import_octane.useLayoutEffect)(
|
|
45
|
+
() => {
|
|
46
|
+
const nextAriaLabelledBy = explicitAriaLabelledBy || labelId || !enableFallback ? void 0 : getAriaLabelledBy(labelSourceRef.current, generatedLabelId);
|
|
47
|
+
if (fallbackAriaLabelledBy !== nextAriaLabelledBy) {
|
|
48
|
+
setFallbackAriaLabelledBy(nextAriaLabelledBy);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
void 0,
|
|
52
|
+
(0, import_internal.subSlot)(slot, "e:fallback")
|
|
53
|
+
);
|
|
54
|
+
return ariaLabelledBy;
|
|
55
|
+
}
|
|
56
|
+
function getAriaLabelledBy(labelSource, generatedLabelId) {
|
|
57
|
+
const label = findAssociatedLabel(labelSource);
|
|
58
|
+
if (!label) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
if (!label.id && generatedLabelId) {
|
|
62
|
+
label.id = generatedLabelId;
|
|
63
|
+
}
|
|
64
|
+
return label.id || void 0;
|
|
65
|
+
}
|
|
66
|
+
function findAssociatedLabel(labelSource) {
|
|
67
|
+
if (!labelSource) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
const parent = labelSource.parentElement;
|
|
71
|
+
if (parent && parent.tagName === "LABEL") {
|
|
72
|
+
return parent;
|
|
73
|
+
}
|
|
74
|
+
const controlId = labelSource.id;
|
|
75
|
+
if (controlId) {
|
|
76
|
+
const nextSibling = labelSource.nextElementSibling;
|
|
77
|
+
if (nextSibling && nextSibling.htmlFor === controlId) {
|
|
78
|
+
return nextSibling;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const labels = labelSource.labels;
|
|
82
|
+
return labels ? labels[0] : void 0;
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
useAriaLabelledBy
|
|
87
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useFieldControlRegistration_exports = {};
|
|
20
|
+
__export(useFieldControlRegistration_exports, {
|
|
21
|
+
useFieldControlRegistration: () => useFieldControlRegistration
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useFieldControlRegistration_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_getCombinedFieldValidityData = require("./getCombinedFieldValidityData.cjs");
|
|
27
|
+
var import_FormContext = require("./FormContext.cjs");
|
|
28
|
+
var import_useStableCallback = require("../useStableCallback.cjs");
|
|
29
|
+
function useFieldControlRegistration(...args) {
|
|
30
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
31
|
+
const slot = slotArg ?? (0, import_internal.S)("useFieldControlRegistration");
|
|
32
|
+
const {
|
|
33
|
+
commit,
|
|
34
|
+
invalid,
|
|
35
|
+
markedDirtyRef,
|
|
36
|
+
name,
|
|
37
|
+
setRegisteredFieldName,
|
|
38
|
+
setRegisteredFieldId,
|
|
39
|
+
setValidityData,
|
|
40
|
+
validityData
|
|
41
|
+
} = user[0];
|
|
42
|
+
const { formRef } = (0, import_FormContext.useFormContext)();
|
|
43
|
+
const activeFieldControlSourceRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "active"));
|
|
44
|
+
const registrationRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "reg"));
|
|
45
|
+
const fallbackControlRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "fallback"));
|
|
46
|
+
const getValueForForm = (0, import_useStableCallback.useStableCallback)(
|
|
47
|
+
() => {
|
|
48
|
+
const registration = registrationRef.current;
|
|
49
|
+
if (!registration) {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
if (registration.getValue) {
|
|
53
|
+
return registration.getValue();
|
|
54
|
+
}
|
|
55
|
+
return registration.value;
|
|
56
|
+
},
|
|
57
|
+
(0, import_internal.subSlot)(slot, "getValue")
|
|
58
|
+
);
|
|
59
|
+
function getRegistrationValue(registration) {
|
|
60
|
+
return registration.value === void 0 ? getValueForForm() : registration.value;
|
|
61
|
+
}
|
|
62
|
+
const validate = (0, import_useStableCallback.useStableCallback)(
|
|
63
|
+
() => {
|
|
64
|
+
const registration = registrationRef.current;
|
|
65
|
+
markedDirtyRef.current = true;
|
|
66
|
+
if (!registration) {
|
|
67
|
+
commit(validityData.value);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
commit(getRegistrationValue(registration));
|
|
71
|
+
},
|
|
72
|
+
(0, import_internal.subSlot)(slot, "validate")
|
|
73
|
+
);
|
|
74
|
+
function refreshRegistration() {
|
|
75
|
+
const registration = registrationRef.current;
|
|
76
|
+
if (!registration || !registration.id) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
formRef.current.fields.set(registration.id, {
|
|
80
|
+
getValue: getValueForForm,
|
|
81
|
+
name: name ?? registration.name,
|
|
82
|
+
controlRef: registration.controlRef ?? fallbackControlRef,
|
|
83
|
+
validityData: (0, import_getCombinedFieldValidityData.getCombinedFieldValidityData)(validityData, invalid),
|
|
84
|
+
validate
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function deleteRegistration(id = registrationRef.current?.id) {
|
|
88
|
+
if (id) {
|
|
89
|
+
formRef.current.fields.delete(id);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function syncInitialValue() {
|
|
93
|
+
const registration = registrationRef.current;
|
|
94
|
+
if (!registration) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const initialValue = getRegistrationValue(registration);
|
|
98
|
+
if (validityData.initialValue === null && initialValue !== null) {
|
|
99
|
+
setValidityData((prev) => ({ ...prev, initialValue }));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
(0, import_octane.useLayoutEffect)(
|
|
103
|
+
() => {
|
|
104
|
+
const registration = registrationRef.current;
|
|
105
|
+
if (!registration || !registration.id) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setRegisteredFieldName(name ? void 0 : registration.name);
|
|
109
|
+
formRef.current.fields.set(registration.id, {
|
|
110
|
+
getValue: getValueForForm,
|
|
111
|
+
name: name ?? registration.name,
|
|
112
|
+
controlRef: registration.controlRef ?? fallbackControlRef,
|
|
113
|
+
validityData: (0, import_getCombinedFieldValidityData.getCombinedFieldValidityData)(validityData, invalid),
|
|
114
|
+
validate
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
[formRef, getValueForForm, invalid, name, setRegisteredFieldName, validate, validityData],
|
|
118
|
+
(0, import_internal.subSlot)(slot, "e:register")
|
|
119
|
+
);
|
|
120
|
+
(0, import_octane.useLayoutEffect)(
|
|
121
|
+
() => {
|
|
122
|
+
const fields = formRef.current.fields;
|
|
123
|
+
return () => {
|
|
124
|
+
const id = registrationRef.current?.id;
|
|
125
|
+
if (id) {
|
|
126
|
+
fields.delete(id);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
[formRef],
|
|
131
|
+
(0, import_internal.subSlot)(slot, "e:cleanup")
|
|
132
|
+
);
|
|
133
|
+
const register = (0, import_useStableCallback.useStableCallback)(
|
|
134
|
+
(source, registration) => {
|
|
135
|
+
if (!registration) {
|
|
136
|
+
if (activeFieldControlSourceRef.current === source) {
|
|
137
|
+
activeFieldControlSourceRef.current = null;
|
|
138
|
+
deleteRegistration();
|
|
139
|
+
registrationRef.current = null;
|
|
140
|
+
setRegisteredFieldName(void 0);
|
|
141
|
+
setRegisteredFieldId(void 0);
|
|
142
|
+
}
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const previousId = registrationRef.current?.id;
|
|
146
|
+
activeFieldControlSourceRef.current = source;
|
|
147
|
+
registrationRef.current = registration;
|
|
148
|
+
if (!name) {
|
|
149
|
+
setRegisteredFieldName(registration.name);
|
|
150
|
+
}
|
|
151
|
+
setRegisteredFieldId(registration.id);
|
|
152
|
+
if (previousId && previousId !== registration.id) {
|
|
153
|
+
deleteRegistration(previousId);
|
|
154
|
+
}
|
|
155
|
+
syncInitialValue();
|
|
156
|
+
refreshRegistration();
|
|
157
|
+
},
|
|
158
|
+
(0, import_internal.subSlot)(slot, "register")
|
|
159
|
+
);
|
|
160
|
+
return [validate, register];
|
|
161
|
+
}
|
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
163
|
+
0 && (module.exports = {
|
|
164
|
+
useFieldControlRegistration
|
|
165
|
+
});
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useFieldValidation_exports = {};
|
|
20
|
+
__export(useFieldValidation_exports, {
|
|
21
|
+
useFieldValidation: () => useFieldValidation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useFieldValidation_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_mergeProps = require("../mergeProps.cjs");
|
|
27
|
+
var import_useTimeout = require("../useTimeout.cjs");
|
|
28
|
+
var import_useRefWithInit = require("../useRefWithInit.cjs");
|
|
29
|
+
var import_useStableCallback = require("../useStableCallback.cjs");
|
|
30
|
+
var import_constants = require("./constants.cjs");
|
|
31
|
+
var import_getCombinedFieldValidityData = require("./getCombinedFieldValidityData.cjs");
|
|
32
|
+
var import_FormContext = require("./FormContext.cjs");
|
|
33
|
+
var import_LabelableContext = require("./LabelableContext.cjs");
|
|
34
|
+
const validityKeys = Object.keys(import_constants.DEFAULT_VALIDITY_STATE);
|
|
35
|
+
function isOnlyValueMissing(state) {
|
|
36
|
+
if (!state || state.valid || !state.valueMissing) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
let onlyValueMissing = false;
|
|
40
|
+
for (const key of validityKeys) {
|
|
41
|
+
if (key === "valid") {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (key === "valueMissing") {
|
|
45
|
+
onlyValueMissing = state[key];
|
|
46
|
+
} else if (state[key]) {
|
|
47
|
+
onlyValueMissing = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return onlyValueMissing;
|
|
51
|
+
}
|
|
52
|
+
function findRepresentativeInput(inputs) {
|
|
53
|
+
let fallback = null;
|
|
54
|
+
for (const input of inputs) {
|
|
55
|
+
if (input.disabled) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (!input.validity.valid) {
|
|
59
|
+
return input;
|
|
60
|
+
}
|
|
61
|
+
fallback ??= input;
|
|
62
|
+
}
|
|
63
|
+
return fallback;
|
|
64
|
+
}
|
|
65
|
+
function clearCustomValidity(element, inputs) {
|
|
66
|
+
let didClearElement = false;
|
|
67
|
+
for (const input of inputs) {
|
|
68
|
+
input.setCustomValidity("");
|
|
69
|
+
didClearElement ||= input === element;
|
|
70
|
+
}
|
|
71
|
+
if (!didClearElement) {
|
|
72
|
+
element.setCustomValidity("");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function useFieldValidation(...args) {
|
|
76
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
77
|
+
const slot = slotArg ?? (0, import_internal.S)("useFieldValidation");
|
|
78
|
+
const params = user[0];
|
|
79
|
+
const { formRef } = (0, import_FormContext.useFormContext)();
|
|
80
|
+
const {
|
|
81
|
+
setValidityData,
|
|
82
|
+
validate,
|
|
83
|
+
validityData,
|
|
84
|
+
validationDebounceTime,
|
|
85
|
+
invalid,
|
|
86
|
+
markedDirtyRef,
|
|
87
|
+
state,
|
|
88
|
+
shouldValidateOnChange,
|
|
89
|
+
getRegisteredFieldId
|
|
90
|
+
} = params;
|
|
91
|
+
const { controlId, getDescriptionProps } = (0, import_LabelableContext.useLabelableContext)();
|
|
92
|
+
const timeout = (0, import_useTimeout.useTimeout)((0, import_internal.subSlot)(slot, "timeout"));
|
|
93
|
+
const inputRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "inputRef"));
|
|
94
|
+
const registeredInputs = (0, import_useRefWithInit.useRefWithInit)(
|
|
95
|
+
() => /* @__PURE__ */ new Set(),
|
|
96
|
+
(0, import_internal.subSlot)(slot, "registered")
|
|
97
|
+
).current;
|
|
98
|
+
const validationCommitIdRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "commitId"));
|
|
99
|
+
const registerInput = (0, import_octane.useCallback)(
|
|
100
|
+
(element) => {
|
|
101
|
+
if (!element) {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
registeredInputs.add(element);
|
|
105
|
+
return () => {
|
|
106
|
+
registeredInputs.delete(element);
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
[registeredInputs],
|
|
110
|
+
(0, import_internal.subSlot)(slot, "registerInput")
|
|
111
|
+
);
|
|
112
|
+
const commit = (0, import_useStableCallback.useStableCallback)(
|
|
113
|
+
async (value, revalidate = false) => {
|
|
114
|
+
const element = findRepresentativeInput(registeredInputs) ?? inputRef.current;
|
|
115
|
+
if (!element) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
validationCommitIdRef.current += 1;
|
|
119
|
+
const validationCommitId = validationCommitIdRef.current;
|
|
120
|
+
function updateRegisteredFieldValidity(nextValidityData2, externalInvalid = invalid) {
|
|
121
|
+
const fieldId = getRegisteredFieldId() ?? controlId;
|
|
122
|
+
if (fieldId == null) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const currentFieldData = formRef.current.fields.get(fieldId);
|
|
126
|
+
if (!currentFieldData) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const validityDataWithFormErrors = (0, import_getCombinedFieldValidityData.getCombinedFieldValidityData)(
|
|
130
|
+
nextValidityData2,
|
|
131
|
+
externalInvalid
|
|
132
|
+
);
|
|
133
|
+
formRef.current.fields.set(fieldId, {
|
|
134
|
+
...currentFieldData,
|
|
135
|
+
validityData: validityDataWithFormErrors
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (revalidate) {
|
|
139
|
+
if (state.valid !== false) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const currentNativeValidity = element.validity;
|
|
143
|
+
if (!currentNativeValidity.valueMissing) {
|
|
144
|
+
const nextValidityData2 = {
|
|
145
|
+
value,
|
|
146
|
+
state: { ...import_constants.DEFAULT_VALIDITY_STATE, valid: true },
|
|
147
|
+
error: "",
|
|
148
|
+
errors: [],
|
|
149
|
+
initialValue: validityData.initialValue
|
|
150
|
+
};
|
|
151
|
+
clearCustomValidity(element, registeredInputs);
|
|
152
|
+
updateRegisteredFieldValidity(nextValidityData2, false);
|
|
153
|
+
setValidityData(nextValidityData2);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const currentNativeValidityObject = validityKeys.reduce(
|
|
157
|
+
(acc, key) => {
|
|
158
|
+
acc[key] = currentNativeValidity[key];
|
|
159
|
+
return acc;
|
|
160
|
+
},
|
|
161
|
+
{}
|
|
162
|
+
);
|
|
163
|
+
if (!currentNativeValidityObject.valid && !isOnlyValueMissing(currentNativeValidityObject)) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function getState(el) {
|
|
168
|
+
const computedState = validityKeys.reduce(
|
|
169
|
+
(acc, key) => {
|
|
170
|
+
acc[key] = el.validity[key];
|
|
171
|
+
return acc;
|
|
172
|
+
},
|
|
173
|
+
{}
|
|
174
|
+
);
|
|
175
|
+
let hasOnlyValueMissingError = false;
|
|
176
|
+
for (const key of validityKeys) {
|
|
177
|
+
if (key === "valid") {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (key === "valueMissing" && computedState[key]) {
|
|
181
|
+
hasOnlyValueMissingError = true;
|
|
182
|
+
} else if (computedState[key]) {
|
|
183
|
+
return computedState;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (hasOnlyValueMissingError && !markedDirtyRef.current) {
|
|
187
|
+
computedState.valid = true;
|
|
188
|
+
computedState.valueMissing = false;
|
|
189
|
+
}
|
|
190
|
+
return computedState;
|
|
191
|
+
}
|
|
192
|
+
timeout.clear();
|
|
193
|
+
let result = null;
|
|
194
|
+
let validationErrors = [];
|
|
195
|
+
const nextState = getState(element);
|
|
196
|
+
let defaultValidationMessage;
|
|
197
|
+
const isValidatingOnChange = shouldValidateOnChange();
|
|
198
|
+
if (element.validationMessage && !isValidatingOnChange) {
|
|
199
|
+
defaultValidationMessage = element.validationMessage;
|
|
200
|
+
validationErrors = [element.validationMessage];
|
|
201
|
+
} else {
|
|
202
|
+
const formValues = Array.from(formRef.current.fields.values()).reduce(
|
|
203
|
+
(acc, field) => {
|
|
204
|
+
if (field.name) {
|
|
205
|
+
acc[field.name] = field.getValue();
|
|
206
|
+
}
|
|
207
|
+
return acc;
|
|
208
|
+
},
|
|
209
|
+
{}
|
|
210
|
+
);
|
|
211
|
+
const resultOrPromise = validate(value, formValues);
|
|
212
|
+
if (typeof resultOrPromise === "object" && resultOrPromise !== null && "then" in resultOrPromise) {
|
|
213
|
+
result = await resultOrPromise;
|
|
214
|
+
if (validationCommitId !== validationCommitIdRef.current) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
result = resultOrPromise;
|
|
219
|
+
}
|
|
220
|
+
if (result !== null) {
|
|
221
|
+
nextState.valid = false;
|
|
222
|
+
nextState.customError = true;
|
|
223
|
+
if (Array.isArray(result)) {
|
|
224
|
+
validationErrors = result;
|
|
225
|
+
element.setCustomValidity(result.join("\n"));
|
|
226
|
+
} else if (result) {
|
|
227
|
+
validationErrors = [result];
|
|
228
|
+
element.setCustomValidity(result);
|
|
229
|
+
}
|
|
230
|
+
} else if (isValidatingOnChange) {
|
|
231
|
+
clearCustomValidity(element, registeredInputs);
|
|
232
|
+
nextState.customError = false;
|
|
233
|
+
if (element.validationMessage) {
|
|
234
|
+
defaultValidationMessage = element.validationMessage;
|
|
235
|
+
validationErrors = [element.validationMessage];
|
|
236
|
+
} else if (element.validity.valid && !nextState.valid) {
|
|
237
|
+
nextState.valid = true;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const nextValidityData = {
|
|
242
|
+
value,
|
|
243
|
+
state: nextState,
|
|
244
|
+
error: defaultValidationMessage ?? (Array.isArray(result) ? result[0] : result ?? ""),
|
|
245
|
+
errors: validationErrors,
|
|
246
|
+
initialValue: validityData.initialValue
|
|
247
|
+
};
|
|
248
|
+
updateRegisteredFieldValidity(nextValidityData);
|
|
249
|
+
setValidityData(nextValidityData);
|
|
250
|
+
},
|
|
251
|
+
(0, import_internal.subSlot)(slot, "commit")
|
|
252
|
+
);
|
|
253
|
+
const change = (0, import_useStableCallback.useStableCallback)(
|
|
254
|
+
(value) => {
|
|
255
|
+
timeout.clear();
|
|
256
|
+
const validateOnChange = shouldValidateOnChange();
|
|
257
|
+
if (validateOnChange && value !== "" && validationDebounceTime) {
|
|
258
|
+
validationCommitIdRef.current += 1;
|
|
259
|
+
timeout.start(validationDebounceTime, () => {
|
|
260
|
+
commit(value);
|
|
261
|
+
});
|
|
262
|
+
} else {
|
|
263
|
+
commit(value, !validateOnChange);
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
(0, import_internal.subSlot)(slot, "change")
|
|
267
|
+
);
|
|
268
|
+
const getValidationProps = (0, import_octane.useCallback)(
|
|
269
|
+
(disabled, externalProps = {}) => (0, import_mergeProps.mergeProps)(
|
|
270
|
+
getDescriptionProps(externalProps),
|
|
271
|
+
state.valid === false && !state.disabled && !disabled ? { "aria-invalid": true } : {}
|
|
272
|
+
),
|
|
273
|
+
[getDescriptionProps, state.disabled, state.valid],
|
|
274
|
+
(0, import_internal.subSlot)(slot, "getValidationProps")
|
|
275
|
+
);
|
|
276
|
+
return (0, import_octane.useMemo)(
|
|
277
|
+
() => ({ getValidationProps, inputRef, registerInput, commit, change }),
|
|
278
|
+
[getValidationProps, registerInput, commit, change],
|
|
279
|
+
(0, import_internal.subSlot)(slot, "return")
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
283
|
+
0 && (module.exports = {
|
|
284
|
+
useFieldValidation
|
|
285
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useLabel_exports = {};
|
|
20
|
+
__export(useLabel_exports, {
|
|
21
|
+
focusElementWithVisible: () => focusElementWithVisible,
|
|
22
|
+
useLabel: () => useLabel
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useLabel_exports);
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_list_utils = require("../composite/list-utils.cjs");
|
|
27
|
+
var import_owner = require("../owner.cjs");
|
|
28
|
+
var import_useRegisteredLabelId = require("../useRegisteredLabelId.cjs");
|
|
29
|
+
var import_useStableCallback = require("../useStableCallback.cjs");
|
|
30
|
+
var import_LabelableContext = require("./LabelableContext.cjs");
|
|
31
|
+
function isHTMLElement(el) {
|
|
32
|
+
return el != null && el instanceof HTMLElement;
|
|
33
|
+
}
|
|
34
|
+
function focusElementWithVisible(element) {
|
|
35
|
+
element.focus({ focusVisible: true });
|
|
36
|
+
}
|
|
37
|
+
function useLabel(...args) {
|
|
38
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
39
|
+
const slot = slotArg ?? (0, import_internal.S)("useLabel");
|
|
40
|
+
const {
|
|
41
|
+
id: idProp,
|
|
42
|
+
fallbackControlId,
|
|
43
|
+
native = false,
|
|
44
|
+
setLabelId: setLabelIdProp,
|
|
45
|
+
focusControl: focusControlProp
|
|
46
|
+
} = user[0] ?? {};
|
|
47
|
+
const { controlId: contextControlId, setLabelId: setContextLabelId } = (0, import_LabelableContext.useLabelableContext)();
|
|
48
|
+
const syncLabelId = (0, import_useStableCallback.useStableCallback)(
|
|
49
|
+
(nextLabelId) => {
|
|
50
|
+
setContextLabelId(nextLabelId);
|
|
51
|
+
setLabelIdProp?.(nextLabelId);
|
|
52
|
+
},
|
|
53
|
+
(0, import_internal.subSlot)(slot, "sync")
|
|
54
|
+
);
|
|
55
|
+
const id = (0, import_useRegisteredLabelId.useRegisteredLabelId)(idProp, syncLabelId, (0, import_internal.subSlot)(slot, "id"));
|
|
56
|
+
const resolvedControlId = contextControlId ?? fallbackControlId;
|
|
57
|
+
function focusControl(event) {
|
|
58
|
+
if (focusControlProp) {
|
|
59
|
+
focusControlProp(event, resolvedControlId);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!resolvedControlId) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const controlElement = (0, import_owner.ownerDocument)(event.currentTarget).getElementById(resolvedControlId);
|
|
66
|
+
if (isHTMLElement(controlElement)) {
|
|
67
|
+
focusElementWithVisible(controlElement);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function handleInteraction(event) {
|
|
71
|
+
const target = (0, import_list_utils.getTarget)(event);
|
|
72
|
+
if (target?.closest("button,input,select,textarea")) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!event.defaultPrevented && event.detail > 1) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
if (native) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
focusControl(event);
|
|
82
|
+
}
|
|
83
|
+
return native ? {
|
|
84
|
+
id,
|
|
85
|
+
htmlFor: resolvedControlId ?? void 0,
|
|
86
|
+
onMouseDown: handleInteraction
|
|
87
|
+
} : {
|
|
88
|
+
id,
|
|
89
|
+
onClick: handleInteraction,
|
|
90
|
+
onPointerDown(event) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
focusElementWithVisible,
|
|
98
|
+
useLabel
|
|
99
|
+
});
|