@eightshift/ui-components 5.0.0 → 5.0.2

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 (144) hide show
  1. package/dist/Button-BpwTmkAe.js +185 -0
  2. package/dist/Collection-n5d0zIgb.js +2398 -0
  3. package/dist/Color-lVhk8V_G.js +2452 -0
  4. package/dist/ColorSwatch-DntWEAC3.js +64 -0
  5. package/dist/ComboBox-BJpTEATT.js +1915 -0
  6. package/dist/Dialog-O9uw63D7.js +2317 -0
  7. package/dist/FieldError-DHrSdE_Q.js +42 -0
  8. package/dist/FocusScope-BEPI2m7u.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-DDPhPPTQ.js +48 -0
  11. package/dist/Heading-ba38ScjJ.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input-BmDS8Juy.js +133 -0
  14. package/dist/Label-JS_ob-kh.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-BTxlCGcc.js +664 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-5aDgmImj.js +637 -0
  19. package/dist/RSPContexts-2lR5GG9p.js +14 -0
  20. package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
  21. package/dist/Separator-CaTBkETC.js +332 -0
  22. package/dist/Slider-C-S1oEH9.js +853 -0
  23. package/dist/Text-BuJgePCv.js +16 -0
  24. package/dist/VisuallyHidden-BYi0pekx.js +48 -0
  25. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  26. package/dist/assets/index.css +57 -0
  27. package/dist/assets/style-admin.css +5908 -0
  28. package/dist/assets/style-editor.css +5908 -0
  29. package/dist/assets/style.css +5914 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +396 -0
  32. package/dist/components/animated-visibility/animated-visibility.js +105 -0
  33. package/dist/components/base-control/base-control.js +86 -0
  34. package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
  35. package/dist/components/button/button.js +387 -0
  36. package/dist/components/checkbox/checkbox.js +323 -0
  37. package/dist/components/color-pickers/color-picker.js +272 -0
  38. package/dist/components/color-pickers/color-swatch.js +59 -0
  39. package/dist/components/color-pickers/gradient-editor.js +534 -0
  40. package/dist/components/color-pickers/solid-color-picker.js +1567 -0
  41. package/dist/components/component-toggle/component-toggle.js +161 -0
  42. package/dist/components/container-panel/container-panel.js +131 -0
  43. package/dist/components/draggable/draggable-context.js +5 -0
  44. package/dist/components/draggable/draggable-handle.js +46 -0
  45. package/dist/components/draggable/draggable.js +7320 -0
  46. package/dist/components/draggable-list/draggable-list-context.js +5 -0
  47. package/dist/components/draggable-list/draggable-list-item.js +77 -0
  48. package/dist/components/draggable-list/draggable-list.js +151 -0
  49. package/dist/components/expandable/expandable.js +342 -0
  50. package/dist/components/index.js +137 -0
  51. package/dist/components/input-field/input-field.js +231 -0
  52. package/dist/components/item-collection/item-collection.js +59 -0
  53. package/dist/components/layout/hstack.js +30 -0
  54. package/dist/components/layout/vstack.js +30 -0
  55. package/dist/components/link-input/link-input.js +284 -0
  56. package/dist/components/matrix-align/matrix-align.js +134 -0
  57. package/dist/components/menu/menu.js +285 -0
  58. package/dist/components/modal/modal.js +305 -0
  59. package/dist/components/notice/notice.js +123 -0
  60. package/dist/components/number-picker/number-picker.js +292 -0
  61. package/dist/components/option-select/option-select.js +264 -0
  62. package/dist/components/options-panel/options-panel.js +158 -0
  63. package/dist/components/placeholders/file-placeholder.js +42 -0
  64. package/dist/components/placeholders/image-placeholder.js +88 -0
  65. package/dist/components/placeholders/media-placeholder.js +63 -0
  66. package/dist/components/popover/popover.js +207 -0
  67. package/dist/components/radio/radio.js +582 -0
  68. package/dist/components/repeater/repeater-context.js +5 -0
  69. package/dist/components/repeater/repeater-item.js +119 -0
  70. package/dist/components/repeater/repeater.js +280 -0
  71. package/dist/components/responsive/mini-responsive.js +498 -0
  72. package/dist/components/responsive/responsive-legacy.js +343 -0
  73. package/dist/components/responsive/responsive.js +583 -0
  74. package/dist/components/responsive-preview/responsive-preview.js +123 -0
  75. package/dist/components/rich-label/rich-label.js +66 -0
  76. package/dist/components/select/async-multi-select.js +157 -0
  77. package/dist/components/select/async-single-select.js +137 -0
  78. package/dist/components/select/custom-select-default-components.js +38 -0
  79. package/dist/components/select/multi-select-components.js +8 -0
  80. package/dist/components/select/multi-select.js +151 -0
  81. package/dist/components/select/react-select-component-wrappers.js +90 -0
  82. package/dist/components/select/shared.js +26 -0
  83. package/dist/components/select/single-select.js +131 -0
  84. package/dist/components/select/styles.js +49 -0
  85. package/dist/components/select/v2/async-select.js +297 -0
  86. package/dist/components/select/v2/shared.js +24 -0
  87. package/dist/components/select/v2/single-select.js +1004 -0
  88. package/dist/components/slider/column-config-slider.js +210 -0
  89. package/dist/components/slider/slider.js +345 -0
  90. package/dist/components/slider/utils.js +94 -0
  91. package/dist/components/spacer/spacer.js +97 -0
  92. package/dist/components/tabs/tabs.js +703 -0
  93. package/dist/components/toggle/switch.js +156 -0
  94. package/dist/components/toggle/toggle.js +64 -0
  95. package/dist/components/toggle-button/toggle-button.js +343 -0
  96. package/dist/components/tooltip/tooltip.js +527 -0
  97. package/dist/context-BbYZoHvX.js +92 -0
  98. package/dist/default-i18n-CT_oS1Fy.js +922 -0
  99. package/dist/filterDOMProps-EDDcM64A.js +28 -0
  100. package/dist/icons/block-icon.js +42 -0
  101. package/dist/icons/generic-color-swatch.js +113 -0
  102. package/dist/icons/icons.js +30495 -0
  103. package/dist/icons/index.js +11 -0
  104. package/dist/icons/jsx-svg.js +50 -0
  105. package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
  106. package/dist/index-BljRBEr_.js +44 -0
  107. package/dist/index-CFozsmNS.js +28321 -0
  108. package/dist/index.js +139 -0
  109. package/dist/lite-DVmmD_-j.js +7 -0
  110. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  111. package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
  112. package/dist/number-GajL10e1.js +36 -0
  113. package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
  114. package/dist/react-select-async.esm-D937XTWW.js +107 -0
  115. package/dist/react-select.esm-Ciai3aKf.js +15 -0
  116. package/dist/style-admin.js +1 -0
  117. package/dist/style-editor.js +1 -0
  118. package/dist/style.js +1 -0
  119. package/dist/textSelection-8DpK8fJl.js +46 -0
  120. package/dist/useButton-Bt3BffJm.js +50 -0
  121. package/dist/useEvent-ICdlokG-.js +23 -0
  122. package/dist/useFocusRing-Bv0UJQl8.js +107 -0
  123. package/dist/useFormReset-D2YaWRIA.js +22 -0
  124. package/dist/useFormValidation-Dy0PXJg5.js +224 -0
  125. package/dist/useHover-C2SkI1Fn.js +895 -0
  126. package/dist/useLabel-BPCd5c7-.js +27 -0
  127. package/dist/useLabels-B7-lUnAF.js +23 -0
  128. package/dist/useListState-DkyH7elT.js +168 -0
  129. package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
  130. package/dist/useNumberField-CU1_u8ze.js +1215 -0
  131. package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
  132. package/dist/usePress-BrJylgPR.js +688 -0
  133. package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
  134. package/dist/useToggle-CDa3YAZI.js +59 -0
  135. package/dist/useToggleState-ibcBUHnB.js +19 -0
  136. package/dist/utilities/array-helpers.js +56 -0
  137. package/dist/utilities/debounce-throttle.js +123 -0
  138. package/dist/utilities/es-dash.js +382 -0
  139. package/dist/utilities/index.js +27 -0
  140. package/dist/utilities/text-helpers.js +136 -0
  141. package/dist/utils-CZt7LCbO.js +403 -0
  142. package/dist/wp/wp-font-enhancements.js +1 -0
  143. package/dist/wp/wp-ui-enhancements.js +1 -0
  144. package/package.json +24 -24
@@ -0,0 +1,151 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { S as StateManagedSelect$1 } from "../../react-select.esm-Ciai3aKf.js";
4
+ import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-Sp-JEFEX.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";
8
+ import { BaseControl } from "../base-control/base-control.js";
9
+ import { eightshiftSelectClasses } from "./styles.js";
10
+ import { c as components } from "../../index-641ee5b8.esm-BPU8rMZr.js";
11
+ /**
12
+ * Multi-select menu with re-orderable items.
13
+ *
14
+ * @component
15
+ * @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
+ * @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.
21
+ * @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
22
+ * @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.
24
+ * @param {Function} props.onChange - Function to call when the value changes.
25
+ * @param {boolean} [props.simpleValue=false] - If `true`, instead of using a `{label: '', value: ''}` value type, a string is used (just the value).
26
+ * @param {boolean} [props.clearable] - Whether the select is clearable.
27
+ * @param {boolean} [props.noSearch] - Whether the search is disabled.
28
+ * @param {boolean} [props.disabled] - Whether the select is disabled.
29
+ * @param {boolean} [props.keepMenuOpenAfterSelect] - Whether the menu stays open after an select.
30
+ * @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
+ * @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
34
+ * @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`).
37
+ * @param {string} [props.className] - Classes to pass to the select menu.
38
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
39
+ *
40
+ * @returns {JSX.Element} The MultiSelect component.
41
+ *
42
+ * @example
43
+ * const [value, setValue] = useState([]);
44
+ *
45
+ * const options = [
46
+ * { label: 'Option 1', value: 'option-1' },
47
+ * { label: 'Option 2', value: 'option-2' },
48
+ * { label: 'Option 3', value: 'option-3' },
49
+ * ];
50
+ *
51
+ * <MultiSelect
52
+ * label='Select items'
53
+ * options={loadOptions}
54
+ * value={value}
55
+ * onChange={setValue}
56
+ * />
57
+ *
58
+ * @preserve
59
+ */
60
+ const MultiSelect = (props) => {
61
+ const {
62
+ label,
63
+ help,
64
+ icon,
65
+ subtitle,
66
+ actions,
67
+ inline,
68
+ value: rawValue,
69
+ onChange,
70
+ options,
71
+ simpleValue = false,
72
+ disabled = false,
73
+ noSearch = false,
74
+ clearable = false,
75
+ keepMenuOpenAfterSelect = false,
76
+ placeholder,
77
+ customClearIndicator,
78
+ customDropdownArrow,
79
+ customMenuOption,
80
+ customValueDisplay,
81
+ customValueRemove,
82
+ customValueContainer,
83
+ className,
84
+ hidden,
85
+ ...additionalProps
86
+ } = props;
87
+ const idBase = useId();
88
+ const value = getValue(simpleValue, rawValue, options).map((item, index) => ({
89
+ ...item,
90
+ id: (simpleValue ? item : item == null ? void 0 : item.value) ?? `${idBase}-${index}`
91
+ }));
92
+ const modifiedOnChange = (v) => {
93
+ if (simpleValue) {
94
+ onChange(v == null ? void 0 : v.map(({ value: value2 }) => value2));
95
+ return;
96
+ }
97
+ onChange(v == null ? void 0 : v.map((item) => ({ ...item, id: void 0 })));
98
+ };
99
+ if (hidden) {
100
+ return null;
101
+ }
102
+ return /* @__PURE__ */ jsx(
103
+ BaseControl,
104
+ {
105
+ label,
106
+ icon,
107
+ subtitle,
108
+ actions,
109
+ help,
110
+ inline,
111
+ children: /* @__PURE__ */ jsx(
112
+ DndContext,
113
+ {
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
+ menuPortalTarget: document.body,
141
+ ...additionalProps
142
+ }
143
+ ) })
144
+ }
145
+ )
146
+ }
147
+ );
148
+ };
149
+ export {
150
+ MultiSelect
151
+ };
@@ -0,0 +1,90 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c as components } from "../../index-641ee5b8.esm-BPU8rMZr.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
+ };
@@ -0,0 +1,26 @@
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 == null ? void 0 : options.find(({ value: itemValue }) => itemValue === value2));
16
+ }
17
+ return value;
18
+ }
19
+ if (simpleValue) {
20
+ return options == null ? void 0 : options.find(({ value: itemValue }) => itemValue === value);
21
+ }
22
+ return value;
23
+ };
24
+ export {
25
+ getValue
26
+ };
@@ -0,0 +1,131 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { S as StateManagedSelect$1 } from "../../react-select.esm-Ciai3aKf.js";
3
+ import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator } from "./custom-select-default-components.js";
4
+ import { getValue } from "./shared.js";
5
+ import { BaseControl } from "../base-control/base-control.js";
6
+ import { eightshiftSelectClasses } from "./styles.js";
7
+ import { c as components } from "../../index-641ee5b8.esm-BPU8rMZr.js";
8
+ /**
9
+ * Select menu.
10
+ *
11
+ * @component
12
+ * @param {Object} props - Component props.
13
+ * @param {string} [props.icon] - Icon of the component.
14
+ * @param {string} [props.help] - Help text of the component.
15
+ * @param {string} [props.label] - Label of the component.
16
+ * @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
17
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
18
+ * @param {string} [props.subtitle] - Subtitle of the component.
19
+ * @param {{label: string, value: string, metadata: Object<string, any>?}[]} props.options - Options to display in the select. `[{ label: string, value: string }]`.
20
+ * @param {string|{label: string, value: string, metadata: Object<string, any>?}} props.value - Current value of the select.
21
+ * @param {Function} props.onChange - Function to call when the value changes.
22
+ * @param {boolean} [props.simpleValue=false] - If `true`, instead of using a `{label: '', value: ''}` value type, a string is used (just the value).
23
+ * @param {boolean} [props.clearable] - Whether the select is clearable.
24
+ * @param {boolean} [props.noSearch] - Whether the search is disabled.
25
+ * @param {boolean} [props.disabled] - Whether the select is disabled.
26
+ * @param {boolean} [props.keepMenuOpenAfterSelect] - Whether the menu stays open after an select.
27
+ * @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
28
+ * @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
29
+ * @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.MultiValue`).
30
+ * @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
31
+ * @param {JSX.Element} [props.customClearIndicator] - If provided, replaces the default 'Clear all' button.
32
+ * @param {string} [props.className] - Classes to pass to the select menu.
33
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
34
+ *
35
+ * @returns {JSX.Element} The Select component.
36
+ *
37
+ * @example
38
+ * const [value, setValue] = useState(null);
39
+ *
40
+ * const options = [
41
+ * { label: 'Option 1', value: 'option-1' },
42
+ * { label: 'Option 2', value: 'option-2' },
43
+ * { label: 'Option 3', value: 'option-3' },
44
+ * ];
45
+ *
46
+ * <MultiSelect
47
+ * label='Select items'
48
+ * options={loadOptions}
49
+ * value={value}
50
+ * onChange={setValue}
51
+ * />
52
+ *
53
+ * @preserve
54
+ */
55
+ const Select = (props) => {
56
+ const {
57
+ icon,
58
+ help,
59
+ label,
60
+ inline,
61
+ actions,
62
+ subtitle,
63
+ value,
64
+ onChange,
65
+ options,
66
+ simpleValue = false,
67
+ disabled = false,
68
+ noSearch = false,
69
+ clearable = false,
70
+ keepMenuOpenAfterSelect = false,
71
+ placeholder,
72
+ customMenuOption,
73
+ customValueDisplay,
74
+ customDropdownArrow,
75
+ customClearIndicator,
76
+ className,
77
+ hidden,
78
+ ...additionalProps
79
+ } = props;
80
+ if (hidden) {
81
+ return null;
82
+ }
83
+ return /* @__PURE__ */ jsx(
84
+ BaseControl,
85
+ {
86
+ label,
87
+ icon,
88
+ subtitle,
89
+ actions,
90
+ help,
91
+ inline,
92
+ children: /* @__PURE__ */ jsx(
93
+ StateManagedSelect$1,
94
+ {
95
+ unstyled: true,
96
+ options,
97
+ value: getValue(simpleValue, value, options),
98
+ onChange: (v) => {
99
+ if (simpleValue) {
100
+ onChange(v == null ? void 0 : v.value);
101
+ return;
102
+ }
103
+ if (v && "id" in v) {
104
+ delete v.id;
105
+ }
106
+ onChange(v);
107
+ },
108
+ closeMenuOnSelect: !keepMenuOpenAfterSelect,
109
+ isClearable: clearable,
110
+ isSearchable: !noSearch,
111
+ isDisabled: disabled,
112
+ className,
113
+ placeholder,
114
+ classNames: eightshiftSelectClasses,
115
+ components: {
116
+ Option: customMenuOption ?? components.Option,
117
+ SingleValue: customValueDisplay ?? components.SingleValue,
118
+ IndicatorSeparator: null,
119
+ DropdownIndicator: customDropdownArrow ?? CustomSelectDefaultDropdownIndicator,
120
+ ClearIndicator: customClearIndicator ?? CustomSelectDefaultClearIndicator
121
+ },
122
+ menuPortalTarget: document.body,
123
+ ...additionalProps
124
+ }
125
+ )
126
+ }
127
+ );
128
+ };
129
+ export {
130
+ Select
131
+ };
@@ -0,0 +1,49 @@
1
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
2
+ const controlStyles = {
3
+ base: "es:border es:border-gray-300 es:rounded-lg es:bg-white es:text-sm es:transition es:group es:shadow-xs 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 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.5";
19
+ const menuStyles = "es:rounded-lg 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-md 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
+ };