@eightshift/ui-components 0.0.1
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/README.md +27 -0
- package/dist/Checkbox-BLcVbhiO.js +178 -0
- package/dist/ColorSwatch-Cmlex_kT.js +66 -0
- package/dist/FieldError-wtMA4667.js +42 -0
- package/dist/FocusScope-1u9yyfIN.js +725 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/GridList-BZPXp3_O.js +1256 -0
- package/dist/Group-DyqpTRPe.js +49 -0
- package/dist/Input-jsbb4ugq.js +130 -0
- package/dist/Label-BPzS-sR7.js +17 -0
- package/dist/ListBox-w9gDaJkV.js +4423 -0
- package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
- package/dist/NumberFormatter-LzoKy975.js +160 -0
- package/dist/RSPContexts-CrNYmadY.js +14 -0
- package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
- package/dist/SelectionManager-mefd0ThJ.js +2155 -0
- package/dist/Separator-DHn0CwdK.js +325 -0
- package/dist/Slider-Pyh2V4bY.js +885 -0
- package/dist/Text-BM136LvS.js +17 -0
- package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
- package/dist/assets/style.css +1 -0
- package/dist/button-BkkdyHfJ.js +307 -0
- package/dist/components/animated-visibility/animated-visibility.js +7165 -0
- package/dist/components/base-control/base-control.js +97 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
- package/dist/components/button/button.js +10 -0
- package/dist/components/checkbox/checkbox.js +119 -0
- package/dist/components/color-pickers/color-picker.js +242 -0
- package/dist/components/color-pickers/color-swatch.js +62 -0
- package/dist/components/color-pickers/gradient-editor.js +516 -0
- package/dist/components/color-pickers/solid-color-picker.js +1633 -0
- package/dist/components/component-toggle/component-toggle.js +71 -0
- package/dist/components/container-panel/container-panel.js +39 -0
- package/dist/components/expandable/expandable.js +144 -0
- package/dist/components/input-field/input-field.js +224 -0
- package/dist/components/link-input/link-input.js +937 -0
- package/dist/components/list-box/list-box.js +152 -0
- package/dist/components/matrix-align/matrix-align.js +185 -0
- package/dist/components/menu/menu.js +1608 -0
- package/dist/components/notice/notice.js +119 -0
- package/dist/components/number-picker/number-picker.js +277 -0
- package/dist/components/popover/popover.js +9 -0
- package/dist/components/radio/radio.js +552 -0
- package/dist/components/repeater/repeater-item.js +127 -0
- package/dist/components/repeater/repeater.js +248 -0
- package/dist/components/responsive/responsive-legacy.js +326 -0
- package/dist/components/responsive/responsive.js +499 -0
- package/dist/components/responsive-preview/responsive-preview.js +119 -0
- package/dist/components/rich-label/rich-label.js +56 -0
- package/dist/components/select/async-multi-select.js +144 -0
- package/dist/components/select/async-single-select.js +126 -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 +134 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +45 -0
- package/dist/components/select/single-select.js +116 -0
- package/dist/components/select/styles.js +55 -0
- package/dist/components/slider/column-config-slider.js +225 -0
- package/dist/components/slider/slider.js +362 -0
- package/dist/components/slider/utils.js +45 -0
- package/dist/components/spacer/spacer.js +93 -0
- package/dist/components/tabs/tabs.js +626 -0
- package/dist/components/toggle/switch.js +140 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle-button/toggle-button.js +206 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/context-jMy6xdVq.js +98 -0
- package/dist/default-i18n-BhE-OUmt.js +873 -0
- package/dist/filterDOMProps-DG2RfOUr.js +30 -0
- package/dist/focusSafely-C3K8zAKj.js +743 -0
- package/dist/hooks/use-cell-edit-mode.js +35 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +21 -0
- package/dist/icons/icons.js +3636 -0
- package/dist/index-Bfb9bWcb.js +28844 -0
- package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
- package/dist/index.js +109 -0
- package/dist/intlStrings-CUhoK9EN.js +2484 -0
- package/dist/isScrollable-PcyglExV.js +10 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-CjVpCNko.js +3677 -0
- package/dist/number-rWqELA8W.js +39 -0
- package/dist/popover-Dx3vKXUX.js +1061 -0
- package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
- package/dist/react-select.esm-BjRWqf0E.js +15 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-BosCCRVE.js +89 -0
- package/dist/tooltip-CkCndvTI.js +1094 -0
- package/dist/useButton-CuG5UzUw.js +74 -0
- package/dist/useEvent-DHv-yhOH.js +24 -0
- package/dist/useFocusRing-Cc-4eouh.js +41 -0
- package/dist/useFocusable-5q1Gek1J.js +81 -0
- package/dist/useFormReset-Buc9YJcv.js +23 -0
- package/dist/useFormValidationState-BAPPNXic.js +238 -0
- package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
- package/dist/useLabel-CGlkoFG0.js +28 -0
- package/dist/useLabels-Dg62M_3P.js +25 -0
- package/dist/useListData-BelKu4kx.js +211 -0
- package/dist/useListState-Domq0blV.js +137 -0
- package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
- package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
- package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
- package/dist/usePress-BQgVor4T.js +698 -0
- package/dist/useToggle-C9ETOBaZ.js +58 -0
- package/dist/useToggleState-DJ_z5E2S.js +21 -0
- package/dist/utilities/classnames.js +16 -0
- package/dist/utilities/text-helpers.js +79 -0
- package/dist/utils-BsiH7-5Y.js +488 -0
- package/package.json +71 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, l as $df56164dff5785e2$export$4338b53315abf666, m as $5dc95899b306f630$export$c9058316764c140e, i as $64fa3d84918910a7$export$ef03459518577ad4, c as $64fa3d84918910a7$export$4d86445c2cf5e3, d as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "../../utils-BsiH7-5Y.js";
|
|
3
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-DG2RfOUr.js";
|
|
4
|
+
import React__default, { forwardRef, createContext } from "react";
|
|
5
|
+
import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-DJ_z5E2S.js";
|
|
6
|
+
import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577 } from "../../useToggle-C9ETOBaZ.js";
|
|
7
|
+
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Cc-4eouh.js";
|
|
8
|
+
import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../focusSafely-C3K8zAKj.js";
|
|
9
|
+
import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "../../VisuallyHidden-BYRI1Lfo.js";
|
|
10
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
11
|
+
function $b418ec0c85c52f27$export$d853f7095ae95f88(props, state, ref) {
|
|
12
|
+
let { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly } = $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref);
|
|
13
|
+
return {
|
|
14
|
+
labelProps,
|
|
15
|
+
inputProps: {
|
|
16
|
+
...inputProps,
|
|
17
|
+
role: "switch",
|
|
18
|
+
checked: isSelected
|
|
19
|
+
},
|
|
20
|
+
isSelected,
|
|
21
|
+
isPressed,
|
|
22
|
+
isDisabled,
|
|
23
|
+
isReadOnly
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const $8e59e948500a8fe1$export$8699e3b644d5a28a = /* @__PURE__ */ createContext(null);
|
|
27
|
+
function $8e59e948500a8fe1$var$Switch(props, ref) {
|
|
28
|
+
let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
|
|
29
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(otherProps, ref, $8e59e948500a8fe1$export$8699e3b644d5a28a);
|
|
30
|
+
let inputRef = $df56164dff5785e2$export$4338b53315abf666($5dc95899b306f630$export$c9058316764c140e(userProvidedInputRef, props.inputRef !== void 0 ? props.inputRef : null));
|
|
31
|
+
let state = $3017fa7ffdddec74$export$8042c6c013fd5226(props);
|
|
32
|
+
let { labelProps, inputProps, isSelected, isDisabled, isReadOnly, isPressed } = $b418ec0c85c52f27$export$d853f7095ae95f88({
|
|
33
|
+
...$64fa3d84918910a7$export$ef03459518577ad4(props),
|
|
34
|
+
// ReactNode type doesn't allow function children.
|
|
35
|
+
children: typeof props.children === "function" ? true : props.children
|
|
36
|
+
}, state, inputRef);
|
|
37
|
+
let { isFocused, isFocusVisible, focusProps } = $f7dceffc5ad7768b$export$4e328f61c538687f();
|
|
38
|
+
let isInteractionDisabled = props.isDisabled || props.isReadOnly;
|
|
39
|
+
let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
|
|
40
|
+
...props,
|
|
41
|
+
isDisabled: isInteractionDisabled
|
|
42
|
+
});
|
|
43
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
44
|
+
...props,
|
|
45
|
+
defaultClassName: "react-aria-Switch",
|
|
46
|
+
values: {
|
|
47
|
+
isSelected,
|
|
48
|
+
isPressed,
|
|
49
|
+
isHovered,
|
|
50
|
+
isFocused,
|
|
51
|
+
isFocusVisible,
|
|
52
|
+
isDisabled,
|
|
53
|
+
isReadOnly,
|
|
54
|
+
state
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
58
|
+
delete DOMProps.id;
|
|
59
|
+
return /* @__PURE__ */ React__default.createElement("label", {
|
|
60
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, labelProps, hoverProps, renderProps),
|
|
61
|
+
ref,
|
|
62
|
+
slot: props.slot || void 0,
|
|
63
|
+
"data-selected": isSelected || void 0,
|
|
64
|
+
"data-pressed": isPressed || void 0,
|
|
65
|
+
"data-hovered": isHovered || void 0,
|
|
66
|
+
"data-focused": isFocused || void 0,
|
|
67
|
+
"data-focus-visible": isFocusVisible || void 0,
|
|
68
|
+
"data-disabled": isDisabled || void 0,
|
|
69
|
+
"data-readonly": isReadOnly || void 0
|
|
70
|
+
}, /* @__PURE__ */ React__default.createElement($5c3e21d68f1c4674$export$439d29a4e110a164, {
|
|
71
|
+
elementType: "span"
|
|
72
|
+
}, /* @__PURE__ */ React__default.createElement("input", {
|
|
73
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(inputProps, focusProps),
|
|
74
|
+
ref: inputRef
|
|
75
|
+
})), renderProps.children);
|
|
76
|
+
}
|
|
77
|
+
const $8e59e948500a8fe1$export$b5d5cf8927ab7262 = /* @__PURE__ */ forwardRef($8e59e948500a8fe1$var$Switch);
|
|
78
|
+
/**
|
|
79
|
+
* A toggle switch.
|
|
80
|
+
*
|
|
81
|
+
* @component
|
|
82
|
+
* @param {Object} props - Component props.
|
|
83
|
+
* @param {boolean} props.checked - Whether the switch is checked.
|
|
84
|
+
* @param {Function} props.onChange - Function to call when the switch is toggled.
|
|
85
|
+
* @param {boolean} [props.disabled] - Whether the switch is disabled.
|
|
86
|
+
* @param {string} [props.id] - The ID of the switch.
|
|
87
|
+
* @param {string} [props.className] - Classes to pass to the switch.
|
|
88
|
+
*
|
|
89
|
+
* @returns {JSX.Element} The Switch component.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* const [checked, setChecked] = useState(false);
|
|
93
|
+
*
|
|
94
|
+
* <Switch
|
|
95
|
+
* checked={checked}
|
|
96
|
+
* onChange={() => setChecked(!checked)}
|
|
97
|
+
* />
|
|
98
|
+
*
|
|
99
|
+
* @preserve
|
|
100
|
+
*/
|
|
101
|
+
const Switch = (props) => {
|
|
102
|
+
const { checked, onChange, disabled, id, children, className } = props;
|
|
103
|
+
return /* @__PURE__ */ jsxs(
|
|
104
|
+
$8e59e948500a8fe1$export$b5d5cf8927ab7262,
|
|
105
|
+
{
|
|
106
|
+
id,
|
|
107
|
+
isDisabled: disabled,
|
|
108
|
+
isSelected: checked ?? false,
|
|
109
|
+
onChange,
|
|
110
|
+
className: "es-uic-group es-uic-flex es-uic-items-center es-uic-justify-between es-uic-gap-2",
|
|
111
|
+
children: [
|
|
112
|
+
children,
|
|
113
|
+
/* @__PURE__ */ jsx("div", { className: classnames("es-uic-flex es-uic-items-center es-uic-min-w-9 es-uic-justify-center", className), children: /* @__PURE__ */ jsx(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: classnames(
|
|
117
|
+
"es-uic-no-webkit-highlight es-uic-h-4 es-uic-w-7 es-uic-shrink-0 es-uic-cursor-pointer es-uic-rounded-full es-uic-border es-uic-border-gray-500 es-uic-bg-white es-uic-p-[0.1875rem] es-uic-shadow-sm es-uic-outline-none es-uic-transition",
|
|
118
|
+
"group-focus-visible:es-uic-ring group-focus-visible:es-uic-ring-teal-500 group-focus-visible:es-uic-ring-opacity-50",
|
|
119
|
+
"group-selected:es-uic-border-teal-800/75 group-selected:es-uic-bg-teal-100/25 group-selected:es-uic-shadow-teal-500/25",
|
|
120
|
+
"group-disabled:es-uic-cursor-default group-disabled:es-uic-border-gray-300 group-disabled:es-uic-bg-white"
|
|
121
|
+
),
|
|
122
|
+
children: /* @__PURE__ */ jsx(
|
|
123
|
+
"span",
|
|
124
|
+
{
|
|
125
|
+
className: classnames(
|
|
126
|
+
"es-uic-block es-uic-size-2 es-uic-rounded-full es-uic-border es-uic-border-gray-500 es-uic-bg-gray-500 es-uic-transition es-uic-will-change-transform",
|
|
127
|
+
"group-selected:es-uic-translate-x-3 group-selected:es-uic-scale-125 group-selected:es-uic-border-teal-600 group-selected:es-uic-bg-teal-600",
|
|
128
|
+
"group-disabled:es-uic-border-gray-300 group-disabled:es-uic-bg-white"
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
) })
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
Switch
|
|
140
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BPzS-sR7.js";
|
|
3
|
+
import { Switch } from "./switch.js";
|
|
4
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
5
|
+
/**
|
|
6
|
+
* A toggle switch with a label and optional icon and subtitle.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @param {Object} props - Component props.
|
|
10
|
+
* @param {boolean} props.checked - Whether the switch is checked.
|
|
11
|
+
* @param {Function} props.onChange - Function to call when the switch is toggled.
|
|
12
|
+
* @param {boolean} [props.disabled] - Whether the switch is disabled.
|
|
13
|
+
* @param {JSX.Element} [props.icon] - Icon to display.
|
|
14
|
+
* @param {string} props.label - Label to display.
|
|
15
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
16
|
+
* @param {string} [props.className] - Classes to pass to the toggle switch.
|
|
17
|
+
* @param {string} [props.labelClassName] - Classes to pass to the label.
|
|
18
|
+
*
|
|
19
|
+
* @returns {JSX.Element} The Toggle component.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const [checked, setChecked] = useState(false);
|
|
23
|
+
*
|
|
24
|
+
* <Toggle
|
|
25
|
+
* icon={icons.myIcon}
|
|
26
|
+
* label='My toggle'
|
|
27
|
+
* checked={checked}
|
|
28
|
+
* onChange={() => setChecked(!checked)}
|
|
29
|
+
* />
|
|
30
|
+
*
|
|
31
|
+
* @preserve
|
|
32
|
+
*/
|
|
33
|
+
const Toggle = (props) => {
|
|
34
|
+
const { checked, onChange, icon, label, subtitle, disabled, className, labelClassName } = props;
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
Switch,
|
|
37
|
+
{
|
|
38
|
+
checked,
|
|
39
|
+
onChange,
|
|
40
|
+
disabled,
|
|
41
|
+
className,
|
|
42
|
+
children: /* @__PURE__ */ jsx(
|
|
43
|
+
RichLabel,
|
|
44
|
+
{
|
|
45
|
+
as: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
46
|
+
icon,
|
|
47
|
+
label,
|
|
48
|
+
subtitle,
|
|
49
|
+
className: labelClassName,
|
|
50
|
+
fullWidth: true
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
Toggle
|
|
58
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { n as $ff5963eb1fccf552$export$e08e3b67e392101e, d as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, c as $64fa3d84918910a7$export$4d86445c2cf5e3 } from "../../utils-BsiH7-5Y.js";
|
|
3
|
+
import React__default, { forwardRef, createContext } from "react";
|
|
4
|
+
import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-DJ_z5E2S.js";
|
|
5
|
+
import { $ as $701a24aa0da5b062$export$ea18c227d4417cc3 } from "../../useButton-CuG5UzUw.js";
|
|
6
|
+
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Cc-4eouh.js";
|
|
7
|
+
import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../focusSafely-C3K8zAKj.js";
|
|
8
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
9
|
+
import { T as Tooltip } from "../../tooltip-CkCndvTI.js";
|
|
10
|
+
function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
|
|
11
|
+
const { isSelected } = state;
|
|
12
|
+
const { isPressed, buttonProps } = $701a24aa0da5b062$export$ea18c227d4417cc3({
|
|
13
|
+
...props,
|
|
14
|
+
onPress: $ff5963eb1fccf552$export$e08e3b67e392101e(state.toggle, props.onPress)
|
|
15
|
+
}, ref);
|
|
16
|
+
return {
|
|
17
|
+
isPressed,
|
|
18
|
+
buttonProps: $3ef42575df84b30b$export$9d1611c77c2fe928(buttonProps, {
|
|
19
|
+
"aria-pressed": isSelected
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const $efde0372d7a700fe$export$43506d75ebd2e218 = /* @__PURE__ */ createContext({});
|
|
24
|
+
function $efde0372d7a700fe$var$ToggleButton(props, ref) {
|
|
25
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $efde0372d7a700fe$export$43506d75ebd2e218);
|
|
26
|
+
let state = $3017fa7ffdddec74$export$8042c6c013fd5226(props);
|
|
27
|
+
let { buttonProps, isPressed } = $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref);
|
|
28
|
+
let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f(props);
|
|
29
|
+
let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456(props);
|
|
30
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
31
|
+
...props,
|
|
32
|
+
values: {
|
|
33
|
+
isHovered,
|
|
34
|
+
isPressed,
|
|
35
|
+
isFocused,
|
|
36
|
+
isSelected: state.isSelected,
|
|
37
|
+
isFocusVisible,
|
|
38
|
+
isDisabled: props.isDisabled || false,
|
|
39
|
+
state
|
|
40
|
+
},
|
|
41
|
+
defaultClassName: "react-aria-ToggleButton"
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ React__default.createElement("button", {
|
|
44
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(buttonProps, focusProps, hoverProps),
|
|
45
|
+
...renderProps,
|
|
46
|
+
ref,
|
|
47
|
+
slot: props.slot || void 0,
|
|
48
|
+
"data-focused": isFocused || void 0,
|
|
49
|
+
"data-disabled": props.isDisabled || void 0,
|
|
50
|
+
"data-pressed": isPressed || void 0,
|
|
51
|
+
"data-selected": state.isSelected || void 0,
|
|
52
|
+
"data-hovered": isHovered || void 0,
|
|
53
|
+
"data-focus-visible": isFocusVisible || void 0
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const $efde0372d7a700fe$export$d2b052e7b4be1756 = /* @__PURE__ */ forwardRef($efde0372d7a700fe$var$ToggleButton);
|
|
57
|
+
/**
|
|
58
|
+
* A simple toggle button component.
|
|
59
|
+
*
|
|
60
|
+
* @component
|
|
61
|
+
* @param {Object} props - Component props.
|
|
62
|
+
* @param {JSX.Element} [props.icon] - Icon to display within the button.
|
|
63
|
+
* @param {ButtonSize} [props.size='default'] - The size of the button.
|
|
64
|
+
* @param {ButtonType} [props.type='default'] - The type of the button.
|
|
65
|
+
* @param {boolean} [props.disabled] - If `true`, the button is disabled.
|
|
66
|
+
* @param {string} [props.className] - Classes to pass to the button.
|
|
67
|
+
* @param {string} [props.tooltip] - Tooltip text to display on hover.
|
|
68
|
+
* @param {boolean} props.selected - Whether the button is selected.
|
|
69
|
+
* @param {Function} [props.onChange] - Function to run when the toggle state changes.
|
|
70
|
+
* @param {string} [props.wrapperClassName] - Classes to pass to the tooltip wrapper.
|
|
71
|
+
* @param {Object} [props.tooltipProps] - Props to pass to the tooltip.
|
|
72
|
+
*
|
|
73
|
+
* @returns {JSX.Element} The Button component.
|
|
74
|
+
*
|
|
75
|
+
* @typedef {'small' | 'default' | 'large'} ButtonSize
|
|
76
|
+
* @typedef {'default' | 'selected' | 'ghost' | 'danger'} ButtonType
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const [selected, setSelected] = useState(false);
|
|
80
|
+
*
|
|
81
|
+
* <ToggleButton
|
|
82
|
+
* selected={selected}
|
|
83
|
+
* onChange={setSelected}
|
|
84
|
+
* icon={icons.myIcon}
|
|
85
|
+
* />
|
|
86
|
+
*
|
|
87
|
+
* <ToggleButton
|
|
88
|
+
* selected={selected}
|
|
89
|
+
* onChange={setSelected}
|
|
90
|
+
* icon={icons.myIcon}
|
|
91
|
+
* >
|
|
92
|
+
* My button
|
|
93
|
+
* </ToggleButton>
|
|
94
|
+
*
|
|
95
|
+
* @preserve
|
|
96
|
+
*/
|
|
97
|
+
const ToggleButton = (props) => {
|
|
98
|
+
const {
|
|
99
|
+
children,
|
|
100
|
+
icon,
|
|
101
|
+
size = "default",
|
|
102
|
+
type = "default",
|
|
103
|
+
disabled,
|
|
104
|
+
className,
|
|
105
|
+
tooltip,
|
|
106
|
+
selected,
|
|
107
|
+
onChange,
|
|
108
|
+
wrapperClassName,
|
|
109
|
+
tooltipProps,
|
|
110
|
+
...other
|
|
111
|
+
} = props;
|
|
112
|
+
const sizes = {
|
|
113
|
+
small: {
|
|
114
|
+
iconButton: "es-uic-size-7",
|
|
115
|
+
button: "es-uic-h-7 es-uic-min-w-7",
|
|
116
|
+
iconButtonPadding: "es-uic-px-1",
|
|
117
|
+
buttonPadding: "es-uic-px-2",
|
|
118
|
+
iconSize: "[&>svg]:es-uic-size-4"
|
|
119
|
+
},
|
|
120
|
+
default: {
|
|
121
|
+
iconButton: "es-uic-size-9",
|
|
122
|
+
button: "es-uic-h-9 es-uic-min-w-9",
|
|
123
|
+
iconButtonPadding: "es-uic-px-1.5",
|
|
124
|
+
buttonPadding: "es-uic-px-2",
|
|
125
|
+
iconSize: "[&>svg]:es-uic-size-5.5"
|
|
126
|
+
},
|
|
127
|
+
large: {
|
|
128
|
+
iconButton: "es-uic-size-10",
|
|
129
|
+
button: "es-uic-h-10 es-uic-min-w-10",
|
|
130
|
+
iconButtonPadding: "es-uic-px-2",
|
|
131
|
+
buttonPadding: "es-uic-px-4",
|
|
132
|
+
iconSize: "[&>svg]:es-uic-size-6"
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const themes = {
|
|
136
|
+
default: {
|
|
137
|
+
regular: "es-uic-border-gray-300 es-uic-text-gray-700 es-uic-shadow-sm es-uic-border",
|
|
138
|
+
hover: "hover:es-uic-border-gray-300 hover:es-uic-bg-gray-100",
|
|
139
|
+
selected: "es-uic-bg-teal-600 es-uic-text-white es-uic-border-teal-600 after:es-uic-opacity-30 es-uic-border es-uic-shadow-md es-uic-shadow-teal-500/25",
|
|
140
|
+
selectedHover: "hover:es-uic-shadow-teal-600/50 hover:after:es-uic-opacity-40",
|
|
141
|
+
focus: " focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
|
|
142
|
+
disabled: "disabled:es-uic-border-gray-200 disabled:es-uic-text-gray-300 es-uic-border"
|
|
143
|
+
},
|
|
144
|
+
ghost: {
|
|
145
|
+
regular: "es-uic-border-transparent es-uic-text-gray-700",
|
|
146
|
+
hover: "hover:es-uic-bg-gray-100",
|
|
147
|
+
disabled: "disabled:es-uic-text-gray-300 disabled:es-uic-border-transparent",
|
|
148
|
+
selected: "es-uic-bg-teal-600 es-uic-text-white es-uic-border-teal-600 after:es-uic-opacity-30 es-uic-shadow es-uic-shadow-teal-500/25",
|
|
149
|
+
selectedHover: "hover:es-uic-shadow-teal-600/50 hover:after:es-uic-opacity-40"
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const component = /* @__PURE__ */ jsxs(
|
|
153
|
+
$efde0372d7a700fe$export$d2b052e7b4be1756,
|
|
154
|
+
{
|
|
155
|
+
isSelected: selected,
|
|
156
|
+
onChange,
|
|
157
|
+
isDisabled: disabled,
|
|
158
|
+
className: ({ isSelected }) => {
|
|
159
|
+
var _a, _b, _c, _d, _e, _f;
|
|
160
|
+
return classnames(
|
|
161
|
+
"es-uic-isolate es-uic-flex es-uic-items-center es-uic-justify-center es-uic-gap-1 es-uic-rounded-md es-uic-transition es-uic-duration-300 es-uic-relative",
|
|
162
|
+
'after:es-uic-absolute after:es-uic-inset-0 after:-es-uic-z-10 after:es-uic-rounded-[0.3125rem] after:es-uic-bg-gradient-to-br after:es-uic-from-teal-100/40 after:es-uic-via-transparent after:es-uic-to-teal-200/50 after:es-uic-opacity-0 after:es-uic-transition-opacity after:es-uic-content-[""]',
|
|
163
|
+
"disabled:es-uic-shadow-none",
|
|
164
|
+
"focus:es-uic-outline-none focus-visible:es-uic-outline-none focus-visible:es-uic-ring",
|
|
165
|
+
!disabled && !isSelected && (((_a = themes[type]) == null ? void 0 : _a.regular) ?? themes.default.regular),
|
|
166
|
+
!disabled && !isSelected && (((_b = themes[type]) == null ? void 0 : _b.hover) ?? themes.default.hover),
|
|
167
|
+
!disabled && isSelected && (((_c = themes[type]) == null ? void 0 : _c.selectedHover) ?? themes.default.selectedHover),
|
|
168
|
+
((_d = themes[type]) == null ? void 0 : _d.disabled) ?? themes.default.disabled,
|
|
169
|
+
((_e = themes[type]) == null ? void 0 : _e.focus) ?? themes.default.focus,
|
|
170
|
+
icon && !children && sizes[size].iconButton,
|
|
171
|
+
children && "es-uic-text-sm",
|
|
172
|
+
children && sizes[size].button,
|
|
173
|
+
children && icon && sizes[size].iconButtonPadding,
|
|
174
|
+
children && !icon && sizes[size].buttonPadding,
|
|
175
|
+
sizes[size].iconSize,
|
|
176
|
+
isSelected && (((_f = themes[type]) == null ? void 0 : _f.selected) ?? themes.default.selected),
|
|
177
|
+
"[.es-uic-button-group_&:not(:first-child)]:es-uic-rounded-l-none [.es-uic-button-group_&:not(:last-child)]:-es-uic-mr-px [.es-uic-button-group_&:not(:last-child)]:es-uic-rounded-r-none",
|
|
178
|
+
"[.es-uic-button-group_&:not(:first-child)]:after:es-uic-rounded-l-none [.es-uic-button-group_&:not(:last-child)]:after:es-uic-rounded-r-none",
|
|
179
|
+
"[.es-uic-button-group_div:not(:first-child)_>_&]:es-uic-rounded-l-none [.es-uic-button-group_div:not(:last-child)_>_&]:-es-uic-mr-px [.es-uic-button-group_div:not(:last-child)_>_&]:es-uic-rounded-r-none",
|
|
180
|
+
"[.es-uic-button-group_div:not(:last-child)_>_&]:after:es-uic-rounded-r-none [.es-uic-button-group_div:not(:first-child)_>_&]:after:es-uic-rounded-l-none",
|
|
181
|
+
className
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
...other,
|
|
185
|
+
children: [
|
|
186
|
+
icon,
|
|
187
|
+
children
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
if (!tooltip) {
|
|
192
|
+
return component;
|
|
193
|
+
}
|
|
194
|
+
return /* @__PURE__ */ jsx(
|
|
195
|
+
Tooltip,
|
|
196
|
+
{
|
|
197
|
+
text: tooltip,
|
|
198
|
+
wrapperClassName,
|
|
199
|
+
...tooltipProps,
|
|
200
|
+
children: component
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
export {
|
|
205
|
+
ToggleButton
|
|
206
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import { D, T } from "../../tooltip-CkCndvTI.js";
|
|
3
|
+
import "../../utilities/classnames.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "../../focusSafely-C3K8zAKj.js";
|
|
6
|
+
import "../../utils-BsiH7-5Y.js";
|
|
7
|
+
export {
|
|
8
|
+
D as DecorativeTooltip,
|
|
9
|
+
T as Tooltip
|
|
10
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React__default, { useState, useEffect, useContext } from "react";
|
|
2
|
+
import { o as $b5e257d569688ac6$export$535bd6ca7f90a273 } from "./utils-BsiH7-5Y.js";
|
|
3
|
+
const $148a7a147e38ea7f$var$RTL_SCRIPTS = /* @__PURE__ */ new Set([
|
|
4
|
+
"Arab",
|
|
5
|
+
"Syrc",
|
|
6
|
+
"Samr",
|
|
7
|
+
"Mand",
|
|
8
|
+
"Thaa",
|
|
9
|
+
"Mend",
|
|
10
|
+
"Nkoo",
|
|
11
|
+
"Adlm",
|
|
12
|
+
"Rohg",
|
|
13
|
+
"Hebr"
|
|
14
|
+
]);
|
|
15
|
+
const $148a7a147e38ea7f$var$RTL_LANGS = /* @__PURE__ */ new Set([
|
|
16
|
+
"ae",
|
|
17
|
+
"ar",
|
|
18
|
+
"arc",
|
|
19
|
+
"bcc",
|
|
20
|
+
"bqi",
|
|
21
|
+
"ckb",
|
|
22
|
+
"dv",
|
|
23
|
+
"fa",
|
|
24
|
+
"glk",
|
|
25
|
+
"he",
|
|
26
|
+
"ku",
|
|
27
|
+
"mzn",
|
|
28
|
+
"nqo",
|
|
29
|
+
"pnb",
|
|
30
|
+
"ps",
|
|
31
|
+
"sd",
|
|
32
|
+
"ug",
|
|
33
|
+
"ur",
|
|
34
|
+
"yi"
|
|
35
|
+
]);
|
|
36
|
+
function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
|
|
37
|
+
if (Intl.Locale) {
|
|
38
|
+
let locale = new Intl.Locale(localeString).maximize();
|
|
39
|
+
let textInfo = typeof locale.getTextInfo === "function" ? locale.getTextInfo() : locale.textInfo;
|
|
40
|
+
if (textInfo)
|
|
41
|
+
return textInfo.direction === "rtl";
|
|
42
|
+
if (locale.script)
|
|
43
|
+
return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(locale.script);
|
|
44
|
+
}
|
|
45
|
+
let lang = localeString.split("-")[0];
|
|
46
|
+
return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
|
|
47
|
+
}
|
|
48
|
+
const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for("react-aria.i18n.locale");
|
|
49
|
+
function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
|
|
50
|
+
let locale = typeof window !== "undefined" && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";
|
|
51
|
+
try {
|
|
52
|
+
Intl.DateTimeFormat.supportedLocalesOf([
|
|
53
|
+
locale
|
|
54
|
+
]);
|
|
55
|
+
} catch (_err) {
|
|
56
|
+
locale = "en-US";
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
locale,
|
|
60
|
+
direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ? "rtl" : "ltr"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
|
|
64
|
+
let $1e5a04cdaf7d1af8$var$listeners = /* @__PURE__ */ new Set();
|
|
65
|
+
function $1e5a04cdaf7d1af8$var$updateLocale() {
|
|
66
|
+
$1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
|
|
67
|
+
for (let listener of $1e5a04cdaf7d1af8$var$listeners)
|
|
68
|
+
listener($1e5a04cdaf7d1af8$var$currentLocale);
|
|
69
|
+
}
|
|
70
|
+
function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
|
|
71
|
+
let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
|
|
72
|
+
let [defaultLocale, setDefaultLocale] = useState($1e5a04cdaf7d1af8$var$currentLocale);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0)
|
|
75
|
+
window.addEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
|
|
76
|
+
$1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
|
|
77
|
+
return () => {
|
|
78
|
+
$1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale);
|
|
79
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0)
|
|
80
|
+
window.removeEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
if (isSSR)
|
|
84
|
+
return {
|
|
85
|
+
locale: "en-US",
|
|
86
|
+
direction: "ltr"
|
|
87
|
+
};
|
|
88
|
+
return defaultLocale;
|
|
89
|
+
}
|
|
90
|
+
const $18f2051aff69b9bf$var$I18nContext = /* @__PURE__ */ React__default.createContext(null);
|
|
91
|
+
function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
|
|
92
|
+
let defaultLocale = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
|
|
93
|
+
let context = useContext($18f2051aff69b9bf$var$I18nContext);
|
|
94
|
+
return context || defaultLocale;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
$18f2051aff69b9bf$export$43bb16f9c6d9e3f7 as $
|
|
98
|
+
};
|