@eightshift/ui-components 5.0.0 → 5.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/dist/Button-wERNNG0T.js +185 -0
- package/dist/Collection-CKsHTyhc.js +2363 -0
- package/dist/Color-BhgbJF5x.js +2452 -0
- package/dist/ColorSwatch-Bcn6oRSg.js +64 -0
- package/dist/ComboBox-D1LPUwWP.js +1906 -0
- package/dist/Dialog-D190gMbE.js +2298 -0
- package/dist/FieldError-DeUh5Wkw.js +42 -0
- package/dist/FocusScope-C-plSxbS.js +831 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/Group-C5iZpSAM.js +48 -0
- package/dist/Heading-D-Pboe4p.js +16 -0
- package/dist/Hidden-rE6uR-lr.js +41 -0
- package/dist/Input--mF4XVE1.js +133 -0
- package/dist/Label-Fp6AwSRn.js +17 -0
- package/dist/List-CZMUbkFU.js +593 -0
- package/dist/ListBox-4oW9kh3R.js +582 -0
- package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
- package/dist/OverlayArrow-BpB9uB_I.js +637 -0
- package/dist/RSPContexts-2lR5GG9p.js +14 -0
- package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
- package/dist/Separator-B88tj5YD.js +323 -0
- package/dist/Slider-CyJzC1bp.js +853 -0
- package/dist/Text-DRpwWot2.js +16 -0
- package/dist/VisuallyHidden-DsKYcRQ_.js +48 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/assets/index.css +57 -0
- package/dist/assets/style-admin.css +5864 -0
- package/dist/assets/style-editor.css +5864 -0
- package/dist/assets/style.css +5870 -0
- package/dist/assets/wp-font-enhancements.css +8 -0
- package/dist/assets/wp-ui-enhancements.css +377 -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 +320 -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 +6979 -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 +291 -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 +579 -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 +991 -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 +704 -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-BYWrbm1z.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 +30371 -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-CFozsmNS.js +28321 -0
- package/dist/index-wl5606BX.js +44 -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-CCcyjiRP.js +46 -0
- package/dist/useButton-BOHxkGQF.js +50 -0
- package/dist/useEvent-D5o_CqDH.js +23 -0
- package/dist/useFocusRing-nMG2uzxS.js +107 -0
- package/dist/useFormReset-DlmRL87g.js +22 -0
- package/dist/useFormValidation-D0_aaK-e.js +224 -0
- package/dist/useHover-VO5tcIli.js +890 -0
- package/dist/useLabel-BKH4fVA4.js +27 -0
- package/dist/useLabels-ntF3rFY0.js +23 -0
- package/dist/useListState-Cq2Nvr-v.js +161 -0
- package/dist/useLocalizedStringFormatter-CGzwx1a0.js +121 -0
- package/dist/useNumberField-C9dmERhP.js +1207 -0
- package/dist/useNumberFormatter-MrRLgvhj.js +13 -0
- package/dist/usePress-DjNo5790.js +677 -0
- package/dist/useSingleSelectListState--r3AAhRj.js +38 -0
- package/dist/useToggle-CQaXLe-O.js +59 -0
- package/dist/useToggleState-C3DLdez5.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-B94NDG0v.js +370 -0
- package/dist/wp/wp-font-enhancements.js +1 -0
- package/dist/wp/wp-ui-enhancements.js +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
3
|
+
import "../../default-i18n-CT_oS1Fy.js";
|
|
4
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
5
|
+
import { icons } from "../../icons/icons.js";
|
|
6
|
+
import { cloneElement } from "react";
|
|
7
|
+
import "../../react-jsx-parser.min-DZCiis5V.js";
|
|
8
|
+
/**
|
|
9
|
+
* A DraggableList item.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @param {Object} props - Component props.
|
|
13
|
+
* @param {JSX.Element} [props.icon] - Icon to display in the label.
|
|
14
|
+
* @param {string} [props.label] - Label to display.
|
|
15
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
16
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
|
|
17
|
+
* @param {string} [props.textValue] - The text value of the item.
|
|
18
|
+
* @param {string} [props.className] - Classes to pass to the label.
|
|
19
|
+
*
|
|
20
|
+
* @returns {JSX.Element} The DraggableList component.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link DraggableList} for usage example.
|
|
23
|
+
*
|
|
24
|
+
* @preserve
|
|
25
|
+
*/
|
|
26
|
+
const DraggableListItem = (props) => {
|
|
27
|
+
const { children, icon, label, subtitle, className, ...rest } = props;
|
|
28
|
+
return /* @__PURE__ */ jsxs(
|
|
29
|
+
BaseControl,
|
|
30
|
+
{
|
|
31
|
+
icon,
|
|
32
|
+
label,
|
|
33
|
+
subtitle,
|
|
34
|
+
className: clsx("es:w-full", className),
|
|
35
|
+
fullWidthLabel: true,
|
|
36
|
+
inline: true,
|
|
37
|
+
...rest,
|
|
38
|
+
children: [
|
|
39
|
+
cloneElement(icons.reorderGrabberV, {
|
|
40
|
+
className: "es:opacity-0 es:transition-opacity es:group-focus-visible:opacity-100 es:text-secondary-400 es:size-4 es:group-hover:opacity-100"
|
|
41
|
+
}),
|
|
42
|
+
children
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A Draggable item handle.
|
|
49
|
+
*
|
|
50
|
+
* @component
|
|
51
|
+
* @param {Object} props - Component props.
|
|
52
|
+
* @param {string} [props.className] - Classes to pass to the handle.
|
|
53
|
+
*
|
|
54
|
+
* @returns {JSX.Element} The DraggableListItemHandle component.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* <DraggableListItemHandle />
|
|
58
|
+
*
|
|
59
|
+
* @preserve
|
|
60
|
+
*/
|
|
61
|
+
const DraggableListItemHandle = (props) => {
|
|
62
|
+
const { className, children, ...rest } = props;
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
className: className ?? 'es:relative es:h-6 es:w-2 es:cursor-pointer es:items-center es:justify-center es:self-center es:rounded es:border es:border-secondary-300 es:bg-secondary-50 es:transition es:after:absolute es:after:inset-0 es:after:m-auto es:after:h-4 es:after:w-px es:after:bg-secondary-200 es:after:transition es:after:content-[""] es:hover:border-accent-500 es:hover:bg-accent-400 es:hover:after:bg-accent-500',
|
|
67
|
+
...rest,
|
|
68
|
+
"data-movable-handle": true,
|
|
69
|
+
tabIndex: -1,
|
|
70
|
+
children
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
DraggableListItem,
|
|
76
|
+
DraggableListItemHandle
|
|
77
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
|
|
4
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
5
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
6
|
+
import { L as List, a as arrayRemove, b as arrayMove } from "../../List-CZMUbkFU.js";
|
|
7
|
+
const fixIds = (items, itemIdBase) => {
|
|
8
|
+
return items == null ? void 0 : items.map((item, i) => ({
|
|
9
|
+
...item,
|
|
10
|
+
id: (item == null ? void 0 : item.id) ?? `${itemIdBase}-${i}`
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A component that allows re-ordering a list of items.
|
|
15
|
+
*
|
|
16
|
+
* @component
|
|
17
|
+
* @param {Object} props - Component props.
|
|
18
|
+
* @param {JSX.Element} [props.icon] - Icon to display in the label.
|
|
19
|
+
* @param {string} [props.label] - Label to display.
|
|
20
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
21
|
+
* @param {string} [props.help] - Help text to display below the input.
|
|
22
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
|
|
23
|
+
* @param {Object<string, any>[]} props.items - Data to display in the list.
|
|
24
|
+
* @param {Function} props.onChange - Function to run when the items change.
|
|
25
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
26
|
+
* @param {boolean} [props.disabled] - If `true`, item reordering is disabled.
|
|
27
|
+
* @param {string} [props.className] - Classes to pass to the item wrapper.
|
|
28
|
+
*
|
|
29
|
+
* @returns {JSX.Element} The DraggableList component.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <DraggableList
|
|
33
|
+
* label='My draggable list'
|
|
34
|
+
* items={items}
|
|
35
|
+
* onChange={setItems}
|
|
36
|
+
* >
|
|
37
|
+
* {(item) => {
|
|
38
|
+
* const { title, updateData } = item;
|
|
39
|
+
*
|
|
40
|
+
* return (
|
|
41
|
+
* <DraggableListItem
|
|
42
|
+
* label={title ?? 'New item'}
|
|
43
|
+
* icon={icons.myIcon}
|
|
44
|
+
* >
|
|
45
|
+
* <InputField
|
|
46
|
+
* label='Title'
|
|
47
|
+
* type='text'
|
|
48
|
+
* value={title}
|
|
49
|
+
* onChange={(value) => updateData({ title: value })}
|
|
50
|
+
* />
|
|
51
|
+
* </DraggableListItem>
|
|
52
|
+
* );
|
|
53
|
+
* }}
|
|
54
|
+
* </DraggableList>
|
|
55
|
+
*
|
|
56
|
+
* @preserve
|
|
57
|
+
*/
|
|
58
|
+
const DraggableList = (props) => {
|
|
59
|
+
const itemIdBase = useId("draggable-list-item-");
|
|
60
|
+
const {
|
|
61
|
+
children,
|
|
62
|
+
items: rawItems,
|
|
63
|
+
onChange,
|
|
64
|
+
icon,
|
|
65
|
+
label,
|
|
66
|
+
subtitle,
|
|
67
|
+
help,
|
|
68
|
+
actions,
|
|
69
|
+
disabled,
|
|
70
|
+
className,
|
|
71
|
+
labelAsHandle,
|
|
72
|
+
hidden,
|
|
73
|
+
...rest
|
|
74
|
+
} = props;
|
|
75
|
+
if (typeof rawItems === "undefined" || rawItems === null || !Array.isArray(rawItems)) {
|
|
76
|
+
console.warn(__("DraggableList: 'items' are not an array or are undefined!", "eightshift-ui-components"));
|
|
77
|
+
}
|
|
78
|
+
const items = fixIds(rawItems ?? [], itemIdBase);
|
|
79
|
+
if (hidden) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
|
+
BaseControl,
|
|
84
|
+
{
|
|
85
|
+
icon,
|
|
86
|
+
label,
|
|
87
|
+
subtitle,
|
|
88
|
+
help,
|
|
89
|
+
actions,
|
|
90
|
+
className: "es:w-full",
|
|
91
|
+
...rest,
|
|
92
|
+
children: /* @__PURE__ */ jsx(
|
|
93
|
+
List,
|
|
94
|
+
{
|
|
95
|
+
values: items,
|
|
96
|
+
onChange: ({ oldIndex, newIndex }) => onChange(newIndex === -1 ? arrayRemove(items, oldIndex) : arrayMove(items, oldIndex, newIndex)),
|
|
97
|
+
renderList: ({ children: children2, props: props2 }) => {
|
|
98
|
+
const { key, ...rest2 } = props2;
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
"ul",
|
|
101
|
+
{
|
|
102
|
+
className: "es:w-full es:list-none",
|
|
103
|
+
...rest2,
|
|
104
|
+
children: children2
|
|
105
|
+
},
|
|
106
|
+
key
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
renderItem: ({ value, index, isDisabled, isDragged, isSelected, isOutOfBounds, props: props2 }) => {
|
|
110
|
+
const { key, ...rest2 } = props2;
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
"li",
|
|
113
|
+
{
|
|
114
|
+
className: clsx(
|
|
115
|
+
"es:group",
|
|
116
|
+
"es:min-h-8 es:w-full",
|
|
117
|
+
"es:flex es:items-center es:gap-1 es:rounded-lg",
|
|
118
|
+
"es:transition-[box-shadow,background-color,filter,opacity,border-color]",
|
|
119
|
+
"es:border es:border-transparent",
|
|
120
|
+
"es:any-focus:outline-hidden es:focus:ring-2 es:focus:ring-accent-500/50 es:focus:border-accent-500",
|
|
121
|
+
isDisabled && "es:grayscale",
|
|
122
|
+
isDragged && "es:bg-white es:opacity-50",
|
|
123
|
+
isSelected && "es:bg-accent-50",
|
|
124
|
+
isDragged ? "es:cursor-grabbing" : "es:cursor-grab"
|
|
125
|
+
),
|
|
126
|
+
...rest2,
|
|
127
|
+
children: children({
|
|
128
|
+
...value,
|
|
129
|
+
updateData: (newValue) => {
|
|
130
|
+
onChange(items.map((i) => i.id === value.id ? { ...i, ...newValue } : i));
|
|
131
|
+
},
|
|
132
|
+
itemIndex: index,
|
|
133
|
+
deleteItem: () => {
|
|
134
|
+
onChange(items.filter((i) => i.id !== value.id));
|
|
135
|
+
if (value.onAfterItemRemove) {
|
|
136
|
+
onAfterItemRemove(value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
},
|
|
141
|
+
(value == null ? void 0 : value.id) ?? key
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
DraggableList
|
|
151
|
+
};
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import React__default, { useRef, useCallback, useEffect, forwardRef, createContext, useContext } from "react";
|
|
3
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
4
|
+
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
6
|
+
import { icons } from "../../icons/icons.js";
|
|
7
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
8
|
+
import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
|
|
9
|
+
import { a as $d2b4bc8c273e7be6$export$24d547caef80ccd1 } from "../../Button-wERNNG0T.js";
|
|
10
|
+
import { e as $bdb11010cef70236$export$f680877a34711e37, n as $b5e257d569688ac6$export$535bd6ca7f90a273, k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, a as $64fa3d84918910a7$export$29f1550f4b0d4415, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a, o as $64fa3d84918910a7$export$c62b8e45d58ddad9, d as $3ef42575df84b30b$export$9d1611c77c2fe928, m as $5dc95899b306f630$export$c9058316764c140e } from "../../utils-B94NDG0v.js";
|
|
11
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
|
|
12
|
+
import { b as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "../../useHover-VO5tcIli.js";
|
|
13
|
+
import { r as reactDomExports } from "../../index-CFozsmNS.js";
|
|
14
|
+
import { $ as $e9faafb641e167db$export$90fc3a17d93f704c } from "../../useEvent-D5o_CqDH.js";
|
|
15
|
+
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-nMG2uzxS.js";
|
|
16
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-Fp6AwSRn.js";
|
|
17
|
+
function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
18
|
+
let { isDisabled } = props;
|
|
19
|
+
let triggerId = $bdb11010cef70236$export$f680877a34711e37();
|
|
20
|
+
let panelId = $bdb11010cef70236$export$f680877a34711e37();
|
|
21
|
+
let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
|
|
22
|
+
let supportsBeforeMatch = !isSSR && "onbeforematch" in document.body;
|
|
23
|
+
let raf = useRef(null);
|
|
24
|
+
let handleBeforeMatch = useCallback(() => {
|
|
25
|
+
raf.current = requestAnimationFrame(() => {
|
|
26
|
+
if (ref.current) ref.current.setAttribute("hidden", "until-found");
|
|
27
|
+
});
|
|
28
|
+
reactDomExports.flushSync(() => {
|
|
29
|
+
state.toggle();
|
|
30
|
+
});
|
|
31
|
+
}, [
|
|
32
|
+
ref,
|
|
33
|
+
state
|
|
34
|
+
]);
|
|
35
|
+
$e9faafb641e167db$export$90fc3a17d93f704c(ref, "beforematch", supportsBeforeMatch ? handleBeforeMatch : null);
|
|
36
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
|
37
|
+
if (raf.current) cancelAnimationFrame(raf.current);
|
|
38
|
+
if (supportsBeforeMatch && ref.current && !isDisabled) {
|
|
39
|
+
if (state.isExpanded) ref.current.removeAttribute("hidden");
|
|
40
|
+
else ref.current.setAttribute("hidden", "until-found");
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
isDisabled,
|
|
44
|
+
ref,
|
|
45
|
+
state.isExpanded,
|
|
46
|
+
supportsBeforeMatch
|
|
47
|
+
]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
return () => {
|
|
50
|
+
if (raf.current) cancelAnimationFrame(raf.current);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
return {
|
|
54
|
+
buttonProps: {
|
|
55
|
+
id: triggerId,
|
|
56
|
+
"aria-expanded": state.isExpanded,
|
|
57
|
+
"aria-controls": panelId,
|
|
58
|
+
onPress: (e) => {
|
|
59
|
+
if (!isDisabled && e.pointerType !== "keyboard") state.toggle();
|
|
60
|
+
},
|
|
61
|
+
isDisabled,
|
|
62
|
+
onPressStart(e) {
|
|
63
|
+
if (e.pointerType === "keyboard" && !isDisabled) state.toggle();
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
panelProps: {
|
|
67
|
+
id: panelId,
|
|
68
|
+
// This can be overridden at the panel element level.
|
|
69
|
+
role: "group",
|
|
70
|
+
"aria-labelledby": triggerId,
|
|
71
|
+
"aria-hidden": !state.isExpanded,
|
|
72
|
+
hidden: supportsBeforeMatch ? true : !state.isExpanded
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function $bf996d45f4a36925$export$3fcbf6e4407997e0(props) {
|
|
77
|
+
let [isExpanded, setExpanded] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(props.isExpanded, props.defaultExpanded || false, props.onExpandedChange);
|
|
78
|
+
const expand = useCallback(() => {
|
|
79
|
+
setExpanded(true);
|
|
80
|
+
}, [
|
|
81
|
+
setExpanded
|
|
82
|
+
]);
|
|
83
|
+
const collapse = useCallback(() => {
|
|
84
|
+
setExpanded(false);
|
|
85
|
+
}, [
|
|
86
|
+
setExpanded
|
|
87
|
+
]);
|
|
88
|
+
const toggle = useCallback(() => {
|
|
89
|
+
setExpanded(!isExpanded);
|
|
90
|
+
}, [
|
|
91
|
+
setExpanded,
|
|
92
|
+
isExpanded
|
|
93
|
+
]);
|
|
94
|
+
return {
|
|
95
|
+
isExpanded,
|
|
96
|
+
setExpanded,
|
|
97
|
+
expand,
|
|
98
|
+
collapse,
|
|
99
|
+
toggle
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const $28f4fd908f0de97f$export$1d40e3e0cc4d5de = /* @__PURE__ */ createContext(null);
|
|
103
|
+
const $28f4fd908f0de97f$export$d665dd135a51b28a = /* @__PURE__ */ createContext(null);
|
|
104
|
+
const $28f4fd908f0de97f$export$dab3ea4a6ef094da = /* @__PURE__ */ createContext(null);
|
|
105
|
+
const $28f4fd908f0de97f$var$InternalDisclosureContext = /* @__PURE__ */ createContext(null);
|
|
106
|
+
const $28f4fd908f0de97f$export$74a362b31437ec83 = /* @__PURE__ */ forwardRef(function Disclosure(props, ref) {
|
|
107
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $28f4fd908f0de97f$export$d665dd135a51b28a);
|
|
108
|
+
let groupState = useContext($28f4fd908f0de97f$export$1d40e3e0cc4d5de);
|
|
109
|
+
let { id, ...otherProps } = props;
|
|
110
|
+
let defaultId = $bdb11010cef70236$export$f680877a34711e37();
|
|
111
|
+
id || (id = defaultId);
|
|
112
|
+
let isExpanded = groupState ? groupState.expandedKeys.has(id) : props.isExpanded;
|
|
113
|
+
let state = $bf996d45f4a36925$export$3fcbf6e4407997e0({
|
|
114
|
+
...props,
|
|
115
|
+
isExpanded,
|
|
116
|
+
onExpandedChange(isExpanded2) {
|
|
117
|
+
var _props_onExpandedChange;
|
|
118
|
+
if (groupState) groupState.toggleKey(id);
|
|
119
|
+
(_props_onExpandedChange = props.onExpandedChange) === null || _props_onExpandedChange === void 0 ? void 0 : _props_onExpandedChange.call(props, isExpanded2);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
let panelRef = React__default.useRef(null);
|
|
123
|
+
let isDisabled = props.isDisabled || (groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled) || false;
|
|
124
|
+
let { buttonProps, panelProps } = $5e910fae8e128ead$export$6e3e27031a30522f({
|
|
125
|
+
...props,
|
|
126
|
+
isExpanded,
|
|
127
|
+
isDisabled
|
|
128
|
+
}, state, panelRef);
|
|
129
|
+
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = $f7dceffc5ad7768b$export$4e328f61c538687f({
|
|
130
|
+
within: true
|
|
131
|
+
});
|
|
132
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
133
|
+
...props,
|
|
134
|
+
id: void 0,
|
|
135
|
+
defaultClassName: "react-aria-Disclosure",
|
|
136
|
+
values: {
|
|
137
|
+
isExpanded: state.isExpanded,
|
|
138
|
+
isDisabled,
|
|
139
|
+
isFocusVisibleWithin,
|
|
140
|
+
state
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(otherProps);
|
|
144
|
+
return /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
145
|
+
values: [
|
|
146
|
+
[
|
|
147
|
+
$d2b4bc8c273e7be6$export$24d547caef80ccd1,
|
|
148
|
+
{
|
|
149
|
+
slots: {
|
|
150
|
+
[$64fa3d84918910a7$export$c62b8e45d58ddad9]: {},
|
|
151
|
+
trigger: buttonProps
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
$28f4fd908f0de97f$var$InternalDisclosureContext,
|
|
157
|
+
{
|
|
158
|
+
panelProps,
|
|
159
|
+
panelRef
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
$28f4fd908f0de97f$export$dab3ea4a6ef094da,
|
|
164
|
+
state
|
|
165
|
+
]
|
|
166
|
+
]
|
|
167
|
+
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
168
|
+
ref,
|
|
169
|
+
"data-expanded": state.isExpanded || void 0,
|
|
170
|
+
"data-disabled": isDisabled || void 0,
|
|
171
|
+
"data-focus-visible-within": isFocusVisibleWithin || void 0,
|
|
172
|
+
...domProps,
|
|
173
|
+
...focusWithinProps,
|
|
174
|
+
...renderProps
|
|
175
|
+
}, renderProps.children));
|
|
176
|
+
});
|
|
177
|
+
const $28f4fd908f0de97f$export$feabaa331e1d464c = /* @__PURE__ */ forwardRef(function DisclosurePanel(props, ref) {
|
|
178
|
+
let { role = "group" } = props;
|
|
179
|
+
let { panelProps, panelRef } = useContext($28f4fd908f0de97f$var$InternalDisclosureContext);
|
|
180
|
+
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = $f7dceffc5ad7768b$export$4e328f61c538687f({
|
|
181
|
+
within: true
|
|
182
|
+
});
|
|
183
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
184
|
+
...props,
|
|
185
|
+
defaultClassName: "react-aria-DisclosurePanel",
|
|
186
|
+
values: {
|
|
187
|
+
isFocusVisibleWithin
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
191
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
192
|
+
...DOMProps,
|
|
193
|
+
ref: $5dc95899b306f630$export$c9058316764c140e(ref, panelRef),
|
|
194
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(panelProps, focusWithinProps),
|
|
195
|
+
...renderProps,
|
|
196
|
+
role,
|
|
197
|
+
"data-focus-visible-within": isFocusVisibleWithin || void 0
|
|
198
|
+
}, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
199
|
+
values: [
|
|
200
|
+
[
|
|
201
|
+
$d2b4bc8c273e7be6$export$24d547caef80ccd1,
|
|
202
|
+
null
|
|
203
|
+
]
|
|
204
|
+
]
|
|
205
|
+
}, props.children));
|
|
206
|
+
});
|
|
207
|
+
/**
|
|
208
|
+
* A component that allows hiding content in an expandable panel, to declutter the UI.
|
|
209
|
+
*
|
|
210
|
+
* @component
|
|
211
|
+
* @param {Object} props - Component props.
|
|
212
|
+
* @param {JSX.Element} [props.icon] - Icon to display in the label.
|
|
213
|
+
* @param {string} props.label - Label to display.
|
|
214
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
215
|
+
* @param {string} [props.className] - Classes to pass to the container.
|
|
216
|
+
* @param {string} [props.contentClassName] - Classes to pass to the inner content wrapper.
|
|
217
|
+
* @param {string} [props.labelClassName] - Classes to pass to the label.
|
|
218
|
+
* @param {string} [props.headerClassName] - Classes to pass to the header (label + trigger).
|
|
219
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display in the panel header, left of the expand button.
|
|
220
|
+
* @param {boolean} [props.keepActionsOnExpand=false] - If `true`, the actions are not hidden when the panel is expanded.
|
|
221
|
+
* @param {boolean} [props.disabled] - If `true`, the expand button is disabled.
|
|
222
|
+
* @param {boolean} [props.open] - Whether the expandable is open.
|
|
223
|
+
* @param {Function} [props.onOpenChange] - Function is called when the panel is opened or closed.
|
|
224
|
+
* @param {object} [props.headerProps] - Props to pass to the header (label + trigger).
|
|
225
|
+
* @param {JSX.Element} [props.customOpenButton] - Allows adding a custom open button. **IMPORTANT**: make sure to set `slot='trigger'` on the passed element!
|
|
226
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
227
|
+
*
|
|
228
|
+
* @returns {JSX.Element} The Expandable component.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* <Expandable label='My component'>
|
|
232
|
+
* ...
|
|
233
|
+
* </Expandable>
|
|
234
|
+
*
|
|
235
|
+
* @preserve
|
|
236
|
+
*/
|
|
237
|
+
const Expandable = (props) => {
|
|
238
|
+
const {
|
|
239
|
+
icon,
|
|
240
|
+
label,
|
|
241
|
+
subtitle,
|
|
242
|
+
className,
|
|
243
|
+
labelClassName,
|
|
244
|
+
contentClassName,
|
|
245
|
+
headerClassName,
|
|
246
|
+
actions,
|
|
247
|
+
keepActionsOnExpand = false,
|
|
248
|
+
disabled,
|
|
249
|
+
noFocusHandling,
|
|
250
|
+
children,
|
|
251
|
+
open = false,
|
|
252
|
+
onOpenChange,
|
|
253
|
+
customOpenButton,
|
|
254
|
+
headerProps,
|
|
255
|
+
hidden,
|
|
256
|
+
...other
|
|
257
|
+
} = props;
|
|
258
|
+
const [isOpen, setIsOpen] = React__default.useState(open);
|
|
259
|
+
if (isOpen && disabled) {
|
|
260
|
+
setIsOpen(false);
|
|
261
|
+
}
|
|
262
|
+
if (hidden) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return /* @__PURE__ */ jsxs(
|
|
266
|
+
$28f4fd908f0de97f$export$74a362b31437ec83,
|
|
267
|
+
{
|
|
268
|
+
isExpanded: isOpen,
|
|
269
|
+
className: clsx("es:w-full es:rounded-xl es:border es:border-secondary-300/0 es:text-sm es:transition", isOpen && "es:border-secondary-300/100 es:shadow-lg", className),
|
|
270
|
+
...other,
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsxs("div", { className: clsx("es:flex es:h-10 es:items-center es:gap-1 es:transition-[padding]", isOpen && "es:py-1 es:pl-2 es:pr-1", headerClassName), children: [
|
|
273
|
+
/* @__PURE__ */ jsx(
|
|
274
|
+
RichLabel,
|
|
275
|
+
{
|
|
276
|
+
icon,
|
|
277
|
+
label,
|
|
278
|
+
subtitle,
|
|
279
|
+
className: labelClassName,
|
|
280
|
+
as: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
281
|
+
fullWidth: true
|
|
282
|
+
}
|
|
283
|
+
),
|
|
284
|
+
actions && !keepActionsOnExpand && /* @__PURE__ */ jsx(
|
|
285
|
+
AnimatedVisibility,
|
|
286
|
+
{
|
|
287
|
+
visible: !isOpen,
|
|
288
|
+
className: "es:ml-auto es:flex es:gap-2",
|
|
289
|
+
transition: "slideFadeDownSlight",
|
|
290
|
+
noInitial: true,
|
|
291
|
+
children: actions
|
|
292
|
+
}
|
|
293
|
+
),
|
|
294
|
+
actions && keepActionsOnExpand && /* @__PURE__ */ jsx("div", { className: "es:ml-auto es:flex es:gap-2", children: actions }),
|
|
295
|
+
customOpenButton && customOpenButton({
|
|
296
|
+
open: isOpen,
|
|
297
|
+
toggleOpen: () => {
|
|
298
|
+
setIsOpen(!isOpen);
|
|
299
|
+
if (onOpenChange) {
|
|
300
|
+
onOpenChange(!isOpen);
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
tooltip: isOpen ? __("Close", "eightshift-ui-components") : __("Open", "eightshift-ui-components"),
|
|
304
|
+
disabled
|
|
305
|
+
}),
|
|
306
|
+
!customOpenButton && /* @__PURE__ */ jsx(
|
|
307
|
+
Button,
|
|
308
|
+
{
|
|
309
|
+
slot: "trigger",
|
|
310
|
+
type: "ghost",
|
|
311
|
+
icon: isOpen ? icons.caretDownFill : icons.caretDown,
|
|
312
|
+
onPress: () => {
|
|
313
|
+
setIsOpen(!isOpen);
|
|
314
|
+
if (onOpenChange) {
|
|
315
|
+
onOpenChange(!isOpen);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
tooltip: isOpen ? __("Close", "eightshift-ui-components") : __("Open", "eightshift-ui-components"),
|
|
319
|
+
disabled,
|
|
320
|
+
className: clsx("es:icon:size-5 es:icon:transition-transform", isOpen && "es:icon:-scale-y-100"),
|
|
321
|
+
size: "small"
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] }),
|
|
325
|
+
/* @__PURE__ */ jsx(
|
|
326
|
+
$28f4fd908f0de97f$export$feabaa331e1d464c,
|
|
327
|
+
{
|
|
328
|
+
className: clsx(
|
|
329
|
+
isOpen && "es:space-y-2.5 es:border-t es:border-t-secondary-200 es:p-2",
|
|
330
|
+
isOpen && "es:motion-safe:motion-preset-slide-down-sm es:motion-safe:motion-ease-spring-smooth es:motion-safe:motion-ease-linear/opacity es:motion-safe:motion-duration-300 es:motion-reduce:motion-preset-fade-md",
|
|
331
|
+
contentClassName
|
|
332
|
+
),
|
|
333
|
+
children
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
};
|
|
340
|
+
export {
|
|
341
|
+
Expandable
|
|
342
|
+
};
|