@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,46 +1,59 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useId } from "react";
3
- import { S as StateManagedSelect$1 } from "../../react-select.esm-BeuAkAyY.js";
4
- import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-B3KuDyYd.js";
5
- import { r as restrictToParentElement } from "../../modifiers.esm-BuJQPI1X.js";
6
- import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator, CustomSelectDefaultMultiValueRemove } from "./custom-select-default-components.js";
7
- import { getValue } from "./shared.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";
8
4
  import { BaseControl } from "../base-control/base-control.js";
9
- import { eightshiftSelectClasses } from "./styles.js";
10
- import { c as components } from "../../index-641ee5b8.esm-DiwvO-RP.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 { g as getValue, $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, S as SelectClearButton, O as OptionItemBase } from "../../shared-DwjRce5e.js";
12
+ import { useRef, cloneElement, isValidElement } from "react";
13
+ import { icons } from "../../icons/icons.js";
14
+ import "../../react-jsx-parser.min-B_hvYYa1.js";
15
+ import { RichLabel } from "../rich-label/rich-label.js";
16
+ import { c as cva } from "../../index-BHpUy2Ix.js";
17
+ import { TriggeredPopover } from "../popover/popover.js";
18
+ import { DraggableList } from "../draggable-list/draggable-list.js";
19
+ import { DraggableListItem } from "../draggable-list/draggable-list-item.js";
20
+ import { c as clsx } from "../../clsx-DgYk2OaC.js";
21
+ import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../useFilter-bhxeEDg8.js";
11
22
  /**
12
- * Multi-select menu with re-orderable items.
23
+ * Multi-select menu.
13
24
  *
14
25
  * @component
15
26
  * @param {Object} props - Component props.
16
- * @param {string} [props.label] - Label of the component.
17
- * @param {string} [props.help] - Help text of the component.
18
27
  * @param {string} [props.icon] - Icon of the component.
19
- * @param {string} [props.subtitle] - Subtitle of the component.
20
- * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
28
+ * @param {string} [props.help] - Help text of the component.
29
+ * @param {string} [props.label] - Label of the component.
21
30
  * @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
31
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
32
+ * @param {string} [props.subtitle] - Subtitle of the component.
22
33
  * @param {{label: string, value: string, metadata: Object<string, any>?}[]} props.options - Options to display in the select. `[{ label: string, value: string }]`.
23
- * @param {{label: string, value: string, metadata: Object<string, any>?}[]} props.value - Current value of the select.
34
+ * @param {string|{label: string, value: string, metadata: Object<string, any>?}} props.value - Current value of the select.
24
35
  * @param {Function} props.onChange - Function to call when the value changes.
25
36
  * @param {boolean} [props.simpleValue=false] - If `true`, instead of using a `{label: '', value: ''}` value type, a string is used (just the value).
26
37
  * @param {boolean} [props.clearable] - Whether the select is clearable.
27
- * @param {boolean} [props.noSearch] - Whether the search is disabled.
28
38
  * @param {boolean} [props.disabled] - Whether the select is disabled.
29
- * @param {boolean} [props.keepMenuOpenAfterSelect] - Whether the menu stays open after an select.
30
39
  * @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
31
- * @param {JSX.Element} [props.customClearIndicator] - If provided, replaces the default 'Clear all' button.
32
- * @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
33
40
  * @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
34
41
  * @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.MultiValue`).
35
- * @param {JSX.Element} [props.customValueRemove] - If provided, replaces the default item remove button (react-select's `components.MultiValueRemove`.
36
- * @param {JSX.Element} [props.customValueContainer] - If provided, replaces the default items container component (react-select's `components.MultiValueContainer`).
42
+ * @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
37
43
  * @param {string} [props.className] - Classes to pass to the select menu.
44
+ * @param {boolean} [props.noMinWidth=false] - If `true`, the select menu will not have a minimum width.
45
+ * @param {boolean} [props.searchable] - If `true`, the menu will allow searching through the options.
46
+ * @param {boolean} [props.flat] - If `true`, component will look more flat. Useful for nested layer of controls.
47
+ * @param {boolean} [props.noReorder] - If `true`, the option for reordering selected items is disabled.
48
+ * @param {SelectSize} [props.size='default'] - Sets the size of the input field.
38
49
  * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
39
50
  *
51
+ * @typedef {'small' | 'medium' | 'default' | 'large'} SelectSize
52
+ *
40
53
  * @returns {JSX.Element} The MultiSelect component.
41
54
  *
42
55
  * @example
43
- * const [value, setValue] = useState([]);
56
+ * const [value, setValue] = useState(null);
44
57
  *
45
58
  * const options = [
46
59
  * { label: 'Option 1', value: 'option-1' },
@@ -59,89 +72,430 @@ import { c as components } from "../../index-641ee5b8.esm-DiwvO-RP.js";
59
72
  */
60
73
  const MultiSelect = (props) => {
61
74
  const {
62
- label,
63
- help,
64
75
  icon,
65
- subtitle,
66
- actions,
76
+ help,
77
+ label,
67
78
  inline,
68
- value: rawValue,
79
+ actions,
80
+ subtitle,
81
+ value,
69
82
  onChange,
70
83
  options,
71
84
  simpleValue = false,
72
85
  disabled = false,
73
- noSearch = false,
74
86
  clearable = false,
75
- keepMenuOpenAfterSelect = false,
76
- placeholder,
77
- customClearIndicator,
78
- customDropdownArrow,
87
+ placeholder = __("Select...", "eightshift-ui-components"),
79
88
  customMenuOption,
80
89
  customValueDisplay,
81
- customValueRemove,
82
- customValueContainer,
90
+ customDropdownArrow,
83
91
  className,
92
+ flat,
93
+ size = "default",
94
+ noMinWidth = false,
95
+ noReorder,
96
+ searchable,
84
97
  hidden,
85
- ...additionalProps
98
+ ...rest
86
99
  } = props;
87
- const idBase = useId();
88
- const value = getValue(simpleValue, rawValue, options).map((item, index) => ({
89
- ...item,
90
- id: (simpleValue ? item : item?.value) ?? `${idBase}-${index}`
91
- }));
92
- const modifiedOnChange = (v) => {
100
+ const ref = useRef();
101
+ const { contains } = $bb77f239b46e8c72$export$3274cf84b703fff({ sensitivity: "base" });
102
+ const currentValue = getValue(simpleValue, value, options);
103
+ const currentValueKeys = value?.map((item) => item?.value ?? item);
104
+ const handleSelectionChange = (selected) => {
105
+ if (selected === null || selected === void 0) {
106
+ onChange(null);
107
+ return;
108
+ }
109
+ if (selected.size === 0) {
110
+ onChange(simpleValue ? "" : []);
111
+ return;
112
+ }
93
113
  if (simpleValue) {
94
- onChange(v?.map(({ value: value2 }) => value2));
114
+ onChange([...selected]);
95
115
  return;
96
116
  }
97
- onChange(v?.map((item) => ({ ...item, id: void 0 })));
117
+ const selectedValues = [...selected]?.map((item) => {
118
+ const option = options.find((option2) => option2.value === item);
119
+ if (!option) {
120
+ return null;
121
+ }
122
+ if (option?.icon && isValidElement(option.icon)) {
123
+ delete option.icon;
124
+ }
125
+ return {
126
+ ...option
127
+ };
128
+ })?.filter(Boolean);
129
+ onChange(
130
+ selectedValues.map((item) => ({
131
+ label: item?.label,
132
+ value: item?.value,
133
+ subtitle: item?.subtitle,
134
+ meta: item?.meta
135
+ }))
136
+ );
98
137
  };
99
138
  if (hidden) {
100
139
  return null;
101
140
  }
141
+ const selectClass = cva(
142
+ [
143
+ "es:relative",
144
+ "es:flex es:items-center es:gap-px",
145
+ "es:leading-none",
146
+ "es:rounded-lg es:hover:rounded-xl es:has-focus-visible:rounded-2xl es:group-open:rounded-2xl",
147
+ "es:transition-plus",
148
+ "es:any-focus:outline-hidden",
149
+ "es:inset-ring",
150
+ "es:has-focus-visible:ring-2 es:has-focus-visible:ring-accent-500/30",
151
+ "es:has-focus-visible:text-accent-950 es:has-focus-visible:inset-ring-accent-500",
152
+ "es:pr-8",
153
+ "es:focus:placeholder:text-surface-400",
154
+ !noMinWidth && "es:min-w-48",
155
+ !inline && "es:w-fill",
156
+ className
157
+ ],
158
+ {
159
+ variants: {
160
+ size: {
161
+ small: ["es:min-h-8", "es:px-2.5"],
162
+ medium: ["es:min-h-9", "es:px-3"],
163
+ default: ["es:min-h-10", "es:px-3"],
164
+ large: ["es:min-h-12", "es:px-4"]
165
+ },
166
+ disabled: {
167
+ false: "es:selection:bg-surface-100 es:selection:text-accent-800",
168
+ true: "es:selection:bg-secondary-200 es:selection:text-secondary-600"
169
+ }
170
+ },
171
+ compoundVariants: [
172
+ {
173
+ flat: false,
174
+ disabled: false,
175
+ class: [
176
+ "es:bg-white",
177
+ "es:bg-linear-to-b es:from-secondary-100/0 es:to-secondary-100/50 es:from-25%",
178
+ "es:hover:from-surface-100/0 es:hover:to-surface-100/50",
179
+ "es:inset-ring-secondary-400/50 es:hover:inset-ring-surface-300 es:focus:inset-ring-surface-400",
180
+ "es:inset-shadow-sm es:inset-shadow-secondary-100/50",
181
+ "es:hover:placeholder:text-surface-400",
182
+ "es:placeholder:text-secondary-400",
183
+ "es:shadow-xs es:shadow-black/5"
184
+ ]
185
+ },
186
+ {
187
+ flat: true,
188
+ disabled: false,
189
+ class: [
190
+ "es:inset-ring-secondary-100",
191
+ "es:focus:text-accent-950",
192
+ "es:placeholder:text-secondary-500/80",
193
+ "es:bg-secondary-100 es:focus:bg-surface-50",
194
+ "es:inset-ring-secondary-200/15 es:hover:inset-ring-secondary-200/65 es:focus:inset-ring-surface-200"
195
+ ]
196
+ },
197
+ { disabled: true, class: ["es:bg-secondary-50 es:inset-ring-secondary-200 es:text-secondary-400"] },
198
+ { readOnly: true, flat: false, class: ["es:bg-secondary-50 es:inset-ring-secondary-300 es:text-secondary-400"] },
199
+ { readOnly: true, flat: true, class: ["es:bg-secondary-50 es:inset-ring-secondary-300/60 es:text-secondary-400"] }
200
+ ],
201
+ defaultVariants: { disabled: false, flat: false, size: "default" }
202
+ }
203
+ );
102
204
  return /* @__PURE__ */ jsx(
103
- BaseControl,
205
+ $82d7e5349645de74$export$ef9b1a59e592288f,
104
206
  {
105
- label,
106
- icon,
107
- subtitle,
108
- actions,
109
- help,
110
- inline,
111
- children: /* @__PURE__ */ jsx(
112
- DndContext,
207
+ selectionMode: "multiple",
208
+ isDisabled: disabled,
209
+ value: currentValueKeys,
210
+ onChange: (selected) => handleSelectionChange(selected),
211
+ placeholder,
212
+ ...rest,
213
+ className: clsx("es:group es:w-fill", rest?.className),
214
+ children: /* @__PURE__ */ jsxs(
215
+ BaseControl,
113
216
  {
114
- modifiers: [restrictToParentElement],
115
- onDragEnd: getDragEndHandler(modifiedOnChange, value),
116
- children: /* @__PURE__ */ jsx(SortableContext, { items: value.map(({ id }) => id), children: /* @__PURE__ */ jsx(
117
- StateManagedSelect$1,
118
- {
119
- isMulti: true,
120
- unstyled: true,
121
- options: options.map((item) => ({ id: item.value, ...item })),
122
- value,
123
- onChange: modifiedOnChange,
124
- closeMenuOnSelect: !keepMenuOpenAfterSelect,
125
- isClearable: clearable,
126
- isSearchable: !noSearch,
127
- isDisabled: disabled,
128
- className,
129
- placeholder,
130
- classNames: eightshiftSelectClasses,
131
- components: {
132
- MultiValue: getMultiValue(customValueDisplay ?? components.MultiValue),
133
- MultiValueContainer: customValueContainer ?? components.MultiValueContainer,
134
- MultiValueRemove: getMultiValueRemove(customValueRemove ?? CustomSelectDefaultMultiValueRemove),
135
- Option: customMenuOption ?? components.Option,
136
- IndicatorSeparator: null,
137
- DropdownIndicator: customDropdownArrow ?? CustomSelectDefaultDropdownIndicator,
138
- ClearIndicator: customClearIndicator ?? CustomSelectDefaultClearIndicator
139
- },
140
- menuPlacement: "auto",
141
- menuPortalTarget: document.body,
142
- ...additionalProps
143
- }
144
- ) })
217
+ label,
218
+ icon,
219
+ subtitle,
220
+ actions,
221
+ help,
222
+ inline,
223
+ labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
224
+ children: [
225
+ /* @__PURE__ */ jsxs(
226
+ "div",
227
+ {
228
+ className: selectClass({ disabled, flat, size }),
229
+ ref,
230
+ children: [
231
+ /* @__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: [
232
+ /* @__PURE__ */ jsx($82d7e5349645de74$export$e288731fd71264f0, { className: "es:select-none es:pointer-events-none", children: ({ isPlaceholder, selectedItems }) => {
233
+ const [selectedItem] = selectedItems;
234
+ if (!currentValueKeys?.length || isPlaceholder) {
235
+ return /* @__PURE__ */ jsx("span", { className: "es:select-none es:pointer-events-none es:pr-6 es:text-sm es:text-surface-500", children: placeholder });
236
+ }
237
+ let icon2 = selectedItem?.icon ?? null;
238
+ if (typeof selectedItem?.icon === "string") {
239
+ icon2 = icons?.[selectedItem?.icon] ?? null;
240
+ }
241
+ if (selectedItems.length > 1) {
242
+ return /* @__PURE__ */ jsx(
243
+ RichLabel,
244
+ {
245
+ icon: icons.multiple,
246
+ label: sprintf(_n("%s item", "%s items", selectedItems.length, "eightshift-ui-components"), selectedItems.length),
247
+ subtitle: selectedItems.map((item) => item?.label ?? item).join(", "),
248
+ subtitleClassName: "es:line-clamp-1 es:max-w-56"
249
+ }
250
+ );
251
+ }
252
+ if (!isPlaceholder && currentValue && customValueDisplay) {
253
+ return customValueDisplay(selectedItem);
254
+ }
255
+ return /* @__PURE__ */ jsx(
256
+ RichLabel,
257
+ {
258
+ icon: icon2,
259
+ label: selectedItem?.label,
260
+ subtitle: selectedItem?.subtitle,
261
+ className: clsx("es:pr-6 es:grow es:w-full", disabled && "es:grayscale es:pointer-events-none"),
262
+ iconClassName: "es:pointer-events-none es:select-none",
263
+ labelClassName: "es:line-clamp-1",
264
+ subtitleClassName: "es:line-clamp-1"
265
+ }
266
+ );
267
+ } }),
268
+ /* @__PURE__ */ jsxs(
269
+ "div",
270
+ {
271
+ 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"),
272
+ "aria-hidden": "true",
273
+ children: [
274
+ !customDropdownArrow && cloneElement(icons.dropdownCaret, {
275
+ className: "es:w-4 es:stroke-[1.2] es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200"
276
+ }),
277
+ customDropdownArrow && /* @__PURE__ */ jsx(
278
+ "div",
279
+ {
280
+ "aria-hidden": "true",
281
+ className: "es:group-aria-expanded:-scale-y-100 es:transition-transform es:duration-200",
282
+ children: customDropdownArrow
283
+ }
284
+ )
285
+ ]
286
+ }
287
+ )
288
+ ] }),
289
+ clearable && /* @__PURE__ */ jsx(SelectClearButton, { multi: true }),
290
+ /* @__PURE__ */ jsxs(
291
+ TriggeredPopover,
292
+ {
293
+ triggerButtonIcon: icons.reorder,
294
+ triggerButtonProps: {
295
+ size: "small",
296
+ type: "ghost",
297
+ className: "es:icon:opacity-80 es:size-7!",
298
+ "aria-label": __("Reorder", "eightshift-ui-components"),
299
+ tooltip: true,
300
+ slot: null
301
+ },
302
+ className: "es:grid es:grid-cols-1 es:grid-rows-[auto_minmax(0,1fr)] es:p-0!",
303
+ wrapperClassName: "es:w-72 es:px-1.5 es:h-fit es:from-surface-300/35 es:to-surface-300/35 es:overflow-clip",
304
+ hidden: noReorder || disabled || currentValue?.length < 2,
305
+ children: [
306
+ /* @__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") }),
307
+ /* @__PURE__ */ jsx(
308
+ DraggableList,
309
+ {
310
+ items: value,
311
+ onChange: (value2) => {
312
+ handleSelectionChange(new Set(value2?.map((item) => item?.value ?? item)));
313
+ },
314
+ className: "es:contents",
315
+ itemContainerClassName: "es:h-full es:max-h-60 es:overflow-y-auto es:pb-1.5 es:mt-0",
316
+ itemClassName: "es:z-999999",
317
+ children: (item) => {
318
+ const realItem = options.find((option) => option.value === (item?.value ?? item));
319
+ return /* @__PURE__ */ jsx(
320
+ DraggableListItem,
321
+ {
322
+ icon: realItem?.icon,
323
+ label: realItem?.label,
324
+ subtitle: realItem?.subtitle,
325
+ iconClassName: "es:pointer-events-none es:select-none",
326
+ labelClassName: "es:line-clamp-1",
327
+ subtitleClassName: "es:line-clamp-1",
328
+ className: clsx("es:min-h-8 es:flex es:items-center es:justify-between", realItem?.icon ? "es:pl-1" : "es:pl-2")
329
+ }
330
+ );
331
+ }
332
+ }
333
+ )
334
+ ]
335
+ }
336
+ )
337
+ ]
338
+ }
339
+ ),
340
+ /* @__PURE__ */ jsxs(
341
+ $07b14b47974efb58$export$5b6b19405a83ff9d,
342
+ {
343
+ className: ({ isEntering, isExiting }) => clsx(
344
+ "es:w-(--trigger-width) es:min-w-72",
345
+ "es:outline-hidden",
346
+ searchable ? "es:rounded-b-xl es:rounded-t-3xl" : "es:rounded-2xl",
347
+ "es:overflow-clip es:grid es:grid-cols-1",
348
+ searchable ? "es:grid-rows-[auto_minmax(0,1fr)]" : "es:grid-rows-1",
349
+ !searchable && "es:has-first-selected:rounded-t-20!",
350
+ "es:has-last-selected:rounded-b-20!",
351
+ "es:inset-ring es:inset-ring-surface-500/10",
352
+ "es:inset-shadow-sm es:inset-shadow-white/30",
353
+ searchable && !options?.length ? "es:bg-surface-50/50" : "es:bg-surface-300/50",
354
+ searchable && !options?.length ? "es:backdrop-blur-sm" : "es:backdrop-blur-md",
355
+ searchable && !options?.length ? "es:backdrop-brightness-105" : "es:backdrop-brightness-110",
356
+ "es:backdrop-saturate-125",
357
+ "es:shadow-lg es:shadow-black/10",
358
+ "es:transition-plus",
359
+ "es:motion-duration-300 es:motion-ease-spring-bouncy",
360
+ "es:placement-bottom:origin-top-left es:placement-top:origin-bottom-left",
361
+ isEntering && "es:motion-scale-x-in-95 es:motion-scale-y-in-85 es:motion-opacity-in-0 es:motion-blur-in-[2px]",
362
+ isEntering && "es:placement-top:motion-translate-y-in-[0.5rem] es:placement-bottom:motion-translate-y-in-[-0.5rem]",
363
+ isExiting && "es:motion-scale-x-out-95 es:motion-scale-y-out-85 es:motion-opacity-out-0 es:motion-blur-out-xs",
364
+ isExiting && "es:placement-top:motion-translate-y-out-[0.5rem] es:placement-bottom:motion-translate-y-out-[-0.5rem]"
365
+ ),
366
+ placement: "bottom left",
367
+ maxHeight: 260,
368
+ triggerRef: ref,
369
+ children: [
370
+ searchable && /* @__PURE__ */ jsxs($d2f53cda644affe3$export$2f2b9559550c7bbc, { filter: contains, children: [
371
+ /* @__PURE__ */ jsxs(
372
+ $440f4836bcb56932$export$b94867ecbd698f21,
373
+ {
374
+ "aria-label": __("Search", "eightshift-ui-components"),
375
+ className: "es:flex es:items-center es:relative",
376
+ autoFocus: true,
377
+ children: [
378
+ /* @__PURE__ */ jsx(
379
+ $3985021b0ad6602f$export$f5b8910cec6cf069,
380
+ {
381
+ placeholder: __("Search...", "eightshift-ui-components"),
382
+ className: clsx(
383
+ "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",
384
+ "es:bg-accent-900/8 es:m-1.5 es:rounded-3xl es:border-none",
385
+ "es:inset-ring es:inset-ring-accent-950/7 es:focus:inset-ring-accent-950/20",
386
+ "es:text-accent-950 es:placeholder:text-accent-700/50",
387
+ "es:transition"
388
+ )
389
+ }
390
+ ),
391
+ /* @__PURE__ */ jsx(
392
+ $d2b4bc8c273e7be6$export$353f5b6fc5456de1,
393
+ {
394
+ "aria-label": __("Clear", "eightshift-ui-components"),
395
+ className: clsx(
396
+ "es:absolute es:right-3 es:top-0 es:bottom-0 es:my-auto es:border-none es:bg-transparent",
397
+ "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",
398
+ "es:peer-placeholder-shown:opacity-0"
399
+ ),
400
+ children: icons.clearAlt
401
+ }
402
+ )
403
+ ]
404
+ }
405
+ ),
406
+ /* @__PURE__ */ jsx(
407
+ $eed445e0843c11d0$export$41f133550aa26f48,
408
+ {
409
+ className: "es:space-y-0.75 es:p-1.5 es:pt-0 es:any-focus:outline-hidden es:h-full es:overflow-y-auto es:rounded-t-xl",
410
+ items: options,
411
+ renderEmptyState: () => /* @__PURE__ */ jsx(
412
+ RichLabel,
413
+ {
414
+ icon: icons.searchEmpty,
415
+ label: __("No results", "eightshift-ui-components"),
416
+ subtitle: __("Try a different search term", "eightshift-ui-components"),
417
+ 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",
418
+ iconClassName: "es:text-accent-700 es:icon:size-7!",
419
+ noColor: true
420
+ }
421
+ ),
422
+ children: (item) => {
423
+ let icon2 = item?.icon ?? null;
424
+ if (typeof item?.icon === "string") {
425
+ icon2 = icons?.[item.icon] ?? null;
426
+ }
427
+ return /* @__PURE__ */ jsxs(
428
+ OptionItemBase,
429
+ {
430
+ id: item.value,
431
+ className: item?.className,
432
+ selectIndicator: true,
433
+ children: [
434
+ customMenuOption && customMenuOption(item),
435
+ !customMenuOption && /* @__PURE__ */ jsx(
436
+ RichLabel,
437
+ {
438
+ icon: icon2,
439
+ label: item?.label,
440
+ subtitle: item?.subtitle,
441
+ noColor: true
442
+ }
443
+ )
444
+ ]
445
+ }
446
+ );
447
+ }
448
+ }
449
+ )
450
+ ] }),
451
+ !searchable && /* @__PURE__ */ jsx(
452
+ $eed445e0843c11d0$export$41f133550aa26f48,
453
+ {
454
+ className: "es:space-y-0.75 es:p-1.5 es:any-focus:outline-hidden es:h-full es:overflow-y-auto es:rounded-t-xl",
455
+ items: options,
456
+ renderEmptyState: () => /* @__PURE__ */ jsx(
457
+ RichLabel,
458
+ {
459
+ icon: icons.searchEmpty,
460
+ label: __("No results", "eightshift-ui-components"),
461
+ subtitle: __("Try a different search term", "eightshift-ui-components"),
462
+ 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",
463
+ iconClassName: "es:text-accent-700 es:icon:size-7!",
464
+ noColor: true
465
+ }
466
+ ),
467
+ children: (item) => {
468
+ let icon2 = item?.icon ?? null;
469
+ if (typeof item?.icon === "string") {
470
+ icon2 = icons?.[item.icon] ?? null;
471
+ }
472
+ return /* @__PURE__ */ jsxs(
473
+ OptionItemBase,
474
+ {
475
+ id: item.value,
476
+ className: item?.className,
477
+ selectIndicator: true,
478
+ children: [
479
+ customMenuOption && customMenuOption(item),
480
+ !customMenuOption && /* @__PURE__ */ jsx(
481
+ RichLabel,
482
+ {
483
+ icon: icon2,
484
+ label: item?.label,
485
+ subtitle: item?.subtitle,
486
+ noColor: true
487
+ }
488
+ )
489
+ ]
490
+ }
491
+ );
492
+ }
493
+ }
494
+ )
495
+ ]
496
+ }
497
+ )
498
+ ]
145
499
  }
146
500
  )
147
501
  }
@@ -1,44 +1,16 @@
1
- /**
2
- * Handles getting the current value.
3
- *
4
- * @param {boolean} simpleValue - Whether `simpleValue` is set.
5
- * @param {string|{label: string, value: string, metadata: Object<string, any>[]}} value - Current value.
6
- * @param {{label: string, value: string}[]} options - Options passed to the component.
7
- *
8
- * @returns Appropriate output for the given input combination.
9
- *
10
- * @preserve
11
- */
12
- const getValue = (simpleValue, value, options) => {
13
- if (Array.isArray(value)) {
14
- if (simpleValue) {
15
- return value.map((value2) => options?.find(({ value: itemValue }) => itemValue === value2));
16
- }
17
- return value;
18
- }
19
- if (simpleValue) {
20
- return options?.find(({ value: itemValue }) => itemValue === value);
21
- }
22
- return value;
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
- };
1
+ import "react/jsx-runtime";
2
+ import "../../default-i18n-CnQeC5Pl.js";
3
+ import "../../Button-BXjXzdW_.js";
4
+ import "../../ListBox-Dd37zMvs.js";
5
+ import { O, S, g, m } from "../../shared-DwjRce5e.js";
6
+ import "../../icons/icons.js";
7
+ import "react";
8
+ import "../../react-jsx-parser.min-B_hvYYa1.js";
9
+ import "../animated-visibility/animated-visibility.js";
10
+ import "../../clsx-DgYk2OaC.js";
41
11
  export {
42
- getValue,
43
- moveArrayItem
12
+ O as OptionItemBase,
13
+ S as SelectClearButton,
14
+ g as getValue,
15
+ m as moveArrayItem
44
16
  };