@pixerate/editor-react 0.160.0 → 0.162.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/dist/paint-editor/StickerPanel.d.cts +3 -3
- package/dist/paint-editor/StickerPanel.d.ts +3 -3
- package/dist/paint-editor/StrokePanel.d.cts +12 -0
- package/dist/paint-editor/StrokePanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +399 -303
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +167 -72
- package/package.json +3 -3
|
@@ -43,6 +43,7 @@ __export(paint_editor_exports, {
|
|
|
43
43
|
PaintToolbar: () => PaintToolbar,
|
|
44
44
|
PaperPanel: () => PaperPanel,
|
|
45
45
|
StickerPanel: () => StickerPanel,
|
|
46
|
+
StrokePanel: () => StrokePanel,
|
|
46
47
|
WetPanel: () => WetPanel,
|
|
47
48
|
usePaintDirector: () => usePaintDirector,
|
|
48
49
|
usePaintEditor: () => usePaintEditor,
|
|
@@ -89,6 +90,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
89
90
|
const [size, setSize] = (0, import_react2.useState)({ width: 800, height: 600 });
|
|
90
91
|
const measured = (0, import_react2.useRef)(false);
|
|
91
92
|
const [predicted, setPredicted] = (0, import_react2.useState)([]);
|
|
93
|
+
const [strokeDrag, setStrokeDrag] = (0, import_react2.useState)(null);
|
|
92
94
|
const presenter = (0, import_react2.useMemo)(() => new import_paint_editor2.PaintCanvasPresenter(controller), [controller]);
|
|
93
95
|
const gesture = (0, import_react2.useMemo)(
|
|
94
96
|
() => new import_paint_editor2.PaintGesture(controller, () => {
|
|
@@ -142,7 +144,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
142
144
|
}, [gesture]);
|
|
143
145
|
const report = () => onError?.(gesture.error);
|
|
144
146
|
const transform = (0, import_paint_editor2.viewCssTransform)(state.view, doc, size);
|
|
145
|
-
const lines = showGuides ? (0, import_paint_editor2.guideOverlay)(controller) : [];
|
|
147
|
+
const lines = showGuides ? (0, import_paint_editor2.guideOverlay)(controller, strokeDrag) : [];
|
|
146
148
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
147
149
|
"div",
|
|
148
150
|
{
|
|
@@ -152,7 +154,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
152
154
|
"aria-label": "Paint canvas",
|
|
153
155
|
"data-testid": "paint-canvas",
|
|
154
156
|
className: `relative overflow-hidden bg-slate-950 outline-none touch-none select-none ${className ?? ""}`,
|
|
155
|
-
style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : "crosshair" },
|
|
157
|
+
style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : tool === "stroke" ? "default" : "crosshair" },
|
|
156
158
|
onPointerDown: (e) => {
|
|
157
159
|
viewport.current?.focus();
|
|
158
160
|
if (gesture.down(e.nativeEvent)) e.target.setPointerCapture?.(e.pointerId);
|
|
@@ -161,14 +163,18 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
161
163
|
onPointerMove: (e) => {
|
|
162
164
|
gesture.move(e.nativeEvent);
|
|
163
165
|
if (gesture.predicted.length || predicted.length) setPredicted(gesture.predicted.map((p) => ({ x: p.x, y: p.y })));
|
|
166
|
+
if (gesture.strokeDrag || strokeDrag) setStrokeDrag(gesture.strokeDrag);
|
|
164
167
|
},
|
|
165
168
|
onPointerUp: (e) => {
|
|
166
169
|
gesture.up(e.nativeEvent);
|
|
167
170
|
setPredicted([]);
|
|
171
|
+
setStrokeDrag(null);
|
|
172
|
+
report();
|
|
168
173
|
},
|
|
169
174
|
onPointerCancel: () => {
|
|
170
175
|
gesture.cancel();
|
|
171
176
|
setPredicted([]);
|
|
177
|
+
setStrokeDrag(null);
|
|
172
178
|
},
|
|
173
179
|
onKeyDown: (e) => {
|
|
174
180
|
if ((0, import_paint_editor2.handlePaintShortcut)(controller, gesture, e)) e.preventDefault();
|
|
@@ -203,8 +209,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
203
209
|
y1: l.from.y,
|
|
204
210
|
x2: l.to.x,
|
|
205
211
|
y2: l.to.y,
|
|
206
|
-
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : "#f472b6",
|
|
207
|
-
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" ? 0.8 : 0.35,
|
|
212
|
+
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "stroke" || l.kind === "sticker" ? "#818cf8" : "#f472b6",
|
|
213
|
+
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "stroke" || l.kind === "sticker" ? 0.8 : 0.35,
|
|
208
214
|
strokeWidth: 1 / state.view.zoom,
|
|
209
215
|
strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
|
|
210
216
|
},
|
|
@@ -1157,6 +1163,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1157
1163
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1158
1164
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1159
1165
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1166
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1160
1167
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1161
1168
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1162
1169
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
@@ -1204,6 +1211,10 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1204
1211
|
}
|
|
1205
1212
|
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1206
1213
|
l.type === "group" ? "\u25B8 " : "",
|
|
1214
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1215
|
+
"\u270E",
|
|
1216
|
+
" "
|
|
1217
|
+
] }),
|
|
1207
1218
|
l.name
|
|
1208
1219
|
] }),
|
|
1209
1220
|
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
@@ -1300,13 +1311,13 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1300
1311
|
};
|
|
1301
1312
|
|
|
1302
1313
|
// src/paint-editor/StickerPanel.tsx
|
|
1303
|
-
var import_react10 = require("react");
|
|
1304
1314
|
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
1305
1315
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1306
1316
|
var StickerPanel = ({ controller, className }) => {
|
|
1307
1317
|
const state = usePaintEditorState(controller);
|
|
1308
1318
|
const [error, attempt] = useAttempt();
|
|
1309
|
-
const
|
|
1319
|
+
const picked = state.selectedSticker;
|
|
1320
|
+
const setPicked = (id) => controller.selectSticker(id);
|
|
1310
1321
|
const layerId = state.document.activeLayerId;
|
|
1311
1322
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1312
1323
|
if (!stickers.length) return null;
|
|
@@ -1323,6 +1334,22 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1323
1334
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Stamp" }),
|
|
1324
1335
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { "aria-label": "Sticker stamp", value: sel.stamp, onChange: (e) => attempt(() => controller.updateSticker(layerId, sel.id, { stamp: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor12.STAMP_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k, children: import_paint_editor12.STAMP_LABELS[k] }, k)) })
|
|
1325
1336
|
] }),
|
|
1337
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1338
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Position" }),
|
|
1339
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1340
|
+
"input",
|
|
1341
|
+
{
|
|
1342
|
+
type: "number",
|
|
1343
|
+
"aria-label": `Sticker ${k}`,
|
|
1344
|
+
defaultValue: sel[k],
|
|
1345
|
+
step: 1,
|
|
1346
|
+
onBlur: (e) => Number(e.target.value) !== sel[k] && attempt(() => controller.updateSticker(layerId, sel.id, { [k]: Number(e.target.value) })),
|
|
1347
|
+
onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
|
|
1348
|
+
className: "w-16 rounded bg-slate-800 px-1 py-0.5"
|
|
1349
|
+
},
|
|
1350
|
+
`${sel.id}-${k}-${sel[k]}`
|
|
1351
|
+
)) })
|
|
1352
|
+
] }),
|
|
1326
1353
|
import_paint_editor12.STICKER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor12.readPath)(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1327
1354
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1328
1355
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
@@ -1338,29 +1365,96 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1338
1365
|
] });
|
|
1339
1366
|
};
|
|
1340
1367
|
|
|
1368
|
+
// src/paint-editor/StrokePanel.tsx
|
|
1369
|
+
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
1370
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1371
|
+
var StrokePanel = ({ controller, className }) => {
|
|
1372
|
+
const state = usePaintEditorState(controller);
|
|
1373
|
+
const [error, attempt] = useAttempt();
|
|
1374
|
+
const layerId = state.document.activeLayerId;
|
|
1375
|
+
const strokes = layerId ? state.document.liveStrokes?.[layerId] : void 0;
|
|
1376
|
+
if (!layerId || !strokes) return null;
|
|
1377
|
+
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1378
|
+
const sel = index >= 0 ? strokes[index] : null;
|
|
1379
|
+
const brushes = state.brushes.filter((b) => !(0, import_paint_editor13.liveStrokeRefusal)(b));
|
|
1380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1381
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1382
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
1383
|
+
"Strokes (",
|
|
1384
|
+
strokes.length,
|
|
1385
|
+
")"
|
|
1386
|
+
] }),
|
|
1387
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1388
|
+
] }),
|
|
1389
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1390
|
+
"button",
|
|
1391
|
+
{
|
|
1392
|
+
type: "button",
|
|
1393
|
+
role: "option",
|
|
1394
|
+
"aria-selected": s.id === state.selectedStroke,
|
|
1395
|
+
title: `${i + 1}. ${s.brush.name} (${s.id})`,
|
|
1396
|
+
className: `h-5 w-5 rounded ring-1 ${s.id === state.selectedStroke ? "ring-indigo-400" : "ring-slate-700"}`,
|
|
1397
|
+
style: { background: s.color },
|
|
1398
|
+
onClick: () => controller.selectStroke(s.id)
|
|
1399
|
+
},
|
|
1400
|
+
s.id
|
|
1401
|
+
)) }),
|
|
1402
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1404
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Brush" }),
|
|
1405
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1406
|
+
"select",
|
|
1407
|
+
{
|
|
1408
|
+
"aria-label": "Stroke brush",
|
|
1409
|
+
value: brushes.some((b) => b.id === sel.brush.id) ? sel.brush.id : "",
|
|
1410
|
+
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1411
|
+
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1412
|
+
children: [
|
|
1413
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: sel.brush.name }),
|
|
1414
|
+
brushes.map((b) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: b.id, children: b.name }, b.id))
|
|
1415
|
+
]
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
] }),
|
|
1419
|
+
import_paint_editor13.STROKE_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor13.readPath)(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1420
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1421
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1423
|
+
] }),
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: index === strokes.length - 1, "aria-label": "Move stroke up", onClick: () => attempt(() => controller.reorderStroke(sel.id, index + 1)), children: "\u2191" }),
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1429
|
+
] })
|
|
1430
|
+
] }),
|
|
1431
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorLine, { error })
|
|
1432
|
+
] });
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1341
1435
|
// src/paint-editor/PaintEditor.tsx
|
|
1342
|
-
var
|
|
1343
|
-
var
|
|
1436
|
+
var import_react23 = require("react");
|
|
1437
|
+
var import_paint_editor15 = require("@pixerate/editor/paint-editor");
|
|
1344
1438
|
|
|
1345
1439
|
// src/playback/AgentPlaybackContext.tsx
|
|
1346
|
-
var
|
|
1347
|
-
var
|
|
1348
|
-
var AgentPlaybackContext = (0,
|
|
1440
|
+
var import_react10 = require("react");
|
|
1441
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1442
|
+
var AgentPlaybackContext = (0, import_react10.createContext)(null);
|
|
1349
1443
|
function useAgentPlayback() {
|
|
1350
|
-
return (0,
|
|
1444
|
+
return (0, import_react10.useContext)(AgentPlaybackContext);
|
|
1351
1445
|
}
|
|
1352
1446
|
|
|
1353
1447
|
// src/playback/usePlaybackSurface.ts
|
|
1354
|
-
var
|
|
1448
|
+
var import_react11 = require("react");
|
|
1355
1449
|
var import_tools = require("@pixerate/editor/tools");
|
|
1356
1450
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
1357
1451
|
const ambient = useAgentPlayback();
|
|
1358
1452
|
const target = playback === void 0 ? ambient : playback;
|
|
1359
|
-
const [ownPresence] = (0,
|
|
1453
|
+
const [ownPresence] = (0, import_react11.useState)(() => new import_tools.PresenceStore());
|
|
1360
1454
|
const presence = sharedPresence ?? ownPresence;
|
|
1361
|
-
const latest = (0,
|
|
1455
|
+
const latest = (0, import_react11.useRef)(options);
|
|
1362
1456
|
latest.current = options;
|
|
1363
|
-
(0,
|
|
1457
|
+
(0, import_react11.useEffect)(() => {
|
|
1364
1458
|
if (!target || !id) return;
|
|
1365
1459
|
const o = () => latest.current;
|
|
1366
1460
|
const surface = {
|
|
@@ -1392,13 +1486,13 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
1392
1486
|
}
|
|
1393
1487
|
|
|
1394
1488
|
// src/playback/PresenceLayer.tsx
|
|
1395
|
-
var
|
|
1396
|
-
var
|
|
1489
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
1490
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1397
1491
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
1398
|
-
const { actors } = (0,
|
|
1492
|
+
const { actors } = (0, import_react12.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
1399
1493
|
if (!actors.length) return null;
|
|
1400
1494
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
1401
|
-
return /* @__PURE__ */ (0,
|
|
1495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1402
1496
|
"div",
|
|
1403
1497
|
{
|
|
1404
1498
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -1412,19 +1506,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1412
1506
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
1413
1507
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
1414
1508
|
})();
|
|
1415
|
-
return /* @__PURE__ */ (0,
|
|
1416
|
-
ring && /* @__PURE__ */ (0,
|
|
1509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react12.default.Fragment, { children: [
|
|
1510
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1417
1511
|
"div",
|
|
1418
1512
|
{
|
|
1419
1513
|
"data-actor-focus": a.id,
|
|
1420
1514
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
1421
1515
|
}
|
|
1422
1516
|
),
|
|
1423
|
-
/* @__PURE__ */ (0,
|
|
1424
|
-
/* @__PURE__ */ (0,
|
|
1425
|
-
/* @__PURE__ */ (0,
|
|
1426
|
-
/* @__PURE__ */ (0,
|
|
1427
|
-
a.message && /* @__PURE__ */ (0,
|
|
1517
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: renderCursor ? renderCursor(a) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1518
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
1519
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
1520
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
1521
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
|
|
1428
1522
|
] })
|
|
1429
1523
|
] }) })
|
|
1430
1524
|
] }, a.id);
|
|
@@ -1434,15 +1528,15 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1434
1528
|
}
|
|
1435
1529
|
|
|
1436
1530
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1437
|
-
var
|
|
1438
|
-
var
|
|
1531
|
+
var import_react22 = require("react");
|
|
1532
|
+
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
1439
1533
|
|
|
1440
1534
|
// src/effects/useEffects.ts
|
|
1441
|
-
var
|
|
1535
|
+
var import_react13 = require("react");
|
|
1442
1536
|
function useEffectDescription(provider, effect) {
|
|
1443
|
-
const [state, setState] = (0,
|
|
1537
|
+
const [state, setState] = (0, import_react13.useState)({ key: "", description: null, error: null });
|
|
1444
1538
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1445
|
-
(0,
|
|
1539
|
+
(0, import_react13.useEffect)(() => {
|
|
1446
1540
|
if (!provider || !effect) return;
|
|
1447
1541
|
let live = true;
|
|
1448
1542
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1457,14 +1551,14 @@ function useEffectDescription(provider, effect) {
|
|
|
1457
1551
|
}
|
|
1458
1552
|
|
|
1459
1553
|
// src/effects/EffectThumbnail.tsx
|
|
1460
|
-
var
|
|
1554
|
+
var import_react14 = require("react");
|
|
1461
1555
|
var import_effects = require("@pixerate/editor/effects");
|
|
1462
|
-
var
|
|
1556
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1463
1557
|
var LABELS = { motion: "Motion", camera: "Camera" };
|
|
1464
1558
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1465
|
-
const ref = (0,
|
|
1466
|
-
const [failed, setFailed] = (0,
|
|
1467
|
-
(0,
|
|
1559
|
+
const ref = (0, import_react14.useRef)(null);
|
|
1560
|
+
const [failed, setFailed] = (0, import_react14.useState)(effect.kind in LABELS);
|
|
1561
|
+
(0, import_react14.useEffect)(() => {
|
|
1468
1562
|
if (effect.kind in LABELS) return;
|
|
1469
1563
|
let live = true;
|
|
1470
1564
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1479,28 +1573,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1479
1573
|
live = false;
|
|
1480
1574
|
};
|
|
1481
1575
|
}, [provider, effect, width, height]);
|
|
1482
|
-
return /* @__PURE__ */ (0,
|
|
1576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1483
1577
|
"div",
|
|
1484
1578
|
{
|
|
1485
1579
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1486
1580
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1487
1581
|
"data-effect-thumbnail": effect.id,
|
|
1488
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1582
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: LABELS[effect.kind] ?? "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
1489
1583
|
}
|
|
1490
1584
|
);
|
|
1491
1585
|
}
|
|
1492
1586
|
|
|
1493
1587
|
// src/effects/EffectsBrowser.tsx
|
|
1494
|
-
var
|
|
1588
|
+
var import_react15 = require("react");
|
|
1495
1589
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1496
|
-
var
|
|
1590
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1497
1591
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1498
|
-
const [all, setAll] = (0,
|
|
1499
|
-
const [query, setQuery] = (0,
|
|
1500
|
-
const [category, setCategory] = (0,
|
|
1501
|
-
const [use, setUse] = (0,
|
|
1502
|
-
const [error, setError] = (0,
|
|
1503
|
-
(0,
|
|
1592
|
+
const [all, setAll] = (0, import_react15.useState)([]);
|
|
1593
|
+
const [query, setQuery] = (0, import_react15.useState)("");
|
|
1594
|
+
const [category, setCategory] = (0, import_react15.useState)("");
|
|
1595
|
+
const [use, setUse] = (0, import_react15.useState)("");
|
|
1596
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1597
|
+
(0, import_react15.useEffect)(() => {
|
|
1504
1598
|
if (!provider) return setAll([]);
|
|
1505
1599
|
let live = true;
|
|
1506
1600
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1511,8 +1605,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1511
1605
|
live = false;
|
|
1512
1606
|
};
|
|
1513
1607
|
}, [provider]);
|
|
1514
|
-
const [found, setFound] = (0,
|
|
1515
|
-
(0,
|
|
1608
|
+
const [found, setFound] = (0, import_react15.useState)([]);
|
|
1609
|
+
(0, import_react15.useEffect)(() => {
|
|
1516
1610
|
if (!provider) return setFound([]);
|
|
1517
1611
|
let live = true;
|
|
1518
1612
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1521,14 +1615,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1521
1615
|
};
|
|
1522
1616
|
}, [provider, query, category, use]);
|
|
1523
1617
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
1524
|
-
const categories = (0,
|
|
1618
|
+
const categories = (0, import_react15.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1525
1619
|
const shown = found.filter(allowed);
|
|
1526
1620
|
if (!provider)
|
|
1527
|
-
return /* @__PURE__ */ (0,
|
|
1528
|
-
return /* @__PURE__ */ (0,
|
|
1529
|
-
title && /* @__PURE__ */ (0,
|
|
1530
|
-
/* @__PURE__ */ (0,
|
|
1531
|
-
/* @__PURE__ */ (0,
|
|
1621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
|
|
1622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
1623
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1625
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1532
1626
|
"input",
|
|
1533
1627
|
{
|
|
1534
1628
|
type: "search",
|
|
@@ -1539,17 +1633,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1539
1633
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1540
1634
|
}
|
|
1541
1635
|
),
|
|
1542
|
-
/* @__PURE__ */ (0,
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1544
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
1636
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
|
|
1637
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "All categories" }),
|
|
1638
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: c, children: c }, c))
|
|
1545
1639
|
] }),
|
|
1546
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1547
|
-
/* @__PURE__ */ (0,
|
|
1548
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
1640
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "Any use" }),
|
|
1642
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1549
1643
|
] })
|
|
1550
1644
|
] }),
|
|
1551
|
-
error && /* @__PURE__ */ (0,
|
|
1552
|
-
/* @__PURE__ */ (0,
|
|
1645
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
1646
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1553
1647
|
"button",
|
|
1554
1648
|
{
|
|
1555
1649
|
type: "button",
|
|
@@ -1558,23 +1652,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1558
1652
|
"data-effect-id": e.id,
|
|
1559
1653
|
onClick: () => onPick(e),
|
|
1560
1654
|
children: [
|
|
1561
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1562
|
-
/* @__PURE__ */ (0,
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1655
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
1564
1658
|
]
|
|
1565
1659
|
}
|
|
1566
1660
|
) }, e.id)) }),
|
|
1567
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
1661
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
1568
1662
|
] });
|
|
1569
1663
|
}
|
|
1570
1664
|
|
|
1571
1665
|
// src/effects/EffectParameters.tsx
|
|
1572
|
-
var
|
|
1666
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
1573
1667
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1574
1668
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1575
1669
|
|
|
1576
1670
|
// src/parameters/fields.tsx
|
|
1577
|
-
var
|
|
1671
|
+
var import_react20 = require("react");
|
|
1578
1672
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1579
1673
|
|
|
1580
1674
|
// src/color/index.ts
|
|
@@ -1587,9 +1681,9 @@ __export(color_exports, {
|
|
|
1587
1681
|
});
|
|
1588
1682
|
|
|
1589
1683
|
// src/color/ColorPicker.tsx
|
|
1590
|
-
var
|
|
1684
|
+
var import_react16 = require("react");
|
|
1591
1685
|
var import_color = require("@pixerate/editor/color");
|
|
1592
|
-
var
|
|
1686
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1593
1687
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
1594
1688
|
function readLocalRecents() {
|
|
1595
1689
|
try {
|
|
@@ -1627,24 +1721,24 @@ var ColorPicker = ({
|
|
|
1627
1721
|
id,
|
|
1628
1722
|
"aria-label": ariaLabel = "Color picker"
|
|
1629
1723
|
}) => {
|
|
1630
|
-
const generatedId = (0,
|
|
1724
|
+
const generatedId = (0, import_react16.useId)();
|
|
1631
1725
|
const pickerId = id || generatedId;
|
|
1632
|
-
const [pickerState, setPickerState] = (0,
|
|
1726
|
+
const [pickerState, setPickerState] = (0, import_react16.useState)(
|
|
1633
1727
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
1634
1728
|
);
|
|
1635
|
-
const stateRef = (0,
|
|
1729
|
+
const stateRef = (0, import_react16.useRef)(pickerState);
|
|
1636
1730
|
stateRef.current = pickerState;
|
|
1637
|
-
(0,
|
|
1731
|
+
(0, import_react16.useEffect)(() => {
|
|
1638
1732
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
1639
1733
|
if (next) {
|
|
1640
1734
|
setPickerState(next);
|
|
1641
1735
|
}
|
|
1642
1736
|
}, [value]);
|
|
1643
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
1737
|
+
const [internalRecent, setInternalRecent] = (0, import_react16.useState)(
|
|
1644
1738
|
() => controlledRecent ? [] : readLocalRecents()
|
|
1645
1739
|
);
|
|
1646
1740
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
1647
|
-
const recordRecent = (0,
|
|
1741
|
+
const recordRecent = (0, import_react16.useCallback)(
|
|
1648
1742
|
(color) => {
|
|
1649
1743
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
1650
1744
|
if (!controlledRecent) {
|
|
@@ -1655,11 +1749,11 @@ var ColorPicker = ({
|
|
|
1655
1749
|
},
|
|
1656
1750
|
[activeRecent, controlledRecent, onRecentChange]
|
|
1657
1751
|
);
|
|
1658
|
-
const [textDraft, setTextDraft] = (0,
|
|
1659
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
1660
|
-
const [isClipped, setIsClipped] = (0,
|
|
1661
|
-
const isTypingRef = (0,
|
|
1662
|
-
(0,
|
|
1752
|
+
const [textDraft, setTextDraft] = (0, import_react16.useState)(value);
|
|
1753
|
+
const [isInvalid, setIsInvalid] = (0, import_react16.useState)(false);
|
|
1754
|
+
const [isClipped, setIsClipped] = (0, import_react16.useState)(false);
|
|
1755
|
+
const isTypingRef = (0, import_react16.useRef)(false);
|
|
1756
|
+
(0, import_react16.useEffect)(() => {
|
|
1663
1757
|
if (!isTypingRef.current) {
|
|
1664
1758
|
setTextDraft(value);
|
|
1665
1759
|
setIsInvalid(false);
|
|
@@ -1667,11 +1761,11 @@ var ColorPicker = ({
|
|
|
1667
1761
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
1668
1762
|
}
|
|
1669
1763
|
}, [value]);
|
|
1670
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
1671
|
-
(0,
|
|
1764
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react16.useState)(false);
|
|
1765
|
+
(0, import_react16.useEffect)(() => {
|
|
1672
1766
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
1673
1767
|
}, []);
|
|
1674
|
-
const emitColorChange = (0,
|
|
1768
|
+
const emitColorChange = (0, import_react16.useCallback)(
|
|
1675
1769
|
(nextState) => {
|
|
1676
1770
|
setPickerState(nextState);
|
|
1677
1771
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -1679,10 +1773,10 @@ var ColorPicker = ({
|
|
|
1679
1773
|
},
|
|
1680
1774
|
[alpha, onChange]
|
|
1681
1775
|
);
|
|
1682
|
-
const latest = (0,
|
|
1776
|
+
const latest = (0, import_react16.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
1683
1777
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
1684
|
-
const endDragRef = (0,
|
|
1685
|
-
(0,
|
|
1778
|
+
const endDragRef = (0, import_react16.useRef)(null);
|
|
1779
|
+
(0, import_react16.useEffect)(() => () => endDragRef.current?.(), []);
|
|
1686
1780
|
const startDrag = (e, next) => {
|
|
1687
1781
|
if (disabled) return;
|
|
1688
1782
|
e.preventDefault();
|
|
@@ -1784,7 +1878,7 @@ var ColorPicker = ({
|
|
|
1784
1878
|
} catch {
|
|
1785
1879
|
}
|
|
1786
1880
|
};
|
|
1787
|
-
const contrastResult = (0,
|
|
1881
|
+
const contrastResult = (0, import_react16.useMemo)(() => {
|
|
1788
1882
|
if (!contrastAgainst) return null;
|
|
1789
1883
|
const fg = (0, import_color.parseColor)(value);
|
|
1790
1884
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -1796,7 +1890,7 @@ var ColorPicker = ({
|
|
|
1796
1890
|
}, [value, contrastAgainst]);
|
|
1797
1891
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
1798
1892
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
1799
|
-
return /* @__PURE__ */ (0,
|
|
1893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1800
1894
|
"div",
|
|
1801
1895
|
{
|
|
1802
1896
|
id: pickerId,
|
|
@@ -1820,7 +1914,7 @@ var ColorPicker = ({
|
|
|
1820
1914
|
pointerEvents: disabled ? "none" : "auto"
|
|
1821
1915
|
},
|
|
1822
1916
|
children: [
|
|
1823
|
-
/* @__PURE__ */ (0,
|
|
1917
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1824
1918
|
"span",
|
|
1825
1919
|
{
|
|
1826
1920
|
role: "status",
|
|
@@ -1839,7 +1933,7 @@ var ColorPicker = ({
|
|
|
1839
1933
|
children: liveDescription
|
|
1840
1934
|
}
|
|
1841
1935
|
),
|
|
1842
|
-
/* @__PURE__ */ (0,
|
|
1936
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1843
1937
|
"div",
|
|
1844
1938
|
{
|
|
1845
1939
|
role: "slider",
|
|
@@ -1861,7 +1955,7 @@ var ColorPicker = ({
|
|
|
1861
1955
|
touchAction: "none",
|
|
1862
1956
|
outline: "none"
|
|
1863
1957
|
},
|
|
1864
|
-
children: /* @__PURE__ */ (0,
|
|
1958
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1865
1959
|
"div",
|
|
1866
1960
|
{
|
|
1867
1961
|
style: {
|
|
@@ -1881,7 +1975,7 @@ var ColorPicker = ({
|
|
|
1881
1975
|
)
|
|
1882
1976
|
}
|
|
1883
1977
|
),
|
|
1884
|
-
/* @__PURE__ */ (0,
|
|
1978
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1885
1979
|
"div",
|
|
1886
1980
|
{
|
|
1887
1981
|
role: "slider",
|
|
@@ -1904,7 +1998,7 @@ var ColorPicker = ({
|
|
|
1904
1998
|
touchAction: "none",
|
|
1905
1999
|
outline: "none"
|
|
1906
2000
|
},
|
|
1907
|
-
children: /* @__PURE__ */ (0,
|
|
2001
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1908
2002
|
"div",
|
|
1909
2003
|
{
|
|
1910
2004
|
style: {
|
|
@@ -1924,7 +2018,7 @@ var ColorPicker = ({
|
|
|
1924
2018
|
)
|
|
1925
2019
|
}
|
|
1926
2020
|
),
|
|
1927
|
-
alpha && /* @__PURE__ */ (0,
|
|
2021
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1928
2022
|
"div",
|
|
1929
2023
|
{
|
|
1930
2024
|
role: "slider",
|
|
@@ -1950,7 +2044,7 @@ var ColorPicker = ({
|
|
|
1950
2044
|
overflow: "hidden"
|
|
1951
2045
|
},
|
|
1952
2046
|
children: [
|
|
1953
|
-
/* @__PURE__ */ (0,
|
|
2047
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1954
2048
|
"div",
|
|
1955
2049
|
{
|
|
1956
2050
|
style: {
|
|
@@ -1960,7 +2054,7 @@ var ColorPicker = ({
|
|
|
1960
2054
|
}
|
|
1961
2055
|
}
|
|
1962
2056
|
),
|
|
1963
|
-
/* @__PURE__ */ (0,
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1964
2058
|
"div",
|
|
1965
2059
|
{
|
|
1966
2060
|
style: {
|
|
@@ -1981,8 +2075,8 @@ var ColorPicker = ({
|
|
|
1981
2075
|
]
|
|
1982
2076
|
}
|
|
1983
2077
|
),
|
|
1984
|
-
/* @__PURE__ */ (0,
|
|
1985
|
-
/* @__PURE__ */ (0,
|
|
2078
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
2079
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1986
2080
|
"div",
|
|
1987
2081
|
{
|
|
1988
2082
|
style: {
|
|
@@ -1996,7 +2090,7 @@ var ColorPicker = ({
|
|
|
1996
2090
|
flexShrink: 0,
|
|
1997
2091
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
1998
2092
|
},
|
|
1999
|
-
children: /* @__PURE__ */ (0,
|
|
2093
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2000
2094
|
"div",
|
|
2001
2095
|
{
|
|
2002
2096
|
style: {
|
|
@@ -2008,7 +2102,7 @@ var ColorPicker = ({
|
|
|
2008
2102
|
)
|
|
2009
2103
|
}
|
|
2010
2104
|
),
|
|
2011
|
-
/* @__PURE__ */ (0,
|
|
2105
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2012
2106
|
"input",
|
|
2013
2107
|
{
|
|
2014
2108
|
type: "text",
|
|
@@ -2038,7 +2132,7 @@ var ColorPicker = ({
|
|
|
2038
2132
|
}
|
|
2039
2133
|
}
|
|
2040
2134
|
),
|
|
2041
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
2135
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2042
2136
|
"button",
|
|
2043
2137
|
{
|
|
2044
2138
|
type: "button",
|
|
@@ -2058,7 +2152,7 @@ var ColorPicker = ({
|
|
|
2058
2152
|
color: "inherit",
|
|
2059
2153
|
cursor: disabled ? "default" : "pointer"
|
|
2060
2154
|
},
|
|
2061
|
-
children: /* @__PURE__ */ (0,
|
|
2155
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2062
2156
|
"svg",
|
|
2063
2157
|
{
|
|
2064
2158
|
width: "14",
|
|
@@ -2070,16 +2164,16 @@ var ColorPicker = ({
|
|
|
2070
2164
|
strokeLinecap: "round",
|
|
2071
2165
|
strokeLinejoin: "round",
|
|
2072
2166
|
children: [
|
|
2073
|
-
/* @__PURE__ */ (0,
|
|
2074
|
-
/* @__PURE__ */ (0,
|
|
2075
|
-
/* @__PURE__ */ (0,
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.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" }),
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
2169
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "m14 6 4 4" })
|
|
2076
2170
|
]
|
|
2077
2171
|
}
|
|
2078
2172
|
)
|
|
2079
2173
|
}
|
|
2080
2174
|
)
|
|
2081
2175
|
] }),
|
|
2082
|
-
isClipped && /* @__PURE__ */ (0,
|
|
2176
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2083
2177
|
"div",
|
|
2084
2178
|
{
|
|
2085
2179
|
role: "note",
|
|
@@ -2095,10 +2189,10 @@ var ColorPicker = ({
|
|
|
2095
2189
|
borderRadius: "4px",
|
|
2096
2190
|
alignSelf: "flex-start"
|
|
2097
2191
|
},
|
|
2098
|
-
children: /* @__PURE__ */ (0,
|
|
2192
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
2099
2193
|
}
|
|
2100
2194
|
),
|
|
2101
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
2195
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2102
2196
|
"div",
|
|
2103
2197
|
{
|
|
2104
2198
|
style: {
|
|
@@ -2112,15 +2206,15 @@ var ColorPicker = ({
|
|
|
2112
2206
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
2113
2207
|
},
|
|
2114
2208
|
children: [
|
|
2115
|
-
/* @__PURE__ */ (0,
|
|
2209
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
|
|
2116
2210
|
"Contrast: ",
|
|
2117
|
-
/* @__PURE__ */ (0,
|
|
2211
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("strong", { children: [
|
|
2118
2212
|
contrastResult.ratio.toFixed(2),
|
|
2119
2213
|
":1"
|
|
2120
2214
|
] })
|
|
2121
2215
|
] }),
|
|
2122
|
-
/* @__PURE__ */ (0,
|
|
2123
|
-
/* @__PURE__ */ (0,
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2124
2218
|
"span",
|
|
2125
2219
|
{
|
|
2126
2220
|
style: {
|
|
@@ -2133,7 +2227,7 @@ var ColorPicker = ({
|
|
|
2133
2227
|
]
|
|
2134
2228
|
}
|
|
2135
2229
|
),
|
|
2136
|
-
/* @__PURE__ */ (0,
|
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2137
2231
|
"span",
|
|
2138
2232
|
{
|
|
2139
2233
|
style: {
|
|
@@ -2150,9 +2244,9 @@ var ColorPicker = ({
|
|
|
2150
2244
|
]
|
|
2151
2245
|
}
|
|
2152
2246
|
),
|
|
2153
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2154
|
-
/* @__PURE__ */ (0,
|
|
2155
|
-
/* @__PURE__ */ (0,
|
|
2247
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2248
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
2249
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2156
2250
|
"button",
|
|
2157
2251
|
{
|
|
2158
2252
|
type: "button",
|
|
@@ -2178,9 +2272,9 @@ var ColorPicker = ({
|
|
|
2178
2272
|
`${color}-${idx}`
|
|
2179
2273
|
)) })
|
|
2180
2274
|
] }),
|
|
2181
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
2182
|
-
/* @__PURE__ */ (0,
|
|
2183
|
-
/* @__PURE__ */ (0,
|
|
2275
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2276
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
2277
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2184
2278
|
"button",
|
|
2185
2279
|
{
|
|
2186
2280
|
type: "button",
|
|
@@ -2211,9 +2305,9 @@ var ColorPicker = ({
|
|
|
2211
2305
|
};
|
|
2212
2306
|
|
|
2213
2307
|
// src/color/DualColorPicker.tsx
|
|
2214
|
-
var
|
|
2308
|
+
var import_react17 = require("react");
|
|
2215
2309
|
var import_color2 = require("@pixerate/editor/color");
|
|
2216
|
-
var
|
|
2310
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2217
2311
|
function DualColorPicker({
|
|
2218
2312
|
value,
|
|
2219
2313
|
onChange,
|
|
@@ -2228,8 +2322,8 @@ function DualColorPicker({
|
|
|
2228
2322
|
disabled = false,
|
|
2229
2323
|
className = ""
|
|
2230
2324
|
}) {
|
|
2231
|
-
const sameId = (0,
|
|
2232
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
2325
|
+
const sameId = (0, import_react17.useId)();
|
|
2326
|
+
const [internalScheme, setInternalScheme] = (0, import_react17.useState)("light");
|
|
2233
2327
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
2234
2328
|
const handleSchemeSelect = (nextScheme) => {
|
|
2235
2329
|
if (onSchemeChange) {
|
|
@@ -2240,7 +2334,7 @@ function DualColorPicker({
|
|
|
2240
2334
|
};
|
|
2241
2335
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
2242
2336
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
2243
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
2337
|
+
const [sameInBoth, setSameInBoth] = (0, import_react17.useState)(isSame);
|
|
2244
2338
|
const handleSameToggle = (e) => {
|
|
2245
2339
|
const nextSame = e.target.checked;
|
|
2246
2340
|
setSameInBoth(nextSame);
|
|
@@ -2272,7 +2366,7 @@ function DualColorPicker({
|
|
|
2272
2366
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
2273
2367
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
2274
2368
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
2275
|
-
return /* @__PURE__ */ (0,
|
|
2369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2276
2370
|
"div",
|
|
2277
2371
|
{
|
|
2278
2372
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -2291,7 +2385,7 @@ function DualColorPicker({
|
|
|
2291
2385
|
boxSizing: "border-box"
|
|
2292
2386
|
},
|
|
2293
2387
|
children: [
|
|
2294
|
-
/* @__PURE__ */ (0,
|
|
2388
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2295
2389
|
"div",
|
|
2296
2390
|
{
|
|
2297
2391
|
role: "tablist",
|
|
@@ -2304,7 +2398,7 @@ function DualColorPicker({
|
|
|
2304
2398
|
gap: "2px"
|
|
2305
2399
|
},
|
|
2306
2400
|
children: [
|
|
2307
|
-
/* @__PURE__ */ (0,
|
|
2401
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2308
2402
|
"button",
|
|
2309
2403
|
{
|
|
2310
2404
|
type: "button",
|
|
@@ -2327,7 +2421,7 @@ function DualColorPicker({
|
|
|
2327
2421
|
children: "Light"
|
|
2328
2422
|
}
|
|
2329
2423
|
),
|
|
2330
|
-
/* @__PURE__ */ (0,
|
|
2424
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2331
2425
|
"button",
|
|
2332
2426
|
{
|
|
2333
2427
|
type: "button",
|
|
@@ -2353,8 +2447,8 @@ function DualColorPicker({
|
|
|
2353
2447
|
]
|
|
2354
2448
|
}
|
|
2355
2449
|
),
|
|
2356
|
-
/* @__PURE__ */ (0,
|
|
2357
|
-
/* @__PURE__ */ (0,
|
|
2450
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2451
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2358
2452
|
"button",
|
|
2359
2453
|
{
|
|
2360
2454
|
type: "button",
|
|
@@ -2376,7 +2470,7 @@ function DualColorPicker({
|
|
|
2376
2470
|
outline: "none"
|
|
2377
2471
|
},
|
|
2378
2472
|
children: [
|
|
2379
|
-
/* @__PURE__ */ (0,
|
|
2473
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2380
2474
|
"span",
|
|
2381
2475
|
{
|
|
2382
2476
|
style: {
|
|
@@ -2388,11 +2482,11 @@ function DualColorPicker({
|
|
|
2388
2482
|
}
|
|
2389
2483
|
}
|
|
2390
2484
|
),
|
|
2391
|
-
/* @__PURE__ */ (0,
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2392
2486
|
]
|
|
2393
2487
|
}
|
|
2394
2488
|
),
|
|
2395
|
-
/* @__PURE__ */ (0,
|
|
2489
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2396
2490
|
"button",
|
|
2397
2491
|
{
|
|
2398
2492
|
type: "button",
|
|
@@ -2414,7 +2508,7 @@ function DualColorPicker({
|
|
|
2414
2508
|
outline: "none"
|
|
2415
2509
|
},
|
|
2416
2510
|
children: [
|
|
2417
|
-
/* @__PURE__ */ (0,
|
|
2511
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2418
2512
|
"span",
|
|
2419
2513
|
{
|
|
2420
2514
|
style: {
|
|
@@ -2426,12 +2520,12 @@ function DualColorPicker({
|
|
|
2426
2520
|
}
|
|
2427
2521
|
}
|
|
2428
2522
|
),
|
|
2429
|
-
/* @__PURE__ */ (0,
|
|
2523
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2430
2524
|
]
|
|
2431
2525
|
}
|
|
2432
2526
|
)
|
|
2433
2527
|
] }),
|
|
2434
|
-
/* @__PURE__ */ (0,
|
|
2528
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2435
2529
|
"div",
|
|
2436
2530
|
{
|
|
2437
2531
|
style: {
|
|
@@ -2442,7 +2536,7 @@ function DualColorPicker({
|
|
|
2442
2536
|
padding: "2px 0"
|
|
2443
2537
|
},
|
|
2444
2538
|
children: [
|
|
2445
|
-
/* @__PURE__ */ (0,
|
|
2539
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2446
2540
|
"label",
|
|
2447
2541
|
{
|
|
2448
2542
|
htmlFor: sameId,
|
|
@@ -2456,7 +2550,7 @@ function DualColorPicker({
|
|
|
2456
2550
|
color: "#c4cad4"
|
|
2457
2551
|
},
|
|
2458
2552
|
children: [
|
|
2459
|
-
/* @__PURE__ */ (0,
|
|
2553
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2460
2554
|
"input",
|
|
2461
2555
|
{
|
|
2462
2556
|
id: sameId,
|
|
@@ -2467,11 +2561,11 @@ function DualColorPicker({
|
|
|
2467
2561
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2468
2562
|
}
|
|
2469
2563
|
),
|
|
2470
|
-
/* @__PURE__ */ (0,
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Same in both" })
|
|
2471
2565
|
]
|
|
2472
2566
|
}
|
|
2473
2567
|
),
|
|
2474
|
-
/* @__PURE__ */ (0,
|
|
2568
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2475
2569
|
"button",
|
|
2476
2570
|
{
|
|
2477
2571
|
type: "button",
|
|
@@ -2493,7 +2587,7 @@ function DualColorPicker({
|
|
|
2493
2587
|
]
|
|
2494
2588
|
}
|
|
2495
2589
|
),
|
|
2496
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
2590
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2497
2591
|
"div",
|
|
2498
2592
|
{
|
|
2499
2593
|
"data-testid": "dual-contrast-summary",
|
|
@@ -2507,20 +2601,20 @@ function DualColorPicker({
|
|
|
2507
2601
|
color: "#8c95a6"
|
|
2508
2602
|
},
|
|
2509
2603
|
children: [
|
|
2510
|
-
/* @__PURE__ */ (0,
|
|
2604
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
2511
2605
|
"Light:",
|
|
2512
2606
|
" ",
|
|
2513
|
-
/* @__PURE__ */ (0,
|
|
2607
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2514
2608
|
dualContrast.light.ratio.toFixed(2),
|
|
2515
2609
|
" (",
|
|
2516
2610
|
dualContrast.light.level,
|
|
2517
2611
|
")"
|
|
2518
2612
|
] })
|
|
2519
2613
|
] }),
|
|
2520
|
-
/* @__PURE__ */ (0,
|
|
2614
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
2521
2615
|
"Dark:",
|
|
2522
2616
|
" ",
|
|
2523
|
-
/* @__PURE__ */ (0,
|
|
2617
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2524
2618
|
dualContrast.dark.ratio.toFixed(2),
|
|
2525
2619
|
" (",
|
|
2526
2620
|
dualContrast.dark.level,
|
|
@@ -2530,7 +2624,7 @@ function DualColorPicker({
|
|
|
2530
2624
|
]
|
|
2531
2625
|
}
|
|
2532
2626
|
),
|
|
2533
|
-
/* @__PURE__ */ (0,
|
|
2627
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2534
2628
|
ColorPicker,
|
|
2535
2629
|
{
|
|
2536
2630
|
value: activeColor,
|
|
@@ -2549,7 +2643,7 @@ function DualColorPicker({
|
|
|
2549
2643
|
}
|
|
2550
2644
|
|
|
2551
2645
|
// src/color/useColorScheme.ts
|
|
2552
|
-
var
|
|
2646
|
+
var import_react18 = require("react");
|
|
2553
2647
|
var import_color3 = require("@pixerate/editor/color");
|
|
2554
2648
|
function getSnapshot(attribute) {
|
|
2555
2649
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -2574,7 +2668,7 @@ function getServerSnapshot() {
|
|
|
2574
2668
|
function useColorScheme(options) {
|
|
2575
2669
|
const override = options?.override;
|
|
2576
2670
|
const attribute = options?.attribute;
|
|
2577
|
-
const subscribe = (0,
|
|
2671
|
+
const subscribe = (0, import_react18.useMemo)(() => {
|
|
2578
2672
|
return (callback) => {
|
|
2579
2673
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2580
2674
|
return () => {
|
|
@@ -2600,7 +2694,7 @@ function useColorScheme(options) {
|
|
|
2600
2694
|
};
|
|
2601
2695
|
};
|
|
2602
2696
|
}, [attribute]);
|
|
2603
|
-
const detected = (0,
|
|
2697
|
+
const detected = (0, import_react18.useSyncExternalStore)(
|
|
2604
2698
|
subscribe,
|
|
2605
2699
|
() => getSnapshot(attribute),
|
|
2606
2700
|
getServerSnapshot
|
|
@@ -2617,11 +2711,11 @@ function useResolvedColor(value, scheme) {
|
|
|
2617
2711
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2618
2712
|
|
|
2619
2713
|
// src/parameters/controls.tsx
|
|
2620
|
-
var
|
|
2621
|
-
var
|
|
2622
|
-
var ParameterComponentsContext = (0,
|
|
2714
|
+
var import_react19 = require("react");
|
|
2715
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2716
|
+
var ParameterComponentsContext = (0, import_react19.createContext)({});
|
|
2623
2717
|
function useParameterComponents() {
|
|
2624
|
-
return (0,
|
|
2718
|
+
return (0, import_react19.useContext)(ParameterComponentsContext);
|
|
2625
2719
|
}
|
|
2626
2720
|
function resolveParameterComponents(explicit, context) {
|
|
2627
2721
|
return {
|
|
@@ -2633,7 +2727,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
2633
2727
|
}
|
|
2634
2728
|
|
|
2635
2729
|
// src/parameters/fields.tsx
|
|
2636
|
-
var
|
|
2730
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2637
2731
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2638
2732
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2639
2733
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -2642,9 +2736,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
2642
2736
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
2643
2737
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2644
2738
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2645
|
-
const inputRef = (0,
|
|
2646
|
-
const lastCommitted = (0,
|
|
2647
|
-
(0,
|
|
2739
|
+
const inputRef = (0, import_react20.useRef)(null);
|
|
2740
|
+
const lastCommitted = (0, import_react20.useRef)(null);
|
|
2741
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
2648
2742
|
lastCommitted.current = null;
|
|
2649
2743
|
const el = inputRef.current;
|
|
2650
2744
|
if (el && el.value !== value) el.value = value;
|
|
@@ -2655,9 +2749,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2655
2749
|
onCommit(text, el);
|
|
2656
2750
|
lastCommitted.current = el.value === text ? text : null;
|
|
2657
2751
|
};
|
|
2658
|
-
const commitRef = (0,
|
|
2752
|
+
const commitRef = (0, import_react20.useRef)(commit);
|
|
2659
2753
|
commitRef.current = commit;
|
|
2660
|
-
(0,
|
|
2754
|
+
(0, import_react20.useEffect)(() => {
|
|
2661
2755
|
const el = inputRef.current;
|
|
2662
2756
|
if (!el) return;
|
|
2663
2757
|
const change = () => commitRef.current(el);
|
|
@@ -2688,7 +2782,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2688
2782
|
if (typeof forwarded === "function") forwarded(el);
|
|
2689
2783
|
else if (forwarded) forwarded.current = el;
|
|
2690
2784
|
};
|
|
2691
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
2785
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
2692
2786
|
}
|
|
2693
2787
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
2694
2788
|
function ParameterNumberInput(props) {
|
|
@@ -2722,9 +2816,9 @@ function ParameterNumberInput(props) {
|
|
|
2722
2816
|
onCommit: handleCommit,
|
|
2723
2817
|
onKeyDown: handleKeyDown
|
|
2724
2818
|
};
|
|
2725
|
-
return /* @__PURE__ */ (0,
|
|
2726
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
2727
|
-
field.unit && /* @__PURE__ */ (0,
|
|
2819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2820
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
2821
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
2728
2822
|
] });
|
|
2729
2823
|
}
|
|
2730
2824
|
function ParameterSlider(props) {
|
|
@@ -2732,7 +2826,7 @@ function ParameterSlider(props) {
|
|
|
2732
2826
|
const ctx = useParameterComponents();
|
|
2733
2827
|
const resolved = resolveParameterComponents(components, ctx);
|
|
2734
2828
|
const CustomSlider = resolved.slider;
|
|
2735
|
-
const dragging = (0,
|
|
2829
|
+
const dragging = (0, import_react20.useRef)(false);
|
|
2736
2830
|
const start = () => {
|
|
2737
2831
|
if (dragging.current) return;
|
|
2738
2832
|
dragging.current = true;
|
|
@@ -2743,7 +2837,7 @@ function ParameterSlider(props) {
|
|
|
2743
2837
|
dragging.current = false;
|
|
2744
2838
|
onGestureEnd?.();
|
|
2745
2839
|
};
|
|
2746
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2840
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterNumberInput, { ...props });
|
|
2747
2841
|
const step = (0, import_parameters.parameterStep)(field);
|
|
2748
2842
|
const sliderProps = {
|
|
2749
2843
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -2757,8 +2851,8 @@ function ParameterSlider(props) {
|
|
|
2757
2851
|
className: rangeClass,
|
|
2758
2852
|
style: parameterRangeStyle
|
|
2759
2853
|
};
|
|
2760
|
-
return /* @__PURE__ */ (0,
|
|
2761
|
-
CustomSlider ? /* @__PURE__ */ (0,
|
|
2854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2855
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2762
2856
|
CustomSlider,
|
|
2763
2857
|
{
|
|
2764
2858
|
...sliderProps,
|
|
@@ -2768,7 +2862,7 @@ function ParameterSlider(props) {
|
|
|
2768
2862
|
onGestureStart: start,
|
|
2769
2863
|
onGestureEnd: end
|
|
2770
2864
|
}
|
|
2771
|
-
) : /* @__PURE__ */ (0,
|
|
2865
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2772
2866
|
"input",
|
|
2773
2867
|
{
|
|
2774
2868
|
type: "range",
|
|
@@ -2780,11 +2874,11 @@ function ParameterSlider(props) {
|
|
|
2780
2874
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
2781
2875
|
}
|
|
2782
2876
|
),
|
|
2783
|
-
/* @__PURE__ */ (0,
|
|
2877
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
2784
2878
|
] });
|
|
2785
2879
|
}
|
|
2786
2880
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
2787
|
-
return /* @__PURE__ */ (0,
|
|
2881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2788
2882
|
"button",
|
|
2789
2883
|
{
|
|
2790
2884
|
type: "button",
|
|
@@ -2795,7 +2889,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2795
2889
|
disabled: disabled || field.readOnly,
|
|
2796
2890
|
onClick: () => onChange(!value),
|
|
2797
2891
|
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
|
|
2798
|
-
children: /* @__PURE__ */ (0,
|
|
2892
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2799
2893
|
"span",
|
|
2800
2894
|
{
|
|
2801
2895
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -2812,7 +2906,7 @@ function ParameterSelect(props) {
|
|
|
2812
2906
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
2813
2907
|
const off = disabled || field.readOnly;
|
|
2814
2908
|
if (field.control === "segmented") {
|
|
2815
|
-
return /* @__PURE__ */ (0,
|
|
2909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2816
2910
|
"button",
|
|
2817
2911
|
{
|
|
2818
2912
|
type: "button",
|
|
@@ -2829,7 +2923,7 @@ function ParameterSelect(props) {
|
|
|
2829
2923
|
}
|
|
2830
2924
|
if (CustomSelect) {
|
|
2831
2925
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
2832
|
-
return /* @__PURE__ */ (0,
|
|
2926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2833
2927
|
CustomSelect,
|
|
2834
2928
|
{
|
|
2835
2929
|
id,
|
|
@@ -2845,7 +2939,7 @@ function ParameterSelect(props) {
|
|
|
2845
2939
|
);
|
|
2846
2940
|
}
|
|
2847
2941
|
const index = options.findIndex((o) => o.value === value);
|
|
2848
|
-
return /* @__PURE__ */ (0,
|
|
2942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2849
2943
|
"select",
|
|
2850
2944
|
{
|
|
2851
2945
|
id,
|
|
@@ -2858,23 +2952,23 @@ function ParameterSelect(props) {
|
|
|
2858
2952
|
},
|
|
2859
2953
|
className: parameterInputClass,
|
|
2860
2954
|
style: parameterSelectStyle,
|
|
2861
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
2955
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2862
2956
|
}
|
|
2863
2957
|
);
|
|
2864
2958
|
}
|
|
2865
2959
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
2866
2960
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
2867
|
-
const [open, setOpen] = (0,
|
|
2868
|
-
const containerRef = (0,
|
|
2869
|
-
const buttonRef = (0,
|
|
2870
|
-
const popoverRef = (0,
|
|
2961
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
2962
|
+
const containerRef = (0, import_react20.useRef)(null);
|
|
2963
|
+
const buttonRef = (0, import_react20.useRef)(null);
|
|
2964
|
+
const popoverRef = (0, import_react20.useRef)(null);
|
|
2871
2965
|
const alpha = !!field.alpha;
|
|
2872
2966
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2873
2967
|
const rgb = hex.slice(0, 7);
|
|
2874
2968
|
const shown = alpha ? hex : rgb;
|
|
2875
2969
|
const off = disabled || field.readOnly;
|
|
2876
2970
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2877
|
-
(0,
|
|
2971
|
+
(0, import_react20.useEffect)(() => {
|
|
2878
2972
|
if (!open) return;
|
|
2879
2973
|
const onPointerDown = (e) => {
|
|
2880
2974
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2896,7 +2990,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2896
2990
|
};
|
|
2897
2991
|
}, [open]);
|
|
2898
2992
|
if (CustomColor) {
|
|
2899
|
-
return /* @__PURE__ */ (0,
|
|
2993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2900
2994
|
CustomColor,
|
|
2901
2995
|
{
|
|
2902
2996
|
id,
|
|
@@ -2911,9 +3005,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2911
3005
|
}
|
|
2912
3006
|
);
|
|
2913
3007
|
}
|
|
2914
|
-
return /* @__PURE__ */ (0,
|
|
2915
|
-
/* @__PURE__ */ (0,
|
|
2916
|
-
/* @__PURE__ */ (0,
|
|
3008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
3009
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2917
3011
|
"button",
|
|
2918
3012
|
{
|
|
2919
3013
|
ref: buttonRef,
|
|
@@ -2924,10 +3018,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2924
3018
|
disabled: off,
|
|
2925
3019
|
onClick: () => setOpen((prev) => !prev),
|
|
2926
3020
|
className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
2927
|
-
children: /* @__PURE__ */ (0,
|
|
3021
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2928
3022
|
}
|
|
2929
3023
|
),
|
|
2930
|
-
/* @__PURE__ */ (0,
|
|
3024
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2931
3025
|
ParameterCommitInput,
|
|
2932
3026
|
{
|
|
2933
3027
|
id,
|
|
@@ -2943,7 +3037,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2943
3037
|
}
|
|
2944
3038
|
)
|
|
2945
3039
|
] }),
|
|
2946
|
-
open && /* @__PURE__ */ (0,
|
|
3040
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2947
3041
|
"div",
|
|
2948
3042
|
{
|
|
2949
3043
|
ref: popoverRef,
|
|
@@ -2957,7 +3051,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2957
3051
|
},
|
|
2958
3052
|
className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
|
|
2959
3053
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2960
|
-
children: /* @__PURE__ */ (0,
|
|
3054
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2961
3055
|
ColorPicker,
|
|
2962
3056
|
{
|
|
2963
3057
|
value: shown,
|
|
@@ -2975,11 +3069,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2975
3069
|
}
|
|
2976
3070
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
2977
3071
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2978
|
-
return /* @__PURE__ */ (0,
|
|
3072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
2979
3073
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2980
|
-
return /* @__PURE__ */ (0,
|
|
2981
|
-
/* @__PURE__ */ (0,
|
|
2982
|
-
/* @__PURE__ */ (0,
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
3076
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2983
3077
|
ParameterNumberInput,
|
|
2984
3078
|
{
|
|
2985
3079
|
field: component,
|
|
@@ -2997,11 +3091,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
2997
3091
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2998
3092
|
const off = disabled || field.readOnly;
|
|
2999
3093
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3000
|
-
return /* @__PURE__ */ (0,
|
|
3001
|
-
/* @__PURE__ */ (0,
|
|
3002
|
-
/* @__PURE__ */ (0,
|
|
3003
|
-
/* @__PURE__ */ (0,
|
|
3004
|
-
/* @__PURE__ */ (0,
|
|
3094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1.5", children: [
|
|
3095
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3096
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3097
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3098
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3005
3099
|
ParameterCommitInput,
|
|
3006
3100
|
{
|
|
3007
3101
|
id,
|
|
@@ -3012,15 +3106,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3012
3106
|
onCommit: (text) => onChange(text.trim())
|
|
3013
3107
|
}
|
|
3014
3108
|
),
|
|
3015
|
-
/* @__PURE__ */ (0,
|
|
3016
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3109
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex gap-1", children: [
|
|
3110
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
3017
3111
|
"label",
|
|
3018
3112
|
{
|
|
3019
3113
|
style: parameterButtonStyle,
|
|
3020
3114
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3021
3115
|
children: [
|
|
3022
3116
|
"Choose file\u2026",
|
|
3023
|
-
/* @__PURE__ */ (0,
|
|
3117
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3024
3118
|
"input",
|
|
3025
3119
|
{
|
|
3026
3120
|
type: "file",
|
|
@@ -3038,7 +3132,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3038
3132
|
]
|
|
3039
3133
|
}
|
|
3040
3134
|
),
|
|
3041
|
-
value && /* @__PURE__ */ (0,
|
|
3135
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3042
3136
|
"button",
|
|
3043
3137
|
{
|
|
3044
3138
|
type: "button",
|
|
@@ -3053,7 +3147,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3053
3147
|
] })
|
|
3054
3148
|
] })
|
|
3055
3149
|
] }),
|
|
3056
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
3150
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3057
3151
|
"button",
|
|
3058
3152
|
{
|
|
3059
3153
|
type: "button",
|
|
@@ -3063,14 +3157,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3063
3157
|
disabled: off,
|
|
3064
3158
|
onClick: () => onChange(o.url),
|
|
3065
3159
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
3066
|
-
children: /* @__PURE__ */ (0,
|
|
3160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
3067
3161
|
},
|
|
3068
3162
|
o.url
|
|
3069
3163
|
)) })
|
|
3070
3164
|
] });
|
|
3071
3165
|
}
|
|
3072
3166
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
3073
|
-
return /* @__PURE__ */ (0,
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3074
3168
|
ParameterCommitInput,
|
|
3075
3169
|
{
|
|
3076
3170
|
id,
|
|
@@ -3089,24 +3183,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
3089
3183
|
switch (field.type) {
|
|
3090
3184
|
case "number":
|
|
3091
3185
|
case "int":
|
|
3092
|
-
return /* @__PURE__ */ (0,
|
|
3186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
3093
3187
|
case "boolean":
|
|
3094
|
-
return /* @__PURE__ */ (0,
|
|
3188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
3095
3189
|
case "choice":
|
|
3096
|
-
return /* @__PURE__ */ (0,
|
|
3190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
3097
3191
|
case "color":
|
|
3098
|
-
return /* @__PURE__ */ (0,
|
|
3192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
3099
3193
|
case "vector":
|
|
3100
|
-
return /* @__PURE__ */ (0,
|
|
3194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
3101
3195
|
case "image":
|
|
3102
|
-
return /* @__PURE__ */ (0,
|
|
3196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
3103
3197
|
case "text":
|
|
3104
|
-
return /* @__PURE__ */ (0,
|
|
3198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
3105
3199
|
}
|
|
3106
3200
|
}
|
|
3107
3201
|
|
|
3108
3202
|
// src/effects/EffectParameters.tsx
|
|
3109
|
-
var
|
|
3203
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3110
3204
|
function EffectParameters({
|
|
3111
3205
|
description,
|
|
3112
3206
|
values,
|
|
@@ -3121,10 +3215,10 @@ function EffectParameters({
|
|
|
3121
3215
|
className = "",
|
|
3122
3216
|
components
|
|
3123
3217
|
}) {
|
|
3124
|
-
const fields = (0,
|
|
3125
|
-
const idBase = (0,
|
|
3126
|
-
const gesture =
|
|
3127
|
-
const count =
|
|
3218
|
+
const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3219
|
+
const idBase = (0, import_react21.useId)();
|
|
3220
|
+
const gesture = import_react21.default.useRef(null);
|
|
3221
|
+
const count = import_react21.default.useRef(0);
|
|
3128
3222
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3129
3223
|
const handlePresetSelect = (name) => {
|
|
3130
3224
|
if (!name) return;
|
|
@@ -3135,8 +3229,8 @@ function EffectParameters({
|
|
|
3135
3229
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3136
3230
|
}
|
|
3137
3231
|
};
|
|
3138
|
-
return /* @__PURE__ */ (0,
|
|
3139
|
-
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0,
|
|
3232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3233
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3140
3234
|
CustomPresetSelect,
|
|
3141
3235
|
{
|
|
3142
3236
|
"aria-label": `${description.name} presets`,
|
|
@@ -3151,7 +3245,7 @@ function EffectParameters({
|
|
|
3151
3245
|
],
|
|
3152
3246
|
onChange: (name) => handlePresetSelect(String(name))
|
|
3153
3247
|
}
|
|
3154
|
-
) : /* @__PURE__ */ (0,
|
|
3248
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
3155
3249
|
"select",
|
|
3156
3250
|
{
|
|
3157
3251
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -3161,8 +3255,8 @@ function EffectParameters({
|
|
|
3161
3255
|
disabled,
|
|
3162
3256
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3163
3257
|
children: [
|
|
3164
|
-
/* @__PURE__ */ (0,
|
|
3165
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3258
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
3259
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
3166
3260
|
]
|
|
3167
3261
|
}
|
|
3168
3262
|
)),
|
|
@@ -3172,14 +3266,14 @@ function EffectParameters({
|
|
|
3172
3266
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
3173
3267
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
3174
3268
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
3175
|
-
return /* @__PURE__ */ (0,
|
|
3176
|
-
/* @__PURE__ */ (0,
|
|
3177
|
-
/* @__PURE__ */ (0,
|
|
3178
|
-
keyed && /* @__PURE__ */ (0,
|
|
3269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
3270
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3271
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
3272
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
3179
3273
|
renderControlAddon?.(field.id),
|
|
3180
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3274
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
3181
3275
|
] }),
|
|
3182
|
-
/* @__PURE__ */ (0,
|
|
3276
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3183
3277
|
ParameterFieldControl,
|
|
3184
3278
|
{
|
|
3185
3279
|
field,
|
|
@@ -3194,15 +3288,15 @@ function EffectParameters({
|
|
|
3194
3288
|
)
|
|
3195
3289
|
] }, field.id);
|
|
3196
3290
|
}),
|
|
3197
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3291
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3198
3292
|
] });
|
|
3199
3293
|
}
|
|
3200
3294
|
|
|
3201
3295
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
3202
|
-
var
|
|
3296
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3203
3297
|
function usePaintEffectsProvider(controller) {
|
|
3204
|
-
const [provider, setProvider] = (0,
|
|
3205
|
-
(0,
|
|
3298
|
+
const [provider, setProvider] = (0, import_react22.useState)(controller.effectsProvider);
|
|
3299
|
+
(0, import_react22.useEffect)(() => {
|
|
3206
3300
|
setProvider(controller.effectsProvider);
|
|
3207
3301
|
return controller.effects.subscribe(setProvider);
|
|
3208
3302
|
}, [controller]);
|
|
@@ -3210,27 +3304,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
3210
3304
|
}
|
|
3211
3305
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
3212
3306
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
3213
|
-
(0,
|
|
3307
|
+
(0, import_react22.useEffect)(() => {
|
|
3214
3308
|
if (!registry) return;
|
|
3215
|
-
return registry.register((0,
|
|
3309
|
+
return registry.register((0, import_paint_editor14.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
3216
3310
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
3217
3311
|
}
|
|
3218
3312
|
function Controls({ provider, effect, name, values, apply }) {
|
|
3219
3313
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3220
|
-
const drags = (0,
|
|
3221
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
3314
|
+
const drags = (0, import_react22.useRef)(/* @__PURE__ */ new Set());
|
|
3315
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
|
|
3222
3316
|
'No effects provider: "',
|
|
3223
3317
|
name ?? effect,
|
|
3224
3318
|
'" is kept as it was drawn.'
|
|
3225
3319
|
] });
|
|
3226
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3227
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
3320
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
|
|
3321
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
3228
3322
|
const commit = (gesture) => {
|
|
3229
3323
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
3230
3324
|
drags.current.add(gesture);
|
|
3231
3325
|
return true;
|
|
3232
3326
|
};
|
|
3233
|
-
return /* @__PURE__ */ (0,
|
|
3327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3234
3328
|
EffectParameters,
|
|
3235
3329
|
{
|
|
3236
3330
|
description,
|
|
@@ -3252,14 +3346,14 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3252
3346
|
const state = usePaintEditorState(controller);
|
|
3253
3347
|
const provider = usePaintEffectsProvider(controller);
|
|
3254
3348
|
const [error, attempt] = useAttempt();
|
|
3255
|
-
const [browse, setBrowse] = (0,
|
|
3256
|
-
const [busy, setBusy] = (0,
|
|
3349
|
+
const [browse, setBrowse] = (0, import_react22.useState)(null);
|
|
3350
|
+
const [busy, setBusy] = (0, import_react22.useState)(false);
|
|
3257
3351
|
const paper = controller.getPaperEffect();
|
|
3258
3352
|
const activeId = state.document.activeLayerId;
|
|
3259
3353
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
3260
3354
|
const active = activeId ? controller.getLayer(activeId) : void 0;
|
|
3261
3355
|
const effectPaint = state.effectPaint;
|
|
3262
|
-
const thumbnail = (0,
|
|
3356
|
+
const thumbnail = (0, import_react22.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
3263
3357
|
const run = (work) => attempt(() => {
|
|
3264
3358
|
setBusy(true);
|
|
3265
3359
|
return work().finally(() => setBusy(false));
|
|
@@ -3275,28 +3369,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3275
3369
|
};
|
|
3276
3370
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
3277
3371
|
const pixel = active?.type === "pixel";
|
|
3278
|
-
return /* @__PURE__ */ (0,
|
|
3279
|
-
/* @__PURE__ */ (0,
|
|
3280
|
-
/* @__PURE__ */ (0,
|
|
3281
|
-
/* @__PURE__ */ (0,
|
|
3282
|
-
/* @__PURE__ */ (0,
|
|
3283
|
-
/* @__PURE__ */ (0,
|
|
3284
|
-
/* @__PURE__ */ (0,
|
|
3285
|
-
/* @__PURE__ */ (0,
|
|
3372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
3373
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3374
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
3375
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
3376
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
3377
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
3378
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
|
|
3379
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
|
|
3286
3380
|
] }),
|
|
3287
|
-
!provider && /* @__PURE__ */ (0,
|
|
3288
|
-
browse && /* @__PURE__ */ (0,
|
|
3289
|
-
paper && /* @__PURE__ */ (0,
|
|
3290
|
-
/* @__PURE__ */ (0,
|
|
3291
|
-
/* @__PURE__ */ (0,
|
|
3381
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
3382
|
+
browse && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
3383
|
+
paper && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
3384
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3385
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3292
3386
|
"Paper: ",
|
|
3293
3387
|
paper.name ?? paper.effect
|
|
3294
3388
|
] }),
|
|
3295
|
-
/* @__PURE__ */ (0,
|
|
3389
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
3296
3390
|
] }),
|
|
3297
|
-
/* @__PURE__ */ (0,
|
|
3298
|
-
/* @__PURE__ */ (0,
|
|
3299
|
-
/* @__PURE__ */ (0,
|
|
3391
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3392
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
3393
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3300
3394
|
"input",
|
|
3301
3395
|
{
|
|
3302
3396
|
type: "range",
|
|
@@ -3318,55 +3412,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3318
3412
|
`o${paper.opacity}`
|
|
3319
3413
|
)
|
|
3320
3414
|
] }),
|
|
3321
|
-
/* @__PURE__ */ (0,
|
|
3322
|
-
/* @__PURE__ */ (0,
|
|
3323
|
-
/* @__PURE__ */ (0,
|
|
3415
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3416
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
3417
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
|
|
3324
3418
|
const blend = e.currentTarget.value;
|
|
3325
3419
|
run(() => controller.updatePaperEffect({ blend }));
|
|
3326
|
-
}, children:
|
|
3420
|
+
}, children: import_paint_editor14.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: b, children: b }, b)) })
|
|
3327
3421
|
] }),
|
|
3328
|
-
/* @__PURE__ */ (0,
|
|
3422
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
3329
3423
|
] }),
|
|
3330
|
-
effectPaint && /* @__PURE__ */ (0,
|
|
3331
|
-
/* @__PURE__ */ (0,
|
|
3332
|
-
thumbnail ? /* @__PURE__ */ (0,
|
|
3333
|
-
/* @__PURE__ */ (0,
|
|
3424
|
+
effectPaint && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
3425
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3426
|
+
thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
3427
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3334
3428
|
"Paint: ",
|
|
3335
3429
|
effectPaint.effect,
|
|
3336
3430
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
3337
3431
|
] }),
|
|
3338
|
-
/* @__PURE__ */ (0,
|
|
3432
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
3339
3433
|
] }),
|
|
3340
|
-
/* @__PURE__ */ (0,
|
|
3434
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
|
|
3341
3435
|
] }),
|
|
3342
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
3343
|
-
/* @__PURE__ */ (0,
|
|
3344
|
-
/* @__PURE__ */ (0,
|
|
3436
|
+
layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
3437
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3438
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3345
3439
|
"Layer: ",
|
|
3346
3440
|
layerEffect.name ?? layerEffect.effect
|
|
3347
3441
|
] }),
|
|
3348
|
-
/* @__PURE__ */ (0,
|
|
3442
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
3349
3443
|
] }),
|
|
3350
|
-
/* @__PURE__ */ (0,
|
|
3444
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
3351
3445
|
] }),
|
|
3352
|
-
/* @__PURE__ */ (0,
|
|
3446
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ErrorLine, { error })
|
|
3353
3447
|
] });
|
|
3354
3448
|
};
|
|
3355
3449
|
|
|
3356
3450
|
// src/paint-editor/PaintEditor.tsx
|
|
3357
|
-
var
|
|
3451
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3358
3452
|
var PAINT_CONTROLS = {
|
|
3359
3453
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
3360
3454
|
lighting: '[data-testid="light-panel"]',
|
|
3361
3455
|
symmetry: '[aria-label="Symmetry"]'
|
|
3362
3456
|
};
|
|
3363
3457
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
3364
|
-
const [tool, setTool] = (0,
|
|
3365
|
-
const [tab, setTab] = (0,
|
|
3366
|
-
const tabRef = (0,
|
|
3458
|
+
const [tool, setTool] = (0, import_react23.useState)("brush");
|
|
3459
|
+
const [tab, setTab] = (0, import_react23.useState)("color");
|
|
3460
|
+
const tabRef = (0, import_react23.useRef)(tab);
|
|
3367
3461
|
tabRef.current = tab;
|
|
3368
|
-
const rootRef = (0,
|
|
3369
|
-
const [ownPresence] = (0,
|
|
3462
|
+
const rootRef = (0, import_react23.useRef)(null);
|
|
3463
|
+
const [ownPresence] = (0, import_react23.useState)(() => new import_paint_editor15.PaintPresence());
|
|
3370
3464
|
const ambientPlayback = useAgentPlayback();
|
|
3371
3465
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
3372
3466
|
const viewBox = () => {
|
|
@@ -3377,12 +3471,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3377
3471
|
const docToClient = (p) => {
|
|
3378
3472
|
const r = viewBox();
|
|
3379
3473
|
if (!r) return null;
|
|
3380
|
-
const q = (0,
|
|
3474
|
+
const q = (0, import_paint_editor15.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
|
|
3381
3475
|
return { x: r.left + q.x, y: r.top + q.y };
|
|
3382
3476
|
};
|
|
3383
3477
|
const clientToDoc = (p) => {
|
|
3384
3478
|
const r = viewBox();
|
|
3385
|
-
return r ? (0,
|
|
3479
|
+
return r ? (0, import_paint_editor15.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
|
|
3386
3480
|
};
|
|
3387
3481
|
const elementRect = (selector) => {
|
|
3388
3482
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -3422,27 +3516,28 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3422
3516
|
const box = rootRef.current?.getBoundingClientRect();
|
|
3423
3517
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
3424
3518
|
};
|
|
3425
|
-
const [error, setError] = (0,
|
|
3519
|
+
const [error, setError] = (0, import_react23.useState)(null);
|
|
3426
3520
|
const effects = usePaintEffectsProvider(controller);
|
|
3427
3521
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
3428
|
-
return /* @__PURE__ */ (0,
|
|
3429
|
-
playing && /* @__PURE__ */ (0,
|
|
3430
|
-
/* @__PURE__ */ (0,
|
|
3431
|
-
/* @__PURE__ */ (0,
|
|
3432
|
-
/* @__PURE__ */ (0,
|
|
3433
|
-
/* @__PURE__ */ (0,
|
|
3434
|
-
/* @__PURE__ */ (0,
|
|
3435
|
-
error && /* @__PURE__ */ (0,
|
|
3522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
|
|
3523
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
3524
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
3525
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
3526
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
3527
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
3528
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
3529
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
3436
3530
|
] }),
|
|
3437
|
-
/* @__PURE__ */ (0,
|
|
3438
|
-
/* @__PURE__ */ (0,
|
|
3439
|
-
/* @__PURE__ */ (0,
|
|
3440
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
3441
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
3442
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
3443
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3444
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3445
|
-
tab === "
|
|
3531
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
3532
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
|
|
3533
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
3534
|
+
tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ColorPanel, { controller }),
|
|
3535
|
+
tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(WetPanel, { controller }),
|
|
3536
|
+
tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaperPanel, { controller }),
|
|
3537
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintLayersPanel, { controller }),
|
|
3538
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StrokePanel, { controller }),
|
|
3539
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StickerPanel, { controller }),
|
|
3540
|
+
tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintEffectsPanel, { controller })
|
|
3446
3541
|
] })
|
|
3447
3542
|
] })
|
|
3448
3543
|
] })
|
|
@@ -3462,6 +3557,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3462
3557
|
PaintToolbar,
|
|
3463
3558
|
PaperPanel,
|
|
3464
3559
|
StickerPanel,
|
|
3560
|
+
StrokePanel,
|
|
3465
3561
|
WetPanel,
|
|
3466
3562
|
usePaintDirector,
|
|
3467
3563
|
usePaintEditor,
|