@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,13 +1,13 @@
|
|
|
1
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
2
2
|
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
3
|
+
import { t as DecorativeTooltip } from "../../tooltip-CT-vzIdz.js";
|
|
4
|
+
import { t as ToggleButton } from "../../toggle-button-Cb4yCEua.js";
|
|
5
|
+
import { t as Button } from "../../button-ldR_tlvk.js";
|
|
6
6
|
import { BaseControl } from "../base-control/base-control.js";
|
|
7
|
-
import { f as upperFirst } from "../../es-dash-
|
|
7
|
+
import { f as upperFirst } from "../../es-dash-DPtJSRjw.js";
|
|
8
8
|
import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
|
|
9
9
|
import { t as sprintf } from "../../sprintf-xJRAt4p0.js";
|
|
10
|
-
import { t as __ } from "../../build-module-
|
|
10
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
11
11
|
import { Icon } from "../../icons/icon.js";
|
|
12
12
|
import { clearAlt } from "../../icons/ui-icons/clear-alt.js";
|
|
13
13
|
import { play } from "../../icons/ui-icons/play.js";
|
|
@@ -15,11 +15,13 @@ import { responsiveOverridesAlt } from "../../icons/ui-icons/responsive-override
|
|
|
15
15
|
import { useState } from "react";
|
|
16
16
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
//#region lib/components/responsive/responsive-legacy.tsx
|
|
18
|
+
var isStringValue = (value) => Object.prototype.toString.call(value) === "[object String]";
|
|
19
|
+
var isBooleanValue = (value) => Object.prototype.toString.call(value) === "[object Boolean]";
|
|
18
20
|
var getResolvedValueLabel = (value, options) => {
|
|
19
21
|
const optionLabel = options?.find((option) => option.value === value)?.label;
|
|
20
22
|
if (optionLabel) return optionLabel;
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
+
if (isStringValue(value)) return upperFirst(value);
|
|
24
|
+
if (isBooleanValue(value)) return String(value);
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* A component that allows the user to set different values for different breakpoints.
|
|
@@ -81,7 +83,7 @@ var ResponsiveLegacy = (props) => {
|
|
|
81
83
|
const getBreakpointValue = (breakpoint) => value[getAttributeName(breakpoint)];
|
|
82
84
|
const getBreakpointLabel = (breakpoint) => getResolvedValueLabel(getBreakpointValue(breakpoint), options);
|
|
83
85
|
const globalOverride = breakpoints.find((breakpoint) => getBreakpointValue(breakpoint) !== inheritValue);
|
|
84
|
-
const
|
|
86
|
+
const renderDefaultTooltip = () => jsx(DecorativeTooltip, {
|
|
85
87
|
placement: "left",
|
|
86
88
|
className: "es:p-3",
|
|
87
89
|
theme: "light",
|
|
@@ -149,7 +151,7 @@ var ResponsiveLegacy = (props) => {
|
|
|
149
151
|
children: [
|
|
150
152
|
!inline ? jsxs("div", {
|
|
151
153
|
className: clsx("es:grid es:items-center es:gap-x-2 es:transition-[grid-template-columns,margin-block-end] es:duration-150", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch", detailsVisible ? "es:mb-2 es:grid-cols-[minmax(0,1.75rem)_minmax(0,1fr)_minmax(0,2.25rem)]" : "es:grid-cols-[minmax(0,0rem)_minmax(0,1fr)_minmax(0,2.25rem)]"),
|
|
152
|
-
children: [detailsVisible ?
|
|
154
|
+
children: [detailsVisible ? renderDefaultTooltip() : null, jsx("div", {
|
|
153
155
|
className: clsx("es:w-full", detailsVisible ? "es:col-start-2 es:col-end-2" : "es:col-span-full"),
|
|
154
156
|
children: children({
|
|
155
157
|
breakpoint: defaultBreakpoint,
|
|
@@ -162,7 +164,7 @@ var ResponsiveLegacy = (props) => {
|
|
|
162
164
|
inline ? jsxs(AnimatedVisibility, {
|
|
163
165
|
className: clsx("es:mb-2 es:grid es:grid-cols-[minmax(0,auto)_minmax(0,1fr)_minmax(0,2.25rem)] es:items-center es:gap-x-2", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch"),
|
|
164
166
|
visible: detailsVisible,
|
|
165
|
-
children: [
|
|
167
|
+
children: [renderDefaultTooltip(), jsx("div", {
|
|
166
168
|
className: "es:col-start-2 es:col-end-2 es:w-full",
|
|
167
169
|
children: children({
|
|
168
170
|
breakpoint: defaultBreakpoint,
|
|
@@ -178,7 +180,7 @@ var ResponsiveLegacy = (props) => {
|
|
|
178
180
|
className: "es:space-y-2",
|
|
179
181
|
children: breakpoints.map((breakpoint, index) => {
|
|
180
182
|
const isOverrideSet = getBreakpointValue(breakpoint) !== inheritValue;
|
|
181
|
-
const aboveOverride =
|
|
183
|
+
const aboveOverride = rawBreakpoints.slice(0, index + 1).reverse().find((candidateBreakpoint) => getBreakpointValue(candidateBreakpoint) !== inheritValue);
|
|
182
184
|
const belowOverride = rawBreakpoints.slice(index + 2).find((candidateBreakpoint) => getBreakpointValue(candidateBreakpoint) !== inheritValue);
|
|
183
185
|
return jsxs("div", {
|
|
184
186
|
className: clsx("es:grid es:grid-cols-[minmax(0,auto)_minmax(0,1fr)_minmax(0,2.25rem)] es:items-center es:gap-x-2", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch"),
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as clsx } from "../../clsx-DQoRUQAf.js";
|
|
2
2
|
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
3
|
+
import { t as DecorativeTooltip } from "../../tooltip-CT-vzIdz.js";
|
|
4
|
+
import { t as ToggleButton } from "../../toggle-button-Cb4yCEua.js";
|
|
5
|
+
import { n as ButtonGroup, t as Button } from "../../button-ldR_tlvk.js";
|
|
6
6
|
import { BaseControl } from "../base-control/base-control.js";
|
|
7
|
-
import { f as upperFirst } from "../../es-dash-
|
|
7
|
+
import { f as upperFirst } from "../../es-dash-DPtJSRjw.js";
|
|
8
8
|
import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
|
|
9
9
|
import { t as sprintf } from "../../sprintf-xJRAt4p0.js";
|
|
10
|
-
import { t as __ } from "../../build-module-
|
|
10
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
11
11
|
import { Icon } from "../../icons/icon.js";
|
|
12
12
|
import { clearAlt } from "../../icons/ui-icons/clear-alt.js";
|
|
13
13
|
import { dropdownCaretAlt } from "../../icons/ui-icons/dropdown-caret-alt.js";
|
|
@@ -31,7 +31,7 @@ var getResponsiveLabel = (value, key, options) => {
|
|
|
31
31
|
if (!currentValue) return;
|
|
32
32
|
return options?.find((option) => option.value === currentValue)?.label ?? upperFirst(currentValue);
|
|
33
33
|
};
|
|
34
|
-
var hasResponsiveOverrides = (value) => Object.keys(value).some((key) => !key.startsWith("_") &&
|
|
34
|
+
var hasResponsiveOverrides = (value) => Object.keys(value).some((key) => !key.startsWith("_") && value[key] !== void 0);
|
|
35
35
|
/**
|
|
36
36
|
* A component that allows the user to set different values for different breakpoints.
|
|
37
37
|
*
|
|
@@ -76,7 +76,7 @@ var hasResponsiveOverrides = (value) => Object.keys(value).some((key) => !key.st
|
|
|
76
76
|
var Responsive = (props) => {
|
|
77
77
|
const { value = {}, onChange, icon, help, label, subtitle, options, breakpoints: rawBreakpoints, desktopFirstBreakpoints: rawDesktopFirstBreakpoints, breakpointData = {}, breakpointUiData, noModeSelect, inline, children, hidden, innerContentAlign = "start", useLegacyDesktopFirst, className } = props;
|
|
78
78
|
const [detailsVisible, setDetailsVisible] = useState(false);
|
|
79
|
-
if (
|
|
79
|
+
if (rawBreakpoints === void 0 || !Array.isArray(rawBreakpoints)) {
|
|
80
80
|
console.warn(__("Responsive: Missing or invalid 'breakpoints' prop.", "eightshift-ui-components"));
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
@@ -84,13 +84,13 @@ var Responsive = (props) => {
|
|
|
84
84
|
let desktopFirstBreakpoints = (rawDesktopFirstBreakpoints ?? rawBreakpoints.slice(1)).map((breakpoint) => breakpoint.startsWith("max-") ? breakpoint : `max-${breakpoint}`);
|
|
85
85
|
if (useLegacyDesktopFirst) desktopFirstBreakpoints = (rawDesktopFirstBreakpoints ?? rawBreakpoints.slice(0, -1)).map((breakpoint) => breakpoint.startsWith("max-") ? breakpoint : `max-${breakpoint}`);
|
|
86
86
|
const isDesktopFirst = value[desktopFirstKey] === true;
|
|
87
|
-
const firstMobileFirstOverride = breakpoints.find((breakpoint) =>
|
|
88
|
-
const lastDesktopFirstOverride = [...desktopFirstBreakpoints].reverse().find((breakpoint) =>
|
|
87
|
+
const firstMobileFirstOverride = breakpoints.find((breakpoint) => value[breakpoint] !== void 0);
|
|
88
|
+
const lastDesktopFirstOverride = [...desktopFirstBreakpoints].reverse().find((breakpoint) => value[breakpoint] !== void 0);
|
|
89
89
|
const breakpointsToMap = isDesktopFirst ? desktopFirstBreakpoints : breakpoints;
|
|
90
90
|
const responsiveOverridesApplied = hasResponsiveOverrides(value);
|
|
91
91
|
const getBreakpointWidth = (breakpoint) => breakpointData[breakpoint] ?? 0;
|
|
92
92
|
if (hidden) return null;
|
|
93
|
-
const
|
|
93
|
+
const renderDefaultTooltip = () => {
|
|
94
94
|
const defaultBreakpoint = isDesktopFirst ? rawBreakpoints[rawBreakpoints.length - 1] : rawBreakpoints[0];
|
|
95
95
|
const overrideIcon = defaultBreakpoint ? breakpointUiData?.[defaultBreakpoint]?.icon : void 0;
|
|
96
96
|
const fallbackBreakpoint = defaultBreakpoint ?? "desktop";
|
|
@@ -244,7 +244,7 @@ var Responsive = (props) => {
|
|
|
244
244
|
children: [
|
|
245
245
|
!isDesktopFirst && !inline ? jsxs("div", {
|
|
246
246
|
className: clsx("es:grid es:items-center es:gap-x-2 es:transition-[grid-template-columns,margin-block-end] es:duration-200", detailsVisible && "es:bg-white/50 es:p-1.5 es:rounded-sm es:first:rounded-t-2xl es:last:rounded-b-2xl es:inset-ring es:inset-ring-accent-600/25", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch", detailsVisible ? "es:mb-0.5 es:grid-cols-[minmax(0,1.75rem)_minmax(0,1fr)_minmax(0,2.25rem)]" : "es:grid-cols-[minmax(0,0rem)_minmax(0,1fr)_minmax(0,2.25rem)]"),
|
|
247
|
-
children: [detailsVisible ?
|
|
247
|
+
children: [detailsVisible ? renderDefaultTooltip() : null, jsx("div", {
|
|
248
248
|
className: clsx("es:w-full", detailsVisible ? "es:col-start-2 es:col-end-2" : "es:col-span-full"),
|
|
249
249
|
children: children({
|
|
250
250
|
breakpoint: defaultKey,
|
|
@@ -261,7 +261,7 @@ var Responsive = (props) => {
|
|
|
261
261
|
!isDesktopFirst && inline ? jsxs(AnimatedVisibility, {
|
|
262
262
|
className: clsx("es:mb-0.5 es:grid es:grid-cols-[minmax(0,1.75rem)_minmax(0,1fr)_minmax(0,2.25rem)] es:items-center es:gap-x-2", "es:bg-white/50 es:p-1.5 es:rounded-sm es:first:rounded-t-2xl es:last:rounded-b-2xl es:inset-ring es:inset-ring-accent-600/25", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch"),
|
|
263
263
|
visible: detailsVisible,
|
|
264
|
-
children: [
|
|
264
|
+
children: [renderDefaultTooltip(), jsx("div", {
|
|
265
265
|
className: "es:col-start-2 es:col-end-2 es:w-full",
|
|
266
266
|
children: children({
|
|
267
267
|
breakpoint: defaultKey,
|
|
@@ -282,8 +282,8 @@ var Responsive = (props) => {
|
|
|
282
282
|
children: breakpointsToMap.map((breakpoint, index) => {
|
|
283
283
|
const realBreakpointName = breakpoint.replace("max-", "");
|
|
284
284
|
const filterBreakpoints = isDesktopFirst ? [...breakpointsToMap, defaultKey] : [defaultKey, ...breakpointsToMap];
|
|
285
|
-
const aboveOverride = isDesktopFirst ? filterBreakpoints.slice(index + 1).find((currentBreakpoint) =>
|
|
286
|
-
const belowOverride = isDesktopFirst ?
|
|
285
|
+
const aboveOverride = isDesktopFirst ? filterBreakpoints.slice(index + 1).find((currentBreakpoint) => value[currentBreakpoint] !== void 0) : filterBreakpoints.slice(0, index + 1).reverse().find((currentBreakpoint) => value[currentBreakpoint] !== void 0);
|
|
286
|
+
const belowOverride = isDesktopFirst ? filterBreakpoints.slice(0, index).reverse().find((currentBreakpoint) => value[currentBreakpoint] !== void 0) : filterBreakpoints.slice(index + 2).find((currentBreakpoint) => value[currentBreakpoint] !== void 0);
|
|
287
287
|
return jsxs("div", {
|
|
288
288
|
className: clsx("es:grid es:grid-cols-[minmax(0,auto)_minmax(0,1fr)_minmax(0,2.25rem)] es:items-center es:gap-x-2", "es:bg-white/50 es:p-1.5 es:rounded-sm es:inset-ring es:inset-ring-surface-200/60", !isDesktopFirst && "es:last:rounded-b-2xl", isDesktopFirst && "es:first:rounded-t-2xl", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch"),
|
|
289
289
|
children: [
|
|
@@ -301,31 +301,31 @@ var Responsive = (props) => {
|
|
|
301
301
|
jsx("span", {
|
|
302
302
|
className: "es:block es:text-balance es:tabular-nums es:font-variation-[\"wdth\"_64,\"wght\"_275,\"ROND\"_50,\"slnt\"_-2] es:text-surface-500 es:mt-1",
|
|
303
303
|
children: !isDesktopFirst ? jsxs(Fragment$1, { children: [
|
|
304
|
-
!belowOverride &&
|
|
305
|
-
belowOverride &&
|
|
306
|
-
|
|
304
|
+
!belowOverride && value[breakpoint] !== void 0 ? sprintf(__("Applied when the browser width is %dpx or more.", "eightshift-ui-components"), getBreakpointWidth(realBreakpointName)) : null,
|
|
305
|
+
belowOverride && value[breakpoint] !== void 0 ? sprintf(__("Applied when the browser width is between %dpx and %dpx.", "eightshift-ui-components"), getBreakpointWidth(realBreakpointName), getBreakpointWidth(belowOverride) - 1) : null,
|
|
306
|
+
value[breakpoint] === void 0 ? sprintf(__("From %dpx", "eightshift-ui-components"), getBreakpointWidth(realBreakpointName)) : null
|
|
307
307
|
] }) : jsxs(Fragment$1, { children: [
|
|
308
|
-
!belowOverride &&
|
|
309
|
-
belowOverride &&
|
|
310
|
-
|
|
308
|
+
!belowOverride && value[breakpoint] !== void 0 ? sprintf(__("Applied when the browser width is %dpx or less.", "eightshift-ui-components"), getBreakpointWidth(realBreakpointName) - 1) : null,
|
|
309
|
+
belowOverride && value[breakpoint] !== void 0 ? sprintf(__("Applied when the browser width is between %dpx and %dpx.", "eightshift-ui-components"), getBreakpointWidth(belowOverride.replace("max-", "")), getBreakpointWidth(realBreakpointName) - 1) : null,
|
|
310
|
+
value[breakpoint] === void 0 ? sprintf(__("Up to %dpx", "eightshift-ui-components"), getBreakpointWidth(breakpoint.replace("max-", ""))) : null
|
|
311
311
|
] })
|
|
312
312
|
}),
|
|
313
|
-
|
|
313
|
+
value[breakpoint] === void 0 ? jsx("span", {
|
|
314
314
|
className: "es:mt-2 es:text-sm es:leading-none es:block es:font-variation-[\"wdth\"_75,\"wght\"_300,\"slnt\"_-5]",
|
|
315
315
|
children: __("Not set", "eightshift-ui-components")
|
|
316
316
|
}) : null,
|
|
317
|
-
|
|
317
|
+
value[breakpoint] !== void 0 ? jsx("div", {
|
|
318
318
|
className: "es:mx-auto es:mt-5",
|
|
319
319
|
children: !isDesktopFirst ? jsx(BreakpointPreview, {
|
|
320
320
|
dotsStart: Boolean(belowOverride),
|
|
321
321
|
blocks: [
|
|
322
|
-
aboveOverride && aboveOverride !== defaultKey &&
|
|
322
|
+
aboveOverride && aboveOverride !== defaultKey && value[aboveOverride] !== void 0 ? {
|
|
323
323
|
breakpoint: breakpointUiData?.[aboveOverride]?.label ?? aboveOverride,
|
|
324
324
|
value: getResponsiveLabel(value, aboveOverride, options),
|
|
325
325
|
dotsStart: !belowOverride,
|
|
326
326
|
alignEnd: !belowOverride
|
|
327
327
|
} : null,
|
|
328
|
-
aboveOverride === defaultKey &&
|
|
328
|
+
aboveOverride === defaultKey && value[defaultKey] !== void 0 ? {
|
|
329
329
|
breakpoint: __("Default", "eightshift-ui-components"),
|
|
330
330
|
value: getResponsiveLabel(value, defaultKey, options),
|
|
331
331
|
dotsStart: !belowOverride,
|
|
@@ -338,7 +338,7 @@ var Responsive = (props) => {
|
|
|
338
338
|
active: true,
|
|
339
339
|
dotsEnd: !belowOverride
|
|
340
340
|
},
|
|
341
|
-
belowOverride &&
|
|
341
|
+
belowOverride && value[belowOverride] !== void 0 ? {
|
|
342
342
|
breakpoint: breakpointUiData?.[belowOverride]?.label ?? belowOverride,
|
|
343
343
|
value: getResponsiveLabel(value, belowOverride, options),
|
|
344
344
|
width: String(getBreakpointWidth(belowOverride)),
|
|
@@ -375,7 +375,7 @@ var Responsive = (props) => {
|
|
|
375
375
|
}) : null
|
|
376
376
|
] }),
|
|
377
377
|
children: jsx("div", {
|
|
378
|
-
className: clsx("es:transition-colors es:icon:size-6 es:mx-0.5",
|
|
378
|
+
className: clsx("es:transition-colors es:icon:size-6 es:mx-0.5", value[breakpoint] !== void 0 ? "es:text-surface-600" : "es:text-surface-300"),
|
|
379
379
|
children: jsx(Icon, {
|
|
380
380
|
icon: breakpointUiData?.[realBreakpointName]?.icon,
|
|
381
381
|
fallback: jsx(Icon, { icon: `screen${upperFirst(realBreakpointName)}` })
|
|
@@ -401,7 +401,7 @@ var Responsive = (props) => {
|
|
|
401
401
|
onChange(newValue);
|
|
402
402
|
},
|
|
403
403
|
icon: clearAlt,
|
|
404
|
-
disabled:
|
|
404
|
+
disabled: value[breakpoint] === void 0,
|
|
405
405
|
type: "ghost"
|
|
406
406
|
})
|
|
407
407
|
]
|
|
@@ -410,7 +410,7 @@ var Responsive = (props) => {
|
|
|
410
410
|
}),
|
|
411
411
|
isDesktopFirst && !inline ? jsxs("div", {
|
|
412
412
|
className: clsx("es:grid es:items-center es:gap-x-2 es:transition-[grid-template-columns,margin-block-start] es:duration-150", detailsVisible && "es:bg-white/50 es:p-1.5 es:rounded-sm es:first:rounded-t-2xl es:last:rounded-b-2xl es:inset-ring es:inset-ring-accent-600/25 es:transition-plus", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch", detailsVisible ? "es:mt-0.5 es:grid-cols-[minmax(0,1.75rem)_minmax(0,1fr)_minmax(0,2.25rem)]" : "es:grid-cols-[minmax(0,0rem)_minmax(0,1fr)_minmax(0,2.25rem)]"),
|
|
413
|
-
children: [detailsVisible ?
|
|
413
|
+
children: [detailsVisible ? renderDefaultTooltip() : null, jsx("div", {
|
|
414
414
|
className: clsx("es:w-full", detailsVisible ? "es:col-start-2 es:col-end-2" : "es:col-span-full"),
|
|
415
415
|
children: children({
|
|
416
416
|
breakpoint: defaultKey,
|
|
@@ -427,7 +427,7 @@ var Responsive = (props) => {
|
|
|
427
427
|
isDesktopFirst && inline ? jsxs(AnimatedVisibility, {
|
|
428
428
|
className: clsx("es:grid es:grid-cols-[minmax(0,1.75rem)_minmax(0,1fr)_minmax(0,2.25rem)] es:items-center es:gap-x-2 es:pt-1", "es:bg-white/50 es:p-1.5 es:rounded-sm es:first:rounded-t-2xl es:last:rounded-b-2xl es:inset-ring es:inset-ring-accent-600/25", innerContentAlign === "start" && "es:justify-items-start", innerContentAlign === "center" && "es:justify-items-center", innerContentAlign === "end" && "es:justify-items-end", innerContentAlign === "stretch" && "es:justify-items-stretch"),
|
|
429
429
|
visible: detailsVisible,
|
|
430
|
-
children: [
|
|
430
|
+
children: [renderDefaultTooltip(), jsx("div", {
|
|
431
431
|
className: "es:col-start-2 es:col-end-2",
|
|
432
432
|
children: children({
|
|
433
433
|
breakpoint: defaultKey,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RichLabel } from "../rich-label/rich-label.js";
|
|
2
|
-
import { f as upperFirst } from "../../es-dash-
|
|
2
|
+
import { f as upperFirst } from "../../es-dash-DPtJSRjw.js";
|
|
3
3
|
import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
|
|
4
|
-
import { t as __ } from "../../build-module-
|
|
4
|
+
import { t as __ } from "../../build-module-BISCoQjQ.js";
|
|
5
5
|
import { previewResponsive } from "../../icons/ui-icons/preview-responsive.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region lib/components/responsive-preview/responsive-preview.tsx
|
|
@@ -40,7 +40,7 @@ var ResponsivePreview = (props) => {
|
|
|
40
40
|
value: options?.find((opt) => opt.value === value?.[defaultKey])?.label ?? upperFirst(value?.[defaultKey])
|
|
41
41
|
}];
|
|
42
42
|
breakpoints.forEach((breakpoint) => {
|
|
43
|
-
if (
|
|
43
|
+
if (value?.[breakpoint] === void 0) return;
|
|
44
44
|
previewItems = [...previewItems, {
|
|
45
45
|
width: String(breakpointData[breakpoint]),
|
|
46
46
|
breakpoint: breakpointUiData?.[breakpoint]?.label ?? breakpoint,
|
|
@@ -50,7 +50,7 @@ var ResponsivePreview = (props) => {
|
|
|
50
50
|
}
|
|
51
51
|
if (lastDesktopFirstOverride && isDesktopFirst) {
|
|
52
52
|
desktopFirstBreakpoints.forEach((breakpoint) => {
|
|
53
|
-
if (
|
|
53
|
+
if (value?.[breakpoint] === void 0) return;
|
|
54
54
|
const normalizedBreakpoint = breakpoint.replace("max-", "");
|
|
55
55
|
previewItems = [...previewItems, {
|
|
56
56
|
alignEnd: true,
|
|
@@ -46,4 +46,4 @@ export type RichLabelProps<T extends ElementType = 'div'> = {
|
|
|
46
46
|
* label='My label'
|
|
47
47
|
* />
|
|
48
48
|
*/
|
|
49
|
-
export declare const RichLabel: <T extends ElementType =
|
|
49
|
+
export declare const RichLabel: <T extends ElementType = 'div'>(props: RichLabelProps<T>) => import("react").JSX.Element | null;
|
|
@@ -21,8 +21,8 @@ var RichLabel = (props) => {
|
|
|
21
21
|
const noColorClassName = noColor ? "" : "";
|
|
22
22
|
if (hidden) return null;
|
|
23
23
|
const ComponentToRender = as ?? "div";
|
|
24
|
-
const labelBaseClassName = "es:font-variation-[\"wdth\"_100,\"wght\"_330,\"ROND\"
|
|
25
|
-
const subtitleBaseClassName = "es:font-variation-[\"wdth\"
|
|
24
|
+
const labelBaseClassName = "es:font-variation-[\"wdth\"_100,\"wght\"_330,\"ROND\"_100]";
|
|
25
|
+
const subtitleBaseClassName = "es:font-variation-[\"wdth\"_85,\"wght\"_285,\"ROND\"_100]";
|
|
26
26
|
if (contentsOnly) return jsxs(Fragment$1, { children: [
|
|
27
27
|
icon && jsx("span", {
|
|
28
28
|
className: clsx("es:icon:size-5 es:not-contrast-more:opacity-85", iconClassName),
|
|
@@ -4,24 +4,23 @@ import { type Primitive } from './shared';
|
|
|
4
4
|
import type { Prettify } from '../../utilities/types';
|
|
5
5
|
type IconValue = string | JSX.Element | null;
|
|
6
6
|
type SelectSize = 'small' | 'medium' | 'default' | 'large';
|
|
7
|
-
|
|
7
|
+
interface RawAsyncItem {
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
10
|
+
type AsyncFetchedData = RawAsyncItem[] | {
|
|
11
|
+
jokes?: RawAsyncItem[];
|
|
12
|
+
};
|
|
8
13
|
type AsyncMultiSelectOption = {
|
|
9
14
|
label: string;
|
|
10
15
|
value: Primitive;
|
|
11
|
-
metadata?:
|
|
12
|
-
meta?:
|
|
16
|
+
metadata?: RawAsyncItem | null;
|
|
17
|
+
meta?: RawAsyncItem | null;
|
|
13
18
|
subtitle?: string;
|
|
14
19
|
icon?: IconValue;
|
|
15
20
|
className?: string;
|
|
16
|
-
[key: string]: unknown;
|
|
17
21
|
};
|
|
18
22
|
type AsyncMultiSelectValue = AsyncMultiSelectOption[] | Primitive[] | '' | null;
|
|
19
|
-
type GroupValueMapping =
|
|
20
|
-
label?: ReactNode;
|
|
21
|
-
icon?: IconValue;
|
|
22
|
-
subtitle?: ReactNode;
|
|
23
|
-
endIcon?: IconValue;
|
|
24
|
-
}>;
|
|
23
|
+
type GroupValueMapping = object;
|
|
25
24
|
type AsyncMultiSelectProps = Omit<ReactAriaSelectProps<AsyncMultiSelectOption, 'multiple'>, 'children' | 'className' | 'isDisabled' | 'items' | 'placeholder' | 'selectionMode' | 'value' | 'onChange'> & {
|
|
26
25
|
/** Label of the component. */
|
|
27
26
|
label?: ReactNode;
|
|
@@ -50,7 +49,7 @@ type AsyncMultiSelectProps = Omit<ReactAriaSelectProps<AsyncMultiSelectOption, '
|
|
|
50
49
|
/** Function to get the value for the item from the fetched data. `(item) => string | number | boolean`. Defaults to reading `item.value`. */
|
|
51
50
|
getValue?: (item: RawAsyncItem) => Primitive | undefined;
|
|
52
51
|
/** Function to get the metadata for the item from the fetched data. `(item) => object` (optional). */
|
|
53
|
-
getMeta?: (item: RawAsyncItem) =>
|
|
52
|
+
getMeta?: (item: RawAsyncItem) => RawAsyncItem | null | undefined;
|
|
54
53
|
/** Function to get the icon for the item from the fetched data. `(item) => JSX.Element | string`. */
|
|
55
54
|
getIcon?: (item: RawAsyncItem | AsyncMultiSelectOption) => IconValue;
|
|
56
55
|
/** Function to get the subtitle for the item from the fetched data. `(item) => string`. */
|
|
@@ -58,13 +57,13 @@ type AsyncMultiSelectProps = Omit<ReactAriaSelectProps<AsyncMultiSelectOption, '
|
|
|
58
57
|
/** Function to get the group name for the item from the fetched data. `(item) => string`. */
|
|
59
58
|
getGroup?: (item: RawAsyncItem) => string | undefined;
|
|
60
59
|
/** Function to pre-process the fetched data before it is used in the select. `(data) => data[]`. Defaults to a passthrough. */
|
|
61
|
-
getData?: (data:
|
|
60
|
+
getData?: (data: AsyncFetchedData) => RawAsyncItem[];
|
|
62
61
|
/** Function to get the URL for fetching data. Provides typed search text if entered. `(searchText) => string`. */
|
|
63
62
|
fetchUrl?: (searchText?: string) => string;
|
|
64
63
|
/** Configuration object for the fetch request, passed to the `fetch` function. Defaults to `{}`. */
|
|
65
64
|
fetchConfig?: RequestInit;
|
|
66
65
|
/** Allows overriding the default fetch function. `(searchText, signal) => Promise`. */
|
|
67
|
-
fetchFunction?: (searchText: string | undefined, signal: AbortSignal) => Promise<
|
|
66
|
+
fetchFunction?: (searchText: string | undefined, signal: AbortSignal) => Promise<AsyncFetchedData>;
|
|
68
67
|
/** Allows processing the options fetched from the source. `(options) => options[]`. Defaults to a passthrough. */
|
|
69
68
|
processLoadedOptions?: (options: RawAsyncItem[]) => RawAsyncItem[];
|
|
70
69
|
/** If provided, replaces the default item in the dropdown menu. `({ value, label, subtitle, metadata }) => JSX.Element`. */
|
|
@@ -1,19 +1,19 @@
|
|
|
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-
|
|
14
|
+
import { i as unescapeHTML } from "../../text-helpers-QrwKKaOh.js";
|
|
15
15
|
import { t as sprintf } from "../../sprintf-xJRAt4p0.js";
|
|
16
|
-
import { n as _n, t as __ } from "../../build-module-
|
|
16
|
+
import { n as _n, t as __ } from "../../build-module-BISCoQjQ.js";
|
|
17
17
|
import { Icon } from "../../icons/icon.js";
|
|
18
18
|
import { Spinner } from "../../icons/spinner.js";
|
|
19
19
|
import { clearAlt } from "../../icons/ui-icons/clear-alt.js";
|
|
@@ -28,16 +28,29 @@ import { selectButtonClass, selectControlClass } from "./styles.js";
|
|
|
28
28
|
import { cloneElement, useMemo, useRef } from "react";
|
|
29
29
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
30
|
//#region lib/components/select/async-multi-select.tsx
|
|
31
|
+
var getRawItemValue = (item, key) => {
|
|
32
|
+
return Object.entries(item).find(([entryKey]) => entryKey === key)?.[1];
|
|
33
|
+
};
|
|
34
|
+
var setRawItemValue = (item, key, value) => {
|
|
35
|
+
Object.defineProperty(item, key, {
|
|
36
|
+
configurable: true,
|
|
37
|
+
enumerable: true,
|
|
38
|
+
value,
|
|
39
|
+
writable: true
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var isNumberValue = (value) => Object.prototype.toString.call(value) === "[object Number]";
|
|
43
|
+
var isAsyncMultiSelectOption = (value) => value instanceof Object && "value" in value && isPrimitive(value.value);
|
|
31
44
|
var TypedDraggableList = DraggableList;
|
|
32
45
|
var getPopoverStyle = (triggerElement) => ({ "--select-width": triggerElement ? `${triggerElement.offsetWidth}px` : "var(--trigger-width)" });
|
|
33
46
|
var getCurrentValue = (value) => {
|
|
34
47
|
if (!Array.isArray(value)) return [];
|
|
35
|
-
return value.filter((item) =>
|
|
48
|
+
return value.filter((item) => isAsyncMultiSelectOption(item));
|
|
36
49
|
};
|
|
37
50
|
var getCurrentValueKeys = (value) => {
|
|
38
51
|
if (!Array.isArray(value)) return [];
|
|
39
52
|
return value.flatMap((item) => {
|
|
40
|
-
if (
|
|
53
|
+
if (isPrimitive(item)) return getOptionKey(item);
|
|
41
54
|
if (item) return getOptionKey(item.value);
|
|
42
55
|
return [];
|
|
43
56
|
});
|
|
@@ -45,14 +58,14 @@ var getCurrentValueKeys = (value) => {
|
|
|
45
58
|
var normalizeSelectedKeys = (selected) => {
|
|
46
59
|
if (selected === null || selected === void 0 || selected === "all") return [];
|
|
47
60
|
return (Array.isArray(selected) ? selected : [...selected]).flatMap((key) => {
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
61
|
+
if (isStringValue(key)) return key;
|
|
62
|
+
if (isNumberValue(key)) return String(key);
|
|
50
63
|
return [];
|
|
51
64
|
});
|
|
52
65
|
};
|
|
53
66
|
var getOptionIcon = (icon) => {
|
|
54
67
|
if (!icon) return;
|
|
55
|
-
return
|
|
68
|
+
return isStringValue(icon) ? jsx(Icon, { icon }) : icon;
|
|
56
69
|
};
|
|
57
70
|
var renderOptionIcon = (icon) => getOptionIcon(icon) ?? null;
|
|
58
71
|
/**
|
|
@@ -77,7 +90,13 @@ var renderOptionIcon = (icon) => getOptionIcon(icon) ?? null;
|
|
|
77
90
|
* />
|
|
78
91
|
*/
|
|
79
92
|
var AsyncMultiSelect = (props) => {
|
|
80
|
-
const { label, help, icon, subtitle, actions, inline, value, onChange, clearable = false, disabled = false, placeholder = __("Select...", "eightshift-ui-components"), fetchUrl, fetchConfig = {}, fetchFunction, getLabel = (item) =>
|
|
93
|
+
const { label, help, icon, subtitle, actions, inline, value, onChange, clearable = false, disabled = false, placeholder = __("Select...", "eightshift-ui-components"), fetchUrl, fetchConfig = {}, fetchFunction, getLabel = (item) => {
|
|
94
|
+
const itemLabel = getRawItemValue(item, "label");
|
|
95
|
+
return isStringValue(itemLabel) ? itemLabel : void 0;
|
|
96
|
+
}, getValue = (item) => {
|
|
97
|
+
const itemValue = getRawItemValue(item, "value");
|
|
98
|
+
return isPrimitive(itemValue) ? itemValue : void 0;
|
|
99
|
+
}, getMeta, getIcon, getSubtitle, getGroup, getData = (data) => Array.isArray(data) ? data : data.jokes ?? [], customMenuOption, customValueDisplay, customDropdownArrow, className, groupKey, groupValueMapping, flat, size = "default", noMinWidth = false, noReorder, hidden, processLoadedOptions = (options) => options, ...rest } = props;
|
|
81
100
|
const ref = useRef(null);
|
|
82
101
|
const currentValue = getCurrentValue(value);
|
|
83
102
|
const currentValueKeys = getCurrentValueKeys(value);
|
|
@@ -107,7 +126,7 @@ var AsyncMultiSelect = (props) => {
|
|
|
107
126
|
}
|
|
108
127
|
if (getSubtitle) entry.subtitle = (unescapeHTML(getSubtitle(item) ?? "") ?? "") || void 0;
|
|
109
128
|
if (getIcon) entry.icon = getIcon(item);
|
|
110
|
-
if (getGroup) entry
|
|
129
|
+
if (getGroup) setRawItemValue(entry, groupKey ?? "_group", getGroup(item));
|
|
111
130
|
return entry;
|
|
112
131
|
});
|
|
113
132
|
if ((filterText ?? "").length > 0) return { items: output };
|
|
@@ -248,7 +267,7 @@ var AsyncMultiSelect = (props) => {
|
|
|
248
267
|
className: "es:grid es:grid-cols-1 es:grid-rows-[auto_minmax(0,1fr)] es:p-0!",
|
|
249
268
|
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!",
|
|
250
269
|
hidden: Boolean(noReorder) || disabled || currentValue.length < 2,
|
|
251
|
-
style: getPopoverStyle(
|
|
270
|
+
style: getPopoverStyle(null),
|
|
252
271
|
children: [jsx("span", {
|
|
253
272
|
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",
|
|
254
273
|
children: __("Item order", "eightshift-ui-components")
|
|
@@ -282,7 +301,7 @@ var AsyncMultiSelect = (props) => {
|
|
|
282
301
|
placement: "bottom left",
|
|
283
302
|
maxHeight: 260,
|
|
284
303
|
triggerRef: ref,
|
|
285
|
-
style: getPopoverStyle(
|
|
304
|
+
style: getPopoverStyle(null),
|
|
286
305
|
children: jsxs($4b38b5b75ecc6208$export$2f2b9559550c7bbc, {
|
|
287
306
|
inputValue: list.filterText,
|
|
288
307
|
onInputChange: (text) => list.setFilterText(text),
|
|
@@ -4,23 +4,22 @@ import { type Primitive } from './shared';
|
|
|
4
4
|
import type { Prettify } from '../../utilities/types';
|
|
5
5
|
type IconValue = string | JSX.Element | null;
|
|
6
6
|
type SelectSize = 'small' | 'medium' | 'default' | 'large';
|
|
7
|
-
|
|
7
|
+
interface RawAsyncItem {
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
10
|
+
type AsyncFetchedData = RawAsyncItem[] | {
|
|
11
|
+
jokes?: RawAsyncItem[];
|
|
12
|
+
};
|
|
8
13
|
type AsyncSelectOption = {
|
|
9
14
|
label: string;
|
|
10
15
|
value: Primitive;
|
|
11
|
-
metadata?:
|
|
12
|
-
meta?:
|
|
16
|
+
metadata?: RawAsyncItem | null;
|
|
17
|
+
meta?: RawAsyncItem | null;
|
|
13
18
|
subtitle?: string;
|
|
14
19
|
icon?: IconValue;
|
|
15
20
|
className?: string;
|
|
16
|
-
[key: string]: unknown;
|
|
17
21
|
};
|
|
18
|
-
type GroupValueMapping =
|
|
19
|
-
label?: ReactNode;
|
|
20
|
-
icon?: IconValue;
|
|
21
|
-
subtitle?: ReactNode;
|
|
22
|
-
endIcon?: IconValue;
|
|
23
|
-
}>;
|
|
22
|
+
type GroupValueMapping = object;
|
|
24
23
|
type AsyncSelectProps = Omit<ReactAriaSelectProps<AsyncSelectOption>, 'children' | 'className' | 'isDisabled' | 'selectedKey' | 'onSelectionChange' | 'items' | 'placeholder' | 'value' | 'onChange'> & {
|
|
25
24
|
/** Label of the component. */
|
|
26
25
|
label?: ReactNode;
|
|
@@ -49,7 +48,7 @@ type AsyncSelectProps = Omit<ReactAriaSelectProps<AsyncSelectOption>, 'children'
|
|
|
49
48
|
/** Function to get the value for the item from the fetched data. `(item) => string | number | boolean`. Defaults to reading `item.value`. */
|
|
50
49
|
getValue?: (item: RawAsyncItem) => Primitive | undefined;
|
|
51
50
|
/** Function to get the metadata for the item from the fetched data. `(item) => object` (optional). */
|
|
52
|
-
getMeta?: (item: RawAsyncItem) =>
|
|
51
|
+
getMeta?: (item: RawAsyncItem) => RawAsyncItem | null | undefined;
|
|
53
52
|
/** Function to get the icon for the item from the fetched data. `(item) => JSX.Element | string`. */
|
|
54
53
|
getIcon?: (item: RawAsyncItem | AsyncSelectOption) => IconValue;
|
|
55
54
|
/** Function to get the subtitle for the item from the fetched data. `(item) => string`. */
|
|
@@ -57,13 +56,13 @@ type AsyncSelectProps = Omit<ReactAriaSelectProps<AsyncSelectOption>, 'children'
|
|
|
57
56
|
/** Function to get the group name for the item from the fetched data. `(item) => string`. */
|
|
58
57
|
getGroup?: (item: RawAsyncItem) => string | undefined;
|
|
59
58
|
/** Function to pre-process the fetched data before it is used in the select. `(data) => data[]`. Defaults to a passthrough. */
|
|
60
|
-
getData?: (data:
|
|
59
|
+
getData?: (data: AsyncFetchedData) => RawAsyncItem[];
|
|
61
60
|
/** Function to get the URL for fetching data. Provides typed search text if entered. `(searchText) => string`. */
|
|
62
61
|
fetchUrl?: (searchText?: string) => string;
|
|
63
62
|
/** Configuration object for the fetch request, passed to the `fetch` function. Defaults to `{}`. */
|
|
64
63
|
fetchConfig?: RequestInit;
|
|
65
64
|
/** Allows overriding the default fetch function. `(searchText, signal) => Promise`. */
|
|
66
|
-
fetchFunction?: (searchText: string | undefined, signal: AbortSignal) => Promise<
|
|
65
|
+
fetchFunction?: (searchText: string | undefined, signal: AbortSignal) => Promise<AsyncFetchedData>;
|
|
67
66
|
/** Allows processing the options fetched from the source. `(options) => options[]`. Defaults to a passthrough. */
|
|
68
67
|
processLoadedOptions?: (options: RawAsyncItem[]) => RawAsyncItem[];
|
|
69
68
|
/** If provided, replaces the default item in the dropdown menu. `({ value, label, subtitle, metadata }) => JSX.Element`. */
|