@eightshift/ui-components 6.1.1 → 6.2.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/dist/{Dialog-D0jMcN-a.js → Dialog-DDfABlp4.js} +26 -17
- package/dist/{ListBox-BaN0n5h3.js → ListBox-ByPsaVVK.js} +10 -8
- package/dist/{SearchField-CafsA525.js → SearchField-BME59dt-.js} +1 -1
- package/dist/{SelectionManager-oojq6MOy.js → SelectionManager-iru59gc4.js} +32 -31
- package/dist/assets/style-admin.css +9 -0
- package/dist/assets/style-editor.css +9 -0
- package/dist/assets/style.css +9 -0
- package/dist/components/color-pickers/solid-color-picker.js +1 -1
- package/dist/components/link-input/link-input.js +6 -6
- package/dist/components/menu/menu.js +1 -1
- package/dist/components/modal/modal.js +2 -2
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/rich-label/rich-label.js +6 -2
- package/dist/components/select/async-multi-select.js +78 -40
- package/dist/components/select/async-select.js +79 -39
- package/dist/components/select/multi-select.js +150 -110
- package/dist/components/select/shared.js +4 -3
- package/dist/components/select/single-select.js +151 -109
- package/dist/components/tabs/tabs.js +3 -3
- package/dist/{shared-CMLCUova.js → shared-HdRrpnhs.js} +39 -5
- package/dist/{useFilter-8S94U4xM.js → useFilter-NhAlifsK.js} +1 -1
- package/dist/{useListState-B22CApJO.js → useListState-HOvCQJFf.js} +1 -1
- package/dist/{useSingleSelectListState-CDZGQDLC.js → useSingleSelectListState-BtrMHGeE.js} +1 -1
- package/package.json +8 -8
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { _ as __ } from "../../default-i18n-CnQeC5Pl.js";
|
|
3
3
|
import { BaseControl } from "../base-control/base-control.js";
|
|
4
|
-
import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../SearchField-
|
|
4
|
+
import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../SearchField-BME59dt-.js";
|
|
5
5
|
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../Button-CFnNdpNZ.js";
|
|
6
|
+
import { f as $07b14b47974efb58$export$5b6b19405a83ff9d, i as $72a5793c14baf454$export$8b251419efc915eb } from "../../Dialog-DDfABlp4.js";
|
|
6
7
|
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-B4X6-x6r.js";
|
|
7
8
|
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BDlf9vIY.js";
|
|
8
|
-
import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../ListBox-
|
|
9
|
-
import {
|
|
10
|
-
import { $ as $
|
|
11
|
-
import { useRef, cloneElement } from "react";
|
|
9
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$dca12b0bb56e4fc } from "../../ListBox-ByPsaVVK.js";
|
|
10
|
+
import { g as getGroupedOptions, $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, S as SelectClearButton, O as OptionItemBase } from "../../shared-HdRrpnhs.js";
|
|
11
|
+
import { $ as $e1995378a142960e$export$fb8073518f34e6ec } from "../../SelectionManager-iru59gc4.js";
|
|
12
|
+
import { useRef, useMemo, cloneElement } from "react";
|
|
12
13
|
import { icons } from "../../icons/icons.js";
|
|
13
14
|
import "../../react-jsx-parser.min-DAh4myol.js";
|
|
14
15
|
import { Spinner } from "../../icons/spinner.js";
|
|
15
16
|
import { RichLabel } from "../rich-label/rich-label.js";
|
|
16
17
|
import { unescapeHTML } from "../../utilities/text-helpers.js";
|
|
17
|
-
import { randomId } from "../../utilities/hash.js";
|
|
18
18
|
import { c as clsx } from "../../clsx-DgYk2OaC.js";
|
|
19
19
|
import { c as cva } from "../../index-BHpUy2Ix.js";
|
|
20
20
|
import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../useAsyncList-DsZvQXls.js";
|
|
@@ -39,6 +39,7 @@ import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../useAsyncLi
|
|
|
39
39
|
* @param {Function} [props.getMeta] - Function to get the metadata for the item from the fetched data. `(item: Object<string, any>) => Object<string, any>` (optional)
|
|
40
40
|
* @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
|
|
41
41
|
* @param {Function} [props.getSubtitle] - Function to get the subtitle for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
42
|
+
* @param {Function} [props.getGroup] - Function to get the group name for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
42
43
|
* @param {Function} [props.getData] - Function to pre-process the fetched data before it is used in the select. `(data: Object<string, any>[]) => Object<string, any>[]`
|
|
43
44
|
* @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
|
|
44
45
|
* @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
|
|
@@ -47,7 +48,9 @@ import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../useAsyncLi
|
|
|
47
48
|
* @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`
|
|
48
49
|
* @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`
|
|
49
50
|
* @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
|
|
50
|
-
* @param {string} props.className - Classes to pass to the select menu.
|
|
51
|
+
* @param {string} [props.className] - Classes to pass to the select menu.
|
|
52
|
+
* @param {string} [props.groupKey] - If provided, the options will be grouped by this key.
|
|
53
|
+
* @param {Object} [props.groupValueMapping] - If provided, the group headers will be mapped to these labels/icons.
|
|
51
54
|
* @param {boolean} [props.flat] - If `true`, component will look more flat. Useful for nested layer of controls.
|
|
52
55
|
* @param {SelectSize} [props.size='default'] - Sets the size of the input field.
|
|
53
56
|
* @param {boolean} [props.noMinWidth=false] - If `true`, the select menu will not have a minimum width.
|
|
@@ -98,9 +101,12 @@ const AsyncSelect = (props) => {
|
|
|
98
101
|
getMeta,
|
|
99
102
|
getIcon,
|
|
100
103
|
getSubtitle,
|
|
104
|
+
getGroup,
|
|
101
105
|
getData = (data) => data,
|
|
102
106
|
extraItemProps,
|
|
103
107
|
hidden,
|
|
108
|
+
groupKey,
|
|
109
|
+
groupValueMapping,
|
|
104
110
|
flat,
|
|
105
111
|
size = "default",
|
|
106
112
|
noMinWidth = false,
|
|
@@ -116,7 +122,8 @@ const AsyncSelect = (props) => {
|
|
|
116
122
|
json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
|
|
117
123
|
} else {
|
|
118
124
|
const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
|
|
119
|
-
|
|
125
|
+
const data = await res.json();
|
|
126
|
+
json = processLoadedOptions ? processLoadedOptions(getData(data)) : getData(data);
|
|
120
127
|
}
|
|
121
128
|
const output = json?.map((item, index) => {
|
|
122
129
|
const id = getValue?.(item) ?? index;
|
|
@@ -127,6 +134,9 @@ const AsyncSelect = (props) => {
|
|
|
127
134
|
if (getSubtitle) {
|
|
128
135
|
entry.subtitle = unescapeHTML(getSubtitle(item));
|
|
129
136
|
}
|
|
137
|
+
if (getGroup) {
|
|
138
|
+
entry[groupKey ?? "_group"] = getGroup(item);
|
|
139
|
+
}
|
|
130
140
|
return entry;
|
|
131
141
|
});
|
|
132
142
|
if (filterText.length > 0) {
|
|
@@ -145,6 +155,40 @@ const AsyncSelect = (props) => {
|
|
|
145
155
|
}
|
|
146
156
|
});
|
|
147
157
|
const ref = useRef();
|
|
158
|
+
const groupedItems = useMemo(
|
|
159
|
+
() => getGroupedOptions(list?.items, groupKey ?? (getGroup ? "_group" : null), groupValueMapping),
|
|
160
|
+
[list?.items, groupKey, groupValueMapping, getGroup]
|
|
161
|
+
);
|
|
162
|
+
const renderItem = (item) => {
|
|
163
|
+
let icon2 = item?.icon ?? null;
|
|
164
|
+
if (typeof item?.icon === "string") {
|
|
165
|
+
icon2 = icons?.[item.icon] ?? null;
|
|
166
|
+
}
|
|
167
|
+
if (getIcon && !icon2) {
|
|
168
|
+
icon2 = getIcon(item);
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */ jsxs(
|
|
171
|
+
OptionItemBase,
|
|
172
|
+
{
|
|
173
|
+
id: item.value,
|
|
174
|
+
textValue: item.label,
|
|
175
|
+
selectIndicator: true,
|
|
176
|
+
children: [
|
|
177
|
+
customMenuOption && customMenuOption(item),
|
|
178
|
+
!customMenuOption && /* @__PURE__ */ jsx(
|
|
179
|
+
RichLabel,
|
|
180
|
+
{
|
|
181
|
+
icon: icon2,
|
|
182
|
+
label: item.label,
|
|
183
|
+
subtitle: item.subtitle,
|
|
184
|
+
noColor: true
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
item.value
|
|
190
|
+
);
|
|
191
|
+
};
|
|
148
192
|
if (hidden) {
|
|
149
193
|
return null;
|
|
150
194
|
}
|
|
@@ -219,7 +263,6 @@ const AsyncSelect = (props) => {
|
|
|
219
263
|
}
|
|
220
264
|
);
|
|
221
265
|
const handleSelectionChange = (selected) => {
|
|
222
|
-
list.filterText = "";
|
|
223
266
|
if (selected === null || selected === void 0) {
|
|
224
267
|
onChange(null);
|
|
225
268
|
return;
|
|
@@ -232,18 +275,20 @@ const AsyncSelect = (props) => {
|
|
|
232
275
|
if (item && "id" in item) {
|
|
233
276
|
delete item.id;
|
|
234
277
|
}
|
|
235
|
-
onChange(
|
|
236
|
-
label: item?.label,
|
|
237
|
-
value: item?.value,
|
|
238
|
-
subtitle: item?.subtitle,
|
|
239
|
-
meta: item?.meta
|
|
240
|
-
});
|
|
278
|
+
onChange(item);
|
|
241
279
|
};
|
|
242
280
|
return /* @__PURE__ */ jsx(
|
|
243
281
|
$82d7e5349645de74$export$ef9b1a59e592288f,
|
|
244
282
|
{
|
|
245
283
|
isDisabled: disabled,
|
|
246
284
|
value: value?.value ?? null,
|
|
285
|
+
onOpenChange: (isOpen) => {
|
|
286
|
+
if (!isOpen) {
|
|
287
|
+
setTimeout(() => {
|
|
288
|
+
list.setFilterText("");
|
|
289
|
+
}, 100);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
247
292
|
onChange: (selected) => handleSelectionChange(selected),
|
|
248
293
|
placeholder,
|
|
249
294
|
...rest,
|
|
@@ -363,7 +408,7 @@ const AsyncSelect = (props) => {
|
|
|
363
408
|
placeholder: __("Search...", "eightshift-ui-components"),
|
|
364
409
|
className: clsx(
|
|
365
410
|
"es:peer es:size-full es:h-9.5 es:outline-hidden! es:pl-3.5 es:pr-9 es:shadow-none! es:text-13! es:placeholder:text-surface-500 es:[&::-webkit-search-cancel-button]:hidden",
|
|
366
|
-
"es:bg-accent-900/8 es:m-1.5 es:rounded-3xl es:border-none!",
|
|
411
|
+
"es:bg-accent-900/8 es:m-1.5 es:rounded-3xl! es:border-none!",
|
|
367
412
|
"es:inset-ring! es:inset-ring-accent-950/7 es:focus:inset-ring-accent-950/20",
|
|
368
413
|
"es:text-accent-950 es:placeholder:text-accent-700/50",
|
|
369
414
|
"es:transition"
|
|
@@ -373,6 +418,7 @@ const AsyncSelect = (props) => {
|
|
|
373
418
|
/* @__PURE__ */ jsx(
|
|
374
419
|
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
375
420
|
{
|
|
421
|
+
slot: "clear",
|
|
376
422
|
"aria-label": __("Clear", "eightshift-ui-components"),
|
|
377
423
|
className: clsx(
|
|
378
424
|
"es:absolute es:right-3 es:top-0 es:bottom-0 es:my-auto es:border-none es:bg-transparent",
|
|
@@ -386,11 +432,10 @@ const AsyncSelect = (props) => {
|
|
|
386
432
|
}
|
|
387
433
|
),
|
|
388
434
|
list.isLoading && /* @__PURE__ */ jsx("div", { className: "es:p-3 es:min-h-16 es:flex es:items-center es:justify-center", children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
389
|
-
/* @__PURE__ */
|
|
435
|
+
/* @__PURE__ */ jsxs(
|
|
390
436
|
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
391
437
|
{
|
|
392
438
|
className: clsx("es:space-y-0.75 es:p-1.5 es:pt-0 es:any-focus:outline-hidden es:h-full es:overflow-y-auto es:rounded-t-xl", list?.isLoading && "es:hidden"),
|
|
393
|
-
items: list.items,
|
|
394
439
|
selectedKeys: list.selectedKeys,
|
|
395
440
|
onSelectionChange: (selected) => {
|
|
396
441
|
list.setSelectedKeys(selected);
|
|
@@ -407,34 +452,29 @@ const AsyncSelect = (props) => {
|
|
|
407
452
|
noColor: true
|
|
408
453
|
}
|
|
409
454
|
),
|
|
410
|
-
children:
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
icon2 = icons?.[item.icon] ?? null;
|
|
414
|
-
}
|
|
415
|
-
return /* @__PURE__ */ jsxs(
|
|
416
|
-
OptionItemBase,
|
|
455
|
+
children: [
|
|
456
|
+
groupedItems && /* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: groupedItems, children: (section) => /* @__PURE__ */ jsxs(
|
|
457
|
+
$eed445e0843c11d0$export$dca12b0bb56e4fc,
|
|
417
458
|
{
|
|
418
|
-
id:
|
|
419
|
-
className:
|
|
420
|
-
selectIndicator: true,
|
|
459
|
+
id: section.key,
|
|
460
|
+
className: "es:flex es:flex-col es:gap-0.75",
|
|
421
461
|
children: [
|
|
422
|
-
|
|
423
|
-
!customMenuOption && /* @__PURE__ */ jsx(
|
|
462
|
+
/* @__PURE__ */ jsx($72a5793c14baf454$export$8b251419efc915eb, { className: "es:px-2.5 es:pb-1 es:pt-3 es:select-none", children: /* @__PURE__ */ jsx(
|
|
424
463
|
RichLabel,
|
|
425
464
|
{
|
|
426
|
-
icon:
|
|
427
|
-
label:
|
|
428
|
-
subtitle:
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
noColor: true
|
|
465
|
+
icon: section?.icon,
|
|
466
|
+
label: section?.label,
|
|
467
|
+
subtitle: section?.subtitle,
|
|
468
|
+
endIcon: section?.endIcon,
|
|
469
|
+
fullWidth: true
|
|
432
470
|
}
|
|
433
|
-
)
|
|
471
|
+
) }),
|
|
472
|
+
/* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: section.options, children: (item) => renderItem(item) })
|
|
434
473
|
]
|
|
435
474
|
}
|
|
436
|
-
)
|
|
437
|
-
|
|
475
|
+
) }),
|
|
476
|
+
!groupedItems && /* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: list.items, children: (item) => renderItem(item) })
|
|
477
|
+
]
|
|
438
478
|
}
|
|
439
479
|
)
|
|
440
480
|
]
|
|
@@ -2,14 +2,15 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { s as sprintf } from "../../sprintf-DmNrJSYG.js";
|
|
3
3
|
import { _ as __, a as _n } from "../../default-i18n-CnQeC5Pl.js";
|
|
4
4
|
import { BaseControl } from "../base-control/base-control.js";
|
|
5
|
-
import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../SearchField-
|
|
5
|
+
import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../SearchField-BME59dt-.js";
|
|
6
6
|
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../Button-CFnNdpNZ.js";
|
|
7
|
+
import { f as $07b14b47974efb58$export$5b6b19405a83ff9d, i as $72a5793c14baf454$export$8b251419efc915eb } from "../../Dialog-DDfABlp4.js";
|
|
7
8
|
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-B4X6-x6r.js";
|
|
8
9
|
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BDlf9vIY.js";
|
|
9
|
-
import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../ListBox-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { useRef, cloneElement, isValidElement } from "react";
|
|
10
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$dca12b0bb56e4fc } from "../../ListBox-ByPsaVVK.js";
|
|
11
|
+
import { g as getGroupedOptions, b as getValue, $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, S as SelectClearButton, O as OptionItemBase } from "../../shared-HdRrpnhs.js";
|
|
12
|
+
import { $ as $e1995378a142960e$export$fb8073518f34e6ec } from "../../SelectionManager-iru59gc4.js";
|
|
13
|
+
import { useRef, useState, useMemo, cloneElement, isValidElement } from "react";
|
|
13
14
|
import { icons } from "../../icons/icons.js";
|
|
14
15
|
import "../../react-jsx-parser.min-DAh4myol.js";
|
|
15
16
|
import { c as clsx } from "../../clsx-DgYk2OaC.js";
|
|
@@ -19,7 +20,7 @@ import { TriggeredPopover } from "../popover/popover.js";
|
|
|
19
20
|
import { DraggableList } from "../draggable-list/draggable-list.js";
|
|
20
21
|
import { DraggableListItem } from "../draggable-list/draggable-list-item.js";
|
|
21
22
|
import { randomId } from "../../utilities/hash.js";
|
|
22
|
-
import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../useFilter-
|
|
23
|
+
import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../useFilter-NhAlifsK.js";
|
|
23
24
|
/**
|
|
24
25
|
* Multi-select menu.
|
|
25
26
|
*
|
|
@@ -35,6 +36,8 @@ import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../useFilter-8
|
|
|
35
36
|
* @param {string|{label: string, value: string, metadata: Object<string, any>?}} props.value - Current value of the select.
|
|
36
37
|
* @param {Function} props.onChange - Function to call when the value changes.
|
|
37
38
|
* @param {boolean} [props.simpleValue=false] - If `true`, instead of using a `{label: '', value: ''}` value type, a string is used (just the value).
|
|
39
|
+
* @param {string} [props.groupKey] - If provided, the options will be grouped by this key.
|
|
40
|
+
* @param {Object} [props.groupValueMapping] - If provided, the group headers will be mapped to these labels/icons.
|
|
38
41
|
* @param {boolean} [props.clearable] - Whether the select is clearable.
|
|
39
42
|
* @param {boolean} [props.disabled] - Whether the select is disabled.
|
|
40
43
|
* @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
|
|
@@ -83,6 +86,8 @@ const MultiSelect = (props) => {
|
|
|
83
86
|
onChange,
|
|
84
87
|
options,
|
|
85
88
|
simpleValue = false,
|
|
89
|
+
groupKey,
|
|
90
|
+
groupValueMapping,
|
|
86
91
|
disabled = false,
|
|
87
92
|
clearable = false,
|
|
88
93
|
placeholder = __("Select...", "eightshift-ui-components"),
|
|
@@ -99,7 +104,43 @@ const MultiSelect = (props) => {
|
|
|
99
104
|
...rest
|
|
100
105
|
} = props;
|
|
101
106
|
const ref = useRef();
|
|
107
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
102
108
|
const { contains } = $bb77f239b46e8c72$export$3274cf84b703fff({ sensitivity: "base" });
|
|
109
|
+
const filteredOptions = useMemo(() => {
|
|
110
|
+
if (!searchable || searchTerm.length === 0) {
|
|
111
|
+
return options;
|
|
112
|
+
}
|
|
113
|
+
return options?.filter((item) => {
|
|
114
|
+
return contains(item.label ?? "", searchTerm) || contains(item?.subtitle ?? "", searchTerm);
|
|
115
|
+
});
|
|
116
|
+
}, [options, searchable, searchTerm, contains]);
|
|
117
|
+
const groupedOptions = useMemo(() => getGroupedOptions(filteredOptions, groupKey, groupValueMapping), [filteredOptions, groupKey, groupValueMapping]);
|
|
118
|
+
const renderItem = (item) => {
|
|
119
|
+
let icon2 = item?.icon ?? null;
|
|
120
|
+
if (typeof item?.icon === "string") {
|
|
121
|
+
icon2 = icons?.[item.icon] ?? null;
|
|
122
|
+
}
|
|
123
|
+
return /* @__PURE__ */ jsxs(
|
|
124
|
+
OptionItemBase,
|
|
125
|
+
{
|
|
126
|
+
id: item?.value ?? randomId(8),
|
|
127
|
+
className: item?.className,
|
|
128
|
+
selectIndicator: true,
|
|
129
|
+
children: [
|
|
130
|
+
customMenuOption && customMenuOption(item),
|
|
131
|
+
!customMenuOption && /* @__PURE__ */ jsx(
|
|
132
|
+
RichLabel,
|
|
133
|
+
{
|
|
134
|
+
icon: icon2,
|
|
135
|
+
label: item?.label,
|
|
136
|
+
subtitle: item?.subtitle,
|
|
137
|
+
noColor: true
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
};
|
|
103
144
|
const currentValue = getValue(simpleValue, value, options);
|
|
104
145
|
const currentValueKeys = value?.map((item) => item?.value ?? item);
|
|
105
146
|
const handleSelectionChange = (selected) => {
|
|
@@ -127,14 +168,7 @@ const MultiSelect = (props) => {
|
|
|
127
168
|
...option
|
|
128
169
|
};
|
|
129
170
|
})?.filter(Boolean);
|
|
130
|
-
onChange(
|
|
131
|
-
selectedValues.map((item) => ({
|
|
132
|
-
label: item?.label,
|
|
133
|
-
value: item?.value,
|
|
134
|
-
subtitle: item?.subtitle,
|
|
135
|
-
meta: item?.meta
|
|
136
|
-
}))
|
|
137
|
-
);
|
|
171
|
+
onChange(selectedValues);
|
|
138
172
|
};
|
|
139
173
|
if (hidden) {
|
|
140
174
|
return null;
|
|
@@ -215,6 +249,11 @@ const MultiSelect = (props) => {
|
|
|
215
249
|
selectionMode: "multiple",
|
|
216
250
|
isDisabled: disabled,
|
|
217
251
|
value: currentValueKeys,
|
|
252
|
+
onOpenChange: (isOpen) => {
|
|
253
|
+
if (!isOpen) {
|
|
254
|
+
setSearchTerm("");
|
|
255
|
+
}
|
|
256
|
+
},
|
|
218
257
|
onChange: (selected) => handleSelectionChange(selected),
|
|
219
258
|
placeholder,
|
|
220
259
|
...rest,
|
|
@@ -375,92 +414,96 @@ const MultiSelect = (props) => {
|
|
|
375
414
|
maxHeight: 260,
|
|
376
415
|
triggerRef: ref,
|
|
377
416
|
children: [
|
|
378
|
-
searchable && /* @__PURE__ */ jsxs(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
388
|
-
{
|
|
389
|
-
placeholder: __("Search...", "eightshift-ui-components"),
|
|
390
|
-
className: clsx(
|
|
391
|
-
"es:peer es:size-full es:h-9.5 es:outline-hidden! es:pl-3.5 es:pr-9 es:shadow-none! es:text-13! es:placeholder:text-surface-500 es:[&::-webkit-search-cancel-button]:hidden",
|
|
392
|
-
"es:bg-accent-900/8 es:m-1.5 es:rounded-3xl es:border-none!",
|
|
393
|
-
"es:inset-ring! es:inset-ring-accent-950/7 es:focus:inset-ring-accent-950/20",
|
|
394
|
-
"es:text-accent-950 es:placeholder:text-accent-700/50",
|
|
395
|
-
"es:transition"
|
|
396
|
-
)
|
|
397
|
-
}
|
|
398
|
-
),
|
|
399
|
-
/* @__PURE__ */ jsx(
|
|
400
|
-
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
401
|
-
{
|
|
402
|
-
"aria-label": __("Clear", "eightshift-ui-components"),
|
|
403
|
-
className: clsx(
|
|
404
|
-
"es:absolute es:right-3 es:top-0 es:bottom-0 es:my-auto es:border-none es:bg-transparent",
|
|
405
|
-
"es:flex es:size-7 es:items-center es:justify-center es:rounded-3xl es:text-sm es:text-surface-700 es:transition es:hover:bg-accent-50 es:hover:text-accent-800 es:any-focus:outline-hidden es:focus:ring-2 es:focus:ring-accent-500/50 es:disabled:text-secondary-300",
|
|
406
|
-
"es:peer-placeholder-shown:opacity-0"
|
|
407
|
-
),
|
|
408
|
-
children: icons.clearAlt
|
|
409
|
-
}
|
|
410
|
-
)
|
|
411
|
-
]
|
|
412
|
-
}
|
|
413
|
-
),
|
|
414
|
-
/* @__PURE__ */ jsx(
|
|
415
|
-
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
416
|
-
{
|
|
417
|
-
className: "es:space-y-0.75 es:p-1.5 es:pt-0 es:any-focus:outline-hidden es:h-full es:overflow-y-auto es:rounded-t-xl",
|
|
418
|
-
items: options,
|
|
419
|
-
renderEmptyState: () => /* @__PURE__ */ jsx(
|
|
420
|
-
RichLabel,
|
|
417
|
+
searchable && /* @__PURE__ */ jsxs(
|
|
418
|
+
$d2f53cda644affe3$export$2f2b9559550c7bbc,
|
|
419
|
+
{
|
|
420
|
+
filter: () => true,
|
|
421
|
+
inputValue: searchTerm,
|
|
422
|
+
onInputChange: setSearchTerm,
|
|
423
|
+
children: [
|
|
424
|
+
/* @__PURE__ */ jsxs(
|
|
425
|
+
$440f4836bcb56932$export$b94867ecbd698f21,
|
|
421
426
|
{
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
427
|
+
"aria-label": __("Search", "eightshift-ui-components"),
|
|
428
|
+
className: "es:flex es:items-center es:relative",
|
|
429
|
+
autoFocus: true,
|
|
430
|
+
children: [
|
|
431
|
+
/* @__PURE__ */ jsx(
|
|
432
|
+
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
433
|
+
{
|
|
434
|
+
placeholder: __("Search...", "eightshift-ui-components"),
|
|
435
|
+
className: clsx(
|
|
436
|
+
"es:peer es:size-full es:h-9.5 es:outline-hidden! es:pl-3.5 es:pr-9 es:shadow-none! es:text-13! es:placeholder:text-surface-500 es:[&::-webkit-search-cancel-button]:hidden",
|
|
437
|
+
"es:bg-accent-900/8 es:m-1.5 es:rounded-3xl! es:border-none!",
|
|
438
|
+
"es:inset-ring! es:inset-ring-accent-950/7 es:focus:inset-ring-accent-950/20",
|
|
439
|
+
"es:text-accent-950 es:placeholder:text-accent-700/50",
|
|
440
|
+
"es:transition"
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ jsx(
|
|
445
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
446
|
+
{
|
|
447
|
+
slot: "clear",
|
|
448
|
+
"aria-label": __("Clear", "eightshift-ui-components"),
|
|
449
|
+
className: clsx(
|
|
450
|
+
"es:absolute es:right-3 es:top-0 es:bottom-0 es:my-auto es:border-none es:bg-transparent",
|
|
451
|
+
"es:flex es:size-7 es:items-center es:justify-center es:rounded-3xl es:text-sm es:text-surface-700 es:transition es:hover:bg-accent-50 es:hover:text-accent-800 es:any-focus:outline-hidden es:focus:ring-2 es:focus:ring-accent-500/50 es:disabled:text-secondary-300",
|
|
452
|
+
"es:peer-placeholder-shown:opacity-0"
|
|
453
|
+
),
|
|
454
|
+
children: icons.clearAlt
|
|
455
|
+
}
|
|
456
|
+
)
|
|
457
|
+
]
|
|
428
458
|
}
|
|
429
459
|
),
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
460
|
+
/* @__PURE__ */ jsxs(
|
|
461
|
+
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
462
|
+
{
|
|
463
|
+
className: "es:space-y-0.75 es:p-1.5 es:pt-0 es:any-focus:outline-hidden es:h-full es:overflow-y-auto es:rounded-t-xl",
|
|
464
|
+
renderEmptyState: () => /* @__PURE__ */ jsx(
|
|
465
|
+
RichLabel,
|
|
466
|
+
{
|
|
467
|
+
icon: icons.searchEmpty,
|
|
468
|
+
label: __("No results", "eightshift-ui-components"),
|
|
469
|
+
subtitle: __("Try a different search term", "eightshift-ui-components"),
|
|
470
|
+
className: "es:min-h-14 es:p-2 es:w-fit es:mx-auto es:motion-preset-slide-up es:motion-ease-spring-bouncy es:motion-duration-200 es:shrink-0",
|
|
471
|
+
iconClassName: "es:text-accent-700 es:icon:size-7!",
|
|
472
|
+
noColor: true
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
children: [
|
|
476
|
+
groupedOptions && /* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: groupedOptions, children: (item) => /* @__PURE__ */ jsxs(
|
|
477
|
+
$eed445e0843c11d0$export$dca12b0bb56e4fc,
|
|
478
|
+
{
|
|
479
|
+
id: item.key,
|
|
480
|
+
className: "es:flex es:flex-col es:gap-0.75",
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ jsx($72a5793c14baf454$export$8b251419efc915eb, { className: "es:px-2.5 es:pb-1 es:pt-3 es:select-none", children: /* @__PURE__ */ jsx(
|
|
483
|
+
RichLabel,
|
|
484
|
+
{
|
|
485
|
+
icon: item?.icon,
|
|
486
|
+
label: item?.label,
|
|
487
|
+
subtitle: item?.subtitle,
|
|
488
|
+
endIcon: item?.endIcon,
|
|
489
|
+
fullWidth: true
|
|
490
|
+
}
|
|
491
|
+
) }),
|
|
492
|
+
/* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: item.options, children: (subItem) => renderItem(subItem) })
|
|
493
|
+
]
|
|
494
|
+
}
|
|
495
|
+
) }),
|
|
496
|
+
!groupedOptions && /* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: searchable ? filteredOptions : options, children: (item) => renderItem(item) })
|
|
497
|
+
]
|
|
434
498
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
selectIndicator: true,
|
|
441
|
-
children: [
|
|
442
|
-
customMenuOption && customMenuOption(item),
|
|
443
|
-
!customMenuOption && /* @__PURE__ */ jsx(
|
|
444
|
-
RichLabel,
|
|
445
|
-
{
|
|
446
|
-
icon: icon2,
|
|
447
|
-
label: item?.label,
|
|
448
|
-
subtitle: item?.subtitle,
|
|
449
|
-
noColor: true
|
|
450
|
-
}
|
|
451
|
-
)
|
|
452
|
-
]
|
|
453
|
-
}
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
)
|
|
458
|
-
] }),
|
|
459
|
-
!searchable && /* @__PURE__ */ jsx(
|
|
499
|
+
)
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
!searchable && /* @__PURE__ */ jsxs(
|
|
460
504
|
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
461
505
|
{
|
|
462
506
|
className: "es:space-y-0.75 es:p-1.5 es:any-focus:outline-hidden es:h-full es:overflow-y-auto es:rounded-t-xl",
|
|
463
|
-
items: options,
|
|
464
507
|
renderEmptyState: () => /* @__PURE__ */ jsx(
|
|
465
508
|
RichLabel,
|
|
466
509
|
{
|
|
@@ -472,32 +515,29 @@ const MultiSelect = (props) => {
|
|
|
472
515
|
noColor: true
|
|
473
516
|
}
|
|
474
517
|
),
|
|
475
|
-
children:
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
icon2 = icons?.[item.icon] ?? null;
|
|
479
|
-
}
|
|
480
|
-
return /* @__PURE__ */ jsxs(
|
|
481
|
-
OptionItemBase,
|
|
518
|
+
children: [
|
|
519
|
+
groupedOptions && /* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: groupedOptions, children: (item) => /* @__PURE__ */ jsxs(
|
|
520
|
+
$eed445e0843c11d0$export$dca12b0bb56e4fc,
|
|
482
521
|
{
|
|
483
|
-
id: item
|
|
484
|
-
className:
|
|
485
|
-
selectIndicator: true,
|
|
522
|
+
id: item.key,
|
|
523
|
+
className: "es:flex es:flex-col es:gap-0.75",
|
|
486
524
|
children: [
|
|
487
|
-
|
|
488
|
-
!customMenuOption && /* @__PURE__ */ jsx(
|
|
525
|
+
/* @__PURE__ */ jsx($72a5793c14baf454$export$8b251419efc915eb, { className: "es:px-2.5 es:pb-1 es:pt-3 es:select-none", children: /* @__PURE__ */ jsx(
|
|
489
526
|
RichLabel,
|
|
490
527
|
{
|
|
491
|
-
icon:
|
|
528
|
+
icon: item?.icon,
|
|
492
529
|
label: item?.label,
|
|
493
530
|
subtitle: item?.subtitle,
|
|
494
|
-
|
|
531
|
+
endIcon: item?.endIcon,
|
|
532
|
+
fullWidth: true
|
|
495
533
|
}
|
|
496
|
-
)
|
|
534
|
+
) }),
|
|
535
|
+
/* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: item.options, children: (subItem) => renderItem(subItem) })
|
|
497
536
|
]
|
|
498
537
|
}
|
|
499
|
-
)
|
|
500
|
-
|
|
538
|
+
) }),
|
|
539
|
+
!groupedOptions && /* @__PURE__ */ jsx($e1995378a142960e$export$fb8073518f34e6ec, { items: options, children: (item) => renderItem(item) })
|
|
540
|
+
]
|
|
501
541
|
}
|
|
502
542
|
)
|
|
503
543
|
]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../default-i18n-CnQeC5Pl.js";
|
|
3
3
|
import "../../Button-CFnNdpNZ.js";
|
|
4
|
-
import "../../ListBox-
|
|
5
|
-
import { O, S, g, m } from "../../shared-
|
|
4
|
+
import "../../ListBox-ByPsaVVK.js";
|
|
5
|
+
import { O, S, g, b, m } from "../../shared-HdRrpnhs.js";
|
|
6
6
|
import "../../icons/icons.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import "../../react-jsx-parser.min-DAh4myol.js";
|
|
@@ -11,6 +11,7 @@ import "../animated-visibility/animated-visibility.js";
|
|
|
11
11
|
export {
|
|
12
12
|
O as OptionItemBase,
|
|
13
13
|
S as SelectClearButton,
|
|
14
|
-
g as
|
|
14
|
+
g as getGroupedOptions,
|
|
15
|
+
b as getValue,
|
|
15
16
|
m as moveArrayItem
|
|
16
17
|
};
|