@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,206 @@
|
|
|
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 progress_exports = {};
|
|
20
|
+
__export(progress_exports, {
|
|
21
|
+
Progress: () => Progress
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(progress_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("./internal.cjs");
|
|
26
|
+
var import_useRenderElement = require("./utils/useRenderElement.cjs");
|
|
27
|
+
var import_useRegisteredLabelId = require("./utils/useRegisteredLabelId.cjs");
|
|
28
|
+
var import_useValueAsRef = require("./utils/useValueAsRef.cjs");
|
|
29
|
+
var import_valueToPercent = require("./utils/valueToPercent.cjs");
|
|
30
|
+
var import_formatNumber = require("./utils/formatNumber.cjs");
|
|
31
|
+
var import_visuallyHidden = require("./utils/visuallyHidden.cjs");
|
|
32
|
+
const progressStateAttributesMapping = {
|
|
33
|
+
status(value) {
|
|
34
|
+
if (value === "progressing") {
|
|
35
|
+
return { "data-progressing": "" };
|
|
36
|
+
}
|
|
37
|
+
if (value === "complete") {
|
|
38
|
+
return { "data-complete": "" };
|
|
39
|
+
}
|
|
40
|
+
if (value === "indeterminate") {
|
|
41
|
+
return { "data-indeterminate": "" };
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const ProgressRootContext = (0, import_octane.createContext)(void 0);
|
|
47
|
+
function useProgressRootContext() {
|
|
48
|
+
const context = (0, import_octane.useContext)(ProgressRootContext);
|
|
49
|
+
if (context === void 0) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"Base UI: ProgressRootContext is missing. Progress parts must be placed within <Progress.Root>."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return context;
|
|
55
|
+
}
|
|
56
|
+
function getDefaultAriaValueText(formattedValue, value) {
|
|
57
|
+
if (value == null) {
|
|
58
|
+
return "indeterminate progress";
|
|
59
|
+
}
|
|
60
|
+
return formattedValue || `${value}%`;
|
|
61
|
+
}
|
|
62
|
+
function ProgressRoot(props) {
|
|
63
|
+
const slot = (0, import_internal.S)("ProgressRoot");
|
|
64
|
+
const {
|
|
65
|
+
format,
|
|
66
|
+
getAriaValueText = getDefaultAriaValueText,
|
|
67
|
+
locale,
|
|
68
|
+
max = 100,
|
|
69
|
+
min = 0,
|
|
70
|
+
value,
|
|
71
|
+
render,
|
|
72
|
+
className,
|
|
73
|
+
children,
|
|
74
|
+
style,
|
|
75
|
+
ref,
|
|
76
|
+
...elementProps
|
|
77
|
+
} = props;
|
|
78
|
+
const [labelId, setLabelId] = (0, import_octane.useState)(void 0, (0, import_internal.subSlot)(slot, "labelId"));
|
|
79
|
+
const formatOptionsRef = (0, import_useValueAsRef.useValueAsRef)(
|
|
80
|
+
format,
|
|
81
|
+
(0, import_internal.subSlot)(slot, "fmt")
|
|
82
|
+
);
|
|
83
|
+
let status = "indeterminate";
|
|
84
|
+
if (Number.isFinite(value)) {
|
|
85
|
+
status = value === max ? "complete" : "progressing";
|
|
86
|
+
}
|
|
87
|
+
const formattedValue = (0, import_formatNumber.formatNumberValue)(value, locale, formatOptionsRef.current);
|
|
88
|
+
const state = (0, import_octane.useMemo)(() => ({ status }), [status], (0, import_internal.subSlot)(slot, "state"));
|
|
89
|
+
const defaultProps = {
|
|
90
|
+
"aria-labelledby": labelId,
|
|
91
|
+
"aria-valuemax": max,
|
|
92
|
+
"aria-valuemin": min,
|
|
93
|
+
"aria-valuenow": value ?? void 0,
|
|
94
|
+
"aria-valuetext": getAriaValueText(formattedValue, value),
|
|
95
|
+
role: "progressbar",
|
|
96
|
+
// Array children reconcile as a keyed list in octane, so both slots carry a key. The
|
|
97
|
+
// consumer's go through a keyed Fragment because they cannot be keyed in place.
|
|
98
|
+
children: [
|
|
99
|
+
(0, import_octane.createElement)(import_octane.Fragment, { key: "children", children }),
|
|
100
|
+
(0, import_octane.createElement)("span", {
|
|
101
|
+
key: "sr-hint",
|
|
102
|
+
role: "presentation",
|
|
103
|
+
style: import_visuallyHidden.visuallyHidden,
|
|
104
|
+
children: "x"
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
const contextValue = (0, import_octane.useMemo)(
|
|
109
|
+
() => ({ formattedValue, max, min, setLabelId, state, status, value }),
|
|
110
|
+
[formattedValue, max, min, setLabelId, state, status, value],
|
|
111
|
+
(0, import_internal.subSlot)(slot, "ctx")
|
|
112
|
+
);
|
|
113
|
+
const element = (0, import_useRenderElement.useRenderElement)(
|
|
114
|
+
"div",
|
|
115
|
+
{ render, className, style },
|
|
116
|
+
{
|
|
117
|
+
state,
|
|
118
|
+
ref,
|
|
119
|
+
props: [defaultProps, elementProps],
|
|
120
|
+
stateAttributesMapping: progressStateAttributesMapping
|
|
121
|
+
},
|
|
122
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
123
|
+
);
|
|
124
|
+
return (0, import_octane.createElement)(ProgressRootContext.Provider, { value: contextValue, children: element });
|
|
125
|
+
}
|
|
126
|
+
function ProgressTrack(props) {
|
|
127
|
+
const slot = (0, import_internal.S)("ProgressTrack");
|
|
128
|
+
const { render, className, style, ref, ...elementProps } = props;
|
|
129
|
+
const { state } = useProgressRootContext();
|
|
130
|
+
return (0, import_useRenderElement.useRenderElement)(
|
|
131
|
+
"div",
|
|
132
|
+
{ render, className, style },
|
|
133
|
+
{ state, ref, props: elementProps, stateAttributesMapping: progressStateAttributesMapping },
|
|
134
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function ProgressIndicator(props) {
|
|
138
|
+
const slot = (0, import_internal.S)("ProgressIndicator");
|
|
139
|
+
const { render, className, style, ref, ...elementProps } = props;
|
|
140
|
+
const { max, min, value, state } = useProgressRootContext();
|
|
141
|
+
const percentageValue = Number.isFinite(value) && value !== null ? (0, import_valueToPercent.valueToPercent)(value, min, max) : null;
|
|
142
|
+
const indicatorStyle = percentageValue == null ? {} : { insetInlineStart: 0, height: "inherit", width: `${percentageValue}%` };
|
|
143
|
+
return (0, import_useRenderElement.useRenderElement)(
|
|
144
|
+
"div",
|
|
145
|
+
{ render, className, style },
|
|
146
|
+
{
|
|
147
|
+
state,
|
|
148
|
+
ref,
|
|
149
|
+
props: [{ style: indicatorStyle }, elementProps],
|
|
150
|
+
stateAttributesMapping: progressStateAttributesMapping
|
|
151
|
+
},
|
|
152
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function ProgressValue(props) {
|
|
156
|
+
const slot = (0, import_internal.S)("ProgressValue");
|
|
157
|
+
const { className, render, children, style, ref, ...elementProps } = props;
|
|
158
|
+
const { value, formattedValue, state } = useProgressRootContext();
|
|
159
|
+
const formattedValueArg = value == null ? "indeterminate" : formattedValue;
|
|
160
|
+
const formattedValueDisplay = value == null ? null : formattedValue;
|
|
161
|
+
return (0, import_useRenderElement.useRenderElement)(
|
|
162
|
+
"span",
|
|
163
|
+
{ render, className, style },
|
|
164
|
+
{
|
|
165
|
+
state,
|
|
166
|
+
ref,
|
|
167
|
+
props: [
|
|
168
|
+
{
|
|
169
|
+
"aria-hidden": true,
|
|
170
|
+
children: typeof children === "function" ? children(formattedValueArg, value) : formattedValueDisplay
|
|
171
|
+
},
|
|
172
|
+
elementProps
|
|
173
|
+
],
|
|
174
|
+
stateAttributesMapping: progressStateAttributesMapping
|
|
175
|
+
},
|
|
176
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
function ProgressLabel(props) {
|
|
180
|
+
const slot = (0, import_internal.S)("ProgressLabel");
|
|
181
|
+
const { render, className, style, id: idProp, ref, ...elementProps } = props;
|
|
182
|
+
const { setLabelId, state } = useProgressRootContext();
|
|
183
|
+
const id = (0, import_useRegisteredLabelId.useRegisteredLabelId)(idProp, setLabelId, (0, import_internal.subSlot)(slot, "labelId"));
|
|
184
|
+
return (0, import_useRenderElement.useRenderElement)(
|
|
185
|
+
"span",
|
|
186
|
+
{ render, className, style },
|
|
187
|
+
{
|
|
188
|
+
state,
|
|
189
|
+
ref,
|
|
190
|
+
props: [{ id, role: "presentation" }, elementProps],
|
|
191
|
+
stateAttributesMapping: progressStateAttributesMapping
|
|
192
|
+
},
|
|
193
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
const Progress = {
|
|
197
|
+
Root: ProgressRoot,
|
|
198
|
+
Track: ProgressTrack,
|
|
199
|
+
Indicator: ProgressIndicator,
|
|
200
|
+
Value: ProgressValue,
|
|
201
|
+
Label: ProgressLabel
|
|
202
|
+
};
|
|
203
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
204
|
+
0 && (module.exports = {
|
|
205
|
+
Progress
|
|
206
|
+
});
|
|
@@ -0,0 +1,264 @@
|
|
|
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 radio_group_exports = {};
|
|
20
|
+
__export(radio_group_exports, {
|
|
21
|
+
RadioGroup: () => RadioGroup
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(radio_group_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("./internal.cjs");
|
|
26
|
+
var import_CompositeRoot = require("./utils/composite/CompositeRoot.cjs");
|
|
27
|
+
var import_keys = require("./utils/composite/keys.cjs");
|
|
28
|
+
var import_contains = require("./utils/contains.cjs");
|
|
29
|
+
var import_useBaseUiId = require("./utils/useBaseUiId.cjs");
|
|
30
|
+
var import_useControlled = require("./utils/useControlled.cjs");
|
|
31
|
+
var import_useStableCallback = require("./utils/useStableCallback.cjs");
|
|
32
|
+
var import_useValueChanged = require("./utils/useValueChanged.cjs");
|
|
33
|
+
var import_constants = require("./utils/field/constants.cjs");
|
|
34
|
+
var import_FieldRootContext = require("./utils/field/FieldRootContext.cjs");
|
|
35
|
+
var import_FormContext = require("./utils/field/FormContext.cjs");
|
|
36
|
+
var import_LabelableContext = require("./utils/field/LabelableContext.cjs");
|
|
37
|
+
var import_useRegisterFieldControl = require("./utils/field/useRegisterFieldControl.cjs");
|
|
38
|
+
var import_RadioGroupContext = require("./utils/RadioGroupContext.cjs");
|
|
39
|
+
var import_fieldset = require("./fieldset.cjs");
|
|
40
|
+
const MODIFIER_KEYS = [import_keys.SHIFT];
|
|
41
|
+
function RadioGroup(props) {
|
|
42
|
+
const slot = (0, import_internal.S)("RadioGroup");
|
|
43
|
+
const {
|
|
44
|
+
render,
|
|
45
|
+
className,
|
|
46
|
+
disabled: disabledProp,
|
|
47
|
+
readOnly,
|
|
48
|
+
required,
|
|
49
|
+
onValueChange: onValueChangeProp,
|
|
50
|
+
value: externalValue,
|
|
51
|
+
defaultValue,
|
|
52
|
+
form,
|
|
53
|
+
name: nameProp,
|
|
54
|
+
inputRef: inputRefProp,
|
|
55
|
+
id: idProp,
|
|
56
|
+
style,
|
|
57
|
+
ref,
|
|
58
|
+
...elementProps
|
|
59
|
+
} = props;
|
|
60
|
+
const {
|
|
61
|
+
setTouched: setFieldTouched,
|
|
62
|
+
setFocused,
|
|
63
|
+
validationMode,
|
|
64
|
+
name: fieldName,
|
|
65
|
+
disabled: fieldDisabled,
|
|
66
|
+
state: fieldState,
|
|
67
|
+
validation,
|
|
68
|
+
setDirty,
|
|
69
|
+
setFilled,
|
|
70
|
+
validityData
|
|
71
|
+
} = (0, import_FieldRootContext.useFieldRootContext)();
|
|
72
|
+
const { labelId } = (0, import_LabelableContext.useLabelableContext)();
|
|
73
|
+
const { clearErrors } = (0, import_FormContext.useFormContext)();
|
|
74
|
+
const fieldsetContext = (0, import_fieldset.useFieldsetRootContext)(true);
|
|
75
|
+
const disabled = fieldDisabled || disabledProp;
|
|
76
|
+
const name = fieldName ?? nameProp;
|
|
77
|
+
const id = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
|
|
78
|
+
const [checkedValue, setCheckedValueUnwrapped] = (0, import_useControlled.useControlled)(
|
|
79
|
+
{ controlled: externalValue, default: defaultValue, name: "RadioGroup", state: "value" },
|
|
80
|
+
(0, import_internal.subSlot)(slot, "value")
|
|
81
|
+
);
|
|
82
|
+
const [touched, setTouched] = (0, import_octane.useState)(false, (0, import_internal.subSlot)(slot, "touched"));
|
|
83
|
+
const setCheckedValue = (0, import_useStableCallback.useStableCallback)(
|
|
84
|
+
(value, eventDetails) => {
|
|
85
|
+
onValueChangeProp?.(value, eventDetails);
|
|
86
|
+
if (eventDetails.isCanceled) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setCheckedValueUnwrapped(value);
|
|
90
|
+
},
|
|
91
|
+
(0, import_internal.subSlot)(slot, "setValue")
|
|
92
|
+
);
|
|
93
|
+
const controlRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "controlRef"));
|
|
94
|
+
const groupInputRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "groupInput"));
|
|
95
|
+
const firstEnabledInputRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "firstInput"));
|
|
96
|
+
function setInputRef(hiddenInput) {
|
|
97
|
+
let cleanup;
|
|
98
|
+
if (inputRefProp) {
|
|
99
|
+
if (typeof inputRefProp === "function") {
|
|
100
|
+
cleanup = inputRefProp(hiddenInput);
|
|
101
|
+
} else {
|
|
102
|
+
inputRefProp.current = hiddenInput;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
groupInputRef.current = hiddenInput;
|
|
106
|
+
validation.inputRef.current = hiddenInput;
|
|
107
|
+
return cleanup;
|
|
108
|
+
}
|
|
109
|
+
const registerControlRef = (0, import_useStableCallback.useStableCallback)(
|
|
110
|
+
(element, isDisabled = false) => {
|
|
111
|
+
if (!element) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (isDisabled) {
|
|
115
|
+
if (controlRef.current === element) {
|
|
116
|
+
controlRef.current = null;
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (controlRef.current == null) {
|
|
121
|
+
controlRef.current = element;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
(0, import_internal.subSlot)(slot, "registerControl")
|
|
125
|
+
);
|
|
126
|
+
const registerInputRef = (0, import_useStableCallback.useStableCallback)(
|
|
127
|
+
(input) => {
|
|
128
|
+
if (!input || input.disabled) {
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
131
|
+
if (!firstEnabledInputRef.current) {
|
|
132
|
+
firstEnabledInputRef.current = input;
|
|
133
|
+
}
|
|
134
|
+
const currentInput = groupInputRef.current;
|
|
135
|
+
if (input.checked || currentInput == null || currentInput.disabled) {
|
|
136
|
+
return setInputRef(input);
|
|
137
|
+
}
|
|
138
|
+
return void 0;
|
|
139
|
+
},
|
|
140
|
+
(0, import_internal.subSlot)(slot, "registerInput")
|
|
141
|
+
);
|
|
142
|
+
const getFormValue = (0, import_useStableCallback.useStableCallback)(
|
|
143
|
+
() => {
|
|
144
|
+
const input = groupInputRef.current;
|
|
145
|
+
if (!input || input.disabled || !input.checked) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return checkedValue ?? null;
|
|
149
|
+
},
|
|
150
|
+
(0, import_internal.subSlot)(slot, "getFormValue")
|
|
151
|
+
);
|
|
152
|
+
(0, import_useRegisterFieldControl.useRegisterFieldControl)(
|
|
153
|
+
controlRef,
|
|
154
|
+
id,
|
|
155
|
+
checkedValue ?? null,
|
|
156
|
+
getFormValue,
|
|
157
|
+
!disabled,
|
|
158
|
+
nameProp,
|
|
159
|
+
(0, import_internal.subSlot)(slot, "register")
|
|
160
|
+
);
|
|
161
|
+
(0, import_useValueChanged.useValueChanged)(
|
|
162
|
+
checkedValue,
|
|
163
|
+
() => {
|
|
164
|
+
clearErrors(name);
|
|
165
|
+
setDirty(checkedValue !== validityData.initialValue);
|
|
166
|
+
setFilled(checkedValue != null);
|
|
167
|
+
validation.change(checkedValue);
|
|
168
|
+
const fallbackInput = firstEnabledInputRef.current;
|
|
169
|
+
if (checkedValue == null && fallbackInput && !fallbackInput.disabled) {
|
|
170
|
+
setInputRef(fallbackInput);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
(0, import_internal.subSlot)(slot, "valueChanged")
|
|
174
|
+
);
|
|
175
|
+
const ariaLabelledby = elementProps["aria-labelledby"] ?? labelId ?? fieldsetContext?.legendId;
|
|
176
|
+
const state = {
|
|
177
|
+
...fieldState,
|
|
178
|
+
disabled: disabled ?? false,
|
|
179
|
+
required: required ?? false,
|
|
180
|
+
readOnly: readOnly ?? false
|
|
181
|
+
};
|
|
182
|
+
const contextValue = (0, import_octane.useMemo)(
|
|
183
|
+
() => ({
|
|
184
|
+
...fieldState,
|
|
185
|
+
checkedValue,
|
|
186
|
+
disabled,
|
|
187
|
+
form,
|
|
188
|
+
validation,
|
|
189
|
+
name,
|
|
190
|
+
readOnly,
|
|
191
|
+
registerControlRef,
|
|
192
|
+
registerInputRef,
|
|
193
|
+
required,
|
|
194
|
+
setCheckedValue,
|
|
195
|
+
setTouched,
|
|
196
|
+
touched
|
|
197
|
+
}),
|
|
198
|
+
[
|
|
199
|
+
checkedValue,
|
|
200
|
+
disabled,
|
|
201
|
+
form,
|
|
202
|
+
validation,
|
|
203
|
+
fieldState,
|
|
204
|
+
name,
|
|
205
|
+
readOnly,
|
|
206
|
+
registerControlRef,
|
|
207
|
+
registerInputRef,
|
|
208
|
+
required,
|
|
209
|
+
setCheckedValue,
|
|
210
|
+
setTouched,
|
|
211
|
+
touched
|
|
212
|
+
],
|
|
213
|
+
(0, import_internal.subSlot)(slot, "ctx")
|
|
214
|
+
);
|
|
215
|
+
const defaultProps = {
|
|
216
|
+
id: idProp,
|
|
217
|
+
role: "radiogroup",
|
|
218
|
+
"aria-required": required || void 0,
|
|
219
|
+
"aria-disabled": disabled || void 0,
|
|
220
|
+
"aria-readonly": readOnly || void 0,
|
|
221
|
+
"aria-labelledby": ariaLabelledby,
|
|
222
|
+
onFocus() {
|
|
223
|
+
setFocused(true);
|
|
224
|
+
},
|
|
225
|
+
onBlur(event) {
|
|
226
|
+
if (!(0, import_contains.contains)(event.currentTarget, event.relatedTarget)) {
|
|
227
|
+
setFieldTouched(true);
|
|
228
|
+
setFocused(false);
|
|
229
|
+
if (validationMode === "onBlur") {
|
|
230
|
+
validation.commit(checkedValue);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
onKeyDownCapture(event) {
|
|
235
|
+
if (event.key.startsWith("Arrow")) {
|
|
236
|
+
setTouched(true);
|
|
237
|
+
setFocused(true);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const compositeRoot = (0, import_octane.createElement)(import_CompositeRoot.CompositeRoot, {
|
|
242
|
+
render,
|
|
243
|
+
className,
|
|
244
|
+
style,
|
|
245
|
+
state,
|
|
246
|
+
props: [
|
|
247
|
+
defaultProps,
|
|
248
|
+
elementProps,
|
|
249
|
+
(p) => validation.getValidationProps(disabled ?? false, p)
|
|
250
|
+
],
|
|
251
|
+
refs: [ref],
|
|
252
|
+
stateAttributesMapping: import_constants.fieldValidityMapping,
|
|
253
|
+
enableHomeAndEndKeys: false,
|
|
254
|
+
modifierKeys: MODIFIER_KEYS
|
|
255
|
+
});
|
|
256
|
+
return (0, import_octane.createElement)(import_RadioGroupContext.RadioGroupContext.Provider, {
|
|
257
|
+
value: contextValue,
|
|
258
|
+
children: compositeRoot
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
262
|
+
0 && (module.exports = {
|
|
263
|
+
RadioGroup
|
|
264
|
+
});
|