@eightshift/ui-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/Checkbox-BLcVbhiO.js +178 -0
- package/dist/ColorSwatch-Cmlex_kT.js +66 -0
- package/dist/FieldError-wtMA4667.js +42 -0
- package/dist/FocusScope-1u9yyfIN.js +725 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/GridList-BZPXp3_O.js +1256 -0
- package/dist/Group-DyqpTRPe.js +49 -0
- package/dist/Input-jsbb4ugq.js +130 -0
- package/dist/Label-BPzS-sR7.js +17 -0
- package/dist/ListBox-w9gDaJkV.js +4423 -0
- package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
- package/dist/NumberFormatter-LzoKy975.js +160 -0
- package/dist/RSPContexts-CrNYmadY.js +14 -0
- package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
- package/dist/SelectionManager-mefd0ThJ.js +2155 -0
- package/dist/Separator-DHn0CwdK.js +325 -0
- package/dist/Slider-Pyh2V4bY.js +885 -0
- package/dist/Text-BM136LvS.js +17 -0
- package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
- package/dist/assets/style.css +1 -0
- package/dist/button-BkkdyHfJ.js +307 -0
- package/dist/components/animated-visibility/animated-visibility.js +7165 -0
- package/dist/components/base-control/base-control.js +97 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
- package/dist/components/button/button.js +10 -0
- package/dist/components/checkbox/checkbox.js +119 -0
- package/dist/components/color-pickers/color-picker.js +242 -0
- package/dist/components/color-pickers/color-swatch.js +62 -0
- package/dist/components/color-pickers/gradient-editor.js +516 -0
- package/dist/components/color-pickers/solid-color-picker.js +1633 -0
- package/dist/components/component-toggle/component-toggle.js +71 -0
- package/dist/components/container-panel/container-panel.js +39 -0
- package/dist/components/expandable/expandable.js +144 -0
- package/dist/components/input-field/input-field.js +224 -0
- package/dist/components/link-input/link-input.js +937 -0
- package/dist/components/list-box/list-box.js +152 -0
- package/dist/components/matrix-align/matrix-align.js +185 -0
- package/dist/components/menu/menu.js +1608 -0
- package/dist/components/notice/notice.js +119 -0
- package/dist/components/number-picker/number-picker.js +277 -0
- package/dist/components/popover/popover.js +9 -0
- package/dist/components/radio/radio.js +552 -0
- package/dist/components/repeater/repeater-item.js +127 -0
- package/dist/components/repeater/repeater.js +248 -0
- package/dist/components/responsive/responsive-legacy.js +326 -0
- package/dist/components/responsive/responsive.js +499 -0
- package/dist/components/responsive-preview/responsive-preview.js +119 -0
- package/dist/components/rich-label/rich-label.js +56 -0
- package/dist/components/select/async-multi-select.js +144 -0
- package/dist/components/select/async-single-select.js +126 -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 +134 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +45 -0
- package/dist/components/select/single-select.js +116 -0
- package/dist/components/select/styles.js +55 -0
- package/dist/components/slider/column-config-slider.js +225 -0
- package/dist/components/slider/slider.js +362 -0
- package/dist/components/slider/utils.js +45 -0
- package/dist/components/spacer/spacer.js +93 -0
- package/dist/components/tabs/tabs.js +626 -0
- package/dist/components/toggle/switch.js +140 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle-button/toggle-button.js +206 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/context-jMy6xdVq.js +98 -0
- package/dist/default-i18n-BhE-OUmt.js +873 -0
- package/dist/filterDOMProps-DG2RfOUr.js +30 -0
- package/dist/focusSafely-C3K8zAKj.js +743 -0
- package/dist/hooks/use-cell-edit-mode.js +35 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +21 -0
- package/dist/icons/icons.js +3636 -0
- package/dist/index-Bfb9bWcb.js +28844 -0
- package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
- package/dist/index.js +109 -0
- package/dist/intlStrings-CUhoK9EN.js +2484 -0
- package/dist/isScrollable-PcyglExV.js +10 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-CjVpCNko.js +3677 -0
- package/dist/number-rWqELA8W.js +39 -0
- package/dist/popover-Dx3vKXUX.js +1061 -0
- package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
- package/dist/react-select.esm-BjRWqf0E.js +15 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-BosCCRVE.js +89 -0
- package/dist/tooltip-CkCndvTI.js +1094 -0
- package/dist/useButton-CuG5UzUw.js +74 -0
- package/dist/useEvent-DHv-yhOH.js +24 -0
- package/dist/useFocusRing-Cc-4eouh.js +41 -0
- package/dist/useFocusable-5q1Gek1J.js +81 -0
- package/dist/useFormReset-Buc9YJcv.js +23 -0
- package/dist/useFormValidationState-BAPPNXic.js +238 -0
- package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
- package/dist/useLabel-CGlkoFG0.js +28 -0
- package/dist/useLabels-Dg62M_3P.js +25 -0
- package/dist/useListData-BelKu4kx.js +211 -0
- package/dist/useListState-Domq0blV.js +137 -0
- package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
- package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
- package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
- package/dist/usePress-BQgVor4T.js +698 -0
- package/dist/useToggle-C9ETOBaZ.js +58 -0
- package/dist/useToggleState-DJ_z5E2S.js +21 -0
- package/dist/utilities/classnames.js +16 -0
- package/dist/utilities/text-helpers.js +79 -0
- package/dist/utils-BsiH7-5Y.js +488 -0
- package/package.json +71 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $251c695a52d94a8d$export$cae13e90592f246a } from "../../ColorSwatch-Cmlex_kT.js";
|
|
3
|
+
import { $ as $799cddbef784668f$export$6e865ea70d7724f } from "../../intlStrings-CUhoK9EN.js";
|
|
4
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
5
|
+
import { _ as __ } from "../../default-i18n-BhE-OUmt.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 classnames to apply.
|
|
14
|
+
* @param {string} [props.colorName] - The name of the color. Should be auto-generated for colors.
|
|
15
|
+
*
|
|
16
|
+
* @returns {JSX.Element} The ColorSwatch component.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <ColorSwatch color="#FF0000" />
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <ColorSwatch gradient="linear-gradient(45deg, #FF0000, #00FF00)" />
|
|
23
|
+
*
|
|
24
|
+
* @preserve
|
|
25
|
+
*/
|
|
26
|
+
const ColorSwatch = (props) => {
|
|
27
|
+
const { color: rawColor, gradient, className, colorName } = props;
|
|
28
|
+
const checkerPattern = "repeating-conic-gradient(#CCC 0% 25%, white 0% 50%) 50% / 0.75rem 0.75rem";
|
|
29
|
+
let color;
|
|
30
|
+
if (rawColor && !gradient) {
|
|
31
|
+
try {
|
|
32
|
+
if (rawColor === "transparent") {
|
|
33
|
+
color = "rgba(0, 0, 0, 0)";
|
|
34
|
+
} else {
|
|
35
|
+
color = $799cddbef784668f$export$6e865ea70d7724f(rawColor);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
color = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const backgroundGradient = gradient ? `${gradient}, ${checkerPattern}` : `linear-gradient(${color}, ${color}), ${checkerPattern}`;
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
$251c695a52d94a8d$export$cae13e90592f246a,
|
|
44
|
+
{
|
|
45
|
+
...props,
|
|
46
|
+
style: {
|
|
47
|
+
background: (color || gradient) && backgroundGradient
|
|
48
|
+
},
|
|
49
|
+
className: () => classnames(
|
|
50
|
+
"es-uic-size-6 es-uic-rounded es-uic-border es-uic-border-gray-300 es-uic-shadow-sm",
|
|
51
|
+
!color && !gradient && "es-uic-bg-white",
|
|
52
|
+
className
|
|
53
|
+
),
|
|
54
|
+
colorName: !color && !gradient ? __("No color", "eightshift-ui-components") : colorName,
|
|
55
|
+
color,
|
|
56
|
+
children: !color && !gradient && /* @__PURE__ */ jsx("div", { className: "es-uic-m-auto es-uic-h-full es-uic-w-px es-uic-rotate-45 es-uic-rounded es-uic-bg-red-500" })
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
ColorSwatch
|
|
62
|
+
};
|
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { _ as __, s as sprintf } from "../../default-i18n-BhE-OUmt.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { a as ButtonGroup } from "../../button-BkkdyHfJ.js";
|
|
5
|
+
import { ToggleButton } from "../toggle-button/toggle-button.js";
|
|
6
|
+
import { Repeater } from "../repeater/repeater.js";
|
|
7
|
+
import { RepeaterItem } from "../repeater/repeater-item.js";
|
|
8
|
+
import { icons } from "../../icons/icons.js";
|
|
9
|
+
import { SolidColorPicker } from "./solid-color-picker.js";
|
|
10
|
+
import { Slider } from "../slider/slider.js";
|
|
11
|
+
import { NumberPicker } from "../number-picker/number-picker.js";
|
|
12
|
+
import { $ as $251c695a52d94a8d$export$cae13e90592f246a } from "../../ColorSwatch-Cmlex_kT.js";
|
|
13
|
+
import { Menu, MenuItem } from "../menu/menu.js";
|
|
14
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
15
|
+
import { MatrixAlign } from "../matrix-align/matrix-align.js";
|
|
16
|
+
import { Spacer } from "../spacer/spacer.js";
|
|
17
|
+
import { Toggle } from "../toggle/toggle.js";
|
|
18
|
+
import { classnames } from "../../utilities/classnames.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++)
|
|
23
|
+
e[r] === "(" ? i++ : e[r] === ")" && i--, i === 0 && o.test(e[r]) && (t.push(e.slice(n, r).trim()), n = r + 1);
|
|
24
|
+
return t.push(e.slice(n).trim()), t;
|
|
25
|
+
}
|
|
26
|
+
function g(e) {
|
|
27
|
+
let o = [];
|
|
28
|
+
for (let t = 0, n = e.length; t < n; ) {
|
|
29
|
+
let [i, r] = c(e[t], /\s+/);
|
|
30
|
+
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++);
|
|
31
|
+
}
|
|
32
|
+
return o;
|
|
33
|
+
}
|
|
34
|
+
var u = /^(-?\d+\.?\d*)(%|vw|vh|px|em|rem|deg|rad|grad|turn)$/;
|
|
35
|
+
function m(e) {
|
|
36
|
+
return u.test(e);
|
|
37
|
+
}
|
|
38
|
+
function l(e) {
|
|
39
|
+
if (!e)
|
|
40
|
+
return;
|
|
41
|
+
let [, o, t] = e.trim().match(u) || [];
|
|
42
|
+
return { value: o, unit: t };
|
|
43
|
+
}
|
|
44
|
+
function P(e) {
|
|
45
|
+
if (!/^(repeating-)?linear-gradient/.test(e))
|
|
46
|
+
throw new SyntaxError(`could not find syntax for this item: ${e}`);
|
|
47
|
+
let [, o, t] = e.match(/(repeating-)?linear-gradient\((.+)\)/), n = { orientation: { type: "directional", value: "bottom" }, repeating: !!o, stops: [] }, i = c(t), r = x(i[0]);
|
|
48
|
+
return r && (n.orientation = r, i.shift()), { ...n, stops: g(i) };
|
|
49
|
+
}
|
|
50
|
+
function x(e) {
|
|
51
|
+
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;
|
|
52
|
+
}
|
|
53
|
+
var w = /* @__PURE__ */ new Set(["closest-corner", "closest-side", "farthest-corner", "farthest-side"]), v = /* @__PURE__ */ new Set(["center", "left", "top", "right", "bottom"]);
|
|
54
|
+
function d(e) {
|
|
55
|
+
return w.has(e);
|
|
56
|
+
}
|
|
57
|
+
function h(e) {
|
|
58
|
+
return v.has(e);
|
|
59
|
+
}
|
|
60
|
+
function R(e) {
|
|
61
|
+
let o = Array(2).fill("");
|
|
62
|
+
for (let t = 0; t < 2; t++)
|
|
63
|
+
e[t] ? o[t] = e[t] : o[t] = "center";
|
|
64
|
+
return o;
|
|
65
|
+
}
|
|
66
|
+
function K(e) {
|
|
67
|
+
if (!/(repeating-)?radial-gradient/.test(e))
|
|
68
|
+
throw new SyntaxError(`could not find syntax for this item: ${e}`);
|
|
69
|
+
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);
|
|
70
|
+
if (S(i[0]))
|
|
71
|
+
return { ...n, stops: g(i) };
|
|
72
|
+
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(" "));
|
|
73
|
+
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) };
|
|
74
|
+
}
|
|
75
|
+
function S(e) {
|
|
76
|
+
return /(circle|ellipse|at)/.test(e) ? false : /^(rgba?|hwb|hsl|lab|lch|oklab|color|#|[a-zA-Z]+)/.test(e);
|
|
77
|
+
}
|
|
78
|
+
var C = /* @__PURE__ */ new Set(["from", "in", "at"]);
|
|
79
|
+
function j(e) {
|
|
80
|
+
if (!/(repeating-)?conic-gradient/.test(e))
|
|
81
|
+
throw new SyntaxError(`could not find syntax for this item: ${e}`);
|
|
82
|
+
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;
|
|
83
|
+
for (let s = 0, f = r.length; s < f; s++)
|
|
84
|
+
C.has(r[s]) && (s > 0 && Object.assign(n, y(p, r, a, s)), p = r[s], a = s + 1);
|
|
85
|
+
return p && (Object.assign(n, y(p, r, a, r.length)), i.shift()), { ...n, stops: g(i) };
|
|
86
|
+
}
|
|
87
|
+
function y(e, o, t, n) {
|
|
88
|
+
switch (e) {
|
|
89
|
+
case "from":
|
|
90
|
+
return { angle: o.slice(t, n).join(" ") };
|
|
91
|
+
case "at":
|
|
92
|
+
return { position: o.slice(t, n).join(" ") };
|
|
93
|
+
case "in": {
|
|
94
|
+
let [i, ...r] = o.slice(t, n);
|
|
95
|
+
return { color: { space: i, method: r.length > 0 ? r.join(" ") : void 0 } };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const getGradientResult = (input, type) => {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
if (!input || !type) {
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
if (typeof input === "string" || !(input == null ? void 0 : input.stops)) {
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
let output = "";
|
|
108
|
+
const { repeating } = input;
|
|
109
|
+
if (repeating) {
|
|
110
|
+
output += "repeating-";
|
|
111
|
+
}
|
|
112
|
+
output += `${type}-gradient(`;
|
|
113
|
+
if (type === "linear") {
|
|
114
|
+
const { orientation } = input;
|
|
115
|
+
if ((orientation == null ? void 0 : orientation.type) === "angular") {
|
|
116
|
+
output += `${orientation.value.value}${orientation.value.unit}, `;
|
|
117
|
+
} else if ((orientation == null ? void 0 : orientation.type) === "directional") {
|
|
118
|
+
output += `to ${orientation.value}, `;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (type === "radial") {
|
|
122
|
+
const { shape, position } = input;
|
|
123
|
+
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"}, `;
|
|
124
|
+
}
|
|
125
|
+
if (type === "conic") {
|
|
126
|
+
const { angle, position } = input;
|
|
127
|
+
output += `from ${angle ?? "0deg"} at ${position ?? "center"}, `;
|
|
128
|
+
}
|
|
129
|
+
output += input.stops.map((stop) => {
|
|
130
|
+
var _a2, _b2;
|
|
131
|
+
return `${stop.color} ${((_a2 = stop.offset) == null ? void 0 : _a2.value) ?? ""}${((_b2 = stop.offset) == null ? void 0 : _b2.unit) ?? ""}`.trim();
|
|
132
|
+
}).join(", ");
|
|
133
|
+
output += ")";
|
|
134
|
+
return output;
|
|
135
|
+
};
|
|
136
|
+
const gradientTypes = [
|
|
137
|
+
{
|
|
138
|
+
label: __("Linear"),
|
|
139
|
+
value: "linear",
|
|
140
|
+
icon: /* @__PURE__ */ jsx("div", { className: "es-uic-transparent es-uic-size-4 es-uic-rounded-full es-uic-bg-gradient-to-br es-uic-from-current" })
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
label: __("Radial"),
|
|
144
|
+
value: "radial",
|
|
145
|
+
icon: /* @__PURE__ */ jsx("div", { className: "es-uic-transparent es-uic-size-4 es-uic-rounded-full es-uic-bg-[radial-gradient(var(--tw-gradient-stops))] es-uic-from-current" })
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
label: __("Conic"),
|
|
149
|
+
value: "conic",
|
|
150
|
+
icon: /* @__PURE__ */ jsx("div", { className: "es-uic-transparent es-uic-size-4 es-uic-rounded-full es-uic-bg-[conic-gradient(var(--tw-gradient-stops))] es-uic-from-current" })
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
const linearDirections = [
|
|
154
|
+
{
|
|
155
|
+
label: __("Right"),
|
|
156
|
+
value: "right",
|
|
157
|
+
iconClass: "es-uic-bg-gradient-to-r"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: __("Left"),
|
|
161
|
+
value: "left",
|
|
162
|
+
iconClass: "es-uic-bg-gradient-to-l"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: __("Top"),
|
|
166
|
+
value: "top",
|
|
167
|
+
iconClass: "es-uic-bg-gradient-to-t"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
label: __("Bottom"),
|
|
171
|
+
value: "bottom",
|
|
172
|
+
iconClass: "es-uic-bg-gradient-to-b"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: __("Top-right"),
|
|
176
|
+
value: "top right",
|
|
177
|
+
iconClass: "es-uic-bg-gradient-to-tr"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
label: __("Top-left"),
|
|
181
|
+
value: "top left",
|
|
182
|
+
iconClass: "es-uic-bg-gradient-to-tl"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: __("Bottom-right"),
|
|
186
|
+
value: "bottom right",
|
|
187
|
+
iconClass: "es-uic-bg-gradient-to-br"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: __("Bottom-left"),
|
|
191
|
+
value: "bottom left",
|
|
192
|
+
iconClass: "es-uic-bg-gradient-to-bl"
|
|
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
|
+
*
|
|
204
|
+
* @returns {JSX.Element} The GradientEditor component.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* <GradientEditor
|
|
208
|
+
* value='linear-gradient(90deg, #000000 0%, #ffffff 100%)'
|
|
209
|
+
* onChange={setGradient}
|
|
210
|
+
* />
|
|
211
|
+
*
|
|
212
|
+
* @preserve
|
|
213
|
+
*/
|
|
214
|
+
const GradientEditor = (props) => {
|
|
215
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
216
|
+
const { value, onChange } = props;
|
|
217
|
+
const gradientData = useMemo(() => {
|
|
218
|
+
if ((value == null ? void 0 : value.startsWith("radial-gradient")) || (value == null ? void 0 : value.startsWith("repeating-radial-gradient"))) {
|
|
219
|
+
return K(value ?? "");
|
|
220
|
+
}
|
|
221
|
+
if ((value == null ? void 0 : value.startsWith("conic-gradient")) || (value == null ? void 0 : value.startsWith("repeating-conic-gradient"))) {
|
|
222
|
+
return j(value ?? "");
|
|
223
|
+
}
|
|
224
|
+
return P(value ?? "");
|
|
225
|
+
}, [value]);
|
|
226
|
+
const gradientType = useMemo(() => {
|
|
227
|
+
if (typeof value === "string" && (value == null ? void 0 : value.startsWith("radial-gradient")) || (value == null ? void 0 : value.startsWith("repeating-radial-gradient"))) {
|
|
228
|
+
return "radial";
|
|
229
|
+
}
|
|
230
|
+
if (typeof value === "string" && (value == null ? void 0 : value.startsWith("conic-gradient")) || (value == null ? void 0 : value.startsWith("repeating-conic-gradient"))) {
|
|
231
|
+
return "conic";
|
|
232
|
+
}
|
|
233
|
+
return "linear";
|
|
234
|
+
}, [value]);
|
|
235
|
+
const setGradientData = (data) => {
|
|
236
|
+
onChange(getGradientResult(data, gradientType));
|
|
237
|
+
};
|
|
238
|
+
const outputGradient = useMemo(
|
|
239
|
+
() => getGradientResult(gradientData, gradientType),
|
|
240
|
+
[gradientData, gradientType]
|
|
241
|
+
);
|
|
242
|
+
return /* @__PURE__ */ jsxs("div", { className: "es-uic-w-full es-uic-space-y-2.5", children: [
|
|
243
|
+
/* @__PURE__ */ jsx(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
className: "es-uic-h-40 es-uic-w-full es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-shadow-sm",
|
|
247
|
+
style: { backgroundImage: outputGradient }
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx(ButtonGroup, { className: "es-uic-w-full", children: gradientTypes.map(({ label, value: value2, icon }) => {
|
|
251
|
+
return /* @__PURE__ */ jsx(
|
|
252
|
+
ToggleButton,
|
|
253
|
+
{
|
|
254
|
+
selected: gradientType === value2,
|
|
255
|
+
onChange: () => onChange(getGradientResult({ stops: gradientData.stops }, value2)),
|
|
256
|
+
icon,
|
|
257
|
+
className: "es-uic-grow",
|
|
258
|
+
children: label
|
|
259
|
+
},
|
|
260
|
+
value2
|
|
261
|
+
);
|
|
262
|
+
}) }),
|
|
263
|
+
/* @__PURE__ */ jsx(Spacer, { size: "xs" }),
|
|
264
|
+
gradientType === "linear" && /* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-items-center es-uic-gap-1", children: [
|
|
265
|
+
/* @__PURE__ */ jsx(
|
|
266
|
+
NumberPicker,
|
|
267
|
+
{
|
|
268
|
+
inline: true,
|
|
269
|
+
icon: icons.angle,
|
|
270
|
+
label: __("Angle", "eightshift-ui-components"),
|
|
271
|
+
min: 0,
|
|
272
|
+
max: 360,
|
|
273
|
+
step: 1,
|
|
274
|
+
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,
|
|
275
|
+
onChange: (angle) => {
|
|
276
|
+
setGradientData({
|
|
277
|
+
...gradientData,
|
|
278
|
+
orientation: { type: "angular", value: { value: angle, unit: "deg" } }
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
suffix: "°",
|
|
282
|
+
size: "small",
|
|
283
|
+
className: "es-uic-grow"
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
/* @__PURE__ */ jsx(
|
|
287
|
+
Menu,
|
|
288
|
+
{
|
|
289
|
+
triggerIcon: icons.sliders,
|
|
290
|
+
triggerProps: {
|
|
291
|
+
tooltip: __("Presets", "eightshift-ui-components")
|
|
292
|
+
},
|
|
293
|
+
keepOpen: true,
|
|
294
|
+
children: linearDirections.map(({ label, value: value2, iconClass }) => {
|
|
295
|
+
return /* @__PURE__ */ jsx(
|
|
296
|
+
MenuItem,
|
|
297
|
+
{
|
|
298
|
+
icon: /* @__PURE__ */ jsx("div", { className: classnames("es-uic-size-5 es-uic-from-gray-700 es-uic-to-gray-200 es-uic-rounded-sm", iconClass) }),
|
|
299
|
+
onClick: () => {
|
|
300
|
+
setGradientData({
|
|
301
|
+
...gradientData,
|
|
302
|
+
orientation: { type: "directional", value: value2 }
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
children: label
|
|
306
|
+
},
|
|
307
|
+
value2
|
|
308
|
+
);
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
] }),
|
|
313
|
+
gradientType === "radial" && /* @__PURE__ */ jsxs("div", { className: "es-uic-space-y-2", children: [
|
|
314
|
+
/* @__PURE__ */ jsx(
|
|
315
|
+
BaseControl,
|
|
316
|
+
{
|
|
317
|
+
label: __("Shape", "eightshift-ui-components"),
|
|
318
|
+
icon: icons.genericShapesAlt,
|
|
319
|
+
inline: true,
|
|
320
|
+
children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
321
|
+
/* @__PURE__ */ jsx(
|
|
322
|
+
ToggleButton,
|
|
323
|
+
{
|
|
324
|
+
selected: gradientData.shape === "circle",
|
|
325
|
+
onChange: () => {
|
|
326
|
+
setGradientData({
|
|
327
|
+
...gradientData,
|
|
328
|
+
shape: "circle"
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
size: "large",
|
|
332
|
+
children: __("Circle", "eightshift-ui-components")
|
|
333
|
+
}
|
|
334
|
+
),
|
|
335
|
+
/* @__PURE__ */ jsx(
|
|
336
|
+
ToggleButton,
|
|
337
|
+
{
|
|
338
|
+
selected: gradientData.shape === "ellipse",
|
|
339
|
+
onChange: () => {
|
|
340
|
+
setGradientData({
|
|
341
|
+
...gradientData,
|
|
342
|
+
shape: "ellipse"
|
|
343
|
+
});
|
|
344
|
+
},
|
|
345
|
+
size: "large",
|
|
346
|
+
children: __("Ellipse", "eightshift-ui-components")
|
|
347
|
+
}
|
|
348
|
+
)
|
|
349
|
+
] })
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
/* @__PURE__ */ jsx(
|
|
353
|
+
MatrixAlign,
|
|
354
|
+
{
|
|
355
|
+
icon: icons.centerPoint,
|
|
356
|
+
label: __("Center point", "eightshift-ui-components"),
|
|
357
|
+
value: `${((_e = (_d = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _d.y) == null ? void 0 : _e.value) ?? "center"} ${((_g = (_f = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _f.x) == null ? void 0 : _g.value) ?? "center"}`,
|
|
358
|
+
onChange: (position) => {
|
|
359
|
+
const [x2, y2] = position.split(" ");
|
|
360
|
+
setGradientData({
|
|
361
|
+
...gradientData,
|
|
362
|
+
position: {
|
|
363
|
+
x: { type: "keyword", value: x2 },
|
|
364
|
+
y: { type: "keyword", value: y2 }
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
] }),
|
|
371
|
+
gradientType === "conic" && /* @__PURE__ */ jsxs("div", { className: "es-uic-space-y-2", children: [
|
|
372
|
+
/* @__PURE__ */ jsx(
|
|
373
|
+
NumberPicker,
|
|
374
|
+
{
|
|
375
|
+
inline: true,
|
|
376
|
+
icon: icons.angle,
|
|
377
|
+
label: __("Angle", "eightshift-ui-components"),
|
|
378
|
+
min: 0,
|
|
379
|
+
max: 360,
|
|
380
|
+
step: 1,
|
|
381
|
+
value: parseInt(gradientData == null ? void 0 : gradientData.angle.replace("deg", "")),
|
|
382
|
+
onChange: (value2) => {
|
|
383
|
+
setGradientData({
|
|
384
|
+
...gradientData,
|
|
385
|
+
angle: `${value2}deg`
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
suffix: "°",
|
|
389
|
+
className: "es-uic-grow"
|
|
390
|
+
}
|
|
391
|
+
),
|
|
392
|
+
/* @__PURE__ */ jsx(
|
|
393
|
+
MatrixAlign,
|
|
394
|
+
{
|
|
395
|
+
icon: icons.centerPoint,
|
|
396
|
+
label: __("Center point", "eightshift-ui-components"),
|
|
397
|
+
value: `${((_i = (_h = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _h.y) == null ? void 0 : _i.value) ?? "center"} ${((_k = (_j = gradientData == null ? void 0 : gradientData.position) == null ? void 0 : _j.x) == null ? void 0 : _k.value) ?? "center"}`,
|
|
398
|
+
onChange: (value2) => {
|
|
399
|
+
setGradientData({
|
|
400
|
+
...gradientData,
|
|
401
|
+
position: value2
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
)
|
|
406
|
+
] }),
|
|
407
|
+
/* @__PURE__ */ jsx(
|
|
408
|
+
Toggle,
|
|
409
|
+
{
|
|
410
|
+
checked: gradientData.repeating,
|
|
411
|
+
onChange: (value2) => {
|
|
412
|
+
setGradientData({
|
|
413
|
+
...gradientData,
|
|
414
|
+
repeating: value2
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
label: __("Repeating", "eightshift-ui-components"),
|
|
418
|
+
icon: icons.gradientRepeat
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
/* @__PURE__ */ jsx(Spacer, { border: true }),
|
|
422
|
+
/* @__PURE__ */ jsx(
|
|
423
|
+
Repeater,
|
|
424
|
+
{
|
|
425
|
+
items: gradientData == null ? void 0 : gradientData.stops,
|
|
426
|
+
onChange: (items) => {
|
|
427
|
+
setGradientData({
|
|
428
|
+
...gradientData,
|
|
429
|
+
stops: items.map(({ color }, i) => ({
|
|
430
|
+
...gradientData.stops[i] ?? {},
|
|
431
|
+
color
|
|
432
|
+
}))
|
|
433
|
+
});
|
|
434
|
+
},
|
|
435
|
+
itemLabelProp: "title",
|
|
436
|
+
icon: icons.gradientStop,
|
|
437
|
+
label: __("Gradient stops", "eightshift-ui-components"),
|
|
438
|
+
addDefaultItem: {
|
|
439
|
+
color: "#000000"
|
|
440
|
+
},
|
|
441
|
+
minItems: 2,
|
|
442
|
+
children: (item) => {
|
|
443
|
+
var _a2, _b2;
|
|
444
|
+
const { color, updateData, itemIndex } = item;
|
|
445
|
+
const defaultOffset = itemIndex * 100 / (gradientData.stops.length - 1);
|
|
446
|
+
const offset = `${((_b2 = (_a2 = gradientData.stops[itemIndex]) == null ? void 0 : _a2.offset) == null ? void 0 : _b2.value) ?? defaultOffset}%`;
|
|
447
|
+
return /* @__PURE__ */ jsx(
|
|
448
|
+
RepeaterItem,
|
|
449
|
+
{
|
|
450
|
+
label: sprintf(__("Stop %s", "eightshift-ui-components"), itemIndex + 1),
|
|
451
|
+
subtitle: `${color} / ${offset ?? defaultOffset}`,
|
|
452
|
+
icon: /* @__PURE__ */ jsx(
|
|
453
|
+
$251c695a52d94a8d$export$cae13e90592f246a,
|
|
454
|
+
{
|
|
455
|
+
className: "es-uic-size-5 es-uic-rounded-full es-uic-border es-uic-border-white es-uic-ring-1 es-uic-ring-black",
|
|
456
|
+
color
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
textValue: sprintf(__("Stop %s", "eightshift-ui-components"), itemIndex + 1),
|
|
460
|
+
children: /* @__PURE__ */ jsx(
|
|
461
|
+
SolidColorPicker,
|
|
462
|
+
{
|
|
463
|
+
value: color,
|
|
464
|
+
onChange: (color2) => {
|
|
465
|
+
updateData({ color: color2 });
|
|
466
|
+
},
|
|
467
|
+
allowTransparency: true,
|
|
468
|
+
outputFormat: "rgba"
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ jsx(
|
|
477
|
+
Slider,
|
|
478
|
+
{
|
|
479
|
+
"aria-label": __("Stop positions", "eightshift-ui-components"),
|
|
480
|
+
min: 0,
|
|
481
|
+
max: 100,
|
|
482
|
+
step: 1,
|
|
483
|
+
value: (_l = gradientData == null ? void 0 : gradientData.stops) == null ? void 0 : _l.map(({ offset }, i) => {
|
|
484
|
+
if (!offset) {
|
|
485
|
+
return i * 100 / (gradientData.stops.length - 1);
|
|
486
|
+
}
|
|
487
|
+
return parseInt(offset == null ? void 0 : offset.value);
|
|
488
|
+
}),
|
|
489
|
+
onChange: (value2) => {
|
|
490
|
+
setGradientData({
|
|
491
|
+
...gradientData,
|
|
492
|
+
stops: gradientData.stops.map((stop, i) => {
|
|
493
|
+
return {
|
|
494
|
+
...stop,
|
|
495
|
+
offset: { value: value2[i], unit: "%" }
|
|
496
|
+
};
|
|
497
|
+
})
|
|
498
|
+
});
|
|
499
|
+
},
|
|
500
|
+
thumbContent: (index) => /* @__PURE__ */ jsx("div", { className: "es-uic-pointer-events-none es-uic-absolute es-uic-inset-0 es-uic-flex es-uic-size-3 es-uic-items-center es-uic-justify-center es-uic-text-center es-uic-text-xs es-uic-font-semibold es-uic-text-white", children: index + 1 }),
|
|
501
|
+
trackStyle: {
|
|
502
|
+
backgroundImage: getGradientResult(
|
|
503
|
+
{ orientation: { type: "directional", value: "right" }, stops: gradientData.stops },
|
|
504
|
+
"linear"
|
|
505
|
+
),
|
|
506
|
+
height: "1.125rem",
|
|
507
|
+
borderRadius: "0.5rem"
|
|
508
|
+
},
|
|
509
|
+
noActiveHighlight: true
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
] });
|
|
513
|
+
};
|
|
514
|
+
export {
|
|
515
|
+
GradientEditor
|
|
516
|
+
};
|