@octanejs/base-ui 0.1.30 → 0.1.32
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,475 @@
|
|
|
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 checkbox_exports = {};
|
|
20
|
+
__export(checkbox_exports, {
|
|
21
|
+
Checkbox: () => Checkbox,
|
|
22
|
+
PARENT_CHECKBOX: () => PARENT_CHECKBOX
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(checkbox_exports);
|
|
25
|
+
var import_octane = require("octane");
|
|
26
|
+
var import_internal = require("./internal.cjs");
|
|
27
|
+
var import_useRenderElement = require("./utils/useRenderElement.cjs");
|
|
28
|
+
var import_mergeProps = require("./utils/mergeProps.cjs");
|
|
29
|
+
var import_useBaseUiId = require("./utils/useBaseUiId.cjs");
|
|
30
|
+
var import_useButton = require("./utils/useButton.cjs");
|
|
31
|
+
var import_useControlled = require("./utils/useControlled.cjs");
|
|
32
|
+
var import_composeRefs = require("./utils/composeRefs.cjs");
|
|
33
|
+
var import_useRefWithInit = require("./utils/useRefWithInit.cjs");
|
|
34
|
+
var import_visuallyHidden = require("./utils/visuallyHidden.cjs");
|
|
35
|
+
var import_owner = require("./utils/owner.cjs");
|
|
36
|
+
var import_getDefaultFormSubmitter = require("./utils/getDefaultFormSubmitter.cjs");
|
|
37
|
+
var import_noop = require("./utils/noop.cjs");
|
|
38
|
+
var import_createChangeEventDetails = require("./utils/createChangeEventDetails.cjs");
|
|
39
|
+
var import_constants = require("./utils/field/constants.cjs");
|
|
40
|
+
var import_FieldRootContext = require("./utils/field/FieldRootContext.cjs");
|
|
41
|
+
var import_FieldItemContext = require("./utils/field/FieldItemContext.cjs");
|
|
42
|
+
var import_FormContext = require("./utils/field/FormContext.cjs");
|
|
43
|
+
var import_LabelableContext = require("./utils/field/LabelableContext.cjs");
|
|
44
|
+
var import_useRegisterFieldControl = require("./utils/field/useRegisterFieldControl.cjs");
|
|
45
|
+
var import_useAriaLabelledBy = require("./utils/field/useAriaLabelledBy.cjs");
|
|
46
|
+
var import_CheckboxGroupContext = require("./utils/CheckboxGroupContext.cjs");
|
|
47
|
+
var import_useValueChanged = require("./utils/useValueChanged.cjs");
|
|
48
|
+
var import_useTransitionStatus = require("./utils/useTransitionStatus.cjs");
|
|
49
|
+
var import_useOpenChangeComplete = require("./utils/useOpenChangeComplete.cjs");
|
|
50
|
+
const PARENT_CHECKBOX = "data-parent";
|
|
51
|
+
function useStateAttributesMapping(state) {
|
|
52
|
+
return (0, import_octane.useMemo)(
|
|
53
|
+
() => ({
|
|
54
|
+
checked(value) {
|
|
55
|
+
if (state.indeterminate) {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
if (value) {
|
|
59
|
+
return { "data-checked": "" };
|
|
60
|
+
}
|
|
61
|
+
return { "data-unchecked": "" };
|
|
62
|
+
},
|
|
63
|
+
...import_constants.fieldValidityMapping
|
|
64
|
+
}),
|
|
65
|
+
[state.indeterminate],
|
|
66
|
+
(0, import_internal.S)("Checkbox.mapping")
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const CheckboxRootContext = (0, import_octane.createContext)(void 0);
|
|
70
|
+
function useCheckboxRootContext() {
|
|
71
|
+
const context = (0, import_octane.useContext)(CheckboxRootContext);
|
|
72
|
+
if (context === void 0) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"Base UI: CheckboxRootContext is missing. Checkbox parts must be placed within <Checkbox.Root>."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return context;
|
|
78
|
+
}
|
|
79
|
+
function CheckboxRoot(props) {
|
|
80
|
+
const slot = (0, import_internal.S)("CheckboxRoot");
|
|
81
|
+
const {
|
|
82
|
+
checked: checkedProp,
|
|
83
|
+
className,
|
|
84
|
+
defaultChecked = false,
|
|
85
|
+
"aria-labelledby": ariaLabelledByProp,
|
|
86
|
+
disabled: disabledProp = false,
|
|
87
|
+
form,
|
|
88
|
+
id: idProp,
|
|
89
|
+
indeterminate = false,
|
|
90
|
+
inputRef: inputRefProp,
|
|
91
|
+
name: nameProp,
|
|
92
|
+
onCheckedChange,
|
|
93
|
+
parent = false,
|
|
94
|
+
readOnly = false,
|
|
95
|
+
render,
|
|
96
|
+
required = false,
|
|
97
|
+
uncheckedValue,
|
|
98
|
+
value: valueProp,
|
|
99
|
+
nativeButton = false,
|
|
100
|
+
style,
|
|
101
|
+
ref,
|
|
102
|
+
...elementProps
|
|
103
|
+
} = props;
|
|
104
|
+
const { clearErrors } = (0, import_FormContext.useFormContext)();
|
|
105
|
+
const {
|
|
106
|
+
disabled: rootDisabled,
|
|
107
|
+
name: fieldName,
|
|
108
|
+
setDirty,
|
|
109
|
+
setFilled,
|
|
110
|
+
setFocused,
|
|
111
|
+
setTouched,
|
|
112
|
+
state: fieldState,
|
|
113
|
+
validationMode,
|
|
114
|
+
validityData,
|
|
115
|
+
validation: localValidation
|
|
116
|
+
} = (0, import_FieldRootContext.useFieldRootContext)();
|
|
117
|
+
const fieldItemContext = (0, import_FieldItemContext.useFieldItemContext)();
|
|
118
|
+
const { labelId, controlId, registerControlId, getDescriptionProps } = (0, import_LabelableContext.useLabelableContext)();
|
|
119
|
+
const groupContext = (0, import_CheckboxGroupContext.useCheckboxGroupContext)();
|
|
120
|
+
const parentContext = groupContext?.parent;
|
|
121
|
+
const isGroupedWithParent = parentContext && groupContext.allValues;
|
|
122
|
+
const disabled = rootDisabled || fieldItemContext.disabled || groupContext?.disabled || disabledProp;
|
|
123
|
+
const name = fieldName ?? nameProp;
|
|
124
|
+
const value = valueProp ?? name;
|
|
125
|
+
const id = (0, import_useBaseUiId.useBaseUiId)(void 0, (0, import_internal.subSlot)(slot, "id"));
|
|
126
|
+
const parentId = (0, import_useBaseUiId.useBaseUiId)(void 0, (0, import_internal.subSlot)(slot, "parentId"));
|
|
127
|
+
let inputId = controlId;
|
|
128
|
+
if (isGroupedWithParent) {
|
|
129
|
+
inputId = parent ? parentId : `${parentContext.id}-${value}`;
|
|
130
|
+
} else if (idProp) {
|
|
131
|
+
inputId = idProp;
|
|
132
|
+
}
|
|
133
|
+
let groupProps = {};
|
|
134
|
+
if (isGroupedWithParent) {
|
|
135
|
+
if (parent) {
|
|
136
|
+
groupProps = groupContext.parent.getParentProps();
|
|
137
|
+
} else if (value) {
|
|
138
|
+
groupProps = groupContext.parent.getChildProps(value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const {
|
|
142
|
+
checked: groupChecked = checkedProp,
|
|
143
|
+
indeterminate: groupIndeterminate = indeterminate,
|
|
144
|
+
onCheckedChange: groupOnChange,
|
|
145
|
+
...otherGroupProps
|
|
146
|
+
} = groupProps;
|
|
147
|
+
const groupValue = groupContext?.value;
|
|
148
|
+
const setGroupValue = groupContext?.setValue;
|
|
149
|
+
const defaultGroupValue = groupContext?.defaultValue;
|
|
150
|
+
const controlRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "controlRef"));
|
|
151
|
+
const controlSourceRef = (0, import_useRefWithInit.useRefWithInit)(
|
|
152
|
+
() => /* @__PURE__ */ Symbol("checkbox-control"),
|
|
153
|
+
(0, import_internal.subSlot)(slot, "controlSrc")
|
|
154
|
+
);
|
|
155
|
+
const hasRegisteredRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "hasReg"));
|
|
156
|
+
const { getButtonProps, buttonRef } = (0, import_useButton.useButton)(
|
|
157
|
+
{ disabled, native: nativeButton },
|
|
158
|
+
(0, import_internal.subSlot)(slot, "button")
|
|
159
|
+
);
|
|
160
|
+
const validation = groupContext?.validation ?? localValidation;
|
|
161
|
+
const [checked, setCheckedState] = (0, import_useControlled.useControlled)(
|
|
162
|
+
{
|
|
163
|
+
controlled: value && groupValue && !parent ? groupValue.includes(value) : groupChecked,
|
|
164
|
+
default: value && defaultGroupValue && !parent ? defaultGroupValue.includes(value) : defaultChecked,
|
|
165
|
+
name: "Checkbox",
|
|
166
|
+
state: "checked"
|
|
167
|
+
},
|
|
168
|
+
(0, import_internal.subSlot)(slot, "checked")
|
|
169
|
+
);
|
|
170
|
+
const computedChecked = isGroupedWithParent ? Boolean(groupChecked) : checked;
|
|
171
|
+
const computedIndeterminate = isGroupedWithParent ? groupIndeterminate || indeterminate : indeterminate;
|
|
172
|
+
(0, import_octane.useLayoutEffect)(
|
|
173
|
+
() => {
|
|
174
|
+
if (registerControlId === import_noop.NOOP) {
|
|
175
|
+
return void 0;
|
|
176
|
+
}
|
|
177
|
+
hasRegisteredRef.current = true;
|
|
178
|
+
registerControlId(controlSourceRef.current, inputId);
|
|
179
|
+
return void 0;
|
|
180
|
+
},
|
|
181
|
+
[inputId, registerControlId, controlSourceRef],
|
|
182
|
+
(0, import_internal.subSlot)(slot, "e:regId")
|
|
183
|
+
);
|
|
184
|
+
(0, import_octane.useEffect)(
|
|
185
|
+
() => {
|
|
186
|
+
const controlSource = controlSourceRef.current;
|
|
187
|
+
return () => {
|
|
188
|
+
if (!hasRegisteredRef.current || registerControlId === import_noop.NOOP) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
hasRegisteredRef.current = false;
|
|
192
|
+
registerControlId(controlSource, void 0);
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
[registerControlId, controlSourceRef],
|
|
196
|
+
(0, import_internal.subSlot)(slot, "e:unregId")
|
|
197
|
+
);
|
|
198
|
+
(0, import_useRegisterFieldControl.useRegisterFieldControl)(
|
|
199
|
+
controlRef,
|
|
200
|
+
id,
|
|
201
|
+
checked,
|
|
202
|
+
void 0,
|
|
203
|
+
!groupContext && !disabled,
|
|
204
|
+
nameProp,
|
|
205
|
+
(0, import_internal.subSlot)(slot, "register")
|
|
206
|
+
);
|
|
207
|
+
const inputRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "inputRef"));
|
|
208
|
+
const mergedInputRef = (0, import_composeRefs.useComposedRefs)(
|
|
209
|
+
inputRefProp,
|
|
210
|
+
inputRef,
|
|
211
|
+
validation.inputRef,
|
|
212
|
+
validation.registerInput,
|
|
213
|
+
(0, import_internal.subSlot)(slot, "mergedInputRef")
|
|
214
|
+
);
|
|
215
|
+
const ariaLabelledBy = (0, import_useAriaLabelledBy.useAriaLabelledBy)(
|
|
216
|
+
ariaLabelledByProp,
|
|
217
|
+
labelId,
|
|
218
|
+
inputRef,
|
|
219
|
+
!nativeButton,
|
|
220
|
+
inputId ?? void 0,
|
|
221
|
+
(0, import_internal.subSlot)(slot, "ariaLabelledBy")
|
|
222
|
+
);
|
|
223
|
+
(0, import_octane.useLayoutEffect)(
|
|
224
|
+
() => {
|
|
225
|
+
const input = inputRef.current;
|
|
226
|
+
if (!input) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
input.indeterminate = computedIndeterminate;
|
|
230
|
+
if (checked) {
|
|
231
|
+
setFilled(true);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
[checked, computedIndeterminate, setFilled],
|
|
235
|
+
(0, import_internal.subSlot)(slot, "e:sync")
|
|
236
|
+
);
|
|
237
|
+
(0, import_useValueChanged.useValueChanged)(
|
|
238
|
+
checked,
|
|
239
|
+
() => {
|
|
240
|
+
if (groupContext) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
clearErrors(name);
|
|
244
|
+
setFilled(checked);
|
|
245
|
+
setDirty(checked !== validityData.initialValue);
|
|
246
|
+
validation.change(checked);
|
|
247
|
+
},
|
|
248
|
+
(0, import_internal.subSlot)(slot, "valueChanged")
|
|
249
|
+
);
|
|
250
|
+
const inputProps = (0, import_mergeProps.mergeProps)(
|
|
251
|
+
{
|
|
252
|
+
checked,
|
|
253
|
+
disabled,
|
|
254
|
+
form,
|
|
255
|
+
name: parent ? void 0 : name,
|
|
256
|
+
id: nativeButton ? void 0 : inputId ?? void 0,
|
|
257
|
+
required,
|
|
258
|
+
ref: mergedInputRef,
|
|
259
|
+
style: name ? import_visuallyHidden.visuallyHiddenInput : import_visuallyHidden.visuallyHidden,
|
|
260
|
+
tabIndex: -1,
|
|
261
|
+
type: "checkbox",
|
|
262
|
+
"aria-hidden": true,
|
|
263
|
+
onChange(event) {
|
|
264
|
+
if (event.defaultPrevented) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (readOnly) {
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const nextChecked = event.currentTarget.checked;
|
|
272
|
+
const details = (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.none, event);
|
|
273
|
+
onCheckedChange?.(nextChecked, details);
|
|
274
|
+
if (details.isCanceled) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
groupOnChange?.(nextChecked, details);
|
|
278
|
+
if (details.isCanceled) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
setCheckedState(nextChecked);
|
|
282
|
+
if (value && groupValue && setGroupValue && !parent && !isGroupedWithParent) {
|
|
283
|
+
const nextGroupValue = nextChecked ? [...groupValue, value] : groupValue.filter((item) => item !== value);
|
|
284
|
+
setGroupValue(nextGroupValue, details);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
onFocus() {
|
|
288
|
+
controlRef.current?.focus();
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
valueProp !== void 0 ? { value: (groupContext ? checked && valueProp : valueProp) || "" } : {},
|
|
292
|
+
getDescriptionProps,
|
|
293
|
+
(p) => validation.getValidationProps(disabled, p)
|
|
294
|
+
);
|
|
295
|
+
(0, import_octane.useEffect)(
|
|
296
|
+
() => {
|
|
297
|
+
if (!parentContext || !value) {
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
const disabledStates = parentContext.disabledStatesRef.current;
|
|
301
|
+
disabledStates.set(value, disabled);
|
|
302
|
+
return () => {
|
|
303
|
+
disabledStates.delete(value);
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
[parentContext, disabled, value],
|
|
307
|
+
(0, import_internal.subSlot)(slot, "e:parentDisabled")
|
|
308
|
+
);
|
|
309
|
+
const state = (0, import_octane.useMemo)(
|
|
310
|
+
() => ({
|
|
311
|
+
...fieldState,
|
|
312
|
+
checked: computedChecked,
|
|
313
|
+
disabled,
|
|
314
|
+
readOnly,
|
|
315
|
+
required,
|
|
316
|
+
indeterminate: computedIndeterminate
|
|
317
|
+
}),
|
|
318
|
+
[fieldState, computedChecked, disabled, readOnly, required, computedIndeterminate],
|
|
319
|
+
(0, import_internal.subSlot)(slot, "state")
|
|
320
|
+
);
|
|
321
|
+
const stateAttributesMapping = useStateAttributesMapping(state);
|
|
322
|
+
const element = (0, import_useRenderElement.useRenderElement)(
|
|
323
|
+
"span",
|
|
324
|
+
{ render, className, style },
|
|
325
|
+
{
|
|
326
|
+
state,
|
|
327
|
+
ref: [buttonRef, controlRef, ref, groupContext?.registerControlRef],
|
|
328
|
+
props: [
|
|
329
|
+
{
|
|
330
|
+
id: nativeButton ? inputId ?? void 0 : id,
|
|
331
|
+
role: "checkbox",
|
|
332
|
+
"aria-checked": computedIndeterminate ? "mixed" : computedChecked,
|
|
333
|
+
"aria-readonly": readOnly || void 0,
|
|
334
|
+
"aria-required": required || void 0,
|
|
335
|
+
"aria-labelledby": ariaLabelledBy,
|
|
336
|
+
[PARENT_CHECKBOX]: parent ? "" : void 0,
|
|
337
|
+
onFocus() {
|
|
338
|
+
if (!disabled) {
|
|
339
|
+
setFocused(true);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
onBlur() {
|
|
343
|
+
const inputEl = inputRef.current;
|
|
344
|
+
if (!inputEl) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
setTouched(true);
|
|
348
|
+
setFocused(false);
|
|
349
|
+
if (validationMode === "onBlur") {
|
|
350
|
+
validation.commit(groupContext ? groupValue : inputEl.checked);
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
onKeyDown(event) {
|
|
354
|
+
if (event.key !== "Enter") {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
(0, import_mergeProps.makeEventPreventable)(event);
|
|
358
|
+
event.preventBaseUIHandler?.();
|
|
359
|
+
if (event.defaultPrevented) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const formToSubmit = inputRef.current?.form ?? null;
|
|
363
|
+
const currentTarget = event.currentTarget;
|
|
364
|
+
const originalPreventDefault = event.preventDefault.bind(event);
|
|
365
|
+
let preventDefaultCalledAfterPropagation = false;
|
|
366
|
+
event.preventDefault = () => {
|
|
367
|
+
preventDefaultCalledAfterPropagation = true;
|
|
368
|
+
originalPreventDefault();
|
|
369
|
+
};
|
|
370
|
+
originalPreventDefault();
|
|
371
|
+
(0, import_owner.ownerWindow)(currentTarget).queueMicrotask(() => {
|
|
372
|
+
event.preventDefault = originalPreventDefault;
|
|
373
|
+
if (!preventDefaultCalledAfterPropagation) {
|
|
374
|
+
(0, import_getDefaultFormSubmitter.getDefaultFormSubmitter)(formToSubmit)?.click();
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
onClick(event) {
|
|
379
|
+
if (readOnly || disabled) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
event.preventDefault();
|
|
383
|
+
const input = inputRef.current;
|
|
384
|
+
if (!input) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
input.dispatchEvent(
|
|
388
|
+
new ((0, import_owner.ownerWindow)(input)).PointerEvent("click", {
|
|
389
|
+
bubbles: true,
|
|
390
|
+
shiftKey: event.shiftKey,
|
|
391
|
+
ctrlKey: event.ctrlKey,
|
|
392
|
+
altKey: event.altKey,
|
|
393
|
+
metaKey: event.metaKey
|
|
394
|
+
})
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
elementProps,
|
|
399
|
+
otherGroupProps,
|
|
400
|
+
getButtonProps,
|
|
401
|
+
getDescriptionProps,
|
|
402
|
+
(p) => validation.getValidationProps(disabled, p)
|
|
403
|
+
],
|
|
404
|
+
stateAttributesMapping
|
|
405
|
+
},
|
|
406
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
407
|
+
);
|
|
408
|
+
const hiddenValueInput = !checked && !groupContext && name && !parent && uncheckedValue !== void 0 ? (0, import_octane.createElement)("input", {
|
|
409
|
+
type: "hidden",
|
|
410
|
+
form,
|
|
411
|
+
name,
|
|
412
|
+
value: uncheckedValue,
|
|
413
|
+
disabled
|
|
414
|
+
}) : null;
|
|
415
|
+
return (0, import_octane.createElement)(CheckboxRootContext.Provider, {
|
|
416
|
+
value: state,
|
|
417
|
+
// Octane reconciles an ARRAY child as a keyed list, so each slot carries a stable key;
|
|
418
|
+
// values that cannot be keyed in place go through a keyed Fragment.
|
|
419
|
+
children: [
|
|
420
|
+
(0, import_octane.createElement)(import_octane.Fragment, { key: "element", children: element }),
|
|
421
|
+
(0, import_octane.createElement)(import_octane.Fragment, { key: "hidden-value", children: hiddenValueInput }),
|
|
422
|
+
(0, import_octane.createElement)("input", { key: "input", ...inputProps })
|
|
423
|
+
]
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
function CheckboxIndicator(props) {
|
|
427
|
+
const slot = (0, import_internal.S)("CheckboxIndicator");
|
|
428
|
+
const { render, className, style, keepMounted = false, ref, ...elementProps } = props;
|
|
429
|
+
const rootState = useCheckboxRootContext();
|
|
430
|
+
const rendered = rootState.checked || rootState.indeterminate;
|
|
431
|
+
const { mounted, transitionStatus, setMounted } = (0, import_useTransitionStatus.useTransitionStatus)(
|
|
432
|
+
rendered,
|
|
433
|
+
(0, import_internal.subSlot)(slot, "ts")
|
|
434
|
+
);
|
|
435
|
+
const indicatorRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "indRef"));
|
|
436
|
+
const state = { ...rootState, transitionStatus };
|
|
437
|
+
(0, import_useOpenChangeComplete.useOpenChangeComplete)(
|
|
438
|
+
{
|
|
439
|
+
open: rendered,
|
|
440
|
+
ref: indicatorRef,
|
|
441
|
+
onComplete() {
|
|
442
|
+
if (!rendered) {
|
|
443
|
+
setMounted(false);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
(0, import_internal.subSlot)(slot, "occ")
|
|
448
|
+
);
|
|
449
|
+
const baseStateAttributesMapping = useStateAttributesMapping(rootState);
|
|
450
|
+
const stateAttributesMapping = {
|
|
451
|
+
...baseStateAttributesMapping,
|
|
452
|
+
...import_useTransitionStatus.transitionStatusMapping,
|
|
453
|
+
...import_constants.fieldValidityMapping
|
|
454
|
+
};
|
|
455
|
+
const shouldRender = keepMounted || mounted;
|
|
456
|
+
const element = (0, import_useRenderElement.useRenderElement)(
|
|
457
|
+
"span",
|
|
458
|
+
{ render, className, style },
|
|
459
|
+
{ ref: [ref, indicatorRef], state, stateAttributesMapping, props: elementProps },
|
|
460
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
461
|
+
);
|
|
462
|
+
if (!shouldRender) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
return element;
|
|
466
|
+
}
|
|
467
|
+
const Checkbox = {
|
|
468
|
+
Root: CheckboxRoot,
|
|
469
|
+
Indicator: CheckboxIndicator
|
|
470
|
+
};
|
|
471
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
472
|
+
0 && (module.exports = {
|
|
473
|
+
Checkbox,
|
|
474
|
+
PARENT_CHECKBOX
|
|
475
|
+
});
|