@pixerate/editor-react 0.95.0 → 0.96.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.
- package/README.md +2 -0
- package/dist/animation-editor/index.cjs +1240 -195
- package/dist/animation-editor/index.js +4 -2
- package/dist/canvas/index.cjs +1418 -373
- package/dist/canvas/index.js +4 -2
- package/dist/chunk-3I7FOSLF.js +988 -0
- package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
- package/dist/{chunk-5R67YSSD.js → chunk-GLSOQNQR.js} +1 -1
- package/dist/{chunk-6YRSQW2V.js → chunk-IY6YOY5B.js} +1 -1
- package/dist/chunk-KIRIU53A.js +72 -0
- package/dist/color/ColorPicker.d.cts +30 -0
- package/dist/color/ColorPicker.d.ts +30 -0
- package/dist/color/DualColorPicker.d.cts +29 -0
- package/dist/color/DualColorPicker.d.ts +29 -0
- package/dist/color/index.cjs +1067 -0
- package/dist/color/index.d.cts +7 -0
- package/dist/color/index.d.ts +7 -0
- package/dist/color/index.js +14 -0
- package/dist/color/useColorScheme.d.cts +16 -0
- package/dist/color/useColorScheme.d.ts +16 -0
- package/dist/effects/index.cjs +1169 -124
- package/dist/effects/index.js +4 -2
- package/dist/gradient/FillPicker.d.cts +27 -0
- package/dist/gradient/FillPicker.d.ts +27 -0
- package/dist/gradient/GradientEditor.d.cts +21 -0
- package/dist/gradient/GradientEditor.d.ts +21 -0
- package/dist/gradient/index.cjs +1601 -0
- package/dist/gradient/index.d.cts +6 -0
- package/dist/gradient/index.d.ts +6 -0
- package/dist/gradient/index.js +617 -0
- package/dist/gradient/useGradientController.d.cts +10 -0
- package/dist/gradient/useGradientController.d.ts +10 -0
- package/dist/image-editor/index.cjs +1742 -697
- package/dist/image-editor/index.js +5 -3
- package/dist/index.cjs +2160 -1115
- package/dist/index.js +5 -3
- package/dist/paint-editor/index.cjs +1233 -188
- package/dist/paint-editor/index.js +4 -2
- package/dist/parameters/fields.d.cts +1 -1
- package/dist/parameters/fields.d.ts +1 -1
- package/dist/parameters/index.cjs +1218 -173
- package/dist/parameters/index.js +3 -1
- package/dist/vector/index.cjs +1219 -174
- package/dist/vector/index.js +4 -2
- package/dist/video-editor/index.cjs +1230 -185
- package/dist/video-editor/index.js +4 -2
- package/package.json +29 -3
|
@@ -0,0 +1,1601 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/gradient/index.ts
|
|
32
|
+
var gradient_exports = {};
|
|
33
|
+
__export(gradient_exports, {
|
|
34
|
+
FillPicker: () => FillPicker,
|
|
35
|
+
GradientEditor: () => GradientEditor,
|
|
36
|
+
useGradientController: () => useGradientController,
|
|
37
|
+
useGradientState: () => useGradientState
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(gradient_exports);
|
|
40
|
+
|
|
41
|
+
// src/gradient/GradientEditor.tsx
|
|
42
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
43
|
+
var import_gradient2 = require("@pixerate/editor/gradient");
|
|
44
|
+
var import_color3 = require("@pixerate/editor/color");
|
|
45
|
+
|
|
46
|
+
// src/color/ColorPicker.tsx
|
|
47
|
+
var import_react = require("react");
|
|
48
|
+
var import_color = require("@pixerate/editor/color");
|
|
49
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
51
|
+
function readLocalRecents() {
|
|
52
|
+
try {
|
|
53
|
+
if (typeof localStorage === "undefined") return [];
|
|
54
|
+
const raw = localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
55
|
+
if (!raw) return [];
|
|
56
|
+
const parsed = JSON.parse(raw);
|
|
57
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
58
|
+
} catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function writeLocalRecents(list) {
|
|
63
|
+
try {
|
|
64
|
+
if (typeof localStorage !== "undefined") {
|
|
65
|
+
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(list));
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
var CHECKERBOARD_BG = "repeating-conic-gradient(var(--pixerate-checker-a, #d4d4d8) 0 25%, var(--pixerate-checker-b, #ffffff) 0 50%)";
|
|
71
|
+
var DEFAULT_PICKER_STATE = { h: 0, s: 1, v: 1, alpha: 1 };
|
|
72
|
+
var ColorPicker = ({
|
|
73
|
+
value,
|
|
74
|
+
onChange,
|
|
75
|
+
onGestureStart,
|
|
76
|
+
onGestureEnd,
|
|
77
|
+
alpha = false,
|
|
78
|
+
swatches,
|
|
79
|
+
recent: controlledRecent,
|
|
80
|
+
onRecentChange,
|
|
81
|
+
contrastAgainst,
|
|
82
|
+
disabled = false,
|
|
83
|
+
className,
|
|
84
|
+
id,
|
|
85
|
+
"aria-label": ariaLabel = "Color picker"
|
|
86
|
+
}) => {
|
|
87
|
+
const generatedId = (0, import_react.useId)();
|
|
88
|
+
const pickerId = id || generatedId;
|
|
89
|
+
const [pickerState, setPickerState] = (0, import_react.useState)(
|
|
90
|
+
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
91
|
+
);
|
|
92
|
+
const stateRef = (0, import_react.useRef)(pickerState);
|
|
93
|
+
stateRef.current = pickerState;
|
|
94
|
+
(0, import_react.useEffect)(() => {
|
|
95
|
+
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
96
|
+
if (next) {
|
|
97
|
+
setPickerState(next);
|
|
98
|
+
}
|
|
99
|
+
}, [value]);
|
|
100
|
+
const [internalRecent, setInternalRecent] = (0, import_react.useState)(
|
|
101
|
+
() => controlledRecent ? [] : readLocalRecents()
|
|
102
|
+
);
|
|
103
|
+
const activeRecent = controlledRecent ?? internalRecent;
|
|
104
|
+
const recordRecent = (0, import_react.useCallback)(
|
|
105
|
+
(color) => {
|
|
106
|
+
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
107
|
+
if (!controlledRecent) {
|
|
108
|
+
setInternalRecent(updated);
|
|
109
|
+
writeLocalRecents(updated);
|
|
110
|
+
}
|
|
111
|
+
onRecentChange?.(updated);
|
|
112
|
+
},
|
|
113
|
+
[activeRecent, controlledRecent, onRecentChange]
|
|
114
|
+
);
|
|
115
|
+
const [textDraft, setTextDraft] = (0, import_react.useState)(value);
|
|
116
|
+
const [isInvalid, setIsInvalid] = (0, import_react.useState)(false);
|
|
117
|
+
const [isClipped, setIsClipped] = (0, import_react.useState)(false);
|
|
118
|
+
const isTypingRef = (0, import_react.useRef)(false);
|
|
119
|
+
(0, import_react.useEffect)(() => {
|
|
120
|
+
if (!isTypingRef.current) {
|
|
121
|
+
setTextDraft(value);
|
|
122
|
+
setIsInvalid(false);
|
|
123
|
+
const parsed = (0, import_color.parseColor)(value);
|
|
124
|
+
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
125
|
+
}
|
|
126
|
+
}, [value]);
|
|
127
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react.useState)(false);
|
|
128
|
+
(0, import_react.useEffect)(() => {
|
|
129
|
+
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
130
|
+
}, []);
|
|
131
|
+
const emitColorChange = (0, import_react.useCallback)(
|
|
132
|
+
(nextState) => {
|
|
133
|
+
setPickerState(nextState);
|
|
134
|
+
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
135
|
+
onChange(hex);
|
|
136
|
+
},
|
|
137
|
+
[alpha, onChange]
|
|
138
|
+
);
|
|
139
|
+
const latest = (0, import_react.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
140
|
+
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
141
|
+
const endDragRef = (0, import_react.useRef)(null);
|
|
142
|
+
(0, import_react.useEffect)(() => () => endDragRef.current?.(), []);
|
|
143
|
+
const startDrag = (e, next) => {
|
|
144
|
+
if (disabled) return;
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
endDragRef.current?.();
|
|
147
|
+
onGestureStart?.();
|
|
148
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
149
|
+
const update = (clientX, clientY) => {
|
|
150
|
+
const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
151
|
+
const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
|
|
152
|
+
latest.current.emitColorChange(next(stateRef.current, x, y));
|
|
153
|
+
};
|
|
154
|
+
update(e.clientX, e.clientY);
|
|
155
|
+
const onPointerMove = (ev) => update(ev.clientX, ev.clientY);
|
|
156
|
+
const end = () => {
|
|
157
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
158
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
159
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
160
|
+
endDragRef.current = null;
|
|
161
|
+
latest.current.onGestureEnd?.();
|
|
162
|
+
};
|
|
163
|
+
const onPointerUp = () => {
|
|
164
|
+
end();
|
|
165
|
+
latest.current.recordRecent((0, import_color.pickerStateToHex)(stateRef.current, latest.current.alpha));
|
|
166
|
+
};
|
|
167
|
+
endDragRef.current = end;
|
|
168
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
169
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
170
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
171
|
+
};
|
|
172
|
+
const handleAreaPointerDown = (e) => startDrag(e, (state, x, y) => (0, import_color.pickerStateFromArea)(state, x, y));
|
|
173
|
+
const handleHuePointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromHue)(state, x));
|
|
174
|
+
const handleAlphaPointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromAlpha)(state, x));
|
|
175
|
+
const handleAreaKeyDown = (e) => {
|
|
176
|
+
if (disabled) return;
|
|
177
|
+
const next = (0, import_color.pickerKeyStep)(pickerState, "area", e.key, e.shiftKey);
|
|
178
|
+
if (next) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
emitColorChange(next);
|
|
181
|
+
recordRecent((0, import_color.pickerStateToHex)(next, alpha));
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const handleHueKeyDown = (e) => {
|
|
185
|
+
if (disabled) return;
|
|
186
|
+
const next = (0, import_color.pickerKeyStep)(pickerState, "hue", e.key, e.shiftKey);
|
|
187
|
+
if (next) {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
emitColorChange(next);
|
|
190
|
+
recordRecent((0, import_color.pickerStateToHex)(next, alpha));
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const handleAlphaKeyDown = (e) => {
|
|
194
|
+
if (disabled) return;
|
|
195
|
+
const next = (0, import_color.pickerKeyStep)(pickerState, "alpha", e.key, e.shiftKey);
|
|
196
|
+
if (next) {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
emitColorChange(next);
|
|
199
|
+
recordRecent((0, import_color.pickerStateToHex)(next, alpha));
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const commitTextInput = (inputElement) => {
|
|
203
|
+
isTypingRef.current = false;
|
|
204
|
+
const parsed = (0, import_color.parseColor)(textDraft);
|
|
205
|
+
if (parsed) {
|
|
206
|
+
setIsInvalid(false);
|
|
207
|
+
setIsClipped(!(0, import_color.inSrgbGamut)(parsed));
|
|
208
|
+
const formatted = (0, import_color.formatHex)(parsed);
|
|
209
|
+
onChange(formatted);
|
|
210
|
+
recordRecent(formatted);
|
|
211
|
+
} else {
|
|
212
|
+
setIsInvalid(true);
|
|
213
|
+
setTextDraft(value);
|
|
214
|
+
if (inputElement) {
|
|
215
|
+
inputElement.value = value;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const handleTextKeyDown = (e) => {
|
|
220
|
+
if (e.key === "Enter") {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
commitTextInput(e.currentTarget);
|
|
223
|
+
} else if (e.key === "Escape") {
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
isTypingRef.current = false;
|
|
226
|
+
setIsInvalid(false);
|
|
227
|
+
setTextDraft(value);
|
|
228
|
+
e.currentTarget.value = value;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
const handleEyeDropper = async () => {
|
|
232
|
+
if (disabled || !hasEyeDropper) return;
|
|
233
|
+
try {
|
|
234
|
+
const EyeDropperClass = window.EyeDropper;
|
|
235
|
+
const eyeDropper = new EyeDropperClass();
|
|
236
|
+
const res = await eyeDropper.open();
|
|
237
|
+
if (res?.sRGBHex) {
|
|
238
|
+
onChange(res.sRGBHex);
|
|
239
|
+
recordRecent(res.sRGBHex);
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const contrastResult = (0, import_react.useMemo)(() => {
|
|
245
|
+
if (!contrastAgainst) return null;
|
|
246
|
+
const fg = (0, import_color.parseColor)(value);
|
|
247
|
+
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
248
|
+
if (!fg || !bg) return null;
|
|
249
|
+
const ratio = (0, import_color.contrastRatio)(fg, bg);
|
|
250
|
+
const aa = ratio >= 4.5;
|
|
251
|
+
const aaa = ratio >= 7;
|
|
252
|
+
return { ratio, aa, aaa };
|
|
253
|
+
}, [value, contrastAgainst]);
|
|
254
|
+
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
255
|
+
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
257
|
+
"div",
|
|
258
|
+
{
|
|
259
|
+
id: pickerId,
|
|
260
|
+
role: "group",
|
|
261
|
+
"aria-label": ariaLabel,
|
|
262
|
+
className,
|
|
263
|
+
style: {
|
|
264
|
+
boxSizing: "border-box",
|
|
265
|
+
width: "var(--pixerate-color-picker-width, 240px)",
|
|
266
|
+
borderRadius: "var(--pixerate-color-picker-radius, 8px)",
|
|
267
|
+
background: "var(--pixerate-color-picker-bg, #1f2430)",
|
|
268
|
+
color: "var(--pixerate-color-picker-fg, #f0f2f5)",
|
|
269
|
+
padding: "12px",
|
|
270
|
+
display: "flex",
|
|
271
|
+
flexDirection: "column",
|
|
272
|
+
gap: "10px",
|
|
273
|
+
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
274
|
+
fontSize: "12px",
|
|
275
|
+
userSelect: "none",
|
|
276
|
+
opacity: disabled ? 0.6 : 1,
|
|
277
|
+
pointerEvents: disabled ? "none" : "auto"
|
|
278
|
+
},
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
281
|
+
"span",
|
|
282
|
+
{
|
|
283
|
+
role: "status",
|
|
284
|
+
"aria-live": "polite",
|
|
285
|
+
style: {
|
|
286
|
+
position: "absolute",
|
|
287
|
+
width: "1px",
|
|
288
|
+
height: "1px",
|
|
289
|
+
padding: 0,
|
|
290
|
+
margin: "-1px",
|
|
291
|
+
overflow: "hidden",
|
|
292
|
+
clip: "rect(0, 0, 0, 0)",
|
|
293
|
+
whiteSpace: "nowrap",
|
|
294
|
+
border: 0
|
|
295
|
+
},
|
|
296
|
+
children: liveDescription
|
|
297
|
+
}
|
|
298
|
+
),
|
|
299
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
300
|
+
"div",
|
|
301
|
+
{
|
|
302
|
+
role: "slider",
|
|
303
|
+
tabIndex: disabled ? -1 : 0,
|
|
304
|
+
"aria-label": "Saturation and brightness",
|
|
305
|
+
"aria-valuetext": `Saturation ${Math.round(pickerState.s * 100)}%, Brightness ${Math.round(
|
|
306
|
+
pickerState.v * 100
|
|
307
|
+
)}%`,
|
|
308
|
+
"aria-disabled": disabled,
|
|
309
|
+
onPointerDown: handleAreaPointerDown,
|
|
310
|
+
onKeyDown: handleAreaKeyDown,
|
|
311
|
+
style: {
|
|
312
|
+
position: "relative",
|
|
313
|
+
width: "100%",
|
|
314
|
+
height: "150px",
|
|
315
|
+
borderRadius: "6px",
|
|
316
|
+
background: (0, import_color.pickerAreaBackground)(pickerState),
|
|
317
|
+
cursor: disabled ? "default" : "crosshair",
|
|
318
|
+
touchAction: "none",
|
|
319
|
+
outline: "none"
|
|
320
|
+
},
|
|
321
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
322
|
+
"div",
|
|
323
|
+
{
|
|
324
|
+
style: {
|
|
325
|
+
position: "absolute",
|
|
326
|
+
width: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
327
|
+
height: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
328
|
+
borderRadius: "50%",
|
|
329
|
+
transform: "translate(-50%, -50%)",
|
|
330
|
+
left: `${pickerState.s * 100}%`,
|
|
331
|
+
top: `${(1 - pickerState.v) * 100}%`,
|
|
332
|
+
border: "2px solid #ffffff",
|
|
333
|
+
boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
|
|
334
|
+
pointerEvents: "none",
|
|
335
|
+
backgroundColor: currentHex
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
),
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
342
|
+
"div",
|
|
343
|
+
{
|
|
344
|
+
role: "slider",
|
|
345
|
+
tabIndex: disabled ? -1 : 0,
|
|
346
|
+
"aria-label": "Hue",
|
|
347
|
+
"aria-valuenow": Math.round(pickerState.h),
|
|
348
|
+
"aria-valuemin": 0,
|
|
349
|
+
"aria-valuemax": 360,
|
|
350
|
+
"aria-valuetext": `${Math.round(pickerState.h)} degrees`,
|
|
351
|
+
"aria-disabled": disabled,
|
|
352
|
+
onPointerDown: handleHuePointerDown,
|
|
353
|
+
onKeyDown: handleHueKeyDown,
|
|
354
|
+
style: {
|
|
355
|
+
position: "relative",
|
|
356
|
+
width: "100%",
|
|
357
|
+
height: "12px",
|
|
358
|
+
borderRadius: "6px",
|
|
359
|
+
background: import_color.PICKER_HUE_BACKGROUND,
|
|
360
|
+
cursor: disabled ? "default" : "pointer",
|
|
361
|
+
touchAction: "none",
|
|
362
|
+
outline: "none"
|
|
363
|
+
},
|
|
364
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
365
|
+
"div",
|
|
366
|
+
{
|
|
367
|
+
style: {
|
|
368
|
+
position: "absolute",
|
|
369
|
+
top: "50%",
|
|
370
|
+
transform: "translate(-50%, -50%)",
|
|
371
|
+
left: `${pickerState.h / 360 * 100}%`,
|
|
372
|
+
width: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
373
|
+
height: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
374
|
+
borderRadius: "50%",
|
|
375
|
+
border: "2px solid #ffffff",
|
|
376
|
+
boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
|
|
377
|
+
pointerEvents: "none",
|
|
378
|
+
backgroundColor: `hsl(${pickerState.h}, 100%, 50%)`
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
385
|
+
"div",
|
|
386
|
+
{
|
|
387
|
+
role: "slider",
|
|
388
|
+
tabIndex: disabled ? -1 : 0,
|
|
389
|
+
"aria-label": "Alpha",
|
|
390
|
+
"aria-valuenow": Math.round(pickerState.alpha * 100),
|
|
391
|
+
"aria-valuemin": 0,
|
|
392
|
+
"aria-valuemax": 100,
|
|
393
|
+
"aria-valuetext": `${Math.round(pickerState.alpha * 100)}%`,
|
|
394
|
+
"aria-disabled": disabled,
|
|
395
|
+
onPointerDown: handleAlphaPointerDown,
|
|
396
|
+
onKeyDown: handleAlphaKeyDown,
|
|
397
|
+
style: {
|
|
398
|
+
position: "relative",
|
|
399
|
+
width: "100%",
|
|
400
|
+
height: "12px",
|
|
401
|
+
borderRadius: "6px",
|
|
402
|
+
backgroundImage: CHECKERBOARD_BG,
|
|
403
|
+
backgroundSize: "8px 8px",
|
|
404
|
+
cursor: disabled ? "default" : "pointer",
|
|
405
|
+
touchAction: "none",
|
|
406
|
+
outline: "none",
|
|
407
|
+
overflow: "hidden"
|
|
408
|
+
},
|
|
409
|
+
children: [
|
|
410
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
style: {
|
|
414
|
+
position: "absolute",
|
|
415
|
+
inset: 0,
|
|
416
|
+
background: (0, import_color.pickerAlphaBackground)(pickerState)
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
421
|
+
"div",
|
|
422
|
+
{
|
|
423
|
+
style: {
|
|
424
|
+
position: "absolute",
|
|
425
|
+
top: "50%",
|
|
426
|
+
transform: "translate(-50%, -50%)",
|
|
427
|
+
left: `${pickerState.alpha * 100}%`,
|
|
428
|
+
width: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
429
|
+
height: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
430
|
+
borderRadius: "50%",
|
|
431
|
+
border: "2px solid #ffffff",
|
|
432
|
+
boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
|
|
433
|
+
pointerEvents: "none",
|
|
434
|
+
backgroundColor: currentHex
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
)
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
),
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
443
|
+
"div",
|
|
444
|
+
{
|
|
445
|
+
style: {
|
|
446
|
+
position: "relative",
|
|
447
|
+
width: "28px",
|
|
448
|
+
height: "28px",
|
|
449
|
+
borderRadius: "4px",
|
|
450
|
+
backgroundImage: CHECKERBOARD_BG,
|
|
451
|
+
backgroundSize: "8px 8px",
|
|
452
|
+
overflow: "hidden",
|
|
453
|
+
flexShrink: 0,
|
|
454
|
+
border: "1px solid rgba(255,255,255,0.15)"
|
|
455
|
+
},
|
|
456
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
457
|
+
"div",
|
|
458
|
+
{
|
|
459
|
+
style: {
|
|
460
|
+
width: "100%",
|
|
461
|
+
height: "100%",
|
|
462
|
+
backgroundColor: currentHex
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
469
|
+
"input",
|
|
470
|
+
{
|
|
471
|
+
type: "text",
|
|
472
|
+
value: textDraft,
|
|
473
|
+
disabled,
|
|
474
|
+
"aria-label": "Color hex or CSS string",
|
|
475
|
+
"aria-invalid": isInvalid ? "true" : void 0,
|
|
476
|
+
onChange: (e) => {
|
|
477
|
+
isTypingRef.current = true;
|
|
478
|
+
setTextDraft(e.target.value);
|
|
479
|
+
setIsInvalid(false);
|
|
480
|
+
},
|
|
481
|
+
onKeyDown: handleTextKeyDown,
|
|
482
|
+
onBlur: (e) => commitTextInput(e.currentTarget),
|
|
483
|
+
style: {
|
|
484
|
+
flex: 1,
|
|
485
|
+
minWidth: 0,
|
|
486
|
+
height: "28px",
|
|
487
|
+
padding: "0 8px",
|
|
488
|
+
fontSize: "12px",
|
|
489
|
+
fontFamily: "monospace",
|
|
490
|
+
borderRadius: "4px",
|
|
491
|
+
border: isInvalid ? "1px solid #ef4444" : "1px solid rgba(255,255,255,0.2)",
|
|
492
|
+
background: "rgba(0,0,0,0.2)",
|
|
493
|
+
color: "inherit",
|
|
494
|
+
outline: "none"
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
499
|
+
"button",
|
|
500
|
+
{
|
|
501
|
+
type: "button",
|
|
502
|
+
disabled,
|
|
503
|
+
"aria-label": "Pick color from screen",
|
|
504
|
+
title: "Pick color from screen",
|
|
505
|
+
onClick: handleEyeDropper,
|
|
506
|
+
style: {
|
|
507
|
+
display: "inline-flex",
|
|
508
|
+
alignItems: "center",
|
|
509
|
+
justifyContent: "center",
|
|
510
|
+
width: "28px",
|
|
511
|
+
height: "28px",
|
|
512
|
+
borderRadius: "4px",
|
|
513
|
+
border: "1px solid rgba(255,255,255,0.2)",
|
|
514
|
+
background: "transparent",
|
|
515
|
+
color: "inherit",
|
|
516
|
+
cursor: disabled ? "default" : "pointer"
|
|
517
|
+
},
|
|
518
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
519
|
+
"svg",
|
|
520
|
+
{
|
|
521
|
+
width: "14",
|
|
522
|
+
height: "14",
|
|
523
|
+
viewBox: "0 0 24 24",
|
|
524
|
+
fill: "none",
|
|
525
|
+
stroke: "currentColor",
|
|
526
|
+
strokeWidth: "2",
|
|
527
|
+
strokeLinecap: "round",
|
|
528
|
+
strokeLinejoin: "round",
|
|
529
|
+
children: [
|
|
530
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
|
|
531
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
532
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m14 6 4 4" })
|
|
533
|
+
]
|
|
534
|
+
}
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
] }),
|
|
539
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
540
|
+
"div",
|
|
541
|
+
{
|
|
542
|
+
role: "note",
|
|
543
|
+
title: "This colour was outside standard sRGB and clipped.",
|
|
544
|
+
style: {
|
|
545
|
+
display: "inline-flex",
|
|
546
|
+
alignItems: "center",
|
|
547
|
+
gap: "4px",
|
|
548
|
+
fontSize: "10px",
|
|
549
|
+
color: "#f59e0b",
|
|
550
|
+
background: "rgba(245, 158, 11, 0.1)",
|
|
551
|
+
padding: "2px 6px",
|
|
552
|
+
borderRadius: "4px",
|
|
553
|
+
alignSelf: "flex-start"
|
|
554
|
+
},
|
|
555
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
559
|
+
"div",
|
|
560
|
+
{
|
|
561
|
+
style: {
|
|
562
|
+
display: "flex",
|
|
563
|
+
alignItems: "center",
|
|
564
|
+
justifyContent: "space-between",
|
|
565
|
+
fontSize: "11px",
|
|
566
|
+
padding: "4px 8px",
|
|
567
|
+
borderRadius: "4px",
|
|
568
|
+
background: "rgba(255,255,255,0.05)",
|
|
569
|
+
border: "1px solid rgba(255,255,255,0.1)"
|
|
570
|
+
},
|
|
571
|
+
children: [
|
|
572
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
573
|
+
"Contrast: ",
|
|
574
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
575
|
+
contrastResult.ratio.toFixed(2),
|
|
576
|
+
":1"
|
|
577
|
+
] })
|
|
578
|
+
] }),
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
581
|
+
"span",
|
|
582
|
+
{
|
|
583
|
+
style: {
|
|
584
|
+
color: contrastResult.aa ? "#10b981" : "#ef4444",
|
|
585
|
+
fontWeight: 600
|
|
586
|
+
},
|
|
587
|
+
children: [
|
|
588
|
+
"AA ",
|
|
589
|
+
contrastResult.aa ? "\u2713" : "\u2717"
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
),
|
|
593
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
594
|
+
"span",
|
|
595
|
+
{
|
|
596
|
+
style: {
|
|
597
|
+
color: contrastResult.aaa ? "#10b981" : "#ef4444",
|
|
598
|
+
fontWeight: 600
|
|
599
|
+
},
|
|
600
|
+
children: [
|
|
601
|
+
"AAA ",
|
|
602
|
+
contrastResult.aaa ? "\u2713" : "\u2717"
|
|
603
|
+
]
|
|
604
|
+
}
|
|
605
|
+
)
|
|
606
|
+
] })
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
),
|
|
610
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
611
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
612
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
613
|
+
"button",
|
|
614
|
+
{
|
|
615
|
+
type: "button",
|
|
616
|
+
"data-testid": "color-picker-swatch",
|
|
617
|
+
title: color,
|
|
618
|
+
disabled,
|
|
619
|
+
"aria-label": `Color ${color}`,
|
|
620
|
+
onClick: () => {
|
|
621
|
+
onChange(color);
|
|
622
|
+
recordRecent(color);
|
|
623
|
+
},
|
|
624
|
+
style: {
|
|
625
|
+
width: "18px",
|
|
626
|
+
height: "18px",
|
|
627
|
+
borderRadius: "3px",
|
|
628
|
+
backgroundColor: color,
|
|
629
|
+
border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
|
|
630
|
+
cursor: disabled ? "default" : "pointer",
|
|
631
|
+
padding: 0,
|
|
632
|
+
outline: "none"
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
`${color}-${idx}`
|
|
636
|
+
)) })
|
|
637
|
+
] }),
|
|
638
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
640
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
641
|
+
"button",
|
|
642
|
+
{
|
|
643
|
+
type: "button",
|
|
644
|
+
"data-testid": "color-picker-recent",
|
|
645
|
+
disabled,
|
|
646
|
+
"aria-label": `Color ${color}`,
|
|
647
|
+
onClick: () => {
|
|
648
|
+
onChange(color);
|
|
649
|
+
recordRecent(color);
|
|
650
|
+
},
|
|
651
|
+
style: {
|
|
652
|
+
width: "18px",
|
|
653
|
+
height: "18px",
|
|
654
|
+
borderRadius: "3px",
|
|
655
|
+
backgroundColor: color,
|
|
656
|
+
border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
|
|
657
|
+
cursor: disabled ? "default" : "pointer",
|
|
658
|
+
padding: 0,
|
|
659
|
+
outline: "none"
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
`recent-${color}-${idx}`
|
|
663
|
+
)) })
|
|
664
|
+
] })
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
);
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
// src/color/DualColorPicker.tsx
|
|
671
|
+
var import_react2 = require("react");
|
|
672
|
+
var import_color2 = require("@pixerate/editor/color");
|
|
673
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
674
|
+
function DualColorPicker({
|
|
675
|
+
value,
|
|
676
|
+
onChange,
|
|
677
|
+
onGestureStart,
|
|
678
|
+
onGestureEnd,
|
|
679
|
+
scheme: controlledScheme,
|
|
680
|
+
onSchemeChange,
|
|
681
|
+
surfaces = import_color2.DEFAULT_SCHEME_SURFACES,
|
|
682
|
+
contrastAgainst,
|
|
683
|
+
alpha = false,
|
|
684
|
+
swatches,
|
|
685
|
+
disabled = false,
|
|
686
|
+
className = ""
|
|
687
|
+
}) {
|
|
688
|
+
const sameId = (0, import_react2.useId)();
|
|
689
|
+
const [internalScheme, setInternalScheme] = (0, import_react2.useState)("light");
|
|
690
|
+
const activeScheme = controlledScheme ?? internalScheme;
|
|
691
|
+
const handleSchemeSelect = (nextScheme) => {
|
|
692
|
+
if (onSchemeChange) {
|
|
693
|
+
onSchemeChange(nextScheme);
|
|
694
|
+
} else {
|
|
695
|
+
setInternalScheme(nextScheme);
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
699
|
+
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
700
|
+
const [sameInBoth, setSameInBoth] = (0, import_react2.useState)(isSame);
|
|
701
|
+
const handleSameToggle = (e) => {
|
|
702
|
+
const nextSame = e.target.checked;
|
|
703
|
+
setSameInBoth(nextSame);
|
|
704
|
+
if (nextSame) {
|
|
705
|
+
const activeVal = activeScheme === "dark" ? dual.dark : dual.light;
|
|
706
|
+
onChange({ light: activeVal, dark: activeVal });
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const handleDerive = () => {
|
|
710
|
+
if (disabled) return;
|
|
711
|
+
onGestureStart?.();
|
|
712
|
+
const currentActive = activeScheme === "dark" ? dual.dark : dual.light;
|
|
713
|
+
const derived = (0, import_color2.deriveDualColor)(currentActive, {
|
|
714
|
+
from: activeScheme,
|
|
715
|
+
// An unreadable surfaces prop falls back to the defaults rather than throwing.
|
|
716
|
+
surfaces: (0, import_color2.normalizeDualColor)(surfaces) ?? import_color2.DEFAULT_SCHEME_SURFACES
|
|
717
|
+
});
|
|
718
|
+
onChange(derived);
|
|
719
|
+
onGestureEnd?.();
|
|
720
|
+
};
|
|
721
|
+
const handleInnerChange = (hex) => {
|
|
722
|
+
if (sameInBoth) {
|
|
723
|
+
onChange({ light: hex, dark: hex });
|
|
724
|
+
} else {
|
|
725
|
+
const updated = (0, import_color2.setDualColorSide)(dual, activeScheme, hex);
|
|
726
|
+
onChange(updated);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
730
|
+
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
731
|
+
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
733
|
+
"div",
|
|
734
|
+
{
|
|
735
|
+
className: `pixerate-dual-color-picker ${className}`,
|
|
736
|
+
style: {
|
|
737
|
+
display: "flex",
|
|
738
|
+
flexDirection: "column",
|
|
739
|
+
gap: "12px",
|
|
740
|
+
padding: "12px",
|
|
741
|
+
background: "#1a1d24",
|
|
742
|
+
color: "#e2e8f0",
|
|
743
|
+
borderRadius: "10px",
|
|
744
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
|
|
745
|
+
width: "260px",
|
|
746
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
747
|
+
fontSize: "13px",
|
|
748
|
+
boxSizing: "border-box"
|
|
749
|
+
},
|
|
750
|
+
children: [
|
|
751
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
752
|
+
"div",
|
|
753
|
+
{
|
|
754
|
+
role: "tablist",
|
|
755
|
+
"aria-label": "Color scheme mode",
|
|
756
|
+
style: {
|
|
757
|
+
display: "flex",
|
|
758
|
+
background: "#111318",
|
|
759
|
+
borderRadius: "6px",
|
|
760
|
+
padding: "2px",
|
|
761
|
+
gap: "2px"
|
|
762
|
+
},
|
|
763
|
+
children: [
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
765
|
+
"button",
|
|
766
|
+
{
|
|
767
|
+
type: "button",
|
|
768
|
+
role: "tab",
|
|
769
|
+
"aria-selected": activeScheme === "light",
|
|
770
|
+
onClick: () => handleSchemeSelect("light"),
|
|
771
|
+
disabled,
|
|
772
|
+
style: {
|
|
773
|
+
flex: 1,
|
|
774
|
+
padding: "6px 8px",
|
|
775
|
+
border: "none",
|
|
776
|
+
borderRadius: "4px",
|
|
777
|
+
background: activeScheme === "light" ? "#2d3342" : "transparent",
|
|
778
|
+
color: activeScheme === "light" ? "#ffffff" : "#8c95a6",
|
|
779
|
+
fontWeight: activeScheme === "light" ? 600 : 400,
|
|
780
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
781
|
+
fontSize: "12px",
|
|
782
|
+
transition: "all 0.15s ease"
|
|
783
|
+
},
|
|
784
|
+
children: "Light"
|
|
785
|
+
}
|
|
786
|
+
),
|
|
787
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
788
|
+
"button",
|
|
789
|
+
{
|
|
790
|
+
type: "button",
|
|
791
|
+
role: "tab",
|
|
792
|
+
"aria-selected": activeScheme === "dark",
|
|
793
|
+
onClick: () => handleSchemeSelect("dark"),
|
|
794
|
+
disabled,
|
|
795
|
+
style: {
|
|
796
|
+
flex: 1,
|
|
797
|
+
padding: "6px 8px",
|
|
798
|
+
border: "none",
|
|
799
|
+
borderRadius: "4px",
|
|
800
|
+
background: activeScheme === "dark" ? "#2d3342" : "transparent",
|
|
801
|
+
color: activeScheme === "dark" ? "#ffffff" : "#8c95a6",
|
|
802
|
+
fontWeight: activeScheme === "dark" ? 600 : 400,
|
|
803
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
804
|
+
fontSize: "12px",
|
|
805
|
+
transition: "all 0.15s ease"
|
|
806
|
+
},
|
|
807
|
+
children: "Dark"
|
|
808
|
+
}
|
|
809
|
+
)
|
|
810
|
+
]
|
|
811
|
+
}
|
|
812
|
+
),
|
|
813
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
814
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
815
|
+
"button",
|
|
816
|
+
{
|
|
817
|
+
type: "button",
|
|
818
|
+
onClick: () => handleSchemeSelect("light"),
|
|
819
|
+
disabled,
|
|
820
|
+
title: "Edit light mode colour",
|
|
821
|
+
style: {
|
|
822
|
+
flex: 1,
|
|
823
|
+
display: "flex",
|
|
824
|
+
flexDirection: "column",
|
|
825
|
+
alignItems: "center",
|
|
826
|
+
gap: "6px",
|
|
827
|
+
padding: "8px",
|
|
828
|
+
background: surfaces.light,
|
|
829
|
+
color: "#000000",
|
|
830
|
+
border: activeScheme === "light" ? "2px solid #3b82f6" : "1px solid #333842",
|
|
831
|
+
borderRadius: "6px",
|
|
832
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
833
|
+
outline: "none"
|
|
834
|
+
},
|
|
835
|
+
children: [
|
|
836
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
837
|
+
"span",
|
|
838
|
+
{
|
|
839
|
+
style: {
|
|
840
|
+
width: "100%",
|
|
841
|
+
height: "24px",
|
|
842
|
+
borderRadius: "4px",
|
|
843
|
+
background: dual.light,
|
|
844
|
+
border: "1px solid rgba(0,0,0,0.15)"
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
849
|
+
]
|
|
850
|
+
}
|
|
851
|
+
),
|
|
852
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
853
|
+
"button",
|
|
854
|
+
{
|
|
855
|
+
type: "button",
|
|
856
|
+
onClick: () => handleSchemeSelect("dark"),
|
|
857
|
+
disabled,
|
|
858
|
+
title: "Edit dark mode colour",
|
|
859
|
+
style: {
|
|
860
|
+
flex: 1,
|
|
861
|
+
display: "flex",
|
|
862
|
+
flexDirection: "column",
|
|
863
|
+
alignItems: "center",
|
|
864
|
+
gap: "6px",
|
|
865
|
+
padding: "8px",
|
|
866
|
+
background: surfaces.dark,
|
|
867
|
+
color: "#ffffff",
|
|
868
|
+
border: activeScheme === "dark" ? "2px solid #3b82f6" : "1px solid #333842",
|
|
869
|
+
borderRadius: "6px",
|
|
870
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
871
|
+
outline: "none"
|
|
872
|
+
},
|
|
873
|
+
children: [
|
|
874
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
875
|
+
"span",
|
|
876
|
+
{
|
|
877
|
+
style: {
|
|
878
|
+
width: "100%",
|
|
879
|
+
height: "24px",
|
|
880
|
+
borderRadius: "4px",
|
|
881
|
+
background: dual.dark,
|
|
882
|
+
border: "1px solid rgba(255,255,255,0.15)"
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
),
|
|
886
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
887
|
+
]
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
] }),
|
|
891
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
892
|
+
"div",
|
|
893
|
+
{
|
|
894
|
+
style: {
|
|
895
|
+
display: "flex",
|
|
896
|
+
alignItems: "center",
|
|
897
|
+
justifyContent: "space-between",
|
|
898
|
+
gap: "8px",
|
|
899
|
+
padding: "2px 0"
|
|
900
|
+
},
|
|
901
|
+
children: [
|
|
902
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
903
|
+
"label",
|
|
904
|
+
{
|
|
905
|
+
htmlFor: sameId,
|
|
906
|
+
style: {
|
|
907
|
+
display: "flex",
|
|
908
|
+
alignItems: "center",
|
|
909
|
+
gap: "6px",
|
|
910
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
911
|
+
userSelect: "none",
|
|
912
|
+
fontSize: "12px",
|
|
913
|
+
color: "#c4cad4"
|
|
914
|
+
},
|
|
915
|
+
children: [
|
|
916
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
917
|
+
"input",
|
|
918
|
+
{
|
|
919
|
+
id: sameId,
|
|
920
|
+
type: "checkbox",
|
|
921
|
+
checked: sameInBoth,
|
|
922
|
+
onChange: handleSameToggle,
|
|
923
|
+
disabled,
|
|
924
|
+
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
925
|
+
}
|
|
926
|
+
),
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Same in both" })
|
|
928
|
+
]
|
|
929
|
+
}
|
|
930
|
+
),
|
|
931
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
932
|
+
"button",
|
|
933
|
+
{
|
|
934
|
+
type: "button",
|
|
935
|
+
onClick: handleDerive,
|
|
936
|
+
disabled,
|
|
937
|
+
style: {
|
|
938
|
+
padding: "4px 10px",
|
|
939
|
+
background: "#2d3342",
|
|
940
|
+
color: "#e2e8f0",
|
|
941
|
+
border: "1px solid #3b4252",
|
|
942
|
+
borderRadius: "4px",
|
|
943
|
+
fontSize: "11px",
|
|
944
|
+
fontWeight: 500,
|
|
945
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
946
|
+
},
|
|
947
|
+
children: "Derive"
|
|
948
|
+
}
|
|
949
|
+
)
|
|
950
|
+
]
|
|
951
|
+
}
|
|
952
|
+
),
|
|
953
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
954
|
+
"div",
|
|
955
|
+
{
|
|
956
|
+
"data-testid": "dual-contrast-summary",
|
|
957
|
+
style: {
|
|
958
|
+
display: "flex",
|
|
959
|
+
justifyContent: "space-between",
|
|
960
|
+
background: "#111318",
|
|
961
|
+
padding: "6px 8px",
|
|
962
|
+
borderRadius: "6px",
|
|
963
|
+
fontSize: "11px",
|
|
964
|
+
color: "#8c95a6"
|
|
965
|
+
},
|
|
966
|
+
children: [
|
|
967
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
968
|
+
"Light:",
|
|
969
|
+
" ",
|
|
970
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
971
|
+
dualContrast.light.ratio.toFixed(2),
|
|
972
|
+
" (",
|
|
973
|
+
dualContrast.light.level,
|
|
974
|
+
")"
|
|
975
|
+
] })
|
|
976
|
+
] }),
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
978
|
+
"Dark:",
|
|
979
|
+
" ",
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
981
|
+
dualContrast.dark.ratio.toFixed(2),
|
|
982
|
+
" (",
|
|
983
|
+
dualContrast.dark.level,
|
|
984
|
+
")"
|
|
985
|
+
] })
|
|
986
|
+
] })
|
|
987
|
+
]
|
|
988
|
+
}
|
|
989
|
+
),
|
|
990
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
991
|
+
ColorPicker,
|
|
992
|
+
{
|
|
993
|
+
value: activeColor,
|
|
994
|
+
onChange: handleInnerChange,
|
|
995
|
+
onGestureStart,
|
|
996
|
+
onGestureEnd,
|
|
997
|
+
contrastAgainst: activeContrastTarget,
|
|
998
|
+
alpha,
|
|
999
|
+
swatches,
|
|
1000
|
+
disabled
|
|
1001
|
+
}
|
|
1002
|
+
)
|
|
1003
|
+
]
|
|
1004
|
+
}
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/gradient/useGradientController.ts
|
|
1009
|
+
var import_react3 = require("react");
|
|
1010
|
+
var import_gradient = require("@pixerate/editor/gradient");
|
|
1011
|
+
function useGradientController(options) {
|
|
1012
|
+
const ref = (0, import_react3.useRef)(null);
|
|
1013
|
+
if (!ref.current) {
|
|
1014
|
+
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
1015
|
+
ref.current = new import_gradient.GradientController(resolvedOptions);
|
|
1016
|
+
}
|
|
1017
|
+
return ref.current;
|
|
1018
|
+
}
|
|
1019
|
+
function useGradientState(controller) {
|
|
1020
|
+
return (0, import_react3.useSyncExternalStore)(
|
|
1021
|
+
(onStoreChange) => controller.subscribe(onStoreChange),
|
|
1022
|
+
() => controller.state,
|
|
1023
|
+
() => controller.state
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// src/gradient/GradientEditor.tsx
|
|
1028
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1029
|
+
var DEFAULT_TYPES = ["linear", "radial", "conic"];
|
|
1030
|
+
var INTERPOLATIONS = ["oklab", "oklch", "srgb", "srgb-linear"];
|
|
1031
|
+
var buttonClass = "inline-flex h-7 items-center justify-center rounded border border-border bg-background px-2 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-primary aria-pressed:text-primary-foreground";
|
|
1032
|
+
var selectClass = "h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
|
|
1033
|
+
var inputClass = "h-7 w-16 rounded border border-border bg-background px-1.5 text-center text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
|
|
1034
|
+
function GradientEditor({
|
|
1035
|
+
controller,
|
|
1036
|
+
types = DEFAULT_TYPES,
|
|
1037
|
+
showPresets = true,
|
|
1038
|
+
showCss = false,
|
|
1039
|
+
dual: controlledDual,
|
|
1040
|
+
onGestureStart,
|
|
1041
|
+
onGestureEnd,
|
|
1042
|
+
className
|
|
1043
|
+
}) {
|
|
1044
|
+
const state = useGradientState(controller);
|
|
1045
|
+
const beginGesture = (label) => {
|
|
1046
|
+
controller.beginGesture(label);
|
|
1047
|
+
onGestureStart?.();
|
|
1048
|
+
};
|
|
1049
|
+
const endGesture = () => {
|
|
1050
|
+
controller.endGesture();
|
|
1051
|
+
onGestureEnd?.();
|
|
1052
|
+
};
|
|
1053
|
+
const gradient = state.gradient;
|
|
1054
|
+
const selectedStopId = state.selectedStopId;
|
|
1055
|
+
const isDual = controlledDual ?? (0, import_gradient2.isDualGradient)(gradient);
|
|
1056
|
+
const [activeScheme, setActiveScheme] = import_react4.default.useState("light");
|
|
1057
|
+
const [copied, setCopied] = import_react4.default.useState(false);
|
|
1058
|
+
const trackRef = (0, import_react4.useRef)(null);
|
|
1059
|
+
const angleDialRef = (0, import_react4.useRef)(null);
|
|
1060
|
+
const selectedStop = gradient.stops.find((s) => s.id === selectedStopId) ?? gradient.stops[0];
|
|
1061
|
+
const previewCss = isDual ? (0, import_gradient2.gradientToCssFallback)(gradient, 16, activeScheme) : (0, import_gradient2.gradientToCss)(gradient);
|
|
1062
|
+
const trackCss = (0, import_gradient2.gradientTrackBackground)(gradient);
|
|
1063
|
+
const handleTrackClick = (e) => {
|
|
1064
|
+
if (controller.isReadOnly) return;
|
|
1065
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1066
|
+
if (rect.width <= 0) return;
|
|
1067
|
+
const offset = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
1068
|
+
controller.addStop(offset);
|
|
1069
|
+
};
|
|
1070
|
+
const handleStopPointerDown = (e, stopId) => {
|
|
1071
|
+
if (controller.isReadOnly) return;
|
|
1072
|
+
e.stopPropagation();
|
|
1073
|
+
controller.selectStop(stopId);
|
|
1074
|
+
beginGesture("Move Stop");
|
|
1075
|
+
const startY = e.clientY;
|
|
1076
|
+
const track = trackRef.current;
|
|
1077
|
+
const rect = track?.getBoundingClientRect();
|
|
1078
|
+
const onPointerMove = (moveEvent) => {
|
|
1079
|
+
if (!rect || rect.width <= 0) return;
|
|
1080
|
+
if (moveEvent.clientY - startY > 32 && controller.getGradient().stops.length > 2) {
|
|
1081
|
+
cleanup();
|
|
1082
|
+
controller.removeStop(stopId);
|
|
1083
|
+
endGesture();
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const nextOffset = Math.max(0, Math.min(1, (moveEvent.clientX - rect.left) / rect.width));
|
|
1087
|
+
controller.updateStop(stopId, { offset: Math.round(nextOffset * 1e3) / 1e3 });
|
|
1088
|
+
};
|
|
1089
|
+
const cleanup = () => {
|
|
1090
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
1091
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
1092
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
1093
|
+
};
|
|
1094
|
+
const onPointerUp = () => {
|
|
1095
|
+
cleanup();
|
|
1096
|
+
endGesture();
|
|
1097
|
+
};
|
|
1098
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
1099
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
1100
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
1101
|
+
};
|
|
1102
|
+
const handleStopKeyDown = (e, stopId) => {
|
|
1103
|
+
if (controller.isReadOnly) return;
|
|
1104
|
+
const res = (0, import_gradient2.gradientKeyStep)(gradient, stopId, e.key, e.shiftKey);
|
|
1105
|
+
if (!res) return;
|
|
1106
|
+
e.preventDefault();
|
|
1107
|
+
if (res.remove) {
|
|
1108
|
+
if (gradient.stops.length > 2) {
|
|
1109
|
+
controller.removeStop(stopId);
|
|
1110
|
+
}
|
|
1111
|
+
} else if (res.offset !== void 0) {
|
|
1112
|
+
controller.updateStop(stopId, { offset: res.offset });
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
const handleAngleDialPointerDown = (e) => {
|
|
1116
|
+
if (controller.isReadOnly) return;
|
|
1117
|
+
const dial = angleDialRef.current;
|
|
1118
|
+
if (!dial) return;
|
|
1119
|
+
beginGesture("Change Angle");
|
|
1120
|
+
const rect = dial.getBoundingClientRect();
|
|
1121
|
+
const center = { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
|
1122
|
+
const update = (pe) => {
|
|
1123
|
+
const deg = (0, import_gradient2.angleFromPointer)(center, { x: pe.clientX, y: pe.clientY }, pe.shiftKey ? 15 : 1);
|
|
1124
|
+
controller.setAngle(deg);
|
|
1125
|
+
};
|
|
1126
|
+
update(e.nativeEvent);
|
|
1127
|
+
const cleanup = () => {
|
|
1128
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
1129
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
1130
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
1131
|
+
};
|
|
1132
|
+
const onPointerMove = (pe) => update(pe);
|
|
1133
|
+
const onPointerUp = () => {
|
|
1134
|
+
cleanup();
|
|
1135
|
+
endGesture();
|
|
1136
|
+
};
|
|
1137
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
1138
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
1139
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
1140
|
+
};
|
|
1141
|
+
const copyCss = (0, import_react4.useCallback)(() => {
|
|
1142
|
+
const text = (0, import_gradient2.gradientToCss)(gradient);
|
|
1143
|
+
navigator.clipboard?.writeText(text).then(() => {
|
|
1144
|
+
setCopied(true);
|
|
1145
|
+
setTimeout(() => setCopied(false), 1500);
|
|
1146
|
+
});
|
|
1147
|
+
}, [gradient]);
|
|
1148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1149
|
+
"div",
|
|
1150
|
+
{
|
|
1151
|
+
className: `flex flex-col gap-3 rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm ${className ?? ""}`,
|
|
1152
|
+
"data-testid": "gradient-editor",
|
|
1153
|
+
children: [
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative h-20 w-full overflow-hidden rounded-md border border-border", children: [
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1156
|
+
"div",
|
|
1157
|
+
{
|
|
1158
|
+
className: "absolute inset-0",
|
|
1159
|
+
style: {
|
|
1160
|
+
backgroundImage: "linear-gradient(45deg, #e0e0e0 25%, transparent 25%), linear-gradient(-45deg, #e0e0e0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e0e0e0 75%), linear-gradient(-45deg, transparent 75%, #e0e0e0 75%)",
|
|
1161
|
+
backgroundSize: "16px 16px",
|
|
1162
|
+
backgroundPosition: "0 0, 0 8px, 8px -8px, -8px 0px"
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
),
|
|
1166
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1167
|
+
"div",
|
|
1168
|
+
{
|
|
1169
|
+
className: "absolute inset-0 transition-all",
|
|
1170
|
+
style: { background: previewCss },
|
|
1171
|
+
"data-testid": "gradient-preview"
|
|
1172
|
+
}
|
|
1173
|
+
)
|
|
1174
|
+
] }),
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1177
|
+
"div",
|
|
1178
|
+
{
|
|
1179
|
+
ref: trackRef,
|
|
1180
|
+
role: "button",
|
|
1181
|
+
tabIndex: 0,
|
|
1182
|
+
"aria-label": "Add gradient stop",
|
|
1183
|
+
className: "relative h-6 w-full cursor-pointer rounded border border-border",
|
|
1184
|
+
style: { background: trackCss },
|
|
1185
|
+
onClick: handleTrackClick,
|
|
1186
|
+
"data-testid": "gradient-track",
|
|
1187
|
+
children: gradient.stops.map((stop, idx) => {
|
|
1188
|
+
const isSelected = stop.id === selectedStopId;
|
|
1189
|
+
const pct = Math.round(stop.offset * 100);
|
|
1190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1191
|
+
"button",
|
|
1192
|
+
{
|
|
1193
|
+
type: "button",
|
|
1194
|
+
role: "slider",
|
|
1195
|
+
"aria-label": `Stop ${idx + 1}, ${stop.color} at ${pct}%`,
|
|
1196
|
+
"aria-valuemin": 0,
|
|
1197
|
+
"aria-valuemax": 100,
|
|
1198
|
+
"aria-valuenow": pct,
|
|
1199
|
+
"aria-pressed": isSelected,
|
|
1200
|
+
disabled: controller.isReadOnly,
|
|
1201
|
+
className: `absolute top-1/2 h-6 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded border border-white shadow-sm transition-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${isSelected ? "scale-110 ring-2 ring-primary z-10" : "hover:scale-105"}`,
|
|
1202
|
+
style: {
|
|
1203
|
+
left: `${stop.offset * 100}%`,
|
|
1204
|
+
backgroundColor: stop.color.startsWith("light-dark(") ? "#888" : stop.color
|
|
1205
|
+
},
|
|
1206
|
+
onClick: (e) => {
|
|
1207
|
+
e.stopPropagation();
|
|
1208
|
+
controller.selectStop(stop.id);
|
|
1209
|
+
},
|
|
1210
|
+
onPointerDown: (e) => handleStopPointerDown(e, stop.id),
|
|
1211
|
+
onKeyDown: (e) => handleStopKeyDown(e, stop.id),
|
|
1212
|
+
"data-testid": `gradient-stop-${stop.id}`
|
|
1213
|
+
},
|
|
1214
|
+
stop.id
|
|
1215
|
+
);
|
|
1216
|
+
})
|
|
1217
|
+
}
|
|
1218
|
+
),
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex justify-between px-0.5 text-[10px] text-muted-foreground", children: [
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "0%" }),
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "50%" }),
|
|
1222
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "100%" })
|
|
1223
|
+
] })
|
|
1224
|
+
] }),
|
|
1225
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1226
|
+
types.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex rounded-md border border-border p-0.5", children: types.map((t) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1227
|
+
"button",
|
|
1228
|
+
{
|
|
1229
|
+
type: "button",
|
|
1230
|
+
className: buttonClass,
|
|
1231
|
+
"aria-pressed": gradient.type === t,
|
|
1232
|
+
disabled: controller.isReadOnly,
|
|
1233
|
+
onClick: () => controller.setType(t),
|
|
1234
|
+
children: t.charAt(0).toUpperCase() + t.slice(1)
|
|
1235
|
+
},
|
|
1236
|
+
t
|
|
1237
|
+
)) }),
|
|
1238
|
+
(gradient.type === "linear" || gradient.type === "conic") && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
1239
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1240
|
+
"div",
|
|
1241
|
+
{
|
|
1242
|
+
ref: angleDialRef,
|
|
1243
|
+
role: "slider",
|
|
1244
|
+
tabIndex: 0,
|
|
1245
|
+
"aria-label": "Gradient angle",
|
|
1246
|
+
"aria-valuemin": 0,
|
|
1247
|
+
"aria-valuemax": 360,
|
|
1248
|
+
"aria-valuenow": gradient.angle ?? 180,
|
|
1249
|
+
className: "relative h-7 w-7 cursor-crosshair rounded-full border border-border bg-muted/40 shadow-inner flex items-center justify-center focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary",
|
|
1250
|
+
onPointerDown: handleAngleDialPointerDown,
|
|
1251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1252
|
+
"div",
|
|
1253
|
+
{
|
|
1254
|
+
className: "h-2.5 w-0.5 rounded-full bg-foreground",
|
|
1255
|
+
style: {
|
|
1256
|
+
transform: `rotate(${gradient.angle ?? 180}deg) translateY(-50%)`,
|
|
1257
|
+
transformOrigin: "50% 100%"
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
)
|
|
1261
|
+
}
|
|
1262
|
+
),
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1264
|
+
"input",
|
|
1265
|
+
{
|
|
1266
|
+
type: "number",
|
|
1267
|
+
"aria-label": "Angle in degrees",
|
|
1268
|
+
className: inputClass,
|
|
1269
|
+
min: 0,
|
|
1270
|
+
max: 360,
|
|
1271
|
+
value: Math.round(gradient.angle ?? 180),
|
|
1272
|
+
disabled: controller.isReadOnly,
|
|
1273
|
+
onChange: (e) => controller.setAngle(Number(e.target.value) % 360)
|
|
1274
|
+
}
|
|
1275
|
+
),
|
|
1276
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-xs text-muted-foreground", children: "\xB0" })
|
|
1277
|
+
] }),
|
|
1278
|
+
gradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1279
|
+
"button",
|
|
1280
|
+
{
|
|
1281
|
+
type: "button",
|
|
1282
|
+
className: buttonClass,
|
|
1283
|
+
"aria-pressed": (gradient.shape ?? "ellipse") === "circle",
|
|
1284
|
+
disabled: controller.isReadOnly,
|
|
1285
|
+
onClick: () => controller.setShape((gradient.shape ?? "ellipse") === "circle" ? "ellipse" : "circle"),
|
|
1286
|
+
children: (gradient.shape ?? "ellipse") === "circle" ? "Circle" : "Ellipse"
|
|
1287
|
+
}
|
|
1288
|
+
) }),
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1290
|
+
"select",
|
|
1291
|
+
{
|
|
1292
|
+
"aria-label": "Interpolation space",
|
|
1293
|
+
className: selectClass,
|
|
1294
|
+
value: gradient.interpolation ?? "oklab",
|
|
1295
|
+
disabled: controller.isReadOnly,
|
|
1296
|
+
onChange: (e) => controller.setInterpolation(e.target.value),
|
|
1297
|
+
children: INTERPOLATIONS.map((space) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: space, children: space }, space))
|
|
1298
|
+
}
|
|
1299
|
+
),
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1 ml-auto", children: [
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1302
|
+
"button",
|
|
1303
|
+
{
|
|
1304
|
+
type: "button",
|
|
1305
|
+
className: buttonClass,
|
|
1306
|
+
title: "Reverse stops",
|
|
1307
|
+
"aria-label": "Reverse stops",
|
|
1308
|
+
disabled: controller.isReadOnly,
|
|
1309
|
+
onClick: () => controller.reverse(),
|
|
1310
|
+
children: "\u21C4"
|
|
1311
|
+
}
|
|
1312
|
+
),
|
|
1313
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1314
|
+
"button",
|
|
1315
|
+
{
|
|
1316
|
+
type: "button",
|
|
1317
|
+
className: buttonClass,
|
|
1318
|
+
title: "Distribute stops evenly",
|
|
1319
|
+
"aria-label": "Distribute stops evenly",
|
|
1320
|
+
disabled: controller.isReadOnly,
|
|
1321
|
+
onClick: () => controller.distribute(),
|
|
1322
|
+
children: "\u2AF6\u2AF6"
|
|
1323
|
+
}
|
|
1324
|
+
),
|
|
1325
|
+
gradient.stops.length > 2 && selectedStop && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1326
|
+
"button",
|
|
1327
|
+
{
|
|
1328
|
+
type: "button",
|
|
1329
|
+
className: buttonClass,
|
|
1330
|
+
title: "Delete selected stop",
|
|
1331
|
+
"aria-label": "Delete selected stop",
|
|
1332
|
+
disabled: controller.isReadOnly,
|
|
1333
|
+
onClick: () => controller.removeStop(selectedStop.id),
|
|
1334
|
+
children: "\u2715"
|
|
1335
|
+
}
|
|
1336
|
+
)
|
|
1337
|
+
] })
|
|
1338
|
+
] }),
|
|
1339
|
+
selectedStop && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "rounded-md border border-border p-2", children: [
|
|
1340
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mb-2 flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
1342
|
+
"Selected Stop (",
|
|
1343
|
+
Math.round(selectedStop.offset * 100),
|
|
1344
|
+
"%)"
|
|
1345
|
+
] }),
|
|
1346
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1347
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Offset:" }),
|
|
1348
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1349
|
+
"input",
|
|
1350
|
+
{
|
|
1351
|
+
type: "number",
|
|
1352
|
+
"aria-label": "Stop offset percentage",
|
|
1353
|
+
className: inputClass,
|
|
1354
|
+
min: 0,
|
|
1355
|
+
max: 100,
|
|
1356
|
+
value: Math.round(selectedStop.offset * 100),
|
|
1357
|
+
disabled: controller.isReadOnly,
|
|
1358
|
+
onChange: (e) => controller.updateStop(selectedStop.id, {
|
|
1359
|
+
offset: Math.max(0, Math.min(100, Number(e.target.value))) / 100
|
|
1360
|
+
})
|
|
1361
|
+
}
|
|
1362
|
+
),
|
|
1363
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "%" })
|
|
1364
|
+
] })
|
|
1365
|
+
] }),
|
|
1366
|
+
isDual ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1367
|
+
DualColorPicker,
|
|
1368
|
+
{
|
|
1369
|
+
value: selectedStop.color,
|
|
1370
|
+
scheme: activeScheme,
|
|
1371
|
+
onSchemeChange: setActiveScheme,
|
|
1372
|
+
onChange: (dualColor) => {
|
|
1373
|
+
controller.updateStop(selectedStop.id, {
|
|
1374
|
+
color: (0, import_color3.formatDualColor)(dualColor)
|
|
1375
|
+
});
|
|
1376
|
+
},
|
|
1377
|
+
onGestureStart: () => beginGesture("Change Stop Color"),
|
|
1378
|
+
onGestureEnd: () => endGesture(),
|
|
1379
|
+
disabled: controller.isReadOnly
|
|
1380
|
+
}
|
|
1381
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1382
|
+
ColorPicker,
|
|
1383
|
+
{
|
|
1384
|
+
value: selectedStop.color,
|
|
1385
|
+
alpha: true,
|
|
1386
|
+
onChange: (color) => {
|
|
1387
|
+
controller.updateStop(selectedStop.id, { color });
|
|
1388
|
+
},
|
|
1389
|
+
onGestureStart: () => beginGesture("Change Stop Color"),
|
|
1390
|
+
onGestureEnd: () => endGesture(),
|
|
1391
|
+
disabled: controller.isReadOnly
|
|
1392
|
+
}
|
|
1393
|
+
)
|
|
1394
|
+
] }),
|
|
1395
|
+
showPresets && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
1396
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Presets" }),
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex flex-wrap gap-1.5", "data-testid": "gradient-presets", children: Object.entries(import_gradient2.GRADIENT_PRESETS).map(([name, preset]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1398
|
+
"button",
|
|
1399
|
+
{
|
|
1400
|
+
type: "button",
|
|
1401
|
+
className: "h-6 w-10 rounded border border-border shadow-sm transition hover:scale-105 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary",
|
|
1402
|
+
style: { background: (0, import_gradient2.gradientToCss)(preset) },
|
|
1403
|
+
title: name,
|
|
1404
|
+
"aria-label": `Preset ${name}`,
|
|
1405
|
+
disabled: controller.isReadOnly,
|
|
1406
|
+
onClick: () => controller.setGradient(preset, `Apply Preset ${name}`)
|
|
1407
|
+
},
|
|
1408
|
+
name
|
|
1409
|
+
)) })
|
|
1410
|
+
] }),
|
|
1411
|
+
showCss && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-col gap-1 border-t border-border pt-2", children: [
|
|
1412
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1413
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-[11px] font-medium text-muted-foreground", children: "CSS Code" }),
|
|
1414
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: buttonClass, onClick: copyCss, children: copied ? "Copied!" : "Copy" })
|
|
1415
|
+
] }),
|
|
1416
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "overflow-x-auto rounded bg-muted p-2 font-mono text-[11px] text-foreground select-all", children: (0, import_gradient2.gradientToCss)(gradient) })
|
|
1417
|
+
] })
|
|
1418
|
+
]
|
|
1419
|
+
}
|
|
1420
|
+
);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
// src/gradient/FillPicker.tsx
|
|
1424
|
+
var import_react5 = require("react");
|
|
1425
|
+
var import_gradient3 = require("@pixerate/editor/gradient");
|
|
1426
|
+
var import_color4 = require("@pixerate/editor/color");
|
|
1427
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1428
|
+
var DEFAULT_MODES = ["solid", "gradient"];
|
|
1429
|
+
var buttonClass2 = "inline-flex h-7 items-center justify-center rounded border border-border bg-background px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-primary aria-pressed:text-primary-foreground";
|
|
1430
|
+
function createDefaultGradientFromColor(colorStr) {
|
|
1431
|
+
const parsed = (0, import_color4.parseColor)(colorStr);
|
|
1432
|
+
const baseHex = parsed ? (0, import_color4.formatHex)(parsed) : "#3b82f6";
|
|
1433
|
+
const lighterHex = (0, import_color4.mixColors)(baseHex, "#ffffff", 0.35, { space: "oklab" }) ?? "#ffffff";
|
|
1434
|
+
return (0, import_gradient3.createGradient)([baseHex, lighterHex]);
|
|
1435
|
+
}
|
|
1436
|
+
function FillPicker({
|
|
1437
|
+
value,
|
|
1438
|
+
onChange,
|
|
1439
|
+
onGestureStart,
|
|
1440
|
+
onGestureEnd,
|
|
1441
|
+
modes = DEFAULT_MODES,
|
|
1442
|
+
alpha = false,
|
|
1443
|
+
swatches,
|
|
1444
|
+
showPresets = true,
|
|
1445
|
+
showCss = false,
|
|
1446
|
+
className,
|
|
1447
|
+
disabled = false
|
|
1448
|
+
}) {
|
|
1449
|
+
const allowsSolid = modes.includes("solid");
|
|
1450
|
+
const allowsGradient = modes.includes("gradient");
|
|
1451
|
+
const modeFor = (v) => (0, import_gradient3.parseCssGradient)(v) && allowsGradient ? "gradient" : allowsSolid ? "solid" : "gradient";
|
|
1452
|
+
const [mode, setModeState] = (0, import_react5.useState)(() => modeFor(value));
|
|
1453
|
+
const latest = (0, import_react5.useRef)({ onChange, mode, disabled });
|
|
1454
|
+
latest.current.onChange = onChange;
|
|
1455
|
+
latest.current.disabled = disabled;
|
|
1456
|
+
const setMode = (next) => {
|
|
1457
|
+
latest.current.mode = next;
|
|
1458
|
+
setModeState(next);
|
|
1459
|
+
};
|
|
1460
|
+
const isDraggingRef = (0, import_react5.useRef)(false);
|
|
1461
|
+
const emittedRef = (0, import_react5.useRef)(null);
|
|
1462
|
+
const loadingRef = (0, import_react5.useRef)(false);
|
|
1463
|
+
const controllerRef = (0, import_react5.useRef)(null);
|
|
1464
|
+
if (!controllerRef.current) {
|
|
1465
|
+
controllerRef.current = new import_gradient3.GradientController({
|
|
1466
|
+
value: (0, import_gradient3.parseCssGradient)(value) ?? createDefaultGradientFromColor(value),
|
|
1467
|
+
readOnly: () => latest.current.disabled,
|
|
1468
|
+
onChange: (g) => {
|
|
1469
|
+
if (loadingRef.current || latest.current.mode !== "gradient") return;
|
|
1470
|
+
const css = (0, import_gradient3.gradientToCss)(g);
|
|
1471
|
+
emittedRef.current = css;
|
|
1472
|
+
latest.current.onChange(css);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
const controller = controllerRef.current;
|
|
1477
|
+
const modesKey = modes.join(",");
|
|
1478
|
+
(0, import_react5.useEffect)(() => {
|
|
1479
|
+
if (isDraggingRef.current) return;
|
|
1480
|
+
const incoming = (0, import_gradient3.parseCssGradient)(value);
|
|
1481
|
+
if (incoming && allowsGradient) {
|
|
1482
|
+
setMode("gradient");
|
|
1483
|
+
if (value !== emittedRef.current) {
|
|
1484
|
+
loadingRef.current = true;
|
|
1485
|
+
try {
|
|
1486
|
+
controller.load(incoming);
|
|
1487
|
+
} finally {
|
|
1488
|
+
loadingRef.current = false;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
} else if (!incoming && allowsSolid) {
|
|
1492
|
+
setMode("solid");
|
|
1493
|
+
}
|
|
1494
|
+
}, [value, modesKey, controller]);
|
|
1495
|
+
const handleGestureStart = () => {
|
|
1496
|
+
isDraggingRef.current = true;
|
|
1497
|
+
onGestureStart?.();
|
|
1498
|
+
};
|
|
1499
|
+
const handleGestureEnd = () => {
|
|
1500
|
+
isDraggingRef.current = false;
|
|
1501
|
+
onGestureEnd?.();
|
|
1502
|
+
};
|
|
1503
|
+
const emit = (next) => {
|
|
1504
|
+
emittedRef.current = next;
|
|
1505
|
+
onChange(next);
|
|
1506
|
+
};
|
|
1507
|
+
const switchToSolid = () => {
|
|
1508
|
+
if (latest.current.mode === "solid") return;
|
|
1509
|
+
setMode("solid");
|
|
1510
|
+
const first = controller.getGradient().stops[0]?.color ?? "#000000";
|
|
1511
|
+
emit((0, import_color4.resolveColor)(first, "light") ?? "#000000");
|
|
1512
|
+
};
|
|
1513
|
+
const switchToGradient = () => {
|
|
1514
|
+
if (latest.current.mode === "gradient") return;
|
|
1515
|
+
setMode("gradient");
|
|
1516
|
+
const next = createDefaultGradientFromColor(value);
|
|
1517
|
+
loadingRef.current = true;
|
|
1518
|
+
try {
|
|
1519
|
+
controller.load(next);
|
|
1520
|
+
} finally {
|
|
1521
|
+
loadingRef.current = false;
|
|
1522
|
+
}
|
|
1523
|
+
emit((0, import_gradient3.gradientToCss)(controller.getGradient()));
|
|
1524
|
+
};
|
|
1525
|
+
const gradientEditor = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1526
|
+
GradientEditor,
|
|
1527
|
+
{
|
|
1528
|
+
controller,
|
|
1529
|
+
showPresets,
|
|
1530
|
+
showCss,
|
|
1531
|
+
onGestureStart: handleGestureStart,
|
|
1532
|
+
onGestureEnd: handleGestureEnd
|
|
1533
|
+
}
|
|
1534
|
+
);
|
|
1535
|
+
if (modes.length === 1 && modes[0] === "solid") {
|
|
1536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, "data-testid": "fill-picker", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1537
|
+
ColorPicker,
|
|
1538
|
+
{
|
|
1539
|
+
value,
|
|
1540
|
+
onChange,
|
|
1541
|
+
onGestureStart,
|
|
1542
|
+
onGestureEnd,
|
|
1543
|
+
alpha,
|
|
1544
|
+
swatches,
|
|
1545
|
+
disabled
|
|
1546
|
+
}
|
|
1547
|
+
) });
|
|
1548
|
+
}
|
|
1549
|
+
if (modes.length === 1 && modes[0] === "gradient") {
|
|
1550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, "data-testid": "fill-picker", children: gradientEditor });
|
|
1551
|
+
}
|
|
1552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col gap-2.5 ${className ?? ""}`, "data-testid": "fill-picker", children: [
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex rounded-md border border-border p-0.5", children: [
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1555
|
+
"button",
|
|
1556
|
+
{
|
|
1557
|
+
type: "button",
|
|
1558
|
+
className: `flex-1 ${buttonClass2}`,
|
|
1559
|
+
"aria-pressed": mode === "solid",
|
|
1560
|
+
disabled,
|
|
1561
|
+
onClick: switchToSolid,
|
|
1562
|
+
children: "Solid"
|
|
1563
|
+
}
|
|
1564
|
+
),
|
|
1565
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1566
|
+
"button",
|
|
1567
|
+
{
|
|
1568
|
+
type: "button",
|
|
1569
|
+
className: `flex-1 ${buttonClass2}`,
|
|
1570
|
+
"aria-pressed": mode === "gradient",
|
|
1571
|
+
disabled,
|
|
1572
|
+
onClick: switchToGradient,
|
|
1573
|
+
children: "Gradient"
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1576
|
+
] }),
|
|
1577
|
+
mode === "solid" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1578
|
+
ColorPicker,
|
|
1579
|
+
{
|
|
1580
|
+
value,
|
|
1581
|
+
onChange,
|
|
1582
|
+
onGestureStart: handleGestureStart,
|
|
1583
|
+
onGestureEnd: handleGestureEnd,
|
|
1584
|
+
alpha,
|
|
1585
|
+
swatches,
|
|
1586
|
+
disabled
|
|
1587
|
+
}
|
|
1588
|
+
) : gradientEditor
|
|
1589
|
+
] });
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
// src/gradient/index.ts
|
|
1593
|
+
__reExport(gradient_exports, require("@pixerate/editor/gradient"), module.exports);
|
|
1594
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1595
|
+
0 && (module.exports = {
|
|
1596
|
+
FillPicker,
|
|
1597
|
+
GradientEditor,
|
|
1598
|
+
useGradientController,
|
|
1599
|
+
useGradientState,
|
|
1600
|
+
...require("@pixerate/editor/gradient")
|
|
1601
|
+
});
|