@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,9 +1,13 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { s as sprintf, _ as __ } from "../../default-i18n-Bk1GxDHz.js";
3
3
  import { Expandable } from "../expandable/expandable.js";
4
4
  import { icons } from "../../icons/icons.js";
5
5
  import { Switch } from "../toggle/switch.js";
6
- import { D as DecorativeTooltip } from "../../tooltip-CkCndvTI.js";
6
+ import { T as TriggeredPopover } from "../../popover-o2Q28Ljn.js";
7
+ import { a as ButtonGroup } from "../../button-idVI4jmd.js";
8
+ import { ToggleButton } from "../toggle-button/toggle-button.js";
9
+ import { Spacer } from "../spacer/spacer.js";
10
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
7
11
  /**
8
12
  * A component that provides a nice way to toggle a component on and off, and display its content in an expandable panel.
9
13
  *
@@ -18,9 +22,13 @@ import { D as DecorativeTooltip } from "../../tooltip-CkCndvTI.js";
18
22
  * @param {boolean} [props.expandButtonDisabled] - If `true`, the expand button is disabled.
19
23
  * @param {boolean} [props.controlOnly] - If `true`, only the control is displayed.
20
24
  * @param {string} [props.contentClassName] - Classes to pass to the content container.
25
+ * @param {ComponentToggleDesign} [props.design='default'] - Design of the component.
26
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
21
27
  *
22
28
  * @returns {JSX.Element} The ComponentToggle component.
23
29
  *
30
+ * @typedef {'default' | 'compact' | 'compactLabel' | 'compactIcon'} ComponentToggleDesign
31
+ *
24
32
  * @example
25
33
  * <ComponentToggle
26
34
  * label='My component'
@@ -43,24 +51,62 @@ const ComponentToggle = (props) => {
43
51
  noUseToggle,
44
52
  expandButtonDisabled,
45
53
  controlOnly,
46
- contentClassName = "es-uic-space-y-2.5"
54
+ contentClassName = "es-uic-space-y-2.5",
55
+ design = "default",
56
+ hidden
47
57
  } = props;
58
+ if (hidden) {
59
+ return null;
60
+ }
48
61
  if (controlOnly) {
49
62
  return children;
50
63
  }
64
+ if (design.startsWith("compact")) {
65
+ const optionsLabel = sprintf(__("%s options", "eightshift-ui-components"), label);
66
+ const hasIcon = design === "compact" || design === "compactIcon";
67
+ const hasLabel = design === "compact" || design === "compactLabel";
68
+ return /* @__PURE__ */ jsxs(ButtonGroup, { children: [
69
+ /* @__PURE__ */ jsx(
70
+ ToggleButton,
71
+ {
72
+ icon: hasIcon && (icon ?? icons.componentGeneric),
73
+ tooltip: hasIcon && label,
74
+ selected: useComponent,
75
+ onChange,
76
+ children: hasLabel && label
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsxs(
80
+ TriggeredPopover,
81
+ {
82
+ triggerButtonProps: {
83
+ className: "es-uic-w-5.5 es-uic-stroke-[1.25]",
84
+ tooltip: optionsLabel,
85
+ disabled: !useComponent
86
+ },
87
+ triggerButtonIcon: icons.dropdownCaretAlt,
88
+ className: clsx("es-uic-w-[18.5rem] es-uic-p-2", contentClassName),
89
+ children: [
90
+ /* @__PURE__ */ jsx(Spacer, { text: optionsLabel }),
91
+ children
92
+ ]
93
+ }
94
+ )
95
+ ] });
96
+ }
51
97
  return /* @__PURE__ */ jsx(
52
98
  Expandable,
53
99
  {
54
100
  icon: icon ?? icons.componentGeneric,
55
101
  label,
56
102
  subtitle,
57
- actions: !noUseToggle && /* @__PURE__ */ jsx(DecorativeTooltip, { text: __("Toggle component", "eightshift-ui-components"), children: /* @__PURE__ */ jsx("div", { className: "es-uic-mr-0.5 es-uic-flex es-uic-min-h-8 es-uic-items-center es-uic-border-r es-uic-border-r-gray-200 es-uic-pr-1.5", children: /* @__PURE__ */ jsx(
103
+ actions: !noUseToggle && /* @__PURE__ */ jsx(
58
104
  Switch,
59
105
  {
60
106
  checked: useComponent,
61
107
  onChange
62
108
  }
63
- ) }) }),
109
+ ),
64
110
  disabled: !useComponent || expandButtonDisabled,
65
111
  children: !expandButtonDisabled && /* @__PURE__ */ jsx("div", { className: contentClassName, children })
66
112
  }
@@ -1,5 +1,11 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { classnames } from "../../utilities/classnames.js";
2
+ import { useState } from "react";
3
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
4
+ import { Switch } from "../toggle/switch.js";
5
+ import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
6
+ import { B as Button } from "../../button-idVI4jmd.js";
7
+ import { icons } from "../../icons/icons.js";
8
+ import { RichLabel } from "../rich-label/rich-label.js";
3
9
  /**
4
10
  * Component that provides a container panel for options, with an optional title.
5
11
  * Best used within the Gutenberg sidebar, instead of the default `PanelBody` component.
@@ -9,6 +15,11 @@ import { classnames } from "../../utilities/classnames.js";
9
15
  * @param {Object} props - Component props.
10
16
  * @param {string} [props.className] - Classes to pass to the container.
11
17
  * @param {string} [props.title] - Title to display on the top of the panel.
18
+ * @param {JSX.Element} [props.icon] - Icon to display on the top of the panel.
19
+ * @param {string} [props.subtitle] - Subtitle to display on the top of the panel.
20
+ * @param {boolean} [props.withToggle] - If `true`, the panel will have a toggle button to control the visibility of child items. Will not show if `title` is not set.
21
+ * @param {boolean} [props.closeable] - If `true`, the panel will have a close button to control the visibility of child items. Will not show if `title` is not set.
22
+ * @param {boolean} [props.startOpen] - If `true`, and panel has either a toggle or a close button, the panel will be open by default.
12
23
  *
13
24
  * @returns {JSX.Element} The ContainerPanel component.
14
25
  *
@@ -19,17 +30,55 @@ import { classnames } from "../../utilities/classnames.js";
19
30
  *
20
31
  * @preserve
21
32
  */
22
- const ContainerPanel = ({ children, className, title }) => {
33
+ const ContainerPanel = (props) => {
34
+ const { children, className, title, icon, subtitle, withToggle, closeable, startOpen = false } = props;
35
+ const [open, setOpen] = useState(startOpen);
23
36
  return /* @__PURE__ */ jsxs(
24
37
  "div",
25
38
  {
26
- className: classnames(
27
- "es-uic-space-y-2.5 es-uic-border-t es-uic-border-t-gray-200 es-uic-p-4 es-uic-pt-3",
39
+ className: clsx(
40
+ "es-uic-space-y-2.5 es-uic-border-t es-uic-border-t-gray-200 es-uic-px-4",
41
+ !(withToggle || closeable) && "es-uic-py-4",
42
+ (withToggle || closeable) && !open && "es-uic-py-2.5",
43
+ (withToggle || closeable) && open && "es-uic-pb-4 es-uic-pt-2.5",
28
44
  className
29
45
  ),
30
46
  children: [
31
- title && /* @__PURE__ */ jsx("span", { className: "es-uic-select-none es-uic-text-[0.8125rem] es-uic-font-medium es-uic-text-gray-500", children: title }),
32
- children
47
+ title && /* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-items-center es-uic-gap-2", children: [
48
+ /* @__PURE__ */ jsx(
49
+ RichLabel,
50
+ {
51
+ icon,
52
+ label: title,
53
+ subtitle,
54
+ className: "es-uic-select-none es-uic-text-[0.8125rem] es-uic-font-medium !es-uic-text-gray-500"
55
+ }
56
+ ),
57
+ (withToggle || closeable) && /* @__PURE__ */ jsxs("div", { className: "es-uic-ml-auto", children: [
58
+ withToggle && /* @__PURE__ */ jsx(
59
+ Switch,
60
+ {
61
+ checked: open,
62
+ onChange: setOpen
63
+ }
64
+ ),
65
+ closeable && /* @__PURE__ */ jsx(
66
+ Button,
67
+ {
68
+ onPress: () => setOpen(!open),
69
+ icon: open ? icons.caretDownFill : icons.caretDown,
70
+ type: "ghost",
71
+ size: "small",
72
+ className: clsx(
73
+ "[&>svg]:es-uic-size-5 [&>svg]:es-uic-transition-transform",
74
+ open && "[&>svg]:-es-uic-scale-y-100"
75
+ )
76
+ }
77
+ )
78
+ ] })
79
+ ] }),
80
+ !(withToggle || closeable) && children,
81
+ (withToggle || closeable) && /* @__PURE__ */ jsx(AnimatedVisibility, { visible: open, children })
33
82
  ]
34
83
  }
35
84
  );
@@ -0,0 +1,74 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { a as $72e60046c03fbe42$export$e96fc9a8407faa6b } from "../../GridList-CzpWxJsS.js";
3
+ import { B as Button } from "../../button-idVI4jmd.js";
4
+ import { icons } from "../../icons/icons.js";
5
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
6
+ import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
7
+ import { RichLabel } from "../rich-label/rich-label.js";
8
+ /**
9
+ * A DraggableList item.
10
+ *
11
+ * @component
12
+ * @param {Object} props - Component props.
13
+ * @param {JSX.Element} [props.icon] - Icon to display in the label.
14
+ * @param {string} [props.label] - Label to display.
15
+ * @param {string} [props.subtitle] - Subtitle to display.
16
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
17
+ * @param {string} [props.textValue] - The text value of the item.
18
+ * @param {string} [props.className] - Classes to pass to the item.
19
+ *
20
+ * @returns {JSX.Element} The DraggableList component.
21
+ *
22
+ * @see {@link DraggableList} for usage example.
23
+ *
24
+ * @preserve
25
+ */
26
+ const DraggableListItem = (props) => {
27
+ const { children, icon, label, subtitle, "aria-label": ariaLabel, className, textValue, ...rest } = props;
28
+ let a11yLabel = textValue;
29
+ if ((label == null ? void 0 : label.length) > 0) {
30
+ a11yLabel = label;
31
+ }
32
+ if (a11yLabel === "" || !a11yLabel) {
33
+ a11yLabel = __("New item", "eightshift-ui-components");
34
+ }
35
+ return /* @__PURE__ */ jsxs(
36
+ $72e60046c03fbe42$export$e96fc9a8407faa6b,
37
+ {
38
+ "aria-label": ariaLabel ?? a11yLabel,
39
+ textValue: a11yLabel,
40
+ className: clsx(
41
+ "es-uic-flex es-uic-min-h-7 es-uic-items-center es-uic-gap-1 es-uic-rounded-lg es-uic-transition",
42
+ "focus:es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50"
43
+ ),
44
+ ...rest,
45
+ children: [
46
+ /* @__PURE__ */ jsx(
47
+ RichLabel,
48
+ {
49
+ icon,
50
+ label,
51
+ subtitle,
52
+ className,
53
+ fullWidth: true
54
+ }
55
+ ),
56
+ /* @__PURE__ */ jsx(
57
+ Button,
58
+ {
59
+ size: "small",
60
+ className: "es-uic-ml-auto es-uic-h-6 es-uic-w-4 es-uic-shrink-0 !es-uic-text-gray-500 es-uic-opacity-5 focus:!es-uic-opacity-100",
61
+ slot: "drag",
62
+ type: "ghost",
63
+ icon: icons.reorderGrabberV,
64
+ tooltip: __("Re-order", "eightshift-ui-components")
65
+ }
66
+ ),
67
+ children
68
+ ]
69
+ }
70
+ );
71
+ };
72
+ export {
73
+ DraggableListItem
74
+ };
@@ -0,0 +1,157 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { $ 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 { useId, useEffect } from "react";
5
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
6
+ import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
7
+ import { BaseControl } from "../base-control/base-control.js";
8
+ import { $ as $0d86e9c8f07f9a7b$export$762f73dccccd255d } from "../../useListData-BelKu4kx.js";
9
+ /**
10
+ * A component that allows re-ordering a list of items.
11
+ *
12
+ * @component
13
+ * @param {Object} props - Component props.
14
+ * @param {JSX.Element} [props.icon] - Icon to display in the label.
15
+ * @param {string} [props.label] - Label to display.
16
+ * @param {string} [props.subtitle] - Subtitle to display.
17
+ * @param {string} [props.help] - Help text to display below the input.
18
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
19
+ * @param {Object<string, any>[]} props.items - Data to display in the list.
20
+ * @param {boolean} [props.hideEmptyState] - If `true`, the empty state will not be displayed when there are no items.
21
+ * @param {Function} props.onChange - Function to run when the items change.
22
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
23
+ * @param {boolean} [props.disabled] - If `true`, item reordering is disabled.
24
+ * @param {string} [props.className] - Classes to pass to the item wrapper.
25
+ *
26
+ * @returns {JSX.Element} The DraggableList component.
27
+ *
28
+ * @example
29
+ * <DraggableList
30
+ * label='My draggable list'
31
+ * items={items}
32
+ * onChange={setItems}
33
+ * >
34
+ * {(item) => {
35
+ * const { title, updateData } = item;
36
+ *
37
+ * return (
38
+ * <DraggableListItem
39
+ * label={title ?? 'New item'}
40
+ * icon={icons.myIcon}
41
+ * >
42
+ * <InputField
43
+ * label='Title'
44
+ * type='text'
45
+ * value={title}
46
+ * onChange={(value) => updateData({ title: value })}
47
+ * />
48
+ * </DraggableListItem>
49
+ * );
50
+ * }}
51
+ * </DraggableList>
52
+ *
53
+ * @preserve
54
+ */
55
+ const DraggableList = (props) => {
56
+ const itemIdBase = useId("draggable-list-item-");
57
+ const {
58
+ children,
59
+ onChange,
60
+ items,
61
+ "aria-label": ariaLabel,
62
+ icon,
63
+ label,
64
+ subtitle,
65
+ help,
66
+ actions,
67
+ hideEmptyState,
68
+ disabled,
69
+ className,
70
+ hidden,
71
+ ...rest
72
+ } = props;
73
+ const list = $0d86e9c8f07f9a7b$export$762f73dccccd255d({
74
+ initialItems: items == null ? void 0 : items.map((item, i) => ({ id: item.id ?? `${itemIdBase}${i}`, ...item })),
75
+ getKey: ({ id }) => id
76
+ });
77
+ let { dragAndDropHooks } = $d8f176866e6dc039$export$2cfc5be7a55829f6({
78
+ isDisabled: disabled,
79
+ getItems: (keys) => [...keys].map((key) => ({ "text/plain": list.getItem(key).id })),
80
+ onReorder(e) {
81
+ if (e.target.dropPosition === "before") {
82
+ list.moveBefore(e.target.key, e.keys);
83
+ } else if (e.target.dropPosition === "after") {
84
+ list.moveAfter(e.target.key, e.keys);
85
+ }
86
+ },
87
+ renderDropIndicator(target) {
88
+ return /* @__PURE__ */ jsx(
89
+ $d8f176866e6dc039$export$62ed72bc21f6b8a6,
90
+ {
91
+ target,
92
+ className: ({ isDropTarget }) => clsx(
93
+ "es-uic-h-10 es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-transition",
94
+ isDropTarget ? "es-uic-border-teal-500 es-uic-bg-teal-500/5" : "es-uic-border-dashed"
95
+ )
96
+ }
97
+ );
98
+ },
99
+ async onInsert(e) {
100
+ let items2 = await Promise.all(
101
+ e.items.map(async (item) => {
102
+ let name = item.kind === "text" ? await item.getText("text/plain") : item.name;
103
+ return { id: Math.random(), name };
104
+ })
105
+ );
106
+ if (e.target.dropPosition === "before") {
107
+ list.insertBefore(e.target.key, ...items2);
108
+ } else if (e.target.dropPosition === "after") {
109
+ list.insertAfter(e.target.key, ...items2);
110
+ }
111
+ }
112
+ });
113
+ useEffect(() => {
114
+ const items2 = list.items.map((item) => {
115
+ const { id, ...rest2 } = item;
116
+ return rest2;
117
+ });
118
+ onChange(items2);
119
+ }, [list.items]);
120
+ if (hidden) {
121
+ return null;
122
+ }
123
+ return /* @__PURE__ */ jsx(
124
+ BaseControl,
125
+ {
126
+ icon,
127
+ label,
128
+ subtitle,
129
+ help,
130
+ actions,
131
+ className: "es-uic-w-full",
132
+ children: /* @__PURE__ */ jsx(
133
+ $72e60046c03fbe42$export$a7bfbda1311ca015,
134
+ {
135
+ "aria-label": ariaLabel ?? __("Draggable list", "eightshift-ui-components"),
136
+ selectionMode: "none",
137
+ items: list.items.map((item, index) => ({
138
+ ...item,
139
+ updateData: (newValue) => {
140
+ list.update(item.id, { ...list.getItem(item.id), ...newValue });
141
+ },
142
+ itemIndex: index,
143
+ deleteItem: () => list.remove(item.id)
144
+ })),
145
+ dragAndDropHooks,
146
+ 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") }),
147
+ className,
148
+ ...rest,
149
+ children
150
+ }
151
+ )
152
+ }
153
+ );
154
+ };
155
+ export {
156
+ DraggableList
157
+ };
@@ -2,12 +2,12 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
3
  import { RichLabel } from "../rich-label/rich-label.js";
4
4
  import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
5
- import { B as Button } from "../../button-BkkdyHfJ.js";
5
+ import { B as Button } from "../../button-idVI4jmd.js";
6
6
  import { icons } from "../../icons/icons.js";
7
- import { classnames } from "../../utilities/classnames.js";
8
- import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
9
- import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BPzS-sR7.js";
10
- import { $ as $9bf71ea28793e738$export$20e40289641fbbb6 } from "../../FocusScope-1u9yyfIN.js";
7
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
8
+ import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
9
+ import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-9x5iLJ-Y.js";
10
+ import { $ as $9bf71ea28793e738$export$20e40289641fbbb6 } from "../../FocusScope-B9b0VMib.js";
11
11
  /**
12
12
  * A component that allows hiding content in an expandable panel, to declutter the UI.
13
13
  *
@@ -17,6 +17,7 @@ import { $ as $9bf71ea28793e738$export$20e40289641fbbb6 } from "../../FocusScope
17
17
  * @param {string} props.label - Label to display.
18
18
  * @param {string} [props.subtitle] - Subtitle to display.
19
19
  * @param {string} [props.className] - Classes to pass to the container.
20
+ * @param {string} [props.contentClassName] - Classes to pass to the inner content wrapper.
20
21
  * @param {string} [props.labelClassName] - Classes to pass to the label.
21
22
  * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display in the panel header, left of the expand button.
22
23
  * @param {boolean} [props.keepActionsOnExpand=false] - If `true`, the actions are not hidden when the panel is expanded.
@@ -24,6 +25,7 @@ import { $ as $9bf71ea28793e738$export$20e40289641fbbb6 } from "../../FocusScope
24
25
  * @param {boolean} [props.noFocusHandling] - If `true`, the focus trapping when the item is expanded is disabled. Useful when part of another component that manages focus itself.
25
26
  * @param {boolean} [props.open] - Whether the expandable is open.
26
27
  * @param {Function} [props.onOpenChange] - Function is called when the panel is opened or closed.
28
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
27
29
  *
28
30
  * @returns {JSX.Element} The Expandable component.
29
31
  *
@@ -41,6 +43,7 @@ const Expandable = (props) => {
41
43
  subtitle,
42
44
  className,
43
45
  labelClassName,
46
+ contentClassName,
44
47
  actions,
45
48
  keepActionsOnExpand = false,
46
49
  disabled,
@@ -48,13 +51,17 @@ const Expandable = (props) => {
48
51
  children,
49
52
  open = false,
50
53
  onOpenChange,
54
+ hidden,
51
55
  ...other
52
56
  } = props;
53
57
  const [isOpen, setIsOpen] = React__default.useState(open);
58
+ if (hidden) {
59
+ return null;
60
+ }
54
61
  const component = /* @__PURE__ */ jsxs(
55
62
  "div",
56
63
  {
57
- className: classnames(
64
+ className: clsx(
58
65
  "es-uic-w-full es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-border-opacity-0 es-uic-text-sm es-uic-transition",
59
66
  isOpen && "es-uic-border-opacity-100 es-uic-shadow-lg",
60
67
  className
@@ -64,9 +71,9 @@ const Expandable = (props) => {
64
71
  /* @__PURE__ */ jsxs(
65
72
  "div",
66
73
  {
67
- className: classnames(
68
- "es-uic-flex es-uic-h-10 es-uic-items-center es-uic-gap-1 es-uic-py-1 es-uic-transition-[padding-inline]",
69
- isOpen && "es-uic-pl-2 es-uic-pr-1"
74
+ className: clsx(
75
+ "es-uic-flex es-uic-h-9 es-uic-items-center es-uic-gap-1 es-uic-transition-[padding]",
76
+ isOpen && "es-uic-py-1 es-uic-pl-2 es-uic-pr-1"
70
77
  ),
71
78
  children: [
72
79
  /* @__PURE__ */ jsx(
@@ -104,8 +111,8 @@ const Expandable = (props) => {
104
111
  },
105
112
  tooltip: isOpen ? __("Close", "eightshift-ui-components") : __("Open", "eightshift-ui-components"),
106
113
  disabled,
107
- className: classnames(
108
- "[&>svg]:es-uic-transition-transform",
114
+ className: clsx(
115
+ "[&>svg]:es-uic-size-5 [&>svg]:es-uic-transition-transform",
109
116
  isOpen && "[&>svg]:-es-uic-scale-y-100"
110
117
  ),
111
118
  size: "small"
@@ -118,7 +125,7 @@ const Expandable = (props) => {
118
125
  AnimatedVisibility,
119
126
  {
120
127
  visible: isOpen,
121
- className: "es-uic-space-y-2.5 es-uic-border-t es-uic-p-2",
128
+ className: clsx("es-uic-space-y-2.5 es-uic-border-t es-uic-p-2", contentClassName),
122
129
  transition: "slideFade",
123
130
  noInitial: true,
124
131
  children
@@ -1,16 +1,16 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { b as $2d73ec29415bd339$export$712718f7aec83d5, $ as $3985021b0ad6602f$export$37fb8590cf2c088c, a as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-jsbb4ugq.js";
3
- import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BPzS-sR7.js";
4
- import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, c as $64fa3d84918910a7$export$4d86445c2cf5e3, d as $3ef42575df84b30b$export$9d1611c77c2fe928, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, h as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, i as $64fa3d84918910a7$export$ef03459518577ad4, j as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-BsiH7-5Y.js";
2
+ import { b as $2d73ec29415bd339$export$712718f7aec83d5, $ as $3985021b0ad6602f$export$37fb8590cf2c088c, a as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-BJA4rmIo.js";
3
+ import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-9x5iLJ-Y.js";
4
+ import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, c as $64fa3d84918910a7$export$4d86445c2cf5e3, d as $3ef42575df84b30b$export$9d1611c77c2fe928, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, h as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, i as $64fa3d84918910a7$export$ef03459518577ad4, j as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-DIBzm1e4.js";
5
5
  import React__default, { forwardRef, createContext, useRef, useState, useCallback } from "react";
6
- import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../focusSafely-C3K8zAKj.js";
7
- import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Cc-4eouh.js";
8
- import { $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-wtMA4667.js";
6
+ import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../focusSafely-B0hyd-S4.js";
7
+ import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-CRx_hYC4.js";
8
+ import { $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-ILxgMZy5.js";
9
9
  import { $ as $d3e0e05bdfcf66bd$export$c24727297075ec6a } from "../../Form-Cq3fu75_.js";
10
- import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-BM136LvS.js";
10
+ import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-Cyxp9ewv.js";
11
11
  import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-DG2RfOUr.js";
12
12
  import { BaseControl } from "../base-control/base-control.js";
13
- import { classnames } from "../../utilities/classnames.js";
13
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
14
14
  const $216918bed6669f72$export$2dc6166a7e65358c = /* @__PURE__ */ createContext({});
15
15
  let $216918bed6669f72$var$filterHoverProps = (props) => {
16
16
  let { onHoverStart, onHoverChange, onHoverEnd, ...otherProps } = props;
@@ -144,6 +144,7 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /* @__PURE__ */ forwardRef($bc
144
144
  * @param {boolean} [props.disabled] - If `true`, the input is disabled.
145
145
  * @param {boolean} [props.readOnly] - If `true`, the input is read-only.
146
146
  * @param {string} [props.className] - Classes to pass to the input field.
147
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
147
148
  *
148
149
  * @returns {JSX.Element} The InputField component.
149
150
  *
@@ -171,8 +172,12 @@ const InputField = (props) => {
171
172
  disabled,
172
173
  readOnly,
173
174
  className,
175
+ hidden,
174
176
  ...other
175
177
  } = props;
178
+ if (hidden) {
179
+ return null;
180
+ }
176
181
  return /* @__PURE__ */ jsx(
177
182
  $bcdf0525bf22703d$export$2c73285ae9390cec,
178
183
  {
@@ -195,7 +200,7 @@ const InputField = (props) => {
195
200
  $3985021b0ad6602f$export$f5b8910cec6cf069,
196
201
  {
197
202
  ...other,
198
- className: classnames(
203
+ className: clsx(
199
204
  "es-uic-min-h-10 es-uic-w-full es-uic-rounded-md es-uic-border es-uic-border-gray-300 es-uic-p-2 es-uic-text-sm es-uic-shadow-sm es-uic-transition selection:es-uic-bg-teal-500/20 selection:es-uic-text-teal-950",
200
205
  "focus:es-uic-outline-none focus-visible:es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
201
206
  className
@@ -206,7 +211,7 @@ const InputField = (props) => {
206
211
  $216918bed6669f72$export$f5c9f3c2c4054eec,
207
212
  {
208
213
  ...other,
209
- className: classnames(
214
+ className: clsx(
210
215
  "es-uic-min-h-10 es-uic-w-full es-uic-rounded-md es-uic-border es-uic-border-gray-300 es-uic-p-2 es-uic-text-sm es-uic-shadow-sm es-uic-transition selection:es-uic-bg-teal-500/20 selection:es-uic-text-teal-950",
211
216
  "focus:es-uic-outline-none focus-visible:es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
212
217
  className
@@ -0,0 +1,40 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
3
+ /**
4
+ * Allows for stacking elements horizontally, with a gap between them.
5
+ *
6
+ * @component
7
+ * @param {Object} props - Component props.
8
+ * @param {boolean} [props.noWrap] - If `true`, the children will not wrap if their size exceeds the container size.
9
+ * @param {string} [props.className] - Classes to pass to the component.
10
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
11
+ *
12
+ * @returns {JSX.Element} The HStack component.
13
+ *
14
+ * @example
15
+ * <HStack>
16
+ * ...
17
+ * </HStack>
18
+ *
19
+ * @preserve
20
+ */
21
+ const HStack = (props) => {
22
+ const { children, noWrap, className, hidden } = props;
23
+ if (hidden) {
24
+ return null;
25
+ }
26
+ return /* @__PURE__ */ jsx(
27
+ "div",
28
+ {
29
+ className: clsx(
30
+ "es-uic-flex es-uic-items-center es-uic-gap-x-1.5 es-uic-gap-y-2",
31
+ !noWrap && "es-uic-flex-wrap",
32
+ className
33
+ ),
34
+ children
35
+ }
36
+ );
37
+ };
38
+ export {
39
+ HStack
40
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
3
+ /**
4
+ * Allows for stacking elements vertically, with a gap between them.
5
+ *
6
+ * @component
7
+ * @param {Object} props - Component props.
8
+ * @param {boolean} [props.noWrap] - If `true`, the children will not wrap if their size exceeds the container size.
9
+ * @param {string} [props.className] - Classes to pass to the component.
10
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
11
+ *
12
+ * @returns {JSX.Element} The VStack component.
13
+ *
14
+ * @example
15
+ * <VStack>
16
+ * ...
17
+ * </VStack>
18
+ *
19
+ * @preserve
20
+ */
21
+ const VStack = (props) => {
22
+ const { children, noWrap, className, hidden } = props;
23
+ if (hidden) {
24
+ return null;
25
+ }
26
+ return /* @__PURE__ */ jsx(
27
+ "div",
28
+ {
29
+ className: clsx(
30
+ "es-uic-flex es-uic-flex-col es-uic-gap-x-1.5 es-uic-gap-y-1.5",
31
+ !noWrap && "es-uic-flex-wrap",
32
+ className
33
+ ),
34
+ children
35
+ }
36
+ );
37
+ };
38
+ export {
39
+ VStack
40
+ };