@eightshift/ui-components 5.0.0 → 5.0.2
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/Button-BpwTmkAe.js +185 -0
- package/dist/Collection-n5d0zIgb.js +2398 -0
- package/dist/Color-lVhk8V_G.js +2452 -0
- package/dist/ColorSwatch-DntWEAC3.js +64 -0
- package/dist/ComboBox-BJpTEATT.js +1915 -0
- package/dist/Dialog-O9uw63D7.js +2317 -0
- package/dist/FieldError-DHrSdE_Q.js +42 -0
- package/dist/FocusScope-BEPI2m7u.js +831 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/Group-DDPhPPTQ.js +48 -0
- package/dist/Heading-ba38ScjJ.js +16 -0
- package/dist/Hidden-rE6uR-lr.js +41 -0
- package/dist/Input-BmDS8Juy.js +133 -0
- package/dist/Label-JS_ob-kh.js +17 -0
- package/dist/List-CZMUbkFU.js +593 -0
- package/dist/ListBox-BTxlCGcc.js +664 -0
- package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
- package/dist/OverlayArrow-5aDgmImj.js +637 -0
- package/dist/RSPContexts-2lR5GG9p.js +14 -0
- package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
- package/dist/Separator-CaTBkETC.js +332 -0
- package/dist/Slider-C-S1oEH9.js +853 -0
- package/dist/Text-BuJgePCv.js +16 -0
- package/dist/VisuallyHidden-BYi0pekx.js +48 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/assets/index.css +57 -0
- package/dist/assets/style-admin.css +5908 -0
- package/dist/assets/style-editor.css +5908 -0
- package/dist/assets/style.css +5914 -0
- package/dist/assets/wp-font-enhancements.css +8 -0
- package/dist/assets/wp-ui-enhancements.css +396 -0
- package/dist/components/animated-visibility/animated-visibility.js +105 -0
- package/dist/components/base-control/base-control.js +86 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
- package/dist/components/button/button.js +387 -0
- package/dist/components/checkbox/checkbox.js +323 -0
- package/dist/components/color-pickers/color-picker.js +272 -0
- package/dist/components/color-pickers/color-swatch.js +59 -0
- package/dist/components/color-pickers/gradient-editor.js +534 -0
- package/dist/components/color-pickers/solid-color-picker.js +1567 -0
- package/dist/components/component-toggle/component-toggle.js +161 -0
- package/dist/components/container-panel/container-panel.js +131 -0
- package/dist/components/draggable/draggable-context.js +5 -0
- package/dist/components/draggable/draggable-handle.js +46 -0
- package/dist/components/draggable/draggable.js +7320 -0
- package/dist/components/draggable-list/draggable-list-context.js +5 -0
- package/dist/components/draggable-list/draggable-list-item.js +77 -0
- package/dist/components/draggable-list/draggable-list.js +151 -0
- package/dist/components/expandable/expandable.js +342 -0
- package/dist/components/index.js +137 -0
- package/dist/components/input-field/input-field.js +231 -0
- package/dist/components/item-collection/item-collection.js +59 -0
- package/dist/components/layout/hstack.js +30 -0
- package/dist/components/layout/vstack.js +30 -0
- package/dist/components/link-input/link-input.js +284 -0
- package/dist/components/matrix-align/matrix-align.js +134 -0
- package/dist/components/menu/menu.js +285 -0
- package/dist/components/modal/modal.js +305 -0
- package/dist/components/notice/notice.js +123 -0
- package/dist/components/number-picker/number-picker.js +292 -0
- package/dist/components/option-select/option-select.js +264 -0
- package/dist/components/options-panel/options-panel.js +158 -0
- package/dist/components/placeholders/file-placeholder.js +42 -0
- package/dist/components/placeholders/image-placeholder.js +88 -0
- package/dist/components/placeholders/media-placeholder.js +63 -0
- package/dist/components/popover/popover.js +207 -0
- package/dist/components/radio/radio.js +582 -0
- package/dist/components/repeater/repeater-context.js +5 -0
- package/dist/components/repeater/repeater-item.js +119 -0
- package/dist/components/repeater/repeater.js +280 -0
- package/dist/components/responsive/mini-responsive.js +498 -0
- package/dist/components/responsive/responsive-legacy.js +343 -0
- package/dist/components/responsive/responsive.js +583 -0
- package/dist/components/responsive-preview/responsive-preview.js +123 -0
- package/dist/components/rich-label/rich-label.js +66 -0
- package/dist/components/select/async-multi-select.js +157 -0
- package/dist/components/select/async-single-select.js +137 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +151 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +26 -0
- package/dist/components/select/single-select.js +131 -0
- package/dist/components/select/styles.js +49 -0
- package/dist/components/select/v2/async-select.js +297 -0
- package/dist/components/select/v2/shared.js +24 -0
- package/dist/components/select/v2/single-select.js +1004 -0
- package/dist/components/slider/column-config-slider.js +210 -0
- package/dist/components/slider/slider.js +345 -0
- package/dist/components/slider/utils.js +94 -0
- package/dist/components/spacer/spacer.js +97 -0
- package/dist/components/tabs/tabs.js +703 -0
- package/dist/components/toggle/switch.js +156 -0
- package/dist/components/toggle/toggle.js +64 -0
- package/dist/components/toggle-button/toggle-button.js +343 -0
- package/dist/components/tooltip/tooltip.js +527 -0
- package/dist/context-BbYZoHvX.js +92 -0
- package/dist/default-i18n-CT_oS1Fy.js +922 -0
- package/dist/filterDOMProps-EDDcM64A.js +28 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +113 -0
- package/dist/icons/icons.js +30495 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/jsx-svg.js +50 -0
- package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
- package/dist/index-BljRBEr_.js +44 -0
- package/dist/index-CFozsmNS.js +28321 -0
- package/dist/index.js +139 -0
- package/dist/lite-DVmmD_-j.js +7 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
- package/dist/number-GajL10e1.js +36 -0
- package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
- package/dist/react-select-async.esm-D937XTWW.js +107 -0
- package/dist/react-select.esm-Ciai3aKf.js +15 -0
- package/dist/style-admin.js +1 -0
- package/dist/style-editor.js +1 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-8DpK8fJl.js +46 -0
- package/dist/useButton-Bt3BffJm.js +50 -0
- package/dist/useEvent-ICdlokG-.js +23 -0
- package/dist/useFocusRing-Bv0UJQl8.js +107 -0
- package/dist/useFormReset-D2YaWRIA.js +22 -0
- package/dist/useFormValidation-Dy0PXJg5.js +224 -0
- package/dist/useHover-C2SkI1Fn.js +895 -0
- package/dist/useLabel-BPCd5c7-.js +27 -0
- package/dist/useLabels-B7-lUnAF.js +23 -0
- package/dist/useListState-DkyH7elT.js +168 -0
- package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
- package/dist/useNumberField-CU1_u8ze.js +1215 -0
- package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
- package/dist/usePress-BrJylgPR.js +688 -0
- package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
- package/dist/useToggle-CDa3YAZI.js +59 -0
- package/dist/useToggleState-ibcBUHnB.js +19 -0
- package/dist/utilities/array-helpers.js +56 -0
- package/dist/utilities/debounce-throttle.js +123 -0
- package/dist/utilities/es-dash.js +382 -0
- package/dist/utilities/index.js +27 -0
- package/dist/utilities/text-helpers.js +136 -0
- package/dist/utils-CZt7LCbO.js +403 -0
- package/dist/wp/wp-font-enhancements.js +1 -0
- package/dist/wp/wp-ui-enhancements.js +1 -0
- package/package.json +24 -24
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-JS_ob-kh.js";
|
|
3
|
+
import { d as $3ef42575df84b30b$export$9d1611c77c2fe928, e as $bdb11010cef70236$export$f680877a34711e37, a as $64fa3d84918910a7$export$29f1550f4b0d4415, l as $df56164dff5785e2$export$4338b53315abf666, m as $5dc95899b306f630$export$c9058316764c140e, h as $64fa3d84918910a7$export$ef03459518577ad4, b as $64fa3d84918910a7$export$4d86445c2cf5e3, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, g as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, i as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-CZt7LCbO.js";
|
|
4
|
+
import { a as $2baaea4c71418dea$export$294aa081a6c6f55d, $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-DHrSdE_Q.js";
|
|
5
|
+
import { $ as $d3e0e05bdfcf66bd$export$c24727297075ec6a } from "../../Form-Cq3fu75_.js";
|
|
6
|
+
import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-BuJgePCv.js";
|
|
7
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
|
|
8
|
+
import React__default, { useMemo, useState, forwardRef, createContext, cloneElement } from "react";
|
|
9
|
+
import { $ as $99facab73266f662$export$5add1d006293d136 } from "../../useFormReset-D2YaWRIA.js";
|
|
10
|
+
import { $ as $f6c31cce2adf654f$export$45712eceda6fad21 } from "../../usePress-BrJylgPR.js";
|
|
11
|
+
import { a as $f645667febf57a63$export$4c014de7c8940b4c, b as $458b0a5536c1a7cf$export$40bfa8c7b0832715, $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-C2SkI1Fn.js";
|
|
12
|
+
import { a as $e93e671b31057976$export$b8473d3665f3a75a, $ as $e5be200c675c3b3a$export$fc1a364ae1f3ff10 } from "../../useFormValidation-Dy0PXJg5.js";
|
|
13
|
+
import { a as $9bf71ea28793e738$export$2d6ec8fc375ceafa } from "../../FocusScope-BEPI2m7u.js";
|
|
14
|
+
import { a as $9ab94262bd0047c7$export$420e68273165f4ec, $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Bv0UJQl8.js";
|
|
15
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-BbYZoHvX.js";
|
|
16
|
+
import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "../../VisuallyHidden-BYi0pekx.js";
|
|
17
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
18
|
+
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
19
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
20
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
21
|
+
const $884aeceb3d67f00f$export$37b65e5b5444d35c = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
23
|
+
let { value, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby } = props;
|
|
24
|
+
const isDisabled = props.isDisabled || state.isDisabled;
|
|
25
|
+
let hasChildren = children != null;
|
|
26
|
+
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
27
|
+
if (!hasChildren && !hasAriaLabel && process.env.NODE_ENV !== "production") console.warn("If you do not provide children, you must specify an aria-label for accessibility");
|
|
28
|
+
let checked = state.selectedValue === value;
|
|
29
|
+
let onChange = (e) => {
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
state.setSelectedValue(value);
|
|
32
|
+
};
|
|
33
|
+
let { pressProps, isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
34
|
+
isDisabled
|
|
35
|
+
});
|
|
36
|
+
let { pressProps: labelProps, isPressed: isLabelPressed } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
37
|
+
isDisabled,
|
|
38
|
+
onPress() {
|
|
39
|
+
var _ref_current;
|
|
40
|
+
state.setSelectedValue(value);
|
|
41
|
+
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
let { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c($3ef42575df84b30b$export$9d1611c77c2fe928(props, {
|
|
45
|
+
onFocus: () => state.setLastFocusedValue(value)
|
|
46
|
+
}), ref);
|
|
47
|
+
let interactions = $3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, focusableProps);
|
|
48
|
+
let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
|
|
49
|
+
labelable: true
|
|
50
|
+
});
|
|
51
|
+
let tabIndex = -1;
|
|
52
|
+
if (state.selectedValue != null) {
|
|
53
|
+
if (state.selectedValue === value) tabIndex = 0;
|
|
54
|
+
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
55
|
+
if (isDisabled) tabIndex = void 0;
|
|
56
|
+
let { name, descriptionId, errorMessageId, validationBehavior } = $884aeceb3d67f00f$export$37b65e5b5444d35c.get(state);
|
|
57
|
+
$99facab73266f662$export$5add1d006293d136(ref, state.selectedValue, state.setSelectedValue);
|
|
58
|
+
$e93e671b31057976$export$b8473d3665f3a75a({
|
|
59
|
+
validationBehavior
|
|
60
|
+
}, state, ref);
|
|
61
|
+
return {
|
|
62
|
+
labelProps: $3ef42575df84b30b$export$9d1611c77c2fe928(labelProps, {
|
|
63
|
+
onClick: (e) => e.preventDefault()
|
|
64
|
+
}),
|
|
65
|
+
inputProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, {
|
|
66
|
+
...interactions,
|
|
67
|
+
type: "radio",
|
|
68
|
+
name,
|
|
69
|
+
tabIndex,
|
|
70
|
+
disabled: isDisabled,
|
|
71
|
+
required: state.isRequired && validationBehavior === "native",
|
|
72
|
+
checked,
|
|
73
|
+
value,
|
|
74
|
+
onChange,
|
|
75
|
+
"aria-describedby": [
|
|
76
|
+
props["aria-describedby"],
|
|
77
|
+
state.isInvalid ? errorMessageId : null,
|
|
78
|
+
descriptionId
|
|
79
|
+
].filter(Boolean).join(" ") || void 0
|
|
80
|
+
}),
|
|
81
|
+
isDisabled,
|
|
82
|
+
isSelected: checked,
|
|
83
|
+
isPressed: isPressed || isLabelPressed
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
87
|
+
let { name, isReadOnly, isRequired, isDisabled, orientation = "vertical", validationBehavior = "aria" } = props;
|
|
88
|
+
let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
89
|
+
let { isInvalid, validationErrors, validationDetails } = state.displayValidation;
|
|
90
|
+
let { labelProps, fieldProps, descriptionProps, errorMessageProps } = $2baaea4c71418dea$export$294aa081a6c6f55d({
|
|
91
|
+
...props,
|
|
92
|
+
// Radio group is not an HTML input element so it
|
|
93
|
+
// shouldn't be labeled by a <label> element.
|
|
94
|
+
labelElementType: "span",
|
|
95
|
+
isInvalid: state.isInvalid,
|
|
96
|
+
errorMessage: props.errorMessage || validationErrors
|
|
97
|
+
});
|
|
98
|
+
let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
|
|
99
|
+
labelable: true
|
|
100
|
+
});
|
|
101
|
+
let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
|
|
102
|
+
onBlurWithin(e) {
|
|
103
|
+
var _props_onBlur;
|
|
104
|
+
(_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
|
|
105
|
+
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
106
|
+
},
|
|
107
|
+
onFocusWithin: props.onFocus,
|
|
108
|
+
onFocusWithinChange: props.onFocusChange
|
|
109
|
+
});
|
|
110
|
+
let onKeyDown = (e) => {
|
|
111
|
+
let nextDir;
|
|
112
|
+
switch (e.key) {
|
|
113
|
+
case "ArrowRight":
|
|
114
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "prev";
|
|
115
|
+
else nextDir = "next";
|
|
116
|
+
break;
|
|
117
|
+
case "ArrowLeft":
|
|
118
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "next";
|
|
119
|
+
else nextDir = "prev";
|
|
120
|
+
break;
|
|
121
|
+
case "ArrowDown":
|
|
122
|
+
nextDir = "next";
|
|
123
|
+
break;
|
|
124
|
+
case "ArrowUp":
|
|
125
|
+
nextDir = "prev";
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(e.currentTarget, {
|
|
132
|
+
from: e.target
|
|
133
|
+
});
|
|
134
|
+
let nextElem;
|
|
135
|
+
if (nextDir === "next") {
|
|
136
|
+
nextElem = walker.nextNode();
|
|
137
|
+
if (!nextElem) {
|
|
138
|
+
walker.currentNode = e.currentTarget;
|
|
139
|
+
nextElem = walker.firstChild();
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
nextElem = walker.previousNode();
|
|
143
|
+
if (!nextElem) {
|
|
144
|
+
walker.currentNode = e.currentTarget;
|
|
145
|
+
nextElem = walker.lastChild();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (nextElem) {
|
|
149
|
+
nextElem.focus();
|
|
150
|
+
state.setSelectedValue(nextElem.value);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
let groupName = $bdb11010cef70236$export$f680877a34711e37(name);
|
|
154
|
+
$884aeceb3d67f00f$export$37b65e5b5444d35c.set(state, {
|
|
155
|
+
name: groupName,
|
|
156
|
+
descriptionId: descriptionProps.id,
|
|
157
|
+
errorMessageId: errorMessageProps.id,
|
|
158
|
+
validationBehavior
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
radioGroupProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, {
|
|
162
|
+
// https://www.w3.org/TR/wai-aria-1.2/#radiogroup
|
|
163
|
+
role: "radiogroup",
|
|
164
|
+
onKeyDown,
|
|
165
|
+
"aria-invalid": state.isInvalid || void 0,
|
|
166
|
+
"aria-errormessage": props["aria-errormessage"],
|
|
167
|
+
"aria-readonly": isReadOnly || void 0,
|
|
168
|
+
"aria-required": isRequired || void 0,
|
|
169
|
+
"aria-disabled": isDisabled || void 0,
|
|
170
|
+
"aria-orientation": orientation,
|
|
171
|
+
...fieldProps,
|
|
172
|
+
...focusWithinProps
|
|
173
|
+
}),
|
|
174
|
+
labelProps,
|
|
175
|
+
descriptionProps,
|
|
176
|
+
errorMessageProps,
|
|
177
|
+
isInvalid,
|
|
178
|
+
validationErrors,
|
|
179
|
+
validationDetails
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
let $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 1e10);
|
|
183
|
+
let $a54cdc5c1942b639$var$i = 0;
|
|
184
|
+
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
185
|
+
let name = useMemo(() => props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
186
|
+
props.name
|
|
187
|
+
]);
|
|
188
|
+
var _props_defaultValue;
|
|
189
|
+
let [selectedValue, setSelected] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
190
|
+
let [lastFocusedValue, setLastFocusedValue] = useState(null);
|
|
191
|
+
let validation = $e5be200c675c3b3a$export$fc1a364ae1f3ff10({
|
|
192
|
+
...props,
|
|
193
|
+
value: selectedValue
|
|
194
|
+
});
|
|
195
|
+
let setSelectedValue = (value) => {
|
|
196
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
197
|
+
setSelected(value);
|
|
198
|
+
validation.commitValidation();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
202
|
+
return {
|
|
203
|
+
...validation,
|
|
204
|
+
name,
|
|
205
|
+
selectedValue,
|
|
206
|
+
setSelectedValue,
|
|
207
|
+
lastFocusedValue,
|
|
208
|
+
setLastFocusedValue,
|
|
209
|
+
isDisabled: props.isDisabled || false,
|
|
210
|
+
isReadOnly: props.isReadOnly || false,
|
|
211
|
+
isRequired: props.isRequired || false,
|
|
212
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
213
|
+
isInvalid
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const $b6c3ddc6086f204d$export$a79eda4ff50e30b6 = /* @__PURE__ */ createContext(null);
|
|
217
|
+
const $b6c3ddc6086f204d$export$b118023277d4a5c3 = /* @__PURE__ */ createContext(null);
|
|
218
|
+
const $b6c3ddc6086f204d$export$29d84393af70866c = /* @__PURE__ */ createContext(null);
|
|
219
|
+
const $b6c3ddc6086f204d$export$a98f0dcb43a68a25 = /* @__PURE__ */ forwardRef(function RadioGroup(props, ref) {
|
|
220
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $b6c3ddc6086f204d$export$a79eda4ff50e30b6);
|
|
221
|
+
let { validationBehavior: formValidationBehavior } = $64fa3d84918910a7$export$fabf2dc03a41866e($d3e0e05bdfcf66bd$export$c24727297075ec6a) || {};
|
|
222
|
+
var _props_validationBehavior, _ref;
|
|
223
|
+
let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : "native";
|
|
224
|
+
let state = $a54cdc5c1942b639$export$bca9d026f8e704eb({
|
|
225
|
+
...props,
|
|
226
|
+
validationBehavior
|
|
227
|
+
});
|
|
228
|
+
let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(!props["aria-label"] && !props["aria-labelledby"]);
|
|
229
|
+
let { radioGroupProps, labelProps, descriptionProps, errorMessageProps, ...validation } = $430f30ed08ec25fa$export$62b9571f283ff5c2({
|
|
230
|
+
...props,
|
|
231
|
+
label,
|
|
232
|
+
validationBehavior
|
|
233
|
+
}, state);
|
|
234
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
235
|
+
...props,
|
|
236
|
+
values: {
|
|
237
|
+
orientation: props.orientation || "vertical",
|
|
238
|
+
isDisabled: state.isDisabled,
|
|
239
|
+
isReadOnly: state.isReadOnly,
|
|
240
|
+
isRequired: state.isRequired,
|
|
241
|
+
isInvalid: state.isInvalid,
|
|
242
|
+
state
|
|
243
|
+
},
|
|
244
|
+
defaultClassName: "react-aria-RadioGroup"
|
|
245
|
+
});
|
|
246
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
247
|
+
...radioGroupProps,
|
|
248
|
+
...renderProps,
|
|
249
|
+
ref,
|
|
250
|
+
slot: props.slot || void 0,
|
|
251
|
+
"data-orientation": props.orientation || "vertical",
|
|
252
|
+
"data-invalid": state.isInvalid || void 0,
|
|
253
|
+
"data-disabled": state.isDisabled || void 0,
|
|
254
|
+
"data-readonly": state.isReadOnly || void 0,
|
|
255
|
+
"data-required": state.isRequired || void 0
|
|
256
|
+
}, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
257
|
+
values: [
|
|
258
|
+
[
|
|
259
|
+
$b6c3ddc6086f204d$export$29d84393af70866c,
|
|
260
|
+
state
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
$01b77f81d0f07f68$export$75b6ee27786ba447,
|
|
264
|
+
{
|
|
265
|
+
...labelProps,
|
|
266
|
+
ref: labelRef,
|
|
267
|
+
elementType: "span"
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
[
|
|
271
|
+
$514c0188e459b4c0$export$9afb8bc826b033ea,
|
|
272
|
+
{
|
|
273
|
+
slots: {
|
|
274
|
+
description: descriptionProps,
|
|
275
|
+
errorMessage: errorMessageProps
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
[
|
|
280
|
+
$ee014567cb39d3f0$export$ff05c3ac10437e03,
|
|
281
|
+
validation
|
|
282
|
+
]
|
|
283
|
+
]
|
|
284
|
+
}, renderProps.children));
|
|
285
|
+
});
|
|
286
|
+
const $b6c3ddc6086f204d$export$d7b12c4107be0d61 = /* @__PURE__ */ forwardRef(function Radio(props, ref) {
|
|
287
|
+
let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
|
|
288
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(otherProps, ref, $b6c3ddc6086f204d$export$b118023277d4a5c3);
|
|
289
|
+
let state = React__default.useContext($b6c3ddc6086f204d$export$29d84393af70866c);
|
|
290
|
+
let inputRef = $df56164dff5785e2$export$4338b53315abf666(useMemo(() => $5dc95899b306f630$export$c9058316764c140e(userProvidedInputRef, props.inputRef !== void 0 ? props.inputRef : null), [
|
|
291
|
+
userProvidedInputRef,
|
|
292
|
+
props.inputRef
|
|
293
|
+
]));
|
|
294
|
+
let { labelProps, inputProps, isSelected, isDisabled, isPressed } = $0d5c49892c1215da$export$37b0961d2f4751e2({
|
|
295
|
+
...$64fa3d84918910a7$export$ef03459518577ad4(props),
|
|
296
|
+
// ReactNode type doesn't allow function children.
|
|
297
|
+
children: typeof props.children === "function" ? true : props.children
|
|
298
|
+
}, state, inputRef);
|
|
299
|
+
let { isFocused, isFocusVisible, focusProps } = $f7dceffc5ad7768b$export$4e328f61c538687f();
|
|
300
|
+
let interactionDisabled = isDisabled || state.isReadOnly;
|
|
301
|
+
let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
|
|
302
|
+
...props,
|
|
303
|
+
isDisabled: interactionDisabled
|
|
304
|
+
});
|
|
305
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
306
|
+
...props,
|
|
307
|
+
defaultClassName: "react-aria-Radio",
|
|
308
|
+
values: {
|
|
309
|
+
isSelected,
|
|
310
|
+
isPressed,
|
|
311
|
+
isHovered,
|
|
312
|
+
isFocused,
|
|
313
|
+
isFocusVisible,
|
|
314
|
+
isDisabled,
|
|
315
|
+
isReadOnly: state.isReadOnly,
|
|
316
|
+
isInvalid: state.isInvalid,
|
|
317
|
+
isRequired: state.isRequired
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
321
|
+
delete DOMProps.id;
|
|
322
|
+
return /* @__PURE__ */ React__default.createElement("label", {
|
|
323
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, labelProps, hoverProps, renderProps),
|
|
324
|
+
ref,
|
|
325
|
+
"data-selected": isSelected || void 0,
|
|
326
|
+
"data-pressed": isPressed || void 0,
|
|
327
|
+
"data-hovered": isHovered || void 0,
|
|
328
|
+
"data-focused": isFocused || void 0,
|
|
329
|
+
"data-focus-visible": isFocusVisible || void 0,
|
|
330
|
+
"data-disabled": isDisabled || void 0,
|
|
331
|
+
"data-readonly": state.isReadOnly || void 0,
|
|
332
|
+
"data-invalid": state.isInvalid || void 0,
|
|
333
|
+
"data-required": state.isRequired || void 0
|
|
334
|
+
}, /* @__PURE__ */ React__default.createElement($5c3e21d68f1c4674$export$439d29a4e110a164, {
|
|
335
|
+
elementType: "span"
|
|
336
|
+
}, /* @__PURE__ */ React__default.createElement("input", {
|
|
337
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(inputProps, focusProps),
|
|
338
|
+
ref: inputRef
|
|
339
|
+
})), renderProps.children);
|
|
340
|
+
});
|
|
341
|
+
/**
|
|
342
|
+
* A simple radio button.
|
|
343
|
+
*
|
|
344
|
+
* @component
|
|
345
|
+
* @param {Object} props - Component props.
|
|
346
|
+
* @param {JSX.Element} [props.icon] - The checkbox icon.
|
|
347
|
+
* @param {string} [props.label] - The checkbox label.
|
|
348
|
+
* @param {string} [props.subtitle] - The checkbox subtitle.
|
|
349
|
+
* @param {boolean} [props.disabled] - Whether the checkbox is disabled.
|
|
350
|
+
* @param {string} [props.className] - Additional classes to add to the checkbox container.
|
|
351
|
+
* @param {string} [props.labelClassName] - Additional classes to add to the label container.
|
|
352
|
+
* @param {boolean} [props.alignEnd] - Whether the label should be aligned to the end.
|
|
353
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
354
|
+
* @param {boolean} [props.inlineSubtitle] - If `true`, the subtitle is shown after the label instead of below it.
|
|
355
|
+
*
|
|
356
|
+
* @returns {JSX.Element} The RadioButton component.
|
|
357
|
+
*
|
|
358
|
+
* @see {@link RadioButtonGroup} for usage example.
|
|
359
|
+
*
|
|
360
|
+
* @preserve
|
|
361
|
+
*/
|
|
362
|
+
const RadioButton = (props) => {
|
|
363
|
+
const {
|
|
364
|
+
icon,
|
|
365
|
+
label,
|
|
366
|
+
subtitle,
|
|
367
|
+
disabled,
|
|
368
|
+
className,
|
|
369
|
+
labelClassName,
|
|
370
|
+
design = "default",
|
|
371
|
+
alignEnd,
|
|
372
|
+
children,
|
|
373
|
+
inlineSubtitle,
|
|
374
|
+
hidden,
|
|
375
|
+
...rest
|
|
376
|
+
} = props;
|
|
377
|
+
if (hidden) {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
const styleClassName = {
|
|
381
|
+
segmented: clsx(
|
|
382
|
+
"es:cursor-pointer es:py-1 es:px-1.5 es:border es:border-secondary-300 es:hover:bg-secondary-100/75 es:transition es:min-h-10",
|
|
383
|
+
"es:first:rounded-t-xl es:last:rounded-b-xl",
|
|
384
|
+
"es:focus-visible:ring-2 es:focus-visible:border-accent-500 es:focus-visible:ring-accent-500/50 es:focus-visible:z-10",
|
|
385
|
+
"es:shadow-xs es:inset-ring es:inset-shadow-xs",
|
|
386
|
+
"es:inset-ring-secondary-100 es:inset-shadow-secondary-100/50"
|
|
387
|
+
),
|
|
388
|
+
segmentedHorizontal: clsx(
|
|
389
|
+
"es:cursor-pointer es:py-1 es:px-1.5 es:border es:border-secondary-300 es:hover:bg-secondary-100/75 es:transition es:grow es:min-h-10",
|
|
390
|
+
"es:first:rounded-l-xl es:last:rounded-r-xl",
|
|
391
|
+
"es:focus-visible:ring-2 es:focus-visible:border-accent-500 es:focus-visible:ring-accent-500/50 es:focus-visible:z-10",
|
|
392
|
+
"es:shadow-xs es:inset-ring es:inset-shadow-xs",
|
|
393
|
+
"es:inset-ring-secondary-100 es:inset-shadow-secondary-100/50"
|
|
394
|
+
)
|
|
395
|
+
};
|
|
396
|
+
return /* @__PURE__ */ jsx(
|
|
397
|
+
$b6c3ddc6086f204d$export$d7b12c4107be0d61,
|
|
398
|
+
{
|
|
399
|
+
isDisabled: disabled,
|
|
400
|
+
className: clsx("es:group es:flex es:items-center es:gap-1.5 es:text-sm", styleClassName[design], className),
|
|
401
|
+
...rest,
|
|
402
|
+
children: ({ isSelected }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
403
|
+
alignEnd && (label || subtitle || icon) && /* @__PURE__ */ jsx(
|
|
404
|
+
RichLabel,
|
|
405
|
+
{
|
|
406
|
+
icon,
|
|
407
|
+
label,
|
|
408
|
+
subtitle,
|
|
409
|
+
className: clsx("es:ml-1", labelClassName),
|
|
410
|
+
inlineSubtitle,
|
|
411
|
+
fullWidth: true,
|
|
412
|
+
fullSizeSubtitle: true,
|
|
413
|
+
as: $01b77f81d0f07f68$export$b04be29aa201d4f5
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
/* @__PURE__ */ jsx(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
className: clsx(
|
|
420
|
+
"es:size-5 es:flex es:items-center es:justify-center",
|
|
421
|
+
"es:transition es:cursor-pointer",
|
|
422
|
+
"es:bg-radial es:border es:rounded-full",
|
|
423
|
+
"es:shadow-xs es:inset-ring es:inset-shadow-xs",
|
|
424
|
+
"es:any-focus:outline-hidden",
|
|
425
|
+
!isSelected && "es:border-secondary-300 es:inset-ring-secondary-100 es:inset-shadow-secondary-100/50",
|
|
426
|
+
!isSelected && "es:from-secondary-50 es:to-white es:text-secondary-600 es:hover:text-accent-950",
|
|
427
|
+
!isSelected && "es:hover:inset-shadow-secondary-100 es:hover:to-secondary-100 es:hover:inset-ring-secondary-100",
|
|
428
|
+
isSelected && "es:text-white es:from-accent-500 es:to-accent-600",
|
|
429
|
+
isSelected && "es:shadow-accent-600/30 es:border-accent-700 es:inset-ring es:inset-ring-accent-600 es:inset-shadow-accent-400/75",
|
|
430
|
+
isSelected && "es:group-focus-visible:inset-ring-accent-600 es:group-focus-visible:inset-shadow-xs es:group-focus-visible:inset-shadow-accent-400",
|
|
431
|
+
!(design == null ? void 0 : design.startsWith("segmented")) && "es:group-focus-visible:ring-2 es:group-focus-visible:ring-accent-500/50",
|
|
432
|
+
!(design == null ? void 0 : design.startsWith("segmented")) && !isSelected && "es:group-focus-visible:border-accent-500",
|
|
433
|
+
!(design == null ? void 0 : design.startsWith("segmented")) && !alignEnd && subtitle && "es:mb-auto"
|
|
434
|
+
),
|
|
435
|
+
children: /* @__PURE__ */ jsx(
|
|
436
|
+
AnimatedVisibility,
|
|
437
|
+
{
|
|
438
|
+
transition: "scaleFade",
|
|
439
|
+
visible: isSelected,
|
|
440
|
+
className: clsx("es:icon:size-3 es:icon:stroke-2", disabled && "es:opacity-55"),
|
|
441
|
+
noInitial: true,
|
|
442
|
+
children: /* @__PURE__ */ jsx("div", { className: "es:size-2 es:rounded-full es:bg-white es:shadow-sm" })
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
),
|
|
447
|
+
!alignEnd && /* @__PURE__ */ jsx(
|
|
448
|
+
RichLabel,
|
|
449
|
+
{
|
|
450
|
+
icon: alignEnd && icon,
|
|
451
|
+
label,
|
|
452
|
+
subtitle,
|
|
453
|
+
className: clsx(labelClassName, subtitle && "es:mt-0.5", "es:[&_>_span_>_svg]:size-5 es:ml-0.5 es:*:space-y-0.5", disabled && "es:opacity-55"),
|
|
454
|
+
inlineSubtitle,
|
|
455
|
+
fullSizeSubtitle: true,
|
|
456
|
+
as: $01b77f81d0f07f68$export$b04be29aa201d4f5
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
!(icon || label || subtitle) && children
|
|
460
|
+
] })
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
};
|
|
464
|
+
RadioButton.displayName = "RadioButton";
|
|
465
|
+
/**
|
|
466
|
+
* A group of radio buttons.
|
|
467
|
+
* This component is required to control radio buttons.
|
|
468
|
+
*
|
|
469
|
+
* Each radio button should have a `value` set!
|
|
470
|
+
*
|
|
471
|
+
* @component
|
|
472
|
+
* @param {Object} props - Component props.
|
|
473
|
+
* @param {JSX.Element} [props.icon] - Icon to show before the label.
|
|
474
|
+
* @param {string} [props.label] - Label to show above the control.
|
|
475
|
+
* @param {string} [props.help] - Help text displayed below the control.
|
|
476
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
|
|
477
|
+
* @param {string} [props.subtitle] - Subtitle to show below the label.
|
|
478
|
+
* @param {RadioButtonGroupOrientation} [props.orientation='vertical'] - Orientation of the radio buttons.
|
|
479
|
+
* @param {RadioButtonGroupDesign} [props.design='default'] - Design of the radio buttons.
|
|
480
|
+
* @param {boolean} [props.disabled] - Whether the radio button group is disabled.
|
|
481
|
+
* @param {boolean} [props.readOnly] - Whether the radio button group is read-only.
|
|
482
|
+
* @param {string} [props.value] - Value of the currently selected radio button.
|
|
483
|
+
* @param {Function} [props.onChange] - Function to call when the value of the selected radio button changes.
|
|
484
|
+
* @param {string} [props.className] - Additional classes to add to the group container.
|
|
485
|
+
* @param {string} [props.labelClassName] - Additional classes to add to the label container.
|
|
486
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
487
|
+
*
|
|
488
|
+
* @returns {JSX.Element} The RadioButtonGroup component.
|
|
489
|
+
*
|
|
490
|
+
* @typedef {'horizontal' | 'vertical'} RadioButtonGroupOrientation
|
|
491
|
+
* @typedef {'default' | 'segmented'} RadioButtonGroupDesign
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* const [value, setValue] = useState('first'); // Or "null" if you don't want anything selected by default.
|
|
495
|
+
*
|
|
496
|
+
* <RadioButtonGroup
|
|
497
|
+
* label='My radio buttons'
|
|
498
|
+
* value={value}
|
|
499
|
+
* onChange={setValue}
|
|
500
|
+
* >
|
|
501
|
+
* <RadioButton value='first' label='First option' />
|
|
502
|
+
* <RadioButton value='second' label='Second option' />
|
|
503
|
+
* </RadioButtonGroup>
|
|
504
|
+
*
|
|
505
|
+
* @preserve
|
|
506
|
+
*/
|
|
507
|
+
const RadioButtonGroup = (props) => {
|
|
508
|
+
const {
|
|
509
|
+
icon,
|
|
510
|
+
help,
|
|
511
|
+
label,
|
|
512
|
+
actions,
|
|
513
|
+
subtitle,
|
|
514
|
+
orientation = "vertical",
|
|
515
|
+
design = "default",
|
|
516
|
+
disabled,
|
|
517
|
+
readOnly,
|
|
518
|
+
value,
|
|
519
|
+
onChange,
|
|
520
|
+
children,
|
|
521
|
+
className,
|
|
522
|
+
labelClassName,
|
|
523
|
+
hidden,
|
|
524
|
+
...rest
|
|
525
|
+
} = props;
|
|
526
|
+
if (hidden) {
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
let mappedChildren = children ?? [];
|
|
530
|
+
if (!Array.isArray(children)) {
|
|
531
|
+
mappedChildren = [children];
|
|
532
|
+
}
|
|
533
|
+
mappedChildren = children.map((child, index) => {
|
|
534
|
+
if (child.type.displayName !== "RadioButton") {
|
|
535
|
+
return child;
|
|
536
|
+
}
|
|
537
|
+
return cloneElement(child, {
|
|
538
|
+
design: orientation === "horizontal" ? `${design}Horizontal` : design,
|
|
539
|
+
key: child.props.value ?? index
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
return /* @__PURE__ */ jsx(
|
|
543
|
+
$b6c3ddc6086f204d$export$a98f0dcb43a68a25,
|
|
544
|
+
{
|
|
545
|
+
className: clsx("es:w-full", className),
|
|
546
|
+
isDisabled: disabled,
|
|
547
|
+
isReadOnly: readOnly,
|
|
548
|
+
onChange,
|
|
549
|
+
value,
|
|
550
|
+
orientation,
|
|
551
|
+
...rest,
|
|
552
|
+
children: /* @__PURE__ */ jsx(
|
|
553
|
+
BaseControl,
|
|
554
|
+
{
|
|
555
|
+
icon,
|
|
556
|
+
label,
|
|
557
|
+
subtitle,
|
|
558
|
+
actions,
|
|
559
|
+
help,
|
|
560
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
561
|
+
className: labelClassName,
|
|
562
|
+
children: /* @__PURE__ */ jsx(
|
|
563
|
+
"div",
|
|
564
|
+
{
|
|
565
|
+
className: clsx(
|
|
566
|
+
design === "default" && orientation === "horizontal" && "es:flex es:flex-wrap es:gap-2.5",
|
|
567
|
+
design === "default" && orientation === "vertical" && "es:flex es:flex-col es:gap-2.5",
|
|
568
|
+
design === "segmented" && orientation === "vertical" && "es:flex es:flex-col es:-space-y-px",
|
|
569
|
+
design === "segmented" && orientation === "horizontal" && "es:nowrap es:flex es:-space-x-px"
|
|
570
|
+
),
|
|
571
|
+
children: mappedChildren
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
};
|
|
579
|
+
export {
|
|
580
|
+
RadioButton,
|
|
581
|
+
RadioButtonGroup
|
|
582
|
+
};
|