@pixerate/editor-react 0.191.0 → 0.192.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/FerroPanel.d.cts +12 -0
- package/dist/paint-editor/FerroPanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +776 -669
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +444 -337
- package/package.json +3 -3
|
@@ -36,6 +36,7 @@ __export(paint_editor_exports, {
|
|
|
36
36
|
BrushPanel: () => BrushPanel,
|
|
37
37
|
ColorPanel: () => ColorPanel,
|
|
38
38
|
EvolutionPanel: () => EvolutionPanel,
|
|
39
|
+
FerroPanel: () => FerroPanel,
|
|
39
40
|
PaintCanvas: () => PaintCanvas,
|
|
40
41
|
PaintEditor: () => PaintEditor,
|
|
41
42
|
PaintEffectsPanel: () => PaintEffectsPanel,
|
|
@@ -143,6 +144,7 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
143
144
|
const measured = (0, import_react2.useRef)(false);
|
|
144
145
|
const [predicted, setPredicted] = (0, import_react2.useState)([]);
|
|
145
146
|
const [strokeDrag, setStrokeDrag] = (0, import_react2.useState)(null);
|
|
147
|
+
const magnetDrag = (0, import_react2.useRef)(null);
|
|
146
148
|
const presenter = (0, import_react2.useMemo)(() => new import_paint_editor2.PaintCanvasPresenter(controller), [controller]);
|
|
147
149
|
const gesture = (0, import_react2.useMemo)(
|
|
148
150
|
() => new import_paint_editor2.PaintGesture(controller, () => {
|
|
@@ -278,6 +280,45 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
278
280
|
predicted.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: predicted.map((p) => `${p.x},${p.y}`).join(" "), fill: "none", stroke: state.color, strokeOpacity: 0.5, strokeWidth: Math.max(1, state.brush.tip.size / 2), strokeLinecap: "round" })
|
|
279
281
|
] }),
|
|
280
282
|
state.guides.references.filter((r) => r.visible).map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferencePanel, { controller, id: r.id }, r.id)),
|
|
283
|
+
showGuides && (state.document.magnets ?? []).map((m) => {
|
|
284
|
+
const p = (0, import_paint_editor2.documentToScreen)(state.view, doc, size, m.x, m.y);
|
|
285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
286
|
+
"button",
|
|
287
|
+
{
|
|
288
|
+
type: "button",
|
|
289
|
+
"aria-label": `Magnet ${m.id}`,
|
|
290
|
+
"data-testid": `paint-magnet-${m.id}`,
|
|
291
|
+
"data-magnet": m.id,
|
|
292
|
+
title: `Magnet ${m.id} (${Math.round(m.x)}, ${Math.round(m.y)})`,
|
|
293
|
+
className: "absolute -translate-x-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded-full border border-indigo-300 bg-slate-900/90 text-[9px] font-bold text-indigo-200 shadow cursor-move",
|
|
294
|
+
style: { left: p.x, top: p.y },
|
|
295
|
+
onPointerDown: (e) => {
|
|
296
|
+
e.stopPropagation();
|
|
297
|
+
magnetDrag.current = { id: m.id, moved: false };
|
|
298
|
+
e.target.setPointerCapture?.(e.pointerId);
|
|
299
|
+
},
|
|
300
|
+
onPointerMove: (e) => {
|
|
301
|
+
const d = magnetDrag.current;
|
|
302
|
+
if (!d || d.id !== m.id) return;
|
|
303
|
+
e.stopPropagation();
|
|
304
|
+
const r = viewport.current?.getBoundingClientRect();
|
|
305
|
+
const box = { width: r?.width || size.width, height: r?.height || size.height };
|
|
306
|
+
const pt = (0, import_paint_editor2.screenToDocument)(state.view, doc, box, e.clientX - (r?.left ?? 0), e.clientY - (r?.top ?? 0));
|
|
307
|
+
controller.updateMagnet(m.id, { x: Math.round(pt.x * 100) / 100, y: Math.round(pt.y * 100) / 100 }, !d.moved);
|
|
308
|
+
d.moved = true;
|
|
309
|
+
},
|
|
310
|
+
onPointerUp: (e) => {
|
|
311
|
+
e.stopPropagation();
|
|
312
|
+
magnetDrag.current = null;
|
|
313
|
+
},
|
|
314
|
+
onPointerCancel: () => {
|
|
315
|
+
magnetDrag.current = null;
|
|
316
|
+
},
|
|
317
|
+
children: m.strength >= 0 ? "N" : "S"
|
|
318
|
+
},
|
|
319
|
+
m.id
|
|
320
|
+
);
|
|
321
|
+
}),
|
|
281
322
|
proposals && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaintProposalGhosts, { proposals, transform, zoom: state.view.zoom }),
|
|
282
323
|
presence && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaintPresenceLayer, { presence, view: state.view, canvas: doc, viewport: size }),
|
|
283
324
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "absolute bottom-1 right-2 text-[10px] text-slate-500 pointer-events-none", "data-testid": "paint-view-status", children: [
|
|
@@ -1256,21 +1297,85 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
1256
1297
|
};
|
|
1257
1298
|
|
|
1258
1299
|
// src/paint-editor/PaperPanel.tsx
|
|
1300
|
+
var import_react12 = require("react");
|
|
1301
|
+
var import_paint_editor7 = require("@pixerate/editor/paint-editor");
|
|
1302
|
+
|
|
1303
|
+
// src/paint-editor/FerroPanel.tsx
|
|
1259
1304
|
var import_react11 = require("react");
|
|
1260
1305
|
var import_paint_editor6 = require("@pixerate/editor/paint-editor");
|
|
1261
1306
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1307
|
+
var FerroPanel = ({ controller, className }) => {
|
|
1308
|
+
const state = usePaintEditorState(controller);
|
|
1309
|
+
const [error, attempt] = useAttempt();
|
|
1310
|
+
const magnets = state.document.magnets ?? [];
|
|
1311
|
+
const activeId = state.document.activeLayerId;
|
|
1312
|
+
const info = (0, import_react11.useMemo)(() => {
|
|
1313
|
+
try {
|
|
1314
|
+
return activeId ? controller.getFerrofluid(activeId) : null;
|
|
1315
|
+
} catch {
|
|
1316
|
+
return null;
|
|
1317
|
+
}
|
|
1318
|
+
}, [controller, state.document, activeId]);
|
|
1319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "ferro-panel", children: [
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1321
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-medium text-slate-300", children: "Ferrofluid & magnets" }),
|
|
1322
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex gap-1", children: [
|
|
1323
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1324
|
+
"button",
|
|
1325
|
+
{
|
|
1326
|
+
type: "button",
|
|
1327
|
+
className: button,
|
|
1328
|
+
onClick: () => attempt(() => controller.addMagnet({ x: Math.round(state.document.canvas.width / 2), y: Math.round(state.document.canvas.height / 2) })),
|
|
1329
|
+
children: "Add magnet"
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
magnets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.removeMagnets()), children: "Clear magnets" })
|
|
1333
|
+
] })
|
|
1334
|
+
] }),
|
|
1335
|
+
magnets.map((m) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-800 p-1.5", "data-magnet": m.id, children: [
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-between text-[11px]", children: [
|
|
1337
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "font-mono text-slate-300", children: [
|
|
1338
|
+
m.id,
|
|
1339
|
+
" (",
|
|
1340
|
+
Math.round(m.x),
|
|
1341
|
+
", ",
|
|
1342
|
+
Math.round(m.y),
|
|
1343
|
+
")"
|
|
1344
|
+
] }),
|
|
1345
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-label": `Remove magnet ${m.id}`, className: "px-1 text-slate-400 hover:text-white", onClick: () => attempt(() => controller.removeMagnets([m.id])), children: "\xD7" })
|
|
1346
|
+
] }),
|
|
1347
|
+
import_paint_editor6.MAGNET_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1348
|
+
PaintSlider,
|
|
1349
|
+
{
|
|
1350
|
+
control: { ...c, label: `${c.label} (${m.id})` },
|
|
1351
|
+
value: (0, import_paint_editor6.readPath)(m, c.path),
|
|
1352
|
+
onCommit: (v) => attempt(() => controller.updateMagnet(m.id, { [c.path]: v }))
|
|
1353
|
+
},
|
|
1354
|
+
c.path
|
|
1355
|
+
))
|
|
1356
|
+
] }, m.id)),
|
|
1357
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1358
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-[11px] text-slate-400", children: info?.ferro ? `${info.activeSpikeArea} spike px \xB7 max ${Math.round(info.maxSpikeHeight * 100)}%` : "No liquid ferrofluid on layer" }),
|
|
1359
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: button, disabled: !info?.ferro, onClick: () => attempt(() => controller.cureFerrofluid()), children: "Cure ferrofluid" })
|
|
1360
|
+
] }),
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ErrorLine, { error })
|
|
1362
|
+
] });
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
// src/paint-editor/PaperPanel.tsx
|
|
1366
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1262
1367
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
1263
1368
|
var PaperPanel = ({ controller, className }) => {
|
|
1264
1369
|
const state = usePaintEditorState(controller);
|
|
1265
1370
|
const [error, attempt] = useAttempt();
|
|
1266
|
-
const [tiltFollow, setTiltFollow] = (0,
|
|
1267
|
-
(0,
|
|
1371
|
+
const [tiltFollow, setTiltFollow] = (0, import_react12.useState)(false);
|
|
1372
|
+
(0, import_react12.useEffect)(() => tiltFollow ? (0, import_paint_editor7.startDeviceTilt)(controller) : void 0, [controller, tiltFollow]);
|
|
1268
1373
|
const paper = state.document.paper;
|
|
1269
|
-
const previews = (0,
|
|
1270
|
-
return /* @__PURE__ */ (0,
|
|
1271
|
-
|
|
1272
|
-
/* @__PURE__ */ (0,
|
|
1273
|
-
/* @__PURE__ */ (0,
|
|
1374
|
+
const previews = (0, import_react12.useMemo)(() => new Map(import_paint_editor7.PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: (0, import_paint_editor7.renderPaper)({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
1375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
1376
|
+
import_paint_editor7.PAPER_FAMILIES.map((family) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
1378
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: import_paint_editor7.PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1274
1379
|
"button",
|
|
1275
1380
|
{
|
|
1276
1381
|
type: "button",
|
|
@@ -1279,130 +1384,131 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
1279
1384
|
title: p.name,
|
|
1280
1385
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
1281
1386
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
1282
|
-
children: /* @__PURE__ */ (0,
|
|
1387
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
1283
1388
|
},
|
|
1284
1389
|
p.preset
|
|
1285
1390
|
)) })
|
|
1286
1391
|
] }, family)),
|
|
1287
|
-
/* @__PURE__ */ (0,
|
|
1288
|
-
/* @__PURE__ */ (0,
|
|
1289
|
-
/* @__PURE__ */ (0,
|
|
1290
|
-
/* @__PURE__ */ (0,
|
|
1392
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-slate-300", children: paper.name }),
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1291
1396
|
] }),
|
|
1292
|
-
|
|
1293
|
-
/* @__PURE__ */ (0,
|
|
1294
|
-
/* @__PURE__ */ (0,
|
|
1295
|
-
/* @__PURE__ */ (0,
|
|
1397
|
+
import_paint_editor7.PAPER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor7.readPath)(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper((0, import_paint_editor7.patchPath)(paper, c.path, v))) }, c.path)),
|
|
1398
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1399
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
1400
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitColorInput, { label: "Backlight colour", value: paper.backlightColor ?? import_paint_editor7.DEFAULT_BACKLIGHT_COLOR, onCommit: (v) => attempt(() => controller.setPaper({ backlightColor: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1296
1401
|
] }),
|
|
1297
|
-
/* @__PURE__ */ (0,
|
|
1298
|
-
/* @__PURE__ */ (0,
|
|
1402
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
1299
1404
|
" Mirror tiling"
|
|
1300
1405
|
] }),
|
|
1301
|
-
/* @__PURE__ */ (0,
|
|
1302
|
-
/* @__PURE__ */ (0,
|
|
1303
|
-
/* @__PURE__ */ (0,
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
/* @__PURE__ */ (0,
|
|
1307
|
-
/* @__PURE__ */ (0,
|
|
1406
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.setPaper({ seed: paper.seed + 1 })), children: "New sheet" }),
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
1408
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
|
|
1409
|
+
import_paint_editor7.LIGHT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor7.readPath)(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
1410
|
+
import_paint_editor7.VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor7.readPath)(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
|
|
1411
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1412
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1308
1413
|
"button",
|
|
1309
1414
|
{
|
|
1310
1415
|
type: "button",
|
|
1311
1416
|
"aria-pressed": tiltFollow,
|
|
1312
1417
|
className: chip(tiltFollow),
|
|
1313
1418
|
onClick: () => attempt(async () => {
|
|
1314
|
-
if (!tiltFollow && !await (0,
|
|
1419
|
+
if (!tiltFollow && !await (0, import_paint_editor7.requestDeviceTiltPermission)()) return;
|
|
1315
1420
|
setTiltFollow((v) => !v);
|
|
1316
1421
|
}),
|
|
1317
1422
|
children: "Device tilt"
|
|
1318
1423
|
}
|
|
1319
1424
|
),
|
|
1320
|
-
/* @__PURE__ */ (0,
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
|
|
1321
1426
|
] })
|
|
1322
1427
|
] }),
|
|
1323
|
-
/* @__PURE__ */ (0,
|
|
1324
|
-
/* @__PURE__ */ (0,
|
|
1325
|
-
/* @__PURE__ */ (0,
|
|
1326
|
-
/* @__PURE__ */ (0,
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
|
|
1429
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1431
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
|
|
1327
1432
|
" UV blacklight"
|
|
1328
1433
|
] }),
|
|
1329
|
-
|
|
1330
|
-
/* @__PURE__ */ (0,
|
|
1331
|
-
/* @__PURE__ */ (0,
|
|
1332
|
-
/* @__PURE__ */ (0,
|
|
1333
|
-
state.heat.hotCells > 0 && /* @__PURE__ */ (0,
|
|
1434
|
+
import_paint_editor7.UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor7.readPath)(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
|
|
1435
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
1436
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.advanceHeat(10)), children: "Step heat" }),
|
|
1437
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.clearHeat()), children: "Cool canvas" }),
|
|
1438
|
+
state.heat.hotCells > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "text-[11px] text-amber-400", children: [
|
|
1334
1439
|
Math.round(state.heat.max * 100),
|
|
1335
1440
|
"% warm"
|
|
1336
1441
|
] })
|
|
1337
1442
|
] })
|
|
1338
1443
|
] }),
|
|
1339
|
-
/* @__PURE__ */ (0,
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FerroPanel, { controller }),
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorLine, { error })
|
|
1340
1446
|
] });
|
|
1341
1447
|
};
|
|
1342
1448
|
|
|
1343
1449
|
// src/paint-editor/ColorPanel.tsx
|
|
1344
|
-
var
|
|
1345
|
-
var import_paint_editor7 = require("@pixerate/editor/paint-editor");
|
|
1450
|
+
var import_react13 = require("react");
|
|
1346
1451
|
var import_paint_editor8 = require("@pixerate/editor/paint-editor");
|
|
1347
|
-
var
|
|
1452
|
+
var import_paint_editor9 = require("@pixerate/editor/paint-editor");
|
|
1453
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1348
1454
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
1349
1455
|
const state = usePaintEditorState(controller);
|
|
1350
1456
|
const [error, attempt] = useAttempt();
|
|
1351
|
-
const [wheel, setWheel] = (0,
|
|
1352
|
-
const [kind, setKind] = (0,
|
|
1353
|
-
const [padTool, setPadTool] = (0,
|
|
1354
|
-
const [sample, setSample] = (0,
|
|
1355
|
-
const [parts, setParts] = (0,
|
|
1356
|
-
const [padName, setPadName] = (0,
|
|
1357
|
-
const padPoints = (0,
|
|
1358
|
-
const ring = (0,
|
|
1457
|
+
const [wheel, setWheel] = (0, import_react13.useState)("ryb");
|
|
1458
|
+
const [kind, setKind] = (0, import_react13.useState)("complementary");
|
|
1459
|
+
const [padTool, setPadTool] = (0, import_react13.useState)("paint");
|
|
1460
|
+
const [sample, setSample] = (0, import_react13.useState)(3);
|
|
1461
|
+
const [parts, setParts] = (0, import_react13.useState)([1, 1]);
|
|
1462
|
+
const [padName, setPadName] = (0, import_react13.useState)("");
|
|
1463
|
+
const padPoints = (0, import_react13.useRef)(null);
|
|
1464
|
+
const ring = (0, import_react13.useMemo)(() => (0, import_paint_editor8.renderColorWheel)(wheelSize, wheel), [wheelSize, wheel]);
|
|
1359
1465
|
const color = state.color;
|
|
1360
|
-
const harmony = (0,
|
|
1361
|
-
const [r, g, b] = (0,
|
|
1362
|
-
const hsv = (0,
|
|
1363
|
-
const effectWell = (0,
|
|
1364
|
-
const pad = (0,
|
|
1466
|
+
const harmony = (0, import_react13.useMemo)(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
1467
|
+
const [r, g, b] = (0, import_paint_editor8.parseHexColor)(color);
|
|
1468
|
+
const hsv = (0, import_paint_editor8.rgbToHsv)(r, g, b);
|
|
1469
|
+
const effectWell = (0, import_react13.useMemo)(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
1470
|
+
const pad = (0, import_react13.useMemo)(() => ({ width: import_paint_editor8.MIXING_PAD_WIDTH, height: import_paint_editor8.MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
1365
1471
|
const R = wheelSize / 2;
|
|
1366
1472
|
const mid = R * 0.82;
|
|
1367
|
-
const setHsv = (s, v) => controller.setColor((0,
|
|
1473
|
+
const setHsv = (s, v) => controller.setColor((0, import_paint_editor8.rgbToHexColor)(...(0, import_paint_editor8.hsvToRgb)(hsv.h, s, v)));
|
|
1368
1474
|
const padPoint = (e) => {
|
|
1369
1475
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1370
|
-
const kx =
|
|
1371
|
-
const ky =
|
|
1372
|
-
const x = Math.min(
|
|
1373
|
-
const y = Math.min(
|
|
1476
|
+
const kx = import_paint_editor8.MIXING_PAD_WIDTH / (rect.width || import_paint_editor8.MIXING_PAD_WIDTH);
|
|
1477
|
+
const ky = import_paint_editor8.MIXING_PAD_HEIGHT / (rect.height || import_paint_editor8.MIXING_PAD_HEIGHT);
|
|
1478
|
+
const x = Math.min(import_paint_editor8.MIXING_PAD_WIDTH, Math.max(0, (e.clientX - rect.left) * kx));
|
|
1479
|
+
const y = Math.min(import_paint_editor8.MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
1374
1480
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
1375
1481
|
};
|
|
1376
|
-
return /* @__PURE__ */ (0,
|
|
1377
|
-
/* @__PURE__ */ (0,
|
|
1378
|
-
/* @__PURE__ */ (0,
|
|
1482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1379
1485
|
"div",
|
|
1380
1486
|
{
|
|
1381
1487
|
role: "slider",
|
|
1382
1488
|
"aria-label": "Hue wheel",
|
|
1383
1489
|
"aria-valuemin": 0,
|
|
1384
1490
|
"aria-valuemax": 360,
|
|
1385
|
-
"aria-valuenow": Math.round((0,
|
|
1491
|
+
"aria-valuenow": Math.round((0, import_paint_editor8.hueToWheel)(hsv.h, wheel)),
|
|
1386
1492
|
tabIndex: 0,
|
|
1387
1493
|
className: "absolute inset-0 cursor-crosshair",
|
|
1388
1494
|
onPointerDown: (e) => {
|
|
1389
1495
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1390
|
-
controller.setColor((0,
|
|
1496
|
+
controller.setColor((0, import_paint_editor8.wheelPick)(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
1391
1497
|
},
|
|
1392
|
-
children: /* @__PURE__ */ (0,
|
|
1498
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
1393
1499
|
}
|
|
1394
1500
|
),
|
|
1395
|
-
/* @__PURE__ */ (0,
|
|
1396
|
-
const p = (0,
|
|
1397
|
-
return /* @__PURE__ */ (0,
|
|
1501
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
1502
|
+
const p = (0, import_paint_editor8.wheelPoint)(h.angle, mid);
|
|
1503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("circle", { cx: R + p.x, cy: R + p.y, r: i === 0 ? 7 : 5, fill: h.color, stroke: "#fff", strokeWidth: i === 0 ? 2 : 1 }, i);
|
|
1398
1504
|
}) }),
|
|
1399
|
-
/* @__PURE__ */ (0,
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "absolute rounded-full border border-slate-700", style: { left: R - R * 0.45, top: R - R * 0.45, width: R * 0.9, height: R * 0.9, background: color } })
|
|
1400
1506
|
] }),
|
|
1401
|
-
/* @__PURE__ */ (0,
|
|
1402
|
-
/* @__PURE__ */ (0,
|
|
1403
|
-
/* @__PURE__ */ (0,
|
|
1404
|
-
/* @__PURE__ */ (0,
|
|
1405
|
-
/* @__PURE__ */ (0,
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1508
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "color", "aria-label": "Paint colour", value: color, onChange: (e) => controller.setColor(e.target.value), className: "h-7 w-9 rounded bg-transparent" }),
|
|
1509
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "color", "aria-label": "Second colour", value: state.secondaryColor, onChange: (e) => controller.setSecondaryColor(e.target.value), className: "h-5 w-7 rounded bg-transparent" }),
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1406
1512
|
"input",
|
|
1407
1513
|
{
|
|
1408
1514
|
"aria-label": "Hex colour",
|
|
@@ -1413,49 +1519,49 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1413
1519
|
color
|
|
1414
1520
|
)
|
|
1415
1521
|
] }),
|
|
1416
|
-
/* @__PURE__ */ (0,
|
|
1417
|
-
/* @__PURE__ */ (0,
|
|
1522
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
1523
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1418
1524
|
"span",
|
|
1419
1525
|
{
|
|
1420
1526
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
1421
1527
|
"aria-label": state.effectPaint ? `Effect paint: ${state.effectPaint.effect}` : state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
|
|
1422
1528
|
"data-testid": "paint-well",
|
|
1423
1529
|
"data-effect-paint": state.effectPaint ? state.effectPaint.effect : void 0,
|
|
1424
|
-
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0,
|
|
1530
|
+
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0, import_paint_editor9.paintSourceCss)(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1425
1531
|
}
|
|
1426
1532
|
),
|
|
1427
|
-
/* @__PURE__ */ (0,
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1428
1534
|
"button",
|
|
1429
1535
|
{
|
|
1430
1536
|
type: "button",
|
|
1431
1537
|
className: chip(state.paint.type === "gradient"),
|
|
1432
1538
|
"aria-pressed": state.paint.type === "gradient",
|
|
1433
1539
|
title: "Paint that changes colour as the stroke goes",
|
|
1434
|
-
onClick: () => attempt(() => state.paint.type === "gradient" ? controller.setColor(color) : controller.setPaint(
|
|
1540
|
+
onClick: () => attempt(() => state.paint.type === "gradient" ? controller.setColor(color) : controller.setPaint(import_paint_editor9.DEFAULT_PAINT_GRADIENT)),
|
|
1435
1541
|
children: "Gradient"
|
|
1436
1542
|
}
|
|
1437
1543
|
)
|
|
1438
1544
|
] }),
|
|
1439
|
-
state.paint.type === "gradient" && /* @__PURE__ */ (0,
|
|
1440
|
-
/* @__PURE__ */ (0,
|
|
1441
|
-
/* @__PURE__ */ (0,
|
|
1442
|
-
/* @__PURE__ */ (0,
|
|
1545
|
+
state.paint.type === "gradient" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1547
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
1548
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "range", "aria-label": "Saturation", min: 0, max: 1, step: 0.01, value: hsv.s, onChange: (e) => setHsv(Number(e.target.value), hsv.v), className: "flex-1 accent-indigo-500" })
|
|
1443
1549
|
] }),
|
|
1444
|
-
/* @__PURE__ */ (0,
|
|
1445
|
-
/* @__PURE__ */ (0,
|
|
1446
|
-
/* @__PURE__ */ (0,
|
|
1550
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1551
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
1552
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "range", "aria-label": "Value", min: 0, max: 1, step: 0.01, value: hsv.v, onChange: (e) => setHsv(hsv.s, Number(e.target.value)), className: "flex-1 accent-indigo-500" })
|
|
1447
1553
|
] }),
|
|
1448
|
-
/* @__PURE__ */ (0,
|
|
1449
|
-
/* @__PURE__ */ (0,
|
|
1450
|
-
/* @__PURE__ */ (0,
|
|
1451
|
-
/* @__PURE__ */ (0,
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1555
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("select", { "aria-label": "Harmony", value: kind, onChange: (e) => setKind(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor8.HARMONY_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: k, children: k }, k)) }),
|
|
1556
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
1557
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1452
1558
|
] }),
|
|
1453
|
-
/* @__PURE__ */ (0,
|
|
1454
|
-
harmony.map((h, i) => /* @__PURE__ */ (0,
|
|
1455
|
-
/* @__PURE__ */ (0,
|
|
1559
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
1560
|
+
harmony.map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", "aria-label": `Use ${h.color}`, title: h.color, className: "h-6 w-6 rounded ring-1 ring-slate-700", style: { background: h.color }, onClick: () => controller.setColor(h.color) }, i)),
|
|
1561
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1456
1562
|
] }),
|
|
1457
|
-
/* @__PURE__ */ (0,
|
|
1458
|
-
state.swatches.map((s, i) => /* @__PURE__ */ (0,
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
1564
|
+
state.swatches.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1459
1565
|
"button",
|
|
1460
1566
|
{
|
|
1461
1567
|
type: "button",
|
|
@@ -1464,7 +1570,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1464
1570
|
"aria-label": s.name ?? (s.paint ? "Gradient" : s.color),
|
|
1465
1571
|
title: `${s.name ?? (s.paint ? "Gradient" : s.color)} (right-click to remove)`,
|
|
1466
1572
|
className: "h-5 w-5 rounded ring-1 ring-slate-700",
|
|
1467
|
-
style: { background: s.paint ? (0,
|
|
1573
|
+
style: { background: s.paint ? (0, import_paint_editor9.paintSourceCss)(s.paint, { paint: color, secondary: state.secondaryColor }) : s.color },
|
|
1468
1574
|
onClick: () => attempt(() => s.paint ? controller.setPaint(s.paint) : controller.setColor(s.color)),
|
|
1469
1575
|
onContextMenu: (e) => {
|
|
1470
1576
|
e.preventDefault();
|
|
@@ -1473,15 +1579,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1473
1579
|
},
|
|
1474
1580
|
i
|
|
1475
1581
|
)),
|
|
1476
|
-
/* @__PURE__ */ (0,
|
|
1582
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1477
1583
|
] }),
|
|
1478
|
-
mixingPad && /* @__PURE__ */ (0,
|
|
1479
|
-
/* @__PURE__ */ (0,
|
|
1480
|
-
/* @__PURE__ */ (0,
|
|
1481
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0,
|
|
1482
|
-
/* @__PURE__ */ (0,
|
|
1584
|
+
mixingPad && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1587
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1483
1589
|
] }),
|
|
1484
|
-
/* @__PURE__ */ (0,
|
|
1590
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1485
1591
|
"div",
|
|
1486
1592
|
{
|
|
1487
1593
|
role: "application",
|
|
@@ -1490,7 +1596,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1490
1596
|
onPointerDown: (e) => {
|
|
1491
1597
|
const p = padPoint(e);
|
|
1492
1598
|
if (padTool === "pick") {
|
|
1493
|
-
attempt(() => controller.mixingPadPick(p.x, p.y, { setColor: true, radius: (0,
|
|
1599
|
+
attempt(() => controller.mixingPadPick(p.x, p.y, { setColor: true, radius: (0, import_paint_editor8.padSampleRadius)(sample) }));
|
|
1494
1600
|
return;
|
|
1495
1601
|
}
|
|
1496
1602
|
padPoints.current = [p];
|
|
@@ -1502,20 +1608,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1502
1608
|
padPoints.current = null;
|
|
1503
1609
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1504
1610
|
},
|
|
1505
|
-
children: /* @__PURE__ */ (0,
|
|
1611
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${import_paint_editor8.MIXING_PAD_WIDTH} / ${import_paint_editor8.MIXING_PAD_HEIGHT}` } })
|
|
1506
1612
|
}
|
|
1507
1613
|
),
|
|
1508
|
-
/* @__PURE__ */ (0,
|
|
1509
|
-
/* @__PURE__ */ (0,
|
|
1510
|
-
/* @__PURE__ */ (0,
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-slate-400", children: "Sample" }),
|
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("select", { "aria-label": "Pick sample size", value: sample, onChange: (e) => setSample(Number(e.target.value)), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor8.PAD_SAMPLE_SIZES.map((n) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1511
1617
|
] }) }),
|
|
1512
|
-
/* @__PURE__ */ (0,
|
|
1513
|
-
/* @__PURE__ */ (0,
|
|
1514
|
-
/* @__PURE__ */ (0,
|
|
1515
|
-
/* @__PURE__ */ (0,
|
|
1516
|
-
/* @__PURE__ */ (0,
|
|
1517
|
-
/* @__PURE__ */ (0,
|
|
1518
|
-
/* @__PURE__ */ (0,
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1619
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1620
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "number", "aria-label": "Paint colour parts", min: 0, max: 20, value: parts[0], onChange: (e) => setParts([Number(e.target.value), parts[1]]), className: "w-10 rounded bg-slate-800 px-1 py-0.5" }),
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-slate-500", children: ":" }),
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "number", "aria-label": "Second colour parts", min: 0, max: 20, value: parts[1], onChange: (e) => setParts([parts[0], Number(e.target.value)]), className: "w-10 rounded bg-slate-800 px-1 py-0.5" }),
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1519
1625
|
"button",
|
|
1520
1626
|
{
|
|
1521
1627
|
type: "button",
|
|
@@ -1534,25 +1640,25 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1534
1640
|
}
|
|
1535
1641
|
)
|
|
1536
1642
|
] }),
|
|
1537
|
-
/* @__PURE__ */ (0,
|
|
1538
|
-
/* @__PURE__ */ (0,
|
|
1539
|
-
/* @__PURE__ */ (0,
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { value: padName, placeholder: "Pad name", "aria-label": "Pad name", onChange: (e) => setPadName(e.target.value), className: "w-24 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
1645
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1540
1646
|
] }),
|
|
1541
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0,
|
|
1542
|
-
/* @__PURE__ */ (0,
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1647
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: "flex items-center gap-1", children: [
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1544
1650
|
] }, p.id)) })
|
|
1545
1651
|
] }),
|
|
1546
|
-
/* @__PURE__ */ (0,
|
|
1652
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ErrorLine, { error })
|
|
1547
1653
|
] });
|
|
1548
1654
|
};
|
|
1549
1655
|
|
|
1550
1656
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1551
|
-
var
|
|
1552
|
-
var
|
|
1657
|
+
var import_react16 = require("react");
|
|
1658
|
+
var import_paint_editor10 = require("@pixerate/editor/paint-editor");
|
|
1553
1659
|
|
|
1554
1660
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
1555
|
-
var
|
|
1661
|
+
var import_react15 = require("react");
|
|
1556
1662
|
var import_raster = require("@pixerate/editor/raster");
|
|
1557
1663
|
|
|
1558
1664
|
// src/image-editor/styles.ts
|
|
@@ -1561,17 +1667,17 @@ var imageSelectClass = "rounded border border-input bg-background px-1.5 py-1 te
|
|
|
1561
1667
|
var imageColorInputClass = "h-6 w-8 rounded border border-border bg-transparent";
|
|
1562
1668
|
|
|
1563
1669
|
// src/image-editor/controls/controls.tsx
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1566
|
-
var ControlsContext = (0,
|
|
1670
|
+
var import_react14 = require("react");
|
|
1671
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1672
|
+
var ControlsContext = (0, import_react14.createContext)({});
|
|
1567
1673
|
function useImageEditorControls() {
|
|
1568
|
-
return (0,
|
|
1674
|
+
return (0, import_react14.useContext)(ControlsContext);
|
|
1569
1675
|
}
|
|
1570
1676
|
function ImageCheckbox(props) {
|
|
1571
1677
|
const Host = useImageEditorControls().Checkbox;
|
|
1572
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1678
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Host, { ...props });
|
|
1573
1679
|
const { checked, label, disabled, onChange, className = "" } = props;
|
|
1574
|
-
return /* @__PURE__ */ (0,
|
|
1680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1575
1681
|
"input",
|
|
1576
1682
|
{
|
|
1577
1683
|
type: "checkbox",
|
|
@@ -1585,9 +1691,9 @@ function ImageCheckbox(props) {
|
|
|
1585
1691
|
}
|
|
1586
1692
|
function ImageRange(props) {
|
|
1587
1693
|
const Host = useImageEditorControls().Range;
|
|
1588
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1694
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Host, { ...props });
|
|
1589
1695
|
const { value, min, max, step, label, disabled, onChange, onStart, onEnd, className = "" } = props;
|
|
1590
|
-
return /* @__PURE__ */ (0,
|
|
1696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1591
1697
|
"input",
|
|
1592
1698
|
{
|
|
1593
1699
|
type: "range",
|
|
@@ -1608,18 +1714,18 @@ function ImageRange(props) {
|
|
|
1608
1714
|
}
|
|
1609
1715
|
function ImageSelect(props) {
|
|
1610
1716
|
const Host = useImageEditorControls().Select;
|
|
1611
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1717
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Host, { ...props });
|
|
1612
1718
|
const { value, options, label, placeholder, disabled, onChange, className = "" } = props;
|
|
1613
|
-
return /* @__PURE__ */ (0,
|
|
1614
|
-
placeholder !== void 0 && /* @__PURE__ */ (0,
|
|
1615
|
-
options.map((o) => /* @__PURE__ */ (0,
|
|
1719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("select", { "aria-label": label, value, disabled, onChange: (e) => onChange(e.target.value), className: `${imageSelectClass} ${className}`, children: [
|
|
1720
|
+
placeholder !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: placeholder }),
|
|
1721
|
+
options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: o.value, children: o.label }, o.value))
|
|
1616
1722
|
] });
|
|
1617
1723
|
}
|
|
1618
1724
|
function ImageColor(props) {
|
|
1619
1725
|
const Host = useImageEditorControls().Color;
|
|
1620
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1726
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Host, { ...props });
|
|
1621
1727
|
const { value, label, alpha, disabled, onChange, className = "" } = props;
|
|
1622
|
-
return /* @__PURE__ */ (0,
|
|
1728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1623
1729
|
"input",
|
|
1624
1730
|
{
|
|
1625
1731
|
type: "color",
|
|
@@ -1633,13 +1739,13 @@ function ImageColor(props) {
|
|
|
1633
1739
|
}
|
|
1634
1740
|
|
|
1635
1741
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
1636
|
-
var
|
|
1742
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1637
1743
|
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
1638
|
-
const [, setTick] = (0,
|
|
1639
|
-
(0,
|
|
1640
|
-
const [open, setOpen] = (0,
|
|
1641
|
-
const [error, setError] = (0,
|
|
1642
|
-
const commitNext = (0,
|
|
1744
|
+
const [, setTick] = (0, import_react15.useState)(0);
|
|
1745
|
+
(0, import_react15.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
1746
|
+
const [open, setOpen] = (0, import_react15.useState)(null);
|
|
1747
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1748
|
+
const commitNext = (0, import_react15.useRef)(true);
|
|
1643
1749
|
const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
|
|
1644
1750
|
const model = (0, import_raster.layerEffectsPanel)(layer);
|
|
1645
1751
|
const id = layer?.id;
|
|
@@ -1652,7 +1758,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1652
1758
|
}
|
|
1653
1759
|
};
|
|
1654
1760
|
if (!model.available || !id) {
|
|
1655
|
-
return /* @__PURE__ */ (0,
|
|
1761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `text-xs text-muted-foreground ${className ?? ""}`, "data-testid": "layer-effects", children: model.reason });
|
|
1656
1762
|
}
|
|
1657
1763
|
const effects = controller.getLayerEffects(id);
|
|
1658
1764
|
const patterns = controller.getDocumentPatterns();
|
|
@@ -1667,14 +1773,14 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1667
1773
|
case "range": {
|
|
1668
1774
|
const k = c.percent ? 100 : 1;
|
|
1669
1775
|
const shown = Math.round(c.value * k * 100) / 100;
|
|
1670
|
-
return /* @__PURE__ */ (0,
|
|
1671
|
-
/* @__PURE__ */ (0,
|
|
1776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
1672
1778
|
label,
|
|
1673
1779
|
" ",
|
|
1674
1780
|
shown,
|
|
1675
1781
|
c.unit
|
|
1676
1782
|
] }),
|
|
1677
|
-
/* @__PURE__ */ (0,
|
|
1783
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1678
1784
|
ImageRange,
|
|
1679
1785
|
{
|
|
1680
1786
|
label,
|
|
@@ -1691,19 +1797,19 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1691
1797
|
] }, c.key);
|
|
1692
1798
|
}
|
|
1693
1799
|
case "color":
|
|
1694
|
-
return /* @__PURE__ */ (0,
|
|
1695
|
-
/* @__PURE__ */ (0,
|
|
1800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
|
|
1801
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageColor, { label, value: c.value, disabled: model.readOnly, onChange: (v) => change(effectId, c, v) }),
|
|
1696
1802
|
label
|
|
1697
1803
|
] }, c.key);
|
|
1698
1804
|
case "checkbox":
|
|
1699
|
-
return /* @__PURE__ */ (0,
|
|
1700
|
-
/* @__PURE__ */ (0,
|
|
1805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
|
|
1806
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageCheckbox, { label, checked: c.value, disabled: model.readOnly, onChange: (on) => change(effectId, c, on) }),
|
|
1701
1807
|
label
|
|
1702
1808
|
] }, c.key);
|
|
1703
1809
|
case "select":
|
|
1704
|
-
return /* @__PURE__ */ (0,
|
|
1705
|
-
/* @__PURE__ */ (0,
|
|
1706
|
-
/* @__PURE__ */ (0,
|
|
1810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-muted-foreground", children: label }),
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1707
1813
|
ImageSelect,
|
|
1708
1814
|
{
|
|
1709
1815
|
label,
|
|
@@ -1716,16 +1822,16 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1716
1822
|
] }, c.key);
|
|
1717
1823
|
}
|
|
1718
1824
|
};
|
|
1719
|
-
return /* @__PURE__ */ (0,
|
|
1720
|
-
/* @__PURE__ */ (0,
|
|
1721
|
-
/* @__PURE__ */ (0,
|
|
1722
|
-
/* @__PURE__ */ (0,
|
|
1723
|
-
/* @__PURE__ */ (0,
|
|
1825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs text-foreground ${className ?? ""}`, "data-testid": "layer-effects", "aria-label": "Layer style", role: "group", children: [
|
|
1826
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1827
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "font-semibold text-foreground", children: heading ? "Layer Style" : "Styles" }),
|
|
1828
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-1 text-foreground", children: [
|
|
1829
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageCheckbox, { label: "Effects on", checked: model.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.setLayerEffectsEnabled(id, on)) }),
|
|
1724
1830
|
"On"
|
|
1725
1831
|
] }),
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
1832
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
1727
1833
|
"Scale",
|
|
1728
|
-
/* @__PURE__ */ (0,
|
|
1834
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1729
1835
|
"input",
|
|
1730
1836
|
{
|
|
1731
1837
|
type: "number",
|
|
@@ -1744,7 +1850,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1744
1850
|
),
|
|
1745
1851
|
"%"
|
|
1746
1852
|
] }),
|
|
1747
|
-
heading && /* @__PURE__ */ (0,
|
|
1853
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1748
1854
|
ImageSelect,
|
|
1749
1855
|
{
|
|
1750
1856
|
label: "Add style",
|
|
@@ -1760,14 +1866,14 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1760
1866
|
}
|
|
1761
1867
|
)
|
|
1762
1868
|
] }),
|
|
1763
|
-
model.readOnly && model.reason && /* @__PURE__ */ (0,
|
|
1764
|
-
/* @__PURE__ */ (0,
|
|
1869
|
+
model.readOnly && model.reason && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-muted-foreground", children: model.reason }),
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ul", { className: "flex flex-col gap-1", "aria-label": "Effects", children: model.rows.map((row) => {
|
|
1765
1871
|
const effect = effects.items.find((e) => e.id === row.id);
|
|
1766
1872
|
const expanded = open === row.id;
|
|
1767
|
-
return /* @__PURE__ */ (0,
|
|
1768
|
-
/* @__PURE__ */ (0,
|
|
1769
|
-
/* @__PURE__ */ (0,
|
|
1770
|
-
/* @__PURE__ */ (0,
|
|
1873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("li", { "data-effect-id": row.id, className: "rounded bg-background/60 ring-1 ring-border", children: [
|
|
1874
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1.5 px-1.5 py-1", children: [
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageCheckbox, { label: `${row.label} on`, checked: row.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.updateLayerEffect(id, row.id, { enabled: on })) }),
|
|
1876
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1771
1877
|
"button",
|
|
1772
1878
|
{
|
|
1773
1879
|
type: "button",
|
|
@@ -1777,17 +1883,17 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1777
1883
|
children: row.label
|
|
1778
1884
|
}
|
|
1779
1885
|
),
|
|
1780
|
-
/* @__PURE__ */ (0,
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: imageIconButtonClass, "aria-label": `Remove ${row.label}`, disabled: model.readOnly, onClick: () => attempt(() => controller.removeLayerEffect(id, row.id)), children: "\u2715" })
|
|
1781
1887
|
] }),
|
|
1782
|
-
expanded && /* @__PURE__ */ (0,
|
|
1888
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "grid grid-cols-2 gap-x-2 gap-y-1 px-1.5 pb-1.5", "data-testid": "effect-settings", children: (0, import_raster.layerEffectControls)(effect, patterns).map((c) => renderControl(row.id, c)) })
|
|
1783
1889
|
] }, row.id);
|
|
1784
1890
|
}) }),
|
|
1785
|
-
error && /* @__PURE__ */ (0,
|
|
1891
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
1786
1892
|
] });
|
|
1787
1893
|
};
|
|
1788
1894
|
|
|
1789
1895
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1790
|
-
var
|
|
1896
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1791
1897
|
function siblingIndex(layers, l) {
|
|
1792
1898
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1793
1899
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1795,7 +1901,7 @@ function siblingIndex(layers, l) {
|
|
|
1795
1901
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1796
1902
|
usePaintEditorState(controller);
|
|
1797
1903
|
const [error, attempt] = useAttempt();
|
|
1798
|
-
const [renaming, setRenaming] = (0,
|
|
1904
|
+
const [renaming, setRenaming] = (0, import_react16.useState)(null);
|
|
1799
1905
|
const layers = controller.listLayers().filter((l) => !l.temporary);
|
|
1800
1906
|
const active = layers.find((l) => l.active) ?? null;
|
|
1801
1907
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1805,18 +1911,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1805
1911
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1806
1912
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1807
1913
|
};
|
|
1808
|
-
return /* @__PURE__ */ (0,
|
|
1809
|
-
/* @__PURE__ */ (0,
|
|
1810
|
-
/* @__PURE__ */ (0,
|
|
1811
|
-
/* @__PURE__ */ (0,
|
|
1812
|
-
/* @__PURE__ */ (0,
|
|
1813
|
-
/* @__PURE__ */ (0,
|
|
1814
|
-
/* @__PURE__ */ (0,
|
|
1815
|
-
/* @__PURE__ */ (0,
|
|
1816
|
-
/* @__PURE__ */ (0,
|
|
1817
|
-
/* @__PURE__ */ (0,
|
|
1914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1917
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1918
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1919
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1920
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1921
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1922
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1923
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1818
1924
|
] }),
|
|
1819
|
-
/* @__PURE__ */ (0,
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1820
1926
|
"li",
|
|
1821
1927
|
{
|
|
1822
1928
|
role: "treeitem",
|
|
@@ -1825,7 +1931,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1825
1931
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1826
1932
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1827
1933
|
children: [
|
|
1828
|
-
/* @__PURE__ */ (0,
|
|
1934
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1829
1935
|
"button",
|
|
1830
1936
|
{
|
|
1831
1937
|
type: "button",
|
|
@@ -1838,7 +1944,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1838
1944
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1839
1945
|
}
|
|
1840
1946
|
),
|
|
1841
|
-
renaming === l.id ? /* @__PURE__ */ (0,
|
|
1947
|
+
renaming === l.id ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1842
1948
|
"input",
|
|
1843
1949
|
{
|
|
1844
1950
|
autoFocus: true,
|
|
@@ -1855,23 +1961,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1855
1961
|
if (e.key === "Escape") setRenaming(null);
|
|
1856
1962
|
}
|
|
1857
1963
|
}
|
|
1858
|
-
) : /* @__PURE__ */ (0,
|
|
1964
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1859
1965
|
l.type === "group" ? "\u25B8 " : "",
|
|
1860
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */ (0,
|
|
1966
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1861
1967
|
"\u270E",
|
|
1862
1968
|
" "
|
|
1863
1969
|
] }),
|
|
1864
1970
|
l.name
|
|
1865
1971
|
] }),
|
|
1866
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0,
|
|
1972
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1867
1973
|
]
|
|
1868
1974
|
},
|
|
1869
1975
|
l.id
|
|
1870
1976
|
)) }),
|
|
1871
|
-
active && /* @__PURE__ */ (0,
|
|
1872
|
-
/* @__PURE__ */ (0,
|
|
1873
|
-
/* @__PURE__ */ (0,
|
|
1874
|
-
/* @__PURE__ */ (0,
|
|
1977
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
1978
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1979
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1875
1981
|
"input",
|
|
1876
1982
|
{
|
|
1877
1983
|
type: "range",
|
|
@@ -1885,40 +1991,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1885
1991
|
}
|
|
1886
1992
|
)
|
|
1887
1993
|
] }),
|
|
1888
|
-
/* @__PURE__ */ (0,
|
|
1889
|
-
/* @__PURE__ */ (0,
|
|
1890
|
-
/* @__PURE__ */ (0,
|
|
1891
|
-
active.type === "group" && /* @__PURE__ */ (0,
|
|
1892
|
-
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1995
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1996
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { "aria-label": "Layer blend", value: active.blend, onChange: (e) => attempt(() => controller.updateLayer(active.id, { blend: e.target.value })), className: "flex-1 rounded bg-slate-800 px-1 py-0.5", children: [
|
|
1997
|
+
active.type === "group" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "pass-through", children: "Pass through" }),
|
|
1998
|
+
import_paint_editor10.BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1893
1999
|
] })
|
|
1894
2000
|
] }),
|
|
1895
|
-
/* @__PURE__ */ (0,
|
|
1896
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0,
|
|
1897
|
-
/* @__PURE__ */ (0,
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex gap-1", children: [
|
|
2002
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-pressed": Boolean(active.locks[k]), className: chip(Boolean(active.locks[k])), onClick: () => attempt(() => controller.updateLayer(active.id, { locks: { [k]: !active.locks[k] } })), children: k === "pixels" ? "Lock pixels" : "Lock transparency" }, k)),
|
|
2003
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1898
2004
|
] }),
|
|
1899
|
-
light?.hasLight && /* @__PURE__ */ (0,
|
|
1900
|
-
/* @__PURE__ */ (0,
|
|
1901
|
-
/* @__PURE__ */ (0,
|
|
1902
|
-
/* @__PURE__ */ (0,
|
|
2005
|
+
light?.hasLight && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1903
2009
|
] }),
|
|
1904
|
-
/* @__PURE__ */ (0,
|
|
1905
|
-
/* @__PURE__ */ (0,
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
2010
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", title: "How far the light spills onto the paint and paper around it (0 turns it off)", children: [
|
|
2011
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
2012
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "range", "aria-label": "Light spill radius", min: 0, max: 120, step: 1, value: light.spill.radius, onChange: (e) => attempt(() => controller.setLightSpill(active.id, { radius: Number(e.target.value) })), className: "flex-1 accent-indigo-500" })
|
|
1907
2013
|
] }),
|
|
1908
|
-
/* @__PURE__ */ (0,
|
|
1909
|
-
/* @__PURE__ */ (0,
|
|
1910
|
-
/* @__PURE__ */ (0,
|
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
2015
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
2016
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "range", "aria-label": "Light spill strength", min: 0, max: 2, step: 0.05, value: light.spill.strength, onChange: (e) => attempt(() => controller.setLightSpill(active.id, { strength: Number(e.target.value) })), className: "flex-1 accent-indigo-500" })
|
|
1911
2017
|
] })
|
|
1912
2018
|
] }),
|
|
1913
|
-
/* @__PURE__ */ (0,
|
|
2019
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "border-t border-slate-800 pt-1.5", "data-testid": "paint-layer-effects", title: "Live layer styles drawn from this layer's paint: glows, shadows, strokes", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1914
2020
|
] }),
|
|
1915
|
-
/* @__PURE__ */ (0,
|
|
2021
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ErrorLine, { error })
|
|
1916
2022
|
] });
|
|
1917
2023
|
};
|
|
1918
2024
|
|
|
1919
2025
|
// src/paint-editor/WetPanel.tsx
|
|
1920
|
-
var
|
|
1921
|
-
var
|
|
2026
|
+
var import_paint_editor11 = require("@pixerate/editor/paint-editor");
|
|
2027
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1922
2028
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1923
2029
|
var WetPanel = ({ controller, className }) => {
|
|
1924
2030
|
const state = usePaintEditorState(controller);
|
|
@@ -1928,31 +2034,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1928
2034
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1929
2035
|
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1930
2036
|
const backend = controller.wetState();
|
|
1931
|
-
return /* @__PURE__ */ (0,
|
|
1932
|
-
/* @__PURE__ */ (0,
|
|
1933
|
-
/* @__PURE__ */ (0,
|
|
1934
|
-
/* @__PURE__ */ (0,
|
|
2037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
2038
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2039
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
2040
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "text-[10px] text-slate-500", children: [
|
|
1935
2041
|
"step ",
|
|
1936
2042
|
wet.clock
|
|
1937
2043
|
] })
|
|
1938
2044
|
] }),
|
|
1939
|
-
/* @__PURE__ */ (0,
|
|
1940
|
-
/* @__PURE__ */ (0,
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
1942
|
-
/* @__PURE__ */ (0,
|
|
1943
|
-
/* @__PURE__ */ (0,
|
|
1944
|
-
/* @__PURE__ */ (0,
|
|
2045
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2046
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
2047
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: chip(wet.instantDry), "aria-pressed": wet.instantDry, title: "Each wet stroke dries as soon as it ends", onClick: () => controller.setInstantDry(!wet.instantDry), children: "Instant dry" }),
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1945
2051
|
] }),
|
|
1946
|
-
/* @__PURE__ */ (0,
|
|
1947
|
-
|
|
1948
|
-
info && /* @__PURE__ */ (0,
|
|
1949
|
-
/* @__PURE__ */ (0,
|
|
1950
|
-
|
|
1951
|
-
/* @__PURE__ */ (0,
|
|
1952
|
-
/* @__PURE__ */ (0,
|
|
1953
|
-
/* @__PURE__ */ (0,
|
|
2052
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintSlider, { control: import_paint_editor11.WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
2053
|
+
import_paint_editor11.WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor11.readPath)(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
2054
|
+
info && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
2056
|
+
import_paint_editor11.WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor11.readPath)(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
2058
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Flow map" }),
|
|
2059
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("select", { "aria-label": "Flow map", value: info.flow.kind, onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setFlowMap(layerId, { kind: e.target.value }))), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor11.WET_FLOW_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1954
2060
|
] }),
|
|
1955
|
-
info.flow.kind !== "none" && /* @__PURE__ */ (0,
|
|
2061
|
+
info.flow.kind !== "none" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1956
2062
|
PaintSlider,
|
|
1957
2063
|
{
|
|
1958
2064
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1961,10 +2067,10 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1961
2067
|
}
|
|
1962
2068
|
)
|
|
1963
2069
|
] }),
|
|
1964
|
-
livePattern && layerId && /* @__PURE__ */ (0,
|
|
1965
|
-
/* @__PURE__ */ (0,
|
|
1966
|
-
/* @__PURE__ */ (0,
|
|
1967
|
-
/* @__PURE__ */ (0,
|
|
2070
|
+
livePattern && layerId && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-live-patterns", children: [
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2072
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "font-medium text-slate-300", children: "Live patterns" }),
|
|
2073
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1968
2074
|
"button",
|
|
1969
2075
|
{
|
|
1970
2076
|
type: "button",
|
|
@@ -1979,35 +2085,35 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1979
2085
|
}
|
|
1980
2086
|
)
|
|
1981
2087
|
] }),
|
|
1982
|
-
/* @__PURE__ */ (0,
|
|
1983
|
-
/* @__PURE__ */ (0,
|
|
1984
|
-
/* @__PURE__ */ (0,
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
2089
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Pattern" }),
|
|
2090
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1985
2091
|
"select",
|
|
1986
2092
|
{
|
|
1987
2093
|
"aria-label": "Live pattern",
|
|
1988
2094
|
value: livePattern.settings.pattern,
|
|
1989
2095
|
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1990
2096
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1991
|
-
children:
|
|
2097
|
+
children: import_paint_editor11.LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: k, children: import_paint_editor11.LIVE_PATTERN_LABELS[k] }, k))
|
|
1992
2098
|
}
|
|
1993
2099
|
)
|
|
1994
2100
|
] }),
|
|
1995
|
-
|
|
2101
|
+
import_paint_editor11.LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor11.readPath)(livePattern.settings, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { [c.path]: v }))) }, c.path))
|
|
1996
2102
|
] }),
|
|
1997
|
-
backend.message && /* @__PURE__ */ (0,
|
|
1998
|
-
backend.backend && /* @__PURE__ */ (0,
|
|
1999
|
-
/* @__PURE__ */ (0,
|
|
2000
|
-
/* @__PURE__ */ (0,
|
|
2001
|
-
/* @__PURE__ */ (0,
|
|
2103
|
+
backend.message && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
2104
|
+
backend.backend && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-[10px] text-slate-500", children: backend.backend.kind === "wasm-threads" ? `WebAssembly, ${backend.backend.threads} threads` : backend.backend.kind === "wasm" ? "WebAssembly, one thread" : "JavaScript" }),
|
|
2105
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
2106
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Engine" }),
|
|
2107
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("select", { "aria-label": "Wet engine", value: wet.gpu, onChange: (e) => attempt(() => controller.setWetEngine({ gpu: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor11.WET_GPU_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: o.value, children: o.label }, o.value)) })
|
|
2002
2108
|
] }),
|
|
2003
|
-
/* @__PURE__ */ (0,
|
|
2004
|
-
/* @__PURE__ */ (0,
|
|
2109
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: (0, import_paint_editor11.wetEngineSummary)(backend.engine) }),
|
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorLine, { error })
|
|
2005
2111
|
] });
|
|
2006
2112
|
};
|
|
2007
2113
|
|
|
2008
2114
|
// src/paint-editor/StickerPanel.tsx
|
|
2009
|
-
var
|
|
2010
|
-
var
|
|
2115
|
+
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
2116
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2011
2117
|
var StickerPanel = ({ controller, className }) => {
|
|
2012
2118
|
const state = usePaintEditorState(controller);
|
|
2013
2119
|
const [error, attempt] = useAttempt();
|
|
@@ -2017,16 +2123,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
2017
2123
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
2018
2124
|
if (!stickers.length) return null;
|
|
2019
2125
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
2020
|
-
return /* @__PURE__ */ (0,
|
|
2021
|
-
/* @__PURE__ */ (0,
|
|
2126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
2127
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
2022
2128
|
"Stickers (",
|
|
2023
2129
|
stickers.length,
|
|
2024
2130
|
")"
|
|
2025
2131
|
] }),
|
|
2026
|
-
/* @__PURE__ */ (0,
|
|
2027
|
-
sel && /* @__PURE__ */ (0,
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2029
|
-
/* @__PURE__ */ (0,
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Stickers", children: stickers.map((s) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", role: "option", "aria-selected": s.id === picked, title: `${(0, import_paint_editor12.stickerRefLabel)(s.ref)} ${s.id}`, className: `h-5 w-5 rounded ring-1 ${s.id === picked ? "ring-indigo-400" : "ring-slate-700"}`, style: { background: s.color }, onClick: () => setPicked(s.id) }, s.id)) }),
|
|
2133
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
2134
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "Sticker" }),
|
|
2135
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2030
2136
|
StickerPicker,
|
|
2031
2137
|
{
|
|
2032
2138
|
controller,
|
|
@@ -2040,9 +2146,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
2040
2146
|
)
|
|
2041
2147
|
}
|
|
2042
2148
|
),
|
|
2043
|
-
/* @__PURE__ */ (0,
|
|
2044
|
-
/* @__PURE__ */ (0,
|
|
2045
|
-
/* @__PURE__ */ (0,
|
|
2149
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2150
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "Position" }),
|
|
2151
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2046
2152
|
"input",
|
|
2047
2153
|
{
|
|
2048
2154
|
type: "number",
|
|
@@ -2056,24 +2162,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
2056
2162
|
`${sel.id}-${k}-${sel[k]}`
|
|
2057
2163
|
)) })
|
|
2058
2164
|
] }),
|
|
2059
|
-
|
|
2060
|
-
/* @__PURE__ */ (0,
|
|
2061
|
-
/* @__PURE__ */ (0,
|
|
2062
|
-
/* @__PURE__ */ (0,
|
|
2165
|
+
import_paint_editor12.STICKER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime18.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)),
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CommitColorInput, { label: "Sticker colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
2063
2169
|
] }),
|
|
2064
|
-
/* @__PURE__ */ (0,
|
|
2065
|
-
/* @__PURE__ */ (0,
|
|
2066
|
-
/* @__PURE__ */ (0,
|
|
2067
|
-
/* @__PURE__ */ (0,
|
|
2170
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2171
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
2172
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
2173
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
2068
2174
|
] })
|
|
2069
2175
|
] }),
|
|
2070
|
-
/* @__PURE__ */ (0,
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ErrorLine, { error })
|
|
2071
2177
|
] });
|
|
2072
2178
|
};
|
|
2073
2179
|
|
|
2074
2180
|
// src/paint-editor/StrokePanel.tsx
|
|
2075
|
-
var
|
|
2076
|
-
var
|
|
2181
|
+
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
2182
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2077
2183
|
var StrokePanel = ({ controller, className }) => {
|
|
2078
2184
|
const state = usePaintEditorState(controller);
|
|
2079
2185
|
const [error, attempt] = useAttempt();
|
|
@@ -2082,17 +2188,17 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
2082
2188
|
if (!layerId || !strokes) return null;
|
|
2083
2189
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
2084
2190
|
const sel = index >= 0 ? strokes[index] : null;
|
|
2085
|
-
const brushes = state.brushes.filter((b) => !(0,
|
|
2086
|
-
return /* @__PURE__ */ (0,
|
|
2087
|
-
/* @__PURE__ */ (0,
|
|
2088
|
-
/* @__PURE__ */ (0,
|
|
2191
|
+
const brushes = state.brushes.filter((b) => !(0, import_paint_editor13.liveStrokeRefusal)(b));
|
|
2192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
2193
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2194
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
2089
2195
|
"Strokes (",
|
|
2090
2196
|
strokes.length,
|
|
2091
2197
|
")"
|
|
2092
2198
|
] }),
|
|
2093
|
-
/* @__PURE__ */ (0,
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
2094
2200
|
] }),
|
|
2095
|
-
/* @__PURE__ */ (0,
|
|
2201
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)(
|
|
2096
2202
|
"button",
|
|
2097
2203
|
{
|
|
2098
2204
|
type: "button",
|
|
@@ -2105,10 +2211,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
2105
2211
|
},
|
|
2106
2212
|
s.id
|
|
2107
2213
|
)) }),
|
|
2108
|
-
sel && /* @__PURE__ */ (0,
|
|
2109
|
-
/* @__PURE__ */ (0,
|
|
2110
|
-
/* @__PURE__ */ (0,
|
|
2111
|
-
/* @__PURE__ */ (0,
|
|
2214
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-slate-400", children: "Brush" }),
|
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2112
2218
|
"select",
|
|
2113
2219
|
{
|
|
2114
2220
|
"aria-label": "Stroke brush",
|
|
@@ -2116,41 +2222,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
2116
2222
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
2117
2223
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
2118
2224
|
children: [
|
|
2119
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0,
|
|
2120
|
-
brushes.map((b) => /* @__PURE__ */ (0,
|
|
2225
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: sel.brush.name }),
|
|
2226
|
+
brushes.map((b) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: b.id, children: b.name }, b.id))
|
|
2121
2227
|
]
|
|
2122
2228
|
}
|
|
2123
2229
|
)
|
|
2124
2230
|
] }),
|
|
2125
|
-
|
|
2126
|
-
/* @__PURE__ */ (0,
|
|
2127
|
-
/* @__PURE__ */ (0,
|
|
2128
|
-
/* @__PURE__ */ (0,
|
|
2231
|
+
import_paint_editor13.STROKE_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime19.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)),
|
|
2232
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
2233
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
2234
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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" })
|
|
2129
2235
|
] }),
|
|
2130
|
-
/* @__PURE__ */ (0,
|
|
2131
|
-
/* @__PURE__ */ (0,
|
|
2132
|
-
/* @__PURE__ */ (0,
|
|
2133
|
-
/* @__PURE__ */ (0,
|
|
2134
|
-
/* @__PURE__ */ (0,
|
|
2236
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2237
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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" }),
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
2135
2241
|
] })
|
|
2136
2242
|
] }),
|
|
2137
|
-
/* @__PURE__ */ (0,
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ErrorLine, { error })
|
|
2138
2244
|
] });
|
|
2139
2245
|
};
|
|
2140
2246
|
|
|
2141
2247
|
// src/paint-editor/PathStrokePanel.tsx
|
|
2142
|
-
var
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2248
|
+
var import_react17 = require("react");
|
|
2249
|
+
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
2250
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2145
2251
|
var PathStrokePanel = ({ controller, className }) => {
|
|
2146
2252
|
const state = usePaintEditorState(controller);
|
|
2147
2253
|
const [error, attempt] = useAttempt();
|
|
2148
|
-
const [path, setPath] = (0,
|
|
2149
|
-
const [taper, setTaper] = (0,
|
|
2150
|
-
const pressure =
|
|
2151
|
-
return /* @__PURE__ */ (0,
|
|
2152
|
-
/* @__PURE__ */ (0,
|
|
2153
|
-
/* @__PURE__ */ (0,
|
|
2254
|
+
const [path, setPath] = (0, import_react17.useState)("");
|
|
2255
|
+
const [taper, setTaper] = (0, import_react17.useState)(import_paint_editor14.PATH_STROKE_TAPERS[0].id);
|
|
2256
|
+
const pressure = import_paint_editor14.PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
2257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2154
2260
|
"textarea",
|
|
2155
2261
|
{
|
|
2156
2262
|
"aria-label": "SVG path data",
|
|
@@ -2161,33 +2267,33 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
2161
2267
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
2162
2268
|
}
|
|
2163
2269
|
),
|
|
2164
|
-
/* @__PURE__ */ (0,
|
|
2165
|
-
/* @__PURE__ */ (0,
|
|
2166
|
-
/* @__PURE__ */ (0,
|
|
2270
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2271
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("select", { "aria-label": "Pressure along the path", value: taper, onChange: (e) => setTaper(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor14.PATH_STROKE_TAPERS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: t.id, children: t.label }, t.id)) }),
|
|
2272
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
2167
2273
|
] }),
|
|
2168
|
-
/* @__PURE__ */ (0,
|
|
2274
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ErrorLine, { error })
|
|
2169
2275
|
] });
|
|
2170
2276
|
};
|
|
2171
2277
|
|
|
2172
2278
|
// src/paint-editor/EvolutionPanel.tsx
|
|
2173
|
-
var
|
|
2174
|
-
var
|
|
2175
|
-
var
|
|
2279
|
+
var import_react18 = require("react");
|
|
2280
|
+
var import_paint_editor15 = require("@pixerate/editor/paint-editor");
|
|
2281
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2176
2282
|
var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
2177
2283
|
const state = usePaintEditorState(controller);
|
|
2178
2284
|
const store = proposals ?? controller.proposals;
|
|
2179
|
-
const proposalState = (0,
|
|
2285
|
+
const proposalState = (0, import_react18.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
2180
2286
|
const [error, attempt] = useAttempt();
|
|
2181
|
-
const [selectedStrokes, setSelectedStrokes] = (0,
|
|
2182
|
-
const [selectedProposals, setSelectedProposals] = (0,
|
|
2183
|
-
const [count, setCount] = (0,
|
|
2184
|
-
const [seed, setSeed] = (0,
|
|
2185
|
-
const [mutation, setMutation] = (0,
|
|
2186
|
-
const [contactSheetUrl, setContactSheetUrl] = (0,
|
|
2187
|
-
const eligibleStrokes = state.document.strokes.filter((s) => !(0,
|
|
2287
|
+
const [selectedStrokes, setSelectedStrokes] = (0, import_react18.useState)([]);
|
|
2288
|
+
const [selectedProposals, setSelectedProposals] = (0, import_react18.useState)([]);
|
|
2289
|
+
const [count, setCount] = (0, import_react18.useState)(4);
|
|
2290
|
+
const [seed, setSeed] = (0, import_react18.useState)(1);
|
|
2291
|
+
const [mutation, setMutation] = (0, import_react18.useState)(() => (0, import_paint_editor15.normalizeMutationRates)());
|
|
2292
|
+
const [contactSheetUrl, setContactSheetUrl] = (0, import_react18.useState)(null);
|
|
2293
|
+
const eligibleStrokes = state.document.strokes.filter((s) => !(0, import_paint_editor15.liveStrokeRefusal)(s.brush));
|
|
2188
2294
|
const activeStrokeIds = selectedStrokes.filter((id) => eligibleStrokes.some((s) => s.id === id));
|
|
2189
2295
|
const effectiveStrokeIds = activeStrokeIds.length > 0 ? activeStrokeIds : state.selectedStroke && eligibleStrokes.some((s) => s.id === state.selectedStroke) ? [state.selectedStroke] : eligibleStrokes.length > 0 ? [eligibleStrokes[eligibleStrokes.length - 1].id] : [];
|
|
2190
|
-
const variants = proposalState.proposals.filter((p) => (0,
|
|
2296
|
+
const variants = proposalState.proposals.filter((p) => (0, import_paint_editor15.proposalGenomeStrokes)(p).length > 0);
|
|
2191
2297
|
const activeProposalIds = selectedProposals.filter((id) => variants.some((v) => v.id === id));
|
|
2192
2298
|
const toggleStroke = (id) => {
|
|
2193
2299
|
setSelectedStrokes((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-15), id]);
|
|
@@ -2195,16 +2301,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2195
2301
|
const toggleProposal = (id) => {
|
|
2196
2302
|
setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
|
|
2197
2303
|
};
|
|
2198
|
-
return /* @__PURE__ */ (0,
|
|
2199
|
-
/* @__PURE__ */ (0,
|
|
2200
|
-
/* @__PURE__ */ (0,
|
|
2304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "evolution-panel", children: [
|
|
2305
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2306
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
2201
2307
|
"Evolution (",
|
|
2202
2308
|
eligibleStrokes.length,
|
|
2203
2309
|
")"
|
|
2204
2310
|
] }),
|
|
2205
|
-
/* @__PURE__ */ (0,
|
|
2206
|
-
/* @__PURE__ */ (0,
|
|
2207
|
-
/* @__PURE__ */ (0,
|
|
2311
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
|
|
2312
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: "Count" }),
|
|
2313
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2208
2314
|
"input",
|
|
2209
2315
|
{
|
|
2210
2316
|
type: "number",
|
|
@@ -2218,9 +2324,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2218
2324
|
)
|
|
2219
2325
|
] }) })
|
|
2220
2326
|
] }),
|
|
2221
|
-
eligibleStrokes.length > 0 && /* @__PURE__ */ (0,
|
|
2327
|
+
eligibleStrokes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex max-h-20 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Parent strokes", children: eligibleStrokes.map((s, i) => {
|
|
2222
2328
|
const on = effectiveStrokeIds.includes(s.id);
|
|
2223
|
-
return /* @__PURE__ */ (0,
|
|
2329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2224
2330
|
"button",
|
|
2225
2331
|
{
|
|
2226
2332
|
type: "button",
|
|
@@ -2234,9 +2340,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2234
2340
|
s.id
|
|
2235
2341
|
);
|
|
2236
2342
|
}) }),
|
|
2237
|
-
|
|
2343
|
+
import_paint_editor15.EVOLUTION_SLIDERS.map((c) => {
|
|
2238
2344
|
const key = c.path;
|
|
2239
|
-
return /* @__PURE__ */ (0,
|
|
2345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2240
2346
|
PaintSlider,
|
|
2241
2347
|
{
|
|
2242
2348
|
control: c,
|
|
@@ -2246,8 +2352,8 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2246
2352
|
c.path
|
|
2247
2353
|
);
|
|
2248
2354
|
}),
|
|
2249
|
-
/* @__PURE__ */ (0,
|
|
2250
|
-
/* @__PURE__ */ (0,
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2356
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2251
2357
|
"button",
|
|
2252
2358
|
{
|
|
2253
2359
|
type: "button",
|
|
@@ -2260,7 +2366,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2260
2366
|
children: "Breed strokes"
|
|
2261
2367
|
}
|
|
2262
2368
|
),
|
|
2263
|
-
activeProposalIds.length === 2 && /* @__PURE__ */ (0,
|
|
2369
|
+
activeProposalIds.length === 2 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2264
2370
|
"button",
|
|
2265
2371
|
{
|
|
2266
2372
|
type: "button",
|
|
@@ -2273,29 +2379,29 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2273
2379
|
children: "Cross over (2)"
|
|
2274
2380
|
}
|
|
2275
2381
|
),
|
|
2276
|
-
variants.length > 0 && /* @__PURE__ */ (0,
|
|
2382
|
+
variants.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2277
2383
|
"button",
|
|
2278
2384
|
{
|
|
2279
2385
|
type: "button",
|
|
2280
2386
|
className: button,
|
|
2281
2387
|
onClick: () => attempt(() => {
|
|
2282
|
-
const sheet = (0,
|
|
2388
|
+
const sheet = (0, import_paint_editor15.exportProposalContactSheetPng)(controller, variants);
|
|
2283
2389
|
setContactSheetUrl(`data:image/png;base64,${sheet.base64}`);
|
|
2284
2390
|
}),
|
|
2285
2391
|
children: "Contact sheet"
|
|
2286
2392
|
}
|
|
2287
2393
|
)
|
|
2288
2394
|
] }),
|
|
2289
|
-
variants.length > 0 && /* @__PURE__ */ (0,
|
|
2290
|
-
const g = (0,
|
|
2395
|
+
variants.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "evolution-grid", children: variants.map((p) => {
|
|
2396
|
+
const g = (0, import_paint_editor15.paintProposalGhost)(p);
|
|
2291
2397
|
const picked = activeProposalIds.includes(p.id);
|
|
2292
|
-
return /* @__PURE__ */ (0,
|
|
2398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2293
2399
|
"div",
|
|
2294
2400
|
{
|
|
2295
2401
|
"data-testid": `evolution-variant-${p.id}`,
|
|
2296
2402
|
className: `flex flex-col gap-1 rounded border p-1.5 ${picked ? "border-indigo-500 bg-slate-800/90" : "border-slate-800 bg-slate-950/60"}`,
|
|
2297
2403
|
children: [
|
|
2298
|
-
/* @__PURE__ */ (0,
|
|
2404
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2299
2405
|
"button",
|
|
2300
2406
|
{
|
|
2301
2407
|
type: "button",
|
|
@@ -2305,10 +2411,10 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2305
2411
|
children: p.title
|
|
2306
2412
|
}
|
|
2307
2413
|
) }),
|
|
2308
|
-
g && /* @__PURE__ */ (0,
|
|
2309
|
-
p.rationale && /* @__PURE__ */ (0,
|
|
2310
|
-
/* @__PURE__ */ (0,
|
|
2311
|
-
/* @__PURE__ */ (0,
|
|
2414
|
+
g && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex h-16 items-center justify-center overflow-hidden rounded bg-slate-900/80 p-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PixelCanvas, { pixels: g, label: p.title, className: "max-h-full max-w-full object-contain" }) }),
|
|
2415
|
+
p.rationale && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "line-clamp-2 text-[10px] text-slate-400", title: p.rationale, children: p.rationale }),
|
|
2416
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2417
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2312
2418
|
"button",
|
|
2313
2419
|
{
|
|
2314
2420
|
type: "button",
|
|
@@ -2321,42 +2427,42 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2321
2427
|
children: "Breed from"
|
|
2322
2428
|
}
|
|
2323
2429
|
),
|
|
2324
|
-
/* @__PURE__ */ (0,
|
|
2325
|
-
/* @__PURE__ */ (0,
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => store.accept(p.id)), children: "Accept" }),
|
|
2431
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => store.reject(p.id)), children: "Dismiss" })
|
|
2326
2432
|
] })
|
|
2327
2433
|
]
|
|
2328
2434
|
},
|
|
2329
2435
|
p.id
|
|
2330
2436
|
);
|
|
2331
2437
|
}) }),
|
|
2332
|
-
contactSheetUrl && /* @__PURE__ */ (0,
|
|
2333
|
-
/* @__PURE__ */ (0,
|
|
2438
|
+
contactSheetUrl && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("img", { src: contactSheetUrl, alt: "Variant contact sheet", className: "w-full rounded border border-slate-800", "data-testid": "evolution-contact-sheet" }),
|
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorLine, { error })
|
|
2334
2440
|
] });
|
|
2335
2441
|
};
|
|
2336
2442
|
|
|
2337
2443
|
// src/paint-editor/PaintEditor.tsx
|
|
2338
|
-
var
|
|
2339
|
-
var
|
|
2444
|
+
var import_react32 = require("react");
|
|
2445
|
+
var import_paint_editor17 = require("@pixerate/editor/paint-editor");
|
|
2340
2446
|
|
|
2341
2447
|
// src/playback/AgentPlaybackContext.tsx
|
|
2342
|
-
var
|
|
2343
|
-
var
|
|
2344
|
-
var AgentPlaybackContext = (0,
|
|
2448
|
+
var import_react19 = require("react");
|
|
2449
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2450
|
+
var AgentPlaybackContext = (0, import_react19.createContext)(null);
|
|
2345
2451
|
function useAgentPlayback() {
|
|
2346
|
-
return (0,
|
|
2452
|
+
return (0, import_react19.useContext)(AgentPlaybackContext);
|
|
2347
2453
|
}
|
|
2348
2454
|
|
|
2349
2455
|
// src/playback/usePlaybackSurface.ts
|
|
2350
|
-
var
|
|
2456
|
+
var import_react20 = require("react");
|
|
2351
2457
|
var import_tools = require("@pixerate/editor/tools");
|
|
2352
2458
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
2353
2459
|
const ambient = useAgentPlayback();
|
|
2354
2460
|
const target = playback === void 0 ? ambient : playback;
|
|
2355
|
-
const [ownPresence] = (0,
|
|
2461
|
+
const [ownPresence] = (0, import_react20.useState)(() => new import_tools.PresenceStore());
|
|
2356
2462
|
const presence = sharedPresence ?? ownPresence;
|
|
2357
|
-
const latest = (0,
|
|
2463
|
+
const latest = (0, import_react20.useRef)(options);
|
|
2358
2464
|
latest.current = options;
|
|
2359
|
-
(0,
|
|
2465
|
+
(0, import_react20.useEffect)(() => {
|
|
2360
2466
|
if (!target || !id) return;
|
|
2361
2467
|
const o = () => latest.current;
|
|
2362
2468
|
const surface = {
|
|
@@ -2388,13 +2494,13 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
2388
2494
|
}
|
|
2389
2495
|
|
|
2390
2496
|
// src/playback/PresenceLayer.tsx
|
|
2391
|
-
var
|
|
2392
|
-
var
|
|
2497
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
2498
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2393
2499
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
2394
|
-
const { actors } = (0,
|
|
2500
|
+
const { actors } = (0, import_react21.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
2395
2501
|
if (!actors.length) return null;
|
|
2396
2502
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
2397
|
-
return /* @__PURE__ */ (0,
|
|
2503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2398
2504
|
"div",
|
|
2399
2505
|
{
|
|
2400
2506
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -2408,19 +2514,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
2408
2514
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
2409
2515
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
2410
2516
|
})();
|
|
2411
|
-
return /* @__PURE__ */ (0,
|
|
2412
|
-
ring && /* @__PURE__ */ (0,
|
|
2517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react21.default.Fragment, { children: [
|
|
2518
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2413
2519
|
"div",
|
|
2414
2520
|
{
|
|
2415
2521
|
"data-actor-focus": a.id,
|
|
2416
2522
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
2417
2523
|
}
|
|
2418
2524
|
),
|
|
2419
|
-
/* @__PURE__ */ (0,
|
|
2420
|
-
/* @__PURE__ */ (0,
|
|
2421
|
-
/* @__PURE__ */ (0,
|
|
2422
|
-
/* @__PURE__ */ (0,
|
|
2423
|
-
a.message && /* @__PURE__ */ (0,
|
|
2525
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.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_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
2526
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.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_runtime23.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 } }) }),
|
|
2527
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
2528
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
2529
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime23.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 })
|
|
2424
2530
|
] })
|
|
2425
2531
|
] }) })
|
|
2426
2532
|
] }, a.id);
|
|
@@ -2430,16 +2536,16 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
2430
2536
|
}
|
|
2431
2537
|
|
|
2432
2538
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
2433
|
-
var
|
|
2434
|
-
var
|
|
2539
|
+
var import_react31 = require("react");
|
|
2540
|
+
var import_paint_editor16 = require("@pixerate/editor/paint-editor");
|
|
2435
2541
|
var import_effects4 = require("@pixerate/editor/effects");
|
|
2436
2542
|
|
|
2437
2543
|
// src/effects/useEffects.ts
|
|
2438
|
-
var
|
|
2544
|
+
var import_react22 = require("react");
|
|
2439
2545
|
function useEffectDescription(provider, effect) {
|
|
2440
|
-
const [state, setState] = (0,
|
|
2546
|
+
const [state, setState] = (0, import_react22.useState)({ key: "", description: null, error: null });
|
|
2441
2547
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
2442
|
-
(0,
|
|
2548
|
+
(0, import_react22.useEffect)(() => {
|
|
2443
2549
|
if (!provider || !effect) return;
|
|
2444
2550
|
let live = true;
|
|
2445
2551
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -2454,14 +2560,14 @@ function useEffectDescription(provider, effect) {
|
|
|
2454
2560
|
}
|
|
2455
2561
|
|
|
2456
2562
|
// src/effects/EffectThumbnail.tsx
|
|
2457
|
-
var
|
|
2563
|
+
var import_react23 = require("react");
|
|
2458
2564
|
var import_effects = require("@pixerate/editor/effects");
|
|
2459
|
-
var
|
|
2565
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2460
2566
|
var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing" };
|
|
2461
2567
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
2462
|
-
const ref = (0,
|
|
2463
|
-
const [failed, setFailed] = (0,
|
|
2464
|
-
(0,
|
|
2568
|
+
const ref = (0, import_react23.useRef)(null);
|
|
2569
|
+
const [failed, setFailed] = (0, import_react23.useState)(effect.kind in LABELS);
|
|
2570
|
+
(0, import_react23.useEffect)(() => {
|
|
2465
2571
|
if (effect.kind in LABELS) return;
|
|
2466
2572
|
let live = true;
|
|
2467
2573
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -2476,28 +2582,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
2476
2582
|
live = false;
|
|
2477
2583
|
};
|
|
2478
2584
|
}, [provider, effect, width, height]);
|
|
2479
|
-
return /* @__PURE__ */ (0,
|
|
2585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2480
2586
|
"div",
|
|
2481
2587
|
{
|
|
2482
2588
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
2483
2589
|
style: { aspectRatio: `${width} / ${height}` },
|
|
2484
2590
|
"data-effect-thumbnail": effect.id,
|
|
2485
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
2591
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime24.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_runtime24.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
2486
2592
|
}
|
|
2487
2593
|
);
|
|
2488
2594
|
}
|
|
2489
2595
|
|
|
2490
2596
|
// src/effects/EffectsBrowser.tsx
|
|
2491
|
-
var
|
|
2597
|
+
var import_react24 = require("react");
|
|
2492
2598
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
2493
|
-
var
|
|
2599
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2494
2600
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
2495
|
-
const [all, setAll] = (0,
|
|
2496
|
-
const [query, setQuery] = (0,
|
|
2497
|
-
const [category, setCategory] = (0,
|
|
2498
|
-
const [use, setUse] = (0,
|
|
2499
|
-
const [error, setError] = (0,
|
|
2500
|
-
(0,
|
|
2601
|
+
const [all, setAll] = (0, import_react24.useState)([]);
|
|
2602
|
+
const [query, setQuery] = (0, import_react24.useState)("");
|
|
2603
|
+
const [category, setCategory] = (0, import_react24.useState)("");
|
|
2604
|
+
const [use, setUse] = (0, import_react24.useState)("");
|
|
2605
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
2606
|
+
(0, import_react24.useEffect)(() => {
|
|
2501
2607
|
if (!provider) return setAll([]);
|
|
2502
2608
|
let live = true;
|
|
2503
2609
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -2508,8 +2614,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2508
2614
|
live = false;
|
|
2509
2615
|
};
|
|
2510
2616
|
}, [provider]);
|
|
2511
|
-
const [found, setFound] = (0,
|
|
2512
|
-
(0,
|
|
2617
|
+
const [found, setFound] = (0, import_react24.useState)([]);
|
|
2618
|
+
(0, import_react24.useEffect)(() => {
|
|
2513
2619
|
if (!provider) return setFound([]);
|
|
2514
2620
|
let live = true;
|
|
2515
2621
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -2518,14 +2624,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2518
2624
|
};
|
|
2519
2625
|
}, [provider, query, category, use]);
|
|
2520
2626
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
2521
|
-
const categories = (0,
|
|
2627
|
+
const categories = (0, import_react24.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
2522
2628
|
const shown = found.filter(allowed);
|
|
2523
2629
|
if (!provider)
|
|
2524
|
-
return /* @__PURE__ */ (0,
|
|
2525
|
-
return /* @__PURE__ */ (0,
|
|
2526
|
-
title && /* @__PURE__ */ (0,
|
|
2527
|
-
/* @__PURE__ */ (0,
|
|
2528
|
-
/* @__PURE__ */ (0,
|
|
2630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.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." });
|
|
2631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
2632
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
2633
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2634
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2529
2635
|
"input",
|
|
2530
2636
|
{
|
|
2531
2637
|
type: "search",
|
|
@@ -2536,17 +2642,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2536
2642
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
2537
2643
|
}
|
|
2538
2644
|
),
|
|
2539
|
-
/* @__PURE__ */ (0,
|
|
2540
|
-
/* @__PURE__ */ (0,
|
|
2541
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
2645
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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: [
|
|
2646
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "", children: "All categories" }),
|
|
2647
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: c, children: c }, c))
|
|
2542
2648
|
] }),
|
|
2543
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
2544
|
-
/* @__PURE__ */ (0,
|
|
2545
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
2649
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime25.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: [
|
|
2650
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "", children: "Any use" }),
|
|
2651
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
2546
2652
|
] })
|
|
2547
2653
|
] }),
|
|
2548
|
-
error && /* @__PURE__ */ (0,
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2654
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
2655
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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_runtime25.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2550
2656
|
"button",
|
|
2551
2657
|
{
|
|
2552
2658
|
type: "button",
|
|
@@ -2555,23 +2661,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2555
2661
|
"data-effect-id": e.id,
|
|
2556
2662
|
onClick: () => onPick(e),
|
|
2557
2663
|
children: [
|
|
2558
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
2559
|
-
/* @__PURE__ */ (0,
|
|
2560
|
-
/* @__PURE__ */ (0,
|
|
2664
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
2665
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
2666
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
2561
2667
|
]
|
|
2562
2668
|
}
|
|
2563
2669
|
) }, e.id)) }),
|
|
2564
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
2670
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
2565
2671
|
] });
|
|
2566
2672
|
}
|
|
2567
2673
|
|
|
2568
2674
|
// src/effects/EffectParameters.tsx
|
|
2569
|
-
var
|
|
2675
|
+
var import_react30 = __toESM(require("react"), 1);
|
|
2570
2676
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
2571
2677
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
2572
2678
|
|
|
2573
2679
|
// src/parameters/fields.tsx
|
|
2574
|
-
var
|
|
2680
|
+
var import_react29 = require("react");
|
|
2575
2681
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
2576
2682
|
|
|
2577
2683
|
// src/color/index.ts
|
|
@@ -2584,9 +2690,9 @@ __export(color_exports, {
|
|
|
2584
2690
|
});
|
|
2585
2691
|
|
|
2586
2692
|
// src/color/ColorPicker.tsx
|
|
2587
|
-
var
|
|
2693
|
+
var import_react25 = require("react");
|
|
2588
2694
|
var import_color = require("@pixerate/editor/color");
|
|
2589
|
-
var
|
|
2695
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2590
2696
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
2591
2697
|
function readLocalRecents() {
|
|
2592
2698
|
try {
|
|
@@ -2624,24 +2730,24 @@ var ColorPicker = ({
|
|
|
2624
2730
|
id,
|
|
2625
2731
|
"aria-label": ariaLabel = "Color picker"
|
|
2626
2732
|
}) => {
|
|
2627
|
-
const generatedId = (0,
|
|
2733
|
+
const generatedId = (0, import_react25.useId)();
|
|
2628
2734
|
const pickerId = id || generatedId;
|
|
2629
|
-
const [pickerState, setPickerState] = (0,
|
|
2735
|
+
const [pickerState, setPickerState] = (0, import_react25.useState)(
|
|
2630
2736
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
2631
2737
|
);
|
|
2632
|
-
const stateRef = (0,
|
|
2738
|
+
const stateRef = (0, import_react25.useRef)(pickerState);
|
|
2633
2739
|
stateRef.current = pickerState;
|
|
2634
|
-
(0,
|
|
2740
|
+
(0, import_react25.useEffect)(() => {
|
|
2635
2741
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
2636
2742
|
if (next) {
|
|
2637
2743
|
setPickerState(next);
|
|
2638
2744
|
}
|
|
2639
2745
|
}, [value]);
|
|
2640
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
2746
|
+
const [internalRecent, setInternalRecent] = (0, import_react25.useState)(
|
|
2641
2747
|
() => controlledRecent ? [] : readLocalRecents()
|
|
2642
2748
|
);
|
|
2643
2749
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
2644
|
-
const recordRecent = (0,
|
|
2750
|
+
const recordRecent = (0, import_react25.useCallback)(
|
|
2645
2751
|
(color) => {
|
|
2646
2752
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
2647
2753
|
if (!controlledRecent) {
|
|
@@ -2652,11 +2758,11 @@ var ColorPicker = ({
|
|
|
2652
2758
|
},
|
|
2653
2759
|
[activeRecent, controlledRecent, onRecentChange]
|
|
2654
2760
|
);
|
|
2655
|
-
const [textDraft, setTextDraft] = (0,
|
|
2656
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
2657
|
-
const [isClipped, setIsClipped] = (0,
|
|
2658
|
-
const isTypingRef = (0,
|
|
2659
|
-
(0,
|
|
2761
|
+
const [textDraft, setTextDraft] = (0, import_react25.useState)(value);
|
|
2762
|
+
const [isInvalid, setIsInvalid] = (0, import_react25.useState)(false);
|
|
2763
|
+
const [isClipped, setIsClipped] = (0, import_react25.useState)(false);
|
|
2764
|
+
const isTypingRef = (0, import_react25.useRef)(false);
|
|
2765
|
+
(0, import_react25.useEffect)(() => {
|
|
2660
2766
|
if (!isTypingRef.current) {
|
|
2661
2767
|
setTextDraft(value);
|
|
2662
2768
|
setIsInvalid(false);
|
|
@@ -2664,11 +2770,11 @@ var ColorPicker = ({
|
|
|
2664
2770
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
2665
2771
|
}
|
|
2666
2772
|
}, [value]);
|
|
2667
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
2668
|
-
(0,
|
|
2773
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react25.useState)(false);
|
|
2774
|
+
(0, import_react25.useEffect)(() => {
|
|
2669
2775
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
2670
2776
|
}, []);
|
|
2671
|
-
const emitColorChange = (0,
|
|
2777
|
+
const emitColorChange = (0, import_react25.useCallback)(
|
|
2672
2778
|
(nextState) => {
|
|
2673
2779
|
setPickerState(nextState);
|
|
2674
2780
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -2676,10 +2782,10 @@ var ColorPicker = ({
|
|
|
2676
2782
|
},
|
|
2677
2783
|
[alpha, onChange]
|
|
2678
2784
|
);
|
|
2679
|
-
const latest = (0,
|
|
2785
|
+
const latest = (0, import_react25.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
2680
2786
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
2681
|
-
const endDragRef = (0,
|
|
2682
|
-
(0,
|
|
2787
|
+
const endDragRef = (0, import_react25.useRef)(null);
|
|
2788
|
+
(0, import_react25.useEffect)(() => () => endDragRef.current?.(), []);
|
|
2683
2789
|
const startDrag = (e, next) => {
|
|
2684
2790
|
if (disabled) return;
|
|
2685
2791
|
e.preventDefault();
|
|
@@ -2781,7 +2887,7 @@ var ColorPicker = ({
|
|
|
2781
2887
|
} catch {
|
|
2782
2888
|
}
|
|
2783
2889
|
};
|
|
2784
|
-
const contrastResult = (0,
|
|
2890
|
+
const contrastResult = (0, import_react25.useMemo)(() => {
|
|
2785
2891
|
if (!contrastAgainst) return null;
|
|
2786
2892
|
const fg = (0, import_color.parseColor)(value);
|
|
2787
2893
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -2793,7 +2899,7 @@ var ColorPicker = ({
|
|
|
2793
2899
|
}, [value, contrastAgainst]);
|
|
2794
2900
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
2795
2901
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
2796
|
-
return /* @__PURE__ */ (0,
|
|
2902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2797
2903
|
"div",
|
|
2798
2904
|
{
|
|
2799
2905
|
id: pickerId,
|
|
@@ -2817,7 +2923,7 @@ var ColorPicker = ({
|
|
|
2817
2923
|
pointerEvents: disabled ? "none" : "auto"
|
|
2818
2924
|
},
|
|
2819
2925
|
children: [
|
|
2820
|
-
/* @__PURE__ */ (0,
|
|
2926
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2821
2927
|
"span",
|
|
2822
2928
|
{
|
|
2823
2929
|
role: "status",
|
|
@@ -2836,7 +2942,7 @@ var ColorPicker = ({
|
|
|
2836
2942
|
children: liveDescription
|
|
2837
2943
|
}
|
|
2838
2944
|
),
|
|
2839
|
-
/* @__PURE__ */ (0,
|
|
2945
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2840
2946
|
"div",
|
|
2841
2947
|
{
|
|
2842
2948
|
role: "slider",
|
|
@@ -2858,7 +2964,7 @@ var ColorPicker = ({
|
|
|
2858
2964
|
touchAction: "none",
|
|
2859
2965
|
outline: "none"
|
|
2860
2966
|
},
|
|
2861
|
-
children: /* @__PURE__ */ (0,
|
|
2967
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2862
2968
|
"div",
|
|
2863
2969
|
{
|
|
2864
2970
|
style: {
|
|
@@ -2878,7 +2984,7 @@ var ColorPicker = ({
|
|
|
2878
2984
|
)
|
|
2879
2985
|
}
|
|
2880
2986
|
),
|
|
2881
|
-
/* @__PURE__ */ (0,
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2882
2988
|
"div",
|
|
2883
2989
|
{
|
|
2884
2990
|
role: "slider",
|
|
@@ -2901,7 +3007,7 @@ var ColorPicker = ({
|
|
|
2901
3007
|
touchAction: "none",
|
|
2902
3008
|
outline: "none"
|
|
2903
3009
|
},
|
|
2904
|
-
children: /* @__PURE__ */ (0,
|
|
3010
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2905
3011
|
"div",
|
|
2906
3012
|
{
|
|
2907
3013
|
style: {
|
|
@@ -2921,7 +3027,7 @@ var ColorPicker = ({
|
|
|
2921
3027
|
)
|
|
2922
3028
|
}
|
|
2923
3029
|
),
|
|
2924
|
-
alpha && /* @__PURE__ */ (0,
|
|
3030
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2925
3031
|
"div",
|
|
2926
3032
|
{
|
|
2927
3033
|
role: "slider",
|
|
@@ -2947,7 +3053,7 @@ var ColorPicker = ({
|
|
|
2947
3053
|
overflow: "hidden"
|
|
2948
3054
|
},
|
|
2949
3055
|
children: [
|
|
2950
|
-
/* @__PURE__ */ (0,
|
|
3056
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2951
3057
|
"div",
|
|
2952
3058
|
{
|
|
2953
3059
|
style: {
|
|
@@ -2957,7 +3063,7 @@ var ColorPicker = ({
|
|
|
2957
3063
|
}
|
|
2958
3064
|
}
|
|
2959
3065
|
),
|
|
2960
|
-
/* @__PURE__ */ (0,
|
|
3066
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2961
3067
|
"div",
|
|
2962
3068
|
{
|
|
2963
3069
|
style: {
|
|
@@ -2978,8 +3084,8 @@ var ColorPicker = ({
|
|
|
2978
3084
|
]
|
|
2979
3085
|
}
|
|
2980
3086
|
),
|
|
2981
|
-
/* @__PURE__ */ (0,
|
|
2982
|
-
/* @__PURE__ */ (0,
|
|
3087
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
3088
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2983
3089
|
"div",
|
|
2984
3090
|
{
|
|
2985
3091
|
style: {
|
|
@@ -2993,7 +3099,7 @@ var ColorPicker = ({
|
|
|
2993
3099
|
flexShrink: 0,
|
|
2994
3100
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
2995
3101
|
},
|
|
2996
|
-
children: /* @__PURE__ */ (0,
|
|
3102
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2997
3103
|
"div",
|
|
2998
3104
|
{
|
|
2999
3105
|
style: {
|
|
@@ -3005,7 +3111,7 @@ var ColorPicker = ({
|
|
|
3005
3111
|
)
|
|
3006
3112
|
}
|
|
3007
3113
|
),
|
|
3008
|
-
/* @__PURE__ */ (0,
|
|
3114
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3009
3115
|
"input",
|
|
3010
3116
|
{
|
|
3011
3117
|
type: "text",
|
|
@@ -3035,7 +3141,7 @@ var ColorPicker = ({
|
|
|
3035
3141
|
}
|
|
3036
3142
|
}
|
|
3037
3143
|
),
|
|
3038
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
3144
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3039
3145
|
"button",
|
|
3040
3146
|
{
|
|
3041
3147
|
type: "button",
|
|
@@ -3055,7 +3161,7 @@ var ColorPicker = ({
|
|
|
3055
3161
|
color: "inherit",
|
|
3056
3162
|
cursor: disabled ? "default" : "pointer"
|
|
3057
3163
|
},
|
|
3058
|
-
children: /* @__PURE__ */ (0,
|
|
3164
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3059
3165
|
"svg",
|
|
3060
3166
|
{
|
|
3061
3167
|
width: "14",
|
|
@@ -3067,16 +3173,16 @@ var ColorPicker = ({
|
|
|
3067
3173
|
strokeLinecap: "round",
|
|
3068
3174
|
strokeLinejoin: "round",
|
|
3069
3175
|
children: [
|
|
3070
|
-
/* @__PURE__ */ (0,
|
|
3071
|
-
/* @__PURE__ */ (0,
|
|
3072
|
-
/* @__PURE__ */ (0,
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.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" }),
|
|
3177
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
3178
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "m14 6 4 4" })
|
|
3073
3179
|
]
|
|
3074
3180
|
}
|
|
3075
3181
|
)
|
|
3076
3182
|
}
|
|
3077
3183
|
)
|
|
3078
3184
|
] }),
|
|
3079
|
-
isClipped && /* @__PURE__ */ (0,
|
|
3185
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3080
3186
|
"div",
|
|
3081
3187
|
{
|
|
3082
3188
|
role: "note",
|
|
@@ -3092,10 +3198,10 @@ var ColorPicker = ({
|
|
|
3092
3198
|
borderRadius: "4px",
|
|
3093
3199
|
alignSelf: "flex-start"
|
|
3094
3200
|
},
|
|
3095
|
-
children: /* @__PURE__ */ (0,
|
|
3201
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
3096
3202
|
}
|
|
3097
3203
|
),
|
|
3098
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
3204
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3099
3205
|
"div",
|
|
3100
3206
|
{
|
|
3101
3207
|
style: {
|
|
@@ -3109,15 +3215,15 @@ var ColorPicker = ({
|
|
|
3109
3215
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
3110
3216
|
},
|
|
3111
3217
|
children: [
|
|
3112
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { children: [
|
|
3113
3219
|
"Contrast: ",
|
|
3114
|
-
/* @__PURE__ */ (0,
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("strong", { children: [
|
|
3115
3221
|
contrastResult.ratio.toFixed(2),
|
|
3116
3222
|
":1"
|
|
3117
3223
|
] })
|
|
3118
3224
|
] }),
|
|
3119
|
-
/* @__PURE__ */ (0,
|
|
3120
|
-
/* @__PURE__ */ (0,
|
|
3225
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
3226
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3121
3227
|
"span",
|
|
3122
3228
|
{
|
|
3123
3229
|
style: {
|
|
@@ -3130,7 +3236,7 @@ var ColorPicker = ({
|
|
|
3130
3236
|
]
|
|
3131
3237
|
}
|
|
3132
3238
|
),
|
|
3133
|
-
/* @__PURE__ */ (0,
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3134
3240
|
"span",
|
|
3135
3241
|
{
|
|
3136
3242
|
style: {
|
|
@@ -3147,9 +3253,9 @@ var ColorPicker = ({
|
|
|
3147
3253
|
]
|
|
3148
3254
|
}
|
|
3149
3255
|
),
|
|
3150
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
3151
|
-
/* @__PURE__ */ (0,
|
|
3152
|
-
/* @__PURE__ */ (0,
|
|
3256
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
3257
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
3258
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3153
3259
|
"button",
|
|
3154
3260
|
{
|
|
3155
3261
|
type: "button",
|
|
@@ -3175,9 +3281,9 @@ var ColorPicker = ({
|
|
|
3175
3281
|
`${color}-${idx}`
|
|
3176
3282
|
)) })
|
|
3177
3283
|
] }),
|
|
3178
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
3179
|
-
/* @__PURE__ */ (0,
|
|
3180
|
-
/* @__PURE__ */ (0,
|
|
3284
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
3285
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
3286
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3181
3287
|
"button",
|
|
3182
3288
|
{
|
|
3183
3289
|
type: "button",
|
|
@@ -3208,9 +3314,9 @@ var ColorPicker = ({
|
|
|
3208
3314
|
};
|
|
3209
3315
|
|
|
3210
3316
|
// src/color/DualColorPicker.tsx
|
|
3211
|
-
var
|
|
3317
|
+
var import_react26 = require("react");
|
|
3212
3318
|
var import_color2 = require("@pixerate/editor/color");
|
|
3213
|
-
var
|
|
3319
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3214
3320
|
function DualColorPicker({
|
|
3215
3321
|
value,
|
|
3216
3322
|
onChange,
|
|
@@ -3225,8 +3331,8 @@ function DualColorPicker({
|
|
|
3225
3331
|
disabled = false,
|
|
3226
3332
|
className = ""
|
|
3227
3333
|
}) {
|
|
3228
|
-
const sameId = (0,
|
|
3229
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
3334
|
+
const sameId = (0, import_react26.useId)();
|
|
3335
|
+
const [internalScheme, setInternalScheme] = (0, import_react26.useState)("light");
|
|
3230
3336
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
3231
3337
|
const handleSchemeSelect = (nextScheme) => {
|
|
3232
3338
|
if (onSchemeChange) {
|
|
@@ -3237,7 +3343,7 @@ function DualColorPicker({
|
|
|
3237
3343
|
};
|
|
3238
3344
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
3239
3345
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
3240
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
3346
|
+
const [sameInBoth, setSameInBoth] = (0, import_react26.useState)(isSame);
|
|
3241
3347
|
const handleSameToggle = (e) => {
|
|
3242
3348
|
const nextSame = e.target.checked;
|
|
3243
3349
|
setSameInBoth(nextSame);
|
|
@@ -3269,7 +3375,7 @@ function DualColorPicker({
|
|
|
3269
3375
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
3270
3376
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
3271
3377
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
3272
|
-
return /* @__PURE__ */ (0,
|
|
3378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3273
3379
|
"div",
|
|
3274
3380
|
{
|
|
3275
3381
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -3288,7 +3394,7 @@ function DualColorPicker({
|
|
|
3288
3394
|
boxSizing: "border-box"
|
|
3289
3395
|
},
|
|
3290
3396
|
children: [
|
|
3291
|
-
/* @__PURE__ */ (0,
|
|
3397
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3292
3398
|
"div",
|
|
3293
3399
|
{
|
|
3294
3400
|
role: "tablist",
|
|
@@ -3301,7 +3407,7 @@ function DualColorPicker({
|
|
|
3301
3407
|
gap: "2px"
|
|
3302
3408
|
},
|
|
3303
3409
|
children: [
|
|
3304
|
-
/* @__PURE__ */ (0,
|
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3305
3411
|
"button",
|
|
3306
3412
|
{
|
|
3307
3413
|
type: "button",
|
|
@@ -3324,7 +3430,7 @@ function DualColorPicker({
|
|
|
3324
3430
|
children: "Light"
|
|
3325
3431
|
}
|
|
3326
3432
|
),
|
|
3327
|
-
/* @__PURE__ */ (0,
|
|
3433
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3328
3434
|
"button",
|
|
3329
3435
|
{
|
|
3330
3436
|
type: "button",
|
|
@@ -3350,8 +3456,8 @@ function DualColorPicker({
|
|
|
3350
3456
|
]
|
|
3351
3457
|
}
|
|
3352
3458
|
),
|
|
3353
|
-
/* @__PURE__ */ (0,
|
|
3354
|
-
/* @__PURE__ */ (0,
|
|
3459
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3355
3461
|
"button",
|
|
3356
3462
|
{
|
|
3357
3463
|
type: "button",
|
|
@@ -3373,7 +3479,7 @@ function DualColorPicker({
|
|
|
3373
3479
|
outline: "none"
|
|
3374
3480
|
},
|
|
3375
3481
|
children: [
|
|
3376
|
-
/* @__PURE__ */ (0,
|
|
3482
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3377
3483
|
"span",
|
|
3378
3484
|
{
|
|
3379
3485
|
style: {
|
|
@@ -3385,11 +3491,11 @@ function DualColorPicker({
|
|
|
3385
3491
|
}
|
|
3386
3492
|
}
|
|
3387
3493
|
),
|
|
3388
|
-
/* @__PURE__ */ (0,
|
|
3494
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
3389
3495
|
]
|
|
3390
3496
|
}
|
|
3391
3497
|
),
|
|
3392
|
-
/* @__PURE__ */ (0,
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3393
3499
|
"button",
|
|
3394
3500
|
{
|
|
3395
3501
|
type: "button",
|
|
@@ -3411,7 +3517,7 @@ function DualColorPicker({
|
|
|
3411
3517
|
outline: "none"
|
|
3412
3518
|
},
|
|
3413
3519
|
children: [
|
|
3414
|
-
/* @__PURE__ */ (0,
|
|
3520
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3415
3521
|
"span",
|
|
3416
3522
|
{
|
|
3417
3523
|
style: {
|
|
@@ -3423,12 +3529,12 @@ function DualColorPicker({
|
|
|
3423
3529
|
}
|
|
3424
3530
|
}
|
|
3425
3531
|
),
|
|
3426
|
-
/* @__PURE__ */ (0,
|
|
3532
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
3427
3533
|
]
|
|
3428
3534
|
}
|
|
3429
3535
|
)
|
|
3430
3536
|
] }),
|
|
3431
|
-
/* @__PURE__ */ (0,
|
|
3537
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3432
3538
|
"div",
|
|
3433
3539
|
{
|
|
3434
3540
|
style: {
|
|
@@ -3439,7 +3545,7 @@ function DualColorPicker({
|
|
|
3439
3545
|
padding: "2px 0"
|
|
3440
3546
|
},
|
|
3441
3547
|
children: [
|
|
3442
|
-
/* @__PURE__ */ (0,
|
|
3548
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3443
3549
|
"label",
|
|
3444
3550
|
{
|
|
3445
3551
|
htmlFor: sameId,
|
|
@@ -3453,7 +3559,7 @@ function DualColorPicker({
|
|
|
3453
3559
|
color: "#c4cad4"
|
|
3454
3560
|
},
|
|
3455
3561
|
children: [
|
|
3456
|
-
/* @__PURE__ */ (0,
|
|
3562
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3457
3563
|
"input",
|
|
3458
3564
|
{
|
|
3459
3565
|
id: sameId,
|
|
@@ -3464,11 +3570,11 @@ function DualColorPicker({
|
|
|
3464
3570
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
3465
3571
|
}
|
|
3466
3572
|
),
|
|
3467
|
-
/* @__PURE__ */ (0,
|
|
3573
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Same in both" })
|
|
3468
3574
|
]
|
|
3469
3575
|
}
|
|
3470
3576
|
),
|
|
3471
|
-
/* @__PURE__ */ (0,
|
|
3577
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3472
3578
|
"button",
|
|
3473
3579
|
{
|
|
3474
3580
|
type: "button",
|
|
@@ -3490,7 +3596,7 @@ function DualColorPicker({
|
|
|
3490
3596
|
]
|
|
3491
3597
|
}
|
|
3492
3598
|
),
|
|
3493
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
3599
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3494
3600
|
"div",
|
|
3495
3601
|
{
|
|
3496
3602
|
"data-testid": "dual-contrast-summary",
|
|
@@ -3504,20 +3610,20 @@ function DualColorPicker({
|
|
|
3504
3610
|
color: "#8c95a6"
|
|
3505
3611
|
},
|
|
3506
3612
|
children: [
|
|
3507
|
-
/* @__PURE__ */ (0,
|
|
3613
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
3508
3614
|
"Light:",
|
|
3509
3615
|
" ",
|
|
3510
|
-
/* @__PURE__ */ (0,
|
|
3616
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
3511
3617
|
dualContrast.light.ratio.toFixed(2),
|
|
3512
3618
|
" (",
|
|
3513
3619
|
dualContrast.light.level,
|
|
3514
3620
|
")"
|
|
3515
3621
|
] })
|
|
3516
3622
|
] }),
|
|
3517
|
-
/* @__PURE__ */ (0,
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
3518
3624
|
"Dark:",
|
|
3519
3625
|
" ",
|
|
3520
|
-
/* @__PURE__ */ (0,
|
|
3626
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
3521
3627
|
dualContrast.dark.ratio.toFixed(2),
|
|
3522
3628
|
" (",
|
|
3523
3629
|
dualContrast.dark.level,
|
|
@@ -3527,7 +3633,7 @@ function DualColorPicker({
|
|
|
3527
3633
|
]
|
|
3528
3634
|
}
|
|
3529
3635
|
),
|
|
3530
|
-
/* @__PURE__ */ (0,
|
|
3636
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3531
3637
|
ColorPicker,
|
|
3532
3638
|
{
|
|
3533
3639
|
value: activeColor,
|
|
@@ -3546,7 +3652,7 @@ function DualColorPicker({
|
|
|
3546
3652
|
}
|
|
3547
3653
|
|
|
3548
3654
|
// src/color/useColorScheme.ts
|
|
3549
|
-
var
|
|
3655
|
+
var import_react27 = require("react");
|
|
3550
3656
|
var import_color3 = require("@pixerate/editor/color");
|
|
3551
3657
|
function getSnapshot(attribute) {
|
|
3552
3658
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -3571,7 +3677,7 @@ function getServerSnapshot() {
|
|
|
3571
3677
|
function useColorScheme(options) {
|
|
3572
3678
|
const override = options?.override;
|
|
3573
3679
|
const attribute = options?.attribute;
|
|
3574
|
-
const subscribe = (0,
|
|
3680
|
+
const subscribe = (0, import_react27.useMemo)(() => {
|
|
3575
3681
|
return (callback) => {
|
|
3576
3682
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
3577
3683
|
return () => {
|
|
@@ -3597,7 +3703,7 @@ function useColorScheme(options) {
|
|
|
3597
3703
|
};
|
|
3598
3704
|
};
|
|
3599
3705
|
}, [attribute]);
|
|
3600
|
-
const detected = (0,
|
|
3706
|
+
const detected = (0, import_react27.useSyncExternalStore)(
|
|
3601
3707
|
subscribe,
|
|
3602
3708
|
() => getSnapshot(attribute),
|
|
3603
3709
|
getServerSnapshot
|
|
@@ -3614,11 +3720,11 @@ function useResolvedColor(value, scheme) {
|
|
|
3614
3720
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
3615
3721
|
|
|
3616
3722
|
// src/parameters/controls.tsx
|
|
3617
|
-
var
|
|
3618
|
-
var
|
|
3619
|
-
var ParameterComponentsContext = (0,
|
|
3723
|
+
var import_react28 = require("react");
|
|
3724
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3725
|
+
var ParameterComponentsContext = (0, import_react28.createContext)({});
|
|
3620
3726
|
function useParameterComponents() {
|
|
3621
|
-
return (0,
|
|
3727
|
+
return (0, import_react28.useContext)(ParameterComponentsContext);
|
|
3622
3728
|
}
|
|
3623
3729
|
function resolveParameterComponents(explicit, context) {
|
|
3624
3730
|
return {
|
|
@@ -3630,7 +3736,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
3630
3736
|
}
|
|
3631
3737
|
|
|
3632
3738
|
// src/parameters/fields.tsx
|
|
3633
|
-
var
|
|
3739
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3634
3740
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
3635
3741
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
3636
3742
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -3639,9 +3745,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
3639
3745
|
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";
|
|
3640
3746
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
3641
3747
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
3642
|
-
const inputRef = (0,
|
|
3643
|
-
const lastCommitted = (0,
|
|
3644
|
-
(0,
|
|
3748
|
+
const inputRef = (0, import_react29.useRef)(null);
|
|
3749
|
+
const lastCommitted = (0, import_react29.useRef)(null);
|
|
3750
|
+
(0, import_react29.useLayoutEffect)(() => {
|
|
3645
3751
|
lastCommitted.current = null;
|
|
3646
3752
|
const el = inputRef.current;
|
|
3647
3753
|
if (el && el.value !== value) el.value = value;
|
|
@@ -3652,9 +3758,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3652
3758
|
onCommit(text, el);
|
|
3653
3759
|
lastCommitted.current = el.value === text ? text : null;
|
|
3654
3760
|
};
|
|
3655
|
-
const commitRef = (0,
|
|
3761
|
+
const commitRef = (0, import_react29.useRef)(commit);
|
|
3656
3762
|
commitRef.current = commit;
|
|
3657
|
-
(0,
|
|
3763
|
+
(0, import_react29.useEffect)(() => {
|
|
3658
3764
|
const el = inputRef.current;
|
|
3659
3765
|
if (!el) return;
|
|
3660
3766
|
const change = () => commitRef.current(el);
|
|
@@ -3685,7 +3791,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3685
3791
|
if (typeof forwarded === "function") forwarded(el);
|
|
3686
3792
|
else if (forwarded) forwarded.current = el;
|
|
3687
3793
|
};
|
|
3688
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
3794
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
3689
3795
|
}
|
|
3690
3796
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
3691
3797
|
function ParameterNumberInput(props) {
|
|
@@ -3719,9 +3825,9 @@ function ParameterNumberInput(props) {
|
|
|
3719
3825
|
onCommit: handleCommit,
|
|
3720
3826
|
onKeyDown: handleKeyDown
|
|
3721
3827
|
};
|
|
3722
|
-
return /* @__PURE__ */ (0,
|
|
3723
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
3724
|
-
field.unit && /* @__PURE__ */ (0,
|
|
3828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
3829
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
3830
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
3725
3831
|
] });
|
|
3726
3832
|
}
|
|
3727
3833
|
function ParameterSlider(props) {
|
|
@@ -3729,7 +3835,7 @@ function ParameterSlider(props) {
|
|
|
3729
3835
|
const ctx = useParameterComponents();
|
|
3730
3836
|
const resolved = resolveParameterComponents(components, ctx);
|
|
3731
3837
|
const CustomSlider = resolved.slider;
|
|
3732
|
-
const dragging = (0,
|
|
3838
|
+
const dragging = (0, import_react29.useRef)(false);
|
|
3733
3839
|
const start = () => {
|
|
3734
3840
|
if (dragging.current) return;
|
|
3735
3841
|
dragging.current = true;
|
|
@@ -3740,7 +3846,7 @@ function ParameterSlider(props) {
|
|
|
3740
3846
|
dragging.current = false;
|
|
3741
3847
|
onGestureEnd?.();
|
|
3742
3848
|
};
|
|
3743
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
3849
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterNumberInput, { ...props });
|
|
3744
3850
|
const step = (0, import_parameters.parameterStep)(field);
|
|
3745
3851
|
const sliderProps = {
|
|
3746
3852
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -3754,8 +3860,8 @@ function ParameterSlider(props) {
|
|
|
3754
3860
|
className: rangeClass,
|
|
3755
3861
|
style: parameterRangeStyle
|
|
3756
3862
|
};
|
|
3757
|
-
return /* @__PURE__ */ (0,
|
|
3758
|
-
CustomSlider ? /* @__PURE__ */ (0,
|
|
3863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3864
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3759
3865
|
CustomSlider,
|
|
3760
3866
|
{
|
|
3761
3867
|
...sliderProps,
|
|
@@ -3765,7 +3871,7 @@ function ParameterSlider(props) {
|
|
|
3765
3871
|
onGestureStart: start,
|
|
3766
3872
|
onGestureEnd: end
|
|
3767
3873
|
}
|
|
3768
|
-
) : /* @__PURE__ */ (0,
|
|
3874
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3769
3875
|
"input",
|
|
3770
3876
|
{
|
|
3771
3877
|
type: "range",
|
|
@@ -3777,11 +3883,11 @@ function ParameterSlider(props) {
|
|
|
3777
3883
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
3778
3884
|
}
|
|
3779
3885
|
),
|
|
3780
|
-
/* @__PURE__ */ (0,
|
|
3886
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
3781
3887
|
] });
|
|
3782
3888
|
}
|
|
3783
3889
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
3784
|
-
return /* @__PURE__ */ (0,
|
|
3890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3785
3891
|
"button",
|
|
3786
3892
|
{
|
|
3787
3893
|
type: "button",
|
|
@@ -3792,7 +3898,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
3792
3898
|
disabled: disabled || field.readOnly,
|
|
3793
3899
|
onClick: () => onChange(!value),
|
|
3794
3900
|
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"}`,
|
|
3795
|
-
children: /* @__PURE__ */ (0,
|
|
3901
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3796
3902
|
"span",
|
|
3797
3903
|
{
|
|
3798
3904
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -3809,7 +3915,7 @@ function ParameterSelect(props) {
|
|
|
3809
3915
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
3810
3916
|
const off = disabled || field.readOnly;
|
|
3811
3917
|
if (field.control === "segmented") {
|
|
3812
|
-
return /* @__PURE__ */ (0,
|
|
3918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)(
|
|
3813
3919
|
"button",
|
|
3814
3920
|
{
|
|
3815
3921
|
type: "button",
|
|
@@ -3826,7 +3932,7 @@ function ParameterSelect(props) {
|
|
|
3826
3932
|
}
|
|
3827
3933
|
if (CustomSelect) {
|
|
3828
3934
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
3829
|
-
return /* @__PURE__ */ (0,
|
|
3935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3830
3936
|
CustomSelect,
|
|
3831
3937
|
{
|
|
3832
3938
|
id,
|
|
@@ -3842,7 +3948,7 @@ function ParameterSelect(props) {
|
|
|
3842
3948
|
);
|
|
3843
3949
|
}
|
|
3844
3950
|
const index = options.findIndex((o) => o.value === value);
|
|
3845
|
-
return /* @__PURE__ */ (0,
|
|
3951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3846
3952
|
"select",
|
|
3847
3953
|
{
|
|
3848
3954
|
id,
|
|
@@ -3855,23 +3961,23 @@ function ParameterSelect(props) {
|
|
|
3855
3961
|
},
|
|
3856
3962
|
className: parameterInputClass,
|
|
3857
3963
|
style: parameterSelectStyle,
|
|
3858
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
3964
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
3859
3965
|
}
|
|
3860
3966
|
);
|
|
3861
3967
|
}
|
|
3862
3968
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
3863
3969
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
3864
|
-
const [open, setOpen] = (0,
|
|
3865
|
-
const containerRef = (0,
|
|
3866
|
-
const buttonRef = (0,
|
|
3867
|
-
const popoverRef = (0,
|
|
3970
|
+
const [open, setOpen] = (0, import_react29.useState)(false);
|
|
3971
|
+
const containerRef = (0, import_react29.useRef)(null);
|
|
3972
|
+
const buttonRef = (0, import_react29.useRef)(null);
|
|
3973
|
+
const popoverRef = (0, import_react29.useRef)(null);
|
|
3868
3974
|
const alpha = !!field.alpha;
|
|
3869
3975
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
3870
3976
|
const rgb = hex.slice(0, 7);
|
|
3871
3977
|
const shown = alpha ? hex : rgb;
|
|
3872
3978
|
const off = disabled || field.readOnly;
|
|
3873
3979
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3874
|
-
(0,
|
|
3980
|
+
(0, import_react29.useEffect)(() => {
|
|
3875
3981
|
if (!open) return;
|
|
3876
3982
|
const onPointerDown = (e) => {
|
|
3877
3983
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3893,7 +3999,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3893
3999
|
};
|
|
3894
4000
|
}, [open]);
|
|
3895
4001
|
if (CustomColor) {
|
|
3896
|
-
return /* @__PURE__ */ (0,
|
|
4002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3897
4003
|
CustomColor,
|
|
3898
4004
|
{
|
|
3899
4005
|
id,
|
|
@@ -3908,9 +4014,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3908
4014
|
}
|
|
3909
4015
|
);
|
|
3910
4016
|
}
|
|
3911
|
-
return /* @__PURE__ */ (0,
|
|
3912
|
-
/* @__PURE__ */ (0,
|
|
3913
|
-
/* @__PURE__ */ (0,
|
|
4017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
4018
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4019
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3914
4020
|
"button",
|
|
3915
4021
|
{
|
|
3916
4022
|
ref: buttonRef,
|
|
@@ -3921,10 +4027,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3921
4027
|
disabled: off,
|
|
3922
4028
|
onClick: () => setOpen((prev) => !prev),
|
|
3923
4029
|
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",
|
|
3924
|
-
children: /* @__PURE__ */ (0,
|
|
4030
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3925
4031
|
}
|
|
3926
4032
|
),
|
|
3927
|
-
/* @__PURE__ */ (0,
|
|
4033
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3928
4034
|
ParameterCommitInput,
|
|
3929
4035
|
{
|
|
3930
4036
|
id,
|
|
@@ -3940,7 +4046,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3940
4046
|
}
|
|
3941
4047
|
)
|
|
3942
4048
|
] }),
|
|
3943
|
-
open && /* @__PURE__ */ (0,
|
|
4049
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3944
4050
|
"div",
|
|
3945
4051
|
{
|
|
3946
4052
|
ref: popoverRef,
|
|
@@ -3954,7 +4060,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3954
4060
|
},
|
|
3955
4061
|
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",
|
|
3956
4062
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3957
|
-
children: /* @__PURE__ */ (0,
|
|
4063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3958
4064
|
ColorPicker,
|
|
3959
4065
|
{
|
|
3960
4066
|
value: shown,
|
|
@@ -3972,11 +4078,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3972
4078
|
}
|
|
3973
4079
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
3974
4080
|
const size = (0, import_parameters.vectorSize)(field);
|
|
3975
|
-
return /* @__PURE__ */ (0,
|
|
4081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
3976
4082
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
3977
|
-
return /* @__PURE__ */ (0,
|
|
3978
|
-
/* @__PURE__ */ (0,
|
|
3979
|
-
/* @__PURE__ */ (0,
|
|
4083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
4084
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
4085
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3980
4086
|
ParameterNumberInput,
|
|
3981
4087
|
{
|
|
3982
4088
|
field: component,
|
|
@@ -3994,11 +4100,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
3994
4100
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
3995
4101
|
const off = disabled || field.readOnly;
|
|
3996
4102
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3997
|
-
return /* @__PURE__ */ (0,
|
|
3998
|
-
/* @__PURE__ */ (0,
|
|
3999
|
-
/* @__PURE__ */ (0,
|
|
4000
|
-
/* @__PURE__ */ (0,
|
|
4001
|
-
/* @__PURE__ */ (0,
|
|
4103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-1.5", children: [
|
|
4104
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4105
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
4106
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
4107
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4002
4108
|
ParameterCommitInput,
|
|
4003
4109
|
{
|
|
4004
4110
|
id,
|
|
@@ -4009,15 +4115,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4009
4115
|
onCommit: (text) => onChange(text.trim())
|
|
4010
4116
|
}
|
|
4011
4117
|
),
|
|
4012
|
-
/* @__PURE__ */ (0,
|
|
4013
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
4118
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex gap-1", children: [
|
|
4119
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4014
4120
|
"label",
|
|
4015
4121
|
{
|
|
4016
4122
|
style: parameterButtonStyle,
|
|
4017
4123
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
4018
4124
|
children: [
|
|
4019
4125
|
"Choose file\u2026",
|
|
4020
|
-
/* @__PURE__ */ (0,
|
|
4126
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4021
4127
|
"input",
|
|
4022
4128
|
{
|
|
4023
4129
|
type: "file",
|
|
@@ -4035,7 +4141,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4035
4141
|
]
|
|
4036
4142
|
}
|
|
4037
4143
|
),
|
|
4038
|
-
value && /* @__PURE__ */ (0,
|
|
4144
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4039
4145
|
"button",
|
|
4040
4146
|
{
|
|
4041
4147
|
type: "button",
|
|
@@ -4050,7 +4156,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4050
4156
|
] })
|
|
4051
4157
|
] })
|
|
4052
4158
|
] }),
|
|
4053
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
4159
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4054
4160
|
"button",
|
|
4055
4161
|
{
|
|
4056
4162
|
type: "button",
|
|
@@ -4060,14 +4166,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4060
4166
|
disabled: off,
|
|
4061
4167
|
onClick: () => onChange(o.url),
|
|
4062
4168
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
4063
|
-
children: /* @__PURE__ */ (0,
|
|
4169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
4064
4170
|
},
|
|
4065
4171
|
o.url
|
|
4066
4172
|
)) })
|
|
4067
4173
|
] });
|
|
4068
4174
|
}
|
|
4069
4175
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
4070
|
-
return /* @__PURE__ */ (0,
|
|
4176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4071
4177
|
ParameterCommitInput,
|
|
4072
4178
|
{
|
|
4073
4179
|
id,
|
|
@@ -4086,24 +4192,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
4086
4192
|
switch (field.type) {
|
|
4087
4193
|
case "number":
|
|
4088
4194
|
case "int":
|
|
4089
|
-
return /* @__PURE__ */ (0,
|
|
4195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
4090
4196
|
case "boolean":
|
|
4091
|
-
return /* @__PURE__ */ (0,
|
|
4197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
4092
4198
|
case "choice":
|
|
4093
|
-
return /* @__PURE__ */ (0,
|
|
4199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
4094
4200
|
case "color":
|
|
4095
|
-
return /* @__PURE__ */ (0,
|
|
4201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
4096
4202
|
case "vector":
|
|
4097
|
-
return /* @__PURE__ */ (0,
|
|
4203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
4098
4204
|
case "image":
|
|
4099
|
-
return /* @__PURE__ */ (0,
|
|
4205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
4100
4206
|
case "text":
|
|
4101
|
-
return /* @__PURE__ */ (0,
|
|
4207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
4102
4208
|
}
|
|
4103
4209
|
}
|
|
4104
4210
|
|
|
4105
4211
|
// src/effects/EffectParameters.tsx
|
|
4106
|
-
var
|
|
4212
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4107
4213
|
function EffectParameters({
|
|
4108
4214
|
description,
|
|
4109
4215
|
values,
|
|
@@ -4118,10 +4224,10 @@ function EffectParameters({
|
|
|
4118
4224
|
className = "",
|
|
4119
4225
|
components
|
|
4120
4226
|
}) {
|
|
4121
|
-
const fields = (0,
|
|
4122
|
-
const idBase = (0,
|
|
4123
|
-
const gesture =
|
|
4124
|
-
const count =
|
|
4227
|
+
const fields = (0, import_react30.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
4228
|
+
const idBase = (0, import_react30.useId)();
|
|
4229
|
+
const gesture = import_react30.default.useRef(null);
|
|
4230
|
+
const count = import_react30.default.useRef(0);
|
|
4125
4231
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
4126
4232
|
const handlePresetSelect = (name) => {
|
|
4127
4233
|
if (!name) return;
|
|
@@ -4132,8 +4238,8 @@ function EffectParameters({
|
|
|
4132
4238
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
4133
4239
|
}
|
|
4134
4240
|
};
|
|
4135
|
-
return /* @__PURE__ */ (0,
|
|
4136
|
-
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0,
|
|
4241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
4242
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4137
4243
|
CustomPresetSelect,
|
|
4138
4244
|
{
|
|
4139
4245
|
"aria-label": `${description.name} presets`,
|
|
@@ -4148,7 +4254,7 @@ function EffectParameters({
|
|
|
4148
4254
|
],
|
|
4149
4255
|
onChange: (name) => handlePresetSelect(String(name))
|
|
4150
4256
|
}
|
|
4151
|
-
) : /* @__PURE__ */ (0,
|
|
4257
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
4152
4258
|
"select",
|
|
4153
4259
|
{
|
|
4154
4260
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -4158,8 +4264,8 @@ function EffectParameters({
|
|
|
4158
4264
|
disabled,
|
|
4159
4265
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
4160
4266
|
children: [
|
|
4161
|
-
/* @__PURE__ */ (0,
|
|
4162
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
4267
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
4268
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
4163
4269
|
]
|
|
4164
4270
|
}
|
|
4165
4271
|
)),
|
|
@@ -4169,14 +4275,14 @@ function EffectParameters({
|
|
|
4169
4275
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
4170
4276
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
4171
4277
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
4172
|
-
return /* @__PURE__ */ (0,
|
|
4173
|
-
/* @__PURE__ */ (0,
|
|
4174
|
-
/* @__PURE__ */ (0,
|
|
4175
|
-
keyed && /* @__PURE__ */ (0,
|
|
4278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
4279
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
4280
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
4281
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
4176
4282
|
renderControlAddon?.(field.id),
|
|
4177
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
4283
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime30.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" })
|
|
4178
4284
|
] }),
|
|
4179
|
-
/* @__PURE__ */ (0,
|
|
4285
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4180
4286
|
ParameterFieldControl,
|
|
4181
4287
|
{
|
|
4182
4288
|
field,
|
|
@@ -4191,15 +4297,15 @@ function EffectParameters({
|
|
|
4191
4297
|
)
|
|
4192
4298
|
] }, field.id);
|
|
4193
4299
|
}),
|
|
4194
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
4300
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
4195
4301
|
] });
|
|
4196
4302
|
}
|
|
4197
4303
|
|
|
4198
4304
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
4199
|
-
var
|
|
4305
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
4200
4306
|
function usePaintEffectsProvider(controller) {
|
|
4201
|
-
const [provider, setProvider] = (0,
|
|
4202
|
-
(0,
|
|
4307
|
+
const [provider, setProvider] = (0, import_react31.useState)(controller.effectsProvider);
|
|
4308
|
+
(0, import_react31.useEffect)(() => {
|
|
4203
4309
|
setProvider(controller.effectsProvider);
|
|
4204
4310
|
return controller.effects.subscribe(setProvider);
|
|
4205
4311
|
}, [controller]);
|
|
@@ -4207,27 +4313,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
4207
4313
|
}
|
|
4208
4314
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
4209
4315
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
4210
|
-
(0,
|
|
4316
|
+
(0, import_react31.useEffect)(() => {
|
|
4211
4317
|
if (!registry) return;
|
|
4212
|
-
return registry.register((0,
|
|
4318
|
+
return registry.register((0, import_paint_editor16.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
4213
4319
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
4214
4320
|
}
|
|
4215
4321
|
function Controls({ provider, effect, name, values, apply }) {
|
|
4216
4322
|
const { description, error } = useEffectDescription(provider, effect);
|
|
4217
|
-
const drags = (0,
|
|
4218
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
4323
|
+
const drags = (0, import_react31.useRef)(/* @__PURE__ */ new Set());
|
|
4324
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
|
|
4219
4325
|
'No effects provider: "',
|
|
4220
4326
|
name ?? effect,
|
|
4221
4327
|
'" is kept as it was drawn.'
|
|
4222
4328
|
] });
|
|
4223
|
-
if (error) return /* @__PURE__ */ (0,
|
|
4224
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
4329
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
|
|
4330
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
4225
4331
|
const commit = (gesture) => {
|
|
4226
4332
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
4227
4333
|
drags.current.add(gesture);
|
|
4228
4334
|
return true;
|
|
4229
4335
|
};
|
|
4230
|
-
return /* @__PURE__ */ (0,
|
|
4336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4231
4337
|
EffectParameters,
|
|
4232
4338
|
{
|
|
4233
4339
|
description,
|
|
@@ -4249,8 +4355,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4249
4355
|
const state = usePaintEditorState(controller);
|
|
4250
4356
|
const provider = usePaintEffectsProvider(controller);
|
|
4251
4357
|
const [error, attempt] = useAttempt();
|
|
4252
|
-
const [browse, setBrowse] = (0,
|
|
4253
|
-
const [busy, setBusy] = (0,
|
|
4358
|
+
const [browse, setBrowse] = (0, import_react31.useState)(null);
|
|
4359
|
+
const [busy, setBusy] = (0, import_react31.useState)(false);
|
|
4254
4360
|
const paper = controller.getPaperEffect();
|
|
4255
4361
|
const activeId = state.document.activeLayerId;
|
|
4256
4362
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -4264,7 +4370,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4264
4370
|
if (!effectPaint) return;
|
|
4265
4371
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
4266
4372
|
};
|
|
4267
|
-
const thumbnail = (0,
|
|
4373
|
+
const thumbnail = (0, import_react31.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
4268
4374
|
const run = (work) => attempt(() => {
|
|
4269
4375
|
setBusy(true);
|
|
4270
4376
|
return work().finally(() => setBusy(false));
|
|
@@ -4280,28 +4386,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4280
4386
|
};
|
|
4281
4387
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
4282
4388
|
const pixel = active?.type === "pixel";
|
|
4283
|
-
return /* @__PURE__ */ (0,
|
|
4284
|
-
/* @__PURE__ */ (0,
|
|
4285
|
-
/* @__PURE__ */ (0,
|
|
4286
|
-
/* @__PURE__ */ (0,
|
|
4287
|
-
/* @__PURE__ */ (0,
|
|
4288
|
-
/* @__PURE__ */ (0,
|
|
4289
|
-
/* @__PURE__ */ (0,
|
|
4290
|
-
/* @__PURE__ */ (0,
|
|
4389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
4390
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
4391
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
4392
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
4393
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
4394
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
4395
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.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" }),
|
|
4396
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.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" })
|
|
4291
4397
|
] }),
|
|
4292
|
-
!provider && /* @__PURE__ */ (0,
|
|
4293
|
-
browse && /* @__PURE__ */ (0,
|
|
4294
|
-
paper && /* @__PURE__ */ (0,
|
|
4295
|
-
/* @__PURE__ */ (0,
|
|
4296
|
-
/* @__PURE__ */ (0,
|
|
4398
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
4399
|
+
browse && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
4400
|
+
paper && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
4401
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4402
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
4297
4403
|
"Paper: ",
|
|
4298
4404
|
paper.name ?? paper.effect
|
|
4299
4405
|
] }),
|
|
4300
|
-
/* @__PURE__ */ (0,
|
|
4406
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
4301
4407
|
] }),
|
|
4302
|
-
/* @__PURE__ */ (0,
|
|
4303
|
-
/* @__PURE__ */ (0,
|
|
4304
|
-
/* @__PURE__ */ (0,
|
|
4408
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
4409
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
4410
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4305
4411
|
"input",
|
|
4306
4412
|
{
|
|
4307
4413
|
type: "range",
|
|
@@ -4323,43 +4429,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4323
4429
|
`o${paper.opacity}`
|
|
4324
4430
|
)
|
|
4325
4431
|
] }),
|
|
4326
|
-
/* @__PURE__ */ (0,
|
|
4327
|
-
/* @__PURE__ */ (0,
|
|
4328
|
-
/* @__PURE__ */ (0,
|
|
4432
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
4433
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
4434
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.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) => {
|
|
4329
4435
|
const blend = e.currentTarget.value;
|
|
4330
4436
|
run(() => controller.updatePaperEffect({ blend }));
|
|
4331
|
-
}, children:
|
|
4437
|
+
}, children: import_paint_editor16.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: b, children: b }, b)) })
|
|
4332
4438
|
] }),
|
|
4333
|
-
/* @__PURE__ */ (0,
|
|
4439
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
4334
4440
|
] }),
|
|
4335
|
-
effectPaint && /* @__PURE__ */ (0,
|
|
4336
|
-
/* @__PURE__ */ (0,
|
|
4337
|
-
thumbnail ? /* @__PURE__ */ (0,
|
|
4338
|
-
/* @__PURE__ */ (0,
|
|
4441
|
+
effectPaint && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
4442
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4443
|
+
thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
4444
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
4339
4445
|
"Paint: ",
|
|
4340
4446
|
effectPaint.effect,
|
|
4341
4447
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
4342
4448
|
] }),
|
|
4343
|
-
/* @__PURE__ */ (0,
|
|
4449
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
4344
4450
|
] }),
|
|
4345
|
-
/* @__PURE__ */ (0,
|
|
4346
|
-
/* @__PURE__ */ (0,
|
|
4347
|
-
/* @__PURE__ */ (0,
|
|
4451
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
4452
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
4453
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
4348
4454
|
"Along the stroke"
|
|
4349
4455
|
] }),
|
|
4350
|
-
hasPathControl && /* @__PURE__ */ (0,
|
|
4351
|
-
/* @__PURE__ */ (0,
|
|
4456
|
+
hasPathControl && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
|
|
4457
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
|
|
4352
4458
|
"Along the stroke (native)"
|
|
4353
4459
|
] }),
|
|
4354
|
-
/* @__PURE__ */ (0,
|
|
4355
|
-
/* @__PURE__ */ (0,
|
|
4460
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
4461
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
4356
4462
|
"Live"
|
|
4357
4463
|
] })
|
|
4358
4464
|
] }),
|
|
4359
|
-
effectPaint.map?.by === "stroke" && /* @__PURE__ */ (0,
|
|
4360
|
-
/* @__PURE__ */ (0,
|
|
4361
|
-
/* @__PURE__ */ (0,
|
|
4362
|
-
/* @__PURE__ */ (0,
|
|
4465
|
+
effectPaint.map?.by === "stroke" && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
4466
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
4467
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "text-slate-400", children: "Length" }),
|
|
4468
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4363
4469
|
"input",
|
|
4364
4470
|
{
|
|
4365
4471
|
type: "number",
|
|
@@ -4373,56 +4479,56 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4373
4479
|
effectPaint.map.length
|
|
4374
4480
|
)
|
|
4375
4481
|
] }),
|
|
4376
|
-
/* @__PURE__ */ (0,
|
|
4377
|
-
/* @__PURE__ */ (0,
|
|
4378
|
-
/* @__PURE__ */ (0,
|
|
4379
|
-
/* @__PURE__ */ (0,
|
|
4482
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
|
|
4483
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: "repeat", children: "Repeat" }),
|
|
4484
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: "mirror", children: "Mirror" }),
|
|
4485
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: "clamp", children: "Clamp" })
|
|
4380
4486
|
] })
|
|
4381
4487
|
] }),
|
|
4382
|
-
/* @__PURE__ */ (0,
|
|
4488
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
4383
4489
|
] }),
|
|
4384
|
-
animation && /* @__PURE__ */ (0,
|
|
4385
|
-
/* @__PURE__ */ (0,
|
|
4490
|
+
animation && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
4491
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
4386
4492
|
"Live paint: ",
|
|
4387
4493
|
animation.strokes,
|
|
4388
4494
|
" ",
|
|
4389
4495
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
4390
4496
|
] }),
|
|
4391
|
-
/* @__PURE__ */ (0,
|
|
4392
|
-
/* @__PURE__ */ (0,
|
|
4393
|
-
/* @__PURE__ */ (0,
|
|
4394
|
-
/* @__PURE__ */ (0,
|
|
4497
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
4498
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
4499
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "text-slate-400", children: "fps" }),
|
|
4500
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
|
|
4395
4501
|
] })
|
|
4396
4502
|
] }),
|
|
4397
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
4398
|
-
/* @__PURE__ */ (0,
|
|
4399
|
-
/* @__PURE__ */ (0,
|
|
4503
|
+
layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
4504
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4505
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
4400
4506
|
"Layer: ",
|
|
4401
4507
|
layerEffect.name ?? layerEffect.effect
|
|
4402
4508
|
] }),
|
|
4403
|
-
/* @__PURE__ */ (0,
|
|
4509
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
4404
4510
|
] }),
|
|
4405
|
-
/* @__PURE__ */ (0,
|
|
4511
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
4406
4512
|
] }),
|
|
4407
|
-
/* @__PURE__ */ (0,
|
|
4513
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ErrorLine, { error })
|
|
4408
4514
|
] });
|
|
4409
4515
|
};
|
|
4410
4516
|
|
|
4411
4517
|
// src/paint-editor/PaintEditor.tsx
|
|
4412
|
-
var
|
|
4518
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
4413
4519
|
var PAINT_CONTROLS = {
|
|
4414
4520
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
4415
4521
|
lighting: '[data-testid="light-panel"]',
|
|
4416
4522
|
symmetry: '[aria-label="Symmetry"]'
|
|
4417
4523
|
};
|
|
4418
4524
|
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4419
|
-
const [tool, setTool] = (0,
|
|
4420
|
-
const [fillOptions, setFillOptions] = (0,
|
|
4421
|
-
const [tab, setTab] = (0,
|
|
4422
|
-
const tabRef = (0,
|
|
4525
|
+
const [tool, setTool] = (0, import_react32.useState)("brush");
|
|
4526
|
+
const [fillOptions, setFillOptions] = (0, import_react32.useState)({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
4527
|
+
const [tab, setTab] = (0, import_react32.useState)("color");
|
|
4528
|
+
const tabRef = (0, import_react32.useRef)(tab);
|
|
4423
4529
|
tabRef.current = tab;
|
|
4424
|
-
const rootRef = (0,
|
|
4425
|
-
const [ownPresence] = (0,
|
|
4530
|
+
const rootRef = (0, import_react32.useRef)(null);
|
|
4531
|
+
const [ownPresence] = (0, import_react32.useState)(() => new import_paint_editor17.PaintPresence());
|
|
4426
4532
|
const ambientPlayback = useAgentPlayback();
|
|
4427
4533
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
4428
4534
|
const viewBox = () => {
|
|
@@ -4433,12 +4539,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4433
4539
|
const docToClient = (p) => {
|
|
4434
4540
|
const r = viewBox();
|
|
4435
4541
|
if (!r) return null;
|
|
4436
|
-
const q = (0,
|
|
4542
|
+
const q = (0, import_paint_editor17.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
|
|
4437
4543
|
return { x: r.left + q.x, y: r.top + q.y };
|
|
4438
4544
|
};
|
|
4439
4545
|
const clientToDoc = (p) => {
|
|
4440
4546
|
const r = viewBox();
|
|
4441
|
-
return r ? (0,
|
|
4547
|
+
return r ? (0, import_paint_editor17.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
|
|
4442
4548
|
};
|
|
4443
4549
|
const elementRect = (selector) => {
|
|
4444
4550
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -4478,30 +4584,30 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4478
4584
|
const box = rootRef.current?.getBoundingClientRect();
|
|
4479
4585
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
4480
4586
|
};
|
|
4481
|
-
const [error, setError] = (0,
|
|
4587
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
4482
4588
|
const effects = usePaintEffectsProvider(controller);
|
|
4483
4589
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
4484
|
-
return /* @__PURE__ */ (0,
|
|
4485
|
-
playing && /* @__PURE__ */ (0,
|
|
4486
|
-
/* @__PURE__ */ (0,
|
|
4487
|
-
/* @__PURE__ */ (0,
|
|
4488
|
-
/* @__PURE__ */ (0,
|
|
4489
|
-
/* @__PURE__ */ (0,
|
|
4490
|
-
/* @__PURE__ */ (0,
|
|
4491
|
-
error && /* @__PURE__ */ (0,
|
|
4590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.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: [
|
|
4591
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
4592
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
|
|
4593
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
4594
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
4595
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
4596
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
4597
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
4492
4598
|
] }),
|
|
4493
|
-
/* @__PURE__ */ (0,
|
|
4494
|
-
/* @__PURE__ */ (0,
|
|
4495
|
-
/* @__PURE__ */ (0,
|
|
4496
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
4497
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
4498
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
4499
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4500
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4501
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4502
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4503
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4504
|
-
tab === "effects" && effects && /* @__PURE__ */ (0,
|
|
4599
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
4600
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime32.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)) }),
|
|
4601
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
4602
|
+
tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ColorPanel, { controller }),
|
|
4603
|
+
tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(WetPanel, { controller }),
|
|
4604
|
+
tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PaperPanel, { controller }),
|
|
4605
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PaintLayersPanel, { controller }),
|
|
4606
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(StrokePanel, { controller }),
|
|
4607
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PathStrokePanel, { controller }),
|
|
4608
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(EvolutionPanel, { controller, proposals }),
|
|
4609
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(StickerPanel, { controller }),
|
|
4610
|
+
tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PaintEffectsPanel, { controller })
|
|
4505
4611
|
] })
|
|
4506
4612
|
] })
|
|
4507
4613
|
] })
|
|
@@ -4514,6 +4620,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4514
4620
|
BrushPanel,
|
|
4515
4621
|
ColorPanel,
|
|
4516
4622
|
EvolutionPanel,
|
|
4623
|
+
FerroPanel,
|
|
4517
4624
|
PaintCanvas,
|
|
4518
4625
|
PaintEditor,
|
|
4519
4626
|
PaintEffectsPanel,
|