@eightshift/ui-components 5.0.0 → 5.0.2
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.
- package/dist/Button-BpwTmkAe.js +185 -0
- package/dist/Collection-n5d0zIgb.js +2398 -0
- package/dist/Color-lVhk8V_G.js +2452 -0
- package/dist/ColorSwatch-DntWEAC3.js +64 -0
- package/dist/ComboBox-BJpTEATT.js +1915 -0
- package/dist/Dialog-O9uw63D7.js +2317 -0
- package/dist/FieldError-DHrSdE_Q.js +42 -0
- package/dist/FocusScope-BEPI2m7u.js +831 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/Group-DDPhPPTQ.js +48 -0
- package/dist/Heading-ba38ScjJ.js +16 -0
- package/dist/Hidden-rE6uR-lr.js +41 -0
- package/dist/Input-BmDS8Juy.js +133 -0
- package/dist/Label-JS_ob-kh.js +17 -0
- package/dist/List-CZMUbkFU.js +593 -0
- package/dist/ListBox-BTxlCGcc.js +664 -0
- package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
- package/dist/OverlayArrow-5aDgmImj.js +637 -0
- package/dist/RSPContexts-2lR5GG9p.js +14 -0
- package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
- package/dist/Separator-CaTBkETC.js +332 -0
- package/dist/Slider-C-S1oEH9.js +853 -0
- package/dist/Text-BuJgePCv.js +16 -0
- package/dist/VisuallyHidden-BYi0pekx.js +48 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/assets/index.css +57 -0
- package/dist/assets/style-admin.css +5908 -0
- package/dist/assets/style-editor.css +5908 -0
- package/dist/assets/style.css +5914 -0
- package/dist/assets/wp-font-enhancements.css +8 -0
- package/dist/assets/wp-ui-enhancements.css +396 -0
- package/dist/components/animated-visibility/animated-visibility.js +105 -0
- package/dist/components/base-control/base-control.js +86 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
- package/dist/components/button/button.js +387 -0
- package/dist/components/checkbox/checkbox.js +323 -0
- package/dist/components/color-pickers/color-picker.js +272 -0
- package/dist/components/color-pickers/color-swatch.js +59 -0
- package/dist/components/color-pickers/gradient-editor.js +534 -0
- package/dist/components/color-pickers/solid-color-picker.js +1567 -0
- package/dist/components/component-toggle/component-toggle.js +161 -0
- package/dist/components/container-panel/container-panel.js +131 -0
- package/dist/components/draggable/draggable-context.js +5 -0
- package/dist/components/draggable/draggable-handle.js +46 -0
- package/dist/components/draggable/draggable.js +7320 -0
- package/dist/components/draggable-list/draggable-list-context.js +5 -0
- package/dist/components/draggable-list/draggable-list-item.js +77 -0
- package/dist/components/draggable-list/draggable-list.js +151 -0
- package/dist/components/expandable/expandable.js +342 -0
- package/dist/components/index.js +137 -0
- package/dist/components/input-field/input-field.js +231 -0
- package/dist/components/item-collection/item-collection.js +59 -0
- package/dist/components/layout/hstack.js +30 -0
- package/dist/components/layout/vstack.js +30 -0
- package/dist/components/link-input/link-input.js +284 -0
- package/dist/components/matrix-align/matrix-align.js +134 -0
- package/dist/components/menu/menu.js +285 -0
- package/dist/components/modal/modal.js +305 -0
- package/dist/components/notice/notice.js +123 -0
- package/dist/components/number-picker/number-picker.js +292 -0
- package/dist/components/option-select/option-select.js +264 -0
- package/dist/components/options-panel/options-panel.js +158 -0
- package/dist/components/placeholders/file-placeholder.js +42 -0
- package/dist/components/placeholders/image-placeholder.js +88 -0
- package/dist/components/placeholders/media-placeholder.js +63 -0
- package/dist/components/popover/popover.js +207 -0
- package/dist/components/radio/radio.js +582 -0
- package/dist/components/repeater/repeater-context.js +5 -0
- package/dist/components/repeater/repeater-item.js +119 -0
- package/dist/components/repeater/repeater.js +280 -0
- package/dist/components/responsive/mini-responsive.js +498 -0
- package/dist/components/responsive/responsive-legacy.js +343 -0
- package/dist/components/responsive/responsive.js +583 -0
- package/dist/components/responsive-preview/responsive-preview.js +123 -0
- package/dist/components/rich-label/rich-label.js +66 -0
- package/dist/components/select/async-multi-select.js +157 -0
- package/dist/components/select/async-single-select.js +137 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +151 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +26 -0
- package/dist/components/select/single-select.js +131 -0
- package/dist/components/select/styles.js +49 -0
- package/dist/components/select/v2/async-select.js +297 -0
- package/dist/components/select/v2/shared.js +24 -0
- package/dist/components/select/v2/single-select.js +1004 -0
- package/dist/components/slider/column-config-slider.js +210 -0
- package/dist/components/slider/slider.js +345 -0
- package/dist/components/slider/utils.js +94 -0
- package/dist/components/spacer/spacer.js +97 -0
- package/dist/components/tabs/tabs.js +703 -0
- package/dist/components/toggle/switch.js +156 -0
- package/dist/components/toggle/toggle.js +64 -0
- package/dist/components/toggle-button/toggle-button.js +343 -0
- package/dist/components/tooltip/tooltip.js +527 -0
- package/dist/context-BbYZoHvX.js +92 -0
- package/dist/default-i18n-CT_oS1Fy.js +922 -0
- package/dist/filterDOMProps-EDDcM64A.js +28 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +113 -0
- package/dist/icons/icons.js +30495 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/jsx-svg.js +50 -0
- package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
- package/dist/index-BljRBEr_.js +44 -0
- package/dist/index-CFozsmNS.js +28321 -0
- package/dist/index.js +139 -0
- package/dist/lite-DVmmD_-j.js +7 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
- package/dist/number-GajL10e1.js +36 -0
- package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
- package/dist/react-select-async.esm-D937XTWW.js +107 -0
- package/dist/react-select.esm-Ciai3aKf.js +15 -0
- package/dist/style-admin.js +1 -0
- package/dist/style-editor.js +1 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-8DpK8fJl.js +46 -0
- package/dist/useButton-Bt3BffJm.js +50 -0
- package/dist/useEvent-ICdlokG-.js +23 -0
- package/dist/useFocusRing-Bv0UJQl8.js +107 -0
- package/dist/useFormReset-D2YaWRIA.js +22 -0
- package/dist/useFormValidation-Dy0PXJg5.js +224 -0
- package/dist/useHover-C2SkI1Fn.js +895 -0
- package/dist/useLabel-BPCd5c7-.js +27 -0
- package/dist/useLabels-B7-lUnAF.js +23 -0
- package/dist/useListState-DkyH7elT.js +168 -0
- package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
- package/dist/useNumberField-CU1_u8ze.js +1215 -0
- package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
- package/dist/usePress-BrJylgPR.js +688 -0
- package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
- package/dist/useToggle-CDa3YAZI.js +59 -0
- package/dist/useToggleState-ibcBUHnB.js +19 -0
- package/dist/utilities/array-helpers.js +56 -0
- package/dist/utilities/debounce-throttle.js +123 -0
- package/dist/utilities/es-dash.js +382 -0
- package/dist/utilities/index.js +27 -0
- package/dist/utilities/text-helpers.js +136 -0
- package/dist/utils-CZt7LCbO.js +403 -0
- package/dist/wp/wp-font-enhancements.js +1 -0
- package/dist/wp/wp-ui-enhancements.js +1 -0
- package/package.json +24 -24
|
@@ -0,0 +1,534 @@
|
|
|
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-DntWEAC3.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
|
+
};
|