@eightshift/ui-components 5.0.0 → 5.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 (144) hide show
  1. package/dist/Button-wERNNG0T.js +185 -0
  2. package/dist/Collection-CKsHTyhc.js +2363 -0
  3. package/dist/Color-BhgbJF5x.js +2452 -0
  4. package/dist/ColorSwatch-Bcn6oRSg.js +64 -0
  5. package/dist/ComboBox-D1LPUwWP.js +1906 -0
  6. package/dist/Dialog-D190gMbE.js +2298 -0
  7. package/dist/FieldError-DeUh5Wkw.js +42 -0
  8. package/dist/FocusScope-C-plSxbS.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-C5iZpSAM.js +48 -0
  11. package/dist/Heading-D-Pboe4p.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input--mF4XVE1.js +133 -0
  14. package/dist/Label-Fp6AwSRn.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-4oW9kh3R.js +582 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-BpB9uB_I.js +637 -0
  19. package/dist/RSPContexts-2lR5GG9p.js +14 -0
  20. package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
  21. package/dist/Separator-B88tj5YD.js +323 -0
  22. package/dist/Slider-CyJzC1bp.js +853 -0
  23. package/dist/Text-DRpwWot2.js +16 -0
  24. package/dist/VisuallyHidden-DsKYcRQ_.js +48 -0
  25. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  26. package/dist/assets/index.css +57 -0
  27. package/dist/assets/style-admin.css +5864 -0
  28. package/dist/assets/style-editor.css +5864 -0
  29. package/dist/assets/style.css +5870 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +377 -0
  32. package/dist/components/animated-visibility/animated-visibility.js +105 -0
  33. package/dist/components/base-control/base-control.js +86 -0
  34. package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
  35. package/dist/components/button/button.js +387 -0
  36. package/dist/components/checkbox/checkbox.js +320 -0
  37. package/dist/components/color-pickers/color-picker.js +272 -0
  38. package/dist/components/color-pickers/color-swatch.js +59 -0
  39. package/dist/components/color-pickers/gradient-editor.js +534 -0
  40. package/dist/components/color-pickers/solid-color-picker.js +1567 -0
  41. package/dist/components/component-toggle/component-toggle.js +161 -0
  42. package/dist/components/container-panel/container-panel.js +131 -0
  43. package/dist/components/draggable/draggable-context.js +5 -0
  44. package/dist/components/draggable/draggable-handle.js +46 -0
  45. package/dist/components/draggable/draggable.js +6979 -0
  46. package/dist/components/draggable-list/draggable-list-context.js +5 -0
  47. package/dist/components/draggable-list/draggable-list-item.js +77 -0
  48. package/dist/components/draggable-list/draggable-list.js +151 -0
  49. package/dist/components/expandable/expandable.js +342 -0
  50. package/dist/components/index.js +137 -0
  51. package/dist/components/input-field/input-field.js +231 -0
  52. package/dist/components/item-collection/item-collection.js +59 -0
  53. package/dist/components/layout/hstack.js +30 -0
  54. package/dist/components/layout/vstack.js +30 -0
  55. package/dist/components/link-input/link-input.js +291 -0
  56. package/dist/components/matrix-align/matrix-align.js +134 -0
  57. package/dist/components/menu/menu.js +285 -0
  58. package/dist/components/modal/modal.js +305 -0
  59. package/dist/components/notice/notice.js +123 -0
  60. package/dist/components/number-picker/number-picker.js +292 -0
  61. package/dist/components/option-select/option-select.js +264 -0
  62. package/dist/components/options-panel/options-panel.js +158 -0
  63. package/dist/components/placeholders/file-placeholder.js +42 -0
  64. package/dist/components/placeholders/image-placeholder.js +88 -0
  65. package/dist/components/placeholders/media-placeholder.js +63 -0
  66. package/dist/components/popover/popover.js +207 -0
  67. package/dist/components/radio/radio.js +579 -0
  68. package/dist/components/repeater/repeater-context.js +5 -0
  69. package/dist/components/repeater/repeater-item.js +119 -0
  70. package/dist/components/repeater/repeater.js +280 -0
  71. package/dist/components/responsive/mini-responsive.js +498 -0
  72. package/dist/components/responsive/responsive-legacy.js +343 -0
  73. package/dist/components/responsive/responsive.js +583 -0
  74. package/dist/components/responsive-preview/responsive-preview.js +123 -0
  75. package/dist/components/rich-label/rich-label.js +66 -0
  76. package/dist/components/select/async-multi-select.js +157 -0
  77. package/dist/components/select/async-single-select.js +137 -0
  78. package/dist/components/select/custom-select-default-components.js +38 -0
  79. package/dist/components/select/multi-select-components.js +8 -0
  80. package/dist/components/select/multi-select.js +151 -0
  81. package/dist/components/select/react-select-component-wrappers.js +90 -0
  82. package/dist/components/select/shared.js +26 -0
  83. package/dist/components/select/single-select.js +131 -0
  84. package/dist/components/select/styles.js +49 -0
  85. package/dist/components/select/v2/async-select.js +297 -0
  86. package/dist/components/select/v2/shared.js +24 -0
  87. package/dist/components/select/v2/single-select.js +991 -0
  88. package/dist/components/slider/column-config-slider.js +210 -0
  89. package/dist/components/slider/slider.js +345 -0
  90. package/dist/components/slider/utils.js +94 -0
  91. package/dist/components/spacer/spacer.js +97 -0
  92. package/dist/components/tabs/tabs.js +704 -0
  93. package/dist/components/toggle/switch.js +156 -0
  94. package/dist/components/toggle/toggle.js +64 -0
  95. package/dist/components/toggle-button/toggle-button.js +343 -0
  96. package/dist/components/tooltip/tooltip.js +527 -0
  97. package/dist/context-BYWrbm1z.js +92 -0
  98. package/dist/default-i18n-CT_oS1Fy.js +922 -0
  99. package/dist/filterDOMProps-EDDcM64A.js +28 -0
  100. package/dist/icons/block-icon.js +42 -0
  101. package/dist/icons/generic-color-swatch.js +113 -0
  102. package/dist/icons/icons.js +30371 -0
  103. package/dist/icons/index.js +11 -0
  104. package/dist/icons/jsx-svg.js +50 -0
  105. package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
  106. package/dist/index-CFozsmNS.js +28321 -0
  107. package/dist/index-wl5606BX.js +44 -0
  108. package/dist/index.js +139 -0
  109. package/dist/lite-DVmmD_-j.js +7 -0
  110. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  111. package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
  112. package/dist/number-GajL10e1.js +36 -0
  113. package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
  114. package/dist/react-select-async.esm-D937XTWW.js +107 -0
  115. package/dist/react-select.esm-Ciai3aKf.js +15 -0
  116. package/dist/style-admin.js +1 -0
  117. package/dist/style-editor.js +1 -0
  118. package/dist/style.js +1 -0
  119. package/dist/textSelection-CCcyjiRP.js +46 -0
  120. package/dist/useButton-BOHxkGQF.js +50 -0
  121. package/dist/useEvent-D5o_CqDH.js +23 -0
  122. package/dist/useFocusRing-nMG2uzxS.js +107 -0
  123. package/dist/useFormReset-DlmRL87g.js +22 -0
  124. package/dist/useFormValidation-D0_aaK-e.js +224 -0
  125. package/dist/useHover-VO5tcIli.js +890 -0
  126. package/dist/useLabel-BKH4fVA4.js +27 -0
  127. package/dist/useLabels-ntF3rFY0.js +23 -0
  128. package/dist/useListState-Cq2Nvr-v.js +161 -0
  129. package/dist/useLocalizedStringFormatter-CGzwx1a0.js +121 -0
  130. package/dist/useNumberField-C9dmERhP.js +1207 -0
  131. package/dist/useNumberFormatter-MrRLgvhj.js +13 -0
  132. package/dist/usePress-DjNo5790.js +677 -0
  133. package/dist/useSingleSelectListState--r3AAhRj.js +38 -0
  134. package/dist/useToggle-CQaXLe-O.js +59 -0
  135. package/dist/useToggleState-C3DLdez5.js +19 -0
  136. package/dist/utilities/array-helpers.js +56 -0
  137. package/dist/utilities/debounce-throttle.js +123 -0
  138. package/dist/utilities/es-dash.js +382 -0
  139. package/dist/utilities/index.js +27 -0
  140. package/dist/utilities/text-helpers.js +136 -0
  141. package/dist/utils-B94NDG0v.js +370 -0
  142. package/dist/wp/wp-font-enhancements.js +1 -0
  143. package/dist/wp/wp-ui-enhancements.js +1 -0
  144. package/package.json +8 -8
@@ -0,0 +1,320 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { a as $4e85f108e88277b8$export$b085522c77523c51 } from "../../RSPContexts-2lR5GG9p.js";
3
+ import { d as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, l as $df56164dff5785e2$export$4338b53315abf666, m as $5dc95899b306f630$export$c9058316764c140e, h as $64fa3d84918910a7$export$ef03459518577ad4, b as $64fa3d84918910a7$export$4d86445c2cf5e3 } from "../../utils-B94NDG0v.js";
4
+ import { $ as $d3e0e05bdfcf66bd$export$c24727297075ec6a } from "../../Form-Cq3fu75_.js";
5
+ import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
6
+ import React__default, { useEffect, useRef, forwardRef, useContext, createContext } from "react";
7
+ import { $ as $e5be200c675c3b3a$export$fc1a364ae1f3ff10, a as $e93e671b31057976$export$b8473d3665f3a75a, b as $e5be200c675c3b3a$export$a763b9476acd3eb, c as $e5be200c675c3b3a$export$dad6ae84456c676a } from "../../useFormValidation-D0_aaK-e.js";
8
+ import { $ as $f6c31cce2adf654f$export$45712eceda6fad21 } from "../../usePress-DjNo5790.js";
9
+ import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577 } from "../../useToggle-CQaXLe-O.js";
10
+ import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-C3DLdez5.js";
11
+ import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-nMG2uzxS.js";
12
+ import { $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-VO5tcIli.js";
13
+ import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "../../VisuallyHidden-DsKYcRQ_.js";
14
+ import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-Fp6AwSRn.js";
15
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
16
+ import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
17
+ import { icons } from "../../icons/icons.js";
18
+ import { RichLabel } from "../rich-label/rich-label.js";
19
+ function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
20
+ let validationState = $e5be200c675c3b3a$export$fc1a364ae1f3ff10({
21
+ ...props,
22
+ value: state.isSelected
23
+ });
24
+ let { isInvalid, validationErrors, validationDetails } = validationState.displayValidation;
25
+ let { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly } = $d2c8e2b0480f3f34$export$cbe85ee05b554577({
26
+ ...props,
27
+ isInvalid
28
+ }, state, inputRef);
29
+ $e93e671b31057976$export$b8473d3665f3a75a(props, validationState, inputRef);
30
+ let { isIndeterminate, isRequired, validationBehavior = "aria" } = props;
31
+ useEffect(() => {
32
+ if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
33
+ });
34
+ let { pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
35
+ isDisabled: isDisabled || isReadOnly,
36
+ onPress() {
37
+ let { [$e5be200c675c3b3a$export$a763b9476acd3eb]: groupValidationState } = props;
38
+ let { commitValidation } = groupValidationState ? groupValidationState : validationState;
39
+ commitValidation();
40
+ }
41
+ });
42
+ return {
43
+ labelProps: $3ef42575df84b30b$export$9d1611c77c2fe928(labelProps, pressProps),
44
+ inputProps: {
45
+ ...inputProps,
46
+ checked: isSelected,
47
+ "aria-required": isRequired && validationBehavior === "aria" || void 0,
48
+ required: isRequired && validationBehavior === "native"
49
+ },
50
+ isSelected,
51
+ isPressed,
52
+ isDisabled,
53
+ isReadOnly,
54
+ isInvalid,
55
+ validationErrors,
56
+ validationDetails
57
+ };
58
+ }
59
+ const $1ae600c947479353$export$ec98120685d4f57d = /* @__PURE__ */ new WeakMap();
60
+ function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
61
+ const toggleState = $3017fa7ffdddec74$export$8042c6c013fd5226({
62
+ isReadOnly: props.isReadOnly || state.isReadOnly,
63
+ isSelected: state.isSelected(props.value),
64
+ onChange(isSelected) {
65
+ if (isSelected) state.addValue(props.value);
66
+ else state.removeValue(props.value);
67
+ if (props.onChange) props.onChange(isSelected);
68
+ }
69
+ });
70
+ let { name, descriptionId, errorMessageId, validationBehavior } = $1ae600c947479353$export$ec98120685d4f57d.get(state);
71
+ var _props_validationBehavior;
72
+ validationBehavior = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : validationBehavior;
73
+ let { realtimeValidation } = $e5be200c675c3b3a$export$fc1a364ae1f3ff10({
74
+ ...props,
75
+ value: toggleState.isSelected,
76
+ // Server validation is handled at the group level.
77
+ name: void 0,
78
+ validationBehavior: "aria"
79
+ });
80
+ let nativeValidation = useRef($e5be200c675c3b3a$export$dad6ae84456c676a);
81
+ let updateValidation = () => {
82
+ state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);
83
+ };
84
+ useEffect(updateValidation);
85
+ let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;
86
+ let displayValidation = validationBehavior === "native" ? state.displayValidation : combinedRealtimeValidation;
87
+ var _props_isRequired;
88
+ let res = $406796ff087fe49b$export$e375f10ce42261c5({
89
+ ...props,
90
+ isReadOnly: props.isReadOnly || state.isReadOnly,
91
+ isDisabled: props.isDisabled || state.isDisabled,
92
+ name: props.name || name,
93
+ isRequired: (_props_isRequired = props.isRequired) !== null && _props_isRequired !== void 0 ? _props_isRequired : state.isRequired,
94
+ validationBehavior,
95
+ [$e5be200c675c3b3a$export$a763b9476acd3eb]: {
96
+ realtimeValidation: combinedRealtimeValidation,
97
+ displayValidation,
98
+ resetValidation: state.resetValidation,
99
+ commitValidation: state.commitValidation,
100
+ updateValidation(v) {
101
+ nativeValidation.current = v;
102
+ updateValidation();
103
+ }
104
+ }
105
+ }, toggleState, inputRef);
106
+ return {
107
+ ...res,
108
+ inputProps: {
109
+ ...res.inputProps,
110
+ "aria-describedby": [
111
+ props["aria-describedby"],
112
+ state.isInvalid ? errorMessageId : null,
113
+ descriptionId
114
+ ].filter(Boolean).join(" ") || void 0
115
+ }
116
+ };
117
+ }
118
+ const $bc237834342dbd75$export$139c5b8563afc1fc = /* @__PURE__ */ createContext(null);
119
+ const $bc237834342dbd75$export$48513f6b9f8ce62d = /* @__PURE__ */ forwardRef(function Checkbox(props, ref) {
120
+ let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
121
+ [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(otherProps, ref, $4e85f108e88277b8$export$b085522c77523c51);
122
+ let { validationBehavior: formValidationBehavior } = $64fa3d84918910a7$export$fabf2dc03a41866e($d3e0e05bdfcf66bd$export$c24727297075ec6a) || {};
123
+ var _props_validationBehavior, _ref;
124
+ let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : "native";
125
+ let groupState = useContext($bc237834342dbd75$export$139c5b8563afc1fc);
126
+ let inputRef = $df56164dff5785e2$export$4338b53315abf666($5dc95899b306f630$export$c9058316764c140e(userProvidedInputRef, props.inputRef !== void 0 ? props.inputRef : null));
127
+ let { labelProps, inputProps, isSelected, isDisabled, isReadOnly, isPressed, isInvalid } = groupState ? $fba3e38d5ca8983f$export$353b32fc6898d37d({
128
+ ...$64fa3d84918910a7$export$ef03459518577ad4(props),
129
+ // Value is optional for standalone checkboxes, but required for CheckboxGroup items;
130
+ // it's passed explicitly here to avoid typescript error (requires ignore).
131
+ // @ts-ignore
132
+ value: props.value,
133
+ // ReactNode type doesn't allow function children.
134
+ children: typeof props.children === "function" ? true : props.children
135
+ }, groupState, inputRef) : $406796ff087fe49b$export$e375f10ce42261c5({
136
+ ...$64fa3d84918910a7$export$ef03459518577ad4(props),
137
+ children: typeof props.children === "function" ? true : props.children,
138
+ validationBehavior
139
+ }, $3017fa7ffdddec74$export$8042c6c013fd5226(props), inputRef);
140
+ let { isFocused, isFocusVisible, focusProps } = $f7dceffc5ad7768b$export$4e328f61c538687f();
141
+ let isInteractionDisabled = isDisabled || isReadOnly;
142
+ let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
143
+ ...props,
144
+ isDisabled: isInteractionDisabled
145
+ });
146
+ let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
147
+ ...props,
148
+ defaultClassName: "react-aria-Checkbox",
149
+ values: {
150
+ isSelected,
151
+ isIndeterminate: props.isIndeterminate || false,
152
+ isPressed,
153
+ isHovered,
154
+ isFocused,
155
+ isFocusVisible,
156
+ isDisabled,
157
+ isReadOnly,
158
+ isInvalid,
159
+ isRequired: props.isRequired || false
160
+ }
161
+ });
162
+ let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
163
+ delete DOMProps.id;
164
+ return /* @__PURE__ */ React__default.createElement("label", {
165
+ ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, labelProps, hoverProps, renderProps),
166
+ ref,
167
+ slot: props.slot || void 0,
168
+ "data-selected": isSelected || void 0,
169
+ "data-indeterminate": props.isIndeterminate || void 0,
170
+ "data-pressed": isPressed || void 0,
171
+ "data-hovered": isHovered || void 0,
172
+ "data-focused": isFocused || void 0,
173
+ "data-focus-visible": isFocusVisible || void 0,
174
+ "data-disabled": isDisabled || void 0,
175
+ "data-readonly": isReadOnly || void 0,
176
+ "data-invalid": isInvalid || void 0,
177
+ "data-required": props.isRequired || void 0
178
+ }, /* @__PURE__ */ React__default.createElement($5c3e21d68f1c4674$export$439d29a4e110a164, {
179
+ elementType: "span"
180
+ }, /* @__PURE__ */ React__default.createElement("input", {
181
+ ...$3ef42575df84b30b$export$9d1611c77c2fe928(inputProps, focusProps),
182
+ ref: inputRef
183
+ })), renderProps.children);
184
+ });
185
+ /**
186
+ * A simple checkbox.
187
+ *
188
+ * @component
189
+ * @param {Object} props - Component props.
190
+ * @param {JSX.Element} [props.icon] - The checkbox icon.
191
+ * @param {string} [props.label] - The checkbox label.
192
+ * @param {string} [props.subtitle] - The checkbox subtitle.
193
+ * @param {boolean} props.checked - Whether the checkbox is checked.
194
+ * @param {boolean} [props.disabled] - Whether the checkbox is disabled.
195
+ * @param {boolean} [props.readOnly] - Whether the checkbox is read-only.
196
+ * @param {boolean} [props.indeterminate] - Whether the checkbox is in an indeterminate state.
197
+ * @param {Function} props.onChange - The function to call when the checkbox is changed.
198
+ * @param {string} [props.className] - Additional classes to add to the checkbox container.
199
+ * @param {string} [props.labelClassName] - Additional classes to add to the label container.
200
+ * @param {boolean} [props.alignEnd] - Whether the label should be aligned to the end.
201
+ * @param {boolean} [props.inlineSubtitle] - If `true`, the subtitle is shown after the label instead of below it.
202
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
203
+ *
204
+ * @returns {JSX.Element} The Checkbox component.
205
+ *
206
+ * @example
207
+ * <Checkbox
208
+ * label='My label'
209
+ * checked={myValue}
210
+ * onChange={(value) => setMyValue(value)}
211
+ * />
212
+ *
213
+ * @preserve
214
+ */
215
+ const Checkbox2 = (props) => {
216
+ const {
217
+ icon,
218
+ label,
219
+ subtitle,
220
+ checked,
221
+ disabled,
222
+ readOnly,
223
+ indeterminate,
224
+ onChange,
225
+ className,
226
+ labelClassName,
227
+ inlineSubtitle,
228
+ alignEnd,
229
+ children,
230
+ hidden,
231
+ ...other
232
+ } = props;
233
+ if (hidden) {
234
+ return null;
235
+ }
236
+ const selectedOrIntermediate = checked || indeterminate;
237
+ return /* @__PURE__ */ jsxs(
238
+ $bc237834342dbd75$export$48513f6b9f8ce62d,
239
+ {
240
+ isDisabled: disabled,
241
+ isIndeterminate: indeterminate,
242
+ isReadOnly: readOnly,
243
+ isSelected: checked ?? false,
244
+ onChange,
245
+ className: clsx("es:group es:flex es:w-full es:items-center es:gap-1.5 es:text-sm", className),
246
+ ...other,
247
+ children: [
248
+ (icon || alignEnd) && (label || subtitle) && /* @__PURE__ */ jsx(
249
+ RichLabel,
250
+ {
251
+ icon,
252
+ label,
253
+ subtitle,
254
+ className: clsx("es:ml-1", labelClassName),
255
+ inlineSubtitle,
256
+ fullSizeSubtitle: true,
257
+ fullWidth: true,
258
+ as: $01b77f81d0f07f68$export$b04be29aa201d4f5
259
+ }
260
+ ),
261
+ /* @__PURE__ */ jsxs(
262
+ "div",
263
+ {
264
+ className: clsx(
265
+ "es:size-5 es:flex es:items-center es:justify-center",
266
+ "es:transition es:cursor-pointer",
267
+ "es:bg-radial es:border es:rounded-md",
268
+ "es:shadow-xs es:inset-ring es:inset-shadow-xs",
269
+ "es:any-focus:outline-hidden es:group-focus-visible:ring-2 es:group-focus-visible:ring-accent-500/50",
270
+ !selectedOrIntermediate && "es:group-focus-visible:border-accent-500",
271
+ !selectedOrIntermediate && "es:border-secondary-300 es:inset-ring-secondary-100 es:inset-shadow-secondary-100/50",
272
+ !selectedOrIntermediate && "es:from-secondary-50 es:to-white es:text-secondary-600 es:hover:text-accent-950",
273
+ !selectedOrIntermediate && "es:hover:inset-shadow-secondary-100 es:hover:to-secondary-100 es:hover:inset-ring-secondary-100",
274
+ selectedOrIntermediate && "es:text-white es:from-accent-500 es:to-accent-600",
275
+ selectedOrIntermediate && "es:shadow-accent-600/30 es:border-accent-700 es:inset-ring es:inset-ring-accent-600 es:inset-shadow-accent-400/75",
276
+ selectedOrIntermediate && "es:group-focus-visible:inset-ring-accent-600 es:group-focus-visible:inset-shadow-xs es:group-focus-visible:inset-shadow-accent-400",
277
+ !alignEnd && subtitle && "es:mb-auto"
278
+ ),
279
+ children: [
280
+ /* @__PURE__ */ jsx(
281
+ AnimatedVisibility,
282
+ {
283
+ transition: "scaleFade",
284
+ visible: indeterminate,
285
+ className: "es:transition-none",
286
+ children: /* @__PURE__ */ jsx("div", { className: "es:h-0.5 es:w-3 es:rounded es:bg-white" })
287
+ }
288
+ ),
289
+ /* @__PURE__ */ jsx(
290
+ AnimatedVisibility,
291
+ {
292
+ transition: "scaleRotateFade",
293
+ visible: !indeterminate && checked,
294
+ className: "es:transition-none es:icon:size-3 es:icon:stroke-3",
295
+ noInitial: true,
296
+ children: icons.check
297
+ }
298
+ )
299
+ ]
300
+ }
301
+ ),
302
+ !icon && !alignEnd && (label || subtitle) && /* @__PURE__ */ jsx(
303
+ RichLabel,
304
+ {
305
+ label,
306
+ subtitle,
307
+ className: clsx(subtitle && "es:mt-0.5", "es:ml-0.5 es:*:space-y-0.5", labelClassName),
308
+ inlineSubtitle,
309
+ fullSizeSubtitle: true,
310
+ as: $01b77f81d0f07f68$export$b04be29aa201d4f5
311
+ }
312
+ ),
313
+ !(icon || label || subtitle) && children
314
+ ]
315
+ }
316
+ );
317
+ };
318
+ export {
319
+ Checkbox2 as Checkbox
320
+ };
@@ -0,0 +1,272 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
3
+ import { Menu, MenuItem, MenuSeparator, MenuSection } 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 { c as clsx } from "../../lite-DVmmD_-j.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 clsx 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 picked color can be removed.
28
+ * @param {boolean} [props.stacked] - If `true`, the control is not rendered inline.
29
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
30
+ * @param {string} [props.tooltip] - If provided, overrides the default tooltip text. If there is no label, the value will still be shown within the tooltip.
31
+ * @param {string} [props.clearItemLabel] - Label for the "None" item, if `clearable` is enabled.
32
+ * @param {JSX.Element|JSX.Element[]} [props.extraOptions] - If `type` is `menu`, allows passing additional menu items, which will be displayed below the options.
33
+ *
34
+ * @returns {JSX.Element} The ColorPicker component.
35
+ *
36
+ * @typedef {'default' | 'fillColor' | 'textColor' | 'textHighlightColor' | 'listMarkerColor'} ColorPickerType
37
+ *
38
+ * @example
39
+ * <ColorPicker
40
+ * icon={icons.fillColor}
41
+ * label={__('Fill color', 'eightshift-ui-components')}
42
+ * subtitle={__('Select fill color', 'eightshift-ui-components')}
43
+ * value={fillColor}
44
+ * onChange={(value) => setAttributes({ fillColor: value })}
45
+ * colors={[
46
+ * { name: 'Red', slug: 'red', color: '#ff0000' },
47
+ * { name: 'Green', slug: 'green', color: '#00ff00' },
48
+ * { name: 'Blue', slug: 'blue', color: '#0000ff' },
49
+ * ]}
50
+ * />
51
+ *
52
+ * @preserve
53
+ */
54
+ const ColorPicker = (props) => {
55
+ var _a, _b;
56
+ const {
57
+ icon,
58
+ label,
59
+ subtitle,
60
+ labelClassName,
61
+ value,
62
+ onChange,
63
+ colors,
64
+ showColorCode,
65
+ noColorGroups,
66
+ type = "default",
67
+ stacked,
68
+ clearable,
69
+ clearItemLabel = __("None", "eightshift-ui-components"),
70
+ hidden,
71
+ tooltip,
72
+ extraOptions,
73
+ ...rest
74
+ } = props;
75
+ if (hidden) {
76
+ return null;
77
+ }
78
+ const currentColor = (_a = colors == null ? void 0 : colors.find(({ slug }) => slug === value)) == null ? void 0 : _a.color;
79
+ const colorSuffixRegex = /(?!^.+)(-?(?:50|100|200|300|400|500|600|700|800|900|950|10|20|30|40|50|60|70|80|90){1})$/gi;
80
+ const hasColorGroups = !noColorGroups && (colors == null ? void 0 : colors.some(({ slug }) => colorSuffixRegex.test(slug)));
81
+ let groupedColors;
82
+ const colorGroupNames = {
83
+ generic: __("Other colors", "eightshift-ui-components")
84
+ };
85
+ if (hasColorGroups) {
86
+ groupedColors = colors.reduce(
87
+ (output, current) => {
88
+ var _a2;
89
+ if (current === void 0 || (current == null ? void 0 : current.name) === void 0 || (current == null ? void 0 : current.slug) === void 0) {
90
+ return output;
91
+ }
92
+ if ((_a2 = current.slug.match(colorSuffixRegex)) == null ? void 0 : _a2.length) {
93
+ const newSlug = current.slug.replace(colorSuffixRegex, "").trim();
94
+ if (!output[newSlug]) {
95
+ output[newSlug] = [];
96
+ colorGroupNames[newSlug] = current.name.replace(colorSuffixRegex, "").trim();
97
+ }
98
+ output[newSlug] = [
99
+ ...output[newSlug],
100
+ {
101
+ ...current,
102
+ shade: current.slug.match(colorSuffixRegex)[0].replace("-", "")
103
+ }
104
+ ];
105
+ } else {
106
+ output.generic = [...output.generic, current];
107
+ }
108
+ return output;
109
+ },
110
+ { generic: [] }
111
+ );
112
+ }
113
+ const SingleItem = ({ name, slug, color, ...rest2 }) => /* @__PURE__ */ jsxs(
114
+ MenuItem,
115
+ {
116
+ ...rest2,
117
+ endIcon: /* @__PURE__ */ jsx(
118
+ ColorSwatch,
119
+ {
120
+ className: "es:size-5.5!",
121
+ color
122
+ }
123
+ ),
124
+ onClick: () => onChange(slug),
125
+ selected: value === slug,
126
+ children: [
127
+ !showColorCode && name.replaceAll("-", " "),
128
+ showColorCode && /* @__PURE__ */ jsx(
129
+ RichLabel,
130
+ {
131
+ label: name.replaceAll("-", " "),
132
+ subtitle: color.toUpperCase()
133
+ }
134
+ )
135
+ ]
136
+ }
137
+ );
138
+ let tooltipText;
139
+ let menuTriggerIcon;
140
+ if (type === "default") {
141
+ tooltipText = __("Color", "eightshift-ui-components");
142
+ } else if (type === "fillColor") {
143
+ tooltipText = __("Fill color", "eightshift-ui-components");
144
+ menuTriggerIcon = icons.colorPickerFill;
145
+ } else if (type === "textColor") {
146
+ tooltipText = __("Text color", "eightshift-ui-components");
147
+ menuTriggerIcon = icons.colorPickerText;
148
+ } else if (type === "textHighlightColor") {
149
+ tooltipText = __("Text highlight color", "eightshift-ui-components");
150
+ menuTriggerIcon = icons.colorPickerTextHighlight;
151
+ } else if (type === "listMarkerColor") {
152
+ tooltipText = __("List marker color", "eightshift-ui-components");
153
+ menuTriggerIcon = icons.colorPickerListMarker;
154
+ }
155
+ const currentColorName = (_b = colors == null ? void 0 : colors.find((color) => (color == null ? void 0 : color.slug) === value)) == null ? void 0 : _b.name;
156
+ if (!label && tooltipText) {
157
+ tooltipText = /* @__PURE__ */ jsx(
158
+ RichLabel,
159
+ {
160
+ label: tooltipText,
161
+ subtitle: currentColorName,
162
+ noColor: true
163
+ }
164
+ );
165
+ } else if (!label && tooltip) {
166
+ tooltipText = /* @__PURE__ */ jsx(
167
+ RichLabel,
168
+ {
169
+ label: tooltip,
170
+ subtitle: currentColorName,
171
+ noColor: true
172
+ }
173
+ );
174
+ } else if (label) {
175
+ tooltipText = currentColorName;
176
+ }
177
+ return /* @__PURE__ */ jsx(
178
+ BaseControl,
179
+ {
180
+ icon,
181
+ label,
182
+ subtitle,
183
+ className: clsx("es:w-full", labelClassName),
184
+ inline: !stacked,
185
+ children: /* @__PURE__ */ jsxs(
186
+ Menu,
187
+ {
188
+ triggerIcon: /* @__PURE__ */ jsxs(Fragment, { children: [
189
+ (type === "default" || icon) && /* @__PURE__ */ jsx(
190
+ ColorSwatch,
191
+ {
192
+ color: currentColor,
193
+ className: "es:size-6! es:shadow-none!"
194
+ }
195
+ ),
196
+ !icon && type !== "default" && /* @__PURE__ */ jsxs("div", { className: "es:relative es:size-6 es:icon:absolute es:icon:inset-0 es:icon:size-full", children: [
197
+ menuTriggerIcon,
198
+ /* @__PURE__ */ jsx(
199
+ ColorSwatch,
200
+ {
201
+ color: currentColor,
202
+ className: "es:absolute es:-bottom-0.5 es:left-0 es:h-2! es:shadow-none!"
203
+ }
204
+ )
205
+ ] })
206
+ ] }),
207
+ keepOpen: true,
208
+ tooltip: tooltipText,
209
+ triggerProps: {
210
+ ...rest.triggerProps,
211
+ "aria-label": typeof label !== "undefined" ? null : props == null ? void 0 : props["aria-label"]
212
+ },
213
+ ...rest,
214
+ children: [
215
+ clearable && /* @__PURE__ */ jsxs(Fragment, { children: [
216
+ /* @__PURE__ */ jsx(
217
+ MenuItem,
218
+ {
219
+ onClick: () => onChange(void 0),
220
+ selected: typeof value === "undefined",
221
+ endIcon: /* @__PURE__ */ jsx(ColorSwatch, { className: "es:size-5.5!" }),
222
+ children: clearItemLabel
223
+ }
224
+ ),
225
+ /* @__PURE__ */ jsx(MenuSeparator, {})
226
+ ] }),
227
+ (noColorGroups || !hasColorGroups) && colors.map((color) => /* @__PURE__ */ jsx(
228
+ SingleItem,
229
+ {
230
+ ...color
231
+ },
232
+ color.slug
233
+ )),
234
+ hasColorGroups && /* @__PURE__ */ jsxs(Fragment, { children: [
235
+ Object.entries(groupedColors).map(([groupSlug, colors2]) => {
236
+ if (groupSlug === "generic") {
237
+ return null;
238
+ }
239
+ return /* @__PURE__ */ jsx(
240
+ MenuSection,
241
+ {
242
+ "aria-label": colorGroupNames[groupSlug],
243
+ children: colors2.map((color) => /* @__PURE__ */ jsx(
244
+ SingleItem,
245
+ {
246
+ ...color
247
+ },
248
+ color.slug
249
+ ))
250
+ },
251
+ groupSlug
252
+ );
253
+ }),
254
+ groupedColors.generic.length > 0 && /* @__PURE__ */ jsx(MenuSection, { "aria-label": colorGroupNames.generic, children: groupedColors.generic.map((color) => /* @__PURE__ */ jsx(
255
+ SingleItem,
256
+ {
257
+ ...color
258
+ },
259
+ color.slug
260
+ )) })
261
+ ] }),
262
+ extraOptions && /* @__PURE__ */ jsx(MenuSeparator, {}),
263
+ extraOptions
264
+ ]
265
+ }
266
+ )
267
+ }
268
+ );
269
+ };
270
+ export {
271
+ ColorPicker
272
+ };
@@ -0,0 +1,59 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { $ as $251c695a52d94a8d$export$cae13e90592f246a } from "../../ColorSwatch-Bcn6oRSg.js";
3
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
4
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
5
+ import { $ as $799cddbef784668f$export$6e865ea70d7724f } from "../../Color-BhgbJF5x.js";
6
+ /**
7
+ * A simple color/gradient swatch.
8
+ *
9
+ * @component
10
+ * @param {Object} props - Component props.
11
+ * @param {string} [props.color] - The color to display.
12
+ * @param {string} [props.gradient] - The gradient to display.
13
+ * @param {string} [props.className] - Additional clsx to apply.
14
+ * @param {string} [props.colorName] - The name of the color. Should be auto-generated for colors.
15
+ * @param {boolean} [props.customGradient=false] - Set to `true` if using a custom gradient.
16
+ *
17
+ * @returns {JSX.Element} The ColorSwatch component.
18
+ *
19
+ * @example
20
+ * <ColorSwatch color="#FF0000" />
21
+ *
22
+ * @example
23
+ * <ColorSwatch gradient="linear-gradient(45deg, #FF0000, #00FF00)" />
24
+ *
25
+ * @preserve
26
+ */
27
+ const ColorSwatch = (props) => {
28
+ const { color: rawColor, gradient, className, colorName, customGradient = false } = props;
29
+ const checkerPattern = "repeating-conic-gradient(#CCC 0% 25%, white 0% 50%) 50% / 0.75rem 0.75rem";
30
+ let color;
31
+ if (rawColor && !gradient && !customGradient) {
32
+ try {
33
+ if (rawColor === "transparent") {
34
+ color = "rgba(0, 0, 0, 0)";
35
+ } else {
36
+ color = $799cddbef784668f$export$6e865ea70d7724f(rawColor);
37
+ }
38
+ } catch (error) {
39
+ color = null;
40
+ }
41
+ }
42
+ const backgroundGradient = gradient ? `${gradient}, ${checkerPattern}` : `linear-gradient(${color}, ${color}), ${checkerPattern}`;
43
+ return /* @__PURE__ */ jsx(
44
+ $251c695a52d94a8d$export$cae13e90592f246a,
45
+ {
46
+ ...props,
47
+ style: {
48
+ background: (color || gradient) && backgroundGradient
49
+ },
50
+ className: () => clsx("es:size-6 es:rounded es:border es:border-secondary-300 es:shadow-xs", !color && !gradient && !customGradient && "es:bg-white", className),
51
+ colorName: !color && !gradient && !customGradient ? __("No color", "eightshift-ui-components") : colorName,
52
+ color,
53
+ children: !color && !gradient && !customGradient && /* @__PURE__ */ jsx("div", { className: "es:m-auto es:h-full es:w-px es:rotate-45 es:rounded es:bg-red-500" })
54
+ }
55
+ );
56
+ };
57
+ export {
58
+ ColorSwatch
59
+ };