@eightshift/ui-components 4.0.0 → 5.0.0
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/package.json +101 -101
- package/dist/Button-CvzGKGCo.js +0 -185
- package/dist/Collection-ddre1L5v.js +0 -2332
- package/dist/Color-MV5kBVXr.js +0 -2452
- package/dist/ColorSwatch-BqQfVu4L.js +0 -64
- package/dist/ComboBox-jQ-dk95U.js +0 -1906
- package/dist/Dialog-DX1aiYyE.js +0 -2300
- package/dist/FieldError-52GVSGgC.js +0 -42
- package/dist/FocusScope-Cri5BFRz.js +0 -831
- package/dist/Form-Cq3fu75_.js +0 -5
- package/dist/Group-_emcIVxI.js +0 -48
- package/dist/Heading-B2153VXe.js +0 -16
- package/dist/Hidden-rE6uR-lr.js +0 -41
- package/dist/Input-BxpFEIXV.js +0 -133
- package/dist/Label-icmbmNdI.js +0 -17
- package/dist/List-BYNHbol3.js +0 -593
- package/dist/ListBox-mJ4nQaL7.js +0 -581
- package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
- package/dist/OverlayArrow-BB0CWwdq.js +0 -629
- package/dist/RSPContexts-2lR5GG9p.js +0 -14
- package/dist/Select-aab027f3.esm--EmXjiL3.js +0 -2469
- package/dist/Separator-D9moUgP8.js +0 -322
- package/dist/Slider-rz2XRMGm.js +0 -853
- package/dist/Text-DVSAPY-K.js +0 -16
- package/dist/VisuallyHidden-f9zX67a_.js +0 -48
- package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
- package/dist/assets/index.css +0 -37
- package/dist/assets/style-admin.css +0 -5255
- package/dist/assets/style-editor.css +0 -5255
- package/dist/assets/style.css +0 -5261
- package/dist/assets/wp-font-enhancements.css +0 -8
- package/dist/assets/wp-ui-enhancements.css +0 -299
- package/dist/components/animated-visibility/animated-visibility.js +0 -105
- package/dist/components/base-control/base-control.js +0 -86
- package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
- package/dist/components/button/button.js +0 -387
- package/dist/components/checkbox/checkbox.js +0 -320
- package/dist/components/color-pickers/color-picker.js +0 -272
- package/dist/components/color-pickers/color-swatch.js +0 -58
- package/dist/components/color-pickers/gradient-editor.js +0 -534
- package/dist/components/color-pickers/solid-color-picker.js +0 -1567
- package/dist/components/component-toggle/component-toggle.js +0 -158
- package/dist/components/container-panel/container-panel.js +0 -131
- package/dist/components/draggable/draggable-context.js +0 -5
- package/dist/components/draggable/draggable-handle.js +0 -46
- package/dist/components/draggable/draggable.js +0 -6207
- package/dist/components/draggable-list/draggable-list-context.js +0 -5
- package/dist/components/draggable-list/draggable-list-item.js +0 -77
- package/dist/components/draggable-list/draggable-list.js +0 -151
- package/dist/components/expandable/expandable.js +0 -342
- package/dist/components/index.js +0 -137
- package/dist/components/input-field/input-field.js +0 -231
- package/dist/components/item-collection/item-collection.js +0 -59
- package/dist/components/layout/hstack.js +0 -30
- package/dist/components/layout/vstack.js +0 -30
- package/dist/components/link-input/link-input.js +0 -293
- package/dist/components/matrix-align/matrix-align.js +0 -134
- package/dist/components/menu/menu.js +0 -285
- package/dist/components/modal/modal.js +0 -305
- package/dist/components/notice/notice.js +0 -123
- package/dist/components/number-picker/number-picker.js +0 -292
- package/dist/components/option-select/option-select.js +0 -264
- package/dist/components/options-panel/options-panel.js +0 -158
- package/dist/components/placeholders/file-placeholder.js +0 -42
- package/dist/components/placeholders/image-placeholder.js +0 -88
- package/dist/components/placeholders/media-placeholder.js +0 -63
- package/dist/components/popover/popover.js +0 -207
- package/dist/components/radio/radio.js +0 -579
- package/dist/components/repeater/repeater-context.js +0 -5
- package/dist/components/repeater/repeater-item.js +0 -119
- package/dist/components/repeater/repeater.js +0 -280
- package/dist/components/responsive/mini-responsive.js +0 -498
- package/dist/components/responsive/responsive-legacy.js +0 -343
- package/dist/components/responsive/responsive.js +0 -580
- package/dist/components/responsive-preview/responsive-preview.js +0 -123
- package/dist/components/rich-label/rich-label.js +0 -66
- package/dist/components/select/async-multi-select.js +0 -157
- package/dist/components/select/async-single-select.js +0 -137
- package/dist/components/select/custom-select-default-components.js +0 -38
- package/dist/components/select/multi-select-components.js +0 -8
- package/dist/components/select/multi-select.js +0 -151
- package/dist/components/select/react-select-component-wrappers.js +0 -90
- package/dist/components/select/shared.js +0 -26
- package/dist/components/select/single-select.js +0 -131
- package/dist/components/select/styles.js +0 -49
- package/dist/components/select/v2/async-select.js +0 -297
- package/dist/components/select/v2/shared.js +0 -24
- package/dist/components/select/v2/single-select.js +0 -990
- package/dist/components/slider/column-config-slider.js +0 -210
- package/dist/components/slider/slider.js +0 -343
- package/dist/components/slider/utils.js +0 -84
- package/dist/components/spacer/spacer.js +0 -97
- package/dist/components/tabs/tabs.js +0 -702
- package/dist/components/toggle/switch.js +0 -155
- package/dist/components/toggle/toggle.js +0 -64
- package/dist/components/toggle-button/toggle-button.js +0 -324
- package/dist/components/tooltip/tooltip.js +0 -525
- package/dist/context-D2KUdwNL.js +0 -92
- package/dist/default-i18n-CT_oS1Fy.js +0 -922
- package/dist/filterDOMProps-EDDcM64A.js +0 -28
- package/dist/icons/block-icon.js +0 -42
- package/dist/icons/generic-color-swatch.js +0 -113
- package/dist/icons/icons.js +0 -30371
- package/dist/icons/index.js +0 -11
- package/dist/icons/jsx-svg.js +0 -50
- package/dist/index-641ee5b8.esm-BPz6U6sJ.js +0 -3137
- package/dist/index-BKGQ6jGS.js +0 -44
- package/dist/index-BYHhzLf-.js +0 -444
- package/dist/index.js +0 -139
- package/dist/lite-DVmmD_-j.js +0 -7
- package/dist/modifiers.esm-BuJQPI1X.js +0 -31
- package/dist/multi-select-components-BlZZoNXC.js +0 -3744
- package/dist/number-GajL10e1.js +0 -36
- package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
- package/dist/react-select-async.esm-CwUoej5h.js +0 -107
- package/dist/react-select.esm-DcwYxadV.js +0 -15
- package/dist/style-admin.js +0 -1
- package/dist/style-editor.js +0 -1
- package/dist/style.js +0 -1
- package/dist/textSelection-0UUS8Yfg.js +0 -46
- package/dist/useButton-BpOKDWEN.js +0 -71
- package/dist/useEvent-B0b-6KBr.js +0 -23
- package/dist/useFocusRing-CV5l3lf6.js +0 -107
- package/dist/useFormReset-C5OggHsw.js +0 -22
- package/dist/useFormValidation-DhDNSjws.js +0 -224
- package/dist/useHover-DwDr6ozG.js +0 -900
- package/dist/useLabel-D7HkNEHT.js +0 -27
- package/dist/useLabels-D8cxd1Z8.js +0 -23
- package/dist/useListState-UGlN5-7P.js +0 -161
- package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
- package/dist/useNumberField-CEAj7Mrj.js +0 -1204
- package/dist/useNumberFormatter-321rAb4J.js +0 -13
- package/dist/usePress-DNW8qpY6.js +0 -664
- package/dist/useSingleSelectListState-DC0wWTUM.js +0 -38
- package/dist/useToggle-BrpmSOB-.js +0 -59
- package/dist/useToggleState-CmQX3SoX.js +0 -19
- package/dist/utilities/array-helpers.js +0 -56
- package/dist/utilities/debounce-throttle.js +0 -123
- package/dist/utilities/es-dash.js +0 -376
- package/dist/utilities/index.js +0 -27
- package/dist/utilities/text-helpers.js +0 -136
- package/dist/utils-DkCSC521.js +0 -370
- package/dist/wp/wp-font-enhancements.js +0 -1
- package/dist/wp/wp-ui-enhancements.js +0 -1
|
@@ -1,155 +0,0 @@
|
|
|
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, h as $64fa3d84918910a7$export$ef03459518577ad4, b as $64fa3d84918910a7$export$4d86445c2cf5e3, d as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "../../utils-DkCSC521.js";
|
|
3
|
-
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
|
|
4
|
-
import React__default, { forwardRef, createContext } from "react";
|
|
5
|
-
import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-CmQX3SoX.js";
|
|
6
|
-
import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577 } from "../../useToggle-BrpmSOB-.js";
|
|
7
|
-
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-CV5l3lf6.js";
|
|
8
|
-
import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-DwDr6ozG.js";
|
|
9
|
-
import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "../../VisuallyHidden-f9zX67a_.js";
|
|
10
|
-
import { c as clsx } from "../../lite-DVmmD_-j.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
|
-
const $8e59e948500a8fe1$export$b5d5cf8927ab7262 = /* @__PURE__ */ forwardRef(function 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
|
-
/**
|
|
78
|
-
* A toggle switch.
|
|
79
|
-
*
|
|
80
|
-
* @component
|
|
81
|
-
* @param {Object} props - Component props.
|
|
82
|
-
* @param {boolean} props.checked - Whether the switch is checked.
|
|
83
|
-
* @param {Function} props.onChange - Function to call when the switch is toggled.
|
|
84
|
-
* @param {boolean} [props.disabled] - Whether the switch is disabled.
|
|
85
|
-
* @param {string} [props.id] - The ID of the switch.
|
|
86
|
-
* @param {string} [props.className] - Classes to pass to the switch.
|
|
87
|
-
* @param {boolean} [props.isIndeterminate] - If `true`, the switch will render in an indeterminate state.
|
|
88
|
-
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
89
|
-
*
|
|
90
|
-
* @returns {JSX.Element} The Switch component.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* const [checked, setChecked] = useState(false);
|
|
94
|
-
*
|
|
95
|
-
* <Switch
|
|
96
|
-
* checked={checked}
|
|
97
|
-
* onChange={() => setChecked(!checked)}
|
|
98
|
-
* />
|
|
99
|
-
*
|
|
100
|
-
* @preserve
|
|
101
|
-
*/
|
|
102
|
-
const Switch2 = (props) => {
|
|
103
|
-
const { checked, onChange, disabled, id, children, className, isIndeterminate, hidden } = props;
|
|
104
|
-
if (hidden) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
return /* @__PURE__ */ jsxs(
|
|
108
|
-
$8e59e948500a8fe1$export$b5d5cf8927ab7262,
|
|
109
|
-
{
|
|
110
|
-
id,
|
|
111
|
-
isDisabled: disabled,
|
|
112
|
-
isSelected: checked ?? false,
|
|
113
|
-
onChange,
|
|
114
|
-
className: "es:group es:flex es:items-center es:justify-between es:gap-2 es:any-focus:outline-hidden",
|
|
115
|
-
children: [
|
|
116
|
-
children,
|
|
117
|
-
/* @__PURE__ */ jsx("div", { className: clsx("es:flex es:shrink-0 es:items-center es:justify-center es:min-h-6.5", className), children: /* @__PURE__ */ jsx(
|
|
118
|
-
"div",
|
|
119
|
-
{
|
|
120
|
-
className: clsx(
|
|
121
|
-
"es:shrink-0 es:group-not-disabled:cursor-pointer es:no-webkit-highlight",
|
|
122
|
-
"es:h-5 es:w-9 es:p-[0.1875rem] es:rounded-full",
|
|
123
|
-
"es:bg-radial-[circle_at_75%_50%]",
|
|
124
|
-
"es:border es:inset-ring es:inset-shadow-xs",
|
|
125
|
-
"es:transition",
|
|
126
|
-
"es:group-focus-visible:ring-2 es:group-focus-visible:ring-accent-500/50 es:group-focus-visible:border-accent-600",
|
|
127
|
-
!checked && !disabled && "es:border-secondary-400 es:inset-ring-secondary-100 es:from-white es:to-secondary-100",
|
|
128
|
-
checked && !disabled && "es:border-accent-700/75 es:inset-ring-accent-500 es:to-accent-500 es:from-accent-600 es:shadow-accent-600/30",
|
|
129
|
-
disabled && "es:cursor-default es:border-secondary-300 es:from-white es:to-secondary-50 es:inset-ring-secondary-200/30 es:inset-shadow-secondary-100",
|
|
130
|
-
!disabled && "es:shadow-xs"
|
|
131
|
-
),
|
|
132
|
-
children: /* @__PURE__ */ jsx(
|
|
133
|
-
"span",
|
|
134
|
-
{
|
|
135
|
-
className: clsx(
|
|
136
|
-
"es:block es:size-3 es:rounded-full es:border es:will-change-transform es:bg-radial",
|
|
137
|
-
"es:transition es:motion-ease-spring-snappy es:ease-[var(--motion-spring-snappy)]",
|
|
138
|
-
!checked && "es:scale-95",
|
|
139
|
-
!checked && !disabled && "es:border-secondary-500 es:from-secondary-500 es:to-secondary-600",
|
|
140
|
-
checked && "es:translate-x-4",
|
|
141
|
-
checked && !disabled && "es:border-accent-600/20 es:from-white es:to-accent-500/30 es:from-40% es:bg-white es:shadow-xs es:shadow-accent-900/60",
|
|
142
|
-
disabled && "es:border-secondary-400 es:bg-secondary-100",
|
|
143
|
-
isIndeterminate && "es:translate-x-2 es:scale-100"
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
) })
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
export {
|
|
154
|
-
Switch2 as Switch
|
|
155
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-icmbmNdI.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
|
-
* @param {boolean} [props.isIndeterminate] - If `true`, the switch will render in an indeterminate state.
|
|
19
|
-
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
20
|
-
*
|
|
21
|
-
* @returns {JSX.Element} The Toggle component.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const [checked, setChecked] = useState(false);
|
|
25
|
-
*
|
|
26
|
-
* <Toggle
|
|
27
|
-
* icon={icons.myIcon}
|
|
28
|
-
* label='My toggle'
|
|
29
|
-
* checked={checked}
|
|
30
|
-
* onChange={() => setChecked(!checked)}
|
|
31
|
-
* />
|
|
32
|
-
*
|
|
33
|
-
* @preserve
|
|
34
|
-
*/
|
|
35
|
-
const Toggle = (props) => {
|
|
36
|
-
const { checked, onChange, icon, label, subtitle, disabled, className, labelClassName, isIndeterminate, hidden } = props;
|
|
37
|
-
if (hidden) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return /* @__PURE__ */ jsx(
|
|
41
|
-
Switch,
|
|
42
|
-
{
|
|
43
|
-
checked,
|
|
44
|
-
onChange,
|
|
45
|
-
disabled,
|
|
46
|
-
className,
|
|
47
|
-
isIndeterminate,
|
|
48
|
-
children: /* @__PURE__ */ jsx(
|
|
49
|
-
RichLabel,
|
|
50
|
-
{
|
|
51
|
-
as: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
52
|
-
icon,
|
|
53
|
-
label,
|
|
54
|
-
subtitle,
|
|
55
|
-
className: labelClassName,
|
|
56
|
-
fullWidth: true
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
Toggle
|
|
64
|
-
};
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { p as $ff5963eb1fccf552$export$e08e3b67e392101e, d as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, b as $64fa3d84918910a7$export$4d86445c2cf5e3 } from "../../utils-DkCSC521.js";
|
|
3
|
-
import React__default, { createContext, forwardRef, useContext } from "react";
|
|
4
|
-
import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-CmQX3SoX.js";
|
|
5
|
-
import { $ as $701a24aa0da5b062$export$ea18c227d4417cc3 } from "../../useButton-BpOKDWEN.js";
|
|
6
|
-
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-CV5l3lf6.js";
|
|
7
|
-
import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-DwDr6ozG.js";
|
|
8
|
-
import { c as cva } from "../../index-BKGQ6jGS.js";
|
|
9
|
-
import { Tooltip } from "../tooltip/tooltip.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
|
-
isSelected,
|
|
19
|
-
isDisabled: props.isDisabled || false,
|
|
20
|
-
buttonProps: $3ef42575df84b30b$export$9d1611c77c2fe928(buttonProps, {
|
|
21
|
-
"aria-pressed": isSelected
|
|
22
|
-
})
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function $4547d1bf40011fdf$export$bc53712daae3d6e6(props, state, ref) {
|
|
26
|
-
let toggleState = {
|
|
27
|
-
isSelected: state.selectedKeys.has(props.id),
|
|
28
|
-
setSelected(isSelected2) {
|
|
29
|
-
state.setSelected(props.id, isSelected2);
|
|
30
|
-
},
|
|
31
|
-
toggle() {
|
|
32
|
-
state.toggleKey(props.id);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
let { isPressed, isSelected, isDisabled, buttonProps } = $55f54f7887471b58$export$51e84d46ca0bc451({
|
|
36
|
-
...props,
|
|
37
|
-
id: void 0,
|
|
38
|
-
isDisabled: props.isDisabled || state.isDisabled
|
|
39
|
-
}, toggleState, ref);
|
|
40
|
-
if (state.selectionMode === "single") {
|
|
41
|
-
buttonProps.role = "radio";
|
|
42
|
-
buttonProps["aria-checked"] = toggleState.isSelected;
|
|
43
|
-
delete buttonProps["aria-pressed"];
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
isPressed,
|
|
47
|
-
isSelected,
|
|
48
|
-
isDisabled,
|
|
49
|
-
buttonProps
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const $84b7d8702d4ff4a8$export$a8a71863db173133 = /* @__PURE__ */ createContext(null);
|
|
53
|
-
const $efde0372d7a700fe$export$43506d75ebd2e218 = /* @__PURE__ */ createContext({});
|
|
54
|
-
const $efde0372d7a700fe$export$d2b052e7b4be1756 = /* @__PURE__ */ forwardRef(function ToggleButton(props, ref) {
|
|
55
|
-
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $efde0372d7a700fe$export$43506d75ebd2e218);
|
|
56
|
-
let groupState = useContext($84b7d8702d4ff4a8$export$a8a71863db173133);
|
|
57
|
-
let state = $3017fa7ffdddec74$export$8042c6c013fd5226(groupState && props.id != null ? {
|
|
58
|
-
isSelected: groupState.selectedKeys.has(props.id),
|
|
59
|
-
onChange(isSelected2) {
|
|
60
|
-
groupState.setSelected(props.id, isSelected2);
|
|
61
|
-
}
|
|
62
|
-
} : props);
|
|
63
|
-
let { buttonProps, isPressed, isSelected, isDisabled } = groupState && props.id != null ? $4547d1bf40011fdf$export$bc53712daae3d6e6({
|
|
64
|
-
...props,
|
|
65
|
-
id: props.id
|
|
66
|
-
}, groupState, ref) : $55f54f7887471b58$export$51e84d46ca0bc451({
|
|
67
|
-
...props,
|
|
68
|
-
id: props.id != null ? String(props.id) : void 0
|
|
69
|
-
}, state, ref);
|
|
70
|
-
let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f(props);
|
|
71
|
-
let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456(props);
|
|
72
|
-
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
73
|
-
...props,
|
|
74
|
-
id: void 0,
|
|
75
|
-
values: {
|
|
76
|
-
isHovered,
|
|
77
|
-
isPressed,
|
|
78
|
-
isFocused,
|
|
79
|
-
isSelected: state.isSelected,
|
|
80
|
-
isFocusVisible,
|
|
81
|
-
isDisabled,
|
|
82
|
-
state
|
|
83
|
-
},
|
|
84
|
-
defaultClassName: "react-aria-ToggleButton"
|
|
85
|
-
});
|
|
86
|
-
return /* @__PURE__ */ React__default.createElement("button", {
|
|
87
|
-
...$3ef42575df84b30b$export$9d1611c77c2fe928(buttonProps, focusProps, hoverProps),
|
|
88
|
-
...renderProps,
|
|
89
|
-
ref,
|
|
90
|
-
slot: props.slot || void 0,
|
|
91
|
-
"data-focused": isFocused || void 0,
|
|
92
|
-
"data-disabled": isDisabled || void 0,
|
|
93
|
-
"data-pressed": isPressed || void 0,
|
|
94
|
-
"data-selected": isSelected || void 0,
|
|
95
|
-
"data-hovered": isHovered || void 0,
|
|
96
|
-
"data-focus-visible": isFocusVisible || void 0
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* A simple toggle button component.
|
|
101
|
-
*
|
|
102
|
-
* @component
|
|
103
|
-
* @param {Object} props - Component props.
|
|
104
|
-
* @param {JSX.Element} [props.icon] - Icon to display within the button.
|
|
105
|
-
* @param {ButtonSize} [props.size='default'] - The size of the button.
|
|
106
|
-
* @param {ButtonType} [props.type='default'] - The type of the button.
|
|
107
|
-
* @param {boolean} [props.disabled] - If `true`, the button is disabled.
|
|
108
|
-
* @param {string} [props.className] - Classes to pass to the button.
|
|
109
|
-
* @param {string} [props.tooltip] - Tooltip text to display on hover.
|
|
110
|
-
* @param {boolean} props.selected - Whether the button is selected.
|
|
111
|
-
* @param {Function} [props.onChange] - Function to run when the toggle state changes.
|
|
112
|
-
* @param {string} [props.wrapperClassName] - Classes to pass to the tooltip wrapper.
|
|
113
|
-
* @param {Object} [props.tooltipProps] - Props to pass to the tooltip.
|
|
114
|
-
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
115
|
-
*
|
|
116
|
-
* @returns {JSX.Element} The Button component.
|
|
117
|
-
*
|
|
118
|
-
* @typedef {'small' | 'default' | 'large'} ButtonSize
|
|
119
|
-
* @typedef {'default' | 'selected' | 'ghost' | 'danger'} ButtonType
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* const [selected, setSelected] = useState(false);
|
|
123
|
-
*
|
|
124
|
-
* <ToggleButton
|
|
125
|
-
* selected={selected}
|
|
126
|
-
* onChange={setSelected}
|
|
127
|
-
* icon={icons.myIcon}
|
|
128
|
-
* />
|
|
129
|
-
*
|
|
130
|
-
* <ToggleButton
|
|
131
|
-
* selected={selected}
|
|
132
|
-
* onChange={setSelected}
|
|
133
|
-
* icon={icons.myIcon}
|
|
134
|
-
* >
|
|
135
|
-
* My button
|
|
136
|
-
* </ToggleButton>
|
|
137
|
-
*
|
|
138
|
-
* @preserve
|
|
139
|
-
*/
|
|
140
|
-
const ToggleButton2 = (props) => {
|
|
141
|
-
const { children, icon, size = "default", type = "default", disabled, className, tooltip, selected, onChange, wrapperClassName, tooltipProps, hidden, ...other } = props;
|
|
142
|
-
if (hidden) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
const componentClasses = cva(
|
|
146
|
-
[
|
|
147
|
-
"es:flex es:items-center es:gap-1",
|
|
148
|
-
"es:transition es:duration-300 es:border es:text-sm",
|
|
149
|
-
"es:any-focus:outline-hidden es:focus-visible:z-10",
|
|
150
|
-
"es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
|
|
151
|
-
"es:focus-visible:border-accent-500",
|
|
152
|
-
"es:btn-group-mid:rounded-none",
|
|
153
|
-
"es:btn-group-h-start:rounded-r-none es:btn-group-v-start:rounded-b-none",
|
|
154
|
-
"es:btn-group-h-end:rounded-l-none es:btn-group-v-end:rounded-t-none",
|
|
155
|
-
"es:cursor-pointer",
|
|
156
|
-
icon && children ? "es:justify-start" : "es:justify-center",
|
|
157
|
-
className
|
|
158
|
-
],
|
|
159
|
-
{
|
|
160
|
-
variants: {
|
|
161
|
-
size: {
|
|
162
|
-
small: "es:icon:size-4.5 es:rounded-md",
|
|
163
|
-
default: "es:icon:size-5.5 es:rounded-lg",
|
|
164
|
-
large: "es:icon:size-6 es:rounded-lg"
|
|
165
|
-
},
|
|
166
|
-
type: {
|
|
167
|
-
default: ["es:bg-radial-[at_50%_125%]", "es:inset-ring es:inset-shadow-xs"],
|
|
168
|
-
ghost: ["es:border-transparent es:text-secondary-700", "es:hover:bg-secondary-100", "es:disabled:border-transparent!"]
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
compoundVariants: [
|
|
172
|
-
{
|
|
173
|
-
type: "default",
|
|
174
|
-
disabled: false,
|
|
175
|
-
selected: false,
|
|
176
|
-
class: [
|
|
177
|
-
"es:text-black",
|
|
178
|
-
"es:from-secondary-50 es:to-white",
|
|
179
|
-
"es:border-secondary-300",
|
|
180
|
-
"es:inset-ring-secondary-100",
|
|
181
|
-
"es:inset-shadow-secondary-100/50",
|
|
182
|
-
"es:shadow-xs",
|
|
183
|
-
"es:hover:inset-shadow-secondary-100 es:hover:to-secondary-100 es:hover:inset-ring-secondary-100",
|
|
184
|
-
"es:hover:text-accent-950",
|
|
185
|
-
"es:focus-visible:text-accent-950"
|
|
186
|
-
]
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
type: "default",
|
|
190
|
-
disabled: false,
|
|
191
|
-
selected: true,
|
|
192
|
-
class: [
|
|
193
|
-
"es:text-white es:accent-text-shadow",
|
|
194
|
-
"es:from-accent-500 es:to-accent-600",
|
|
195
|
-
"es:border-accent-700",
|
|
196
|
-
"es:inset-ring es:inset-ring-accent-600",
|
|
197
|
-
"es:inset-shadow-xs es:inset-shadow-accent-400/75",
|
|
198
|
-
"es:focus-visible:border-accent-700",
|
|
199
|
-
"es:focus-visible:inset-ring es:focus-visible:inset-ring-accent-600",
|
|
200
|
-
"es:focus-visible:inset-shadow-xs es:focus-visible:inset-shadow-accent-400",
|
|
201
|
-
"es:shadow-xs es:shadow-accent-600/30"
|
|
202
|
-
]
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
disabled: true,
|
|
206
|
-
class: "es:disabled:border-secondary-300 es:disabled:text-secondary-400 es:border es:shadow-none es:disabled:inset-shadow-transparent es:disabled:inset-ring-0"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
type: "ghost",
|
|
210
|
-
disabled: false,
|
|
211
|
-
selected: true,
|
|
212
|
-
class: ["es:bg-accent-600 es:text-white es:border-accent-600 es:shadow-xs es:shadow-accent-500/25", "es:hover:shadow-accent-600/50"]
|
|
213
|
-
},
|
|
214
|
-
// Sizes.
|
|
215
|
-
{
|
|
216
|
-
size: "small",
|
|
217
|
-
iconOnly: false,
|
|
218
|
-
class: "es:h-7 es:min-w-7"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
size: "small",
|
|
222
|
-
iconOnly: true,
|
|
223
|
-
class: "es:size-7"
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
size: "small",
|
|
227
|
-
hasIcon: false,
|
|
228
|
-
iconOnly: false,
|
|
229
|
-
class: "es:px-2"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
size: "small",
|
|
233
|
-
hasIcon: true,
|
|
234
|
-
iconOnly: false,
|
|
235
|
-
class: "es:px-1"
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
size: "default",
|
|
239
|
-
iconOnly: false,
|
|
240
|
-
class: "es:h-9 es:min-w-9"
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
size: "default",
|
|
244
|
-
iconOnly: true,
|
|
245
|
-
class: "es:size-9"
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
size: "default",
|
|
249
|
-
hasIcon: false,
|
|
250
|
-
iconOnly: false,
|
|
251
|
-
class: "es:px-2"
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
size: "default",
|
|
255
|
-
hasIcon: true,
|
|
256
|
-
iconOnly: false,
|
|
257
|
-
class: "es:px-1.5"
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
size: "large",
|
|
261
|
-
iconOnly: false,
|
|
262
|
-
class: "es:h-10 es:min-w-10"
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
size: "large",
|
|
266
|
-
iconOnly: true,
|
|
267
|
-
class: "es:size-10"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
size: "large",
|
|
271
|
-
hasIcon: false,
|
|
272
|
-
iconOnly: false,
|
|
273
|
-
class: "es:px-4"
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
size: "large",
|
|
277
|
-
hasIcon: true,
|
|
278
|
-
iconOnly: false,
|
|
279
|
-
class: "es:px-2"
|
|
280
|
-
}
|
|
281
|
-
],
|
|
282
|
-
defaultVariants: {
|
|
283
|
-
selected: false,
|
|
284
|
-
disabled: false
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
const component = /* @__PURE__ */ jsxs(
|
|
289
|
-
$efde0372d7a700fe$export$d2b052e7b4be1756,
|
|
290
|
-
{
|
|
291
|
-
isSelected: selected,
|
|
292
|
-
onChange,
|
|
293
|
-
isDisabled: disabled,
|
|
294
|
-
className: componentClasses({
|
|
295
|
-
disabled,
|
|
296
|
-
selected,
|
|
297
|
-
hasIcon: Boolean(icon),
|
|
298
|
-
iconOnly: Boolean(icon && !children),
|
|
299
|
-
size,
|
|
300
|
-
type
|
|
301
|
-
}),
|
|
302
|
-
...other,
|
|
303
|
-
children: [
|
|
304
|
-
icon,
|
|
305
|
-
children
|
|
306
|
-
]
|
|
307
|
-
}
|
|
308
|
-
);
|
|
309
|
-
if (!tooltip) {
|
|
310
|
-
return component;
|
|
311
|
-
}
|
|
312
|
-
return /* @__PURE__ */ jsx(
|
|
313
|
-
Tooltip,
|
|
314
|
-
{
|
|
315
|
-
text: tooltip,
|
|
316
|
-
wrapperClassName,
|
|
317
|
-
...tooltipProps,
|
|
318
|
-
children: component
|
|
319
|
-
}
|
|
320
|
-
);
|
|
321
|
-
};
|
|
322
|
-
export {
|
|
323
|
-
ToggleButton2 as ToggleButton
|
|
324
|
-
};
|