@eightshift/ui-components 5.6.0 → 6.0.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.
Files changed (150) hide show
  1. package/dist/{Button-BhEIfWLY.js → Button-BXjXzdW_.js} +13 -13
  2. package/dist/{Dialog-B8p4Ymh7.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-Bll1lQEW.js → List-BGHOoFf0.js} +8 -8
  10. package/dist/{ListBox-CEpKw7yC.js → ListBox-Dd37zMvs.js} +40 -41
  11. package/dist/{OverlayArrow-DDfa8khI.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-D6mPli0i.js → SearchField-CHYnN-jt.js} +16 -16
  15. package/dist/{SelectionManager-D77bfEbg.js → SelectionManager-N8X7T_4D.js} +44 -46
  16. package/dist/{SharedElementTransition-BjRNHsjx.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/breakpoint-preview/breakpoint-preview.js +0 -1
  37. package/dist/components/button/button.js +249 -155
  38. package/dist/components/checkbox/checkbox.js +96 -37
  39. package/dist/components/color-pickers/color-picker.js +16 -7
  40. package/dist/components/color-pickers/color-swatch.js +5 -57
  41. package/dist/components/color-pickers/gradient-editor.js +161 -138
  42. package/dist/components/color-pickers/solid-color-picker.js +308 -206
  43. package/dist/components/component-toggle/component-toggle.js +12 -8
  44. package/dist/components/container-panel/container-panel.js +54 -31
  45. package/dist/components/draggable/draggable-handle.js +8 -7
  46. package/dist/components/draggable/draggable.js +2 -2
  47. package/dist/components/draggable-list/draggable-list-item.js +21 -12
  48. package/dist/components/draggable-list/draggable-list.js +19 -21
  49. package/dist/components/expandable/expandable.js +56 -28
  50. package/dist/components/index.js +7 -21
  51. package/dist/components/input-field/input-field.js +112 -35
  52. package/dist/components/item-collection/item-collection.js +1 -1
  53. package/dist/components/link-input/link-input.js +181 -121
  54. package/dist/components/matrix-align/matrix-align.js +54 -21
  55. package/dist/components/menu/menu.js +26 -34
  56. package/dist/components/modal/modal.js +31 -28
  57. package/dist/components/notice/notice.js +45 -28
  58. package/dist/components/number-picker/number-picker.js +151 -101
  59. package/dist/components/option-select/option-select.js +40 -4
  60. package/dist/components/options-panel/options-panel.js +52 -25
  61. package/dist/components/placeholders/file-picker-shell.js +10 -10
  62. package/dist/components/placeholders/file-placeholder.js +14 -6
  63. package/dist/components/placeholders/image-placeholder.js +14 -4
  64. package/dist/components/placeholders/media-placeholder.js +11 -4
  65. package/dist/components/popover/popover.js +14 -11
  66. package/dist/components/portal-provider/portal-provider.js +1 -1
  67. package/dist/components/radio/radio.js +118 -429
  68. package/dist/components/repeater/repeater-item.js +7 -10
  69. package/dist/components/repeater/repeater.js +9 -15
  70. package/dist/components/responsive/mini-responsive.js +53 -62
  71. package/dist/components/responsive/responsive-legacy.js +1 -2
  72. package/dist/components/responsive/responsive.js +27 -28
  73. package/dist/components/responsive-preview/responsive-preview.js +1 -2
  74. package/dist/components/rich-label/rich-label.js +5 -5
  75. package/dist/components/select/async-multi-select.js +467 -100
  76. package/dist/components/select/{v2/async-select.js → async-select.js} +182 -106
  77. package/dist/components/select/multi-select.js +437 -83
  78. package/dist/components/select/shared.js +14 -42
  79. package/dist/components/select/single-select.js +349 -54
  80. package/dist/components/slider/column-config-slider.js +138 -45
  81. package/dist/components/slider/slider.js +265 -205
  82. package/dist/components/slider/utils.js +32 -1
  83. package/dist/components/smart-image/smart-image.js +27 -6
  84. package/dist/components/smart-image/worker-inline.js +1 -1
  85. package/dist/components/spacer/spacer.js +2 -2
  86. package/dist/components/tabs/tabs.js +370 -101
  87. package/dist/components/toggle/switch.js +174 -39
  88. package/dist/components/toggle/toggle.js +6 -3
  89. package/dist/components/toggle-button/toggle-button.js +140 -56
  90. package/dist/components/tooltip/tooltip.js +27 -26
  91. package/dist/{context-DMOmz986.js → context-BQvmiUqb.js} +3 -3
  92. package/dist/{default-i18n-DBm-GqWM.js → default-i18n-CnQeC5Pl.js} +10 -10
  93. package/dist/{general-6STKQIrk.js → general-B6pOveVp.js} +13 -12
  94. package/dist/icons/icons.js +28 -9
  95. package/dist/icons/jsx-svg.js +1 -1
  96. package/dist/icons/spinner.js +3 -1
  97. package/dist/{index-Dq3gT5pW.js → index-BHpUy2Ix.js} +1 -1
  98. package/dist/{index-DjyEH0Gg.js → index-oFgxU4zs.js} +6 -4
  99. package/dist/index.js +6 -20
  100. package/dist/proxy-0B6wWuDe.js +7409 -0
  101. package/dist/{react-jsx-parser.min-VUl-CuCv.js → react-jsx-parser.min-B_hvYYa1.js} +5 -5
  102. package/dist/{Select-CHzjZxXy.js → shared-DwjRce5e.js} +170 -36
  103. package/dist/{textSelection-DbCKqaw8.js → textSelection-CwHUtNVX.js} +1 -1
  104. package/dist/{useButton-B2EaQJT_.js → useButton-DdZrS1Kz.js} +3 -3
  105. package/dist/{useEvent-BifIGnVS.js → useEvent-BD7Olibq.js} +1 -1
  106. package/dist/{useFilter-BPcJ-Jzv.js → useFilter-bhxeEDg8.js} +1 -1
  107. package/dist/{useFocusRing-Cgm0R4Cf.js → useFocusRing-D3b7Kh4P.js} +1 -1
  108. package/dist/{useFormReset-yV9VVy9R.js → useFormReset-WUv2PdFO.js} +1 -1
  109. package/dist/{useFormValidation-CeNsUGWK.js → useFormValidation-DQeXkyLm.js} +2 -2
  110. package/dist/{useHover-BRDW3y7-.js → useHover-Bycb7BsD.js} +7 -7
  111. package/dist/{useLabel-C8umX0gk.js → useLabel-Bnv4-T24.js} +2 -2
  112. package/dist/{useLabels-Cdxi6JSa.js → useLabels-B49ptFDX.js} +1 -1
  113. package/dist/{useListState-DZycqxCn.js → useListState-ZKhRO8ML.js} +1 -1
  114. package/dist/{useLocalizedStringFormatter-eaZiN2tE.js → useLocalizedStringFormatter-NETP-8H8.js} +1 -1
  115. package/dist/{useNumberField-CEA9Q4w_.js → useNumberField-D2fUHql3.js} +10 -10
  116. package/dist/{useNumberFormatter-BCmkV-7c.js → useNumberFormatter-DGvuRCn7.js} +1 -1
  117. package/dist/{usePress-BCEPS3hl.js → usePress-B8OteQMu.js} +6 -6
  118. package/dist/{useSingleSelectListState-BFZEfeqI.js → useSingleSelectListState-BBTu4shO.js} +2 -2
  119. package/dist/{useToggle-DNoP2bvV.js → useToggle-BZhaYwZl.js} +4 -4
  120. package/dist/{useToggleState-CzN79ary.js → useToggleState-VkXJjsru.js} +1 -1
  121. package/dist/utilities/general.js +2 -2
  122. package/dist/utilities/hash.js +30 -0
  123. package/dist/utilities/index.js +4 -6
  124. package/dist/{utils-cvK1vxO7.js → utils-DGpXyJOJ.js} +29 -42
  125. package/dist/workers/image-analysis.worker.js +3 -3
  126. package/package.json +26 -23
  127. package/dist/ColorSwatch-xVS3rMYS.js +0 -66
  128. package/dist/Select-ef7c0426.esm-BJmjGGzK.js +0 -2474
  129. package/dist/Separator-DcqCdD4k.js +0 -344
  130. package/dist/_commonjsHelpers-BhWcALO8.js +0 -38
  131. package/dist/assets/wp-font-enhancements.css +0 -2
  132. package/dist/assets/wp-ui-enhancements.css +0 -2
  133. package/dist/components/select/async-single-select.js +0 -138
  134. package/dist/components/select/custom-select-default-components.js +0 -38
  135. package/dist/components/select/multi-select-components.js +0 -8
  136. package/dist/components/select/react-select-component-wrappers.js +0 -90
  137. package/dist/components/select/styles.js +0 -49
  138. package/dist/components/select/v2/async-multi-select.js +0 -433
  139. package/dist/components/select/v2/multi-select.js +0 -404
  140. package/dist/components/select/v2/shared.js +0 -69
  141. package/dist/components/select/v2/single-select.js +0 -358
  142. package/dist/index-641ee5b8.esm-DiwvO-RP.js +0 -3139
  143. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  144. package/dist/multi-select-components-B3KuDyYd.js +0 -3744
  145. package/dist/react-select-async.esm-_4pk-41v.js +0 -107
  146. package/dist/react-select.esm-BeuAkAyY.js +0 -15
  147. package/dist/sha256-C56UDWfQ.js +0 -533
  148. package/dist/useDragAndDrop-DUXKDS0N.js +0 -3925
  149. package/dist/wp/wp-font-enhancements.js +0 -1
  150. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,90 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { c as components } from "../../index-641ee5b8.esm-DiwvO-RP.js";
3
- /**
4
- * Custom dropdown indicator for CustomSelect.
5
- *
6
- * (a wrapper for `components.DropdownIndicator` from `react-select`)
7
- *
8
- * @param {import('react-select').DropdownIndicatorProps} props - components.DropdownIndicator props.
9
- *
10
- * @preserve
11
- */
12
- const RSDropdownIndicator = (props) => /* @__PURE__ */ jsx(components.DropdownIndicator, { ...props });
13
- /**
14
- * Custom value display for CustomSelect.
15
- *
16
- * (a wrapper for `components.SingleValue` from `react-select`)
17
- *
18
- * @param {import('react-select').SingleValueProps} props - components.SingleValue props.
19
- *
20
- * @preserve
21
- */
22
- const RSSingleValue = (props) => /* @__PURE__ */ jsx(components.SingleValue, { ...props });
23
- /**
24
- * Custom value display for multi item select.
25
- *
26
- * (a wrapper for `components.MultiValue` from `react-select`)
27
- *
28
- * @param {import('react-select').MultiValueProps} props - components.SingleValue props.
29
- *
30
- * @preserve
31
- */
32
- const RSMultiValue = (props) => /* @__PURE__ */ jsx(components.MultiValue, { ...props });
33
- /**
34
- * Custom option for CustomSelect.
35
- *
36
- * (a wrapper for `components.Option` from `react-select`)
37
- *
38
- * @param {import('react-select').OptionProps} props - components.Option props.
39
- *
40
- * @preserve
41
- */
42
- const RSOption = (props) => /* @__PURE__ */ jsx(components.Option, { ...props });
43
- /**
44
- * Custom multiple value remove button for CustomSelect.
45
- *
46
- * (a wrapper for `components.MultiValueRemove` from `react-select`)
47
- *
48
- * @param {import('react-select').MultiValueRemoveProps} props - components.MultiValueRemove props.
49
- *
50
- * @preserve
51
- */
52
- const RSMultiValueRemove = (props) => /* @__PURE__ */ jsx(components.MultiValueRemove, { ...props });
53
- /**
54
- * Custom multiple value display container for CustomSelect.
55
- *
56
- * (a wrapper for `components.MultiValueContainer` from `react-select`)
57
- *
58
- * @param {import('react-select').MultiValueGenericProps} props - components.MultiValueContainer props.
59
- *
60
- * @preserve
61
- */
62
- const RSMultiValueContainer = (props) => /* @__PURE__ */ jsx(components.MultiValueContainer, { ...props });
63
- /**
64
- * Custom multiple value display for CustomSelect.
65
- *
66
- * (a wrapper for `components.MultiValueLabel` from `react-select`)
67
- *
68
- * @param {import('react-select').MultiValueGenericProps} props - components.MultiValueLabel props.
69
- *
70
- * @preserve
71
- */
72
- const RSMultiValueLabel = (props) => /* @__PURE__ */ jsx(components.MultiValueLabel, { ...props });
73
- /**
74
- * Default clear indicator for CustomSelect.
75
- *
76
- * @param {import('react-select').ClearIndicatorProps} props - components.ClearIndicator props.
77
- *
78
- * @preserve
79
- */
80
- const RSClearIndicator = (props) => /* @__PURE__ */ jsx(components.ClearIndicator, { ...props });
81
- export {
82
- RSClearIndicator,
83
- RSDropdownIndicator,
84
- RSMultiValue,
85
- RSMultiValueContainer,
86
- RSMultiValueLabel,
87
- RSMultiValueRemove,
88
- RSOption,
89
- RSSingleValue
90
- };
@@ -1,49 +0,0 @@
1
- import { c as clsx } from "../../lite-DVmmD_-j.js";
2
- const controlStyles = {
3
- base: "es:border es:border-gray-300 es:rounded-10 es:bg-white es:text-sm es:transition es:group es:shadow-sm es:min-h-10! es:inset-ring es:inset-ring-secondary-100",
4
- focus: "es:ring-2 es:ring-accent-500/50 es:border-accent-500!"
5
- };
6
- const placeholderStyles = "es:text-gray-400 es:ml-1";
7
- const selectInputStyles = "es:any-focus:outline-hidden es:[&_input]:shadow-none! es:[&_input:focus]:shadow-none!";
8
- const valueContainerStyles = "es:gap-1 es:ml-1.25 es:my-1 es:overflow-visible!";
9
- const singleValueStyles = "es:ml-0.5 es:px-1";
10
- const multiValueStyles = clsx(
11
- "es:bg-gray-100 es:rounded-md es:py-1 es:px-1.5 es:border es:border-gray-100 hover:border-gray-300 es:items-center es:gap-1.5 es:transition es:overflow-visible es:max-w-40",
12
- "es:in-focus-visible:outline-hidden es:in-focus-visible:ring",
13
- "es:in-focus-visible:ring-accent-500/50"
14
- );
15
- const multiValueLabelStyles = "es:select-none";
16
- const multiValueRemoveStyles = "es:hover:bg-red-500/15 es:hover:text-red-900 es:text-gray-500 es:rounded es:p-0.5 es:icon:size-3.5 es:icon:stroke-[1.5] es:transition";
17
- const clearIndicatorStyles = "es:text-gray-500 es:p-1 es:rounded-md hover:bg-red-50 hover:text-red-800 es:transition";
18
- const dropdownIndicatorStyles = "es:text-gray-500 es:px-1 es:group-hover:text-black es:icon:transition-transform es:icon:duration-500 es:icon:size-5";
19
- const menuStyles = "es:rounded-2xl es:border es:border-gray-200 es:bg-white es:shadow-lg es:mt-1 es:text-sm es:overflow-x-hidden es:min-w-48";
20
- const optionStyles = {
21
- base: "es:p-2 es:flex! es:items-center es:gap-1.5 es:text-gray-800 es:rounded-xl es:icon:size-5 es:icon:text-gray-500 es:transition es:mx-1 es:first:mt-1 es:last:mb-1 es:w-auto! es:min-h-9",
22
- focus: "es:bg-gray-100 es:active:bg-accent-700/15",
23
- selected: "es:bg-accent-600/15 es:text-accent-950"
24
- };
25
- const noOptionsMessageStyles = "es:text-gray-400 es:p-4";
26
- const groupHeadingStyles = "es:ml-3 es:mt-3 es:mb-1 es:text-gray-500/80 es:empty:hidden";
27
- const groupStyles = "es:border-b es:border-b-gray-200 es:last:border-b-0";
28
- const loadingMessageStyles = "es:p-4";
29
- const eightshiftSelectClasses = {
30
- clearIndicator: () => clearIndicatorStyles,
31
- control: ({ isFocused }) => clsx(isFocused && controlStyles.focus, controlStyles.base),
32
- dropdownIndicator: () => dropdownIndicatorStyles,
33
- group: () => groupStyles,
34
- groupHeading: () => groupHeadingStyles,
35
- input: () => selectInputStyles,
36
- menu: () => menuStyles,
37
- multiValue: () => multiValueStyles,
38
- multiValueLabel: () => multiValueLabelStyles,
39
- multiValueRemove: () => multiValueRemoveStyles,
40
- noOptionsMessage: () => noOptionsMessageStyles,
41
- option: ({ isFocused, isSelected }) => clsx(isFocused && optionStyles.focus, isSelected && optionStyles.selected, optionStyles.base),
42
- placeholder: () => placeholderStyles,
43
- singleValue: () => singleValueStyles,
44
- valueContainer: () => valueContainerStyles,
45
- loadingMessage: () => loadingMessageStyles
46
- };
47
- export {
48
- eightshiftSelectClasses
49
- };
@@ -1,433 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { _ as __ } from "../../../default-i18n-DBm-GqWM.js";
3
- import { BaseControl } from "../../base-control/base-control.js";
4
- import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-D6mPli0i.js";
5
- import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-BhEIfWLY.js";
6
- import { g as $de32f1b87079253c$export$2e1e1122cf0cba88, e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-B8p4Ymh7.js";
7
- import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Input-8yja_IHC.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-CEpKw7yC.js";
10
- import { $ as $514c0188e459b4c0$export$5f1af8db9871e1d6 } from "../../../Text-AxKZjtFm.js";
11
- import { $ as $d8f176866e6dc039$export$2cfc5be7a55829f6 } from "../../../useDragAndDrop-DUXKDS0N.js";
12
- import { useRef, useEffect, cloneElement } from "react";
13
- import { icons } from "../../../icons/icons.js";
14
- import "../../../react-jsx-parser.min-VUl-CuCv.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 "../../../sha256-C56UDWfQ.js";
20
- import { moveArrayItem } from "../shared.js";
21
- import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyncList-D52mQcrH.js";
22
- /**
23
- * Async multi-select menu.
24
- *
25
- * @component
26
- * @param {Object} props - Component props.
27
- * @param {string} [props.label] - Label of the component.
28
- * @param {string} [props.help] - Help text of the component.
29
- * @param {string} [props.icon] - Icon of the component.
30
- * @param {string} [props.subtitle] - Subtitle of the component.
31
- * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
32
- * @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
33
- * @param {{label: string, value: string, metadata: Object<string, any>?}[]} props.value - Current value of the select.
34
- * @param {Function} props.onChange - Function to call when the value changes.
35
- * @param {boolean} [props.clearable=false] - Whether the select is clearable.
36
- * @param {boolean} [props.disabled=false] - Whether the select is disabled.
37
- * @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
38
- * @param {Function} [props.getLabel] - Function to get the label for the item from the fetched data. `(item: Object<string, any>) => string`
39
- * @param {Function} [props.getValue] - Function to get the value for the item from the fetched data. `(item: Object<string, any>) => string`
40
- * @param {Function} [props.getMeta] - Function to get the metadata for the item from the fetched data. `(item: Object<string, any>) => Object<string, any>` (optional)
41
- * @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
42
- * @param {Function} [props.getSubtitle] - Function to get the subtitle for the item from the fetched data. `(item: Object<string, any>) => string`
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>[]`
44
- * @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
45
- * @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
46
- * @param {Function} [props.fetchFunction] - Allows overriding the default fetch function. `fetchFunction: (url: string, fetchOptions: Object<string, any>, searchText?: string) => Promise<Object<string, any>>`
47
- * @param {Function} [props.processLoadedOptions] - Allows processing the options fetched from the source. `(options: Object<string, any>[]) => Object<string, any>[]`
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`
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`
50
- * @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
51
- * @param {string} props.className - Classes to pass to the select menu.
52
- * @param {boolean} [props.noMinWidth=false] - If `true`, the select menu will not have a minimum width.
53
- * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
54
- *
55
- * @returns {JSX.Element} The __AsyncMultiSelectNext component.
56
- *
57
- * @example
58
- * const [value, setValue] = useState(null);
59
- *
60
- * <__AsyncMultiSelectNext
61
- * label='Select items'
62
- * value={value}
63
- * onChange={setValue}
64
- * fetchUrl={(searchText) => `https://api.example.com/items?search=${searchText}`}
65
- * getLabel={(item) => item?.label}
66
- * getValue={(item) => item?.id}
67
- * getIcon={() => icons.emptyCircle}
68
- * />
69
- *
70
- * @preserve
71
- */
72
- const __AsyncMultiSelectNext = (props) => {
73
- const {
74
- label,
75
- help,
76
- icon,
77
- subtitle,
78
- actions,
79
- inline,
80
- value,
81
- onChange,
82
- clearable,
83
- disabled,
84
- placeholder = __("Select...", "eightshift-ui-components"),
85
- fetchUrl,
86
- fetchConfig = {},
87
- fetchFunction,
88
- getLabel = (item) => item?.label,
89
- getValue = (item) => item?.value,
90
- getMeta,
91
- getIcon,
92
- getSubtitle,
93
- getData = (data) => data,
94
- customMenuOption,
95
- customValueDisplay,
96
- customDropdownArrow,
97
- className,
98
- noMinWidth,
99
- hidden,
100
- processLoadedOptions,
101
- ...rest
102
- } = props;
103
- const list = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
104
- initialSelectedKeys: Array.isArray(value) ? value.map((item) => item?.value) : [],
105
- getKey: (item) => item.value,
106
- async load({ signal, filterText }) {
107
- let json = [];
108
- if (fetchFunction) {
109
- const res = await fetchFunction(filterText, signal);
110
- json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
111
- } else {
112
- const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
113
- json = processLoadedOptions ? processLoadedOptions(getData(await res.json())) : getData(res);
114
- }
115
- const output = json?.map((item, index) => {
116
- const id = getValue?.(item) ?? index;
117
- const entry = { label: unescapeHTML(getLabel?.(item) ?? ""), value: id };
118
- if (getMeta) {
119
- entry.meta = getMeta(item);
120
- }
121
- if (getSubtitle) {
122
- entry.subtitle = unescapeHTML(getSubtitle(item));
123
- }
124
- return entry;
125
- });
126
- if (filterText.length > 0) {
127
- return {
128
- items: output
129
- };
130
- }
131
- const extra = value?.map((val) => {
132
- if (output?.find((item) => item.value === val?.value)) {
133
- return null;
134
- }
135
- return val;
136
- })?.filter(Boolean) ?? [];
137
- return {
138
- items: [...output, ...extra]
139
- };
140
- }
141
- });
142
- const handleSelectionChange = (rawSelected) => {
143
- const selected = list.filterText.length > 0 ? /* @__PURE__ */ new Set([...value?.map((item) => item?.value) ?? [], ...rawSelected]) : rawSelected;
144
- list.filterText = "";
145
- if (selected === null || selected === void 0) {
146
- onChange(null);
147
- return;
148
- }
149
- if (selected.size === 0) {
150
- onChange([]);
151
- return;
152
- }
153
- const selectedValues = [...selected].map((item) => {
154
- const option = list.items.find((option2) => option2.value === item) || value.find((option2) => option2.value === item);
155
- if (!option) {
156
- return null;
157
- }
158
- return {
159
- ...option
160
- };
161
- }).filter(Boolean);
162
- onChange(selectedValues);
163
- };
164
- const ref = useRef();
165
- let { dragAndDropHooks } = $d8f176866e6dc039$export$2cfc5be7a55829f6({
166
- getItems: (keys) => [...keys].map((key) => ({ "text/plain": key, text: value.find((item) => item.value === key)?.label ?? key })),
167
- onReorder(e) {
168
- handleSelectionChange(
169
- new Set(
170
- moveArrayItem(
171
- value?.map((item) => item?.value),
172
- [...e.keys][0],
173
- e.target.key,
174
- e.target.dropPosition
175
- )
176
- )
177
- );
178
- },
179
- renderDragPreview(items) {
180
- 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: [
181
- truncateEnd(items[0]["text"], 20),
182
- items.length > 1 && /* @__PURE__ */ jsx("span", { className: "badge", children: items.length })
183
- ] });
184
- },
185
- renderDropIndicator(target) {
186
- return /* @__PURE__ */ jsx(
187
- $612b8eb6cb90e02d$export$62ed72bc21f6b8a6,
188
- {
189
- target,
190
- 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"
191
- }
192
- );
193
- },
194
- isDisabled: disabled || value.length < 2
195
- });
196
- useEffect(() => {
197
- if (list.selectedKeys.size !== (value ?? []).length) {
198
- list.setSelectedKeys(new Set(value?.map((item) => item?.value)));
199
- list.setFilterText("");
200
- }
201
- }, [value]);
202
- if (hidden) {
203
- return null;
204
- }
205
- return /* @__PURE__ */ jsx(
206
- BaseControl,
207
- {
208
- label,
209
- icon,
210
- subtitle,
211
- actions,
212
- help,
213
- inline,
214
- labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
215
- ...rest,
216
- children: /* @__PURE__ */ jsxs(
217
- $de32f1b87079253c$export$2e1e1122cf0cba88,
218
- {
219
- onOpenChange: (isOpen) => {
220
- if (!isOpen) {
221
- list.setFilterText("");
222
- }
223
- },
224
- children: [
225
- /* @__PURE__ */ jsxs(
226
- $d2b4bc8c273e7be6$export$353f5b6fc5456de1,
227
- {
228
- "aria-label": __("Select items", "eightshift-ui-components"),
229
- className: clsx(
230
- "es:group",
231
- "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",
232
- "es:min-h-9 es:rounded-10 es:border es:border-secondary-300 es:bg-white es:text-sm es:shadow-sm es:transition",
233
- "es:inset-ring es:inset-ring-secondary-100",
234
- "es:any-focus:outline-hidden",
235
- !noMinWidth && "es:min-w-48",
236
- !inline && "es:w-full",
237
- disabled && "es:select-none es:shadow-none!",
238
- "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",
239
- className
240
- ),
241
- ref,
242
- children: [
243
- /* @__PURE__ */ jsx(
244
- $eed445e0843c11d0$export$41f133550aa26f48,
245
- {
246
- "aria-label": __("Selected items", "eightshift-ui-components"),
247
- layout: "grid",
248
- items: value,
249
- selectionMode: "none",
250
- dependencies: [value],
251
- 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",
252
- renderEmptyState: () => /* @__PURE__ */ jsx("div", { className: "es:text-secondary-500 es:pl-1.5 es:flex es:items-center", children: placeholder }),
253
- dragAndDropHooks,
254
- children: (item) => /* @__PURE__ */ jsxs(
255
- $eed445e0843c11d0$export$a11e76429ed99b4,
256
- {
257
- id: item?.value,
258
- textValue: item?.label,
259
- className: clsx(
260
- "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",
261
- !disabled && value.size >= 2 && "es:cursor-move"
262
- ),
263
- children: [
264
- customValueDisplay && customValueDisplay(truncateEnd(item?.label, 20), item),
265
- !customValueDisplay && /* @__PURE__ */ jsx($514c0188e459b4c0$export$5f1af8db9871e1d6, { slot: "label", children: truncateEnd(item?.label, 20) })
266
- ]
267
- }
268
- )
269
- }
270
- ),
271
- /* @__PURE__ */ jsxs("div", { className: "es:shrink-0 es:ml-auto es:peer-has-dragging:hidden", children: [
272
- !customDropdownArrow && cloneElement(icons.dropdownCaretAlt, {
273
- className: "es:shrink-0 es:w-4 es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200"
274
- }),
275
- customDropdownArrow && /* @__PURE__ */ jsx(
276
- "div",
277
- {
278
- "aria-hidden": "true",
279
- className: "es:shrink-0 es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200",
280
- children: customDropdownArrow
281
- }
282
- )
283
- ] })
284
- ]
285
- }
286
- ),
287
- /* @__PURE__ */ jsx(
288
- $07b14b47974efb58$export$5b6b19405a83ff9d,
289
- {
290
- "aria-label": __("Items", "eightshift-ui-components"),
291
- className: ({ isEntering, isExiting }) => clsx(
292
- "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",
293
- "es:any-focus:outline-hidden",
294
- "es:motion-safe:motion-duration-200 es:motion-safe:motion-ease-spring-bouncy",
295
- "es:placement-bottom:origin-top-left es:placement-top:origin-bottom-left",
296
- "es:placement-left:origin-right es:placement-right:origin-left",
297
- isEntering && "es:motion-safe:motion-scale-in-95 es:motion-opacity-in-0",
298
- 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%]",
299
- isExiting && "es:motion-safe:motion-scale-out-95 es:motion-opacity-out-0",
300
- 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%]"
301
- ),
302
- placement: "bottom left",
303
- maxHeight: 360,
304
- triggerRef: ref,
305
- children: /* @__PURE__ */ jsxs(
306
- $d2f53cda644affe3$export$2f2b9559550c7bbc,
307
- {
308
- inputValue: list.filterText,
309
- onInputChange: list.setFilterText,
310
- children: [
311
- /* @__PURE__ */ jsxs(
312
- $440f4836bcb56932$export$b94867ecbd698f21,
313
- {
314
- "aria-label": __("Search", "eightshift-ui-components"),
315
- className: "es:flex es:items-center es:bg-secondary-100 es:m-2 es:rounded-lg es:relative es:placeholder:text-secondary-500",
316
- autoFocus: true,
317
- children: [
318
- /* @__PURE__ */ jsx(
319
- $3985021b0ad6602f$export$f5b8910cec6cf069,
320
- {
321
- placeholder: __("Search...", "eightshift-ui-components"),
322
- 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"
323
- }
324
- ),
325
- /* @__PURE__ */ jsx(
326
- $d2b4bc8c273e7be6$export$353f5b6fc5456de1,
327
- {
328
- "aria-label": __("Clear", "eightshift-ui-components"),
329
- className: clsx(
330
- "es:absolute es:right-2 es:top-0 es:bottom-0 es:my-auto",
331
- "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",
332
- "es:peer-placeholder-shown:opacity-0"
333
- ),
334
- children: icons.clearAlt
335
- }
336
- )
337
- ]
338
- }
339
- ),
340
- /* @__PURE__ */ jsx("div", { className: "es:w-full es:h-px es:bg-secondary-200 es:shrink-0" }),
341
- 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 es:motion-preset-spin es:motion-duration-1500" }) }),
342
- /* @__PURE__ */ jsx(
343
- $eed445e0843c11d0$export$41f133550aa26f48,
344
- {
345
- 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"),
346
- items: list.items,
347
- selectedKeys: list.selectedKeys,
348
- selectionMode: "multiple",
349
- selectionBehavior: "toggle",
350
- onSelectionChange: (selected) => {
351
- list.setSelectedKeys(selected);
352
- handleSelectionChange(selected);
353
- },
354
- dependencies: [value],
355
- renderEmptyState: () => /* @__PURE__ */ jsx(
356
- RichLabel,
357
- {
358
- icon: icons.searchEmpty,
359
- label: __("No results", "eightshift-ui-components"),
360
- subtitle: __("Try a different search term", "eightshift-ui-components"),
361
- 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",
362
- iconClassName: "es:text-accent-700 es:icon:size-7!",
363
- noColor: true
364
- }
365
- ),
366
- children: (item) => {
367
- let icon2 = getIcon ? getIcon(item) : item?.icon ?? null;
368
- if (typeof item?.icon === "string") {
369
- icon2 = icons?.[item.icon] ?? null;
370
- }
371
- return /* @__PURE__ */ jsxs(
372
- OptionItemBase,
373
- {
374
- id: item?.value,
375
- className: item?.className,
376
- selectIndicator: true,
377
- children: [
378
- customMenuOption && customMenuOption(item),
379
- !customMenuOption && /* @__PURE__ */ jsx(
380
- RichLabel,
381
- {
382
- icon: icon2,
383
- label: item?.label,
384
- subtitle: item?.subtitle,
385
- noColor: true
386
- }
387
- )
388
- ]
389
- }
390
- );
391
- }
392
- }
393
- ),
394
- clearable && value.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
395
- /* @__PURE__ */ jsx("div", { className: "es:w-full es:h-px es:bg-secondary-200 es:shrink-0" }),
396
- /* @__PURE__ */ jsx(
397
- $d2b4bc8c273e7be6$export$353f5b6fc5456de1,
398
- {
399
- slot: "close",
400
- onPress: () => handleSelectionChange([]),
401
- className: clsx(
402
- "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",
403
- "es:any-focus:outline-hidden es:overflow-clip",
404
- "es:not-selected:hover:bg-secondary-100 es:not-selected:hover:outline-hidden",
405
- "es:selected:bg-accent-600/15 es:selected:text-accent-950",
406
- "es:selected:focus-visible:inset-ring es:selected:focus-visible:inset-ring-accent-600/30",
407
- "es:not-selected:focus-visible:bg-secondary-100 es:not-selected:focus-visible:outline-hidden",
408
- "es:active:bg-accent-700/15"
409
- ),
410
- children: /* @__PURE__ */ jsx(
411
- RichLabel,
412
- {
413
- icon: icons.clearAlt,
414
- label: __("Clear selection", "eightshift-ui-components")
415
- }
416
- )
417
- }
418
- )
419
- ] })
420
- ]
421
- }
422
- )
423
- }
424
- )
425
- ]
426
- }
427
- )
428
- }
429
- );
430
- };
431
- export {
432
- __AsyncMultiSelectNext
433
- };