@eightshift/ui-components 4.0.0 → 5.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.
- package/package.json +101 -101
- package/dist/Button-CvzGKGCo.js +0 -185
- package/dist/Collection-ddre1L5v.js +0 -2332
- package/dist/Color-MV5kBVXr.js +0 -2452
- package/dist/ColorSwatch-BqQfVu4L.js +0 -64
- package/dist/ComboBox-jQ-dk95U.js +0 -1906
- package/dist/Dialog-DX1aiYyE.js +0 -2300
- package/dist/FieldError-52GVSGgC.js +0 -42
- package/dist/FocusScope-Cri5BFRz.js +0 -831
- package/dist/Form-Cq3fu75_.js +0 -5
- package/dist/Group-_emcIVxI.js +0 -48
- package/dist/Heading-B2153VXe.js +0 -16
- package/dist/Hidden-rE6uR-lr.js +0 -41
- package/dist/Input-BxpFEIXV.js +0 -133
- package/dist/Label-icmbmNdI.js +0 -17
- package/dist/List-BYNHbol3.js +0 -593
- package/dist/ListBox-mJ4nQaL7.js +0 -581
- package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
- package/dist/OverlayArrow-BB0CWwdq.js +0 -629
- package/dist/RSPContexts-2lR5GG9p.js +0 -14
- package/dist/Select-aab027f3.esm--EmXjiL3.js +0 -2469
- package/dist/Separator-D9moUgP8.js +0 -322
- package/dist/Slider-rz2XRMGm.js +0 -853
- package/dist/Text-DVSAPY-K.js +0 -16
- package/dist/VisuallyHidden-f9zX67a_.js +0 -48
- package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
- package/dist/assets/index.css +0 -37
- package/dist/assets/style-admin.css +0 -5255
- package/dist/assets/style-editor.css +0 -5255
- package/dist/assets/style.css +0 -5261
- package/dist/assets/wp-font-enhancements.css +0 -8
- package/dist/assets/wp-ui-enhancements.css +0 -299
- package/dist/components/animated-visibility/animated-visibility.js +0 -105
- package/dist/components/base-control/base-control.js +0 -86
- package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
- package/dist/components/button/button.js +0 -387
- package/dist/components/checkbox/checkbox.js +0 -320
- package/dist/components/color-pickers/color-picker.js +0 -272
- package/dist/components/color-pickers/color-swatch.js +0 -58
- package/dist/components/color-pickers/gradient-editor.js +0 -534
- package/dist/components/color-pickers/solid-color-picker.js +0 -1567
- package/dist/components/component-toggle/component-toggle.js +0 -158
- package/dist/components/container-panel/container-panel.js +0 -131
- package/dist/components/draggable/draggable-context.js +0 -5
- package/dist/components/draggable/draggable-handle.js +0 -46
- package/dist/components/draggable/draggable.js +0 -6207
- package/dist/components/draggable-list/draggable-list-context.js +0 -5
- package/dist/components/draggable-list/draggable-list-item.js +0 -77
- package/dist/components/draggable-list/draggable-list.js +0 -151
- package/dist/components/expandable/expandable.js +0 -342
- package/dist/components/index.js +0 -137
- package/dist/components/input-field/input-field.js +0 -231
- package/dist/components/item-collection/item-collection.js +0 -59
- package/dist/components/layout/hstack.js +0 -30
- package/dist/components/layout/vstack.js +0 -30
- package/dist/components/link-input/link-input.js +0 -293
- package/dist/components/matrix-align/matrix-align.js +0 -134
- package/dist/components/menu/menu.js +0 -285
- package/dist/components/modal/modal.js +0 -305
- package/dist/components/notice/notice.js +0 -123
- package/dist/components/number-picker/number-picker.js +0 -292
- package/dist/components/option-select/option-select.js +0 -264
- package/dist/components/options-panel/options-panel.js +0 -158
- package/dist/components/placeholders/file-placeholder.js +0 -42
- package/dist/components/placeholders/image-placeholder.js +0 -88
- package/dist/components/placeholders/media-placeholder.js +0 -63
- package/dist/components/popover/popover.js +0 -207
- package/dist/components/radio/radio.js +0 -579
- package/dist/components/repeater/repeater-context.js +0 -5
- package/dist/components/repeater/repeater-item.js +0 -119
- package/dist/components/repeater/repeater.js +0 -280
- package/dist/components/responsive/mini-responsive.js +0 -498
- package/dist/components/responsive/responsive-legacy.js +0 -343
- package/dist/components/responsive/responsive.js +0 -580
- package/dist/components/responsive-preview/responsive-preview.js +0 -123
- package/dist/components/rich-label/rich-label.js +0 -66
- package/dist/components/select/async-multi-select.js +0 -157
- package/dist/components/select/async-single-select.js +0 -137
- package/dist/components/select/custom-select-default-components.js +0 -38
- package/dist/components/select/multi-select-components.js +0 -8
- package/dist/components/select/multi-select.js +0 -151
- package/dist/components/select/react-select-component-wrappers.js +0 -90
- package/dist/components/select/shared.js +0 -26
- package/dist/components/select/single-select.js +0 -131
- package/dist/components/select/styles.js +0 -49
- package/dist/components/select/v2/async-select.js +0 -297
- package/dist/components/select/v2/shared.js +0 -24
- package/dist/components/select/v2/single-select.js +0 -990
- package/dist/components/slider/column-config-slider.js +0 -210
- package/dist/components/slider/slider.js +0 -343
- package/dist/components/slider/utils.js +0 -84
- package/dist/components/spacer/spacer.js +0 -97
- package/dist/components/tabs/tabs.js +0 -702
- package/dist/components/toggle/switch.js +0 -155
- package/dist/components/toggle/toggle.js +0 -64
- package/dist/components/toggle-button/toggle-button.js +0 -324
- package/dist/components/tooltip/tooltip.js +0 -525
- package/dist/context-D2KUdwNL.js +0 -92
- package/dist/default-i18n-CT_oS1Fy.js +0 -922
- package/dist/filterDOMProps-EDDcM64A.js +0 -28
- package/dist/icons/block-icon.js +0 -42
- package/dist/icons/generic-color-swatch.js +0 -113
- package/dist/icons/icons.js +0 -30371
- package/dist/icons/index.js +0 -11
- package/dist/icons/jsx-svg.js +0 -50
- package/dist/index-641ee5b8.esm-BPz6U6sJ.js +0 -3137
- package/dist/index-BKGQ6jGS.js +0 -44
- package/dist/index-BYHhzLf-.js +0 -444
- package/dist/index.js +0 -139
- package/dist/lite-DVmmD_-j.js +0 -7
- package/dist/modifiers.esm-BuJQPI1X.js +0 -31
- package/dist/multi-select-components-BlZZoNXC.js +0 -3744
- package/dist/number-GajL10e1.js +0 -36
- package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
- package/dist/react-select-async.esm-CwUoej5h.js +0 -107
- package/dist/react-select.esm-DcwYxadV.js +0 -15
- package/dist/style-admin.js +0 -1
- package/dist/style-editor.js +0 -1
- package/dist/style.js +0 -1
- package/dist/textSelection-0UUS8Yfg.js +0 -46
- package/dist/useButton-BpOKDWEN.js +0 -71
- package/dist/useEvent-B0b-6KBr.js +0 -23
- package/dist/useFocusRing-CV5l3lf6.js +0 -107
- package/dist/useFormReset-C5OggHsw.js +0 -22
- package/dist/useFormValidation-DhDNSjws.js +0 -224
- package/dist/useHover-DwDr6ozG.js +0 -900
- package/dist/useLabel-D7HkNEHT.js +0 -27
- package/dist/useLabels-D8cxd1Z8.js +0 -23
- package/dist/useListState-UGlN5-7P.js +0 -161
- package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
- package/dist/useNumberField-CEAj7Mrj.js +0 -1204
- package/dist/useNumberFormatter-321rAb4J.js +0 -13
- package/dist/usePress-DNW8qpY6.js +0 -664
- package/dist/useSingleSelectListState-DC0wWTUM.js +0 -38
- package/dist/useToggle-BrpmSOB-.js +0 -59
- package/dist/useToggleState-CmQX3SoX.js +0 -19
- package/dist/utilities/array-helpers.js +0 -56
- package/dist/utilities/debounce-throttle.js +0 -123
- package/dist/utilities/es-dash.js +0 -376
- package/dist/utilities/index.js +0 -27
- package/dist/utilities/text-helpers.js +0 -136
- package/dist/utils-DkCSC521.js +0 -370
- package/dist/wp/wp-font-enhancements.js +0 -1
- package/dist/wp/wp-ui-enhancements.js +0 -1
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
3
|
-
import { S as StateManagedSelect$1 } from "../../react-select.esm-DcwYxadV.js";
|
|
4
|
-
import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValueRemove, b as getMultiValue } from "../../multi-select-components-BlZZoNXC.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-BPz6U6sJ.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
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { c as components } from "../../index-641ee5b8.esm-BPz6U6sJ.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,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { S as StateManagedSelect$1 } from "../../react-select.esm-DcwYxadV.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-BPz6U6sJ.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
|
-
};
|
|
@@ -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-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
|
-
};
|