@eightshift/ui-components 8.1.0 → 8.3.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/dist/{Autocomplete-BUU44AuW.js → Autocomplete-Dqkum3dO.js} +29 -25
- package/dist/{Button-_E2Z5G2l.js → Button-DHgs_rCq.js} +15 -9
- package/dist/{Dialog-3XLIaepk.js → Dialog-CldDJ_4u.js} +390 -189
- package/dist/{Disclosure-Dh0z_DEQ.js → Disclosure-BHNgL5Is.js} +33 -29
- package/dist/{FocusScope-BKGWN6UK.js → FocusScope-CUuL5wjz.js} +13 -8
- package/dist/{Heading-BWTs9ckA.js → Heading-BQje2nS2.js} +1 -1
- package/dist/{I18nProvider-BskRMK8G.js → I18nProvider-R_4IDnf9.js} +1 -1
- package/dist/{Label-UpU4cKPh.js → Label-C4bJkVti.js} +1 -1
- package/dist/{ListBox-DepY-52g.js → ListBox-CZXso3mJ.js} +14 -38
- package/dist/{NumberFormatter-WKBRKiEA.js → NumberFormatter-Bwdv413k.js} +4 -2
- package/dist/{RadioGroup-Br9Mn9QJ.js → RadioGroup-BTByPMrl.js} +35 -35
- package/dist/{SearchField-q2Fj0L9K.js → SearchField-DkX1vqMN.js} +29 -26
- package/dist/{Slider-B8icnyOo.js → Slider-Dw-JjfLx.js} +55 -44
- package/dist/{Text-D4y19vs8.js → Text-CA2_mHEB.js} +4 -3
- package/dist/{VisuallyHidden-B_LZ_kn7.js → VisuallyHidden-ZZwHZDro.js} +2 -2
- package/dist/{animation-DpSgtWyu.js → animation-COc9P6ap.js} +2 -4
- package/dist/assets/{image-analysis-worker-BuHru-CI.js → image-analysis-worker-CBOB71mx.js} +1 -1
- package/dist/assets/style-admin.css +1 -1
- package/dist/assets/style-editor.css +1 -1
- package/dist/assets/style.css +1 -1
- package/dist/assets/wp-overrides/make-block-messages-nicer.css +1 -1
- package/dist/{build-module-DG6ZK7Ty.js → build-module-BISCoQjQ.js} +4 -4
- package/dist/{button-XSk_8UW7.js → button-ldR_tlvk.js} +64 -13
- package/dist/{checkbox-BYaS9tQ5.js → checkbox-DDyLJRY8.js} +8 -8
- package/dist/{color-swatch-6ZEIXej3.js → color-swatch-DmhdOhe4.js} +15 -16
- package/dist/components/animated-visibility/animated-visibility.js +5 -3
- package/dist/components/base-control/base-control.d.ts +1 -1
- package/dist/components/base-control/base-control.js +1 -1
- package/dist/components/base-control/container.d.ts +4 -30
- package/dist/components/base-control/container.js +5 -32
- package/dist/components/breakpoint-preview/breakpoint-preview.js +1 -1
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/checkbox/checkbox.js +1 -1
- package/dist/components/color-pickers/color-picker.js +8 -8
- package/dist/components/color-pickers/color-swatch.js +1 -1
- package/dist/components/color-pickers/gradient-editor.js +1 -1
- package/dist/components/color-pickers/solid-color-picker.js +1 -1
- package/dist/components/component-toggle/component-toggle.d.ts +1 -1
- package/dist/components/component-toggle/component-toggle.js +4 -4
- package/dist/components/container-panel/container-panel.js +11 -11
- package/dist/components/contextual-help/contextual-help.js +3 -3
- package/dist/components/draggable/draggable.d.ts +3 -3
- package/dist/components/draggable/draggable.js +1 -1
- package/dist/components/draggable-list/draggable-list.d.ts +3 -3
- package/dist/components/draggable-list/draggable-list.js +9 -9
- package/dist/components/expandable/expandable.js +4 -4
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +18 -17
- package/dist/components/input-field/input-field.d.ts +1 -1
- package/dist/components/input-field/input-field.js +1 -1
- package/dist/components/item-collection/item-collection.d.ts +3 -28
- package/dist/components/item-collection/item-collection.js +7 -7
- package/dist/components/link-input/link-input.d.ts +0 -2
- package/dist/components/link-input/link-input.js +1 -1
- package/dist/components/matrix-align/matrix-align.js +5 -4
- package/dist/components/menu/menu.d.ts +8 -29
- package/dist/components/menu/menu.js +11 -8
- package/dist/components/modal/modal.js +1 -1
- package/dist/components/notice/notice.js +8 -8
- package/dist/components/number-picker/number-picker.d.ts +1 -1
- package/dist/components/number-picker/number-picker.js +1 -1
- package/dist/components/option-select/option-select.d.ts +1 -1
- package/dist/components/option-select/option-select.js +22 -16
- package/dist/components/options-panel/options-panel.js +4 -4
- package/dist/components/placeholders/file-picker-shell.js +4 -3
- package/dist/components/placeholders/file-placeholder.js +3 -2
- package/dist/components/popover/popover.js +5 -5
- package/dist/components/portal-provider/portal-provider.js +2 -1
- package/dist/components/prompt-popover/prompt-popover.d.ts +56 -0
- package/dist/components/prompt-popover/prompt-popover.js +81 -0
- package/dist/components/radio/radio.d.ts +2 -1
- package/dist/components/radio/radio.js +2 -2
- package/dist/components/repeater/repeater-context.d.ts +0 -1
- package/dist/components/repeater/repeater-item.js +2 -2
- package/dist/components/repeater/repeater.d.ts +5 -38
- package/dist/components/repeater/repeater.js +8 -11
- package/dist/components/responsive/mini-responsive.d.ts +0 -1
- package/dist/components/responsive/mini-responsive.js +31 -31
- package/dist/components/responsive/responsive-legacy.d.ts +0 -1
- package/dist/components/responsive/responsive-legacy.js +13 -11
- package/dist/components/responsive/responsive.d.ts +0 -1
- package/dist/components/responsive/responsive.js +29 -29
- package/dist/components/responsive-preview/responsive-preview.js +4 -4
- package/dist/components/rich-label/rich-label.d.ts +1 -1
- package/dist/components/rich-label/rich-label.js +2 -2
- package/dist/components/select/async-multi-select.d.ts +12 -13
- package/dist/components/select/async-multi-select.js +40 -21
- package/dist/components/select/async-select.d.ts +12 -13
- package/dist/components/select/async-select.js +39 -21
- package/dist/components/select/multi-select.d.ts +2 -8
- package/dist/components/select/multi-select.js +20 -20
- package/dist/components/select/shared.d.ts +7 -11
- package/dist/components/select/shared.js +2 -2
- package/dist/components/select/single-select.d.ts +2 -8
- package/dist/components/select/single-select.js +17 -17
- package/dist/components/select/styles.d.ts +2 -2
- package/dist/components/slider/column-config-slider.js +8 -6
- package/dist/components/slider/slider.js +16 -12
- package/dist/components/slider/utils.js +1 -1
- package/dist/components/smart-image/smart-image.d.ts +1 -2
- package/dist/components/smart-image/smart-image.js +53 -51
- package/dist/components/tabs/tabs.d.ts +16 -64
- package/dist/components/tabs/tabs.js +1 -1
- package/dist/components/toggle/switch.d.ts +1 -1
- package/dist/components/toggle/switch.js +1 -1
- package/dist/components/toggle/toggle.js +2 -2
- package/dist/components/toggle-button/toggle-button.d.ts +2 -2
- package/dist/components/toggle-button/toggle-button.js +1 -1
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/{draggable-9MfdTVWP.js → draggable-oS68xcYX.js} +130 -125
- package/dist/{es-dash-DunirOmV.js → es-dash-DPtJSRjw.js} +23 -52
- package/dist/{gradient-editor-yqSw0uPA.js → gradient-editor-DP8ioFX1.js} +39 -30
- package/dist/icons/block-icon.js +1 -1
- package/dist/icons/icon.d.ts +3 -3
- package/dist/icons/icon.js +21 -9
- package/dist/icons/icons.d.ts +210 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/jsx-svg.d.ts +5 -4
- package/dist/icons/jsx-svg.js +1 -1
- package/dist/index.js +18 -17
- package/dist/{input-field-nN6BO0oz.js → input-field-C-XvZeCZ.js} +8 -8
- package/dist/{jsx-svg-BjGQUBLh.js → jsx-svg-DRwJdRpA.js} +171 -129
- package/dist/{keyboard-g5Amam-c.js → keyboard-Cdqi5ZQQ.js} +1 -1
- package/dist/{link-input-BhlPElU8.js → link-input-DdwuqoMg.js} +147 -89
- package/dist/{modal-B5axB0Fc.js → modal-DZco5MDu.js} +15 -14
- package/dist/{number-picker-nnOf0XnN.js → number-picker-XqKW0BNi.js} +9 -9
- package/dist/{react-y40Dt3ab.js → react-O71mlJXS.js} +250 -266
- package/dist/{shared-Ba_bt4s9.js → shared-YXMIX2ka.js} +60 -44
- package/dist/{solid-color-picker-CsosgTVa.js → solid-color-picker-D5LEdmDM.js} +78 -58
- package/dist/{switch-BJ4_OyUm.js → switch-Bo6nmed_.js} +8 -8
- package/dist/{tabs-wAe0AAyu.js → tabs-DE-qb7Kt.js} +35 -30
- package/dist/{text-helpers-2j9DuxP1.js → text-helpers-QrwKKaOh.js} +3 -2
- package/dist/{textSelection-B_Nv6Jz3.js → textSelection-C17LWYmO.js} +3 -3
- package/dist/{toggle-button-BLJdEp8V.js → toggle-button-Cb4yCEua.js} +39 -8
- package/dist/{tooltip-BW9nj5-V.js → tooltip-CT-vzIdz.js} +68 -62
- package/dist/{useAsyncList-B3-uyJgA.js → useAsyncList-CjKVLGN0.js} +8 -4
- package/dist/{useButton-CPMVLXoX.js → useButton-V65TBDGM.js} +3 -3
- package/dist/{useCollection-PzY6FI39.js → useCollection-DqUS7tjk.js} +281 -184
- package/dist/useEvent-C9zwSNzZ.js +18 -0
- package/dist/{useField-DrfR8j9h.js → useField-B_ibsWst.js} +2 -2
- package/dist/{useFilter-CiCjo6Na.js → useFilter-C75IzdIZ.js} +1 -1
- package/dist/{useFocusRing-CrYHpV7C.js → useFocusRing-JidySWlU.js} +1 -1
- package/dist/{useFormReset-U6c35PHq.js → useFormReset-Sp8-miDa.js} +1 -1
- package/dist/{useFormValidation-B2q2MGWN.js → useFormValidation-CpmQEh8J.js} +2 -2
- package/dist/{useHover-CNsbAR0V.js → useHover-CaY3sRjL.js} +250 -46
- package/dist/{useLabel-DuxAjaic.js → useLabel-gfFDE4bn.js} +2 -2
- package/dist/{useLabels-NUsp5IW3.js → useLabels-Dcg-cEyM.js} +1 -1
- package/dist/{useListState-FLxa7R_U.js → useListState-CzB3v6M9.js} +6 -11
- package/dist/{useLocalizedStringFormatter-Ccm8EL_u.js → useLocalizedStringFormatter-CTCqjYu4.js} +6 -1
- package/dist/{useNumberFieldState-DWvm7CXu.js → useNumberFieldState-DC3XY3DQ.js} +79 -62
- package/dist/{useNumberFormatter-B0_D7a_o.js → useNumberFormatter-DbAt_fC_.js} +2 -2
- package/dist/{useOverlayTriggerState-zZ7homyI.js → useOverlayTriggerState-BKmSTK_5.js} +16 -11
- package/dist/{usePress-DRoujMNm.js → usePress-CUCWcP-m.js} +50 -28
- package/dist/{useSlot-pRz-v9kC.js → useSlot-CnQHcvd4.js} +1 -1
- package/dist/{useTextField-e8jIFT3s.js → useTextField-C3QIkMON.js} +6 -6
- package/dist/{useToggle-CR_ZKvr_.js → useToggle-bbGRUbo4.js} +6 -6
- package/dist/{useToggleState-ButQxGrJ.js → useToggleState-D_rLMrVW.js} +1 -1
- package/dist/utilities/array-helpers.d.ts +2 -2
- package/dist/utilities/array-helpers.js +4 -3
- package/dist/utilities/debounce-throttle.d.ts +9 -2
- package/dist/utilities/es-dash.d.ts +11 -8
- package/dist/utilities/es-dash.js +1 -1
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/text-helpers.js +1 -1
- package/dist/utilities/web-workers.d.ts +7 -7
- package/dist/utilities/web-workers.js +5 -5
- package/dist/{utils-Czi6q2Ub.js → utils-ClM91CuL.js} +30 -19
- package/package.json +23 -27
- package/dist/useEvent-CzuFZ2HT.js +0 -22
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
2
|
-
import { t as $4b38b5b75ecc6208$export$2f2b9559550c7bbc } from "../../Autocomplete-
|
|
3
|
-
import {
|
|
4
|
-
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-
|
|
5
|
-
import { n as $7705c033048f6da7$export$353f5b6fc5456de1 } from "../../Button-
|
|
6
|
-
import {
|
|
7
|
-
import { r as $41fb335299a4a39e$export$f5b8910cec6cf069 } from "../../useTextField-
|
|
8
|
-
import { c as $c8bb816105474884$export$ef9b1a59e592288f, i as getOptionKey, n as SelectClearButton, r as getGroupedOptions,
|
|
9
|
-
import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, t as $928221da08ecbc62$export$41f133550aa26f48 } from "../../ListBox-
|
|
10
|
-
import { t as $29a5029ff43c9612$export$b94867ecbd698f21 } from "../../SearchField-
|
|
11
|
-
import { t as $c73d3f3d5ec90946$export$bc3384a35de93d66 } from "../../useAsyncList-
|
|
2
|
+
import { t as $4b38b5b75ecc6208$export$2f2b9559550c7bbc } from "../../Autocomplete-Dqkum3dO.js";
|
|
3
|
+
import { y as $42ceafc619f9c3ba$export$fb8073518f34e6ec } from "../../useCollection-DqUS7tjk.js";
|
|
4
|
+
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-C4bJkVti.js";
|
|
5
|
+
import { n as $7705c033048f6da7$export$353f5b6fc5456de1 } from "../../Button-DHgs_rCq.js";
|
|
6
|
+
import { T as $53e61d82d8b8611d$export$8b251419efc915eb, u as $542a13ca2fa5b484$export$5b6b19405a83ff9d } from "../../Dialog-CldDJ_4u.js";
|
|
7
|
+
import { r as $41fb335299a4a39e$export$f5b8910cec6cf069 } from "../../useTextField-C3QIkMON.js";
|
|
8
|
+
import { c as isStringValue, d as $c8bb816105474884$export$ef9b1a59e592288f, i as getOptionKey, n as SelectClearButton, o as isPrimitive, r as getGroupedOptions, t as OptionItemBase, u as $c8bb816105474884$export$e288731fd71264f0 } from "../../shared-YXMIX2ka.js";
|
|
9
|
+
import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, t as $928221da08ecbc62$export$41f133550aa26f48 } from "../../ListBox-CZXso3mJ.js";
|
|
10
|
+
import { t as $29a5029ff43c9612$export$b94867ecbd698f21 } from "../../SearchField-DkX1vqMN.js";
|
|
11
|
+
import { t as $c73d3f3d5ec90946$export$bc3384a35de93d66 } from "../../useAsyncList-CjKVLGN0.js";
|
|
12
12
|
import { RichLabel } from "../rich-label/rich-label.js";
|
|
13
13
|
import { BaseControl } from "../base-control/base-control.js";
|
|
14
|
-
import { i as unescapeHTML } from "../../text-helpers-
|
|
15
|
-
import { t as __ } from "../../build-module-
|
|
14
|
+
import { i as unescapeHTML } from "../../text-helpers-QrwKKaOh.js";
|
|
15
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
16
16
|
import { Icon } from "../../icons/icon.js";
|
|
17
17
|
import { Spinner } from "../../icons/spinner.js";
|
|
18
18
|
import { clearAlt } from "../../icons/ui-icons/clear-alt.js";
|
|
@@ -22,20 +22,32 @@ import { selectButtonClass, selectControlClass } from "./styles.js";
|
|
|
22
22
|
import { cloneElement, useMemo, useRef } from "react";
|
|
23
23
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
24
|
//#region lib/components/select/async-select.tsx
|
|
25
|
+
var getRawItemValue = (item, key) => {
|
|
26
|
+
return Object.entries(item).find(([entryKey]) => entryKey === key)?.[1];
|
|
27
|
+
};
|
|
28
|
+
var setRawItemValue = (item, key, value) => {
|
|
29
|
+
Object.defineProperty(item, key, {
|
|
30
|
+
configurable: true,
|
|
31
|
+
enumerable: true,
|
|
32
|
+
value,
|
|
33
|
+
writable: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
var isNumberValue = (value) => Object.prototype.toString.call(value) === "[object Number]";
|
|
25
37
|
var getPopoverStyle = (triggerElement) => ({ "--select-width": triggerElement ? `${triggerElement.offsetWidth}px` : "var(--trigger-width)" });
|
|
26
38
|
var renderOptionIcon = (icon) => icon ? jsx(Icon, { icon }) : null;
|
|
27
39
|
var getKeyFromSelection = (selected) => {
|
|
28
40
|
if (!selected || selected === "all") return null;
|
|
29
41
|
for (const key of selected) {
|
|
30
|
-
if (
|
|
31
|
-
if (
|
|
42
|
+
if (isStringValue(key)) return key;
|
|
43
|
+
if (isNumberValue(key)) return String(key);
|
|
32
44
|
}
|
|
33
45
|
return null;
|
|
34
46
|
};
|
|
35
47
|
var getKeyFromValue = (selected) => {
|
|
36
48
|
if (selected === null || selected === void 0) return null;
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
49
|
+
if (isStringValue(selected)) return selected;
|
|
50
|
+
if (isNumberValue(selected)) return String(selected);
|
|
39
51
|
return null;
|
|
40
52
|
};
|
|
41
53
|
/**
|
|
@@ -59,8 +71,14 @@ var getKeyFromValue = (selected) => {
|
|
|
59
71
|
* />
|
|
60
72
|
*/
|
|
61
73
|
var AsyncSelect = (props) => {
|
|
62
|
-
const { label, help, icon, subtitle, actions, inline, value: rawValue, onChange, disabled = false, clearable = false, className, placeholder = __("Select...", "eightshift-ui-components"), customMenuOption, customValueDisplay, customDropdownArrow, processLoadedOptions = (options) => options, fetchUrl, fetchConfig = {}, fetchFunction, getLabel = (item) =>
|
|
63
|
-
|
|
74
|
+
const { label, help, icon, subtitle, actions, inline, value: rawValue, onChange, disabled = false, clearable = false, className, placeholder = __("Select...", "eightshift-ui-components"), customMenuOption, customValueDisplay, customDropdownArrow, processLoadedOptions = (options) => options, fetchUrl, fetchConfig = {}, fetchFunction, getLabel = (item) => {
|
|
75
|
+
const itemLabel = getRawItemValue(item, "label");
|
|
76
|
+
return isStringValue(itemLabel) ? itemLabel : void 0;
|
|
77
|
+
}, getValue = (item) => {
|
|
78
|
+
const itemValue = getRawItemValue(item, "value");
|
|
79
|
+
return isPrimitive(itemValue) ? itemValue : void 0;
|
|
80
|
+
}, getMeta, getIcon, getSubtitle, getGroup, getData = (data) => Array.isArray(data) ? data : data.jokes ?? [], extraItemProps, hidden, groupKey, groupValueMapping, flat, size = "default", noMinWidth = false, ...rest } = props;
|
|
81
|
+
const value = rawValue;
|
|
64
82
|
const ref = useRef(null);
|
|
65
83
|
const list = $c73d3f3d5ec90946$export$bc3384a35de93d66({
|
|
66
84
|
initialSelectedKeys: value ? [getOptionKey(value.value)] : [],
|
|
@@ -88,9 +106,9 @@ var AsyncSelect = (props) => {
|
|
|
88
106
|
}
|
|
89
107
|
if (getSubtitle) entry.subtitle = (unescapeHTML(getSubtitle(item) ?? "") ?? "") || void 0;
|
|
90
108
|
if (getIcon) entry.icon = getIcon(item);
|
|
91
|
-
if (getGroup) entry
|
|
109
|
+
if (getGroup) setRawItemValue(entry, groupKey ?? "_group", getGroup(item));
|
|
92
110
|
if (extraItemProps?.length) extraItemProps.forEach((propName) => {
|
|
93
|
-
entry
|
|
111
|
+
setRawItemValue(entry, propName, getRawItemValue(item, propName));
|
|
94
112
|
});
|
|
95
113
|
return entry;
|
|
96
114
|
});
|
|
@@ -199,7 +217,7 @@ var AsyncSelect = (props) => {
|
|
|
199
217
|
placement: "bottom left",
|
|
200
218
|
maxHeight: 260,
|
|
201
219
|
triggerRef: ref,
|
|
202
|
-
style: getPopoverStyle(
|
|
220
|
+
style: getPopoverStyle(null),
|
|
203
221
|
children: jsxs($4b38b5b75ecc6208$export$2f2b9559550c7bbc, {
|
|
204
222
|
inputValue: list.filterText,
|
|
205
223
|
onInputChange: (text) => list.setFilterText(text),
|
|
@@ -7,18 +7,12 @@ type SelectSize = 'small' | 'medium' | 'default' | 'large';
|
|
|
7
7
|
type SelectOption = {
|
|
8
8
|
label: string;
|
|
9
9
|
value: Primitive;
|
|
10
|
-
metadata?:
|
|
10
|
+
metadata?: object | null;
|
|
11
11
|
subtitle?: ReactNode;
|
|
12
12
|
icon?: IconValue;
|
|
13
13
|
className?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
14
|
};
|
|
16
|
-
type GroupValueMapping =
|
|
17
|
-
label?: ReactNode;
|
|
18
|
-
icon?: IconValue;
|
|
19
|
-
subtitle?: ReactNode;
|
|
20
|
-
endIcon?: IconValue;
|
|
21
|
-
}>;
|
|
15
|
+
type GroupValueMapping = object;
|
|
22
16
|
type MultiSelectValueType = SelectOption[] | Primitive[] | '' | null;
|
|
23
17
|
type MultiSelectProps = Omit<ReactAriaSelectProps<SelectOption, 'multiple'>, 'children' | 'className' | 'isDisabled' | 'items' | 'placeholder' | 'selectionMode'> & {
|
|
24
18
|
/** Icon of the component. */
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
2
|
-
import { t as $4b38b5b75ecc6208$export$2f2b9559550c7bbc } from "../../Autocomplete-
|
|
3
|
-
import {
|
|
4
|
-
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-
|
|
5
|
-
import { n as $7705c033048f6da7$export$353f5b6fc5456de1 } from "../../Button-
|
|
6
|
-
import {
|
|
7
|
-
import { r as $41fb335299a4a39e$export$f5b8910cec6cf069 } from "../../useTextField-
|
|
8
|
-
import { c as $c8bb816105474884$export$ef9b1a59e592288f, i as getOptionKey, n as SelectClearButton, r as getGroupedOptions, s as
|
|
9
|
-
import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, t as $928221da08ecbc62$export$41f133550aa26f48 } from "../../ListBox-
|
|
10
|
-
import { t as $ef182bb9912241d8$export$3274cf84b703fff } from "../../useFilter-
|
|
11
|
-
import { t as $29a5029ff43c9612$export$b94867ecbd698f21 } from "../../SearchField-
|
|
2
|
+
import { t as $4b38b5b75ecc6208$export$2f2b9559550c7bbc } from "../../Autocomplete-Dqkum3dO.js";
|
|
3
|
+
import { y as $42ceafc619f9c3ba$export$fb8073518f34e6ec } from "../../useCollection-DqUS7tjk.js";
|
|
4
|
+
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-C4bJkVti.js";
|
|
5
|
+
import { n as $7705c033048f6da7$export$353f5b6fc5456de1 } from "../../Button-DHgs_rCq.js";
|
|
6
|
+
import { T as $53e61d82d8b8611d$export$8b251419efc915eb, u as $542a13ca2fa5b484$export$5b6b19405a83ff9d } from "../../Dialog-CldDJ_4u.js";
|
|
7
|
+
import { r as $41fb335299a4a39e$export$f5b8910cec6cf069 } from "../../useTextField-C3QIkMON.js";
|
|
8
|
+
import { c as isStringValue, d as $c8bb816105474884$export$ef9b1a59e592288f, i as getOptionKey, n as SelectClearButton, r as getGroupedOptions, s as isSelectOption, t as OptionItemBase, u as $c8bb816105474884$export$e288731fd71264f0 } from "../../shared-YXMIX2ka.js";
|
|
9
|
+
import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, t as $928221da08ecbc62$export$41f133550aa26f48 } from "../../ListBox-CZXso3mJ.js";
|
|
10
|
+
import { t as $ef182bb9912241d8$export$3274cf84b703fff } from "../../useFilter-C75IzdIZ.js";
|
|
11
|
+
import { t as $29a5029ff43c9612$export$b94867ecbd698f21 } from "../../SearchField-DkX1vqMN.js";
|
|
12
12
|
import { RichLabel } from "../rich-label/rich-label.js";
|
|
13
13
|
import { BaseControl } from "../base-control/base-control.js";
|
|
14
14
|
import { t as sprintf } from "../../sprintf-xJRAt4p0.js";
|
|
15
|
-
import { n as _n, t as __ } from "../../build-module-
|
|
15
|
+
import { n as _n, t as __ } from "../../build-module-BISCoQjQ.js";
|
|
16
16
|
import { Icon } from "../../icons/icon.js";
|
|
17
17
|
import { clearAlt } from "../../icons/ui-icons/clear-alt.js";
|
|
18
18
|
import { dropdownCaret } from "../../icons/ui-icons/dropdown-caret.js";
|
|
@@ -28,25 +28,25 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
28
28
|
//#region lib/components/select/multi-select.tsx
|
|
29
29
|
var TypedDraggableList = DraggableList;
|
|
30
30
|
var getSearchableText = (content) => {
|
|
31
|
-
if (
|
|
31
|
+
if (isStringValue(content)) return content;
|
|
32
32
|
return "";
|
|
33
33
|
};
|
|
34
34
|
var getPopoverStyle = (triggerElement) => ({ "--select-width": triggerElement ? `${triggerElement.offsetWidth}px` : "var(--trigger-width)" });
|
|
35
35
|
var getSelectedKeys = (value) => {
|
|
36
36
|
if (!Array.isArray(value)) return [];
|
|
37
|
-
return value.map((item) =>
|
|
37
|
+
return value.map((item) => isSelectOption(item) ? getOptionKey(item.value) : getOptionKey(item));
|
|
38
38
|
};
|
|
39
39
|
var getCurrentValue = (value, simpleValue, options) => {
|
|
40
40
|
if (!Array.isArray(value)) return [];
|
|
41
|
-
if (!simpleValue) return value.filter((item) =>
|
|
41
|
+
if (!simpleValue) return value.filter((item) => isSelectOption(item));
|
|
42
42
|
return value.map((item) => {
|
|
43
|
-
const itemValue =
|
|
43
|
+
const itemValue = isSelectOption(item) ? item.value : item;
|
|
44
44
|
return options.find((option) => getOptionKey(option.value) === getOptionKey(itemValue));
|
|
45
45
|
}).filter((item) => Boolean(item));
|
|
46
46
|
};
|
|
47
47
|
var getOptionIcon = (icon) => {
|
|
48
48
|
if (!icon) return;
|
|
49
|
-
return
|
|
49
|
+
return isStringValue(icon) ? jsx(Icon, { icon }) : icon;
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* Multi-select menu.
|
|
@@ -113,7 +113,7 @@ var MultiSelect = (props) => {
|
|
|
113
113
|
onChange(null);
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
const selectedKeys = selected.filter((item) =>
|
|
116
|
+
const selectedKeys = selected.filter((item) => isStringValue(item));
|
|
117
117
|
if (selectedKeys.length === 0) {
|
|
118
118
|
onChange(simpleValue ? "" : []);
|
|
119
119
|
return;
|
|
@@ -215,7 +215,7 @@ var MultiSelect = (props) => {
|
|
|
215
215
|
className: "es:grid es:grid-cols-1 es:grid-rows-[auto_minmax(0,1fr)] es:p-0!",
|
|
216
216
|
wrapperClassName: "es:w-(--select-width) es:min-w-72 es:px-1.5 es:h-fit es:from-surface-300/35 es:to-surface-300/35 es:overflow-clip es:rounded-20!",
|
|
217
217
|
hidden: noReorder || disabled || currentValue.length < 2,
|
|
218
|
-
style: getPopoverStyle(
|
|
218
|
+
style: getPopoverStyle(null),
|
|
219
219
|
children: [jsx("span", {
|
|
220
220
|
className: "es:text-sm es:ml-3 es:mt-2 es:mb-1 es:font-variation-[\"wdth\"_100,\"wght\"_325,\"ROND\"_100] es:text-surface-600",
|
|
221
221
|
children: __("Item order", "eightshift-ui-components")
|
|
@@ -232,7 +232,7 @@ var MultiSelect = (props) => {
|
|
|
232
232
|
return jsx(DraggableListItem, {
|
|
233
233
|
icon: getOptionIcon(realItem?.icon),
|
|
234
234
|
label: realItem?.label,
|
|
235
|
-
subtitle:
|
|
235
|
+
subtitle: isStringValue(realItem?.subtitle) ? realItem.subtitle : void 0,
|
|
236
236
|
iconClassName: "es:pointer-events-none es:select-none",
|
|
237
237
|
labelClassName: "es:line-clamp-1",
|
|
238
238
|
subtitleClassName: "es:line-clamp-1",
|
|
@@ -247,7 +247,7 @@ var MultiSelect = (props) => {
|
|
|
247
247
|
placement: "bottom left",
|
|
248
248
|
maxHeight: 260,
|
|
249
249
|
triggerRef: ref,
|
|
250
|
-
style: getPopoverStyle(
|
|
250
|
+
style: getPopoverStyle(null),
|
|
251
251
|
children: searchable ? jsxs($4b38b5b75ecc6208$export$2f2b9559550c7bbc, {
|
|
252
252
|
filter: () => true,
|
|
253
253
|
inputValue: searchTerm,
|
|
@@ -2,19 +2,15 @@ import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
|
2
2
|
import { ListBoxItem } from 'react-aria-components';
|
|
3
3
|
import type { Prettify } from '../../utilities/types';
|
|
4
4
|
export type Primitive = string | number | boolean;
|
|
5
|
+
export declare const isPrimitive: <T>(value: T) => value is T & Primitive;
|
|
6
|
+
export declare const isStringValue: <T>(value: T) => value is T & string;
|
|
5
7
|
export declare const getOptionKey: (value: Primitive) => string;
|
|
6
|
-
type IconValue = string | JSX.Element | null;
|
|
7
8
|
type SelectOption<Value extends Primitive = string> = {
|
|
8
9
|
label: string;
|
|
9
10
|
value: Value;
|
|
10
|
-
[key: string]: unknown;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
icon?: IconValue;
|
|
15
|
-
subtitle?: ReactNode;
|
|
16
|
-
endIcon?: IconValue;
|
|
17
|
-
}>;
|
|
12
|
+
export declare const isSelectOption: <T>(value: T) => value is T & SelectOption<Primitive>;
|
|
13
|
+
type GroupValueMapping = object;
|
|
18
14
|
type GroupedOption<Option extends SelectOption<Primitive> = SelectOption> = {
|
|
19
15
|
key: string;
|
|
20
16
|
label: ReactNode;
|
|
@@ -46,7 +42,7 @@ export declare const OptionItemBase: (props: Prettify<OptionItemBaseProps>) => i
|
|
|
46
42
|
*
|
|
47
43
|
* @returns {SelectOption[] | SelectOption | Primitive[] | Primitive | undefined} Appropriate output for the given input combination.
|
|
48
44
|
*/
|
|
49
|
-
export declare const getValue: (simpleValue: boolean, value: SelectOption<Primitive>[] | SelectOption<Primitive> | Primitive[] | Primitive, options?: SelectOption<Primitive>[]) => Primitive | SelectOption<Primitive> |
|
|
45
|
+
export declare const getValue: (simpleValue: boolean, value: SelectOption<Primitive>[] | SelectOption<Primitive> | Primitive[] | Primitive, options?: SelectOption<Primitive>[]) => Primitive[] | (SelectOption<Primitive> | undefined)[] | SelectOption<Primitive> | Primitive | undefined;
|
|
50
46
|
/**
|
|
51
47
|
* Moves an array item before or after another item in the array.
|
|
52
48
|
*
|
|
@@ -57,7 +53,7 @@ export declare const getValue: (simpleValue: boolean, value: SelectOption<Primit
|
|
|
57
53
|
* @param {'before' | 'after'} [position='before'] - Where to place the moved item.
|
|
58
54
|
* @returns {Item[]} New array with the item moved.
|
|
59
55
|
*/
|
|
60
|
-
export declare const moveArrayItem: <Item>(array: Item[], itemToMove: Item, targetItem: Item, position?:
|
|
56
|
+
export declare const moveArrayItem: <Item>(array: Item[], itemToMove: Item, targetItem: Item, position?: 'before' | 'after') => Item[];
|
|
61
57
|
export declare const SelectClearButton: ({ multi }: Prettify<SelectClearButtonProps>) => import("react").JSX.Element;
|
|
62
58
|
/**
|
|
63
59
|
* Groups options by a key.
|
|
@@ -68,5 +64,5 @@ export declare const SelectClearButton: ({ multi }: Prettify<SelectClearButtonPr
|
|
|
68
64
|
*
|
|
69
65
|
* @returns {GroupedOption[] | null} Grouped options.
|
|
70
66
|
*/
|
|
71
|
-
export declare const getGroupedOptions: <Option extends SelectOption<Primitive
|
|
67
|
+
export declare const getGroupedOptions: <Option extends SelectOption<Primitive>, Mapping extends object = GroupValueMapping>(filteredOptions?: Option[] | null, groupKey?: string, groupValueMapping?: Mapping) => GroupedOption<Option>[] | null;
|
|
72
68
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getValue, i as getOptionKey, n as SelectClearButton, o as
|
|
2
|
-
export { OptionItemBase, SelectClearButton, getGroupedOptions, getOptionKey, getValue, moveArrayItem };
|
|
1
|
+
import { a as getValue, c as isStringValue, i as getOptionKey, l as moveArrayItem, n as SelectClearButton, o as isPrimitive, r as getGroupedOptions, s as isSelectOption, t as OptionItemBase } from "../../shared-YXMIX2ka.js";
|
|
2
|
+
export { OptionItemBase, SelectClearButton, getGroupedOptions, getOptionKey, getValue, isPrimitive, isSelectOption, isStringValue, moveArrayItem };
|
|
@@ -7,18 +7,12 @@ type SelectSize = 'small' | 'medium' | 'default' | 'large';
|
|
|
7
7
|
type SelectOption = {
|
|
8
8
|
label: string;
|
|
9
9
|
value: Primitive;
|
|
10
|
-
metadata?:
|
|
10
|
+
metadata?: object | null;
|
|
11
11
|
subtitle?: ReactNode;
|
|
12
12
|
icon?: IconValue;
|
|
13
13
|
className?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
14
|
};
|
|
16
|
-
type GroupValueMapping =
|
|
17
|
-
label?: ReactNode;
|
|
18
|
-
icon?: IconValue;
|
|
19
|
-
subtitle?: ReactNode;
|
|
20
|
-
endIcon?: IconValue;
|
|
21
|
-
}>;
|
|
15
|
+
type GroupValueMapping = object;
|
|
22
16
|
type SelectValueType = SelectOption | Primitive | null;
|
|
23
17
|
type SelectProps = Omit<ReactAriaSelectProps<SelectOption>, 'children' | 'className' | 'isDisabled' | 'selectedKey' | 'onSelectionChange' | 'items' | 'placeholder'> & {
|
|
24
18
|
/** Icon of the component. */
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
2
|
-
import { t as $4b38b5b75ecc6208$export$2f2b9559550c7bbc } from "../../Autocomplete-
|
|
3
|
-
import {
|
|
4
|
-
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-
|
|
5
|
-
import { n as $7705c033048f6da7$export$353f5b6fc5456de1 } from "../../Button-
|
|
6
|
-
import {
|
|
7
|
-
import { r as $41fb335299a4a39e$export$f5b8910cec6cf069 } from "../../useTextField-
|
|
8
|
-
import { c as $c8bb816105474884$export$ef9b1a59e592288f, i as getOptionKey, n as SelectClearButton, r as getGroupedOptions,
|
|
9
|
-
import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, t as $928221da08ecbc62$export$41f133550aa26f48 } from "../../ListBox-
|
|
10
|
-
import { t as $ef182bb9912241d8$export$3274cf84b703fff } from "../../useFilter-
|
|
11
|
-
import { t as $29a5029ff43c9612$export$b94867ecbd698f21 } from "../../SearchField-
|
|
2
|
+
import { t as $4b38b5b75ecc6208$export$2f2b9559550c7bbc } from "../../Autocomplete-Dqkum3dO.js";
|
|
3
|
+
import { y as $42ceafc619f9c3ba$export$fb8073518f34e6ec } from "../../useCollection-DqUS7tjk.js";
|
|
4
|
+
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-C4bJkVti.js";
|
|
5
|
+
import { n as $7705c033048f6da7$export$353f5b6fc5456de1 } from "../../Button-DHgs_rCq.js";
|
|
6
|
+
import { T as $53e61d82d8b8611d$export$8b251419efc915eb, u as $542a13ca2fa5b484$export$5b6b19405a83ff9d } from "../../Dialog-CldDJ_4u.js";
|
|
7
|
+
import { r as $41fb335299a4a39e$export$f5b8910cec6cf069 } from "../../useTextField-C3QIkMON.js";
|
|
8
|
+
import { c as isStringValue, d as $c8bb816105474884$export$ef9b1a59e592288f, i as getOptionKey, n as SelectClearButton, o as isPrimitive, r as getGroupedOptions, t as OptionItemBase, u as $c8bb816105474884$export$e288731fd71264f0 } from "../../shared-YXMIX2ka.js";
|
|
9
|
+
import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, t as $928221da08ecbc62$export$41f133550aa26f48 } from "../../ListBox-CZXso3mJ.js";
|
|
10
|
+
import { t as $ef182bb9912241d8$export$3274cf84b703fff } from "../../useFilter-C75IzdIZ.js";
|
|
11
|
+
import { t as $29a5029ff43c9612$export$b94867ecbd698f21 } from "../../SearchField-DkX1vqMN.js";
|
|
12
12
|
import { RichLabel } from "../rich-label/rich-label.js";
|
|
13
13
|
import { BaseControl } from "../base-control/base-control.js";
|
|
14
|
-
import { t as __ } from "../../build-module-
|
|
14
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
15
15
|
import { Icon } from "../../icons/icon.js";
|
|
16
16
|
import { clearAlt } from "../../icons/ui-icons/clear-alt.js";
|
|
17
17
|
import { dropdownCaret } from "../../icons/ui-icons/dropdown-caret.js";
|
|
@@ -21,13 +21,13 @@ import { cloneElement, useMemo, useRef, useState } from "react";
|
|
|
21
21
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
22
|
//#region lib/components/select/single-select.tsx
|
|
23
23
|
var getSelectedKey = (value, simpleValue) => {
|
|
24
|
-
if (simpleValue) return
|
|
25
|
-
if (!value ||
|
|
24
|
+
if (simpleValue) return isPrimitive(value) ? getOptionKey(value) : null;
|
|
25
|
+
if (!value || !(value instanceof Object)) return null;
|
|
26
26
|
const selectedValue = value.value;
|
|
27
|
-
return
|
|
27
|
+
return isPrimitive(selectedValue) ? getOptionKey(selectedValue) : null;
|
|
28
28
|
};
|
|
29
29
|
var getSearchableText = (content) => {
|
|
30
|
-
if (
|
|
30
|
+
if (isStringValue(content)) return content;
|
|
31
31
|
return "";
|
|
32
32
|
};
|
|
33
33
|
var getPopoverStyle = (triggerElement) => ({ "--select-width": triggerElement ? `${triggerElement.offsetWidth}px` : "var(--trigger-width)" });
|
|
@@ -102,7 +102,7 @@ var Select = (props) => {
|
|
|
102
102
|
onChange(null);
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
105
|
+
if (!isStringValue(selected)) {
|
|
106
106
|
onChange(null);
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
@@ -175,7 +175,7 @@ var Select = (props) => {
|
|
|
175
175
|
placement: "bottom left",
|
|
176
176
|
maxHeight: 260,
|
|
177
177
|
triggerRef: ref,
|
|
178
|
-
style: getPopoverStyle(
|
|
178
|
+
style: getPopoverStyle(null),
|
|
179
179
|
children: searchable ? jsxs($4b38b5b75ecc6208$export$2f2b9559550c7bbc, {
|
|
180
180
|
filter: () => true,
|
|
181
181
|
inputValue: searchTerm,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const selectButtonClass: (props?: ({
|
|
2
|
-
size?: "
|
|
2
|
+
size?: "default" | "large" | "medium" | "small" | null | undefined;
|
|
3
3
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
4
|
export declare const selectControlClass: (props?: ({
|
|
5
5
|
disabled?: boolean | null | undefined;
|
|
@@ -8,5 +8,5 @@ export declare const selectControlClass: (props?: ({
|
|
|
8
8
|
inline?: boolean | null | undefined;
|
|
9
9
|
flat?: boolean | null | undefined;
|
|
10
10
|
readOnly?: boolean | null | undefined;
|
|
11
|
-
size?: "
|
|
11
|
+
size?: "default" | "large" | "medium" | "small" | null | undefined;
|
|
12
12
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { n as AnimatePresence, t as motion } from "../../react-y40Dt3ab.js";
|
|
2
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
3
|
-
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-
|
|
4
|
-
import { i as $806e559d0c2c64a0$export$472062a354075cee, o as $806e559d0c2c64a0$export$a590f758a961cb5b, r as $806e559d0c2c64a0$export$2c1b491743890dec, t as $806e559d0c2c64a0$export$105594979f116971 } from "../../Slider-
|
|
2
|
+
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-C4bJkVti.js";
|
|
3
|
+
import { i as $806e559d0c2c64a0$export$472062a354075cee, o as $806e559d0c2c64a0$export$a590f758a961cb5b, r as $806e559d0c2c64a0$export$2c1b491743890dec, t as $806e559d0c2c64a0$export$105594979f116971 } from "../../Slider-Dw-JjfLx.js";
|
|
5
4
|
import { BaseControl } from "../base-control/base-control.js";
|
|
6
5
|
import { t as sprintf } from "../../sprintf-xJRAt4p0.js";
|
|
7
|
-
import { t as __ } from "../../build-module-
|
|
6
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
8
7
|
import { chevronLeft } from "../../icons/ui-icons/chevron-left.js";
|
|
9
8
|
import { chevronRight } from "../../icons/ui-icons/chevron-right.js";
|
|
9
|
+
import { n as AnimatePresence, t as motion } from "../../react-O71mlJXS.js";
|
|
10
10
|
import { getColumnConfigOutputText } from "./utils.js";
|
|
11
11
|
import "react";
|
|
12
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region lib/components/slider/column-config-slider.tsx
|
|
14
|
+
var isNumberValue = (value) => Object.prototype.toString.call(value) === "[object Number]";
|
|
14
15
|
var getColumnConfigValue = (value) => {
|
|
15
16
|
if (!Array.isArray(value) || value.length !== 2) return null;
|
|
16
17
|
const [startValue, endValue] = value;
|
|
17
|
-
if (
|
|
18
|
+
if (!isNumberValue(startValue) || !isNumberValue(endValue)) return null;
|
|
18
19
|
return [startValue, endValue];
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
@@ -166,7 +167,8 @@ var ColumnConfigSliderOutput = ({ showOuterAsGutter }) => jsx($806e559d0c2c64a0$
|
|
|
166
167
|
children: ({ state }) => {
|
|
167
168
|
const columns = state.getThumbMaxValue(1);
|
|
168
169
|
const offset = parseInt(state.getThumbValueLabel(0), 10);
|
|
169
|
-
|
|
170
|
+
const width = parseInt(state.getThumbValueLabel(1), 10) - offset + 1;
|
|
171
|
+
return getColumnConfigOutputText(columns, offset, width, showOuterAsGutter);
|
|
170
172
|
}
|
|
171
173
|
});
|
|
172
174
|
//#endregion
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { n as AnimatePresence, t as motion } from "../../react-y40Dt3ab.js";
|
|
2
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
3
|
-
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-
|
|
4
|
-
import { i as $806e559d0c2c64a0$export$472062a354075cee, o as $806e559d0c2c64a0$export$a590f758a961cb5b, r as $806e559d0c2c64a0$export$2c1b491743890dec, t as $806e559d0c2c64a0$export$105594979f116971 } from "../../Slider-
|
|
5
|
-
import { t as NumberPicker } from "../../number-picker-
|
|
2
|
+
import { n as $43a3b93638fe5db9$export$b04be29aa201d4f5 } from "../../Label-C4bJkVti.js";
|
|
3
|
+
import { i as $806e559d0c2c64a0$export$472062a354075cee, o as $806e559d0c2c64a0$export$a590f758a961cb5b, r as $806e559d0c2c64a0$export$2c1b491743890dec, t as $806e559d0c2c64a0$export$105594979f116971 } from "../../Slider-Dw-JjfLx.js";
|
|
4
|
+
import { t as NumberPicker } from "../../number-picker-XqKW0BNi.js";
|
|
6
5
|
import { BaseControl } from "../base-control/base-control.js";
|
|
7
|
-
import { t as __ } from "../../build-module-
|
|
6
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
8
7
|
import { HStack } from "../layout/hstack.js";
|
|
8
|
+
import { n as AnimatePresence, t as motion } from "../../react-O71mlJXS.js";
|
|
9
9
|
import { generateGridTemplate, generateMarkers } from "./utils.js";
|
|
10
10
|
import { useState } from "react";
|
|
11
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
//#region lib/components/slider/slider.tsx
|
|
13
|
+
var isNumberValue = (value) => Object.prototype.toString.call(value) === "[object Number]";
|
|
14
|
+
var isStringValue = (value) => Object.prototype.toString.call(value) === "[object String]";
|
|
15
|
+
var isMarkerMap = (markers) => markers !== true && markers !== "dots" && markers !== "lines";
|
|
13
16
|
/**
|
|
14
17
|
* A single/multi-thumb slider component.
|
|
15
18
|
*
|
|
@@ -32,13 +35,13 @@ var Slider = (props) => {
|
|
|
32
35
|
let startPoint = rawStartPoint ?? null;
|
|
33
36
|
if (Array.isArray(value) && rawStartPoint) startPoint = null;
|
|
34
37
|
let generatedMarkers = {};
|
|
35
|
-
if (markers &&
|
|
38
|
+
if (markers && isMarkerMap(markers) && Object.keys(markers).length > 0) generatedMarkers = markers;
|
|
36
39
|
if (markers === true || markers === "dots") generatedMarkers = generateMarkers(min, max, markerStep);
|
|
37
40
|
const markerEntries = Object.entries(generatedMarkers);
|
|
38
41
|
markerEntries.sort((firstEntry, secondEntry) => parseFloat(firstEntry[0]) - parseFloat(secondEntry[0]));
|
|
39
42
|
const markerData = vertical ? [...markerEntries].reverse() : markerEntries;
|
|
40
43
|
const isRange = Array.isArray(value);
|
|
41
|
-
const singleValue =
|
|
44
|
+
const singleValue = isNumberValue(value) ? value : value[0] ?? min;
|
|
42
45
|
return jsx($806e559d0c2c64a0$export$472062a354075cee, {
|
|
43
46
|
value,
|
|
44
47
|
onChange,
|
|
@@ -62,7 +65,7 @@ var Slider = (props) => {
|
|
|
62
65
|
children: ({ state }) => state.values.map((_, index) => state.getThumbValueLabel(index)).join(" – ")
|
|
63
66
|
}) : null,
|
|
64
67
|
inputField && !isRange ? jsx(NumberPicker, {
|
|
65
|
-
"aria-label":
|
|
68
|
+
"aria-label": isStringValue(label) ? label : __("Slider value", "eightshift-ui-components"),
|
|
66
69
|
value: singleValue,
|
|
67
70
|
onChange: (nextValue) => onChange(nextValue),
|
|
68
71
|
min,
|
|
@@ -80,7 +83,7 @@ var Slider = (props) => {
|
|
|
80
83
|
jsx($806e559d0c2c64a0$export$105594979f116971, {
|
|
81
84
|
className: clsx("es:isolate", vertical && "es:mx-auto es:h-48", !vertical && "es:grow"),
|
|
82
85
|
children: ({ state }) => {
|
|
83
|
-
const stateValues = state.values.filter(
|
|
86
|
+
const stateValues = state.values.filter(isNumberValue);
|
|
84
87
|
const firstStateValue = stateValues[0] ?? min;
|
|
85
88
|
const lastStateValue = stateValues.at(-1) ?? firstStateValue;
|
|
86
89
|
let gridTemplate = generateGridTemplate(stateValues.map((_, index) => Math.round(state.getThumbPercent(index) * 100)), startPoint, { spaceBetween: 3 });
|
|
@@ -114,9 +117,10 @@ var Slider = (props) => {
|
|
|
114
117
|
const dotValue = parseFloat(rawDotValue);
|
|
115
118
|
let isWithinActiveBar = false;
|
|
116
119
|
if (isRange) isWithinActiveBar = dotValue > firstStateValue && dotValue < lastStateValue;
|
|
117
|
-
else if (startPoint !== null)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
else if (startPoint !== null) {
|
|
121
|
+
if (firstStateValue < startPoint) isWithinActiveBar = dotValue > firstStateValue && dotValue <= startPoint;
|
|
122
|
+
else isWithinActiveBar = dotValue >= startPoint && dotValue < firstStateValue;
|
|
123
|
+
} else isWithinActiveBar = dotValue < firstStateValue;
|
|
120
124
|
return jsx("div", {
|
|
121
125
|
className: clsx("es:relative", "es:size-0.75 es:place-self-center es:rounded-2xl", !disabled && isWithinActiveBar && "es:bg-accent-50", !disabled && !isWithinActiveBar && "es:bg-surface-500", disabled && isWithinActiveBar && "es:bg-secondary-300", disabled && !isWithinActiveBar && "es:bg-secondary-400", stateValues.includes(dotValue) && "es:opacity-0"),
|
|
122
126
|
children: jsx("span", {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as sprintf } from "../../sprintf-xJRAt4p0.js";
|
|
2
|
-
import { n as _n, t as __ } from "../../build-module-
|
|
2
|
+
import { n as _n, t as __ } from "../../build-module-BISCoQjQ.js";
|
|
3
3
|
//#region lib/components/slider/utils.ts
|
|
4
4
|
/**
|
|
5
5
|
* Generates an array of markers based on the provided minimum and maximum values and step.
|
|
@@ -3,7 +3,6 @@ import type { Prettify } from '../../utilities/types';
|
|
|
3
3
|
type AnalysisSource = 'worker' | 'cache' | 'analysisData';
|
|
4
4
|
type ImageAnalysisSettings = {
|
|
5
5
|
numColors?: number;
|
|
6
|
-
[key: string]: unknown;
|
|
7
6
|
};
|
|
8
7
|
type SmartImageColor = {
|
|
9
8
|
color: string;
|
|
@@ -97,5 +96,5 @@ type SmartImageProps = SmartImageImageProps & {
|
|
|
97
96
|
* )}
|
|
98
97
|
* </SmartImage>
|
|
99
98
|
*/
|
|
100
|
-
declare const SmartImage: (props: Prettify<SmartImageProps>) => string | number | boolean |
|
|
99
|
+
declare const SmartImage: (props: Prettify<SmartImageProps>) => string | number | boolean | import("react").JSX.Element | Iterable<ReactNode> | null | undefined;
|
|
101
100
|
export { SmartImage, SmartImage as __SmartImage };
|