@eightshift/ui-components 0.0.1 → 0.0.3

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.
Files changed (116) hide show
  1. package/README.md +0 -1
  2. package/dist/Button-eebLs4cp.js +54 -0
  3. package/dist/{Checkbox-BLcVbhiO.js → Checkbox-BN0TEda-.js} +7 -7
  4. package/dist/{ColorSwatch-Cmlex_kT.js → ColorSwatch-BrowHhTG.js} +4 -4
  5. package/dist/{FieldError-wtMA4667.js → FieldError-ILxgMZy5.js} +2 -2
  6. package/dist/{FocusScope-1u9yyfIN.js → FocusScope-B9b0VMib.js} +2 -2
  7. package/dist/GeistMonoVF.woff2 +0 -0
  8. package/dist/GeistVF.woff2 +0 -0
  9. package/dist/{GridList-BZPXp3_O.js → GridList-CzpWxJsS.js} +18 -18
  10. package/dist/{Group-DyqpTRPe.js → Group-Dkdm2-E7.js} +3 -3
  11. package/dist/{Input-jsbb4ugq.js → Input-BJA4rmIo.js} +7 -7
  12. package/dist/{Label-BPzS-sR7.js → Label-9x5iLJ-Y.js} +1 -1
  13. package/dist/{ListBox-w9gDaJkV.js → ListBox-D3Vr4vvC.js} +18 -18
  14. package/dist/{Select-49a62830.esm-C-RFtLiD.js → Select-49a62830.esm-CKPmlkza.js} +1 -1
  15. package/dist/{SelectionManager-mefd0ThJ.js → SelectionManager-sedvcM-1.js} +8 -8
  16. package/dist/{Separator-DHn0CwdK.js → Separator-B6rnDabE.js} +3 -3
  17. package/dist/{Slider-Pyh2V4bY.js → Slider-C5U5N7uM.js} +11 -11
  18. package/dist/{Text-BM136LvS.js → Text-Cyxp9ewv.js} +1 -1
  19. package/dist/{VisuallyHidden-BYRI1Lfo.js → VisuallyHidden-BPJVSUyp.js} +2 -2
  20. package/dist/_commonjsHelpers-DWwsNxpa.js +8 -0
  21. package/dist/assets/fonts.css +1 -0
  22. package/dist/assets/style.css +1 -1
  23. package/dist/assets/wp.css +1 -0
  24. package/dist/{button-BkkdyHfJ.js → button-idVI4jmd.js} +45 -64
  25. package/dist/components/base-control/base-control.js +29 -39
  26. package/dist/components/breakpoint-preview/breakpoint-preview.js +7 -7
  27. package/dist/components/button/button.js +6 -5
  28. package/dist/components/checkbox/checkbox.js +9 -7
  29. package/dist/components/color-pickers/color-picker.js +27 -36
  30. package/dist/components/color-pickers/color-swatch.js +6 -6
  31. package/dist/components/color-pickers/gradient-editor.js +10 -6
  32. package/dist/components/color-pickers/solid-color-picker.js +35 -38
  33. package/dist/components/component-toggle/component-toggle.js +52 -6
  34. package/dist/components/container-panel/container-panel.js +55 -6
  35. package/dist/components/draggable-list/draggable-list-item.js +74 -0
  36. package/dist/components/draggable-list/draggable-list.js +157 -0
  37. package/dist/components/expandable/expandable.js +19 -12
  38. package/dist/components/input-field/input-field.js +15 -10
  39. package/dist/components/layout/hstack.js +40 -0
  40. package/dist/components/layout/vstack.js +40 -0
  41. package/dist/components/link-input/link-input.js +35 -31
  42. package/dist/components/list-box/list-box.js +11 -6
  43. package/dist/components/matrix-align/matrix-align.js +12 -7
  44. package/dist/components/menu/menu.js +26 -21
  45. package/dist/components/notice/notice.js +11 -7
  46. package/dist/components/number-picker/number-picker.js +19 -13
  47. package/dist/components/option-select/option-select.js +231 -0
  48. package/dist/components/placeholders/file-placeholder.js +53 -0
  49. package/dist/components/placeholders/image-placeholder.js +88 -0
  50. package/dist/components/placeholders/media-placeholder.js +62 -0
  51. package/dist/components/popover/popover.js +4 -4
  52. package/dist/components/radio/radio.js +56 -38
  53. package/dist/components/repeater/repeater-item.js +46 -39
  54. package/dist/components/repeater/repeater.js +82 -56
  55. package/dist/components/responsive/responsive-legacy.js +17 -12
  56. package/dist/components/responsive/responsive.js +227 -160
  57. package/dist/components/responsive-preview/responsive-preview.js +5 -3
  58. package/dist/components/rich-label/rich-label.js +12 -8
  59. package/dist/components/select/async-multi-select.js +9 -6
  60. package/dist/components/select/async-single-select.js +7 -2
  61. package/dist/components/select/custom-select-default-components.js +3 -3
  62. package/dist/components/select/multi-select-components.js +2 -2
  63. package/dist/components/select/multi-select.js +9 -6
  64. package/dist/components/select/react-select-component-wrappers.js +1 -1
  65. package/dist/components/select/single-select.js +7 -2
  66. package/dist/components/select/styles.js +4 -4
  67. package/dist/components/slider/column-config-slider.js +18 -34
  68. package/dist/components/slider/slider.js +19 -26
  69. package/dist/components/slider/utils.js +44 -1
  70. package/dist/components/spacer/spacer.js +21 -11
  71. package/dist/components/tabs/tabs.js +21 -20
  72. package/dist/components/toggle/switch.js +18 -12
  73. package/dist/components/toggle/toggle.js +8 -2
  74. package/dist/components/toggle-button/toggle-button.js +25 -13
  75. package/dist/components/tooltip/tooltip.js +4 -4
  76. package/dist/{context-jMy6xdVq.js → context-BAcFg5GO.js} +1 -1
  77. package/dist/{default-i18n-BhE-OUmt.js → default-i18n-Bk1GxDHz.js} +1 -1
  78. package/dist/{focusSafely-C3K8zAKj.js → focusSafely-B0hyd-S4.js} +1 -1
  79. package/dist/fonts.js +1 -0
  80. package/dist/icons/icons.js +184 -164
  81. package/dist/icons/jsx-svg.js +4957 -0
  82. package/dist/{index-Bfb9bWcb.js → index-BDk0TPWz.js} +1 -1
  83. package/dist/{index-a301f526.esm-Bioi4cGX.js → index-a301f526.esm-BzTuHLdr.js} +1 -1
  84. package/dist/index.js +30 -4
  85. package/dist/{intlStrings-CUhoK9EN.js → intlStrings-Ctkp0HDc.js} +1 -1
  86. package/dist/lite-pbIeT7tm.js +8 -0
  87. package/dist/{multi-select-components-CjVpCNko.js → multi-select-components-nORKdJ-2.js} +3 -3
  88. package/dist/{popover-Dx3vKXUX.js → popover-o2Q28Ljn.js} +19 -14
  89. package/dist/{react-select-async.esm-TFb_ZX6C.js → react-select-async.esm-CLj9uZTq.js} +3 -3
  90. package/dist/{react-select.esm-BjRWqf0E.js → react-select.esm-3tyTZmrx.js} +3 -3
  91. package/dist/{textSelection-BosCCRVE.js → textSelection-BRZdHY-4.js} +1 -1
  92. package/dist/{tooltip-CkCndvTI.js → tooltip-T6H9uF-Z.js} +10 -10
  93. package/dist/{useButton-CuG5UzUw.js → useButton-D-xACzEY.js} +3 -3
  94. package/dist/{useEvent-DHv-yhOH.js → useEvent-XlYPKgwX.js} +1 -1
  95. package/dist/{useFocusRing-Cc-4eouh.js → useFocusRing-CRx_hYC4.js} +1 -1
  96. package/dist/{useFocusable-5q1Gek1J.js → useFocusable-CHfpEdlE.js} +2 -2
  97. package/dist/{useFormReset-Buc9YJcv.js → useFormReset-aHn6-wRk.js} +1 -1
  98. package/dist/{useFormValidationState-BAPPNXic.js → useFormValidationState-CdYmOaXI.js} +2 -2
  99. package/dist/{useHasTabbableChild-D3uUNhJ0.js → useHasTabbableChild-domoFB7A.js} +2 -2
  100. package/dist/{useLabel-CGlkoFG0.js → useLabel-DVhXVhtH.js} +2 -2
  101. package/dist/{useLabels-Dg62M_3P.js → useLabels-C7E5SkOi.js} +1 -1
  102. package/dist/{useListState-Domq0blV.js → useListState-BRsq7O1C.js} +1 -1
  103. package/dist/{useLocalizedStringFormatter-Prmz0h0A.js → useLocalizedStringFormatter-WsEL47qR.js} +1 -1
  104. package/dist/{useNumberFieldState-BLU3uhSR.js → useNumberFieldState-ZH2Qyyxh.js} +9 -9
  105. package/dist/{useNumberFormatter-BLc2xjZn.js → useNumberFormatter-mhdYLxWQ.js} +1 -1
  106. package/dist/{usePress-BQgVor4T.js → usePress-B42RawCH.js} +3 -3
  107. package/dist/{useToggle-C9ETOBaZ.js → useToggle-CExfZM8x.js} +4 -4
  108. package/dist/{useToggleState-DJ_z5E2S.js → useToggleState-DghG5ImG.js} +1 -1
  109. package/dist/utilities/array-helpers.js +30 -0
  110. package/dist/utilities/index.js +8 -0
  111. package/dist/utilities/text-helpers.js +30 -4
  112. package/dist/{utils-BsiH7-5Y.js → utils-DIBzm1e4.js} +1 -1
  113. package/dist/wp.js +1 -0
  114. package/package.json +11 -4
  115. package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
  116. 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-BLcVbhiO.js";
3
- import { $ as $72e60046c03fbe42$export$54fe942636b6416d, b as $72e60046c03fbe42$export$e96fc9a8407faa6b } from "../../GridList-BZPXp3_O.js";
4
- import { B as Button } from "../../button-BkkdyHfJ.js";
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 { classnames } from "../../utilities/classnames.js";
6
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
7
7
  import { Expandable } from "../expandable/expandable.js";
8
- import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
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 ButtonGroup component.
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: classnames(
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 }) => /* @__PURE__ */ jsx(
63
- Expandable,
64
- {
65
- disabled: selectionMode === "multiple",
66
- icon: /* @__PURE__ */ jsxs(Fragment, { children: [
67
- selectionMode === "multiple" && /* @__PURE__ */ jsx(Checkbox, { slot: "selection" }),
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: classnames(
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 { $ as $72e60046c03fbe42$export$54fe942636b6416d, a as $72e60046c03fbe42$export$a7bfbda1311ca015 } from "../../GridList-BZPXp3_O.js";
3
- import { b as $d8f176866e6dc039$export$2cfc5be7a55829f6, c as $d8f176866e6dc039$export$62ed72bc21f6b8a6 } from "../../ListBox-w9gDaJkV.js";
4
- import { B as Button, a as ButtonGroup } from "../../button-BkkdyHfJ.js";
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, useEffect } from "react";
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 { $ as $0d86e9c8f07f9a7b$export$762f73dccccd255d } from "../../useListData-BelKu4kx.js";
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[]<string, any>} props.items - Data to display in the repeater.
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,65 @@ 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
+ rawOnChange(currentItems);
103
+ };
104
+ const list = {
105
+ items,
106
+ selectedKeys: rawList.selectionManager.selectedKeys,
107
+ setSelectedKeys: (keys) => rawList.selectionManager.setSelectedKeys(keys),
108
+ getKey: ({ key }) => items.find((item) => item.key === key),
109
+ getItem: (key) => items.find((item) => item.key === key),
110
+ update: (key, newValue) => {
111
+ const index = [...items].findIndex((item) => item.key === key);
112
+ items[index] = { ...items[index], ...newValue };
113
+ onChange(items);
114
+ },
115
+ move: (sourceKey, targetKeys) => {
116
+ const sourceIndex = items.findIndex((item) => item.key === sourceKey);
117
+ const targetIndices = [...targetKeys].map((key) => items.findIndex((item) => item.key === key));
118
+ onChange(arrayMoveMultiple(items, targetIndices, sourceIndex));
119
+ },
120
+ insert: (targetKey, ...newItems) => {
121
+ const targetIndex = items.findIndex((item) => item.key === targetKey);
122
+ const newItemsWithKeys = newItems.map((item) => ({ ...item, id: `${itemIdBase}${items.length + 1}` }));
123
+ onChange([...items.slice(0, targetIndex), ...newItemsWithKeys, ...items.slice(targetIndex)]);
124
+ },
125
+ removeSelectedItems: () => {
126
+ const keys = rawList.selectionManager.selectedKeys;
127
+ const newItems = items.filter((item) => !keys.has(item.key));
128
+ onChange(newItems);
129
+ },
130
+ append: (item) => {
131
+ onChange([...items, item]);
132
+ }
133
+ };
90
134
  let { dragAndDropHooks } = $d8f176866e6dc039$export$2cfc5be7a55829f6({
91
135
  isDisabled: selectable || !canReorder,
92
- getItems: (keys) => [...keys].map((key) => ({
93
- "text/plain": list.getItem(key)[itemLabelProp] ?? __("New item", "eightshift-ui-components")
94
- })),
136
+ getItems: (keys) => [...keys].map((key) => ({ "text/plain": list.getItem(key).id })),
95
137
  onReorder(e) {
96
138
  if (e.target.dropPosition === "before") {
97
- list.moveBefore(e.target.key, e.keys);
139
+ list.move(e.target.key, e.keys);
98
140
  } else if (e.target.dropPosition === "after") {
99
- list.moveAfter(e.target.key, e.keys);
141
+ list.move(e.target.key, e.keys);
100
142
  }
101
143
  },
102
144
  renderDropIndicator(target) {
@@ -104,41 +146,17 @@ const Repeater = (props) => {
104
146
  $d8f176866e6dc039$export$62ed72bc21f6b8a6,
105
147
  {
106
148
  target,
107
- className: ({ isDropTarget }) => classnames(
149
+ className: ({ isDropTarget }) => clsx(
108
150
  "es-uic-h-10 es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-transition",
109
151
  isDropTarget ? "es-uic-border-teal-500 es-uic-bg-teal-500/5" : "es-uic-border-dashed"
110
152
  )
111
153
  }
112
154
  );
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
155
  }
134
156
  });
135
- useEffect(() => {
136
- const items2 = list.items.map((item) => {
137
- const { id, ...rest2 } = item;
138
- return rest2;
139
- });
140
- onChange(items2);
141
- }, [list.items]);
157
+ if (hidden) {
158
+ return null;
159
+ }
142
160
  return /* @__PURE__ */ jsx(
143
161
  BaseControl,
144
162
  {
@@ -158,9 +176,7 @@ const Repeater = (props) => {
158
176
  {
159
177
  onPress: () => {
160
178
  var _a;
161
- const removedItems = [
162
- ...((_a = list == null ? void 0 : list.selectedKeys.keys()) == null ? void 0 : _a.map((key) => list.getItem(key))) ?? []
163
- ];
179
+ const removedItems = [...((_a = list == null ? void 0 : list.selectedKeys.keys()) == null ? void 0 : _a.map((key) => list.getItem(key))) ?? []];
164
180
  list.removeSelectedItems();
165
181
  setSelectable(false);
166
182
  setCanDelete(false);
@@ -179,7 +195,7 @@ const Repeater = (props) => {
179
195
  }
180
196
  ),
181
197
  /* @__PURE__ */ jsxs(ButtonGroup, { children: [
182
- /* @__PURE__ */ jsx(
198
+ !addButton && /* @__PURE__ */ jsx(
183
199
  Button,
184
200
  {
185
201
  onPress: () => {
@@ -195,6 +211,16 @@ const Repeater = (props) => {
195
211
  disabled: addDisabled || selectable
196
212
  }
197
213
  ),
214
+ addButton && addButton({
215
+ addItem: (additional = {}) => {
216
+ const newItem = { id: `${itemIdBase}${list.items.length + 1}`, ...addDefaultItem, ...additional };
217
+ list.append(newItem);
218
+ if (onAfterItemAdd) {
219
+ onAfterItemAdd(newItem);
220
+ }
221
+ },
222
+ disabled: addDisabled || selectable
223
+ }),
198
224
  /* @__PURE__ */ jsx(
199
225
  ToggleButton,
200
226
  {
@@ -226,16 +252,16 @@ const Repeater = (props) => {
226
252
  items: list.items.map((item, index) => ({
227
253
  ...item,
228
254
  updateData: (newValue) => {
229
- list.update(item.id, { ...list.getItem(item.id), ...newValue });
255
+ list.update(item.key, { ...list.getItem(item.key), ...newValue });
230
256
  },
231
257
  itemIndex: index,
232
- deleteItem: () => list.remove(item.id),
258
+ deleteItem: () => list.remove(item.key),
233
259
  canReorder,
234
260
  setCanReorder
235
261
  })),
236
262
  dragAndDropHooks,
237
263
  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: "es-uic-space-y-1.5",
264
+ className,
239
265
  ...rest,
240
266
  children
241
267
  }
@@ -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-CkCndvTI.js";
4
- import { classnames } from "../../utilities/classnames.js";
5
- import { _ as __, s as sprintf } from "../../default-i18n-BhE-OUmt.js";
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-BkkdyHfJ.js";
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-8 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-bg-gray-200 es-uic-p-0.5 es-uic-text-gray-950 [&>svg]:es-uic-size-4", children: icons[`screen${upperFirst(defaultBreakpoint)}`] ?? icons.play })
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: classnames(
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,_2rem),_minmax(0,_1fr),_minmax(0,_2.25rem)]" : "es-uic-grid-cols-[minmax(0,_0rem),_minmax(0,_1fr),_minmax(0,_2.25rem)]"
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: classnames(detailsVisible ? "es-uic-col-start-2 es-uic-col-end-2" : "es-uic-col-span-full"), children: children({
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: classnames(
290
- "es-uic-flex es-uic-size-8 es-uic-shrink-0 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-bg-gray-100 es-uic-p-0.5 es-uic-text-gray-800",
291
- value[attribute[breakpoint]] === inheritValue && "[&>svg]:es-uic-opacity-25"
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
  }