@eightshift/ui-components 3.0.1 → 5.0.0

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/package.json +101 -101
  2. package/dist/Button-BPLceDeW.js +0 -185
  3. package/dist/Collection-CZxddMZS.js +0 -2332
  4. package/dist/Color-MV5kBVXr.js +0 -2452
  5. package/dist/ColorSwatch-BqQfVu4L.js +0 -64
  6. package/dist/ComboBox-_RfyhwZw.js +0 -1906
  7. package/dist/Dialog-8tYeQ9n4.js +0 -2300
  8. package/dist/FieldError-52GVSGgC.js +0 -42
  9. package/dist/FocusScope-Cri5BFRz.js +0 -831
  10. package/dist/Form-Cq3fu75_.js +0 -5
  11. package/dist/Group-_emcIVxI.js +0 -48
  12. package/dist/Heading-B2153VXe.js +0 -16
  13. package/dist/Hidden-rE6uR-lr.js +0 -41
  14. package/dist/Input-BxpFEIXV.js +0 -133
  15. package/dist/Label-icmbmNdI.js +0 -17
  16. package/dist/List-CZMUbkFU.js +0 -593
  17. package/dist/ListBox-Ca6hiCqz.js +0 -581
  18. package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
  19. package/dist/OverlayArrow-CYXQSlEU.js +0 -629
  20. package/dist/RSPContexts-2lR5GG9p.js +0 -14
  21. package/dist/Select-aab027f3.esm-PDJCDE95.js +0 -2469
  22. package/dist/Separator-4IIDRlV_.js +0 -322
  23. package/dist/Slider-rz2XRMGm.js +0 -853
  24. package/dist/Text-DVSAPY-K.js +0 -16
  25. package/dist/VisuallyHidden-f9zX67a_.js +0 -48
  26. package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
  27. package/dist/assets/index.css +0 -37
  28. package/dist/assets/style-admin.css +0 -5255
  29. package/dist/assets/style-editor.css +0 -5255
  30. package/dist/assets/style.css +0 -5261
  31. package/dist/assets/wp-font-enhancements.css +0 -8
  32. package/dist/assets/wp-ui-enhancements.css +0 -299
  33. package/dist/components/animated-visibility/animated-visibility.js +0 -105
  34. package/dist/components/base-control/base-control.js +0 -86
  35. package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
  36. package/dist/components/button/button.js +0 -387
  37. package/dist/components/checkbox/checkbox.js +0 -320
  38. package/dist/components/color-pickers/color-picker.js +0 -272
  39. package/dist/components/color-pickers/color-swatch.js +0 -58
  40. package/dist/components/color-pickers/gradient-editor.js +0 -534
  41. package/dist/components/color-pickers/solid-color-picker.js +0 -1567
  42. package/dist/components/component-toggle/component-toggle.js +0 -158
  43. package/dist/components/container-panel/container-panel.js +0 -131
  44. package/dist/components/draggable/draggable-context.js +0 -5
  45. package/dist/components/draggable/draggable-handle.js +0 -46
  46. package/dist/components/draggable/draggable.js +0 -6207
  47. package/dist/components/draggable-list/draggable-list-context.js +0 -5
  48. package/dist/components/draggable-list/draggable-list-item.js +0 -77
  49. package/dist/components/draggable-list/draggable-list.js +0 -151
  50. package/dist/components/expandable/expandable.js +0 -342
  51. package/dist/components/index.js +0 -137
  52. package/dist/components/input-field/input-field.js +0 -231
  53. package/dist/components/item-collection/item-collection.js +0 -59
  54. package/dist/components/layout/hstack.js +0 -30
  55. package/dist/components/layout/vstack.js +0 -30
  56. package/dist/components/link-input/link-input.js +0 -293
  57. package/dist/components/matrix-align/matrix-align.js +0 -134
  58. package/dist/components/menu/menu.js +0 -285
  59. package/dist/components/modal/modal.js +0 -305
  60. package/dist/components/notice/notice.js +0 -123
  61. package/dist/components/number-picker/number-picker.js +0 -292
  62. package/dist/components/option-select/option-select.js +0 -264
  63. package/dist/components/options-panel/options-panel.js +0 -158
  64. package/dist/components/placeholders/file-placeholder.js +0 -42
  65. package/dist/components/placeholders/image-placeholder.js +0 -88
  66. package/dist/components/placeholders/media-placeholder.js +0 -63
  67. package/dist/components/popover/popover.js +0 -207
  68. package/dist/components/radio/radio.js +0 -579
  69. package/dist/components/repeater/repeater-context.js +0 -5
  70. package/dist/components/repeater/repeater-item.js +0 -119
  71. package/dist/components/repeater/repeater.js +0 -280
  72. package/dist/components/responsive/mini-responsive.js +0 -498
  73. package/dist/components/responsive/responsive-legacy.js +0 -343
  74. package/dist/components/responsive/responsive.js +0 -580
  75. package/dist/components/responsive-preview/responsive-preview.js +0 -123
  76. package/dist/components/rich-label/rich-label.js +0 -66
  77. package/dist/components/select/async-multi-select.js +0 -157
  78. package/dist/components/select/async-single-select.js +0 -137
  79. package/dist/components/select/custom-select-default-components.js +0 -38
  80. package/dist/components/select/multi-select-components.js +0 -8
  81. package/dist/components/select/multi-select.js +0 -151
  82. package/dist/components/select/react-select-component-wrappers.js +0 -90
  83. package/dist/components/select/shared.js +0 -26
  84. package/dist/components/select/single-select.js +0 -131
  85. package/dist/components/select/styles.js +0 -49
  86. package/dist/components/select/v2/async-select.js +0 -297
  87. package/dist/components/select/v2/shared.js +0 -24
  88. package/dist/components/select/v2/single-select.js +0 -990
  89. package/dist/components/slider/column-config-slider.js +0 -210
  90. package/dist/components/slider/slider.js +0 -343
  91. package/dist/components/slider/utils.js +0 -84
  92. package/dist/components/spacer/spacer.js +0 -97
  93. package/dist/components/tabs/tabs.js +0 -702
  94. package/dist/components/toggle/switch.js +0 -155
  95. package/dist/components/toggle/toggle.js +0 -64
  96. package/dist/components/toggle-button/toggle-button.js +0 -324
  97. package/dist/components/tooltip/tooltip.js +0 -525
  98. package/dist/context-D2KUdwNL.js +0 -92
  99. package/dist/default-i18n-CT_oS1Fy.js +0 -922
  100. package/dist/filterDOMProps-EDDcM64A.js +0 -28
  101. package/dist/icons/block-icon.js +0 -42
  102. package/dist/icons/generic-color-swatch.js +0 -113
  103. package/dist/icons/icons.js +0 -30371
  104. package/dist/icons/index.js +0 -11
  105. package/dist/icons/jsx-svg.js +0 -50
  106. package/dist/index-641ee5b8.esm-DIuJijyT.js +0 -3137
  107. package/dist/index-BKGQ6jGS.js +0 -44
  108. package/dist/index-CFozsmNS.js +0 -28321
  109. package/dist/index.js +0 -139
  110. package/dist/lite-DVmmD_-j.js +0 -7
  111. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  112. package/dist/multi-select-components-Sp-JEFEX.js +0 -3744
  113. package/dist/number-GajL10e1.js +0 -36
  114. package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
  115. package/dist/react-select-async.esm-Bql4G5iV.js +0 -107
  116. package/dist/react-select.esm-B_TudhTU.js +0 -15
  117. package/dist/style-admin.js +0 -1
  118. package/dist/style-editor.js +0 -1
  119. package/dist/style.js +0 -1
  120. package/dist/textSelection-0UUS8Yfg.js +0 -46
  121. package/dist/useButton-Cg474OYB.js +0 -71
  122. package/dist/useEvent-B0b-6KBr.js +0 -23
  123. package/dist/useFocusRing-CV5l3lf6.js +0 -107
  124. package/dist/useFormReset-C5OggHsw.js +0 -22
  125. package/dist/useFormValidation-DhDNSjws.js +0 -224
  126. package/dist/useHover-DwDr6ozG.js +0 -900
  127. package/dist/useLabel-D7HkNEHT.js +0 -27
  128. package/dist/useLabels-D8cxd1Z8.js +0 -23
  129. package/dist/useListState-DVr6aYd_.js +0 -161
  130. package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
  131. package/dist/useNumberField-TwM0Z9D1.js +0 -1204
  132. package/dist/useNumberFormatter-321rAb4J.js +0 -13
  133. package/dist/usePress-Cucx-xSA.js +0 -664
  134. package/dist/useSingleSelectListState-CMGsRHHh.js +0 -38
  135. package/dist/useToggle-C0I3vs0g.js +0 -59
  136. package/dist/useToggleState-CmQX3SoX.js +0 -19
  137. package/dist/utilities/array-helpers.js +0 -56
  138. package/dist/utilities/debounce-throttle.js +0 -123
  139. package/dist/utilities/es-dash.js +0 -376
  140. package/dist/utilities/index.js +0 -27
  141. package/dist/utilities/text-helpers.js +0 -136
  142. package/dist/utils-DkCSC521.js +0 -370
  143. package/dist/wp/wp-font-enhancements.js +0 -1
  144. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,534 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { _ as __, s as sprintf } from "../../default-i18n-CT_oS1Fy.js";
3
- import { useMemo, useState } from "react";
4
- import { ButtonGroup, Button } from "../button/button.js";
5
- import { icons } from "../../icons/icons.js";
6
- import { SolidColorPicker } from "./solid-color-picker.js";
7
- import { Slider } from "../slider/slider.js";
8
- import { NumberPicker } from "../number-picker/number-picker.js";
9
- import { $ as $251c695a52d94a8d$export$cae13e90592f246a } from "../../ColorSwatch-BqQfVu4L.js";
10
- import { Menu, MenuItem } from "../menu/menu.js";
11
- import { MatrixAlign } from "../matrix-align/matrix-align.js";
12
- import { Spacer } from "../spacer/spacer.js";
13
- import { Toggle } from "../toggle/toggle.js";
14
- import { OptionSelect } from "../option-select/option-select.js";
15
- import { DraggableList } from "../draggable-list/draggable-list.js";
16
- import { DraggableListItem } from "../draggable-list/draggable-list-item.js";
17
- import { TriggeredPopover } from "../popover/popover.js";
18
- import { c as clsx } from "../../lite-DVmmD_-j.js";
19
- function c(e, o = ",") {
20
- let t = [], n = 0, i = 0;
21
- o = new RegExp(o);
22
- for (let r = 0; r < e.length; r++) e[r] === "(" ? i++ : e[r] === ")" && i--, i === 0 && o.test(e[r]) && (t.push(e.slice(n, r).trim()), n = r + 1);
23
- return t.push(e.slice(n).trim()), t;
24
- }
25
- function g(e) {
26
- let o = [];
27
- for (let t = 0, n = e.length; t < n; ) {
28
- let [i, r] = c(e[t], /\s+/);
29
- m(e[t + 1]) ? (o.push({ color: i, offset: l(r), hint: l(e[t + 1]) }), t += 2) : (o.push({ color: i, offset: l(r) }), t++);
30
- }
31
- return o;
32
- }
33
- var u = /^(-?\d+\.?\d*)(%|vw|vh|px|em|rem|deg|rad|grad|turn)$/;
34
- function m(e) {
35
- return u.test(e);
36
- }
37
- function l(e) {
38
- if (!e) return;
39
- let [, o, t] = e.trim().match(u) || [];
40
- return { value: o, unit: t };
41
- }
42
- function P(e) {
43
- if (!/^(repeating-)?linear-gradient/.test(e)) throw new SyntaxError(`could not find syntax for this item: ${e}`);
44
- let [, o, t] = e.match(/(repeating-)?linear-gradient\((.+)\)/), n = { orientation: { type: "directional", value: "bottom" }, repeating: !!o, stops: [] }, i = c(t), r = x(i[0]);
45
- return r && (n.orientation = r, i.shift()), { ...n, stops: g(i) };
46
- }
47
- function x(e) {
48
- return e.startsWith("to ") ? { type: "directional", value: e.replace("to ", "") } : ["turn", "deg", "grad", "rad"].some((o) => e.endsWith(o)) ? { type: "angular", value: l(e) } : null;
49
- }
50
- var w = /* @__PURE__ */ new Set(["closest-corner", "closest-side", "farthest-corner", "farthest-side"]), v = /* @__PURE__ */ new Set(["center", "left", "top", "right", "bottom"]);
51
- function d(e) {
52
- return w.has(e);
53
- }
54
- function h(e) {
55
- return v.has(e);
56
- }
57
- function R(e) {
58
- let o = Array(2).fill("");
59
- for (let t = 0; t < 2; t++) e[t] ? o[t] = e[t] : o[t] = "center";
60
- return o;
61
- }
62
- function K(e) {
63
- if (!/(repeating-)?radial-gradient/.test(e)) throw new SyntaxError(`could not find syntax for this item: ${e}`);
64
- let [, o, t] = e.match(/(repeating-)?radial-gradient\((.+)\)/), n = { shape: "ellipse", repeating: !!o, size: [{ type: "keyword", value: "farthest-corner" }], position: { x: { type: "keyword", value: "center" }, y: { type: "keyword", value: "center" } }, stops: [] }, i = c(t);
65
- if (S(i[0])) return { ...n, stops: g(i) };
66
- let r = i[0].split("at").map((f) => f.trim()), p = ((r[0] || "").match(/(circle|ellipse)/) || [])[1], a = (r[0] || "").match(/(-?\d+\.?\d*(vw|vh|px|em|rem|%|rad|grad|turn|deg)?|closest-corner|closest-side|farthest-corner|farthest-side)/g) || [], s = R((r[1] || "").split(" "));
67
- return p ? n.shape = p : a.length === 1 && !d(a[0]) ? n.shape = "circle" : n.shape = "ellipse", a.length === 0 && a.push("farthest-corner"), n.size = a.map((f) => d(f) ? { type: "keyword", value: f } : { type: "length", value: l(f) }), n.position.x = h(s[0]) ? { type: "keyword", value: s[0] } : { type: "length", value: l(s[0]) }, n.position.y = h(s[1]) ? { type: "keyword", value: s[1] } : { type: "length", value: l(s[1]) }, (p || a.length > 0 || r[1]) && i.shift(), { ...n, stops: g(i) };
68
- }
69
- function S(e) {
70
- return /(circle|ellipse|at)/.test(e) ? false : /^(rgba?|hwb|hsl|lab|lch|oklab|color|#|[a-zA-Z]+)/.test(e);
71
- }
72
- var C = /* @__PURE__ */ new Set(["from", "in", "at"]);
73
- function j(e) {
74
- if (!/(repeating-)?conic-gradient/.test(e)) throw new SyntaxError(`could not find syntax for this item: ${e}`);
75
- let [, o, t] = e.match(/(repeating-)?conic-gradient\((.+)\)/), n = { angle: "0deg", repeating: !!o, position: "center", stops: [] }, i = c(t).map((s) => s.trim()), r = c(i[0], /\s+/), p = "", a = 0;
76
- for (let s = 0, f = r.length; s < f; s++) C.has(r[s]) && (s > 0 && Object.assign(n, y(p, r, a, s)), p = r[s], a = s + 1);
77
- return p && (Object.assign(n, y(p, r, a, r.length)), i.shift()), { ...n, stops: g(i) };
78
- }
79
- function y(e, o, t, n) {
80
- switch (e) {
81
- case "from":
82
- return { angle: o.slice(t, n).join(" ") };
83
- case "at":
84
- return { position: o.slice(t, n).join(" ") };
85
- case "in": {
86
- let [i, ...r] = o.slice(t, n);
87
- return { color: { space: i, method: r.length > 0 ? r.join(" ") : void 0 } };
88
- }
89
- }
90
- }
91
- const getGradientResult = (input, type) => {
92
- var _a, _b;
93
- if (!input || !type) {
94
- return "";
95
- }
96
- if (typeof input === "string" || !(input == null ? void 0 : input.stops)) {
97
- return "";
98
- }
99
- let output = "";
100
- const { repeating } = input;
101
- if (repeating) {
102
- output += "repeating-";
103
- }
104
- output += `${type}-gradient(`;
105
- if (type === "linear") {
106
- const { orientation } = input;
107
- if ((orientation == null ? void 0 : orientation.type) === "angular") {
108
- output += `${orientation.value.value}${orientation.value.unit}, `;
109
- } else if ((orientation == null ? void 0 : orientation.type) === "directional") {
110
- output += `to ${orientation.value}, `;
111
- }
112
- }
113
- if (type === "radial") {
114
- const { shape, position } = input;
115
- output += `${shape ?? "circle"} at ${((_a = position == null ? void 0 : position.x) == null ? void 0 : _a.value) ?? "center"} ${((_b = position == null ? void 0 : position.y) == null ? void 0 : _b.value) ?? "center"}, `;
116
- }
117
- if (type === "conic") {
118
- const { angle, position } = input;
119
- output += `from ${angle ?? "0deg"} at ${position ?? "center"}, `;
120
- }
121
- output += input.stops.map((stop) => {
122
- var _a2, _b2;
123
- return `${stop.color} ${((_a2 = stop.offset) == null ? void 0 : _a2.value) ?? ""}${((_b2 = stop.offset) == null ? void 0 : _b2.unit) ?? ""}`.trim();
124
- }).join(", ");
125
- output += ")";
126
- return output;
127
- };
128
- const gradientTypes = [
129
- {
130
- label: __("Linear"),
131
- value: "linear",
132
- icon: /* @__PURE__ */ jsx("div", { className: "es:transparent es:size-4 es:rounded-full es:bg-linear-to-br es:from-current" })
133
- },
134
- {
135
- label: __("Radial"),
136
- value: "radial",
137
- icon: /* @__PURE__ */ jsx("div", { className: "es:transparent es:size-4 es:rounded-full es:bg-[radial-gradient(var(--tw-gradient-stops))] es:from-current" })
138
- },
139
- {
140
- label: __("Conic"),
141
- value: "conic",
142
- icon: /* @__PURE__ */ jsx("div", { className: "es:transparent es:size-4 es:rounded-full es:bg-[conic-gradient(var(--tw-gradient-stops))] es:from-current" })
143
- }
144
- ];
145
- const linearDirections = [
146
- {
147
- label: __("Right"),
148
- value: "right",
149
- iconClass: "es:bg-linear-to-r",
150
- valueDegrees: 90
151
- },
152
- {
153
- label: __("Left"),
154
- value: "left",
155
- iconClass: "es:bg-linear-to-l",
156
- valueDegrees: 180
157
- },
158
- {
159
- label: __("Top"),
160
- value: "top",
161
- iconClass: "es:bg-linear-to-t",
162
- valueDegrees: 270
163
- },
164
- {
165
- label: __("Bottom"),
166
- value: "bottom",
167
- iconClass: "es:bg-linear-to-b",
168
- valueDegrees: 90
169
- },
170
- {
171
- label: __("Top-right"),
172
- value: "top right",
173
- iconClass: "es:bg-linear-to-tr",
174
- valueDegrees: 45
175
- },
176
- {
177
- label: __("Top-left"),
178
- value: "top left",
179
- iconClass: "es:bg-linear-to-tl",
180
- valueDegrees: 315
181
- },
182
- {
183
- label: __("Bottom-right"),
184
- value: "bottom right",
185
- iconClass: "es:bg-linear-to-br",
186
- valueDegrees: 135
187
- },
188
- {
189
- label: __("Bottom-left"),
190
- value: "bottom left",
191
- iconClass: "es:bg-linear-to-bl",
192
- valueDegrees: 225
193
- }
194
- ];
195
- /**
196
- * A simple gradient editor.
197
- * Allows editing linear, radial, and conic gradients.
198
- *
199
- * @component
200
- * @param {Object} props - Component props.
201
- * @param {string} props.value - The gradient definition.
202
- * @param {Function} props.onChange - Function to run when the gradient changes.
203
- * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
204
- *
205
- * @returns {JSX.Element} The GradientEditor component.
206
- *
207
- * @example
208
- * <GradientEditor
209
- * value='linear-gradient(90deg, #000000 0%, #ffffff 100%)'
210
- * onChange={setGradient}
211
- * />
212
- *
213
- * @preserve
214
- */
215
- const GradientEditor = (props) => {
216
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
217
- const { value, onChange, hidden } = props;
218
- const gradientData = useMemo(() => {
219
- if ((value == null ? void 0 : value.startsWith("radial-gradient")) || (value == null ? void 0 : value.startsWith("repeating-radial-gradient"))) {
220
- return K(value ?? "");
221
- }
222
- if ((value == null ? void 0 : value.startsWith("conic-gradient")) || (value == null ? void 0 : value.startsWith("repeating-conic-gradient"))) {
223
- return j(value ?? "");
224
- }
225
- return P(value ?? "");
226
- }, [value]);
227
- const gradientType = useMemo(() => {
228
- if (typeof value === "string" && (value == null ? void 0 : value.startsWith("radial-gradient")) || (value == null ? void 0 : value.startsWith("repeating-radial-gradient"))) {
229
- return "radial";
230
- }
231
- if (typeof value === "string" && (value == null ? void 0 : value.startsWith("conic-gradient")) || (value == null ? void 0 : value.startsWith("repeating-conic-gradient"))) {
232
- return "conic";
233
- }
234
- return "linear";
235
- }, [value]);
236
- const setGradientData = (data) => {
237
- onChange(getGradientResult(data, gradientType));
238
- };
239
- const outputGradient = useMemo(() => getGradientResult(gradientData, gradientType), [gradientData, gradientType]);
240
- const [squarePreview, setSquarePreview] = useState(false);
241
- if (hidden) {
242
- return null;
243
- }
244
- return /* @__PURE__ */ jsxs("div", { className: "es:w-full es:space-y-2.5", children: [
245
- /* @__PURE__ */ jsx(
246
- "button",
247
- {
248
- className: clsx(
249
- "es:shadow-sm, es:mx-auto es:block es:h-40 es:cursor-pointer es:rounded-lg es:border es:border-secondary-300 es:transition-[width]",
250
- squarePreview ? "es:w-40" : "es:w-full"
251
- ),
252
- style: { backgroundImage: outputGradient },
253
- onClick: () => setSquarePreview((prev) => !prev),
254
- "aria-label": __("Toggle preview size", "eightshift-ui-components")
255
- }
256
- ),
257
- /* @__PURE__ */ jsx(
258
- OptionSelect,
259
- {
260
- "aria-label": __("Gradient type", "eightshift-ui-components"),
261
- value: gradientType,
262
- onChange: (value2) => onChange(getGradientResult({ stops: gradientData.stops }, value2)),
263
- options: gradientTypes,
264
- wrapperProps: { className: "es:mx-auto es:w-fit" },
265
- type: "toggleButtons"
266
- }
267
- ),
268
- gradientType === "linear" && /* @__PURE__ */ jsxs("div", { className: "es:flex es:items-center es:gap-1", children: [
269
- /* @__PURE__ */ jsx(
270
- NumberPicker,
271
- {
272
- inline: true,
273
- icon: icons.angle,
274
- label: __("Angle", "eightshift-ui-components"),
275
- min: 0,
276
- max: 360,
277
- step: 1,
278
- value: ((_a = gradientData == null ? void 0 : gradientData.orientation) == null ? void 0 : _a.type) === "angular" ? (_c = (_b = gradientData == null ? void 0 : gradientData.orientation) == null ? void 0 : _b.value) == null ? void 0 : _c.value : null,
279
- onChange: (angle) => {
280
- setGradientData({
281
- ...gradientData,
282
- orientation: { type: "angular", value: { value: angle, unit: "deg" } }
283
- });
284
- },
285
- suffix: "°",
286
- size: "small",
287
- className: "es:grow",
288
- placeholder: ((_d = linearDirections.find(({ value: value2 }) => {
289
- var _a2;
290
- return value2 === ((_a2 = gradientData == null ? void 0 : gradientData.orientation) == null ? void 0 : _a2.value);
291
- })) == null ? void 0 : _d.valueDegrees) ?? ""
292
- }
293
- ),
294
- /* @__PURE__ */ jsx(
295
- Menu,
296
- {
297
- triggerIcon: icons.sliders,
298
- triggerProps: {
299
- tooltip: __("Presets", "eightshift-ui-components")
300
- },
301
- keepOpen: true,
302
- children: linearDirections.map(({ label, value: value2, iconClass }) => {
303
- return /* @__PURE__ */ jsx(
304
- MenuItem,
305
- {
306
- icon: /* @__PURE__ */ jsx("div", { className: clsx("es:size-5 es:rounded-sm es:from-secondary-700 es:to-secondary-200", iconClass) }),
307
- onClick: () => {
308
- setGradientData({
309
- ...gradientData,
310
- orientation: { type: "directional", value: value2 }
311
- });
312
- },
313
- children: label
314
- },
315
- value2
316
- );
317
- })
318
- }
319
- )
320
- ] }),
321
- gradientType === "radial" && /* @__PURE__ */ jsxs("div", { className: "es:space-y-2", children: [
322
- /* @__PURE__ */ jsx(
323
- OptionSelect,
324
- {
325
- label: __("Shape", "eightshift-ui-components"),
326
- icon: icons.genericShapesAlt,
327
- inline: true,
328
- options: [
329
- { label: __("Circle", "eightshift-ui-components"), value: "circle" },
330
- { label: __("Ellipse", "eightshift-ui-components"), value: "ellipse" }
331
- ],
332
- value: gradientData.shape,
333
- onChange: (value2) => {
334
- setGradientData({
335
- ...gradientData,
336
- shape: value2
337
- });
338
- }
339
- }
340
- ),
341
- /* @__PURE__ */ jsx(
342
- MatrixAlign,
343
- {
344
- icon: icons.centerPoint,
345
- label: __("Center point", "eightshift-ui-components"),
346
- value: `${((_f = (_e = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _e.y) == null ? void 0 : _f.value) ?? "center"} ${((_h = (_g = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _g.x) == null ? void 0 : _h.value) ?? "center"}`,
347
- onChange: (position) => {
348
- const [x2, y2] = position.split(" ");
349
- setGradientData({
350
- ...gradientData,
351
- position: {
352
- x: { type: "keyword", value: x2 },
353
- y: { type: "keyword", value: y2 }
354
- }
355
- });
356
- }
357
- }
358
- )
359
- ] }),
360
- gradientType === "conic" && /* @__PURE__ */ jsxs("div", { className: "es:space-y-2", children: [
361
- /* @__PURE__ */ jsx(
362
- NumberPicker,
363
- {
364
- inline: true,
365
- icon: icons.angle,
366
- label: __("Angle", "eightshift-ui-components"),
367
- min: 0,
368
- max: 360,
369
- step: 1,
370
- value: parseInt(gradientData == null ? void 0 : gradientData.angle.replace("deg", "")),
371
- onChange: (value2) => {
372
- setGradientData({
373
- ...gradientData,
374
- angle: `${value2}deg`
375
- });
376
- },
377
- size: "small",
378
- suffix: "°",
379
- className: "es:grow"
380
- }
381
- ),
382
- /* @__PURE__ */ jsx(
383
- MatrixAlign,
384
- {
385
- icon: icons.centerPoint,
386
- label: __("Center point", "eightshift-ui-components"),
387
- value: `${((_j = (_i = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _i.y) == null ? void 0 : _j.value) ?? "center"} ${((_l = (_k = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _k.x) == null ? void 0 : _l.value) ?? "center"}`,
388
- onChange: (value2) => {
389
- setGradientData({
390
- ...gradientData,
391
- position: value2
392
- });
393
- }
394
- }
395
- )
396
- ] }),
397
- /* @__PURE__ */ jsx(
398
- Toggle,
399
- {
400
- checked: gradientData.repeating,
401
- onChange: (value2) => {
402
- setGradientData({
403
- ...gradientData,
404
- repeating: value2
405
- });
406
- },
407
- label: __("Repeating", "eightshift-ui-components"),
408
- icon: icons.gradientRepeat
409
- }
410
- ),
411
- /* @__PURE__ */ jsx(Spacer, { border: true }),
412
- /* @__PURE__ */ jsx(
413
- DraggableList,
414
- {
415
- items: gradientData == null ? void 0 : gradientData.stops,
416
- onChange: (items) => {
417
- setGradientData({
418
- ...gradientData,
419
- stops: items.map(({ color }, i) => ({
420
- ...gradientData.stops[i] ?? {},
421
- color
422
- }))
423
- });
424
- },
425
- icon: icons.gradientStop,
426
- label: __("Gradient stops", "eightshift-ui-components"),
427
- actions: /* @__PURE__ */ jsx(
428
- Button,
429
- {
430
- icon: icons.add,
431
- size: "small",
432
- onPress: () => {
433
- setGradientData({
434
- ...gradientData,
435
- stops: [...gradientData.stops, { color: "#000000FF" }]
436
- });
437
- },
438
- "aria-label": __("Add stop", "eightshift-ui-components")
439
- }
440
- ),
441
- children: (item) => {
442
- const { color, updateData, itemIndex } = item;
443
- return /* @__PURE__ */ jsx(
444
- DraggableListItem,
445
- {
446
- label: sprintf(__("Stop %s", "eightshift-ui-components"), itemIndex + 1),
447
- subtitle: color,
448
- icon: /* @__PURE__ */ jsx(
449
- $251c695a52d94a8d$export$cae13e90592f246a,
450
- {
451
- className: "es:size-5 es:rounded-full es:border es:border-white es:ring-1 es:ring-black",
452
- color
453
- }
454
- ),
455
- textValue: sprintf(__("Stop %s", "eightshift-ui-components"), itemIndex + 1),
456
- children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [
457
- /* @__PURE__ */ jsx(
458
- TriggeredPopover,
459
- {
460
- triggerButtonIcon: icons.color,
461
- triggerButtonProps: { size: "small" },
462
- children: /* @__PURE__ */ jsx(
463
- SolidColorPicker,
464
- {
465
- value: color,
466
- onChange: (color2) => {
467
- updateData({ color: color2 });
468
- },
469
- allowTransparency: true,
470
- outputFormat: "rgba"
471
- }
472
- )
473
- }
474
- ),
475
- /* @__PURE__ */ jsx(
476
- Button,
477
- {
478
- onPress: () => {
479
- setGradientData({
480
- ...gradientData,
481
- stops: gradientData.stops.filter((_, i) => i !== itemIndex)
482
- });
483
- },
484
- icon: icons.trash,
485
- size: "small",
486
- "aria-label": __("Delete stop", "eightshift-ui-components"),
487
- disabled: gradientData.stops.length <= 2
488
- }
489
- )
490
- ] })
491
- }
492
- );
493
- }
494
- },
495
- (_m = gradientData == null ? void 0 : gradientData.stops) == null ? void 0 : _m.length
496
- ),
497
- /* @__PURE__ */ jsx(
498
- Slider,
499
- {
500
- "aria-label": __("Stop positions", "eightshift-ui-components"),
501
- min: 0,
502
- max: 100,
503
- step: 1,
504
- value: (_n = gradientData == null ? void 0 : gradientData.stops) == null ? void 0 : _n.map(({ offset }, i) => {
505
- if (!offset) {
506
- return i * 100 / (gradientData.stops.length - 1);
507
- }
508
- return parseInt(offset == null ? void 0 : offset.value);
509
- }),
510
- onChange: (value2) => {
511
- setGradientData({
512
- ...gradientData,
513
- stops: gradientData.stops.map((stop, i) => {
514
- return {
515
- ...stop,
516
- offset: { value: value2[i], unit: "%" }
517
- };
518
- })
519
- });
520
- },
521
- thumbContent: (index) => /* @__PURE__ */ jsx("div", { className: "es:pointer-events-none es:absolute es:inset-0 es:flex es:size-3 es:items-center es:justify-center es:text-center es:text-xs es:font-semibold es:text-white", children: index + 1 }),
522
- trackStyle: {
523
- backgroundImage: getGradientResult({ orientation: { type: "directional", value: "right" }, stops: gradientData.stops }, "linear"),
524
- height: "1.125rem",
525
- borderRadius: "0.5rem"
526
- },
527
- noActiveHighlight: true
528
- }
529
- )
530
- ] });
531
- };
532
- export {
533
- GradientEditor
534
- };