@eightshift/ui-components 7.1.0 → 7.2.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 (102) hide show
  1. package/dist/assets/fonts/geist-latin-400-normal.woff2 +0 -0
  2. package/dist/assets/fonts/geist-latin-500-normal.woff2 +0 -0
  3. package/dist/assets/fonts/geist-latin-700-normal.woff2 +0 -0
  4. package/dist/assets/fonts/geist-latin-ext-400-normal.woff2 +0 -0
  5. package/dist/assets/fonts/geist-latin-ext-500-normal.woff2 +0 -0
  6. package/dist/assets/fonts/geist-latin-ext-700-normal.woff2 +0 -0
  7. package/dist/assets/fonts/geist-mono-latin-400-normal.woff2 +0 -0
  8. package/dist/assets/fonts/geist-mono-latin-500-normal.woff2 +0 -0
  9. package/dist/assets/fonts/geist-mono-latin-700-normal.woff2 +0 -0
  10. package/dist/assets/fonts/geist-mono-latin-ext-400-normal.woff2 +0 -0
  11. package/dist/assets/fonts/geist-mono-latin-ext-500-normal.woff2 +0 -0
  12. package/dist/assets/fonts/geist-mono-latin-ext-700-normal.woff2 +0 -0
  13. package/dist/assets/fonts/google-sans-flex-latin-ext-full-normal.woff2 +0 -0
  14. package/dist/assets/fonts/google-sans-flex-latin-full-normal.woff2 +0 -0
  15. package/dist/assets/fonts/google-sans-flex-symbols-full-normal.woff2 +0 -0
  16. package/dist/assets/style-admin.css +3 -12528
  17. package/dist/assets/style-editor.css +3 -12492
  18. package/dist/assets/style.css +3 -12498
  19. package/dist/assets/wp-overrides/allow-full-width-blocks.css +1 -5
  20. package/dist/assets/wp-overrides/fix-label-text-case.css +1 -28
  21. package/dist/assets/wp-overrides/increase-sidebar-width.css +1 -3
  22. package/dist/assets/wp-overrides/make-block-messages-nicer.css +1 -154
  23. package/dist/assets/wp-overrides/replace-fonts.css +1 -7
  24. package/dist/assets/wp-overrides/restyle-tooltips.css +1 -193
  25. package/dist/assets/wp-overrides/round-corners.css +1 -199
  26. package/dist/assets/wp-overrides/unify-button-sizes.css +1 -4
  27. package/dist/{button-COTeluL8.js → button-D9cbyHeZ.js} +2 -2
  28. package/dist/{checkbox-D0AWkLhp.js → checkbox-BO5RZmO8.js} +1 -1
  29. package/dist/{color-swatch-CBYsO_Zs.js → color-swatch-D2ZBkuTt.js} +1 -1
  30. package/dist/components/base-control/container.js +1 -1
  31. package/dist/components/button/button.js +1 -2
  32. package/dist/components/checkbox/checkbox.js +1 -1
  33. package/dist/components/color-pickers/color-picker.js +2 -2
  34. package/dist/components/color-pickers/color-swatch.js +1 -2
  35. package/dist/components/color-pickers/gradient-editor.js +1 -3
  36. package/dist/components/color-pickers/solid-color-picker.js +1 -2
  37. package/dist/components/component-toggle/component-toggle.js +4 -4
  38. package/dist/components/container-panel/container-panel.js +2 -3
  39. package/dist/components/draggable/draggable-handle.js +1 -1
  40. package/dist/components/draggable/draggable.js +1 -2
  41. package/dist/components/draggable-list/draggable-list-item.js +1 -1
  42. package/dist/components/draggable-list/draggable-list.js +2 -2
  43. package/dist/components/expandable/expandable.js +2 -2
  44. package/dist/components/index.js +14 -16
  45. package/dist/components/input-field/input-field.js +1 -1
  46. package/dist/components/item-collection/item-collection.js +1 -1
  47. package/dist/components/link-input/link-input.js +1 -2
  48. package/dist/components/matrix-align/matrix-align.js +1 -1
  49. package/dist/components/menu/menu.js +2 -2
  50. package/dist/components/modal/modal.js +1 -2
  51. package/dist/components/number-picker/number-picker.js +1 -2
  52. package/dist/components/option-select/option-select.js +3 -3
  53. package/dist/components/placeholders/file-picker-shell.js +1 -2
  54. package/dist/components/placeholders/file-placeholder.js +1 -1
  55. package/dist/components/popover/popover.js +2 -2
  56. package/dist/components/radio/radio.js +1 -1
  57. package/dist/components/repeater/repeater-item.js +2 -2
  58. package/dist/components/repeater/repeater.js +3 -3
  59. package/dist/components/responsive/mini-responsive.js +2 -2
  60. package/dist/components/responsive/responsive-legacy.js +3 -3
  61. package/dist/components/responsive/responsive.js +3 -3
  62. package/dist/components/responsive-preview/responsive-preview.js +1 -1
  63. package/dist/components/select/async-multi-select.js +2 -2
  64. package/dist/components/select/async-select.js +2 -2
  65. package/dist/components/select/multi-select.js +2 -2
  66. package/dist/components/select/shared.js +1 -2
  67. package/dist/components/select/single-select.js +2 -2
  68. package/dist/components/select/styles.js +1 -1
  69. package/dist/components/slider/column-config-slider.js +1 -1
  70. package/dist/components/slider/slider.js +1 -2
  71. package/dist/components/slider/utils.js +1 -1
  72. package/dist/components/smart-image/smart-image.js +1 -2
  73. package/dist/components/tabs/tabs.js +1 -2
  74. package/dist/components/toggle/switch.js +1 -1
  75. package/dist/components/toggle/toggle.js +1 -1
  76. package/dist/components/toggle-button/toggle-button.js +1 -1
  77. package/dist/{draggable-CYQyD9gG.js → draggable-CTDVJ4zd.js} +1 -1
  78. package/dist/gradient-editor-xfxA_s9a.js +1583 -0
  79. package/dist/icons/index.js +1 -1
  80. package/dist/icons/jsx-svg.js +1 -1
  81. package/dist/index.js +14 -16
  82. package/dist/{input-field-UCZL5bqv.js → input-field-_OCWbftf.js} +1 -1
  83. package/dist/{link-input-D7iDRpOM.js → link-input-Bh8G7Urm.js} +2 -2
  84. package/dist/{modal-DbVLYMkH.js → modal-snrElwty.js} +2 -2
  85. package/dist/{number-picker-CkA1iJNZ.js → number-picker-Dhtx4409.js} +3 -2
  86. package/dist/{shared-D_OXizRt.js → shared-BiWZjrGF.js} +1 -1
  87. package/dist/{smart-image-CbSsEASF.js → smart-image-CBNbxJ57.js} +1 -1
  88. package/dist/{solid-color-picker-DbT-aoVx.js → solid-color-picker-DukArNH-.js} +2 -2
  89. package/dist/{switch-L8dFSQWQ.js → switch-DmsvyQPa.js} +1 -1
  90. package/dist/{tabs-BrdyBER5.js → tabs-DaIUEc0g.js} +2 -2
  91. package/dist/{toggle-button-DJ8jNQ-9.js → toggle-button-BlzUGfGy.js} +1 -1
  92. package/dist/utilities/general.js +25 -2
  93. package/dist/utilities/index.js +3 -3
  94. package/package.json +4 -7
  95. package/dist/general-BKOvs-AO.js +0 -4276
  96. package/dist/gradient-editor-BAd_Gzx4.js +0 -604
  97. package/dist/workers/image-analysis.worker.js +0 -60
  98. /package/dist/{List-CMK5qsNF.js → List-DWlgW2Ex.js} +0 -0
  99. /package/dist/{build-module-sxK3nxOK.js → build-module-Bsx62nlm.js} +0 -0
  100. /package/dist/{dist-DIK9pFxO.js → dist-2gkv7_1U.js} +0 -0
  101. /package/dist/{jsx-svg-OBADs_Qs.js → jsx-svg-BRJ4n3pD.js} +0 -0
  102. /package/dist/{utilities-CPFDXC3B.js → utilities-lwX686oD.js} +0 -0
@@ -1,604 +0,0 @@
1
- import { t as clsx } from "./clsx-BUU5J41u.js";
2
- import { n as ButtonGroup, t as Button } from "./button-COTeluL8.js";
3
- import { n as $251c695a52d94a8d$export$cae13e90592f246a } from "./color-swatch-CBYsO_Zs.js";
4
- import { t as SolidColorPicker } from "./solid-color-picker-DbT-aoVx.js";
5
- import { t as NumberPicker } from "./number-picker-CkA1iJNZ.js";
6
- import { BaseControl } from "./components/base-control/base-control.js";
7
- import { o as isColorDark, s as srgb } from "./general-BKOvs-AO.js";
8
- import { r as sprintf, t as __ } from "./build-module-sxK3nxOK.js";
9
- import { add } from "./icons/ui-icons/add.js";
10
- import { angle } from "./icons/ui-icons/angle.js";
11
- import { centerPoint } from "./icons/ui-icons/center-point.js";
12
- import { genericShapesAlt } from "./icons/ui-icons/generic-shapes-alt.js";
13
- import { gradientRepeat } from "./icons/ui-icons/gradient-repeat.js";
14
- import { gradientStop } from "./icons/ui-icons/gradient-stop.js";
15
- import { sliders } from "./icons/ui-icons/sliders.js";
16
- import { trash } from "./icons/ui-icons/trash.js";
17
- import { TriggeredPopover } from "./components/popover/popover.js";
18
- import { Menu, MenuItem } from "./components/menu/menu.js";
19
- import { Container, ContainerGroup } from "./components/base-control/container.js";
20
- import { DraggableList } from "./components/draggable-list/draggable-list.js";
21
- import { DraggableListItem } from "./components/draggable-list/draggable-list-item.js";
22
- import { Slider } from "./components/slider/slider.js";
23
- import { MatrixAlign } from "./components/matrix-align/matrix-align.js";
24
- import { Toggle } from "./components/toggle/toggle.js";
25
- import { OptionSelect } from "./components/option-select/option-select.js";
26
- import { useMemo, useState } from "react";
27
- import { jsx, jsxs } from "react/jsx-runtime";
28
- //#region node_modules/css-gradient-parser/dist/index.js
29
- function c(e, o = ",") {
30
- let t = [], n = 0, i = 0;
31
- o = new RegExp(o);
32
- 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);
33
- return t.push(e.slice(n).trim()), t;
34
- }
35
- function g(e) {
36
- let o = [];
37
- for (let t = 0, n = e.length; t < n;) {
38
- let [i, r] = c(e[t], /\s+/);
39
- m(e[t + 1]) ? (o.push({
40
- color: i,
41
- offset: l(r),
42
- hint: l(e[t + 1])
43
- }), t += 2) : (o.push({
44
- color: i,
45
- offset: l(r)
46
- }), t++);
47
- }
48
- return o;
49
- }
50
- var u = /^(-?\d+\.?\d*)(%|vw|vh|px|em|rem|deg|rad|grad|turn|ch|vmin|vmax)?$/;
51
- function m(e) {
52
- return u.test(e);
53
- }
54
- function l(e) {
55
- if (!e) return;
56
- let [, o, t] = e.trim().match(u) || [];
57
- return {
58
- value: o,
59
- unit: t ?? "px"
60
- };
61
- }
62
- function P(e) {
63
- if (!/^(repeating-)?linear-gradient/.test(e)) throw new SyntaxError(`could not find syntax for this item: ${e}`);
64
- let [, o, t] = e.match(/(repeating-)?linear-gradient\((.+)\)/), n = {
65
- orientation: {
66
- type: "directional",
67
- value: "bottom"
68
- },
69
- repeating: !!o,
70
- stops: []
71
- }, i = c(t), r = x(i[0]);
72
- return r && (n.orientation = r, i.shift()), {
73
- ...n,
74
- stops: g(i)
75
- };
76
- }
77
- function x(e) {
78
- return e.startsWith("to ") ? {
79
- type: "directional",
80
- value: e.replace("to ", "")
81
- } : [
82
- "turn",
83
- "deg",
84
- "grad",
85
- "rad"
86
- ].some((o) => e.endsWith(o)) ? {
87
- type: "angular",
88
- value: l(e)
89
- } : null;
90
- }
91
- var v = new Set([
92
- "closest-corner",
93
- "closest-side",
94
- "farthest-corner",
95
- "farthest-side"
96
- ]), w = new Set([
97
- "center",
98
- "left",
99
- "top",
100
- "right",
101
- "bottom"
102
- ]);
103
- function d(e) {
104
- return v.has(e);
105
- }
106
- function h(e) {
107
- return w.has(e);
108
- }
109
- function R(e) {
110
- let o = Array(2).fill("");
111
- for (let t = 0; t < 2; t++) e[t] ? o[t] = e[t] : o[t] = "center";
112
- return o;
113
- }
114
- function K(e) {
115
- if (!/(repeating-)?radial-gradient/.test(e)) throw new SyntaxError(`could not find syntax for this item: ${e}`);
116
- let [, o, t] = e.match(/(repeating-)?radial-gradient\((.+)\)/), n = {
117
- shape: "ellipse",
118
- repeating: !!o,
119
- size: [{
120
- type: "keyword",
121
- value: "farthest-corner"
122
- }],
123
- position: {
124
- x: {
125
- type: "keyword",
126
- value: "center"
127
- },
128
- y: {
129
- type: "keyword",
130
- value: "center"
131
- }
132
- },
133
- stops: []
134
- }, i = c(t);
135
- if (S(i[0])) return {
136
- ...n,
137
- stops: g(i)
138
- };
139
- 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(" "));
140
- 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) ? {
141
- type: "keyword",
142
- value: f
143
- } : {
144
- type: "length",
145
- value: l(f)
146
- }), n.position.x = h(s[0]) ? {
147
- type: "keyword",
148
- value: s[0]
149
- } : {
150
- type: "length",
151
- value: l(s[0])
152
- }, n.position.y = h(s[1]) ? {
153
- type: "keyword",
154
- value: s[1]
155
- } : {
156
- type: "length",
157
- value: l(s[1])
158
- }, (p || a.length > 0 || r[1]) && i.shift(), {
159
- ...n,
160
- stops: g(i)
161
- };
162
- }
163
- function S(e) {
164
- return /(circle|ellipse|at)/.test(e) ? !1 : /^(rgba?|hwb|hsla?|lab|lch|oklab|color|#|[a-zA-Z]+)/.test(e);
165
- }
166
- var C = new Set([
167
- "from",
168
- "in",
169
- "at"
170
- ]);
171
- function j(e) {
172
- if (!/(repeating-)?conic-gradient/.test(e)) throw new SyntaxError(`could not find syntax for this item: ${e}`);
173
- let [, o, t] = e.match(/(repeating-)?conic-gradient\((.+)\)/), n = {
174
- angle: "0deg",
175
- repeating: !!o,
176
- position: "center",
177
- stops: []
178
- }, i = c(t).map((s) => s.trim()), r = c(i[0], /\s+/), p = "", a = 0;
179
- 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);
180
- return p && (Object.assign(n, y(p, r, a, r.length)), i.shift()), {
181
- ...n,
182
- stops: g(i)
183
- };
184
- }
185
- function y(e, o, t, n) {
186
- switch (e) {
187
- case "from": return { angle: o.slice(t, n).join(" ") };
188
- case "at": return { position: o.slice(t, n).join(" ") };
189
- case "in": {
190
- let [i, ...r] = o.slice(t, n);
191
- return { color: {
192
- space: i,
193
- method: r.length > 0 ? r.join(" ") : void 0
194
- } };
195
- }
196
- }
197
- }
198
- //#endregion
199
- //#region lib/components/color-pickers/gradient-editor.jsx
200
- var getGradientResult = (input, type) => {
201
- if (!input || !type) return "";
202
- if (typeof input === "string" || !input?.stops) return "";
203
- let output = "";
204
- const { repeating } = input;
205
- if (repeating) output += "repeating-";
206
- output += `${type}-gradient(`;
207
- if (type === "linear") {
208
- const { orientation } = input;
209
- if (orientation?.type === "angular") output += `${orientation.value.value}${orientation.value.unit}, `;
210
- else if (orientation?.type === "directional") output += `to ${orientation.value}, `;
211
- }
212
- if (type === "radial") {
213
- const { shape, position } = input;
214
- output += `${shape ?? "circle"} at ${position?.x?.value ?? "center"} ${position?.y?.value ?? "center"}, `;
215
- }
216
- if (type === "conic") {
217
- const { angle, position } = input;
218
- output += `from ${angle ?? "0deg"} at ${position ?? "center"}, `;
219
- }
220
- output += input.stops.map((stop) => {
221
- return `${stop.color} ${stop.offset?.value ?? ""}${stop.offset?.unit ?? ""}`.trim();
222
- }).join(", ");
223
- output += ")";
224
- return output;
225
- };
226
- var gradientTypes = [
227
- {
228
- label: __("Linear"),
229
- value: "linear",
230
- icon: jsx("div", { className: "es:transparent es:size-4 es:rounded-full es:bg-linear-to-br es:from-current" })
231
- },
232
- {
233
- label: __("Radial"),
234
- value: "radial",
235
- icon: jsx("div", { className: "es:transparent es:size-4 es:rounded-full es:bg-radial es:from-current/75 es:to-current/10" })
236
- },
237
- {
238
- label: __("Conic"),
239
- value: "conic",
240
- icon: jsx("div", { className: "es:transparent es:size-4 es:rounded-full es:bg-conic es:from-current" })
241
- }
242
- ];
243
- var linearDirections = [
244
- {
245
- label: __("Right"),
246
- value: "right",
247
- iconClass: "es:bg-linear-to-r",
248
- valueDegrees: 90
249
- },
250
- {
251
- label: __("Left"),
252
- value: "left",
253
- iconClass: "es:bg-linear-to-l",
254
- valueDegrees: 180
255
- },
256
- {
257
- label: __("Top"),
258
- value: "top",
259
- iconClass: "es:bg-linear-to-t",
260
- valueDegrees: 270
261
- },
262
- {
263
- label: __("Bottom"),
264
- value: "bottom",
265
- iconClass: "es:bg-linear-to-b",
266
- valueDegrees: 90
267
- },
268
- {
269
- label: __("Top-right"),
270
- value: "top right",
271
- iconClass: "es:bg-linear-to-tr",
272
- valueDegrees: 45
273
- },
274
- {
275
- label: __("Top-left"),
276
- value: "top left",
277
- iconClass: "es:bg-linear-to-tl",
278
- valueDegrees: 315
279
- },
280
- {
281
- label: __("Bottom-right"),
282
- value: "bottom right",
283
- iconClass: "es:bg-linear-to-br",
284
- valueDegrees: 135
285
- },
286
- {
287
- label: __("Bottom-left"),
288
- value: "bottom left",
289
- iconClass: "es:bg-linear-to-bl",
290
- valueDegrees: 225
291
- }
292
- ];
293
- /**
294
- * A simple gradient editor.
295
- * Allows editing linear, radial, and conic gradients.
296
- *
297
- * @component
298
- * @param {Object} props - Component props.
299
- * @param {string} props.value - The gradient definition.
300
- * @param {Function} props.onChange - Function to run when the gradient changes.
301
- * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
302
- *
303
- * @returns {JSX.Element} The GradientEditor component.
304
- *
305
- * @example
306
- * <GradientEditor
307
- * value='linear-gradient(90deg, #000000 0%, #ffffff 100%)'
308
- * onChange={setGradient}
309
- * />
310
- */
311
- var GradientEditor = (props) => {
312
- const { value, onChange, hidden } = props;
313
- const gradientData = useMemo(() => {
314
- if (value?.startsWith("radial-gradient") || value?.startsWith("repeating-radial-gradient")) return K(value ?? "");
315
- if (value?.startsWith("conic-gradient") || value?.startsWith("repeating-conic-gradient")) return j(value ?? "");
316
- return P(value ?? "");
317
- }, [value]);
318
- const gradientType = useMemo(() => {
319
- if (typeof value === "string" && value?.startsWith("radial-gradient") || value?.startsWith("repeating-radial-gradient")) return "radial";
320
- if (typeof value === "string" && value?.startsWith("conic-gradient") || value?.startsWith("repeating-conic-gradient")) return "conic";
321
- return "linear";
322
- }, [value]);
323
- const setGradientData = (data) => {
324
- onChange(getGradientResult(data, gradientType));
325
- };
326
- const outputGradient = useMemo(() => getGradientResult(gradientData, gradientType), [gradientData, gradientType]);
327
- const [squarePreview, setSquarePreview] = useState(false);
328
- if (hidden) return null;
329
- return jsxs("div", {
330
- className: "es:w-full es:space-y-2.5",
331
- children: [
332
- jsx(ContainerGroup, { children: jsxs(Container, { children: [jsx("button", {
333
- className: clsx("es:shadow-sm, es:mx-auto es:block es:h-40 es:rounded-lg es:border es:border-secondary-300 es:transition-[width] es:duration-300 es:ease-spring-snappy", "es:mb-2", squarePreview ? "es:w-40" : "es:w-full"),
334
- style: { backgroundImage: outputGradient },
335
- onClick: () => setSquarePreview((prev) => !prev),
336
- "aria-label": __("Toggle preview size", "eightshift-ui-components")
337
- }), jsx(Slider, {
338
- className: "es:mb-5",
339
- "aria-label": __("Stop positions", "eightshift-ui-components"),
340
- min: 0,
341
- max: 100,
342
- step: 1,
343
- value: gradientData?.stops?.map(({ offset }, i) => {
344
- if (!offset) return i * 100 / (gradientData.stops.length - 1);
345
- return parseInt(offset?.value);
346
- }),
347
- onChange: (value) => {
348
- setGradientData({
349
- ...gradientData,
350
- stops: gradientData.stops.map((stop, i) => {
351
- return {
352
- ...stop,
353
- offset: {
354
- value: value[i],
355
- unit: "%"
356
- }
357
- };
358
- })
359
- });
360
- },
361
- thumbContent: (index) => {
362
- const colorData = srgb(gradientData.stops[index]?.color);
363
- let foregroundColor = "black";
364
- if (colorData.alpha >= .5 && isColorDark(colorData.r, colorData.g, colorData.b)) foregroundColor = "white";
365
- return jsx("div", {
366
- className: "es:pointer-events-none es:absolute es:-bottom-4.5 es:-translate-x-1/3 es:flex es:w-3 es:items-center es:justify-center es:text-center es:text-12 es:leading-none es:py-px es:rounded-sm es:font-semibold es:tabular-nums es:font-mono es:ring es:ring-accent-600",
367
- style: {
368
- backgroundColor: gradientData.stops[index]?.color,
369
- color: foregroundColor
370
- },
371
- children: index + 1
372
- });
373
- },
374
- noActiveHighlight: true,
375
- tooltipContent: (value) => `${Math.round(value)}%`
376
- })] }) }),
377
- jsxs(ContainerGroup, { children: [
378
- jsx(Container, { children: jsx(OptionSelect, {
379
- label: __("Type", "eightshift-ui-components"),
380
- value: gradientType,
381
- onChange: (value) => onChange(getGradientResult({ stops: gradientData.stops }, value)),
382
- options: gradientTypes,
383
- type: "toggleButtons",
384
- inline: true
385
- }) }),
386
- jsx(Container, {
387
- hidden: gradientType !== "linear",
388
- children: jsx(NumberPicker, {
389
- inline: true,
390
- icon: angle,
391
- label: __("Angle", "eightshift-ui-components"),
392
- min: 0,
393
- max: 360,
394
- step: 1,
395
- value: gradientData?.orientation?.type === "angular" ? gradientData?.orientation?.value?.value : null,
396
- onChange: (angle) => {
397
- setGradientData({
398
- ...gradientData,
399
- orientation: {
400
- type: "angular",
401
- value: {
402
- value: angle,
403
- unit: "deg"
404
- }
405
- }
406
- });
407
- },
408
- suffix: "°",
409
- size: "medium",
410
- className: "es:grow",
411
- placeholder: linearDirections.find(({ value }) => value === gradientData?.orientation?.value)?.valueDegrees ?? "",
412
- children: jsx(Menu, {
413
- triggerIcon: sliders,
414
- triggerProps: {
415
- tooltip: __("Presets", "eightshift-ui-components"),
416
- slot: null
417
- },
418
- keepOpen: true,
419
- children: linearDirections.map(({ label, value, iconClass }) => {
420
- return jsx(MenuItem, {
421
- icon: jsx("div", { className: clsx("es:size-5 es:rounded-sm es:from-secondary-700 es:to-secondary-200", iconClass) }),
422
- onClick: () => {
423
- setGradientData({
424
- ...gradientData,
425
- orientation: {
426
- type: "directional",
427
- value
428
- }
429
- });
430
- },
431
- children: label
432
- }, value);
433
- })
434
- })
435
- })
436
- }),
437
- jsx(Container, {
438
- hidden: gradientType !== "radial",
439
- children: jsx(OptionSelect, {
440
- label: __("Shape", "eightshift-ui-components"),
441
- icon: genericShapesAlt,
442
- inline: true,
443
- options: [{
444
- label: __("Circle", "eightshift-ui-components"),
445
- value: "circle"
446
- }, {
447
- label: __("Ellipse", "eightshift-ui-components"),
448
- value: "ellipse"
449
- }],
450
- value: gradientData.shape,
451
- onChange: (value) => {
452
- setGradientData({
453
- ...gradientData,
454
- shape: value
455
- });
456
- }
457
- })
458
- }),
459
- jsx(Container, {
460
- hidden: gradientType !== "radial",
461
- children: jsx(MatrixAlign, {
462
- icon: centerPoint,
463
- label: __("Center point", "eightshift-ui-components"),
464
- value: `${gradientData?.position?.y?.value ?? "center"} ${gradientData?.position?.x?.value ?? "center"}`,
465
- onChange: (position) => {
466
- const [x, y] = position.split(" ");
467
- setGradientData({
468
- ...gradientData,
469
- position: {
470
- x: {
471
- type: "keyword",
472
- value: x
473
- },
474
- y: {
475
- type: "keyword",
476
- value: y
477
- }
478
- }
479
- });
480
- }
481
- })
482
- }),
483
- jsx(Container, {
484
- hidden: gradientType !== "conic",
485
- children: jsx(NumberPicker, {
486
- inline: true,
487
- icon: angle,
488
- label: __("Angle", "eightshift-ui-components"),
489
- min: 0,
490
- max: 360,
491
- step: 1,
492
- value: parseInt(gradientData?.angle?.replace("deg", "")),
493
- onChange: (value) => {
494
- setGradientData({
495
- ...gradientData,
496
- angle: `${value}deg`
497
- });
498
- },
499
- size: "medium",
500
- suffix: "°"
501
- })
502
- }),
503
- jsx(Container, {
504
- hidden: gradientType !== "conic",
505
- children: jsx(MatrixAlign, {
506
- icon: centerPoint,
507
- label: __("Center point", "eightshift-ui-components"),
508
- value: `${gradientData?.position?.y?.value ?? "center"} ${gradientData?.position?.x?.value ?? "center"}`,
509
- onChange: (value) => {
510
- setGradientData({
511
- ...gradientData,
512
- position: value
513
- });
514
- }
515
- })
516
- }),
517
- jsx(Container, { children: jsx(Toggle, {
518
- checked: gradientData.repeating,
519
- onChange: (value) => {
520
- setGradientData({
521
- ...gradientData,
522
- repeating: value
523
- });
524
- },
525
- label: __("Repeating", "eightshift-ui-components"),
526
- icon: gradientRepeat
527
- }) })
528
- ] }),
529
- jsx(BaseControl, {
530
- icon: gradientStop,
531
- label: __("Gradient stops", "eightshift-ui-components"),
532
- inline: true,
533
- children: jsx(Button, {
534
- icon: add,
535
- size: "small",
536
- onPress: () => {
537
- setGradientData({
538
- ...gradientData,
539
- stops: [...gradientData.stops, { color: "#000000FF" }]
540
- });
541
- },
542
- type: "simple",
543
- "aria-label": __("Add stop", "eightshift-ui-components")
544
- })
545
- }),
546
- jsx(ContainerGroup, { children: jsx(DraggableList, {
547
- items: gradientData?.stops,
548
- onChange: (items) => {
549
- setGradientData({
550
- ...gradientData,
551
- stops: items.map(({ color }, i) => ({
552
- ...gradientData.stops[i] ?? {},
553
- color
554
- }))
555
- });
556
- },
557
- orientation: "vertical",
558
- className: "es:contents",
559
- children: (item) => {
560
- const { color, updateData, itemIndex } = item;
561
- return jsx(DraggableListItem, {
562
- label: sprintf(__("Stop %s", "eightshift-ui-components"), itemIndex + 1),
563
- subtitle: color,
564
- icon: jsx(TriggeredPopover, {
565
- triggerButtonIcon: jsx($251c695a52d94a8d$export$cae13e90592f246a, {
566
- className: "es:size-5.5 es:rounded-full es:border es:border-white es:ring-1 es:ring-black",
567
- color
568
- }),
569
- triggerButtonProps: {
570
- size: "small",
571
- type: "ghost",
572
- className: "es:p-0!"
573
- },
574
- className: "es:p-2.5",
575
- children: jsx(SolidColorPicker, {
576
- value: color,
577
- onChange: (color) => {
578
- updateData({ color });
579
- },
580
- allowTransparency: true,
581
- outputFormat: "rgba"
582
- })
583
- }),
584
- children: jsx(ButtonGroup, { children: jsx(Button, {
585
- onPress: () => {
586
- setGradientData({
587
- ...gradientData,
588
- stops: gradientData.stops.filter((_, i) => i !== itemIndex)
589
- });
590
- },
591
- icon: trash,
592
- size: "small",
593
- "aria-label": __("Delete stop", "eightshift-ui-components"),
594
- disabled: gradientData.stops.length <= 2,
595
- type: "dangerGhost"
596
- }) })
597
- });
598
- }
599
- }) })
600
- ]
601
- });
602
- };
603
- //#endregion
604
- export { GradientEditor as t };
@@ -1,60 +0,0 @@
1
- import { c as FLOAT_RGBA, l as floatBufferFromCanvas, r as analyzeImageData } from "../general-BKOvs-AO.js";
2
- //#region lib/workers/image-analysis.worker.js
3
- /**
4
- * Web Worker for image analysis
5
- */
6
- self.onmessage = async (event) => {
7
- const { imageBitmap, settings } = event.data;
8
- try {
9
- const result = await analyzeImageInWorker(imageBitmap, settings);
10
- self.postMessage({
11
- success: true,
12
- data: result
13
- });
14
- } catch (error) {
15
- self.postMessage({
16
- success: false,
17
- error: error.message,
18
- stack: error.stack
19
- });
20
- }
21
- };
22
- async function analyzeImageInWorker(imageBitmap, rawSettings) {
23
- const settings = {
24
- numColors: 3,
25
- lightnessThreshold: .5,
26
- yFrom: 0,
27
- yTo: 1,
28
- maxSize: 600,
29
- alphaThreshold: 50,
30
- ...rawSettings
31
- };
32
- const { yFrom, yTo, maxSize } = settings;
33
- const imageWidth = imageBitmap.width;
34
- const imageHeight = imageBitmap.height;
35
- if (!imageWidth || !imageHeight) return false;
36
- let imageScale = 1;
37
- if (imageWidth > maxSize || imageHeight > maxSize) imageScale = Math.min(maxSize / imageWidth, maxSize / imageHeight);
38
- const imageWidthScaled = Math.floor(imageWidth * imageScale);
39
- const imageHeightScaled = Math.floor(imageHeight * imageScale);
40
- const srcX = 0;
41
- const srcY = Math.floor(yFrom * imageHeight);
42
- const srcW = Math.max(1, imageWidth);
43
- const srcH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeight));
44
- const destW = Math.max(1, imageWidthScaled);
45
- const destH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeightScaled));
46
- const colorCanvas = new OffscreenCanvas(destW, destH);
47
- colorCanvas.getContext("2d").drawImage(imageBitmap, srcX, srcY, srcW, srcH, 0, 0, destW, destH);
48
- const buffer = floatBufferFromCanvas(colorCanvas, FLOAT_RGBA);
49
- const transparencyContext = new OffscreenCanvas(imageWidthScaled, imageHeightScaled).getContext("2d");
50
- transparencyContext.drawImage(imageBitmap, 0, 0, imageWidth, imageHeight, 0, 0, imageWidthScaled, imageHeightScaled);
51
- const imageData = transparencyContext.getImageData(0, 0, imageWidthScaled, imageHeightScaled).data;
52
- return analyzeImageData({
53
- buffer,
54
- imageData,
55
- width: imageWidthScaled,
56
- height: imageHeightScaled,
57
- settings
58
- });
59
- }
60
- //#endregion
File without changes
File without changes