@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,297 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { _ as __ } from "../../../default-i18n-CT_oS1Fy.js";
|
|
3
|
+
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-wERNNG0T.js";
|
|
4
|
+
import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66, a as $d01f2c01039c0eec$export$72b9695b8216309a, b as $d01f2c01039c0eec$export$c02625b26074192c } from "../../../ComboBox-D1LPUwWP.js";
|
|
5
|
+
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Input--mF4XVE1.js";
|
|
6
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-Fp6AwSRn.js";
|
|
7
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-4oW9kh3R.js";
|
|
8
|
+
import { $ as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-D190gMbE.js";
|
|
9
|
+
import { $ as $514c0188e459b4c0$export$5f1af8db9871e1d6 } from "../../../Text-DRpwWot2.js";
|
|
10
|
+
import { OptionItemBase } from "./shared.js";
|
|
11
|
+
import { RichLabel } from "../../rich-label/rich-label.js";
|
|
12
|
+
import { BaseControl } from "../../base-control/base-control.js";
|
|
13
|
+
import { useEffect, useRef, cloneElement, useContext } from "react";
|
|
14
|
+
import { icons } from "../../../icons/icons.js";
|
|
15
|
+
import "../../../react-jsx-parser.min-DZCiis5V.js";
|
|
16
|
+
import { unescapeHTML } from "../../../utilities/text-helpers.js";
|
|
17
|
+
import { c as clsx } from "../../../utils-B94NDG0v.js";
|
|
18
|
+
/**
|
|
19
|
+
* Select menu with async loading.
|
|
20
|
+
*
|
|
21
|
+
* @component
|
|
22
|
+
* @param {Object} props - Component props.
|
|
23
|
+
* @param {string} [props.label] - Label of the component.
|
|
24
|
+
* @param {string} [props.help] - Help text of the component.
|
|
25
|
+
* @param {string} [props.icon] - Icon of the component.
|
|
26
|
+
* @param {string} [props.subtitle] - Subtitle of the component.
|
|
27
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
|
|
28
|
+
* @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
|
|
29
|
+
* @param {{label: string, value: string, metadata: Object<string, any>?}} props.value - Current value of the select.
|
|
30
|
+
* @param {Function} props.onChange - Function to call when the value changes.
|
|
31
|
+
* @param {boolean} [props.clearable=false] - Whether the select is clearable.
|
|
32
|
+
* @param {boolean} [props.noSearch=false] - Whether the search is disabled.
|
|
33
|
+
* @param {boolean} [props.disabled=false] - Whether the select is disabled.
|
|
34
|
+
* @param {boolean} [props.keepMenuOpenAfterSelect=false] - Whether the menu stays open after an select.
|
|
35
|
+
* @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
|
|
36
|
+
* @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu. `({ value: string, label: string, subtitle: string, metadata: any }) => JSX.Element`
|
|
37
|
+
* @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item. `({ value: string, label: string, subtitle: string, metadata: any }) => JSX.Element`
|
|
38
|
+
* @param {Function} [props.processLoadedOptions] - Allows modifying (filtering, grouping, ...) options output after the items have been dynamically fetched. Must include `label`, `value`, and `id` keys in the output, additional fields can be added as required.
|
|
39
|
+
* @param {string} props.className - Classes to pass to the select menu.
|
|
40
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
41
|
+
*
|
|
42
|
+
* @returns {JSX.Element} The __ExperimentalAsyncSelect component.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const [value, setValue] = useState(null);
|
|
46
|
+
*
|
|
47
|
+
* <__ExperimentalAsyncSelect
|
|
48
|
+
* label='Select items'
|
|
49
|
+
* fetchUrl={(searchText) => `https://api.example.com/items?q=${searchText}`}
|
|
50
|
+
* value={value}
|
|
51
|
+
* onChange={setValue}
|
|
52
|
+
* getLabel={(item) => item?.name}
|
|
53
|
+
* getValue={(item) => item?.id}
|
|
54
|
+
* />
|
|
55
|
+
*
|
|
56
|
+
* @preserve
|
|
57
|
+
*/
|
|
58
|
+
const __ExperimentalAsyncSelect = (props) => {
|
|
59
|
+
const {
|
|
60
|
+
label,
|
|
61
|
+
help,
|
|
62
|
+
icon,
|
|
63
|
+
subtitle,
|
|
64
|
+
actions,
|
|
65
|
+
inline,
|
|
66
|
+
value,
|
|
67
|
+
onChange,
|
|
68
|
+
noSearch = false,
|
|
69
|
+
disabled = false,
|
|
70
|
+
clearable = false,
|
|
71
|
+
className,
|
|
72
|
+
placeholder,
|
|
73
|
+
customMenuOption,
|
|
74
|
+
customValueDisplay,
|
|
75
|
+
processLoadedOptions = (options) => options,
|
|
76
|
+
fetchUrl,
|
|
77
|
+
fetchConfig = {},
|
|
78
|
+
getLabel,
|
|
79
|
+
getValue,
|
|
80
|
+
getMeta,
|
|
81
|
+
getIcon,
|
|
82
|
+
getSubtitle,
|
|
83
|
+
getData = (data) => data,
|
|
84
|
+
hidden,
|
|
85
|
+
...rest
|
|
86
|
+
} = props;
|
|
87
|
+
let list = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
88
|
+
// initialFilterText: value?.label,
|
|
89
|
+
async load({ signal, filterText: rawFilterText }) {
|
|
90
|
+
let filterText = rawFilterText.trim();
|
|
91
|
+
const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
|
|
92
|
+
const json = getData(await res.json());
|
|
93
|
+
const output = json == null ? void 0 : json.map((item) => {
|
|
94
|
+
const id = getValue(item);
|
|
95
|
+
const entry = { label: unescapeHTML(getLabel(item)), value: id };
|
|
96
|
+
if (getMeta) {
|
|
97
|
+
entry.meta = getMeta(item);
|
|
98
|
+
}
|
|
99
|
+
if (getSubtitle) {
|
|
100
|
+
entry.subtitle = unescapeHTML(getSubtitle(item));
|
|
101
|
+
}
|
|
102
|
+
return entry;
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
items: output
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
let listItems = [...list.items];
|
|
110
|
+
if (value == null ? void 0 : value.value) {
|
|
111
|
+
const selectedIndex = listItems.findIndex((item) => item.value === (value == null ? void 0 : value.value));
|
|
112
|
+
if (selectedIndex === -1) {
|
|
113
|
+
listItems = [{ ...value }, ...listItems];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (list.filterText !== (value == null ? void 0 : value.label)) {
|
|
118
|
+
list.setFilterText(value == null ? void 0 : value.label);
|
|
119
|
+
}
|
|
120
|
+
if (!value && list.filterText) {
|
|
121
|
+
list.setFilterText("");
|
|
122
|
+
}
|
|
123
|
+
}, [value]);
|
|
124
|
+
const ref = useRef();
|
|
125
|
+
if (hidden) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsxs(
|
|
129
|
+
$d01f2c01039c0eec$export$72b9695b8216309a,
|
|
130
|
+
{
|
|
131
|
+
onSelectionChange: (selected) => {
|
|
132
|
+
if (selected === null || selected === void 0) {
|
|
133
|
+
onChange(null);
|
|
134
|
+
list.setFilterText("");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (selected === (value == null ? void 0 : value.value) || list.filterText === (value == null ? void 0 : value.label)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const item = (list == null ? void 0 : list.getItem(selected)) ?? listItems.find((item2) => item2.value === selected);
|
|
141
|
+
if (!item) {
|
|
142
|
+
onChange(null);
|
|
143
|
+
list.setFilterText("");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
list.setFilterText(item.label);
|
|
147
|
+
onChange(item);
|
|
148
|
+
},
|
|
149
|
+
allowsCustomValue: false,
|
|
150
|
+
allowsEmptyCollection: true,
|
|
151
|
+
selectedKey: (value == null ? void 0 : value.value) ?? null,
|
|
152
|
+
inputValue: list.filterText,
|
|
153
|
+
onInputChange: list.setFilterText,
|
|
154
|
+
items: listItems,
|
|
155
|
+
isDisabled: disabled,
|
|
156
|
+
menuTrigger: "focus",
|
|
157
|
+
...rest,
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ jsx(
|
|
160
|
+
BaseControl,
|
|
161
|
+
{
|
|
162
|
+
icon,
|
|
163
|
+
label,
|
|
164
|
+
subtitle,
|
|
165
|
+
help,
|
|
166
|
+
actions,
|
|
167
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
168
|
+
inline,
|
|
169
|
+
children: /* @__PURE__ */ jsxs(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: clsx(
|
|
173
|
+
"es:relative es:flex es:max-w-80 es:items-center es:gap-1 es:p-1 es:focus-visible:outline-hidden es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
|
|
174
|
+
"es:h-9 es:rounded-lg es:border es:border-secondary-300 es:bg-white es:text-sm es:shadow-xs es:transition",
|
|
175
|
+
"es:any-focus:outline-hidden",
|
|
176
|
+
!inline && "es:w-full",
|
|
177
|
+
disabled && "es:select-none",
|
|
178
|
+
"es:has-[[aria-haspopup=listbox][data-focus-visible=true],[aria-autocomplete=list][data-focus-visible=true]]:border-accent-500 es:has-[[aria-haspopup=listbox][data-focus-visible=true],[aria-autocomplete=list][data-focus-visible=true]]:ring-2 es:has-[[aria-haspopup=listbox][data-focus-visible=true],[aria-autocomplete=list][data-focus-visible=true]]:ring-accent-500/50"
|
|
179
|
+
),
|
|
180
|
+
ref,
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
184
|
+
{
|
|
185
|
+
className: clsx(
|
|
186
|
+
"es:peer es:h-6 es:w-full es:grow es:rounded-sm es:p-1 es:pr-6 es:text-sm es:text-transparent es:transition",
|
|
187
|
+
"es:focus:text-current es:any-focus:outline-hidden",
|
|
188
|
+
"es:selection:bg-accent-500/20 es:selection:text-accent-950",
|
|
189
|
+
disabled && "es:bg-transparent es:text-secondary-400 es:selection:bg-transparent es:selection:text-transparent"
|
|
190
|
+
),
|
|
191
|
+
placeholder: placeholder ?? __("Select...", "eightshift-ui-components")
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
value && /* @__PURE__ */ jsxs(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
className: clsx(
|
|
198
|
+
"es:pointer-events-none es:absolute es:bottom-0 es:left-2 es:top-0 es:my-auto es:flex es:select-none es:items-center es:overflow-hidden",
|
|
199
|
+
"es:has-[svg]:left-1 es:peer-data-[focused=true]:invisible es:peer-disabled:opacity-40",
|
|
200
|
+
clearable ? "es:right-16" : "es:right-6"
|
|
201
|
+
),
|
|
202
|
+
children: [
|
|
203
|
+
customValueDisplay && customValueDisplay(value),
|
|
204
|
+
!customValueDisplay && /* @__PURE__ */ jsx(
|
|
205
|
+
RichLabel,
|
|
206
|
+
{
|
|
207
|
+
icon: getIcon(value),
|
|
208
|
+
label: value == null ? void 0 : value.label,
|
|
209
|
+
subtitle: value == null ? void 0 : value.subtitle,
|
|
210
|
+
className: "es:[&_span]:overflow-hidden es:[&_span]:text-ellipsis es:[&_span]:text-nowrap"
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
clearable && /* @__PURE__ */ jsx(ClearButton, { disabled }),
|
|
217
|
+
/* @__PURE__ */ jsx($d2b4bc8c273e7be6$export$353f5b6fc5456de1, { className: clsx("es:group es:absolute es:bottom-0 es:right-0 es:top-0 es:my-auto es:size-6", disabled ? "es:text-secondary-300" : "es:text-secondary-500"), children: cloneElement(icons.dropdownCaretAlt, {
|
|
218
|
+
className: "es:w-4 es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200",
|
|
219
|
+
"aria-hidden": true
|
|
220
|
+
}) })
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ jsxs(
|
|
227
|
+
$07b14b47974efb58$export$5b6b19405a83ff9d,
|
|
228
|
+
{
|
|
229
|
+
className: ({ isEntering, isExiting }) => clsx(
|
|
230
|
+
"es:flex es:w-80 es:min-w-9 es:max-w-80 es:flex-col es:overflow-x-hidden es:rounded-lg es:border es:border-secondary-200 es:bg-white es:text-sm es:shadow-lg",
|
|
231
|
+
"es:any-focus:outline-hidden",
|
|
232
|
+
isEntering && "es:motion-safe:motion-preset-slide-down-sm es:motion-safe:motion-duration-300 es:motion-reduce:motion-preset-fade-md",
|
|
233
|
+
isExiting && "es:not-motion-reduce:motion-translate-y-out-[-2.5%] es:motion-opacity-out-0 es:motion-duration-200"
|
|
234
|
+
),
|
|
235
|
+
placement: "bottom left",
|
|
236
|
+
triggerRef: ref,
|
|
237
|
+
children: [
|
|
238
|
+
!list.isLoading && list.items.length > 0 && /* @__PURE__ */ jsx($eed445e0843c11d0$export$41f133550aa26f48, { className: "es:space-y-0.5 es:p-1 es:any-focus:outline-hidden", children: (item) => {
|
|
239
|
+
return /* @__PURE__ */ jsxs(
|
|
240
|
+
OptionItemBase,
|
|
241
|
+
{
|
|
242
|
+
id: item.value,
|
|
243
|
+
className: item == null ? void 0 : item.className,
|
|
244
|
+
children: [
|
|
245
|
+
customMenuOption && customMenuOption(item),
|
|
246
|
+
!customMenuOption && /* @__PURE__ */ jsx(
|
|
247
|
+
RichLabel,
|
|
248
|
+
{
|
|
249
|
+
icon: (item == null ? void 0 : item.icon) ?? getIcon(item),
|
|
250
|
+
label: item == null ? void 0 : item.label,
|
|
251
|
+
subtitle: item.subtitle
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
} }),
|
|
258
|
+
list.isLoading && cloneElement(icons.loader, { className: "es:mx-auto es:my-4 es:animate-spin es:size-5.5 es:text-accent-700" }),
|
|
259
|
+
!list.isLoading && list.items.length === 0 && /* @__PURE__ */ jsx("div", { className: "es:flex es:p-2", children: /* @__PURE__ */ jsxs(
|
|
260
|
+
$514c0188e459b4c0$export$5f1af8db9871e1d6,
|
|
261
|
+
{
|
|
262
|
+
slot: "errorMessage",
|
|
263
|
+
className: clsx("es:flex es:w-full es:items-center es:gap-1 es:rounded es:text-amber-950"),
|
|
264
|
+
children: [
|
|
265
|
+
icons.searchEmpty,
|
|
266
|
+
__("Nothing found", "eightshift-ui-components")
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
) })
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
const ClearButton = ({ disabled }) => {
|
|
278
|
+
const state = useContext($d01f2c01039c0eec$export$c02625b26074192c);
|
|
279
|
+
const isEmpty = (state == null ? void 0 : state.selectedKey) === null || (state == null ? void 0 : state.inputValue) === "";
|
|
280
|
+
return /* @__PURE__ */ jsx(
|
|
281
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
282
|
+
{
|
|
283
|
+
"aria-label": __("Clear value", "eightshift-ui-components"),
|
|
284
|
+
className: clsx(
|
|
285
|
+
"es:mr-7 es:flex es:h-6 es:w-8 es:items-center es:justify-center es:rounded es:text-sm es:text-secondary-600 es:transition es:hover:bg-red-50 es:hover:text-red-900 es:any-focus:outline-hidden es:focus:ring-2 es:focus:ring-accent-500/50 es:disabled:text-secondary-300 es:cursor-pointer",
|
|
286
|
+
isEmpty ? "es:hidden" : "es:flex"
|
|
287
|
+
),
|
|
288
|
+
onPress: () => state == null ? void 0 : state.setSelectedKey(null),
|
|
289
|
+
slot: null,
|
|
290
|
+
isDisabled: disabled || isEmpty,
|
|
291
|
+
children: icons.clearAlt
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
export {
|
|
296
|
+
__ExperimentalAsyncSelect
|
|
297
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { a as $eed445e0843c11d0$export$a11e76429ed99b4 } from "../../../ListBox-4oW9kh3R.js";
|
|
3
|
+
import { c as clsx } from "../../../utils-B94NDG0v.js";
|
|
4
|
+
const OptionItemBase = (props) => {
|
|
5
|
+
var _a;
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
$eed445e0843c11d0$export$a11e76429ed99b4,
|
|
8
|
+
{
|
|
9
|
+
...props,
|
|
10
|
+
textValue: (_a = props == null ? void 0 : props.value) == null ? void 0 : _a.label,
|
|
11
|
+
className: clsx(
|
|
12
|
+
"es:flex es:min-h-9 es:select-none es:items-center es:gap-1 es:rounded es:p-2 es:transition",
|
|
13
|
+
"es:any-focus:outline-hidden",
|
|
14
|
+
"es:hover:bg-secondary-100 es:hover:outline-hidden",
|
|
15
|
+
"selected:es:bg-accent-600/15 selected:es:text-accent-950",
|
|
16
|
+
"es:focus-visible:bg-secondary-100 es:focus-visible:outline-hidden",
|
|
17
|
+
"es:active:bg-accent-700/15"
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
OptionItemBase
|
|
24
|
+
};
|