@eightshift/ui-components 5.1.4 → 5.2.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-DH22t_SM.js → Button-RTwMSBs-.js} +20 -26
- package/dist/{Collection-BRJOMbOa.js → Collection-D_KhdLDC.js} +40 -23
- package/dist/{Color-CNqKeT8D.js → Color-WxFE7lQB.js} +2 -2
- package/dist/{ColorSwatch-Dt3lRApA.js → ColorSwatch-xVS3rMYS.js} +9 -7
- package/dist/{Dialog-D6EdDPeu.js → Dialog-Xf6AsnV-.js} +86 -62
- package/dist/{FieldError-DHrSdE_Q.js → FieldError-B8BgFmIQ.js} +2 -2
- package/dist/{FocusScope-BEPI2m7u.js → FocusScope-BnwM-e8R.js} +24 -22
- package/dist/{Form-Bnyyv3Im.js → Form-BeMxJA29.js} +13 -3
- package/dist/{Input-DfSBLhDx.js → Group-C4cXobNT.js} +56 -11
- package/dist/{Heading-ba38ScjJ.js → Heading-bh1HU5HH.js} +1 -1
- package/dist/{Label-JS_ob-kh.js → Label-DWVaNd2E.js} +1 -1
- package/dist/{List-BLeHBkfx.js → List-CwJTORxj.js} +1 -1
- package/dist/{ListBox-BY3gwI8c.js → ListBox-BeC97FZ4.js} +62 -38
- package/dist/{OverlayArrow-BUfV-5P3.js → OverlayArrow-EZ0v_ljk.js} +6 -6
- package/dist/{Select-BebwUgKB.js → Select-DEQf8ZWI.js} +96 -58
- package/dist/{Select-aab027f3.esm-BKIJGje-.js → Select-ef7c0426.esm-D6WOCaYm.js} +11 -6
- package/dist/{Separator-CTQWg_HO.js → Separator-Fl7qSeN-.js} +37 -20
- package/dist/{Slider-uOPcIpqS.js → Slider-BQFSEhvk.js} +28 -21
- package/dist/{Text-BuJgePCv.js → Text-AxKZjtFm.js} +1 -1
- package/dist/{TextField-o2U-uBWv.js → TextField-x_eEa_qR.js} +20 -10
- package/dist/{VisuallyHidden-BYi0pekx.js → VisuallyHidden-D9s7FTtC.js} +2 -2
- package/dist/assets/style-admin.css +227 -3
- package/dist/assets/style-editor.css +227 -3
- package/dist/assets/style.css +227 -3
- package/dist/components/base-control/base-control.js +1 -1
- package/dist/components/button/button.js +11 -10
- package/dist/components/checkbox/checkbox.js +17 -12
- package/dist/components/color-pickers/color-picker.js +1 -1
- package/dist/components/color-pickers/color-swatch.js +3 -3
- package/dist/components/color-pickers/gradient-editor.js +3 -2
- package/dist/components/color-pickers/solid-color-picker.js +85 -49
- package/dist/components/component-toggle/component-toggle.js +2 -1
- package/dist/components/draggable/draggable-handle.js +1 -1
- package/dist/components/draggable/draggable.js +191 -170
- package/dist/components/draggable-list/draggable-list-item.js +1 -1
- package/dist/components/draggable-list/draggable-list.js +2 -2
- package/dist/components/expandable/expandable.js +18 -18
- package/dist/components/index.js +5 -1
- package/dist/components/input-field/input-field.js +3 -3
- package/dist/components/item-collection/item-collection.js +1 -1
- package/dist/components/link-input/link-input.js +45 -34
- package/dist/components/matrix-align/matrix-align.js +1 -1
- package/dist/components/menu/menu.js +3 -3
- package/dist/components/modal/modal.js +39 -13
- package/dist/components/number-picker/number-picker.js +15 -13
- package/dist/components/option-select/option-select.js +1 -1
- package/dist/components/options-panel/options-panel.js +1 -1
- package/dist/components/placeholders/file-placeholder.js +1 -1
- package/dist/components/popover/popover.js +2 -2
- package/dist/components/radio/radio.js +45 -22
- package/dist/components/repeater/repeater-item.js +1 -1
- package/dist/components/repeater/repeater.js +2 -2
- package/dist/components/responsive/mini-responsive.js +3 -2
- package/dist/components/responsive/responsive-legacy.js +2 -1
- package/dist/components/responsive/responsive.js +2 -1
- package/dist/components/responsive-preview/responsive-preview.js +1 -1
- package/dist/components/select/async-multi-select.js +3 -3
- package/dist/components/select/async-single-select.js +2 -2
- package/dist/components/select/custom-select-default-components.js +1 -1
- package/dist/components/select/multi-select-components.js +1 -1
- package/dist/components/select/multi-select.js +3 -3
- package/dist/components/select/react-select-component-wrappers.js +1 -1
- package/dist/components/select/shared.js +19 -1
- package/dist/components/select/single-select.js +2 -2
- package/dist/components/select/v2/async-multi-select.js +432 -0
- package/dist/components/select/v2/async-select.js +25 -14
- package/dist/components/select/v2/multi-select.js +403 -0
- package/dist/components/select/v2/shared.js +44 -8
- package/dist/components/select/v2/single-select.js +10 -10
- package/dist/components/slider/column-config-slider.js +3 -3
- package/dist/components/slider/slider.js +3 -3
- package/dist/components/slider/utils.js +2 -1
- package/dist/components/tabs/tabs.js +33 -23
- package/dist/components/toggle/switch.js +11 -8
- package/dist/components/toggle/toggle.js +1 -1
- package/dist/components/toggle-button/toggle-button.js +14 -8
- package/dist/components/tooltip/tooltip.js +9 -7
- package/dist/{context-BbYZoHvX.js → context-DMOmz986.js} +1 -1
- package/dist/{default-i18n-OFa3zAyB.js → default-i18n-DY6EfUSA.js} +21 -284
- package/dist/filterDOMProps-D2C6R0DK.js +71 -0
- package/dist/icons/icons.js +1 -1
- package/dist/{index-641ee5b8.esm-BPU8rMZr.js → index-641ee5b8.esm-Bu-mgopl.js} +1 -1
- package/dist/{index-CFozsmNS.js → index-CBHA_HDD.js} +3 -1
- package/dist/{index-BljRBEr_.js → index-Dq3gT5pW.js} +1 -1
- package/dist/index.js +4 -0
- package/dist/{multi-select-components-BcKzA24f.js → multi-select-components-rCCyCaKO.js} +1 -1
- package/dist/{number-CHmNj-oR.js → number-7sOvrqo0.js} +7 -2
- package/dist/{react-select-async.esm-D937XTWW.js → react-select-async.esm-XYrsKYb2.js} +3 -3
- package/dist/{react-select.esm-Ciai3aKf.js → react-select.esm-CCSPY6XR.js} +3 -3
- package/dist/sprintf-DmNrJSYG.js +51 -0
- package/dist/{textSelection-8DpK8fJl.js → textSelection-D5tWX1rJ.js} +1 -1
- package/dist/{useAsyncList-fLtZMvJO.js → useAsyncList-ZqaIH2gh.js} +1 -1
- package/dist/{useButton-lRcWnvOB.js → useButton-BtJSiQi3.js} +13 -5
- package/dist/useDragAndDrop-CddFteYC.js +3917 -0
- package/dist/{useEvent-ICdlokG-.js → useEvent-BifIGnVS.js} +1 -1
- package/dist/{useFilter-BR5z1A4Q.js → useFilter-Cl2ggwwq.js} +1 -1
- package/dist/{useFocusRing-Bv0UJQl8.js → useFocusRing-D5BfOWag.js} +3 -3
- package/dist/{useFormReset-D2YaWRIA.js → useFormReset-yV9VVy9R.js} +3 -4
- package/dist/{useHover-C2SkI1Fn.js → useHover-44IApaa2.js} +67 -34
- package/dist/{useLabel-BPCd5c7-.js → useLabel-C8umX0gk.js} +2 -2
- package/dist/{useLabels-B7-lUnAF.js → useLabels-Cdxi6JSa.js} +1 -1
- package/dist/{useListState-BrZ2XvDS.js → useListState-BSkHuB7-.js} +1 -1
- package/dist/{useLocalizedStringFormatter-C9GO0IDB.js → useLocalizedStringFormatter-eaZiN2tE.js} +1 -1
- package/dist/{useNumberField-y0dLc_6m.js → useNumberField-JhWPy1JY.js} +23 -16
- package/dist/{useNumberFormatter-CZ9QUnRt.js → useNumberFormatter-BCmkV-7c.js} +1 -1
- package/dist/{usePress-DWBuejBp.js → usePress-BnrkvZ7e.js} +20 -5
- package/dist/{useSingleSelectListState-Bh46cRXs.js → useSingleSelectListState-CzJFsSHr.js} +2 -2
- package/dist/{useToggle-yGuUBU7q.js → useToggle-OaIBlwRu.js} +21 -8
- package/dist/{useToggleState-ibcBUHnB.js → useToggleState-BF8hvidm.js} +5 -1
- package/dist/{utils-CZt7LCbO.js → utils-cvK1vxO7.js} +9 -7
- package/package.json +18 -18
- package/dist/Group-LBogWgyp.js +0 -48
- package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
- package/dist/filterDOMProps-EDDcM64A.js +0 -28
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import { A as AsyncSelect$1 } from "../../react-select-async.esm-
|
|
4
|
-
import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-
|
|
3
|
+
import { A as AsyncSelect$1 } from "../../react-select-async.esm-XYrsKYb2.js";
|
|
4
|
+
import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-rCCyCaKO.js";
|
|
5
5
|
import { r as restrictToParentElement } from "../../modifiers.esm-BuJQPI1X.js";
|
|
6
6
|
import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator, CustomSelectDefaultMultiValueRemove } from "./custom-select-default-components.js";
|
|
7
7
|
import { BaseControl } from "../base-control/base-control.js";
|
|
8
8
|
import { eightshiftSelectClasses } from "./styles.js";
|
|
9
|
-
import { c as components } from "../../index-641ee5b8.esm-
|
|
9
|
+
import { c as components } from "../../index-641ee5b8.esm-Bu-mgopl.js";
|
|
10
10
|
/**
|
|
11
11
|
* Multi-select menu with async loading and re-ordering.
|
|
12
12
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { A as AsyncSelect$1 } from "../../react-select-async.esm-
|
|
2
|
+
import { A as AsyncSelect$1 } from "../../react-select-async.esm-XYrsKYb2.js";
|
|
3
3
|
import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator } from "./custom-select-default-components.js";
|
|
4
4
|
import { BaseControl } from "../base-control/base-control.js";
|
|
5
5
|
import { eightshiftSelectClasses } from "./styles.js";
|
|
6
|
-
import { c as components } from "../../index-641ee5b8.esm-
|
|
6
|
+
import { c as components } from "../../index-641ee5b8.esm-Bu-mgopl.js";
|
|
7
7
|
/**
|
|
8
8
|
* Select menu with async loading.
|
|
9
9
|
*
|
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React__default from "react";
|
|
3
3
|
import { icons } from "../../icons/icons.js";
|
|
4
4
|
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
5
|
-
import { c as components } from "../../index-641ee5b8.esm-
|
|
5
|
+
import { c as components } from "../../index-641ee5b8.esm-Bu-mgopl.js";
|
|
6
6
|
/**
|
|
7
7
|
* Default dropdown indicator for CustomSelect.
|
|
8
8
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import { S as StateManagedSelect$1 } from "../../react-select.esm-
|
|
4
|
-
import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-
|
|
3
|
+
import { S as StateManagedSelect$1 } from "../../react-select.esm-CCSPY6XR.js";
|
|
4
|
+
import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-rCCyCaKO.js";
|
|
5
5
|
import { r as restrictToParentElement } from "../../modifiers.esm-BuJQPI1X.js";
|
|
6
6
|
import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator, CustomSelectDefaultMultiValueRemove } from "./custom-select-default-components.js";
|
|
7
7
|
import { getValue } from "./shared.js";
|
|
8
8
|
import { BaseControl } from "../base-control/base-control.js";
|
|
9
9
|
import { eightshiftSelectClasses } from "./styles.js";
|
|
10
|
-
import { c as components } from "../../index-641ee5b8.esm-
|
|
10
|
+
import { c as components } from "../../index-641ee5b8.esm-Bu-mgopl.js";
|
|
11
11
|
/**
|
|
12
12
|
* Multi-select menu with re-orderable items.
|
|
13
13
|
*
|
|
@@ -21,6 +21,24 @@ const getValue = (simpleValue, value, options) => {
|
|
|
21
21
|
}
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
+
const moveArrayItem = (array, itemToMove, targetItem, position = "before") => {
|
|
25
|
+
const result = [...array];
|
|
26
|
+
const sourceIndex = result.indexOf(itemToMove);
|
|
27
|
+
const targetIndex = result.indexOf(targetItem);
|
|
28
|
+
if (sourceIndex === -1 || targetIndex === -1) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
result.splice(sourceIndex, 1);
|
|
32
|
+
let adjustedTargetIndex;
|
|
33
|
+
if (position === "after") {
|
|
34
|
+
adjustedTargetIndex = sourceIndex < targetIndex ? targetIndex : targetIndex + 1;
|
|
35
|
+
} else if (position === "before") {
|
|
36
|
+
adjustedTargetIndex = sourceIndex < targetIndex ? targetIndex - 1 : targetIndex;
|
|
37
|
+
}
|
|
38
|
+
result.splice(adjustedTargetIndex, 0, itemToMove);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
24
41
|
export {
|
|
25
|
-
getValue
|
|
42
|
+
getValue,
|
|
43
|
+
moveArrayItem
|
|
26
44
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { S as StateManagedSelect$1 } from "../../react-select.esm-
|
|
2
|
+
import { S as StateManagedSelect$1 } from "../../react-select.esm-CCSPY6XR.js";
|
|
3
3
|
import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator } from "./custom-select-default-components.js";
|
|
4
4
|
import { getValue } from "./shared.js";
|
|
5
5
|
import { BaseControl } from "../base-control/base-control.js";
|
|
6
6
|
import { eightshiftSelectClasses } from "./styles.js";
|
|
7
|
-
import { c as components } from "../../index-641ee5b8.esm-
|
|
7
|
+
import { c as components } from "../../index-641ee5b8.esm-Bu-mgopl.js";
|
|
8
8
|
/**
|
|
9
9
|
* Select menu.
|
|
10
10
|
*
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { _ as __ } from "../../../default-i18n-DY6EfUSA.js";
|
|
3
|
+
import { BaseControl } from "../../base-control/base-control.js";
|
|
4
|
+
import { b as $d2f53cda644affe3$export$2f2b9559550c7bbc, c as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../Separator-Fl7qSeN-.js";
|
|
5
|
+
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-RTwMSBs-.js";
|
|
6
|
+
import { g as $de32f1b87079253c$export$2e1e1122cf0cba88, e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-Xf6AsnV-.js";
|
|
7
|
+
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Group-C4cXobNT.js";
|
|
8
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-DWVaNd2E.js";
|
|
9
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$a11e76429ed99b4, b as $612b8eb6cb90e02d$export$62ed72bc21f6b8a6 } from "../../../ListBox-BeC97FZ4.js";
|
|
10
|
+
import { $ as $514c0188e459b4c0$export$5f1af8db9871e1d6 } from "../../../Text-AxKZjtFm.js";
|
|
11
|
+
import { $ as $d8f176866e6dc039$export$2cfc5be7a55829f6 } from "../../../useDragAndDrop-CddFteYC.js";
|
|
12
|
+
import { useRef, useEffect, cloneElement } from "react";
|
|
13
|
+
import { icons } from "../../../icons/icons.js";
|
|
14
|
+
import "../../../react-jsx-parser.min-LF707GK8.js";
|
|
15
|
+
import { OptionItemBase } from "./shared.js";
|
|
16
|
+
import { RichLabel } from "../../rich-label/rich-label.js";
|
|
17
|
+
import { c as clsx } from "../../../utils-cvK1vxO7.js";
|
|
18
|
+
import { truncateEnd, unescapeHTML } from "../../../utilities/text-helpers.js";
|
|
19
|
+
import { moveArrayItem } from "../shared.js";
|
|
20
|
+
import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyncList-ZqaIH2gh.js";
|
|
21
|
+
/**
|
|
22
|
+
* Async multi-select menu.
|
|
23
|
+
*
|
|
24
|
+
* @component
|
|
25
|
+
* @param {Object} props - Component props.
|
|
26
|
+
* @param {string} [props.label] - Label of the component.
|
|
27
|
+
* @param {string} [props.help] - Help text of the component.
|
|
28
|
+
* @param {string} [props.icon] - Icon of the component.
|
|
29
|
+
* @param {string} [props.subtitle] - Subtitle of the component.
|
|
30
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
|
|
31
|
+
* @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
|
|
32
|
+
* @param {{label: string, value: string, metadata: Object<string, any>?}[]} props.value - Current value of the select.
|
|
33
|
+
* @param {Function} props.onChange - Function to call when the value changes.
|
|
34
|
+
* @param {boolean} [props.clearable=false] - Whether the select is clearable.
|
|
35
|
+
* @param {boolean} [props.disabled=false] - Whether the select is disabled.
|
|
36
|
+
* @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
|
|
37
|
+
* @param {Function} [props.getLabel] - Function to get the label for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
38
|
+
* @param {Function} [props.getValue] - Function to get the value for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
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
|
+
* @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
|
|
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.getData] - Function to pre-process the fetched data before it is used in the select. `(data: Object<string, any>[]) => Object<string, any>[]`
|
|
43
|
+
* @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
|
|
44
|
+
* @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
|
|
45
|
+
* @param {Function} [props.fetchFunction] - Allows overriding the default fetch function. `fetchFunction: (url: string, fetchOptions: Object<string, any>, searchText?: string) => Promise<Object<string, any>>`
|
|
46
|
+
* @param {Function} [props.processLoadedOptions] - Allows processing the options fetched from the source. `(options: Object<string, any>[]) => Object<string, any>[]`
|
|
47
|
+
* @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
|
+
* @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
|
+
* @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 {boolean} [props.noMinWidth=false] - If `true`, the select menu will not have a minimum width.
|
|
52
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
53
|
+
*
|
|
54
|
+
* @returns {JSX.Element} The __AsyncMultiSelectNext component.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const [value, setValue] = useState(null);
|
|
58
|
+
*
|
|
59
|
+
* <__AsyncMultiSelectNext
|
|
60
|
+
* label='Select items'
|
|
61
|
+
* value={value}
|
|
62
|
+
* onChange={setValue}
|
|
63
|
+
* fetchUrl={(searchText) => `https://api.example.com/items?search=${searchText}`}
|
|
64
|
+
* getLabel={(item) => item?.label}
|
|
65
|
+
* getValue={(item) => item?.id}
|
|
66
|
+
* getIcon={() => icons.emptyCircle}
|
|
67
|
+
* />
|
|
68
|
+
*
|
|
69
|
+
* @preserve
|
|
70
|
+
*/
|
|
71
|
+
const __AsyncMultiSelectNext = (props) => {
|
|
72
|
+
const {
|
|
73
|
+
label,
|
|
74
|
+
help,
|
|
75
|
+
icon,
|
|
76
|
+
subtitle,
|
|
77
|
+
actions,
|
|
78
|
+
inline,
|
|
79
|
+
value,
|
|
80
|
+
onChange,
|
|
81
|
+
clearable,
|
|
82
|
+
disabled,
|
|
83
|
+
placeholder = __("Select...", "eightshift-ui-components"),
|
|
84
|
+
fetchUrl,
|
|
85
|
+
fetchConfig = {},
|
|
86
|
+
fetchFunction,
|
|
87
|
+
getLabel = (item) => item?.label,
|
|
88
|
+
getValue = (item) => item?.value,
|
|
89
|
+
getMeta,
|
|
90
|
+
getIcon,
|
|
91
|
+
getSubtitle,
|
|
92
|
+
getData = (data) => data,
|
|
93
|
+
customMenuOption,
|
|
94
|
+
customValueDisplay,
|
|
95
|
+
customDropdownArrow,
|
|
96
|
+
className,
|
|
97
|
+
noMinWidth,
|
|
98
|
+
hidden,
|
|
99
|
+
processLoadedOptions,
|
|
100
|
+
...rest
|
|
101
|
+
} = props;
|
|
102
|
+
const list = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
103
|
+
initialSelectedKeys: Array.isArray(value) ? value.map((item) => item?.value) : [],
|
|
104
|
+
getKey: (item) => item.value,
|
|
105
|
+
async load({ signal, filterText }) {
|
|
106
|
+
let json = [];
|
|
107
|
+
if (fetchFunction) {
|
|
108
|
+
const res = await fetchFunction(filterText, signal);
|
|
109
|
+
json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
|
|
110
|
+
} else {
|
|
111
|
+
const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
|
|
112
|
+
json = processLoadedOptions ? processLoadedOptions(getData(await res.json())) : getData(res);
|
|
113
|
+
}
|
|
114
|
+
const output = json?.map((item, index) => {
|
|
115
|
+
const id = getValue?.(item) ?? index;
|
|
116
|
+
const entry = { label: unescapeHTML(getLabel?.(item) ?? ""), value: id };
|
|
117
|
+
if (getMeta) {
|
|
118
|
+
entry.meta = getMeta(item);
|
|
119
|
+
}
|
|
120
|
+
if (getSubtitle) {
|
|
121
|
+
entry.subtitle = unescapeHTML(getSubtitle(item));
|
|
122
|
+
}
|
|
123
|
+
return entry;
|
|
124
|
+
});
|
|
125
|
+
if (filterText.length > 0) {
|
|
126
|
+
return {
|
|
127
|
+
items: output
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const extra = value?.map((val) => {
|
|
131
|
+
if (output?.find((item) => item.value === val?.value)) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return val;
|
|
135
|
+
})?.filter(Boolean) ?? [];
|
|
136
|
+
return {
|
|
137
|
+
items: [...output, ...extra]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const handleSelectionChange = (rawSelected) => {
|
|
142
|
+
const selected = list.filterText.length > 0 ? /* @__PURE__ */ new Set([...value?.map((item) => item?.value) ?? [], ...rawSelected]) : rawSelected;
|
|
143
|
+
list.filterText = "";
|
|
144
|
+
if (selected === null || selected === void 0) {
|
|
145
|
+
onChange(null);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (selected.size === 0) {
|
|
149
|
+
onChange([]);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const selectedValues = [...selected].map((item) => {
|
|
153
|
+
const option = list.items.find((option2) => option2.value === item) || value.find((option2) => option2.value === item);
|
|
154
|
+
if (!option) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
...option
|
|
159
|
+
};
|
|
160
|
+
}).filter(Boolean);
|
|
161
|
+
onChange(selectedValues);
|
|
162
|
+
};
|
|
163
|
+
const ref = useRef();
|
|
164
|
+
let { dragAndDropHooks } = $d8f176866e6dc039$export$2cfc5be7a55829f6({
|
|
165
|
+
getItems: (keys) => [...keys].map((key) => ({ "text/plain": key, text: value.find((item) => item.value === key)?.label ?? key })),
|
|
166
|
+
onReorder(e) {
|
|
167
|
+
handleSelectionChange(
|
|
168
|
+
new Set(
|
|
169
|
+
moveArrayItem(
|
|
170
|
+
value?.map((item) => item?.value),
|
|
171
|
+
[...e.keys][0],
|
|
172
|
+
e.target.key,
|
|
173
|
+
e.target.dropPosition
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
},
|
|
178
|
+
renderDragPreview(items) {
|
|
179
|
+
return /* @__PURE__ */ jsxs("div", { className: "es:bg-accent-700 es:rounded-md es:px-1.5 es:py-0.5 es:text-white es:translate-x-7 es:translate-y-6", children: [
|
|
180
|
+
truncateEnd(items[0]["text"], 20),
|
|
181
|
+
items.length > 1 && /* @__PURE__ */ jsx("span", { className: "badge", children: items.length })
|
|
182
|
+
] });
|
|
183
|
+
},
|
|
184
|
+
renderDropIndicator(target) {
|
|
185
|
+
return /* @__PURE__ */ jsx(
|
|
186
|
+
$612b8eb6cb90e02d$export$62ed72bc21f6b8a6,
|
|
187
|
+
{
|
|
188
|
+
target,
|
|
189
|
+
className: "es:w-0.75 es:h-5.5 es:rounded-md es:transition es:inset-ring-0 es:drop-target:bg-accent-600 es:bg-accent-700/30 es:any-focus:outline-hidden es:any-focus:inset-ring-0"
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
isDisabled: disabled || value.length < 2
|
|
194
|
+
});
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
if (list.selectedKeys.size !== (value ?? []).length) {
|
|
197
|
+
list.setSelectedKeys(new Set(value?.map((item) => item?.value)));
|
|
198
|
+
list.setFilterText("");
|
|
199
|
+
}
|
|
200
|
+
}, [value]);
|
|
201
|
+
if (hidden) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
return /* @__PURE__ */ jsx(
|
|
205
|
+
BaseControl,
|
|
206
|
+
{
|
|
207
|
+
label,
|
|
208
|
+
icon,
|
|
209
|
+
subtitle,
|
|
210
|
+
actions,
|
|
211
|
+
help,
|
|
212
|
+
inline,
|
|
213
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
214
|
+
...rest,
|
|
215
|
+
children: /* @__PURE__ */ jsxs(
|
|
216
|
+
$de32f1b87079253c$export$2e1e1122cf0cba88,
|
|
217
|
+
{
|
|
218
|
+
onOpenChange: (isOpen) => {
|
|
219
|
+
if (!isOpen) {
|
|
220
|
+
list.setFilterText("");
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
children: [
|
|
224
|
+
/* @__PURE__ */ jsxs(
|
|
225
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
226
|
+
{
|
|
227
|
+
"aria-label": __("Select items", "eightshift-ui-components"),
|
|
228
|
+
className: clsx(
|
|
229
|
+
"es:group",
|
|
230
|
+
"es:relative es:flex es:items-center es:gap-1 es:py-0.75 es:pl-0.75 es:pr-1.5 es:focus-visible:outline-hidden es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
|
|
231
|
+
"es:min-h-9 es:rounded-10 es:border es:border-secondary-300 es:bg-white es:text-sm es:shadow-sm es:transition",
|
|
232
|
+
"es:inset-ring es:inset-ring-secondary-100",
|
|
233
|
+
"es:any-focus:outline-hidden",
|
|
234
|
+
!noMinWidth && "es:min-w-48",
|
|
235
|
+
!inline && "es:w-full",
|
|
236
|
+
disabled && "es:select-none es:shadow-none!",
|
|
237
|
+
"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",
|
|
238
|
+
className
|
|
239
|
+
),
|
|
240
|
+
ref,
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ jsx(
|
|
243
|
+
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
244
|
+
{
|
|
245
|
+
"aria-label": __("Selected items", "eightshift-ui-components"),
|
|
246
|
+
layout: "grid",
|
|
247
|
+
items: value,
|
|
248
|
+
selectionMode: "none",
|
|
249
|
+
dependencies: [value],
|
|
250
|
+
className: "es:peer es:w-full es:flex es:items-center es:flex-wrap es:gap-0.75 es:has-dragging:inset-ring-1 es:has-dragging:inset-ring-accent-500/10 es:rounded-md es:transition es:leading-tight",
|
|
251
|
+
renderEmptyState: () => /* @__PURE__ */ jsx("div", { className: "es:text-secondary-500 es:pl-1.5 es:flex es:items-center", children: placeholder }),
|
|
252
|
+
dragAndDropHooks,
|
|
253
|
+
children: (item) => /* @__PURE__ */ jsxs(
|
|
254
|
+
$eed445e0843c11d0$export$a11e76429ed99b4,
|
|
255
|
+
{
|
|
256
|
+
id: item?.value,
|
|
257
|
+
textValue: item?.label,
|
|
258
|
+
className: clsx(
|
|
259
|
+
"es:inset-ring es:inset-ring-secondary-200/30 es:h-7 es:bg-secondary-100 es:focus-visible:inset-ring-accent-500 es:dragging:cursor-grabbing es:focus:outline-hidden es:py-1 es:px-1.5 es:rounded-7 es:dragging:inset-ring-accent-600/20 es:dragging:bg-transparent es:dragging:text-accent-600/40 es:transition es:flex es:items-center es:gap-1",
|
|
260
|
+
!disabled && value.size >= 2 && "es:cursor-move"
|
|
261
|
+
),
|
|
262
|
+
children: [
|
|
263
|
+
customValueDisplay && customValueDisplay(truncateEnd(item?.label, 20), item),
|
|
264
|
+
!customValueDisplay && /* @__PURE__ */ jsx($514c0188e459b4c0$export$5f1af8db9871e1d6, { slot: "label", children: truncateEnd(item?.label, 20) })
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsxs("div", { className: "es:shrink-0 es:ml-auto es:peer-has-dragging:hidden", children: [
|
|
271
|
+
!customDropdownArrow && cloneElement(icons.dropdownCaretAlt, {
|
|
272
|
+
className: "es:shrink-0 es:w-4 es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200"
|
|
273
|
+
}),
|
|
274
|
+
customDropdownArrow && /* @__PURE__ */ jsx(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
"aria-hidden": "true",
|
|
278
|
+
className: "es:shrink-0 es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200",
|
|
279
|
+
children: customDropdownArrow
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
] })
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
/* @__PURE__ */ jsx(
|
|
287
|
+
$07b14b47974efb58$export$5b6b19405a83ff9d,
|
|
288
|
+
{
|
|
289
|
+
"aria-label": __("Items", "eightshift-ui-components"),
|
|
290
|
+
className: ({ isEntering, isExiting }) => clsx(
|
|
291
|
+
"es:flex es:w-76 es:min-w-9 es:max-w-76 es:flex-col es:overflow-hidden es:rounded-2xl es:border es:border-secondary-200 es:bg-white es:text-sm es:shadow-xl es:inset-ring es:inset-ring-secondary-100",
|
|
292
|
+
"es:any-focus:outline-hidden",
|
|
293
|
+
"es:motion-safe:motion-duration-200 es:motion-safe:motion-ease-spring-bouncy",
|
|
294
|
+
"es:placement-bottom:origin-top-left es:placement-top:origin-bottom-left",
|
|
295
|
+
"es:placement-left:origin-right es:placement-right:origin-left",
|
|
296
|
+
isEntering && "es:motion-safe:motion-scale-in-95 es:motion-opacity-in-0",
|
|
297
|
+
isEntering && "es:motion-safe:placement-top:motion-translate-y-in-[5%] es:motion-safe:placement-bottom:motion-translate-y-in-[-5%] es:motion-safe:placement-left:motion-translate-x-in-[5%] es:motion-safe:placement-right:motion-translate-x-in-[-5%]",
|
|
298
|
+
isExiting && "es:motion-safe:motion-scale-out-95 es:motion-opacity-out-0",
|
|
299
|
+
isExiting && "es:motion-safe:placement-top:motion-translate-y-out-[5%] es:motion-safe:placement-bottom:motion-translate-y-out-[-5%] es:motion-safe:placement-left:motion-translate-x-out-[5%] es:motion-safe:placement-right:motion-translate-x-out-[-5%]"
|
|
300
|
+
),
|
|
301
|
+
placement: "bottom left",
|
|
302
|
+
maxHeight: 360,
|
|
303
|
+
triggerRef: ref,
|
|
304
|
+
children: /* @__PURE__ */ jsxs(
|
|
305
|
+
$d2f53cda644affe3$export$2f2b9559550c7bbc,
|
|
306
|
+
{
|
|
307
|
+
inputValue: list.filterText,
|
|
308
|
+
onInputChange: list.setFilterText,
|
|
309
|
+
children: [
|
|
310
|
+
/* @__PURE__ */ jsxs(
|
|
311
|
+
$440f4836bcb56932$export$b94867ecbd698f21,
|
|
312
|
+
{
|
|
313
|
+
"aria-label": __("Search", "eightshift-ui-components"),
|
|
314
|
+
className: "es:flex es:items-center es:bg-secondary-100 es:m-2 es:rounded-lg es:relative es:placeholder:text-secondary-500",
|
|
315
|
+
autoFocus: true,
|
|
316
|
+
children: [
|
|
317
|
+
/* @__PURE__ */ jsx(
|
|
318
|
+
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
319
|
+
{
|
|
320
|
+
placeholder: __("Search...", "eightshift-ui-components"),
|
|
321
|
+
className: "es:peer es:size-full es:h-9 es:outline-hidden es:shadow-none es:px-2.5 es:text-sm es:py-0 es:[&::-webkit-search-cancel-button]:hidden"
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
/* @__PURE__ */ jsx(
|
|
325
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
326
|
+
{
|
|
327
|
+
"aria-label": __("Clear", "eightshift-ui-components"),
|
|
328
|
+
className: clsx(
|
|
329
|
+
"es:absolute es:right-2 es:top-0 es:bottom-0 es:my-auto",
|
|
330
|
+
"es:flex es:size-6 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",
|
|
331
|
+
"es:peer-placeholder-shown:opacity-0"
|
|
332
|
+
),
|
|
333
|
+
children: icons.clearAlt
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
/* @__PURE__ */ jsx("div", { className: "es:w-full es:h-px es:bg-secondary-200 es:shrink-0" }),
|
|
340
|
+
list.isLoading && /* @__PURE__ */ jsx("div", { className: "es:p-3 es:min-h-16 es:flex es:items-center es:justify-center", children: cloneElement(icons.loader, { className: "es:text-accent-600! es:size-5.5 es:motion-preset-spin es:motion-duration-1500" }) }),
|
|
341
|
+
/* @__PURE__ */ jsx(
|
|
342
|
+
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
343
|
+
{
|
|
344
|
+
className: clsx("es:space-y-0.5 es:p-1 es:any-focus:outline-hidden es:min-h-16", list.isLoading && "es:hidden", list?.items?.length > 0 && "es:overflow-y-auto"),
|
|
345
|
+
items: list.items,
|
|
346
|
+
selectedKeys: list.selectedKeys,
|
|
347
|
+
selectionMode: "multiple",
|
|
348
|
+
selectionBehavior: "toggle",
|
|
349
|
+
onSelectionChange: (selected) => {
|
|
350
|
+
list.setSelectedKeys(selected);
|
|
351
|
+
handleSelectionChange(selected);
|
|
352
|
+
},
|
|
353
|
+
dependencies: [value],
|
|
354
|
+
renderEmptyState: () => /* @__PURE__ */ jsx(
|
|
355
|
+
RichLabel,
|
|
356
|
+
{
|
|
357
|
+
icon: icons.searchEmpty,
|
|
358
|
+
label: __("No results", "eightshift-ui-components"),
|
|
359
|
+
subtitle: __("Try a different search term", "eightshift-ui-components"),
|
|
360
|
+
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",
|
|
361
|
+
iconClassName: "es:text-accent-700 es:icon:size-7!",
|
|
362
|
+
noColor: true
|
|
363
|
+
}
|
|
364
|
+
),
|
|
365
|
+
children: (item) => {
|
|
366
|
+
let icon2 = getIcon ? getIcon(item) : item?.icon ?? null;
|
|
367
|
+
if (typeof item?.icon === "string") {
|
|
368
|
+
icon2 = icons?.[item.icon] ?? null;
|
|
369
|
+
}
|
|
370
|
+
return /* @__PURE__ */ jsxs(
|
|
371
|
+
OptionItemBase,
|
|
372
|
+
{
|
|
373
|
+
id: item?.value,
|
|
374
|
+
className: item?.className,
|
|
375
|
+
selectIndicator: true,
|
|
376
|
+
children: [
|
|
377
|
+
customMenuOption && customMenuOption(item),
|
|
378
|
+
!customMenuOption && /* @__PURE__ */ jsx(
|
|
379
|
+
RichLabel,
|
|
380
|
+
{
|
|
381
|
+
icon: icon2,
|
|
382
|
+
label: item?.label,
|
|
383
|
+
subtitle: item?.subtitle,
|
|
384
|
+
noColor: true
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
]
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
clearable && value.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
394
|
+
/* @__PURE__ */ jsx("div", { className: "es:w-full es:h-px es:bg-secondary-200 es:shrink-0" }),
|
|
395
|
+
/* @__PURE__ */ jsx(
|
|
396
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
397
|
+
{
|
|
398
|
+
slot: "close",
|
|
399
|
+
onPress: () => handleSelectionChange([]),
|
|
400
|
+
className: clsx(
|
|
401
|
+
"es:flex es:h-10 es:m-1 es:select-none es:items-center es:gap-1 es:rounded-xl es:px-2 es:py-1.5 es:transition es:scroll-m-1",
|
|
402
|
+
"es:any-focus:outline-hidden es:overflow-clip",
|
|
403
|
+
"es:not-selected:hover:bg-secondary-100 es:not-selected:hover:outline-hidden",
|
|
404
|
+
"es:selected:bg-accent-600/15 es:selected:text-accent-950",
|
|
405
|
+
"es:selected:focus-visible:inset-ring es:selected:focus-visible:inset-ring-accent-600/30",
|
|
406
|
+
"es:not-selected:focus-visible:bg-secondary-100 es:not-selected:focus-visible:outline-hidden",
|
|
407
|
+
"es:active:bg-accent-700/15"
|
|
408
|
+
),
|
|
409
|
+
children: /* @__PURE__ */ jsx(
|
|
410
|
+
RichLabel,
|
|
411
|
+
{
|
|
412
|
+
icon: icons.clearAlt,
|
|
413
|
+
label: __("Clear selection", "eightshift-ui-components")
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
}
|
|
417
|
+
)
|
|
418
|
+
] })
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
)
|
|
424
|
+
]
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
}
|
|
428
|
+
);
|
|
429
|
+
};
|
|
430
|
+
export {
|
|
431
|
+
__AsyncMultiSelectNext
|
|
432
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { _ as __ } from "../../../default-i18n-
|
|
2
|
+
import { _ as __ } from "../../../default-i18n-DY6EfUSA.js";
|
|
3
3
|
import { BaseControl } from "../../base-control/base-control.js";
|
|
4
|
-
import { b as $d2f53cda644affe3$export$2f2b9559550c7bbc, c as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../Separator-
|
|
5
|
-
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-
|
|
6
|
-
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../
|
|
7
|
-
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-
|
|
8
|
-
import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-
|
|
9
|
-
import { e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-
|
|
10
|
-
import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, b as $82d7e5349645de74$export$ef445b55be0601bd } from "../../../Select-
|
|
4
|
+
import { b as $d2f53cda644affe3$export$2f2b9559550c7bbc, c as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../Separator-Fl7qSeN-.js";
|
|
5
|
+
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-RTwMSBs-.js";
|
|
6
|
+
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Group-C4cXobNT.js";
|
|
7
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-DWVaNd2E.js";
|
|
8
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-BeC97FZ4.js";
|
|
9
|
+
import { e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-Xf6AsnV-.js";
|
|
10
|
+
import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, b as $82d7e5349645de74$export$ef445b55be0601bd } from "../../../Select-DEQf8ZWI.js";
|
|
11
11
|
import { useRef, useEffect, cloneElement, useContext } from "react";
|
|
12
12
|
import { icons } from "../../../icons/icons.js";
|
|
13
13
|
import "../../../react-jsx-parser.min-LF707GK8.js";
|
|
14
14
|
import { OptionItemBase } from "./shared.js";
|
|
15
15
|
import { RichLabel } from "../../rich-label/rich-label.js";
|
|
16
16
|
import { unescapeHTML } from "../../../utilities/text-helpers.js";
|
|
17
|
-
import { c as clsx } from "../../../utils-
|
|
18
|
-
import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyncList-
|
|
17
|
+
import { c as clsx } from "../../../utils-cvK1vxO7.js";
|
|
18
|
+
import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyncList-ZqaIH2gh.js";
|
|
19
19
|
/**
|
|
20
20
|
* Select menu with async loading.
|
|
21
21
|
*
|
|
@@ -38,6 +38,10 @@ import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyn
|
|
|
38
38
|
* @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
|
|
39
39
|
* @param {Function} [props.getSubtitle] - Function to get the subtitle for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
40
40
|
* @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>[]`
|
|
41
|
+
* @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
|
|
42
|
+
* @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
|
|
43
|
+
* @param {Function} [props.fetchFunction] - Allows overriding the default fetch function. `fetchFunction: (url: string, fetchOptions: Object<string, any>, searchText?: string) => Promise<Object<string, any>>`
|
|
44
|
+
* @param {Function} [props.processLoadedOptions] - Allows processing the options fetched from the source. `(options: Object<string, any>[]) => Object<string, any>[]`
|
|
41
45
|
* @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`
|
|
42
46
|
* @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`
|
|
43
47
|
* @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
|
|
@@ -81,8 +85,9 @@ const AsyncSelectNext = (props) => {
|
|
|
81
85
|
processLoadedOptions = (options) => options,
|
|
82
86
|
fetchUrl,
|
|
83
87
|
fetchConfig = {},
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
fetchFunction,
|
|
89
|
+
getLabel = (item) => item?.label,
|
|
90
|
+
getValue = (item) => item?.value,
|
|
86
91
|
getMeta,
|
|
87
92
|
getIcon,
|
|
88
93
|
getSubtitle,
|
|
@@ -94,8 +99,14 @@ const AsyncSelectNext = (props) => {
|
|
|
94
99
|
const list = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
95
100
|
getKey: (item) => item.value,
|
|
96
101
|
async load({ signal, filterText }) {
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
let json = [];
|
|
103
|
+
if (fetchFunction) {
|
|
104
|
+
const res = await fetchFunction(filterText, signal);
|
|
105
|
+
json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
|
|
106
|
+
} else {
|
|
107
|
+
const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
|
|
108
|
+
json = processLoadedOptions ? processLoadedOptions(getData(await res.json())) : getData(res);
|
|
109
|
+
}
|
|
99
110
|
const output = json?.map((item, index) => {
|
|
100
111
|
const id = getValue?.(item) ?? index;
|
|
101
112
|
const entry = { label: unescapeHTML(getLabel?.(item) ?? ""), value: id };
|