@eightshift/ui-components 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/Button-eebLs4cp.js +54 -0
- package/dist/{Checkbox-BLcVbhiO.js → Checkbox-BN0TEda-.js} +7 -7
- package/dist/{ColorSwatch-Cmlex_kT.js → ColorSwatch-BrowHhTG.js} +4 -4
- package/dist/{FieldError-wtMA4667.js → FieldError-ILxgMZy5.js} +2 -2
- package/dist/{FocusScope-1u9yyfIN.js → FocusScope-B9b0VMib.js} +2 -2
- package/dist/GeistMonoVF.woff2 +0 -0
- package/dist/GeistVF.woff2 +0 -0
- package/dist/{GridList-BZPXp3_O.js → GridList-CzpWxJsS.js} +18 -18
- package/dist/{Group-DyqpTRPe.js → Group-Dkdm2-E7.js} +3 -3
- package/dist/{Input-jsbb4ugq.js → Input-BJA4rmIo.js} +7 -7
- package/dist/{Label-BPzS-sR7.js → Label-9x5iLJ-Y.js} +1 -1
- package/dist/{ListBox-w9gDaJkV.js → ListBox-D3Vr4vvC.js} +18 -18
- package/dist/{Select-49a62830.esm-C-RFtLiD.js → Select-49a62830.esm-CKPmlkza.js} +1 -1
- package/dist/{SelectionManager-mefd0ThJ.js → SelectionManager-sedvcM-1.js} +8 -8
- package/dist/{Separator-DHn0CwdK.js → Separator-B6rnDabE.js} +3 -3
- package/dist/{Slider-Pyh2V4bY.js → Slider-C5U5N7uM.js} +11 -11
- package/dist/{Text-BM136LvS.js → Text-Cyxp9ewv.js} +1 -1
- package/dist/{VisuallyHidden-BYRI1Lfo.js → VisuallyHidden-BPJVSUyp.js} +2 -2
- package/dist/_commonjsHelpers-DWwsNxpa.js +8 -0
- package/dist/assets/fonts.css +1 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/wp.css +1 -0
- package/dist/{button-BkkdyHfJ.js → button-idVI4jmd.js} +45 -64
- package/dist/components/base-control/base-control.js +29 -39
- package/dist/components/breakpoint-preview/breakpoint-preview.js +7 -7
- package/dist/components/button/button.js +6 -5
- package/dist/components/checkbox/checkbox.js +9 -7
- package/dist/components/color-pickers/color-picker.js +27 -36
- package/dist/components/color-pickers/color-swatch.js +6 -6
- package/dist/components/color-pickers/gradient-editor.js +10 -6
- package/dist/components/color-pickers/solid-color-picker.js +35 -38
- package/dist/components/component-toggle/component-toggle.js +52 -6
- package/dist/components/container-panel/container-panel.js +55 -6
- package/dist/components/draggable-list/draggable-list-item.js +74 -0
- package/dist/components/draggable-list/draggable-list.js +157 -0
- package/dist/components/expandable/expandable.js +19 -12
- package/dist/components/input-field/input-field.js +15 -10
- package/dist/components/layout/hstack.js +40 -0
- package/dist/components/layout/vstack.js +40 -0
- package/dist/components/link-input/link-input.js +35 -31
- package/dist/components/list-box/list-box.js +11 -6
- package/dist/components/matrix-align/matrix-align.js +12 -7
- package/dist/components/menu/menu.js +26 -21
- package/dist/components/notice/notice.js +11 -7
- package/dist/components/number-picker/number-picker.js +19 -13
- package/dist/components/option-select/option-select.js +231 -0
- package/dist/components/placeholders/file-placeholder.js +53 -0
- package/dist/components/placeholders/image-placeholder.js +88 -0
- package/dist/components/placeholders/media-placeholder.js +62 -0
- package/dist/components/popover/popover.js +4 -4
- package/dist/components/radio/radio.js +56 -38
- package/dist/components/repeater/repeater-item.js +46 -39
- package/dist/components/repeater/repeater.js +83 -56
- package/dist/components/responsive/responsive-legacy.js +17 -12
- package/dist/components/responsive/responsive.js +227 -160
- package/dist/components/responsive-preview/responsive-preview.js +5 -3
- package/dist/components/rich-label/rich-label.js +12 -8
- package/dist/components/select/async-multi-select.js +9 -6
- package/dist/components/select/async-single-select.js +7 -2
- package/dist/components/select/custom-select-default-components.js +3 -3
- package/dist/components/select/multi-select-components.js +2 -2
- package/dist/components/select/multi-select.js +9 -6
- package/dist/components/select/react-select-component-wrappers.js +1 -1
- package/dist/components/select/single-select.js +7 -2
- package/dist/components/select/styles.js +4 -4
- package/dist/components/slider/column-config-slider.js +18 -34
- package/dist/components/slider/slider.js +19 -26
- package/dist/components/slider/utils.js +44 -1
- package/dist/components/spacer/spacer.js +21 -11
- package/dist/components/tabs/tabs.js +21 -20
- package/dist/components/toggle/switch.js +18 -12
- package/dist/components/toggle/toggle.js +8 -2
- package/dist/components/toggle-button/toggle-button.js +25 -13
- package/dist/components/tooltip/tooltip.js +4 -4
- package/dist/{context-jMy6xdVq.js → context-BAcFg5GO.js} +1 -1
- package/dist/{default-i18n-BhE-OUmt.js → default-i18n-Bk1GxDHz.js} +1 -1
- package/dist/{focusSafely-C3K8zAKj.js → focusSafely-B0hyd-S4.js} +1 -1
- package/dist/fonts.js +1 -0
- package/dist/icons/icons.js +184 -164
- package/dist/icons/jsx-svg.js +4957 -0
- package/dist/{index-Bfb9bWcb.js → index-BDk0TPWz.js} +1 -1
- package/dist/{index-a301f526.esm-Bioi4cGX.js → index-a301f526.esm-BzTuHLdr.js} +1 -1
- package/dist/index.js +30 -4
- package/dist/{intlStrings-CUhoK9EN.js → intlStrings-Ctkp0HDc.js} +1 -1
- package/dist/lite-pbIeT7tm.js +8 -0
- package/dist/{multi-select-components-CjVpCNko.js → multi-select-components-nORKdJ-2.js} +3 -3
- package/dist/{popover-Dx3vKXUX.js → popover-o2Q28Ljn.js} +19 -14
- package/dist/{react-select-async.esm-TFb_ZX6C.js → react-select-async.esm-CLj9uZTq.js} +3 -3
- package/dist/{react-select.esm-BjRWqf0E.js → react-select.esm-3tyTZmrx.js} +3 -3
- package/dist/{textSelection-BosCCRVE.js → textSelection-BRZdHY-4.js} +1 -1
- package/dist/{tooltip-CkCndvTI.js → tooltip-T6H9uF-Z.js} +10 -10
- package/dist/{useButton-CuG5UzUw.js → useButton-D-xACzEY.js} +3 -3
- package/dist/{useEvent-DHv-yhOH.js → useEvent-XlYPKgwX.js} +1 -1
- package/dist/{useFocusRing-Cc-4eouh.js → useFocusRing-CRx_hYC4.js} +1 -1
- package/dist/{useFocusable-5q1Gek1J.js → useFocusable-CHfpEdlE.js} +2 -2
- package/dist/{useFormReset-Buc9YJcv.js → useFormReset-aHn6-wRk.js} +1 -1
- package/dist/{useFormValidationState-BAPPNXic.js → useFormValidationState-CdYmOaXI.js} +2 -2
- package/dist/{useHasTabbableChild-D3uUNhJ0.js → useHasTabbableChild-domoFB7A.js} +2 -2
- package/dist/{useLabel-CGlkoFG0.js → useLabel-DVhXVhtH.js} +2 -2
- package/dist/{useLabels-Dg62M_3P.js → useLabels-C7E5SkOi.js} +1 -1
- package/dist/{useListState-Domq0blV.js → useListState-BRsq7O1C.js} +1 -1
- package/dist/{useLocalizedStringFormatter-Prmz0h0A.js → useLocalizedStringFormatter-WsEL47qR.js} +1 -1
- package/dist/{useNumberFieldState-BLU3uhSR.js → useNumberFieldState-ZH2Qyyxh.js} +9 -9
- package/dist/{useNumberFormatter-BLc2xjZn.js → useNumberFormatter-mhdYLxWQ.js} +1 -1
- package/dist/{usePress-BQgVor4T.js → usePress-B42RawCH.js} +3 -3
- package/dist/{useToggle-C9ETOBaZ.js → useToggle-CExfZM8x.js} +4 -4
- package/dist/{useToggleState-DJ_z5E2S.js → useToggleState-DghG5ImG.js} +1 -1
- package/dist/utilities/array-helpers.js +30 -0
- package/dist/utilities/index.js +8 -0
- package/dist/utilities/text-helpers.js +30 -4
- package/dist/{utils-BsiH7-5Y.js → utils-DIBzm1e4.js} +1 -1
- package/dist/wp.js +1 -0
- package/package.json +11 -4
- package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
- package/dist/utilities/classnames.js +0 -16
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { $ as $bc237834342dbd75$export$48513f6b9f8ce62d } from "../../Checkbox-
|
|
3
|
-
import {
|
|
4
|
-
import { B as Button } from "../../button-
|
|
2
|
+
import { $ as $bc237834342dbd75$export$48513f6b9f8ce62d } from "../../Checkbox-BN0TEda-.js";
|
|
3
|
+
import { b as $72e60046c03fbe42$export$54fe942636b6416d, a as $72e60046c03fbe42$export$e96fc9a8407faa6b } from "../../GridList-CzpWxJsS.js";
|
|
4
|
+
import { B as Button } from "../../button-idVI4jmd.js";
|
|
5
5
|
import { icons } from "../../icons/icons.js";
|
|
6
|
-
import {
|
|
6
|
+
import { c as clsx } from "../../lite-pbIeT7tm.js";
|
|
7
7
|
import { Expandable } from "../expandable/expandable.js";
|
|
8
|
-
import { _ as __ } from "../../default-i18n-
|
|
8
|
+
import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
|
|
9
9
|
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
10
10
|
import { useRef } from "react";
|
|
11
11
|
import { useCellEditMode } from "../../hooks/use-cell-edit-mode.js";
|
|
@@ -20,8 +20,9 @@ import { useCellEditMode } from "../../hooks/use-cell-edit-mode.js";
|
|
|
20
20
|
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
|
|
21
21
|
* @param {string} [props.textValue] - The text value of the item.
|
|
22
22
|
* @param {string} [props.className] - Classes to pass to the item.
|
|
23
|
+
* @param {bool} [props.expandDisabled] - If `true`, the item cannot be expanded.
|
|
23
24
|
*
|
|
24
|
-
* @returns {JSX.Element} The
|
|
25
|
+
* @returns {JSX.Element} The RepeaterItem component.
|
|
25
26
|
*
|
|
26
27
|
* @see {@link Repeater} for usage example.
|
|
27
28
|
*
|
|
@@ -37,6 +38,7 @@ const RepeaterItem = (props) => {
|
|
|
37
38
|
className,
|
|
38
39
|
actions,
|
|
39
40
|
textValue,
|
|
41
|
+
expandDisabled,
|
|
40
42
|
...rest
|
|
41
43
|
} = props;
|
|
42
44
|
let a11yLabel = textValue;
|
|
@@ -54,43 +56,48 @@ const RepeaterItem = (props) => {
|
|
|
54
56
|
{
|
|
55
57
|
"aria-label": ariaLabel ?? a11yLabel,
|
|
56
58
|
textValue: a11yLabel,
|
|
57
|
-
className:
|
|
59
|
+
className: clsx(
|
|
58
60
|
"es-uic-rounded-lg es-uic-transition",
|
|
59
61
|
"focus:es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50"
|
|
60
62
|
),
|
|
61
63
|
...rest,
|
|
62
|
-
children: ({ selectionMode, allowsDragging, isDragging }) =>
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
selectionMode === "none" && icon
|
|
69
|
-
] }),
|
|
70
|
-
label: /* @__PURE__ */ jsx("div", { className: "es-uic-flex es-uic-items-center es-uic-gap-1", children: label }),
|
|
71
|
-
subtitle,
|
|
72
|
-
labelClassName: className,
|
|
73
|
-
className: classnames(isDragging && "es-uic-opacity-25"),
|
|
74
|
-
onOpenChange: (isOpen) => setCanReorder(!isOpen),
|
|
75
|
-
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
76
|
-
selectionMode === "none" && allowsDragging && /* @__PURE__ */ jsx(
|
|
77
|
-
Button,
|
|
78
|
-
{
|
|
79
|
-
size: "small",
|
|
80
|
-
className: "es-uic-h-6 es-uic-w-4 !es-uic-text-gray-500 es-uic-opacity-5 focus:!es-uic-opacity-100",
|
|
81
|
-
slot: "drag",
|
|
82
|
-
type: "ghost",
|
|
83
|
-
icon: icons.reorderGrabberV,
|
|
84
|
-
tooltip: __("Re-order", "eightshift-ui-components")
|
|
85
|
-
}
|
|
86
|
-
),
|
|
87
|
-
actions
|
|
88
|
-
] }),
|
|
89
|
-
noFocusHandling: true,
|
|
90
|
-
...preventProps,
|
|
91
|
-
children
|
|
64
|
+
children: ({ selectionMode, allowsDragging, isDragging }) => {
|
|
65
|
+
let itemIcon = null;
|
|
66
|
+
if (selectionMode === "multiple") {
|
|
67
|
+
itemIcon = /* @__PURE__ */ jsx(Checkbox, { slot: "selection" });
|
|
68
|
+
} else if (selectionMode === "none") {
|
|
69
|
+
itemIcon = icon;
|
|
92
70
|
}
|
|
93
|
-
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
Expandable,
|
|
73
|
+
{
|
|
74
|
+
disabled: expandDisabled || selectionMode === "multiple",
|
|
75
|
+
icon: itemIcon,
|
|
76
|
+
label: /* @__PURE__ */ jsx("div", { className: "es-uic-flex es-uic-items-center es-uic-gap-1", children: label }),
|
|
77
|
+
subtitle,
|
|
78
|
+
labelClassName: className,
|
|
79
|
+
className: clsx(isDragging && "es-uic-opacity-25"),
|
|
80
|
+
onOpenChange: (isOpen) => setCanReorder(!isOpen),
|
|
81
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
82
|
+
selectionMode === "none" && allowsDragging && /* @__PURE__ */ jsx(
|
|
83
|
+
Button,
|
|
84
|
+
{
|
|
85
|
+
size: "small",
|
|
86
|
+
className: "es-uic-h-6 es-uic-w-4 !es-uic-text-gray-500 es-uic-opacity-5 focus:!es-uic-opacity-100",
|
|
87
|
+
slot: "drag",
|
|
88
|
+
type: "ghost",
|
|
89
|
+
icon: icons.reorderGrabberV,
|
|
90
|
+
tooltip: __("Re-order", "eightshift-ui-components")
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
actions
|
|
94
|
+
] }),
|
|
95
|
+
noFocusHandling: true,
|
|
96
|
+
...preventProps,
|
|
97
|
+
children
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
);
|
|
96
103
|
} });
|
|
@@ -100,7 +107,7 @@ const Checkbox = (props) => {
|
|
|
100
107
|
/* @__PURE__ */ jsxs(
|
|
101
108
|
"div",
|
|
102
109
|
{
|
|
103
|
-
className:
|
|
110
|
+
className: clsx(
|
|
104
111
|
"es-uic-flex es-uic-size-5.5 es-uic-items-center es-uic-justify-center es-uic-rounded-md es-uic-border es-uic-text-gray-600 es-uic-shadow-sm es-uic-transition",
|
|
105
112
|
isSelected && "es-uic-border-teal-600 es-uic-bg-teal-600 es-uic-text-white"
|
|
106
113
|
),
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { b as $72e60046c03fbe42$export$54fe942636b6416d, $ as $72e60046c03fbe42$export$a7bfbda1311ca015 } from "../../GridList-CzpWxJsS.js";
|
|
3
|
+
import { $ as $d8f176866e6dc039$export$2cfc5be7a55829f6, a as $d8f176866e6dc039$export$62ed72bc21f6b8a6 } from "../../ListBox-D3Vr4vvC.js";
|
|
4
|
+
import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
|
|
5
|
+
import { B as Button, a as ButtonGroup } from "../../button-idVI4jmd.js";
|
|
5
6
|
import { icons } from "../../icons/icons.js";
|
|
6
|
-
import { useId, useState
|
|
7
|
-
import { classnames } from "../../utilities/classnames.js";
|
|
8
|
-
import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
|
|
7
|
+
import { useId, useState } from "react";
|
|
9
8
|
import { BaseControl } from "../base-control/base-control.js";
|
|
10
9
|
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
11
10
|
import { ToggleButton } from "../toggle-button/toggle-button.js";
|
|
12
|
-
import {
|
|
11
|
+
import { arrayMoveMultiple } from "../../utilities/array-helpers.js";
|
|
12
|
+
import { c as clsx } from "../../lite-pbIeT7tm.js";
|
|
13
|
+
import { $ as $e72dd72e1c76a225$export$2f645645f7bca764 } from "../../useListState-BRsq7O1C.js";
|
|
13
14
|
/**
|
|
14
15
|
* A component that allows re-ordering a list of items with additional sub-options.
|
|
15
16
|
*
|
|
@@ -20,8 +21,7 @@ import { $ as $0d86e9c8f07f9a7b$export$762f73dccccd255d } from "../../useListDat
|
|
|
20
21
|
* @param {string} [props.subtitle] - Subtitle to display.
|
|
21
22
|
* @param {string} [props.help] - Help text to display below the input.
|
|
22
23
|
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
|
|
23
|
-
* @param {Object
|
|
24
|
-
* @param {string} [props.itemLabelProp] - Property of an item to use as the label when re-ordering items.
|
|
24
|
+
* @param {Object<string, any>[]} props.items - Data to display in the repeater.
|
|
25
25
|
* @param {boolean} [props.hideEmptyState] - If `true`, the empty state will not be displayed when there are no items.
|
|
26
26
|
* @param {Object<string, any>} [props.addDefaultItem] - Additional properties to add to a new item.
|
|
27
27
|
* @param {boolean} [props.addDisabled] - If `true`, the add button is disabled.
|
|
@@ -29,6 +29,9 @@ import { $ as $0d86e9c8f07f9a7b$export$762f73dccccd255d } from "../../useListDat
|
|
|
29
29
|
* @param {Function} [props.onAfterItemAdd] - Function to run after an item is added.
|
|
30
30
|
* @param {Function} [props.onAfterItemRemove] - Function to run after an item is removed.
|
|
31
31
|
* @param {Number} [props.minItems] - The minimum number of items that must be present. If there are less items than this, deleting items will be disabled.
|
|
32
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
33
|
+
* @param {JSX.Element} [props.addButton] - If provided, overrides the default add button. `(props: { addItem: (additional: Object<string, any>?) => void, disabled: Boolean }) => JSX.Element`.
|
|
34
|
+
* @param {string} [props.className] - Classes to pass to the item wrapper.
|
|
32
35
|
*
|
|
33
36
|
* @returns {JSX.Element} The Repeater component.
|
|
34
37
|
*
|
|
@@ -63,9 +66,8 @@ const Repeater = (props) => {
|
|
|
63
66
|
const itemIdBase = useId("repeater-item-");
|
|
64
67
|
const {
|
|
65
68
|
children,
|
|
66
|
-
onChange,
|
|
67
|
-
items,
|
|
68
|
-
itemLabelProp,
|
|
69
|
+
onChange: rawOnChange,
|
|
70
|
+
items: rawItems,
|
|
69
71
|
"aria-label": ariaLabel,
|
|
70
72
|
icon,
|
|
71
73
|
label,
|
|
@@ -78,25 +80,66 @@ const Repeater = (props) => {
|
|
|
78
80
|
onAfterItemAdd,
|
|
79
81
|
onAfterItemRemove,
|
|
80
82
|
minItems,
|
|
83
|
+
addButton,
|
|
84
|
+
className,
|
|
85
|
+
hidden,
|
|
81
86
|
...rest
|
|
82
87
|
} = props;
|
|
83
|
-
const list = $0d86e9c8f07f9a7b$export$762f73dccccd255d({
|
|
84
|
-
initialItems: items == null ? void 0 : items.map((item, i) => ({ id: item.id ?? `${itemIdBase}${i}`, ...item })),
|
|
85
|
-
getKey: ({ id }) => id
|
|
86
|
-
});
|
|
87
88
|
const [selectable, setSelectable] = useState(false);
|
|
88
89
|
const [canDelete, setCanDelete] = useState(false);
|
|
89
90
|
const [canReorder, setCanReorder] = useState(true);
|
|
91
|
+
const items = rawItems.map((item, i) => ({
|
|
92
|
+
key: item.key ?? `${itemIdBase}-${i}`,
|
|
93
|
+
...item
|
|
94
|
+
}));
|
|
95
|
+
const rawList = $e72dd72e1c76a225$export$2f645645f7bca764({
|
|
96
|
+
items,
|
|
97
|
+
selectionMode: selectable ? "multiple" : "none"
|
|
98
|
+
});
|
|
99
|
+
const onChange = (items2) => {
|
|
100
|
+
const currentItems = [...items2];
|
|
101
|
+
currentItems.forEach((item) => delete item.key);
|
|
102
|
+
console.log(items2, currentItems);
|
|
103
|
+
rawOnChange(currentItems);
|
|
104
|
+
};
|
|
105
|
+
const list = {
|
|
106
|
+
items,
|
|
107
|
+
selectedKeys: rawList.selectionManager.selectedKeys,
|
|
108
|
+
setSelectedKeys: (keys) => rawList.selectionManager.setSelectedKeys(keys),
|
|
109
|
+
getKey: ({ key }) => items.find((item) => item.key === key),
|
|
110
|
+
getItem: (key) => items.find((item) => item.key === key),
|
|
111
|
+
update: (key, newValue) => {
|
|
112
|
+
const index = [...items].findIndex((item) => item.key === key);
|
|
113
|
+
items[index] = { ...items[index], ...newValue };
|
|
114
|
+
onChange(items);
|
|
115
|
+
},
|
|
116
|
+
move: (sourceKey, targetKeys) => {
|
|
117
|
+
const sourceIndex = items.findIndex((item) => item.key === sourceKey);
|
|
118
|
+
const targetIndices = [...targetKeys].map((key) => items.findIndex((item) => item.key === key));
|
|
119
|
+
onChange(arrayMoveMultiple(items, targetIndices, sourceIndex));
|
|
120
|
+
},
|
|
121
|
+
insert: (targetKey, ...newItems) => {
|
|
122
|
+
const targetIndex = items.findIndex((item) => item.key === targetKey);
|
|
123
|
+
const newItemsWithKeys = newItems.map((item) => ({ ...item, id: `${itemIdBase}${items.length + 1}` }));
|
|
124
|
+
onChange([...items.slice(0, targetIndex), ...newItemsWithKeys, ...items.slice(targetIndex)]);
|
|
125
|
+
},
|
|
126
|
+
removeSelectedItems: () => {
|
|
127
|
+
const keys = rawList.selectionManager.selectedKeys;
|
|
128
|
+
const newItems = items.filter((item) => !keys.has(item.key));
|
|
129
|
+
onChange(newItems);
|
|
130
|
+
},
|
|
131
|
+
append: (item) => {
|
|
132
|
+
onChange([...items, item]);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
90
135
|
let { dragAndDropHooks } = $d8f176866e6dc039$export$2cfc5be7a55829f6({
|
|
91
136
|
isDisabled: selectable || !canReorder,
|
|
92
|
-
getItems: (keys) => [...keys].map((key) => ({
|
|
93
|
-
"text/plain": list.getItem(key)[itemLabelProp] ?? __("New item", "eightshift-ui-components")
|
|
94
|
-
})),
|
|
137
|
+
getItems: (keys) => [...keys].map((key) => ({ "text/plain": list.getItem(key).id })),
|
|
95
138
|
onReorder(e) {
|
|
96
139
|
if (e.target.dropPosition === "before") {
|
|
97
|
-
list.
|
|
140
|
+
list.move(e.target.key, e.keys);
|
|
98
141
|
} else if (e.target.dropPosition === "after") {
|
|
99
|
-
list.
|
|
142
|
+
list.move(e.target.key, e.keys);
|
|
100
143
|
}
|
|
101
144
|
},
|
|
102
145
|
renderDropIndicator(target) {
|
|
@@ -104,41 +147,17 @@ const Repeater = (props) => {
|
|
|
104
147
|
$d8f176866e6dc039$export$62ed72bc21f6b8a6,
|
|
105
148
|
{
|
|
106
149
|
target,
|
|
107
|
-
className: ({ isDropTarget }) =>
|
|
150
|
+
className: ({ isDropTarget }) => clsx(
|
|
108
151
|
"es-uic-h-10 es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-transition",
|
|
109
152
|
isDropTarget ? "es-uic-border-teal-500 es-uic-bg-teal-500/5" : "es-uic-border-dashed"
|
|
110
153
|
)
|
|
111
154
|
}
|
|
112
155
|
);
|
|
113
|
-
},
|
|
114
|
-
renderDragPreview(items2) {
|
|
115
|
-
let label2 = items2[0]["text/plain"];
|
|
116
|
-
if (!label2 || label2 === "") {
|
|
117
|
-
label2 = __("New item", "eightshift-ui-components");
|
|
118
|
-
}
|
|
119
|
-
return /* @__PURE__ */ jsx("div", { className: "es-uic-rounded-md es-uic-bg-teal-500 es-uic-px-1.5 es-uic-py-1 es-uic-text-xs es-uic-text-white es-uic-shadow-lg es-uic-shadow-teal-500/30", children: label2 });
|
|
120
|
-
},
|
|
121
|
-
async onInsert(e) {
|
|
122
|
-
let items2 = await Promise.all(
|
|
123
|
-
e.items.map(async (item) => {
|
|
124
|
-
let name = item.kind === "text" ? await item.getText("text/plain") : item.name;
|
|
125
|
-
return { id: Math.random(), name };
|
|
126
|
-
})
|
|
127
|
-
);
|
|
128
|
-
if (e.target.dropPosition === "before") {
|
|
129
|
-
list.insertBefore(e.target.key, ...items2);
|
|
130
|
-
} else if (e.target.dropPosition === "after") {
|
|
131
|
-
list.insertAfter(e.target.key, ...items2);
|
|
132
|
-
}
|
|
133
156
|
}
|
|
134
157
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return rest2;
|
|
139
|
-
});
|
|
140
|
-
onChange(items2);
|
|
141
|
-
}, [list.items]);
|
|
158
|
+
if (hidden) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
142
161
|
return /* @__PURE__ */ jsx(
|
|
143
162
|
BaseControl,
|
|
144
163
|
{
|
|
@@ -158,9 +177,7 @@ const Repeater = (props) => {
|
|
|
158
177
|
{
|
|
159
178
|
onPress: () => {
|
|
160
179
|
var _a;
|
|
161
|
-
const removedItems = [
|
|
162
|
-
...((_a = list == null ? void 0 : list.selectedKeys.keys()) == null ? void 0 : _a.map((key) => list.getItem(key))) ?? []
|
|
163
|
-
];
|
|
180
|
+
const removedItems = [...((_a = list == null ? void 0 : list.selectedKeys.keys()) == null ? void 0 : _a.map((key) => list.getItem(key))) ?? []];
|
|
164
181
|
list.removeSelectedItems();
|
|
165
182
|
setSelectable(false);
|
|
166
183
|
setCanDelete(false);
|
|
@@ -179,7 +196,7 @@ const Repeater = (props) => {
|
|
|
179
196
|
}
|
|
180
197
|
),
|
|
181
198
|
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
182
|
-
/* @__PURE__ */ jsx(
|
|
199
|
+
!addButton && /* @__PURE__ */ jsx(
|
|
183
200
|
Button,
|
|
184
201
|
{
|
|
185
202
|
onPress: () => {
|
|
@@ -195,6 +212,16 @@ const Repeater = (props) => {
|
|
|
195
212
|
disabled: addDisabled || selectable
|
|
196
213
|
}
|
|
197
214
|
),
|
|
215
|
+
addButton && addButton({
|
|
216
|
+
addItem: (additional = {}) => {
|
|
217
|
+
const newItem = { id: `${itemIdBase}${list.items.length + 1}`, ...addDefaultItem, ...additional };
|
|
218
|
+
list.append(newItem);
|
|
219
|
+
if (onAfterItemAdd) {
|
|
220
|
+
onAfterItemAdd(newItem);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
disabled: addDisabled || selectable
|
|
224
|
+
}),
|
|
198
225
|
/* @__PURE__ */ jsx(
|
|
199
226
|
ToggleButton,
|
|
200
227
|
{
|
|
@@ -226,16 +253,16 @@ const Repeater = (props) => {
|
|
|
226
253
|
items: list.items.map((item, index) => ({
|
|
227
254
|
...item,
|
|
228
255
|
updateData: (newValue) => {
|
|
229
|
-
list.update(item.
|
|
256
|
+
list.update(item.key, { ...list.getItem(item.key), ...newValue });
|
|
230
257
|
},
|
|
231
258
|
itemIndex: index,
|
|
232
|
-
deleteItem: () => list.remove(item.
|
|
259
|
+
deleteItem: () => list.remove(item.key),
|
|
233
260
|
canReorder,
|
|
234
261
|
setCanReorder
|
|
235
262
|
})),
|
|
236
263
|
dragAndDropHooks,
|
|
237
264
|
renderEmptyState: () => hideEmptyState ? null : /* @__PURE__ */ jsx("div", { className: "es-uic-rounded-md es-uic-border es-uic-border-dashed es-uic-border-gray-300 es-uic-p-2 es-uic-text-sm es-uic-text-gray-400", children: __("No items", "eightshift-ui-components") }),
|
|
238
|
-
className
|
|
265
|
+
className,
|
|
239
266
|
...rest,
|
|
240
267
|
children
|
|
241
268
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { D as DecorativeTooltip } from "../../tooltip-
|
|
4
|
-
import {
|
|
5
|
-
import { _ as __, s as sprintf } from "../../default-i18n-
|
|
3
|
+
import { D as DecorativeTooltip } from "../../tooltip-T6H9uF-Z.js";
|
|
4
|
+
import { c as clsx } from "../../lite-pbIeT7tm.js";
|
|
5
|
+
import { _ as __, s as sprintf } from "../../default-i18n-Bk1GxDHz.js";
|
|
6
6
|
import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
|
|
7
7
|
import { upperFirst } from "../../utilities/text-helpers.js";
|
|
8
8
|
import { icons } from "../../icons/icons.js";
|
|
9
|
-
import { B as Button } from "../../button-
|
|
9
|
+
import { B as Button } from "../../button-idVI4jmd.js";
|
|
10
10
|
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
11
11
|
import { ToggleButton } from "../toggle-button/toggle-button.js";
|
|
12
12
|
import { BaseControl } from "../base-control/base-control.js";
|
|
@@ -43,6 +43,7 @@ import { BaseControl } from "../base-control/base-control.js";
|
|
|
43
43
|
* @param {boolean} [props.inline] - If `true`, the default breakpoint is shown inline with the label. In the expanded state, all breakpoints are shown below the label.
|
|
44
44
|
* @param {Object<string, number>} [props.breakpointData] - Breakpoints to use. `{ [breakpoint: string]: number }`.
|
|
45
45
|
* @param {string[]} [props.breakpoints] - Breakpoints to use. `{ [breakpoint: string]: number }`.
|
|
46
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
46
47
|
*
|
|
47
48
|
* @returns {JSX.Element} The ResponsiveLegacy component.
|
|
48
49
|
*
|
|
@@ -89,13 +90,17 @@ const ResponsiveLegacy = (props) => {
|
|
|
89
90
|
children,
|
|
90
91
|
inline,
|
|
91
92
|
breakpointData,
|
|
92
|
-
breakpoints: rawBreakpoints = Object.keys(breakpointData).toReversed()
|
|
93
|
+
breakpoints: rawBreakpoints = Object.keys(breakpointData).toReversed(),
|
|
94
|
+
hidden
|
|
93
95
|
} = props;
|
|
94
96
|
const inheritValue = allowUndefined ? void 0 : rawInheritValue;
|
|
95
97
|
const [detailsVisible, setDetailsVisible] = useState(false);
|
|
96
98
|
const breakpoints = rawBreakpoints.slice(1);
|
|
97
99
|
const globalOverride = breakpoints.find((breakpoint) => (value == null ? void 0 : value[attribute[breakpoint]]) !== inheritValue);
|
|
98
100
|
const defaultBreakpoint = rawBreakpoints[0];
|
|
101
|
+
if (hidden) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
99
104
|
const DefaultTooltip = () => {
|
|
100
105
|
var _a, _b;
|
|
101
106
|
return /* @__PURE__ */ jsx(
|
|
@@ -136,7 +141,7 @@ const ResponsiveLegacy = (props) => {
|
|
|
136
141
|
}
|
|
137
142
|
) })
|
|
138
143
|
] }),
|
|
139
|
-
children: /* @__PURE__ */ jsx("div", { className: "es-uic-flex es-uic-size-
|
|
144
|
+
children: /* @__PURE__ */ jsx("div", { className: "es-uic-flex es-uic-size-7 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-border es-uic-border-teal-500/10 es-uic-bg-teal-50 es-uic-p-0.5 es-uic-text-teal-800 es-uic-shadow-sm es-uic-shadow-teal-600/25 [&>svg]:es-uic-size-5", children: icons[`screen${upperFirst(defaultBreakpoint)}`] ?? icons.play })
|
|
140
145
|
}
|
|
141
146
|
);
|
|
142
147
|
};
|
|
@@ -179,13 +184,13 @@ const ResponsiveLegacy = (props) => {
|
|
|
179
184
|
!inline && /* @__PURE__ */ jsxs(
|
|
180
185
|
"div",
|
|
181
186
|
{
|
|
182
|
-
className:
|
|
187
|
+
className: clsx(
|
|
183
188
|
"es-uic-grid es-uic-items-center es-uic-gap-x-2 es-uic-transition-[grid-template-columns,_margin-block-end] es-uic-duration-150",
|
|
184
|
-
detailsVisible ? "es-uic-mb-2 es-uic-grid-cols-[minmax(0,
|
|
189
|
+
detailsVisible ? "es-uic-mb-2 es-uic-grid-cols-[minmax(0,_1.75rem),_minmax(0,_1fr),_minmax(0,_2.25rem)]" : "es-uic-grid-cols-[minmax(0,_0rem),_minmax(0,_1fr),_minmax(0,_2.25rem)]"
|
|
185
190
|
),
|
|
186
191
|
children: [
|
|
187
192
|
detailsVisible && /* @__PURE__ */ jsx(DefaultTooltip, {}),
|
|
188
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
193
|
+
/* @__PURE__ */ jsx("div", { className: clsx(detailsVisible ? "es-uic-col-start-2 es-uic-col-end-2" : "es-uic-col-span-full"), children: children({
|
|
189
194
|
breakpoint: defaultBreakpoint,
|
|
190
195
|
currentValue: value == null ? void 0 : value[attribute[defaultBreakpoint]],
|
|
191
196
|
options,
|
|
@@ -286,9 +291,9 @@ const ResponsiveLegacy = (props) => {
|
|
|
286
291
|
children: /* @__PURE__ */ jsx(
|
|
287
292
|
"div",
|
|
288
293
|
{
|
|
289
|
-
className:
|
|
290
|
-
"es-uic-flex es-uic-size-
|
|
291
|
-
value[attribute[breakpoint]] === inheritValue
|
|
294
|
+
className: clsx(
|
|
295
|
+
"es-uic-flex es-uic-size-7 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-border es-uic-p-0.5 es-uic-shadow-sm es-uic-transition-colors [&>svg]:es-uic-size-5",
|
|
296
|
+
value[attribute[breakpoint]] === inheritValue ? "es-uic-border-gray-200 es-uic-bg-gray-50 es-uic-text-gray-700" : "es-uic-border-gray-100 es-uic-bg-white es-uic-text-gray-500"
|
|
292
297
|
),
|
|
293
298
|
children: (_e = icons) == null ? void 0 : _e[`screen${upperFirst(breakpoint)}`]
|
|
294
299
|
}
|