@eightshift/ui-components 3.0.1 → 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-BPLceDeW.js +0 -185
- package/dist/Collection-CZxddMZS.js +0 -2332
- package/dist/Color-MV5kBVXr.js +0 -2452
- package/dist/ColorSwatch-BqQfVu4L.js +0 -64
- package/dist/ComboBox-_RfyhwZw.js +0 -1906
- package/dist/Dialog-8tYeQ9n4.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-CZMUbkFU.js +0 -593
- package/dist/ListBox-Ca6hiCqz.js +0 -581
- package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
- package/dist/OverlayArrow-CYXQSlEU.js +0 -629
- package/dist/RSPContexts-2lR5GG9p.js +0 -14
- package/dist/Select-aab027f3.esm-PDJCDE95.js +0 -2469
- package/dist/Separator-4IIDRlV_.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-DIuJijyT.js +0 -3137
- package/dist/index-BKGQ6jGS.js +0 -44
- package/dist/index-CFozsmNS.js +0 -28321
- 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-Sp-JEFEX.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-Bql4G5iV.js +0 -107
- package/dist/react-select.esm-B_TudhTU.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-Cg474OYB.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-DVr6aYd_.js +0 -161
- package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
- package/dist/useNumberField-TwM0Z9D1.js +0 -1204
- package/dist/useNumberFormatter-321rAb4J.js +0 -13
- package/dist/usePress-Cucx-xSA.js +0 -664
- package/dist/useSingleSelectListState-CMGsRHHh.js +0 -38
- package/dist/useToggle-C0I3vs0g.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,123 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
|
|
3
|
-
import { upperFirst } from "../../utilities/es-dash.js";
|
|
4
|
-
import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
|
|
5
|
-
import { icons } from "../../icons/icons.js";
|
|
6
|
-
import { RichLabel } from "../rich-label/rich-label.js";
|
|
7
|
-
/**
|
|
8
|
-
* A component that displays a preview of the responsive settings.
|
|
9
|
-
*
|
|
10
|
-
* **Note**: Only intended for horizontal groups of buttons that don't wrap.
|
|
11
|
-
*
|
|
12
|
-
* @component
|
|
13
|
-
* @param {Object} props - Component props.
|
|
14
|
-
* @param {Object} props.value - The value object.
|
|
15
|
-
* @param {boolean} props.isDesktopFirst - Whether the desktop-first mode is enabled.
|
|
16
|
-
* @param {string[]} props.breakpoints - Breakpoints to use.
|
|
17
|
-
* @param {string[]} [props.desktopFirstBreakpoints] - Breakpoints to use in desktop-first mode. If not provided, the breakpoints will be used in reverse order.
|
|
18
|
-
* @param {{label: string, value: string}[]} props.options - Options of the attribute the component is linked to. `{ value: string, label: string }[]`.
|
|
19
|
-
* @param {Object} props.breakpointData - Breakpoints to use. `{ [breakpoint: string]: number }`.
|
|
20
|
-
* @param {Object<string, number>} [props.breakpointUiData] - Allows overriding breakpoint names and icons. `{ [breakpoint: string]: { label: string, icon: JSX.Element|string } }`.
|
|
21
|
-
*
|
|
22
|
-
* @returns {JSX.Element} The ResponsivePreview component.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* <ResponsivePreview
|
|
26
|
-
* value={value}
|
|
27
|
-
* isDesktopFirst={isDesktopFirst}
|
|
28
|
-
* breakpoints={breakpoints}
|
|
29
|
-
* options={options}
|
|
30
|
-
* breakpointData={breakpointData} // e.g. from global manifest
|
|
31
|
-
* />
|
|
32
|
-
*
|
|
33
|
-
* @preserve
|
|
34
|
-
*/
|
|
35
|
-
const ResponsivePreview = (props) => {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
const {
|
|
38
|
-
value,
|
|
39
|
-
isDesktopFirst: rawIsDesktopFirst,
|
|
40
|
-
breakpoints: rawBreakpoints,
|
|
41
|
-
desktopFirstBreakpoints: rawDesktopFirstBreakpoints,
|
|
42
|
-
options,
|
|
43
|
-
breakpointData,
|
|
44
|
-
breakpointUiData
|
|
45
|
-
} = props;
|
|
46
|
-
const isDesktopFirst = rawIsDesktopFirst ?? (value == null ? void 0 : value["_desktopFirst"]) ?? false;
|
|
47
|
-
const breakpoints = rawBreakpoints;
|
|
48
|
-
const desktopFirstBreakpoints = rawDesktopFirstBreakpoints ?? rawBreakpoints.slice(0, -1);
|
|
49
|
-
const firstMobileFirstOverride = breakpoints.find((breakpoint) => value == null ? void 0 : value[breakpoint]);
|
|
50
|
-
const lastDesktopFirstOverride = desktopFirstBreakpoints.toReversed().find((breakpoint) => value == null ? void 0 : value[breakpoint]);
|
|
51
|
-
let previewItems = [];
|
|
52
|
-
if (firstMobileFirstOverride && !isDesktopFirst) {
|
|
53
|
-
previewItems = [
|
|
54
|
-
...previewItems,
|
|
55
|
-
{
|
|
56
|
-
breakpoint: __("Default", "eightshift-ui-components"),
|
|
57
|
-
value: ((_a = options == null ? void 0 : options.find((opt) => opt.value === (value == null ? void 0 : value["_default"]))) == null ? void 0 : _a.label) ?? upperFirst(value == null ? void 0 : value["_default"])
|
|
58
|
-
}
|
|
59
|
-
];
|
|
60
|
-
breakpoints.forEach((breakpoint) => {
|
|
61
|
-
var _a2, _b2;
|
|
62
|
-
if (typeof (value == null ? void 0 : value[breakpoint]) === "undefined") {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
previewItems = [
|
|
66
|
-
...previewItems,
|
|
67
|
-
{
|
|
68
|
-
width: breakpointData[breakpoint],
|
|
69
|
-
breakpoint: ((_a2 = breakpointUiData == null ? void 0 : breakpointUiData[breakpoint]) == null ? void 0 : _a2.label) ?? breakpoint,
|
|
70
|
-
value: ((_b2 = options == null ? void 0 : options.find((opt) => opt.value === (value == null ? void 0 : value[breakpoint]))) == null ? void 0 : _b2.label) ?? upperFirst(value == null ? void 0 : value[breakpoint])
|
|
71
|
-
}
|
|
72
|
-
];
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (lastDesktopFirstOverride && isDesktopFirst) {
|
|
76
|
-
desktopFirstBreakpoints.forEach((breakpoint) => {
|
|
77
|
-
var _a2, _b2;
|
|
78
|
-
if (typeof (value == null ? void 0 : value[breakpoint]) === "undefined") {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
previewItems = [
|
|
82
|
-
...previewItems,
|
|
83
|
-
{
|
|
84
|
-
alignEnd: true,
|
|
85
|
-
widthEnd: breakpointData[breakpoint.replace("max-", "")],
|
|
86
|
-
breakpoint: ((_a2 = breakpointUiData == null ? void 0 : breakpointUiData[breakpoint.replace("max-", "")]) == null ? void 0 : _a2.label) ?? breakpoint.replace("max-", ""),
|
|
87
|
-
value: ((_b2 = options == null ? void 0 : options.find((opt) => opt.value === (value == null ? void 0 : value[breakpoint]))) == null ? void 0 : _b2.label) ?? upperFirst(value == null ? void 0 : value[breakpoint])
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
});
|
|
91
|
-
previewItems = [
|
|
92
|
-
...previewItems,
|
|
93
|
-
{
|
|
94
|
-
breakpoint: __("Default", "eightshift-ui-components"),
|
|
95
|
-
value: ((_b = options == null ? void 0 : options.find((opt) => opt.value === (value == null ? void 0 : value["_default"]))) == null ? void 0 : _b.label) ?? upperFirst(value == null ? void 0 : value["_default"])
|
|
96
|
-
}
|
|
97
|
-
];
|
|
98
|
-
}
|
|
99
|
-
return /* @__PURE__ */ jsxs("div", { className: "es:flex es:min-w-72 es:flex-col es:items-start es:gap-4 es:p-2 es:text-sm", children: [
|
|
100
|
-
/* @__PURE__ */ jsxs("div", { className: "es:flex es:w-full es:items-center es:gap-2.5", children: [
|
|
101
|
-
/* @__PURE__ */ jsx(
|
|
102
|
-
RichLabel,
|
|
103
|
-
{
|
|
104
|
-
icon: icons.previewResponsive,
|
|
105
|
-
label: __("Responsive preview", "eightshift-ui-components")
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ jsx("span", { className: "es:ml-auto es:select-none es:rounded es:bg-secondary-100 es:px-1 es:py-0.5 es:text-xs es:text-secondary-500", children: isDesktopFirst ? __("Desktop-first", "eightshift-ui-components") : __("Mobile-first", "eightshift-ui-components") })
|
|
109
|
-
] }),
|
|
110
|
-
previewItems.length === 0 && /* @__PURE__ */ jsx("span", { className: "es:text-sm es:italic es:text-secondary-500", children: __("No overrides applied", "eightshift-ui-components") }),
|
|
111
|
-
/* @__PURE__ */ jsx(
|
|
112
|
-
BreakpointPreview,
|
|
113
|
-
{
|
|
114
|
-
blocks: previewItems,
|
|
115
|
-
dotsStart: true,
|
|
116
|
-
dotsEnd: true
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
] });
|
|
120
|
-
};
|
|
121
|
-
export {
|
|
122
|
-
ResponsivePreview
|
|
123
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
3
|
-
/**
|
|
4
|
-
* Component that displays a label, with an optional icon and subtitle.
|
|
5
|
-
*
|
|
6
|
-
* @component
|
|
7
|
-
* @param {Object} props - Component props.
|
|
8
|
-
* @param {JSX.Element} [props.icon] - Icon to display.
|
|
9
|
-
* @param {string} [props.label] - Label to display.
|
|
10
|
-
* @param {string} [props.subtitle] - Subtitle to display.
|
|
11
|
-
* @param {JSX.Element} [props.as] - Element to render the label as. Not compatible with `contentsOnly`.
|
|
12
|
-
* @param {string} [props.className] - Classes to pass to the label.
|
|
13
|
-
* @param {string} [props.iconClassName] - Classes to pass to the icon.
|
|
14
|
-
* @param {boolean} [props.fullWidth=false] - If `true`, the component will take up as much space as it can.
|
|
15
|
-
* @param {boolean} [props.contentsOnly] - If `true`, only the label (/icon/subtitle) will be rendered, without any wrapping elements. Useful if you want to provide your own layout.
|
|
16
|
-
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
17
|
-
* @param {boolean} [props.noColor] - If `true`, colors on text won't be set, opacity will be used instead.
|
|
18
|
-
* @param {boolean} [props.fullSizeSubtitle] - If `true`, the subtitle is the same size as the label.
|
|
19
|
-
* @param {boolean} [props.inlineSubtitle] - If `true`, the subtitle is shown after the label instead of below it.
|
|
20
|
-
*
|
|
21
|
-
* @returns {JSX.Element} The RichLabel component.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* <RichLabel
|
|
25
|
-
* icon={icons.myIcon}
|
|
26
|
-
* label='My label'
|
|
27
|
-
* />
|
|
28
|
-
*
|
|
29
|
-
* @preserve
|
|
30
|
-
*/
|
|
31
|
-
const RichLabel = (props) => {
|
|
32
|
-
const { icon, label, subtitle, as, className, iconClassName, fullWidth = false, contentsOnly, hidden, noColor, fullSizeSubtitle, inlineSubtitle } = props;
|
|
33
|
-
if (hidden) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const ComponentToRender = as ?? "div";
|
|
37
|
-
if (contentsOnly) {
|
|
38
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
-
icon && /* @__PURE__ */ jsx("span", { className: clsx("es:icon:size-5.5", !noColor && "es:text-slate-500"), children: icon }),
|
|
40
|
-
label && /* @__PURE__ */ jsx("span", { className: clsx("es:text-balance", !noColor && "es:text-secondary-800"), children: label }),
|
|
41
|
-
subtitle && /* @__PURE__ */ jsx("span", { className: clsx("es:text-balance es:text-xs es:opacity-65", !noColor && "es:text-secondary-800"), children: subtitle })
|
|
42
|
-
] });
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ jsxs(
|
|
45
|
-
ComponentToRender,
|
|
46
|
-
{
|
|
47
|
-
className: clsx(
|
|
48
|
-
"es:flex es:items-center es:gap-1.5 es:text-sm",
|
|
49
|
-
!noColor && "es:text-secondary-800 es:[&>span>svg]:text-slate-500",
|
|
50
|
-
noColor && "es:[&>span>svg]:opacity-80",
|
|
51
|
-
fullWidth && "es:grow",
|
|
52
|
-
className
|
|
53
|
-
),
|
|
54
|
-
children: [
|
|
55
|
-
icon && /* @__PURE__ */ jsx("span", { className: clsx("es:icon:size-5.5", iconClassName), children: icon }),
|
|
56
|
-
(label || subtitle) && /* @__PURE__ */ jsxs("div", { className: clsx("es:flex es:items-start es:text-balance es:text-start", inlineSubtitle ? "es:gap-1.5" : "es:flex-col"), children: [
|
|
57
|
-
label && /* @__PURE__ */ jsx("span", { children: label }),
|
|
58
|
-
subtitle && /* @__PURE__ */ jsx("span", { className: clsx(!fullSizeSubtitle && "es:text-xs", "es:opacity-65"), children: subtitle })
|
|
59
|
-
] })
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
RichLabel
|
|
66
|
-
};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
3
|
-
import { A as AsyncSelect$1 } from "../../react-select-async.esm-Bql4G5iV.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 { BaseControl } from "../base-control/base-control.js";
|
|
8
|
-
import { eightshiftSelectClasses } from "./styles.js";
|
|
9
|
-
import { c as components } from "../../index-641ee5b8.esm-DIuJijyT.js";
|
|
10
|
-
/**
|
|
11
|
-
* Multi-select menu with async loading and re-ordering.
|
|
12
|
-
*
|
|
13
|
-
* @component
|
|
14
|
-
* @param {Object} props - Component props.
|
|
15
|
-
* @param {string} [props.label] - Label of the component.
|
|
16
|
-
* @param {string} [props.help] - Help text of the component.
|
|
17
|
-
* @param {string} [props.icon] - Icon of the component.
|
|
18
|
-
* @param {string} [props.subtitle] - Subtitle of the component.
|
|
19
|
-
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
|
|
20
|
-
* @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
|
|
21
|
-
* @param {boolean|{label: string, value: string, metadata: Object<string, any>?}[]} [props.preloadOptions=true] - If `true`, the initial loading is done as soon as the component is loaded. If an array of `{label: '', value: ''}` option is provided, that is loaded immediately, dynamic fetching only happens in search. If `false`, nothing is loaded immediately, fetching only happens when an user types to search.
|
|
22
|
-
* @param {Function<Promise>} props.loadOptions - Async function that returns an array of `{label: '', value: ''}`-formatted items. `loadOptions(searchText: string): Promise<{label: string, value: string, [metadata]: Array}[]>`.
|
|
23
|
-
* @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.clearable] - Whether the select is clearable.
|
|
26
|
-
* @param {boolean} [props.noSearch] - Whether the search is disabled.
|
|
27
|
-
* @param {boolean} [props.disabled] - Whether the select is disabled.
|
|
28
|
-
* @param {boolean} [props.keepMenuOpenAfterSelect] - Whether the menu stays open after an select.
|
|
29
|
-
* @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
|
|
30
|
-
* @param {JSX.Element} [props.customClearIndicator] - If provided, replaces the default 'Clear all' button.
|
|
31
|
-
* @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
|
|
32
|
-
* @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
|
|
33
|
-
* @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.MultiValue`).
|
|
34
|
-
* @param {JSX.Element} [props.customValueRemove] - If provided, replaces the default item remove button (react-select's `components.MultiValueRemove`.
|
|
35
|
-
* @param {JSX.Element} [props.customValueContainer] - If provided, replaces the default items container component (react-select's `components.MultiValueContainer`).
|
|
36
|
-
* @param {Function} [props.processLoadedOptions] - Allows modifying (filtering, grouping, ...) options output after the items have been dynamically fetched. Must include `label`, `value`, and `id` keys in the output, additional fields can be added as required.
|
|
37
|
-
* @param {string} [props.className] - Classes to pass to the select menu.
|
|
38
|
-
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
39
|
-
*
|
|
40
|
-
* @returns {JSX.Element} The AsyncMultiSelect component.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* const [value, setValue] = useState([]);
|
|
44
|
-
*
|
|
45
|
-
* const loadOptions = async (searchText) => {
|
|
46
|
-
* const response = await fetch(`https://api.example.com/items?q=${searchText}`);
|
|
47
|
-
* const data = await response.json();
|
|
48
|
-
*
|
|
49
|
-
* return data.items.map((item) => ({
|
|
50
|
-
* label: item.name,
|
|
51
|
-
* value: item.id,
|
|
52
|
-
* }));
|
|
53
|
-
* };
|
|
54
|
-
*
|
|
55
|
-
* <AsyncMultiSelect
|
|
56
|
-
* label='Select items'
|
|
57
|
-
* loadOptions={loadOptions}
|
|
58
|
-
* value={value}
|
|
59
|
-
* onChange={setValue}
|
|
60
|
-
* />
|
|
61
|
-
*
|
|
62
|
-
* @preserve
|
|
63
|
-
*/
|
|
64
|
-
const AsyncMultiSelect = (props) => {
|
|
65
|
-
const {
|
|
66
|
-
label,
|
|
67
|
-
help,
|
|
68
|
-
icon,
|
|
69
|
-
subtitle,
|
|
70
|
-
actions,
|
|
71
|
-
inline,
|
|
72
|
-
loadOptions,
|
|
73
|
-
preloadOptions = true,
|
|
74
|
-
value: rawValue,
|
|
75
|
-
onChange,
|
|
76
|
-
disabled = false,
|
|
77
|
-
noSearch = false,
|
|
78
|
-
clearable = false,
|
|
79
|
-
keepMenuOpenAfterSelect = false,
|
|
80
|
-
className,
|
|
81
|
-
placeholder,
|
|
82
|
-
customMenuOption,
|
|
83
|
-
customValueRemove,
|
|
84
|
-
customValueDisplay,
|
|
85
|
-
customDropdownArrow,
|
|
86
|
-
customValueContainer,
|
|
87
|
-
customClearIndicator,
|
|
88
|
-
processLoadedOptions = (options) => options,
|
|
89
|
-
hidden,
|
|
90
|
-
...additionalProps
|
|
91
|
-
} = props;
|
|
92
|
-
const idBase = useId();
|
|
93
|
-
const value = rawValue.map((item, index) => ({
|
|
94
|
-
...item,
|
|
95
|
-
id: (item == null ? void 0 : item.value) ?? `${idBase}-${index}`
|
|
96
|
-
}));
|
|
97
|
-
const modifiedOnChange = (v) => {
|
|
98
|
-
onChange(v == null ? void 0 : v.map((item) => ({ ...item, id: void 0 })));
|
|
99
|
-
};
|
|
100
|
-
if (hidden) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
const customLoadOptions = async (searchText) => {
|
|
104
|
-
const results = await loadOptions(searchText);
|
|
105
|
-
return processLoadedOptions((results == null ? void 0 : results.map((item) => ({ id: item.value, ...item }))) ?? []);
|
|
106
|
-
};
|
|
107
|
-
return /* @__PURE__ */ jsx(
|
|
108
|
-
BaseControl,
|
|
109
|
-
{
|
|
110
|
-
label,
|
|
111
|
-
icon,
|
|
112
|
-
subtitle,
|
|
113
|
-
actions,
|
|
114
|
-
help,
|
|
115
|
-
inline,
|
|
116
|
-
children: /* @__PURE__ */ jsx(
|
|
117
|
-
DndContext,
|
|
118
|
-
{
|
|
119
|
-
modifiers: [restrictToParentElement],
|
|
120
|
-
onDragEnd: getDragEndHandler(modifiedOnChange, value),
|
|
121
|
-
children: /* @__PURE__ */ jsx(SortableContext, { items: value.map(({ id }) => id), children: /* @__PURE__ */ jsx(
|
|
122
|
-
AsyncSelect$1,
|
|
123
|
-
{
|
|
124
|
-
isMulti: true,
|
|
125
|
-
unstyled: true,
|
|
126
|
-
loadOptions: customLoadOptions,
|
|
127
|
-
defaultOptions: preloadOptions,
|
|
128
|
-
value,
|
|
129
|
-
onChange: modifiedOnChange,
|
|
130
|
-
closeMenuOnSelect: !keepMenuOpenAfterSelect,
|
|
131
|
-
isClearable: clearable,
|
|
132
|
-
isSearchable: !noSearch,
|
|
133
|
-
isDisabled: disabled,
|
|
134
|
-
className,
|
|
135
|
-
placeholder,
|
|
136
|
-
classNames: eightshiftSelectClasses,
|
|
137
|
-
components: {
|
|
138
|
-
MultiValue: getMultiValue(customValueDisplay ?? components.MultiValue),
|
|
139
|
-
MultiValueContainer: customValueContainer ?? components.MultiValueContainer,
|
|
140
|
-
MultiValueRemove: getMultiValueRemove(customValueRemove ?? CustomSelectDefaultMultiValueRemove),
|
|
141
|
-
Option: customMenuOption ?? components.Option,
|
|
142
|
-
IndicatorSeparator: null,
|
|
143
|
-
DropdownIndicator: customDropdownArrow ?? CustomSelectDefaultDropdownIndicator,
|
|
144
|
-
ClearIndicator: customClearIndicator ?? CustomSelectDefaultClearIndicator
|
|
145
|
-
},
|
|
146
|
-
menuPortalTarget: document.body,
|
|
147
|
-
...additionalProps
|
|
148
|
-
}
|
|
149
|
-
) })
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
};
|
|
155
|
-
export {
|
|
156
|
-
AsyncMultiSelect
|
|
157
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { A as AsyncSelect$1 } from "../../react-select-async.esm-Bql4G5iV.js";
|
|
3
|
-
import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator } from "./custom-select-default-components.js";
|
|
4
|
-
import { BaseControl } from "../base-control/base-control.js";
|
|
5
|
-
import { eightshiftSelectClasses } from "./styles.js";
|
|
6
|
-
import { c as components } from "../../index-641ee5b8.esm-DIuJijyT.js";
|
|
7
|
-
/**
|
|
8
|
-
* Select menu with async loading.
|
|
9
|
-
*
|
|
10
|
-
* @component
|
|
11
|
-
* @param {Object} props - Component props.
|
|
12
|
-
* @param {string} [props.label] - Label of the component.
|
|
13
|
-
* @param {string} [props.help] - Help text of the component.
|
|
14
|
-
* @param {string} [props.icon] - Icon of the component.
|
|
15
|
-
* @param {string} [props.subtitle] - Subtitle of the component.
|
|
16
|
-
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
|
|
17
|
-
* @param {boolean} [props.inline] - Whether the Select menu is displayed inline with the label, to the right.
|
|
18
|
-
* @param {boolean|{label: string, value: string, metadata: Object<string, any>?}[]} [props.preloadOptions=true] - If `true`, the initial loading is done as soon as the component is loaded. If an array of `{label: '', value: ''}` option is provided, that is loaded immediately, dynamic fetching only happens in search. If `false`, nothing is loaded immediately, fetching only happens when an user types to search.
|
|
19
|
-
* @param {Function} props.loadOptions - Async function that returns an array of `{label: '', value: ''}`-formatted items. `loadOptions(searchText: string): Promise<{label: string, value: string, metadata: Object<string, any>?}[]>`.
|
|
20
|
-
* @param {{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.clearable=false] - Whether the select is clearable.
|
|
23
|
-
* @param {boolean} [props.noSearch=false] - Whether the search is disabled.
|
|
24
|
-
* @param {boolean} [props.disabled=false] - Whether the select is disabled.
|
|
25
|
-
* @param {boolean} [props.keepMenuOpenAfterSelect=false] - Whether the menu stays open after an select.
|
|
26
|
-
* @param {string} [props.placeholder] - Placeholder text to show when no value is selected.
|
|
27
|
-
* @param {JSX.Element} [props.customDropdownIndicator] - If provided, replaces the default dropdown arrow indicator.
|
|
28
|
-
* @param {JSX.Element} [props.customClearIndicator] - If provided and `noClear` is `false`, replaces the default 'Clear all' button.
|
|
29
|
-
* @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
|
|
30
|
-
* @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.SingleValue`).
|
|
31
|
-
* @param {Function} [props.processLoadedOptions] - Allows modifying (filtering, grouping, ...) options output after the items have been dynamically fetched. Must include `label`, `value`, and `id` keys in the output, additional fields can be added as required.
|
|
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 AsyncSelect component.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* const [value, setValue] = useState(null);
|
|
39
|
-
*
|
|
40
|
-
* const loadOptions = async (searchText) => {
|
|
41
|
-
* const response = await fetch(`https://api.example.com/items?q=${searchText}`);
|
|
42
|
-
* const data = await response.json();
|
|
43
|
-
*
|
|
44
|
-
* return data.items.map((item) => ({
|
|
45
|
-
* label: item.name,
|
|
46
|
-
* value: item.id,
|
|
47
|
-
* }));
|
|
48
|
-
* };
|
|
49
|
-
*
|
|
50
|
-
* <AsyncMultiSelect
|
|
51
|
-
* label='Select items'
|
|
52
|
-
* loadOptions={loadOptions}
|
|
53
|
-
* value={value}
|
|
54
|
-
* onChange={setValue}
|
|
55
|
-
* />
|
|
56
|
-
*
|
|
57
|
-
* @preserve
|
|
58
|
-
*/
|
|
59
|
-
const AsyncSelect = (props) => {
|
|
60
|
-
const {
|
|
61
|
-
label,
|
|
62
|
-
help,
|
|
63
|
-
icon,
|
|
64
|
-
subtitle,
|
|
65
|
-
actions,
|
|
66
|
-
inline,
|
|
67
|
-
loadOptions,
|
|
68
|
-
preloadOptions = true,
|
|
69
|
-
value,
|
|
70
|
-
onChange,
|
|
71
|
-
noSearch = false,
|
|
72
|
-
disabled = false,
|
|
73
|
-
clearable = false,
|
|
74
|
-
keepMenuOpenAfterSelect = false,
|
|
75
|
-
className,
|
|
76
|
-
placeholder,
|
|
77
|
-
customMenuOption,
|
|
78
|
-
customValueDisplay,
|
|
79
|
-
customDropdownArrow,
|
|
80
|
-
customClearIndicator,
|
|
81
|
-
processLoadedOptions = (options) => options,
|
|
82
|
-
hidden,
|
|
83
|
-
...additionalProps
|
|
84
|
-
} = props;
|
|
85
|
-
if (hidden) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
const customLoadOptions = async (searchText) => {
|
|
89
|
-
const results = await loadOptions(searchText);
|
|
90
|
-
return processLoadedOptions((results == null ? void 0 : results.map((item) => ({ id: item.value, ...item }))) ?? []);
|
|
91
|
-
};
|
|
92
|
-
return /* @__PURE__ */ jsx(
|
|
93
|
-
BaseControl,
|
|
94
|
-
{
|
|
95
|
-
label,
|
|
96
|
-
icon,
|
|
97
|
-
subtitle,
|
|
98
|
-
actions,
|
|
99
|
-
help,
|
|
100
|
-
inline,
|
|
101
|
-
children: /* @__PURE__ */ jsx(
|
|
102
|
-
AsyncSelect$1,
|
|
103
|
-
{
|
|
104
|
-
unstyled: true,
|
|
105
|
-
loadOptions: customLoadOptions,
|
|
106
|
-
defaultOptions: preloadOptions,
|
|
107
|
-
value,
|
|
108
|
-
onChange: (value2) => {
|
|
109
|
-
if (value2 && "id" in value2) {
|
|
110
|
-
delete value2.id;
|
|
111
|
-
}
|
|
112
|
-
onChange(value2);
|
|
113
|
-
},
|
|
114
|
-
closeMenuOnSelect: !keepMenuOpenAfterSelect,
|
|
115
|
-
isClearable: clearable,
|
|
116
|
-
isSearchable: !noSearch,
|
|
117
|
-
isDisabled: disabled,
|
|
118
|
-
className,
|
|
119
|
-
placeholder,
|
|
120
|
-
classNames: eightshiftSelectClasses,
|
|
121
|
-
components: {
|
|
122
|
-
Option: customMenuOption ?? components.Option,
|
|
123
|
-
SingleValue: customValueDisplay ?? components.SingleValue,
|
|
124
|
-
IndicatorSeparator: null,
|
|
125
|
-
DropdownIndicator: customDropdownArrow ?? CustomSelectDefaultDropdownIndicator,
|
|
126
|
-
ClearIndicator: customClearIndicator ?? CustomSelectDefaultClearIndicator
|
|
127
|
-
},
|
|
128
|
-
menuPortalTarget: document.body,
|
|
129
|
-
...additionalProps
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
export {
|
|
136
|
-
AsyncSelect
|
|
137
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React__default from "react";
|
|
3
|
-
import { icons } from "../../icons/icons.js";
|
|
4
|
-
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
5
|
-
import { c as components } from "../../index-641ee5b8.esm-DIuJijyT.js";
|
|
6
|
-
/**
|
|
7
|
-
* Default dropdown indicator for CustomSelect.
|
|
8
|
-
*
|
|
9
|
-
* @param {import('react-select').DropdownIndicatorProps} props - components.DropdownIndicator props.
|
|
10
|
-
*
|
|
11
|
-
* @preserve
|
|
12
|
-
*/
|
|
13
|
-
const CustomSelectDefaultDropdownIndicator = (props) => {
|
|
14
|
-
return /* @__PURE__ */ jsx(components.DropdownIndicator, { ...props, children: React__default.cloneElement(icons.dropdownCaretAlt, {
|
|
15
|
-
className: clsx(props.selectProps.menuIsOpen && "es:-scale-y-100 ")
|
|
16
|
-
}) });
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Default clear indicator for CustomSelect.
|
|
20
|
-
*
|
|
21
|
-
* @param {import('react-select').ClearIndicatorProps} props - components.DropdownIndicator props.
|
|
22
|
-
*
|
|
23
|
-
* @preserve
|
|
24
|
-
*/
|
|
25
|
-
const CustomSelectDefaultClearIndicator = (props) => /* @__PURE__ */ jsx(components.ClearIndicator, { ...props, children: icons.clear });
|
|
26
|
-
/**
|
|
27
|
-
* Default multiple value remove element for CustomSelect.
|
|
28
|
-
*
|
|
29
|
-
* @param {import('react-select').MultiValueRemoveProps} props - components.MultiValueRemove props.
|
|
30
|
-
*
|
|
31
|
-
* @preserve
|
|
32
|
-
*/
|
|
33
|
-
const CustomSelectDefaultMultiValueRemove = (props) => /* @__PURE__ */ jsx(components.MultiValueRemove, { ...props, children: React__default.cloneElement(icons.clear, { className: "es:size-4" }) });
|
|
34
|
-
export {
|
|
35
|
-
CustomSelectDefaultClearIndicator,
|
|
36
|
-
CustomSelectDefaultDropdownIndicator,
|
|
37
|
-
CustomSelectDefaultMultiValueRemove
|
|
38
|
-
};
|