@eightshift/ui-components 5.6.1 → 6.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.
Files changed (146) hide show
  1. package/dist/{Button-CQ5ZZJ2w.js → Button-BXjXzdW_.js} +13 -13
  2. package/dist/{Dialog-BMgMUQuN.js → Dialog-D8bjn-nh.js} +404 -77
  3. package/dist/{FieldError-B8BgFmIQ.js → FieldError-DwBG6m1U.js} +2 -2
  4. package/dist/{FocusScope-B5vxRkHm.js → FocusScope-BMk5oZCk.js} +8 -8
  5. package/dist/{Heading-B5aEynOM.js → Heading-BmRX4BRL.js} +3 -3
  6. package/dist/{Hidden-rE6uR-lr.js → Hidden-Rfj-STx7.js} +4 -4
  7. package/dist/{Input-8yja_IHC.js → Input-CNNksOWg.js} +11 -11
  8. package/dist/{Label-DWVaNd2E.js → Label-D8a3eYb-.js} +4 -4
  9. package/dist/{List-BiAnh5G5.js → List-BGHOoFf0.js} +8 -8
  10. package/dist/{ListBox-DggfiuO_.js → ListBox-Dd37zMvs.js} +40 -41
  11. package/dist/{OverlayArrow-DraDOoRn.js → OverlayArrow-DokC40S3.js} +6 -6
  12. package/dist/{PortalProvider---wyKpMr.js → PortalProvider-CHPnqDSH.js} +2 -2
  13. package/dist/RadioGroup-BVFvITWO.js +371 -0
  14. package/dist/{SearchField-DWGdCvnn.js → SearchField-CHYnN-jt.js} +16 -16
  15. package/dist/{SelectionManager-B6-b5NM2.js → SelectionManager-N8X7T_4D.js} +44 -46
  16. package/dist/{SharedElementTransition-fML-zIv6.js → SharedElementTransition-BDT84GtD.js} +3 -3
  17. package/dist/{Slider-DfU6bRtH.js → Slider-CL5CM9S8.js} +23 -23
  18. package/dist/{Text-AxKZjtFm.js → Text-ztX6G1zR.js} +3 -3
  19. package/dist/{VisuallyHidden-CgnIuZJ2.js → VisuallyHidden-DTUuKFiI.js} +4 -4
  20. package/dist/assets/style-admin.css +12156 -2
  21. package/dist/assets/style-editor.css +12156 -2
  22. package/dist/assets/style.css +12162 -2
  23. package/dist/assets/wp-overrides/allow-full-width-blocks.css +6 -0
  24. package/dist/assets/wp-overrides/fix-label-text-case.css +29 -0
  25. package/dist/assets/wp-overrides/increase-sidebar-width.css +4 -0
  26. package/dist/assets/wp-overrides/make-block-messages-nicer.css +155 -0
  27. package/dist/assets/wp-overrides/replace-fonts.css +8 -0
  28. package/dist/assets/wp-overrides/restyle-tooltips.css +194 -0
  29. package/dist/assets/wp-overrides/round-corners.css +200 -0
  30. package/dist/assets/wp-overrides/unify-button-sizes.css +5 -0
  31. package/dist/clsx-DgYk2OaC.js +16 -0
  32. package/dist/{Color-WxFE7lQB.js → color-swatch-CFIuSPcO.js} +124 -6
  33. package/dist/components/animated-visibility/animated-visibility.js +25 -17
  34. package/dist/components/base-control/base-control.js +8 -5
  35. package/dist/components/base-control/container.js +204 -0
  36. package/dist/components/button/button.js +249 -155
  37. package/dist/components/checkbox/checkbox.js +96 -37
  38. package/dist/components/color-pickers/color-picker.js +16 -7
  39. package/dist/components/color-pickers/color-swatch.js +5 -57
  40. package/dist/components/color-pickers/gradient-editor.js +161 -138
  41. package/dist/components/color-pickers/solid-color-picker.js +308 -206
  42. package/dist/components/component-toggle/component-toggle.js +12 -8
  43. package/dist/components/container-panel/container-panel.js +54 -31
  44. package/dist/components/draggable/draggable-handle.js +8 -7
  45. package/dist/components/draggable/draggable.js +2 -2
  46. package/dist/components/draggable-list/draggable-list-item.js +21 -12
  47. package/dist/components/draggable-list/draggable-list.js +19 -21
  48. package/dist/components/expandable/expandable.js +56 -28
  49. package/dist/components/index.js +7 -21
  50. package/dist/components/input-field/input-field.js +112 -35
  51. package/dist/components/item-collection/item-collection.js +1 -1
  52. package/dist/components/link-input/link-input.js +181 -121
  53. package/dist/components/matrix-align/matrix-align.js +54 -20
  54. package/dist/components/menu/menu.js +26 -34
  55. package/dist/components/modal/modal.js +31 -28
  56. package/dist/components/notice/notice.js +45 -28
  57. package/dist/components/number-picker/number-picker.js +151 -101
  58. package/dist/components/option-select/option-select.js +40 -4
  59. package/dist/components/options-panel/options-panel.js +52 -25
  60. package/dist/components/placeholders/file-picker-shell.js +10 -9
  61. package/dist/components/placeholders/file-placeholder.js +14 -6
  62. package/dist/components/placeholders/image-placeholder.js +14 -4
  63. package/dist/components/placeholders/media-placeholder.js +11 -4
  64. package/dist/components/popover/popover.js +14 -11
  65. package/dist/components/portal-provider/portal-provider.js +1 -1
  66. package/dist/components/radio/radio.js +118 -429
  67. package/dist/components/repeater/repeater-item.js +7 -10
  68. package/dist/components/repeater/repeater.js +9 -15
  69. package/dist/components/responsive/mini-responsive.js +53 -61
  70. package/dist/components/responsive/responsive-legacy.js +1 -1
  71. package/dist/components/responsive/responsive.js +27 -27
  72. package/dist/components/responsive-preview/responsive-preview.js +1 -1
  73. package/dist/components/rich-label/rich-label.js +5 -5
  74. package/dist/components/select/async-multi-select.js +467 -100
  75. package/dist/components/select/{v2/async-select.js → async-select.js} +182 -105
  76. package/dist/components/select/multi-select.js +437 -83
  77. package/dist/components/select/shared.js +14 -42
  78. package/dist/components/select/single-select.js +349 -54
  79. package/dist/components/slider/column-config-slider.js +138 -45
  80. package/dist/components/slider/slider.js +265 -205
  81. package/dist/components/slider/utils.js +32 -1
  82. package/dist/components/smart-image/smart-image.js +25 -4
  83. package/dist/components/smart-image/worker-inline.js +1 -1
  84. package/dist/components/spacer/spacer.js +2 -2
  85. package/dist/components/tabs/tabs.js +370 -101
  86. package/dist/components/toggle/switch.js +174 -39
  87. package/dist/components/toggle/toggle.js +6 -3
  88. package/dist/components/toggle-button/toggle-button.js +140 -56
  89. package/dist/components/tooltip/tooltip.js +27 -26
  90. package/dist/{context-DMOmz986.js → context-BQvmiUqb.js} +3 -3
  91. package/dist/{default-i18n-DBm-GqWM.js → default-i18n-CnQeC5Pl.js} +10 -10
  92. package/dist/{general-Ck8IV7xJ.js → general-B6pOveVp.js} +11 -10
  93. package/dist/icons/icons.js +28 -9
  94. package/dist/icons/jsx-svg.js +1 -1
  95. package/dist/icons/spinner.js +3 -1
  96. package/dist/{index-Dq3gT5pW.js → index-BHpUy2Ix.js} +1 -1
  97. package/dist/{index-D8-Zjpbd.js → index-oFgxU4zs.js} +3 -3
  98. package/dist/index.js +6 -20
  99. package/dist/proxy-0B6wWuDe.js +7409 -0
  100. package/dist/{react-jsx-parser.min-VUl-CuCv.js → react-jsx-parser.min-B_hvYYa1.js} +5 -5
  101. package/dist/{Select-BvggcFOX.js → shared-DwjRce5e.js} +170 -36
  102. package/dist/{textSelection-DbCKqaw8.js → textSelection-CwHUtNVX.js} +1 -1
  103. package/dist/{useButton-v9ngEj50.js → useButton-DdZrS1Kz.js} +3 -3
  104. package/dist/{useEvent-BifIGnVS.js → useEvent-BD7Olibq.js} +1 -1
  105. package/dist/{useFilter-BlkUH1Ma.js → useFilter-bhxeEDg8.js} +1 -1
  106. package/dist/{useFocusRing-Cgm0R4Cf.js → useFocusRing-D3b7Kh4P.js} +1 -1
  107. package/dist/{useFormReset-yV9VVy9R.js → useFormReset-WUv2PdFO.js} +1 -1
  108. package/dist/{useFormValidation-CeNsUGWK.js → useFormValidation-DQeXkyLm.js} +2 -2
  109. package/dist/{useHover-BRDW3y7-.js → useHover-Bycb7BsD.js} +7 -7
  110. package/dist/{useLabel-C8umX0gk.js → useLabel-Bnv4-T24.js} +2 -2
  111. package/dist/{useLabels-Cdxi6JSa.js → useLabels-B49ptFDX.js} +1 -1
  112. package/dist/{useListState-RdLrYsMP.js → useListState-ZKhRO8ML.js} +1 -1
  113. package/dist/{useLocalizedStringFormatter-eaZiN2tE.js → useLocalizedStringFormatter-NETP-8H8.js} +1 -1
  114. package/dist/{useNumberField-D16dDfYF.js → useNumberField-D2fUHql3.js} +10 -10
  115. package/dist/{useNumberFormatter-BCmkV-7c.js → useNumberFormatter-DGvuRCn7.js} +1 -1
  116. package/dist/{usePress-DJskZBH9.js → usePress-B8OteQMu.js} +6 -6
  117. package/dist/{useSingleSelectListState-n0AVMr3Y.js → useSingleSelectListState-BBTu4shO.js} +2 -2
  118. package/dist/{useToggle-DSBDAfdw.js → useToggle-BZhaYwZl.js} +4 -4
  119. package/dist/{useToggleState-CzN79ary.js → useToggleState-VkXJjsru.js} +1 -1
  120. package/dist/utilities/general.js +1 -1
  121. package/dist/utilities/index.js +1 -1
  122. package/dist/{utils-cvK1vxO7.js → utils-DGpXyJOJ.js} +29 -42
  123. package/dist/workers/image-analysis.worker.js +3 -3
  124. package/package.json +26 -22
  125. package/dist/ColorSwatch-xVS3rMYS.js +0 -66
  126. package/dist/Select-ef7c0426.esm-CmTkSxDx.js +0 -2474
  127. package/dist/Separator-B-xeqOkC.js +0 -344
  128. package/dist/assets/wp-font-enhancements.css +0 -2
  129. package/dist/assets/wp-ui-enhancements.css +0 -2
  130. package/dist/components/select/async-single-select.js +0 -138
  131. package/dist/components/select/custom-select-default-components.js +0 -38
  132. package/dist/components/select/multi-select-components.js +0 -8
  133. package/dist/components/select/react-select-component-wrappers.js +0 -90
  134. package/dist/components/select/styles.js +0 -49
  135. package/dist/components/select/v2/async-multi-select.js +0 -432
  136. package/dist/components/select/v2/multi-select.js +0 -403
  137. package/dist/components/select/v2/shared.js +0 -69
  138. package/dist/components/select/v2/single-select.js +0 -358
  139. package/dist/index-641ee5b8.esm-DVp0njHa.js +0 -3139
  140. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  141. package/dist/multi-select-components-CT_W0Cy9.js +0 -3744
  142. package/dist/react-select-async.esm-Zl1LPaPb.js +0 -107
  143. package/dist/react-select.esm-Bu36HujU.js +0 -15
  144. package/dist/useDragAndDrop-C08ZXv4F.js +0 -3925
  145. package/dist/wp/wp-font-enhancements.js +0 -1
  146. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,14 +1,28 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useId } from "react";
3
- import { A as AsyncSelect$1 } from "../../react-select-async.esm-Zl1LPaPb.js";
4
- import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-CT_W0Cy9.js";
5
- import { r as restrictToParentElement } from "../../modifiers.esm-BuJQPI1X.js";
6
- import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator, CustomSelectDefaultMultiValueRemove } from "./custom-select-default-components.js";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { s as sprintf } from "../../sprintf-DmNrJSYG.js";
3
+ import { _ as __, a as _n } from "../../default-i18n-CnQeC5Pl.js";
7
4
  import { BaseControl } from "../base-control/base-control.js";
8
- import { eightshiftSelectClasses } from "./styles.js";
9
- import { c as components } from "../../index-641ee5b8.esm-DVp0njHa.js";
5
+ import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../SearchField-CHYnN-jt.js";
6
+ import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../Button-BXjXzdW_.js";
7
+ import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-CNNksOWg.js";
8
+ import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-D8a3eYb-.js";
9
+ import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../ListBox-Dd37zMvs.js";
10
+ import { $ as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../Dialog-D8bjn-nh.js";
11
+ import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, S as SelectClearButton, O as OptionItemBase } from "../../shared-DwjRce5e.js";
12
+ import { useRef, cloneElement } from "react";
13
+ import { icons } from "../../icons/icons.js";
14
+ import "../../react-jsx-parser.min-B_hvYYa1.js";
15
+ import { Spinner } from "../../icons/spinner.js";
16
+ import { RichLabel } from "../rich-label/rich-label.js";
17
+ import { unescapeHTML } from "../../utilities/text-helpers.js";
18
+ import { c as cva } from "../../index-BHpUy2Ix.js";
19
+ import { TriggeredPopover } from "../popover/popover.js";
20
+ import { DraggableList } from "../draggable-list/draggable-list.js";
21
+ import { DraggableListItem } from "../draggable-list/draggable-list-item.js";
22
+ import { c as clsx } from "../../clsx-DgYk2OaC.js";
23
+ import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../useAsyncList-D52mQcrH.js";
10
24
  /**
11
- * Multi-select menu with async loading and re-ordering.
25
+ * Async multi-select menu.
12
26
  *
13
27
  * @component
14
28
  * @param {Object} props - Component props.
@@ -18,45 +32,46 @@ import { c as components } from "../../index-641ee5b8.esm-DVp0njHa.js";
18
32
  * @param {string} [props.subtitle] - Subtitle of the component.
19
33
  * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
20
34
  * @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
21
- * @param {boolean|{label: string, value: string, metadata: Object<string, any>?}[]} [props.preloadOptions=true] - If `true`, the initial loading is done as soon as the component is loaded. If an array of `{label: '', value: ''}` option is provided, that is loaded immediately, dynamic fetching only happens in search. If `false`, nothing is loaded immediately, fetching only happens when an user types to search.
22
- * @param {Function<Promise>} props.loadOptions - Async function that returns an array of `{label: '', value: ''}`-formatted items. `loadOptions(searchText: string): Promise<{label: string, value: string, [metadata]: Array}[]>`.
23
35
  * @param {{label: string, value: string, metadata: Object<string, any>?}[]} props.value - Current value of the select.
24
36
  * @param {Function} props.onChange - Function to call when the value changes.
25
- * @param {boolean} [props.clearable] - Whether the select is clearable.
26
- * @param {boolean} [props.noSearch] - Whether the search is disabled.
27
- * @param {boolean} [props.disabled] - Whether the select is disabled.
28
- * @param {boolean} [props.keepMenuOpenAfterSelect] - Whether the menu stays open after an select.
37
+ * @param {boolean} [props.clearable=false] - Whether the select is clearable.
38
+ * @param {boolean} [props.disabled=false] - Whether the select is disabled.
29
39
  * @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
30
- * @param {JSX.Element} [props.customClearIndicator] - If provided, replaces the default 'Clear all' button.
40
+ * @param {Function} [props.getLabel] - Function to get the label for the item from the fetched data. `(item: Object<string, any>) => string`
41
+ * @param {Function} [props.getValue] - Function to get the value for the item from the fetched data. `(item: Object<string, any>) => string`
42
+ * @param {Function} [props.getMeta] - Function to get the metadata for the item from the fetched data. `(item: Object<string, any>) => Object<string, any>` (optional)
43
+ * @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
44
+ * @param {Function} [props.getSubtitle] - Function to get the subtitle for the item from the fetched data. `(item: Object<string, any>) => string`
45
+ * @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>[]`
46
+ * @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
47
+ * @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
48
+ * @param {Function} [props.fetchFunction] - Allows overriding the default fetch function. `fetchFunction: (url: string, fetchOptions: Object<string, any>, searchText?: string) => Promise<Object<string, any>>`
49
+ * @param {Function} [props.processLoadedOptions] - Allows processing the options fetched from the source. `(options: Object<string, any>[]) => Object<string, any>[]`
50
+ * @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`
51
+ * @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`
31
52
  * @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
32
- * @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
33
- * @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.MultiValue`).
34
- * @param {JSX.Element} [props.customValueRemove] - If provided, replaces the default item remove button (react-select's `components.MultiValueRemove`.
35
- * @param {JSX.Element} [props.customValueContainer] - If provided, replaces the default items container component (react-select's `components.MultiValueContainer`).
36
- * @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.
37
- * @param {string} [props.className] - Classes to pass to the select menu.
53
+ * @param {string} props.className - Classes to pass to the select menu.
54
+ * @param {boolean} [props.noMinWidth=false] - If `true`, the select menu will not have a minimum width.
55
+ * @param {boolean} [props.flat] - If `true`, component will look more flat. Useful for nested layer of controls.
56
+ * @param {boolean} [props.noReorder] - If `true`, the option for reordering selected items is disabled.
57
+ * @param {SelectSize} [props.size='default'] - Sets the size of the input field.
38
58
  * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
39
59
  *
60
+ * @typedef {'small' | 'medium' | 'default' | 'large'} SelectSize
61
+ *
40
62
  * @returns {JSX.Element} The AsyncMultiSelect component.
41
63
  *
42
64
  * @example
43
- * const [value, setValue] = useState([]);
44
- *
45
- * const loadOptions = async (searchText) => {
46
- * const response = await fetch(`https://api.example.com/items?q=${searchText}`);
47
- * const data = await response.json();
48
- *
49
- * return data.items.map((item) => ({
50
- * label: item.name,
51
- * value: item.id,
52
- * }));
53
- * };
65
+ * const [value, setValue] = useState(null);
54
66
  *
55
67
  * <AsyncMultiSelect
56
68
  * label='Select items'
57
- * loadOptions={loadOptions}
58
69
  * value={value}
59
70
  * onChange={setValue}
71
+ * fetchUrl={(searchText) => `https://api.example.com/items?search=${searchText}`}
72
+ * getLabel={(item) => item?.label}
73
+ * getValue={(item) => item?.id}
74
+ * getIcon={() => icons.emptyCircle}
60
75
  * />
61
76
  *
62
77
  * @preserve
@@ -69,85 +84,437 @@ const AsyncMultiSelect = (props) => {
69
84
  subtitle,
70
85
  actions,
71
86
  inline,
72
- loadOptions,
73
- preloadOptions = true,
74
- value: rawValue,
87
+ value,
75
88
  onChange,
76
- disabled = false,
77
- noSearch = false,
78
- clearable = false,
79
- keepMenuOpenAfterSelect = false,
80
- className,
81
- placeholder,
89
+ clearable,
90
+ disabled,
91
+ placeholder = __("Select...", "eightshift-ui-components"),
92
+ fetchUrl,
93
+ fetchConfig = {},
94
+ fetchFunction,
95
+ getLabel = (item) => item?.label,
96
+ getValue = (item) => item?.value,
97
+ getMeta,
98
+ getIcon,
99
+ getSubtitle,
100
+ getData = (data) => data,
82
101
  customMenuOption,
83
- customValueRemove,
84
102
  customValueDisplay,
85
103
  customDropdownArrow,
86
- customValueContainer,
87
- customClearIndicator,
88
- processLoadedOptions = (options) => options,
104
+ className,
105
+ flat,
106
+ size = "default",
107
+ noMinWidth = false,
108
+ noReorder,
89
109
  hidden,
90
- ...additionalProps
110
+ processLoadedOptions,
111
+ ...rest
91
112
  } = props;
92
- const idBase = useId();
93
- const value = rawValue.map((item, index) => ({
94
- ...item,
95
- id: item?.value ?? `${idBase}-${index}`
96
- }));
97
- const modifiedOnChange = (v) => {
98
- onChange(v?.map((item) => ({ ...item, id: void 0 })));
113
+ const list = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
114
+ initialSelectedKeys: Array.isArray(value) ? value.map((item) => item?.value) : [],
115
+ getKey: (item) => item.value,
116
+ async load({ signal, filterText }) {
117
+ let json = [];
118
+ if (fetchFunction) {
119
+ const res = await fetchFunction(filterText, signal);
120
+ json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
121
+ } else {
122
+ const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
123
+ json = processLoadedOptions ? processLoadedOptions(getData(await res.json())) : getData(res);
124
+ }
125
+ const output = json?.map((item, index) => {
126
+ const id = getValue?.(item) ?? index;
127
+ const entry = { ...item, label: unescapeHTML(getLabel?.(item) ?? ""), value: id };
128
+ if (getMeta) {
129
+ entry.meta = getMeta(item);
130
+ }
131
+ if (getSubtitle) {
132
+ entry.subtitle = unescapeHTML(getSubtitle(item));
133
+ }
134
+ return entry;
135
+ });
136
+ if (filterText.length > 0) {
137
+ return {
138
+ items: output
139
+ };
140
+ }
141
+ const extra = value?.map((val) => {
142
+ if (output?.find((item) => item.value === val?.value)) {
143
+ return null;
144
+ }
145
+ return val;
146
+ })?.filter(Boolean) ?? [];
147
+ return {
148
+ items: [...output, ...extra]
149
+ };
150
+ }
151
+ });
152
+ const handleSelectionChange = (rawSelected) => {
153
+ const selected = list.filterText.length > 0 ? /* @__PURE__ */ new Set([...value?.map((item) => item?.value) ?? [], ...rawSelected]) : rawSelected;
154
+ list.filterText = "";
155
+ if (selected === null || selected === void 0) {
156
+ onChange(null);
157
+ return;
158
+ }
159
+ if (selected.size === 0) {
160
+ onChange([]);
161
+ return;
162
+ }
163
+ const selectedValues = [...selected].map((item) => {
164
+ const option = list.items.find((option2) => option2.value === item) || value.find((option2) => option2.value === item);
165
+ if (!option) {
166
+ return null;
167
+ }
168
+ return {
169
+ ...option
170
+ };
171
+ }).filter(Boolean);
172
+ onChange(
173
+ selectedValues.map((item) => ({
174
+ label: item?.label,
175
+ value: item?.value,
176
+ subtitle: item?.subtitle,
177
+ meta: item?.meta
178
+ }))
179
+ );
99
180
  };
181
+ const ref = useRef();
182
+ const currentValueKeys = value?.map((item) => item?.value ?? item);
183
+ const selectClass = cva(
184
+ [
185
+ "es:relative",
186
+ "es:flex es:items-center es:gap-px",
187
+ "es:leading-none",
188
+ "es:rounded-lg es:hover:rounded-xl es:has-focus-visible:rounded-2xl es:group-open:rounded-2xl",
189
+ "es:transition-plus",
190
+ "es:any-focus:outline-hidden",
191
+ "es:inset-ring",
192
+ "es:has-focus-visible:ring-2 es:has-focus-visible:ring-accent-500/30",
193
+ "es:has-focus-visible:text-accent-950 es:has-focus-visible:inset-ring-accent-500",
194
+ "es:pr-8",
195
+ "es:focus:placeholder:text-surface-400",
196
+ !noMinWidth && "es:min-w-48",
197
+ !inline && "es:w-fill",
198
+ className
199
+ ],
200
+ {
201
+ variants: {
202
+ size: {
203
+ small: ["es:min-h-8", "es:px-2.5"],
204
+ medium: ["es:min-h-9", "es:px-3"],
205
+ default: ["es:min-h-10", "es:px-3"],
206
+ large: ["es:min-h-12", "es:px-4"]
207
+ },
208
+ disabled: {
209
+ false: "es:selection:bg-surface-100 es:selection:text-accent-800",
210
+ true: "es:selection:bg-secondary-200 es:selection:text-secondary-600"
211
+ }
212
+ },
213
+ compoundVariants: [
214
+ {
215
+ flat: false,
216
+ disabled: false,
217
+ class: [
218
+ "es:bg-white",
219
+ "es:bg-linear-to-b es:from-secondary-100/0 es:to-secondary-100/50 es:from-25%",
220
+ "es:hover:from-surface-100/0 es:hover:to-surface-100/50",
221
+ "es:inset-ring-secondary-400/50 es:hover:inset-ring-surface-300 es:focus:inset-ring-surface-400",
222
+ "es:inset-shadow-sm es:inset-shadow-secondary-100/50",
223
+ "es:hover:placeholder:text-surface-400",
224
+ "es:placeholder:text-secondary-400",
225
+ "es:shadow-xs es:shadow-black/5"
226
+ ]
227
+ },
228
+ {
229
+ flat: true,
230
+ disabled: false,
231
+ class: [
232
+ "es:inset-ring-secondary-100",
233
+ "es:focus:text-accent-950",
234
+ "es:placeholder:text-secondary-500/80",
235
+ "es:bg-secondary-100 es:focus:bg-surface-50",
236
+ "es:inset-ring-secondary-200/15 es:hover:inset-ring-secondary-200/65 es:focus:inset-ring-surface-200"
237
+ ]
238
+ },
239
+ { disabled: true, class: ["es:bg-secondary-50 es:inset-ring-secondary-200 es:text-secondary-400"] },
240
+ { readOnly: true, flat: false, class: ["es:bg-secondary-50 es:inset-ring-secondary-300 es:text-secondary-400"] },
241
+ { readOnly: true, flat: true, class: ["es:bg-secondary-50 es:inset-ring-secondary-300/60 es:text-secondary-400"] }
242
+ ],
243
+ defaultVariants: { disabled: false, flat: false, size: "default" }
244
+ }
245
+ );
100
246
  if (hidden) {
101
247
  return null;
102
248
  }
103
- const customLoadOptions = async (searchText) => {
104
- const results = await loadOptions(searchText);
105
- return processLoadedOptions(results?.map((item) => ({ id: item.value, ...item })) ?? []);
106
- };
107
249
  return /* @__PURE__ */ jsx(
108
- BaseControl,
250
+ $82d7e5349645de74$export$ef9b1a59e592288f,
109
251
  {
110
- label,
111
- icon,
112
- subtitle,
113
- actions,
114
- help,
115
- inline,
116
- children: /* @__PURE__ */ jsx(
117
- DndContext,
252
+ selectionMode: "multiple",
253
+ isDisabled: disabled,
254
+ value: currentValueKeys,
255
+ onChange: (selected) => handleSelectionChange(selected),
256
+ placeholder,
257
+ ...rest,
258
+ className: clsx("es:group es:w-fill", rest?.className),
259
+ children: /* @__PURE__ */ jsxs(
260
+ BaseControl,
118
261
  {
119
- modifiers: [restrictToParentElement],
120
- onDragEnd: getDragEndHandler(modifiedOnChange, value),
121
- children: /* @__PURE__ */ jsx(SortableContext, { items: value.map(({ id }) => id), children: /* @__PURE__ */ jsx(
122
- AsyncSelect$1,
123
- {
124
- isMulti: true,
125
- unstyled: true,
126
- loadOptions: customLoadOptions,
127
- defaultOptions: preloadOptions,
128
- value,
129
- onChange: modifiedOnChange,
130
- closeMenuOnSelect: !keepMenuOpenAfterSelect,
131
- isClearable: clearable,
132
- isSearchable: !noSearch,
133
- isDisabled: disabled,
134
- className,
135
- placeholder,
136
- classNames: eightshiftSelectClasses,
137
- components: {
138
- MultiValue: getMultiValue(customValueDisplay ?? components.MultiValue),
139
- MultiValueContainer: customValueContainer ?? components.MultiValueContainer,
140
- MultiValueRemove: getMultiValueRemove(customValueRemove ?? CustomSelectDefaultMultiValueRemove),
141
- Option: customMenuOption ?? components.Option,
142
- IndicatorSeparator: null,
143
- DropdownIndicator: customDropdownArrow ?? CustomSelectDefaultDropdownIndicator,
144
- ClearIndicator: customClearIndicator ?? CustomSelectDefaultClearIndicator
145
- },
146
- menuPlacement: "auto",
147
- menuPortalTarget: document.body,
148
- ...additionalProps
149
- }
150
- ) })
262
+ label,
263
+ icon,
264
+ subtitle,
265
+ actions,
266
+ help,
267
+ inline,
268
+ labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
269
+ children: [
270
+ /* @__PURE__ */ jsxs(
271
+ "div",
272
+ {
273
+ className: selectClass({ disabled, flat, size }),
274
+ ref,
275
+ children: [
276
+ /* @__PURE__ */ jsxs($d2b4bc8c273e7be6$export$353f5b6fc5456de1, { className: "es:any-focus:outline-hidden es:text-start es:size-full es:inline-block es:group es:overflow-x-clip", children: [
277
+ /* @__PURE__ */ jsx($82d7e5349645de74$export$e288731fd71264f0, { className: "es:select-none es:pointer-events-none", children: ({ isPlaceholder, selectedItems }) => {
278
+ const [selectedItem] = selectedItems;
279
+ if (!currentValueKeys?.length || isPlaceholder) {
280
+ return /* @__PURE__ */ jsx("span", { className: "es:select-none es:pointer-events-none es:pr-6 es:text-sm es:text-surface-500", children: placeholder });
281
+ }
282
+ let icon2 = getIcon ? getIcon(selectedItem) : selectedItem?.icon ?? null;
283
+ if (typeof selectedItem?.icon === "string") {
284
+ icon2 = icons?.[selectedItem.icon] ?? null;
285
+ }
286
+ if (selectedItems.length > 1) {
287
+ return /* @__PURE__ */ jsx(
288
+ RichLabel,
289
+ {
290
+ icon: icons.multiple,
291
+ label: sprintf(_n("%s item", "%s items", selectedItems.length, "eightshift-ui-components"), selectedItems.length),
292
+ subtitle: selectedItems.map((item) => item?.label ?? item).join(", "),
293
+ subtitleClassName: "es:line-clamp-1 es:max-w-56"
294
+ }
295
+ );
296
+ }
297
+ if (!isPlaceholder && value && customValueDisplay) {
298
+ return customValueDisplay(selectedItem);
299
+ }
300
+ return /* @__PURE__ */ jsx(
301
+ RichLabel,
302
+ {
303
+ icon: icon2,
304
+ label: selectedItem?.label,
305
+ subtitle: selectedItem?.subtitle,
306
+ className: clsx("es:pr-6 es:grow es:w-full", disabled && "es:grayscale es:pointer-events-none"),
307
+ iconClassName: "es:pointer-events-none es:select-none",
308
+ labelClassName: "es:line-clamp-1",
309
+ subtitleClassName: "es:line-clamp-1"
310
+ }
311
+ );
312
+ } }),
313
+ /* @__PURE__ */ jsxs(
314
+ "div",
315
+ {
316
+ className: clsx("es:absolute es:bottom-0 es:right-3 es:top-0 es:my-auto es:flex es:items-center", disabled ? "es:text-secondary-300" : "es:text-secondary-500"),
317
+ "aria-hidden": "true",
318
+ children: [
319
+ !customDropdownArrow && cloneElement(icons.dropdownCaret, {
320
+ className: "es:w-4 es:stroke-[1.2] es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200"
321
+ }),
322
+ customDropdownArrow && /* @__PURE__ */ jsx(
323
+ "div",
324
+ {
325
+ "aria-hidden": "true",
326
+ className: "es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200",
327
+ children: customDropdownArrow
328
+ }
329
+ )
330
+ ]
331
+ }
332
+ )
333
+ ] }),
334
+ clearable && /* @__PURE__ */ jsx(SelectClearButton, { multi: true }),
335
+ /* @__PURE__ */ jsxs(
336
+ TriggeredPopover,
337
+ {
338
+ "aria-label": __("Item order", "eightshift-ui-components"),
339
+ triggerButtonIcon: icons.reorder,
340
+ triggerButtonProps: {
341
+ size: "small",
342
+ type: "ghost",
343
+ className: "es:icon:opacity-80 es:size-7!",
344
+ "aria-label": __("Reorder", "eightshift-ui-components"),
345
+ tooltip: true,
346
+ slot: null
347
+ },
348
+ className: "es:grid es:grid-cols-1 es:grid-rows-[auto_minmax(0,1fr)] es:p-0!",
349
+ wrapperClassName: "es:w-72 es:px-1.5 es:h-fit es:from-surface-300/35 es:to-surface-300/35 es:overflow-clip",
350
+ hidden: noReorder || disabled || value?.length < 2,
351
+ children: [
352
+ /* @__PURE__ */ jsx("span", { className: 'es:text-lg es:mx-auto es:my-1 es:font-variation-["wdth"_140,"wght"_320] es:text-surface-600', children: __("Item order", "eightshift-ui-components") }),
353
+ /* @__PURE__ */ jsx(
354
+ DraggableList,
355
+ {
356
+ items: value,
357
+ onChange: (value2) => {
358
+ handleSelectionChange(new Set(value2?.map((item) => item?.value ?? item)));
359
+ },
360
+ className: "es:contents",
361
+ itemContainerClassName: "es:h-full es:max-h-60 es:overflow-y-auto es:pb-1.5 es:mt-0",
362
+ itemClassName: "es:z-999999",
363
+ children: (item) => {
364
+ const realItem = list.getItem(item?.value);
365
+ let icon2 = getIcon ? getIcon(realItem) : realItem?.icon ?? null;
366
+ if (typeof realItem?.icon === "string") {
367
+ icon2 = icons?.[realItem.icon] ?? null;
368
+ }
369
+ return /* @__PURE__ */ jsx(
370
+ DraggableListItem,
371
+ {
372
+ icon: icon2,
373
+ label: realItem?.label,
374
+ subtitle: realItem?.subtitle,
375
+ iconClassName: "es:pointer-events-none es:select-none",
376
+ labelClassName: "es:line-clamp-1",
377
+ subtitleClassName: "es:line-clamp-1",
378
+ className: clsx("es:min-h-8 es:flex es:items-center es:justify-between", realItem?.icon ? "es:pl-1" : "es:pl-2")
379
+ }
380
+ );
381
+ }
382
+ }
383
+ )
384
+ ]
385
+ }
386
+ )
387
+ ]
388
+ }
389
+ ),
390
+ /* @__PURE__ */ jsx(
391
+ $07b14b47974efb58$export$5b6b19405a83ff9d,
392
+ {
393
+ className: ({ isEntering, isExiting }) => clsx(
394
+ "es:w-(--trigger-width) es:min-w-72",
395
+ "es:outline-hidden",
396
+ "es:rounded-b-xl es:rounded-t-3xl",
397
+ "es:overflow-clip es:grid es:grid-cols-1",
398
+ "es:grid-rows-[auto_minmax(0,1fr)]",
399
+ "es:has-last-selected:rounded-b-20!",
400
+ "es:inset-ring es:inset-ring-surface-500/10",
401
+ "es:inset-shadow-sm es:inset-shadow-white/30",
402
+ !list?.items?.length ? "es:bg-surface-50/50" : "es:bg-surface-300/50",
403
+ !list?.items?.length ? "es:backdrop-blur-sm" : "es:backdrop-blur-md",
404
+ !list?.items?.length ? "es:backdrop-brightness-105" : "es:backdrop-brightness-110",
405
+ "es:backdrop-saturate-125",
406
+ "es:shadow-lg es:shadow-black/10",
407
+ "es:transition-plus",
408
+ "es:motion-duration-300 es:motion-ease-spring-bouncy",
409
+ "es:placement-bottom:origin-top-left es:placement-top:origin-bottom-left",
410
+ isEntering && "es:motion-scale-x-in-95 es:motion-scale-y-in-85 es:motion-opacity-in-0 es:motion-blur-in-[2px]",
411
+ isEntering && "es:placement-top:motion-translate-y-in-[0.5rem] es:placement-bottom:motion-translate-y-in-[-0.5rem]",
412
+ isExiting && "es:motion-scale-x-out-95 es:motion-scale-y-out-85 es:motion-opacity-out-0 es:motion-blur-out-xs",
413
+ isExiting && "es:placement-top:motion-translate-y-out-[0.5rem] es:placement-bottom:motion-translate-y-out-[-0.5rem]"
414
+ ),
415
+ placement: "bottom left",
416
+ maxHeight: 260,
417
+ triggerRef: ref,
418
+ children: /* @__PURE__ */ jsxs(
419
+ $d2f53cda644affe3$export$2f2b9559550c7bbc,
420
+ {
421
+ inputValue: list.filterText,
422
+ onInputChange: list.setFilterText,
423
+ children: [
424
+ /* @__PURE__ */ jsxs(
425
+ $440f4836bcb56932$export$b94867ecbd698f21,
426
+ {
427
+ "aria-label": __("Search", "eightshift-ui-components"),
428
+ className: "es:flex es:items-center es:relative",
429
+ children: [
430
+ /* @__PURE__ */ jsx(
431
+ $3985021b0ad6602f$export$f5b8910cec6cf069,
432
+ {
433
+ placeholder: __("Search...", "eightshift-ui-components"),
434
+ className: clsx(
435
+ "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",
436
+ "es:bg-accent-900/8 es:m-1.5 es:rounded-3xl es:border-none",
437
+ "es:inset-ring es:inset-ring-accent-950/7 es:focus:inset-ring-accent-950/20",
438
+ "es:text-accent-950 es:placeholder:text-accent-700/50",
439
+ "es:transition"
440
+ )
441
+ }
442
+ ),
443
+ /* @__PURE__ */ jsx(
444
+ $d2b4bc8c273e7be6$export$353f5b6fc5456de1,
445
+ {
446
+ "aria-label": __("Clear", "eightshift-ui-components"),
447
+ className: clsx(
448
+ "es:absolute es:right-3 es:top-0 es:bottom-0 es:my-auto es:border-none es:bg-transparent",
449
+ "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 es:cursor-pointer",
450
+ "es:peer-placeholder-shown:opacity-0"
451
+ ),
452
+ children: icons.clearAlt
453
+ }
454
+ )
455
+ ]
456
+ }
457
+ ),
458
+ 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, {}) }),
459
+ /* @__PURE__ */ jsx(
460
+ $eed445e0843c11d0$export$41f133550aa26f48,
461
+ {
462
+ 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"),
463
+ items: list.items,
464
+ selectedKeys: list.selectedKeys,
465
+ selectionMode: "multiple",
466
+ selectionBehavior: "toggle",
467
+ onSelectionChange: (selected) => {
468
+ list.setSelectedKeys(selected);
469
+ handleSelectionChange(selected);
470
+ },
471
+ renderEmptyState: () => /* @__PURE__ */ jsx(
472
+ RichLabel,
473
+ {
474
+ icon: icons.searchEmpty,
475
+ label: __("No results", "eightshift-ui-components"),
476
+ subtitle: __("Try a different search term", "eightshift-ui-components"),
477
+ 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",
478
+ iconClassName: "es:text-accent-700 es:icon:size-7!",
479
+ noColor: true
480
+ }
481
+ ),
482
+ children: (item) => {
483
+ let icon2 = getIcon ? getIcon(item) : item?.icon ?? null;
484
+ if (typeof item?.icon === "string") {
485
+ icon2 = icons?.[item.icon] ?? null;
486
+ }
487
+ return /* @__PURE__ */ jsxs(
488
+ OptionItemBase,
489
+ {
490
+ id: item?.value,
491
+ className: item?.className,
492
+ selectIndicator: true,
493
+ children: [
494
+ customMenuOption && customMenuOption(item),
495
+ !customMenuOption && /* @__PURE__ */ jsx(
496
+ RichLabel,
497
+ {
498
+ icon: icon2,
499
+ label: item?.label,
500
+ subtitle: item?.subtitle,
501
+ labelClassName: "es:line-clamp-1",
502
+ subtitleClassName: "es:line-clamp-1",
503
+ noColor: true
504
+ }
505
+ )
506
+ ]
507
+ }
508
+ );
509
+ }
510
+ }
511
+ )
512
+ ]
513
+ }
514
+ )
515
+ }
516
+ )
517
+ ]
151
518
  }
152
519
  )
153
520
  }