@eightshift/ui-components 0.0.1

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 (112) hide show
  1. package/README.md +27 -0
  2. package/dist/Checkbox-BLcVbhiO.js +178 -0
  3. package/dist/ColorSwatch-Cmlex_kT.js +66 -0
  4. package/dist/FieldError-wtMA4667.js +42 -0
  5. package/dist/FocusScope-1u9yyfIN.js +725 -0
  6. package/dist/Form-Cq3fu75_.js +5 -0
  7. package/dist/GridList-BZPXp3_O.js +1256 -0
  8. package/dist/Group-DyqpTRPe.js +49 -0
  9. package/dist/Input-jsbb4ugq.js +130 -0
  10. package/dist/Label-BPzS-sR7.js +17 -0
  11. package/dist/ListBox-w9gDaJkV.js +4423 -0
  12. package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
  13. package/dist/NumberFormatter-LzoKy975.js +160 -0
  14. package/dist/RSPContexts-CrNYmadY.js +14 -0
  15. package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
  16. package/dist/SelectionManager-mefd0ThJ.js +2155 -0
  17. package/dist/Separator-DHn0CwdK.js +325 -0
  18. package/dist/Slider-Pyh2V4bY.js +885 -0
  19. package/dist/Text-BM136LvS.js +17 -0
  20. package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
  21. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  22. package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
  23. package/dist/assets/style.css +1 -0
  24. package/dist/button-BkkdyHfJ.js +307 -0
  25. package/dist/components/animated-visibility/animated-visibility.js +7165 -0
  26. package/dist/components/base-control/base-control.js +97 -0
  27. package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
  28. package/dist/components/button/button.js +10 -0
  29. package/dist/components/checkbox/checkbox.js +119 -0
  30. package/dist/components/color-pickers/color-picker.js +242 -0
  31. package/dist/components/color-pickers/color-swatch.js +62 -0
  32. package/dist/components/color-pickers/gradient-editor.js +516 -0
  33. package/dist/components/color-pickers/solid-color-picker.js +1633 -0
  34. package/dist/components/component-toggle/component-toggle.js +71 -0
  35. package/dist/components/container-panel/container-panel.js +39 -0
  36. package/dist/components/expandable/expandable.js +144 -0
  37. package/dist/components/input-field/input-field.js +224 -0
  38. package/dist/components/link-input/link-input.js +937 -0
  39. package/dist/components/list-box/list-box.js +152 -0
  40. package/dist/components/matrix-align/matrix-align.js +185 -0
  41. package/dist/components/menu/menu.js +1608 -0
  42. package/dist/components/notice/notice.js +119 -0
  43. package/dist/components/number-picker/number-picker.js +277 -0
  44. package/dist/components/popover/popover.js +9 -0
  45. package/dist/components/radio/radio.js +552 -0
  46. package/dist/components/repeater/repeater-item.js +127 -0
  47. package/dist/components/repeater/repeater.js +248 -0
  48. package/dist/components/responsive/responsive-legacy.js +326 -0
  49. package/dist/components/responsive/responsive.js +499 -0
  50. package/dist/components/responsive-preview/responsive-preview.js +119 -0
  51. package/dist/components/rich-label/rich-label.js +56 -0
  52. package/dist/components/select/async-multi-select.js +144 -0
  53. package/dist/components/select/async-single-select.js +126 -0
  54. package/dist/components/select/custom-select-default-components.js +38 -0
  55. package/dist/components/select/multi-select-components.js +8 -0
  56. package/dist/components/select/multi-select.js +134 -0
  57. package/dist/components/select/react-select-component-wrappers.js +90 -0
  58. package/dist/components/select/shared.js +45 -0
  59. package/dist/components/select/single-select.js +116 -0
  60. package/dist/components/select/styles.js +55 -0
  61. package/dist/components/slider/column-config-slider.js +225 -0
  62. package/dist/components/slider/slider.js +362 -0
  63. package/dist/components/slider/utils.js +45 -0
  64. package/dist/components/spacer/spacer.js +93 -0
  65. package/dist/components/tabs/tabs.js +626 -0
  66. package/dist/components/toggle/switch.js +140 -0
  67. package/dist/components/toggle/toggle.js +58 -0
  68. package/dist/components/toggle-button/toggle-button.js +206 -0
  69. package/dist/components/tooltip/tooltip.js +10 -0
  70. package/dist/context-jMy6xdVq.js +98 -0
  71. package/dist/default-i18n-BhE-OUmt.js +873 -0
  72. package/dist/filterDOMProps-DG2RfOUr.js +30 -0
  73. package/dist/focusSafely-C3K8zAKj.js +743 -0
  74. package/dist/hooks/use-cell-edit-mode.js +35 -0
  75. package/dist/icons/block-icon.js +42 -0
  76. package/dist/icons/generic-color-swatch.js +21 -0
  77. package/dist/icons/icons.js +3636 -0
  78. package/dist/index-Bfb9bWcb.js +28844 -0
  79. package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
  80. package/dist/index.js +109 -0
  81. package/dist/intlStrings-CUhoK9EN.js +2484 -0
  82. package/dist/isScrollable-PcyglExV.js +10 -0
  83. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  84. package/dist/multi-select-components-CjVpCNko.js +3677 -0
  85. package/dist/number-rWqELA8W.js +39 -0
  86. package/dist/popover-Dx3vKXUX.js +1061 -0
  87. package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
  88. package/dist/react-select.esm-BjRWqf0E.js +15 -0
  89. package/dist/style.js +1 -0
  90. package/dist/textSelection-BosCCRVE.js +89 -0
  91. package/dist/tooltip-CkCndvTI.js +1094 -0
  92. package/dist/useButton-CuG5UzUw.js +74 -0
  93. package/dist/useEvent-DHv-yhOH.js +24 -0
  94. package/dist/useFocusRing-Cc-4eouh.js +41 -0
  95. package/dist/useFocusable-5q1Gek1J.js +81 -0
  96. package/dist/useFormReset-Buc9YJcv.js +23 -0
  97. package/dist/useFormValidationState-BAPPNXic.js +238 -0
  98. package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
  99. package/dist/useLabel-CGlkoFG0.js +28 -0
  100. package/dist/useLabels-Dg62M_3P.js +25 -0
  101. package/dist/useListData-BelKu4kx.js +211 -0
  102. package/dist/useListState-Domq0blV.js +137 -0
  103. package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
  104. package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
  105. package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
  106. package/dist/usePress-BQgVor4T.js +698 -0
  107. package/dist/useToggle-C9ETOBaZ.js +58 -0
  108. package/dist/useToggleState-DJ_z5E2S.js +21 -0
  109. package/dist/utilities/classnames.js +16 -0
  110. package/dist/utilities/text-helpers.js +79 -0
  111. package/dist/utils-BsiH7-5Y.js +488 -0
  112. package/package.json +71 -0
@@ -0,0 +1,97 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { $ as $514c0188e459b4c0$export$5f1af8db9871e1d6 } from "../../Text-BM136LvS.js";
3
+ import { classnames } from "../../utilities/classnames.js";
4
+ import { RichLabel } from "../rich-label/rich-label.js";
5
+ /**
6
+ * Component that allows wrapping components with a common layout that includes a label and optional icon, subtitle, actions, and help text.
7
+ *
8
+ * @component
9
+ * @param {Object} props - Component props.
10
+ * @param {JSX.Element} [props.icon] - Icon to display in the label.
11
+ * @param {string} props.label - Label to display.
12
+ * @param {string} props.subtitle - Subtitle to display below the label.
13
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
14
+ * @param {string} [props.help] - Help text to show below the component.
15
+ * @param {boolean} [props.inline] - If `true`, the component is displayed inline - icon/label/subtitle are on the left, the passed content is on the right. **Note:** not compatible with `actions`.
16
+ * @param {string} [props.className] - Classes to pass to the main element wrapper.
17
+ * @param {string} [props.controlContainerClassName] - Classes to pass to the control container.
18
+ * @param {boolean} [props.fullWidthLabel] - If `true`, the label expands to fill up the whole width, instead of taking up only the space it needs.
19
+ * @param {JSX.Element} [props.labelAs] - If provided, the label (includes icon and subtitle) will be rendered as this element.
20
+ *
21
+ * @returns {JSX.Element} The BaseControl component.
22
+ *
23
+ * @example
24
+ * <BaseControl label='My component' icon={icons.myIcon}>
25
+ * <div>Content</div>
26
+ * </BaseControl>
27
+ *
28
+ * @preserve
29
+ */
30
+ const BaseControl = (props) => {
31
+ const {
32
+ icon,
33
+ label,
34
+ subtitle,
35
+ actions,
36
+ help,
37
+ children,
38
+ inline,
39
+ className,
40
+ controlContainerClassName,
41
+ fullWidthLabel,
42
+ labelAs
43
+ } = props;
44
+ if (!children) {
45
+ return null;
46
+ }
47
+ if (!(label || icon || subtitle)) {
48
+ return children;
49
+ }
50
+ return /* @__PURE__ */ jsxs("div", { className: classnames("es-uic-space-y-1", className), children: [
51
+ /* @__PURE__ */ jsxs(
52
+ "div",
53
+ {
54
+ className: classnames(
55
+ "es-uic-flex es-uic-items-center es-uic-gap-1",
56
+ !inline && !icon && "es-uic-pb-0.5"
57
+ ),
58
+ children: [
59
+ (label || icon || subtitle) && /* @__PURE__ */ jsx(
60
+ RichLabel,
61
+ {
62
+ icon,
63
+ label,
64
+ subtitle,
65
+ fullWidth: fullWidthLabel,
66
+ as: labelAs
67
+ }
68
+ ),
69
+ inline && /* @__PURE__ */ jsx(
70
+ "div",
71
+ {
72
+ className: classnames(
73
+ "es-uic-ml-auto es-uic-flex es-uic-items-center es-uic-gap-1",
74
+ controlContainerClassName
75
+ ),
76
+ children
77
+ }
78
+ ),
79
+ !inline && actions && /* @__PURE__ */ jsx("div", { className: classnames("es-uic-flex es-uic-items-center es-uic-gap-1", !inline && "es-uic-ml-auto"), children: actions })
80
+ ]
81
+ }
82
+ ),
83
+ !inline && Array.isArray(children) && children.filter(Boolean).length > 1 && /* @__PURE__ */ jsx("div", { className: classnames("es-uic-space-y-1", controlContainerClassName), children }),
84
+ !inline && (!Array.isArray(children) || children.filter(Boolean).length < 2) && children,
85
+ help && /* @__PURE__ */ jsx(
86
+ $514c0188e459b4c0$export$5f1af8db9871e1d6,
87
+ {
88
+ className: "es-uic-text-sm es-uic-text-gray-400",
89
+ slot: "description",
90
+ children: help
91
+ }
92
+ )
93
+ ] });
94
+ };
95
+ export {
96
+ BaseControl
97
+ };
@@ -0,0 +1,218 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { Fragment as Fragment$1 } from "react";
3
+ import { classnames } from "../../utilities/classnames.js";
4
+ import { upperFirst } from "../../utilities/text-helpers.js";
5
+ /**
6
+ * Component that renders a preview of the breakpoints to help users visualize the options they set.
7
+ *
8
+ * @component
9
+ * @param {Object} props - Component props.
10
+ * @param {Object[]} [props.blocks] - Blocks to display.
11
+ * @param {string} [props.blocks[].width] - Current breakpoint width. Left-aligned with the block.
12
+ * @param {string} [props.blocks[].widthEnd] - Current breakpoint width. Right-aligned with the block.
13
+ * @param {string} [props.blocks[].breakpoint] - Breakpoint name.
14
+ * @param {string} [props.blocks[].value] - Current value at the breakpoint.
15
+ * @param {boolean} [props.blocks[].dotsStart=false] - If `true`, dots are displayed at the start of the block.
16
+ * @param {boolean} [props.blocks[].dotsEnd=false] - If `true`, dots are displayed at the end of the block.
17
+ * @param {boolean} [props.blocks[].active=false] - If `true`, the block is active.
18
+ * @param {boolean} [props.blocks[].alignEnd=false] - If `true`, the block is aligned to the end.
19
+ * @param {BreakpointColor} [props.blocks[].color] - Color of the block.
20
+ * @param {boolean} [props.dotsStart=false] - If `true`, dots are displayed at the start of the preview.
21
+ * @param {boolean} [props.dotsEnd=false] - If `true`, dots are displayed at the end of the preview.
22
+ * *
23
+ * @returns {JSX.Element} The BreakpointPreview component.
24
+ *
25
+ * @typedef {'blue' | 'green' | 'yellow' | 'red' | 'indigo' | 'orange' | 'cyan' | 'teal' | 'fuchsia' | 'black' | 'default'} BreakpointColor
26
+ *
27
+ * @example
28
+ * <BreakpointPreview
29
+ * blocks={[
30
+ * {
31
+ * breakpoint: 'Mobile',
32
+ * widthEnd: '480px',
33
+ * value: 'Regular',
34
+ * dotsStart: true,
35
+ * alignEnd: true,
36
+ * active: true,
37
+ * },
38
+ * {
39
+ * breakpoint: 'Default',
40
+ * value: 'Small',
41
+ * dotsEnd: true,
42
+ * },
43
+ * ]}
44
+ * />
45
+ *
46
+ * @preserve
47
+ */
48
+ const BreakpointPreview = (props) => {
49
+ const { blocks: rawBlocks, dotsStart = false, dotsEnd = false } = props;
50
+ const blocks = rawBlocks.filter(Boolean);
51
+ if (!blocks || blocks.length < 1) {
52
+ return null;
53
+ }
54
+ const hasActive = (blocks == null ? void 0 : blocks.some(({ active }) => active)) ?? false;
55
+ const activeColors = {
56
+ blue: {
57
+ text: "es-uic-text-blue-500",
58
+ bg: "es-uic-bg-blue-500"
59
+ },
60
+ green: {
61
+ text: "es-uic-text-lime-500",
62
+ bg: "es-uic-bg-lime-500"
63
+ },
64
+ yellow: {
65
+ text: "es-uic-text-yellow-400",
66
+ bg: "es-uic-bg-yellow-400"
67
+ },
68
+ red: {
69
+ text: "es-uic-text-red-500",
70
+ bg: "es-uic-bg-red-500"
71
+ },
72
+ indigo: {
73
+ text: "es-uic-text-indigo-500",
74
+ bg: "es-uic-bg-indigo-500"
75
+ },
76
+ orange: {
77
+ text: "es-uic-text-orange-500",
78
+ bg: "es-uic-bg-orange-500"
79
+ },
80
+ cyan: {
81
+ text: "es-uic-text-cyan-500",
82
+ bg: "es-uic-bg-cyan-500"
83
+ },
84
+ teal: {
85
+ text: "es-uic-text-teal-500",
86
+ bg: "es-uic-bg-teal-500"
87
+ },
88
+ fuchsia: {
89
+ text: "es-uic-text-fuchsia-500",
90
+ bg: "es-uic-bg-fuchsia-500"
91
+ },
92
+ black: {
93
+ text: "es-uic-text-black",
94
+ bg: "es-uic-bg-black"
95
+ },
96
+ default: {
97
+ text: "es-uic-text-slate-600",
98
+ bg: "es-uic-bg-slate-600"
99
+ }
100
+ };
101
+ return /* @__PURE__ */ jsxs(
102
+ "div",
103
+ {
104
+ className: classnames(
105
+ "es-uic-grid es-uic-w-fit es-uic-mx-auto es-uic-shrink-0 es-uic-auto-cols-auto es-uic-grid-rows-[auto,_auto] es-uic-gap-x-2 es-uic-gap-y-0.5"
106
+ ),
107
+ children: [
108
+ dotsStart && /* @__PURE__ */ jsxs(Fragment, { children: [
109
+ /* @__PURE__ */ jsx("div", { className: "es-uic-row-start-1 es-uic-flex es-uic-shrink-0 es-uic-translate-x-1 es-uic-items-center es-uic-gap-1 es-uic-text-gray-400 es-uic-justify-self-end", children: /* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-gap-0.5 es-uic-text-gray-300", children: [
110
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
111
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
112
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" })
113
+ ] }) }),
114
+ /* @__PURE__ */ jsx("div", { className: "es-uic-row-start-2 es-uic-size-px es-uic-justify-self-end" })
115
+ ] }),
116
+ blocks.map(
117
+ ({
118
+ width,
119
+ widthEnd,
120
+ breakpoint,
121
+ value,
122
+ dotsStart: dotsStart2 = false,
123
+ dotsEnd: dotsEnd2 = false,
124
+ active = false,
125
+ alignEnd = false,
126
+ color
127
+ }, i) => {
128
+ var _a, _b;
129
+ const activeTextColor = ((_a = activeColors == null ? void 0 : activeColors[color]) == null ? void 0 : _a.text) ?? activeColors.default.text;
130
+ const activeBgColor = ((_b = activeColors == null ? void 0 : activeColors[color]) == null ? void 0 : _b.bg) ?? activeColors.default.bg;
131
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
132
+ /* @__PURE__ */ jsxs("div", { className: "es-uic-row-start-1 es-uic-flex es-uic-min-w-28 es-uic-items-center es-uic-gap-1 es-uic-font-mono es-uic-font-medium es-uic-text-gray-400", children: [
133
+ dotsStart2 && /* @__PURE__ */ jsxs(
134
+ "div",
135
+ {
136
+ className: classnames(
137
+ "es-uic-flex es-uic-gap-0.5",
138
+ active ? activeTextColor : "text-gray-300"
139
+ ),
140
+ children: [
141
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
142
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
143
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" })
144
+ ]
145
+ }
146
+ ),
147
+ width && /* @__PURE__ */ jsx("span", { children: width }),
148
+ /* @__PURE__ */ jsx(
149
+ "div",
150
+ {
151
+ className: classnames(
152
+ "es-uic-grow es-uic-rounded",
153
+ active ? "es-uic-h-0.5" : "es-uic-h-px es-uic-bg-gray-300",
154
+ active && activeBgColor
155
+ )
156
+ }
157
+ ),
158
+ widthEnd && /* @__PURE__ */ jsx("span", { children: widthEnd }),
159
+ dotsEnd2 && /* @__PURE__ */ jsxs(
160
+ "div",
161
+ {
162
+ className: classnames(
163
+ "es-uic-flex es-uic-gap-0.5",
164
+ active ? activeTextColor : "es-uic-text-gray-300"
165
+ ),
166
+ children: [
167
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
168
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
169
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" })
170
+ ]
171
+ }
172
+ )
173
+ ] }),
174
+ /* @__PURE__ */ jsxs("div", { className: "es-uic-row-start-2 es-uic-flex es-uic-w-full es-uic-min-w-28 es-uic-flex-col es-uic-items-start es-uic-gap-1", children: [
175
+ /* @__PURE__ */ jsx(
176
+ "span",
177
+ {
178
+ className: classnames(
179
+ "es-uic-rounded es-uic-px-1 es-uic-py-0.5",
180
+ hasActive && active && "es-uic-text-white",
181
+ hasActive && active && activeBgColor,
182
+ hasActive && !active && "es-uic-bg-gray-200 es-uic-text-gray-500",
183
+ !hasActive && "es-uic-bg-gray-600 es-uic-text-white",
184
+ alignEnd && "es-uic-ml-auto"
185
+ ),
186
+ children: upperFirst(breakpoint)
187
+ }
188
+ ),
189
+ value && /* @__PURE__ */ jsx(
190
+ "span",
191
+ {
192
+ className: classnames(
193
+ "-es-uic-mt-0.5 es-uic-px-1",
194
+ active ? "es-uic-text-gray-400" : "es-uic-text-gray-400",
195
+ alignEnd && "es-uic-ml-auto"
196
+ ),
197
+ children: value
198
+ }
199
+ )
200
+ ] })
201
+ ] }, i);
202
+ }
203
+ ),
204
+ dotsEnd && /* @__PURE__ */ jsxs(Fragment, { children: [
205
+ /* @__PURE__ */ jsx("div", { className: "es-uic-row-start-1 es-uic-flex es-uic-shrink-0 -es-uic-translate-x-1 es-uic-items-center es-uic-gap-1 es-uic-font-mono es-uic-font-medium es-uic-text-gray-400", children: /* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-gap-0.5 es-uic-text-gray-300", children: [
206
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
207
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" }),
208
+ /* @__PURE__ */ jsx("div", { className: "es-uic-size-0.5 es-uic-rounded es-uic-bg-current" })
209
+ ] }) }),
210
+ /* @__PURE__ */ jsx("div", { className: "es-uic-row-start-2 es-uic-size-px" })
211
+ ] })
212
+ ]
213
+ }
214
+ );
215
+ };
216
+ export {
217
+ BreakpointPreview
218
+ };
@@ -0,0 +1,10 @@
1
+ import "react/jsx-runtime";
2
+ import { B, a } from "../../button-BkkdyHfJ.js";
3
+ import "../../utilities/classnames.js";
4
+ import "../../tooltip-CkCndvTI.js";
5
+ import "../../default-i18n-BhE-OUmt.js";
6
+ import "../../utils-BsiH7-5Y.js";
7
+ export {
8
+ B as Button,
9
+ a as ButtonGroup
10
+ };
@@ -0,0 +1,119 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { $ as $bc237834342dbd75$export$48513f6b9f8ce62d } from "../../Checkbox-BLcVbhiO.js";
3
+ import { classnames } from "../../utilities/classnames.js";
4
+ import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
5
+ import { icons } from "../../icons/icons.js";
6
+ import { RichLabel } from "../rich-label/rich-label.js";
7
+ /**
8
+ * A simple checkbox.
9
+ *
10
+ * @component
11
+ * @param {Object} props - Component props.
12
+ * @param {JSX.Element} [props.icon] - The checkbox icon.
13
+ * @param {string} [props.label] - The checkbox label.
14
+ * @param {string} [props.subtitle] - The checkbox subtitle.
15
+ * @param {boolean} props.checked - Whether the checkbox is checked.
16
+ * @param {boolean} [props.disabled] - Whether the checkbox is disabled.
17
+ * @param {boolean} [props.readOnly] - Whether the checkbox is read-only.
18
+ * @param {boolean} [props.indeterminate] - Whether the checkbox is in an indeterminate state.
19
+ * @param {Function} props.onChange - The function to call when the checkbox is changed.
20
+ * @param {string} [props.className] - Additional classes to add to the checkbox container.
21
+ * @param {string} [props.labelClassName] - Additional classes to add to the label container.
22
+ * @param {boolean} [props.alignEnd] - Whether the label should be aligned to the end.
23
+ *
24
+ * @returns {JSX.Element} The Checkbox component.
25
+ *
26
+ * @example
27
+ * <Checkbox
28
+ * label='My label'
29
+ * checked={myValue}
30
+ * onChange={(value) => setMyValue(value)}
31
+ * />
32
+ *
33
+ * @preserve
34
+ */
35
+ const Checkbox = (props) => {
36
+ const {
37
+ icon,
38
+ label,
39
+ subtitle,
40
+ checked,
41
+ disabled,
42
+ readOnly,
43
+ indeterminate,
44
+ onChange,
45
+ className,
46
+ labelClassName,
47
+ alignEnd,
48
+ children,
49
+ ...other
50
+ } = props;
51
+ return /* @__PURE__ */ jsx(
52
+ $bc237834342dbd75$export$48513f6b9f8ce62d,
53
+ {
54
+ isDisabled: disabled,
55
+ isIndeterminate: indeterminate,
56
+ isReadOnly: readOnly,
57
+ isSelected: checked ?? false,
58
+ onChange,
59
+ className: classnames(
60
+ "es-uic-flex es-uic-w-full es-uic-items-center es-uic-gap-1.5 es-uic-text-sm",
61
+ className
62
+ ),
63
+ ...other,
64
+ children: ({ isIndeterminate, isSelected }) => /* @__PURE__ */ jsxs(Fragment, { children: [
65
+ (icon || alignEnd) && (label || subtitle) && /* @__PURE__ */ jsx(
66
+ RichLabel,
67
+ {
68
+ icon,
69
+ label,
70
+ subtitle,
71
+ className: labelClassName,
72
+ fullWidth: true
73
+ }
74
+ ),
75
+ /* @__PURE__ */ jsxs(
76
+ "div",
77
+ {
78
+ className: classnames(
79
+ "es-uic-flex es-uic-size-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",
80
+ isSelected ? "es-uic-border-teal-600 es-uic-bg-teal-600 es-uic-text-white" : "es-uic-border-gray-300"
81
+ ),
82
+ children: [
83
+ /* @__PURE__ */ jsx(
84
+ AnimatedVisibility,
85
+ {
86
+ transition: "scaleRotateFade",
87
+ visible: isIndeterminate,
88
+ children: /* @__PURE__ */ jsx("div", { className: "es-uic-h-[1.5px] es-uic-w-3 es-uic-rounded es-uic-bg-white" })
89
+ }
90
+ ),
91
+ /* @__PURE__ */ jsx(
92
+ AnimatedVisibility,
93
+ {
94
+ transition: "scaleRotateFade",
95
+ visible: !isIndeterminate && isSelected,
96
+ className: "[&>svg]:es-uic-size-3 [&>svg]:es-uic-stroke-2",
97
+ noInitial: true,
98
+ children: icons.check
99
+ }
100
+ )
101
+ ]
102
+ }
103
+ ),
104
+ !icon && !alignEnd && (label || subtitle) && /* @__PURE__ */ jsx(
105
+ RichLabel,
106
+ {
107
+ label,
108
+ subtitle,
109
+ className: labelClassName
110
+ }
111
+ ),
112
+ !(icon || label || subtitle) && children
113
+ ] })
114
+ }
115
+ );
116
+ };
117
+ export {
118
+ Checkbox
119
+ };
@@ -0,0 +1,242 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
3
+ import { Menu, MenuSection, MenuItem } from "../menu/menu.js";
4
+ import { ColorSwatch } from "./color-swatch.js";
5
+ import { RichLabel } from "../rich-label/rich-label.js";
6
+ import { BaseControl } from "../base-control/base-control.js";
7
+ import { classnames } from "../../utilities/classnames.js";
8
+ import { icons } from "../../icons/icons.js";
9
+ /**
10
+ * Color picker.
11
+ *
12
+ * @component
13
+ * @param {Object} props - Component props.
14
+ * @param {string} [props.icon] - Icon to display.
15
+ * @param {string} [props.label] - Label to display.
16
+ * @param {string} [props.subtitle] - Subtitle to display.
17
+ * @param {string} [props.labelClassName] - Additional classnames passed to the label.
18
+ * @param {string} props.value - Selected value.
19
+ * @param {Function} props.onChange - Function to run when the value changes.
20
+ * @param {Object[]} props.colors - Colors to display.
21
+ * @param {string} props.colors[].name - Color name.
22
+ * @param {string} props.colors[].slug - Color slug.
23
+ * @param {string} props.colors[].color - Color value (HEX, RGB, HSL, HSB).
24
+ * @param {boolean} [props.showColorCode] - If `true`, the HEX color code is shown below the color name.
25
+ * @param {boolean} [props.noColorGroups] - If `true`, colors won't be grouped by shades.
26
+ * @param {ColorPickerType} props.type - Type of the color picker. Affects the icon and tooltip.
27
+ * @param {boolean} [props.clearable] - If `true`, the color can be deselected.
28
+ *
29
+ * @returns {JSX.Element} The ColorPicker component.
30
+ *
31
+ * @typedef {'default' | 'fillColor' | 'textColor' | 'textHighlightColor'} ColorPickerType
32
+ *
33
+ * @example
34
+ * <ColorPicker
35
+ * icon={icons.fillColor}
36
+ * label={__('Fill color', 'eightshift-ui-components')}
37
+ * subtitle={__('Select fill color', 'eightshift-ui-components')}
38
+ * value={fillColor}
39
+ * onChange={(value) => setAttributes({ fillColor: value })}
40
+ * colors={[
41
+ * { name: 'Red', slug: 'red', color: '#ff0000' },
42
+ * { name: 'Green', slug: 'green', color: '#00ff00' },
43
+ * { name: 'Blue', slug: 'blue', color: '#0000ff' },
44
+ * ]}
45
+ * />
46
+ *
47
+ * @preserve
48
+ */
49
+ const ColorPicker = (props) => {
50
+ var _a;
51
+ const {
52
+ icon,
53
+ label,
54
+ subtitle,
55
+ labelClassName,
56
+ value,
57
+ onChange,
58
+ colors,
59
+ showColorCode,
60
+ noColorGroups,
61
+ type = "default",
62
+ clearable,
63
+ ...rest
64
+ } = props;
65
+ const currentColor = (_a = colors == null ? void 0 : colors.find(({ slug }) => slug === value)) == null ? void 0 : _a.color;
66
+ const colorSuffixRegex = /(?!^.+)(-?(?:50|100|200|300|400|500|600|700|800|900|950|10|20|30|40|50|60|70|80|90){1})$/gi;
67
+ const hasColorGroups = !noColorGroups && (colors == null ? void 0 : colors.some(({ slug }) => colorSuffixRegex.test(slug)));
68
+ let groupedColors;
69
+ const colorGroupNames = {
70
+ generic: __("Other colors", "eightshift-ui-components")
71
+ };
72
+ if (hasColorGroups) {
73
+ groupedColors = colors.reduce(
74
+ (output, current) => {
75
+ var _a2;
76
+ if (current === void 0 || (current == null ? void 0 : current.name) === void 0 || (current == null ? void 0 : current.slug) === void 0) {
77
+ return output;
78
+ }
79
+ if ((_a2 = current.slug.match(colorSuffixRegex)) == null ? void 0 : _a2.length) {
80
+ const newSlug = current.slug.replace(colorSuffixRegex, "").trim();
81
+ if (!output[newSlug]) {
82
+ output[newSlug] = [];
83
+ colorGroupNames[newSlug] = current.name.replace(colorSuffixRegex, "").trim();
84
+ }
85
+ output[newSlug] = [
86
+ ...output[newSlug],
87
+ {
88
+ ...current,
89
+ shade: current.slug.match(colorSuffixRegex)[0].replace("-", "")
90
+ }
91
+ ];
92
+ } else {
93
+ output.generic = [...output.generic, current];
94
+ }
95
+ return output;
96
+ },
97
+ { generic: [] }
98
+ );
99
+ }
100
+ const SingleItem = ({ name, slug, color, ...rest2 }) => /* @__PURE__ */ jsxs(
101
+ MenuItem,
102
+ {
103
+ ...rest2,
104
+ endIcon: /* @__PURE__ */ jsx(
105
+ ColorSwatch,
106
+ {
107
+ className: "!es-uic-size-5.5",
108
+ color
109
+ }
110
+ ),
111
+ onClick: () => {
112
+ if (clearable && value === slug) {
113
+ onChange(void 0);
114
+ return;
115
+ }
116
+ onChange(slug);
117
+ },
118
+ checked: clearable ? value === slug : null,
119
+ selected: !clearable ? value === slug : null,
120
+ children: [
121
+ !showColorCode && name,
122
+ showColorCode && /* @__PURE__ */ jsx(
123
+ RichLabel,
124
+ {
125
+ label: name,
126
+ subtitle: color.toUpperCase()
127
+ }
128
+ )
129
+ ]
130
+ }
131
+ );
132
+ let tooltipText;
133
+ if (!label && type === "default") {
134
+ tooltipText = __("Color", "eightshift-ui-components");
135
+ } else if (!label && type === "fillColor") {
136
+ tooltipText = __("Fill color", "eightshift-ui-components");
137
+ } else if (!label && type === "textColor") {
138
+ tooltipText = __("Text color", "eightshift-ui-components");
139
+ } else if (!label && type === "textHighlightColor") {
140
+ tooltipText = __("Text highlight color", "eightshift-ui-components");
141
+ }
142
+ return /* @__PURE__ */ jsx(
143
+ BaseControl,
144
+ {
145
+ icon,
146
+ label,
147
+ subtitle,
148
+ className: classnames("es-uic-w-full", labelClassName),
149
+ inline: true,
150
+ children: /* @__PURE__ */ jsxs(
151
+ Menu,
152
+ {
153
+ triggerIcon: /* @__PURE__ */ jsxs(Fragment, { children: [
154
+ (type === "default" || icon) && /* @__PURE__ */ jsx(
155
+ ColorSwatch,
156
+ {
157
+ color: currentColor,
158
+ className: "!es-uic-size-6 !es-uic-shadow-none"
159
+ }
160
+ ),
161
+ !icon && type === "fillColor" && /* @__PURE__ */ jsxs("div", { className: "es-uic-relative es-uic-size-6 [&>svg]:es-uic-absolute [&>svg]:-es-uic-top-0.5 [&>svg]:es-uic-left-0.5 [&>svg]:es-uic-size-[1.125rem]", children: [
162
+ icons.fillColor,
163
+ /* @__PURE__ */ jsx(
164
+ ColorSwatch,
165
+ {
166
+ color: currentColor,
167
+ className: "es-uic-absolute -es-uic-bottom-0.5 es-uic-left-0 !es-uic-h-2 !es-uic-shadow-none"
168
+ }
169
+ )
170
+ ] }),
171
+ !icon && type === "textColor" && /* @__PURE__ */ jsxs("div", { className: "es-uic-relative es-uic-size-6 [&>svg]:es-uic-absolute [&>svg]:-es-uic-top-[0.25rem] [&>svg]:es-uic-left-0 [&>svg]:es-uic-size-6", children: [
172
+ icons.textAbc,
173
+ /* @__PURE__ */ jsx(
174
+ ColorSwatch,
175
+ {
176
+ color: currentColor,
177
+ className: "es-uic-absolute -es-uic-bottom-0.5 es-uic-left-0 !es-uic-h-2 !es-uic-shadow-none"
178
+ }
179
+ )
180
+ ] }),
181
+ !icon && type === "textHighlightColor" && /* @__PURE__ */ jsxs("div", { className: "es-uic-relative es-uic-size-6 [&>svg]:es-uic-absolute [&>svg]:-es-uic-top-[0.325rem] [&>svg]:es-uic-left-0 [&>svg]:es-uic-size-6", children: [
182
+ icons.titleGeneric,
183
+ /* @__PURE__ */ jsx(
184
+ ColorSwatch,
185
+ {
186
+ color: currentColor,
187
+ className: "es-uic-absolute -es-uic-bottom-0.5 es-uic-left-0 !es-uic-h-2 !es-uic-shadow-none"
188
+ }
189
+ )
190
+ ] })
191
+ ] }),
192
+ keepOpen: true,
193
+ triggerProps: {
194
+ tooltip: tooltipText,
195
+ ...rest.triggerProps
196
+ },
197
+ ...rest,
198
+ children: [
199
+ (noColorGroups || !hasColorGroups) && colors.map((color) => /* @__PURE__ */ jsx(
200
+ SingleItem,
201
+ {
202
+ ...color
203
+ },
204
+ color.slug
205
+ )),
206
+ hasColorGroups && /* @__PURE__ */ jsxs(Fragment, { children: [
207
+ Object.entries(groupedColors).map(([groupSlug, colors2]) => {
208
+ if (groupSlug === "generic") {
209
+ return null;
210
+ }
211
+ return /* @__PURE__ */ jsx(
212
+ MenuSection,
213
+ {
214
+ label: colorGroupNames[groupSlug],
215
+ children: colors2.map((color) => /* @__PURE__ */ jsx(
216
+ SingleItem,
217
+ {
218
+ ...color
219
+ },
220
+ color.slug
221
+ ))
222
+ },
223
+ groupSlug
224
+ );
225
+ }),
226
+ groupedColors.generic.length > 0 && /* @__PURE__ */ jsx(MenuSection, { "aria-label": colorGroupNames.generic, children: groupedColors.generic.map((color) => /* @__PURE__ */ jsx(
227
+ SingleItem,
228
+ {
229
+ ...color
230
+ },
231
+ color.slug
232
+ )) })
233
+ ] })
234
+ ]
235
+ }
236
+ )
237
+ }
238
+ );
239
+ };
240
+ export {
241
+ ColorPicker
242
+ };