@pixerate/editor-react 0.190.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 +801 -660
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +469 -328
- 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);
|
|
@@ -1926,32 +2032,33 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1926
2032
|
const wet = state.wet;
|
|
1927
2033
|
const layerId = state.document.activeLayerId;
|
|
1928
2034
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
2035
|
+
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1929
2036
|
const backend = controller.wetState();
|
|
1930
|
-
return /* @__PURE__ */ (0,
|
|
1931
|
-
/* @__PURE__ */ (0,
|
|
1932
|
-
/* @__PURE__ */ (0,
|
|
1933
|
-
/* @__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: [
|
|
1934
2041
|
"step ",
|
|
1935
2042
|
wet.clock
|
|
1936
2043
|
] })
|
|
1937
2044
|
] }),
|
|
1938
|
-
/* @__PURE__ */ (0,
|
|
1939
|
-
/* @__PURE__ */ (0,
|
|
1940
|
-
/* @__PURE__ */ (0,
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
1942
|
-
/* @__PURE__ */ (0,
|
|
1943
|
-
/* @__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" })
|
|
1944
2051
|
] }),
|
|
1945
|
-
/* @__PURE__ */ (0,
|
|
1946
|
-
|
|
1947
|
-
info && /* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
1949
|
-
|
|
1950
|
-
/* @__PURE__ */ (0,
|
|
1951
|
-
/* @__PURE__ */ (0,
|
|
1952
|
-
/* @__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)) })
|
|
1953
2060
|
] }),
|
|
1954
|
-
info.flow.kind !== "none" && /* @__PURE__ */ (0,
|
|
2061
|
+
info.flow.kind !== "none" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1955
2062
|
PaintSlider,
|
|
1956
2063
|
{
|
|
1957
2064
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1960,20 +2067,53 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1960
2067
|
}
|
|
1961
2068
|
)
|
|
1962
2069
|
] }),
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
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)(
|
|
2074
|
+
"button",
|
|
2075
|
+
{
|
|
2076
|
+
type: "button",
|
|
2077
|
+
className: button,
|
|
2078
|
+
onClick: () => attempt(async () => {
|
|
2079
|
+
await controller.wetIdle();
|
|
2080
|
+
const cx = Math.round(state.document.canvas.width / 2);
|
|
2081
|
+
const cy = Math.round(state.document.canvas.height / 2);
|
|
2082
|
+
controller.seedLivePatterns({ layerId, points: [{ x: cx, y: cy }] });
|
|
2083
|
+
}),
|
|
2084
|
+
children: "Seed pattern"
|
|
2085
|
+
}
|
|
2086
|
+
)
|
|
2087
|
+
] }),
|
|
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)(
|
|
2091
|
+
"select",
|
|
2092
|
+
{
|
|
2093
|
+
"aria-label": "Live pattern",
|
|
2094
|
+
value: livePattern.settings.pattern,
|
|
2095
|
+
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
2096
|
+
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
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))
|
|
2098
|
+
}
|
|
2099
|
+
)
|
|
2100
|
+
] }),
|
|
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))
|
|
2102
|
+
] }),
|
|
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)) })
|
|
1968
2108
|
] }),
|
|
1969
|
-
/* @__PURE__ */ (0,
|
|
1970
|
-
/* @__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 })
|
|
1971
2111
|
] });
|
|
1972
2112
|
};
|
|
1973
2113
|
|
|
1974
2114
|
// src/paint-editor/StickerPanel.tsx
|
|
1975
|
-
var
|
|
1976
|
-
var
|
|
2115
|
+
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
2116
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1977
2117
|
var StickerPanel = ({ controller, className }) => {
|
|
1978
2118
|
const state = usePaintEditorState(controller);
|
|
1979
2119
|
const [error, attempt] = useAttempt();
|
|
@@ -1983,16 +2123,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1983
2123
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1984
2124
|
if (!stickers.length) return null;
|
|
1985
2125
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1986
|
-
return /* @__PURE__ */ (0,
|
|
1987
|
-
/* @__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: [
|
|
1988
2128
|
"Stickers (",
|
|
1989
2129
|
stickers.length,
|
|
1990
2130
|
")"
|
|
1991
2131
|
] }),
|
|
1992
|
-
/* @__PURE__ */ (0,
|
|
1993
|
-
sel && /* @__PURE__ */ (0,
|
|
1994
|
-
/* @__PURE__ */ (0,
|
|
1995
|
-
/* @__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)(
|
|
1996
2136
|
StickerPicker,
|
|
1997
2137
|
{
|
|
1998
2138
|
controller,
|
|
@@ -2006,9 +2146,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
2006
2146
|
)
|
|
2007
2147
|
}
|
|
2008
2148
|
),
|
|
2009
|
-
/* @__PURE__ */ (0,
|
|
2010
|
-
/* @__PURE__ */ (0,
|
|
2011
|
-
/* @__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)(
|
|
2012
2152
|
"input",
|
|
2013
2153
|
{
|
|
2014
2154
|
type: "number",
|
|
@@ -2022,24 +2162,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
2022
2162
|
`${sel.id}-${k}-${sel[k]}`
|
|
2023
2163
|
)) })
|
|
2024
2164
|
] }),
|
|
2025
|
-
|
|
2026
|
-
/* @__PURE__ */ (0,
|
|
2027
|
-
/* @__PURE__ */ (0,
|
|
2028
|
-
/* @__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" })
|
|
2029
2169
|
] }),
|
|
2030
|
-
/* @__PURE__ */ (0,
|
|
2031
|
-
/* @__PURE__ */ (0,
|
|
2032
|
-
/* @__PURE__ */ (0,
|
|
2033
|
-
/* @__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" })
|
|
2034
2174
|
] })
|
|
2035
2175
|
] }),
|
|
2036
|
-
/* @__PURE__ */ (0,
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ErrorLine, { error })
|
|
2037
2177
|
] });
|
|
2038
2178
|
};
|
|
2039
2179
|
|
|
2040
2180
|
// src/paint-editor/StrokePanel.tsx
|
|
2041
|
-
var
|
|
2042
|
-
var
|
|
2181
|
+
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
2182
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2043
2183
|
var StrokePanel = ({ controller, className }) => {
|
|
2044
2184
|
const state = usePaintEditorState(controller);
|
|
2045
2185
|
const [error, attempt] = useAttempt();
|
|
@@ -2048,17 +2188,17 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
2048
2188
|
if (!layerId || !strokes) return null;
|
|
2049
2189
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
2050
2190
|
const sel = index >= 0 ? strokes[index] : null;
|
|
2051
|
-
const brushes = state.brushes.filter((b) => !(0,
|
|
2052
|
-
return /* @__PURE__ */ (0,
|
|
2053
|
-
/* @__PURE__ */ (0,
|
|
2054
|
-
/* @__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: [
|
|
2055
2195
|
"Strokes (",
|
|
2056
2196
|
strokes.length,
|
|
2057
2197
|
")"
|
|
2058
2198
|
] }),
|
|
2059
|
-
/* @__PURE__ */ (0,
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
2060
2200
|
] }),
|
|
2061
|
-
/* @__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)(
|
|
2062
2202
|
"button",
|
|
2063
2203
|
{
|
|
2064
2204
|
type: "button",
|
|
@@ -2071,10 +2211,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
2071
2211
|
},
|
|
2072
2212
|
s.id
|
|
2073
2213
|
)) }),
|
|
2074
|
-
sel && /* @__PURE__ */ (0,
|
|
2075
|
-
/* @__PURE__ */ (0,
|
|
2076
|
-
/* @__PURE__ */ (0,
|
|
2077
|
-
/* @__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)(
|
|
2078
2218
|
"select",
|
|
2079
2219
|
{
|
|
2080
2220
|
"aria-label": "Stroke brush",
|
|
@@ -2082,41 +2222,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
2082
2222
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
2083
2223
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
2084
2224
|
children: [
|
|
2085
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0,
|
|
2086
|
-
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))
|
|
2087
2227
|
]
|
|
2088
2228
|
}
|
|
2089
2229
|
)
|
|
2090
2230
|
] }),
|
|
2091
|
-
|
|
2092
|
-
/* @__PURE__ */ (0,
|
|
2093
|
-
/* @__PURE__ */ (0,
|
|
2094
|
-
/* @__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" })
|
|
2095
2235
|
] }),
|
|
2096
|
-
/* @__PURE__ */ (0,
|
|
2097
|
-
/* @__PURE__ */ (0,
|
|
2098
|
-
/* @__PURE__ */ (0,
|
|
2099
|
-
/* @__PURE__ */ (0,
|
|
2100
|
-
/* @__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" })
|
|
2101
2241
|
] })
|
|
2102
2242
|
] }),
|
|
2103
|
-
/* @__PURE__ */ (0,
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ErrorLine, { error })
|
|
2104
2244
|
] });
|
|
2105
2245
|
};
|
|
2106
2246
|
|
|
2107
2247
|
// src/paint-editor/PathStrokePanel.tsx
|
|
2108
|
-
var
|
|
2109
|
-
var
|
|
2110
|
-
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");
|
|
2111
2251
|
var PathStrokePanel = ({ controller, className }) => {
|
|
2112
2252
|
const state = usePaintEditorState(controller);
|
|
2113
2253
|
const [error, attempt] = useAttempt();
|
|
2114
|
-
const [path, setPath] = (0,
|
|
2115
|
-
const [taper, setTaper] = (0,
|
|
2116
|
-
const pressure =
|
|
2117
|
-
return /* @__PURE__ */ (0,
|
|
2118
|
-
/* @__PURE__ */ (0,
|
|
2119
|
-
/* @__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)(
|
|
2120
2260
|
"textarea",
|
|
2121
2261
|
{
|
|
2122
2262
|
"aria-label": "SVG path data",
|
|
@@ -2127,33 +2267,33 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
2127
2267
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
2128
2268
|
}
|
|
2129
2269
|
),
|
|
2130
|
-
/* @__PURE__ */ (0,
|
|
2131
|
-
/* @__PURE__ */ (0,
|
|
2132
|
-
/* @__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" })
|
|
2133
2273
|
] }),
|
|
2134
|
-
/* @__PURE__ */ (0,
|
|
2274
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ErrorLine, { error })
|
|
2135
2275
|
] });
|
|
2136
2276
|
};
|
|
2137
2277
|
|
|
2138
2278
|
// src/paint-editor/EvolutionPanel.tsx
|
|
2139
|
-
var
|
|
2140
|
-
var
|
|
2141
|
-
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");
|
|
2142
2282
|
var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
2143
2283
|
const state = usePaintEditorState(controller);
|
|
2144
2284
|
const store = proposals ?? controller.proposals;
|
|
2145
|
-
const proposalState = (0,
|
|
2285
|
+
const proposalState = (0, import_react18.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
2146
2286
|
const [error, attempt] = useAttempt();
|
|
2147
|
-
const [selectedStrokes, setSelectedStrokes] = (0,
|
|
2148
|
-
const [selectedProposals, setSelectedProposals] = (0,
|
|
2149
|
-
const [count, setCount] = (0,
|
|
2150
|
-
const [seed, setSeed] = (0,
|
|
2151
|
-
const [mutation, setMutation] = (0,
|
|
2152
|
-
const [contactSheetUrl, setContactSheetUrl] = (0,
|
|
2153
|
-
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));
|
|
2154
2294
|
const activeStrokeIds = selectedStrokes.filter((id) => eligibleStrokes.some((s) => s.id === id));
|
|
2155
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] : [];
|
|
2156
|
-
const variants = proposalState.proposals.filter((p) => (0,
|
|
2296
|
+
const variants = proposalState.proposals.filter((p) => (0, import_paint_editor15.proposalGenomeStrokes)(p).length > 0);
|
|
2157
2297
|
const activeProposalIds = selectedProposals.filter((id) => variants.some((v) => v.id === id));
|
|
2158
2298
|
const toggleStroke = (id) => {
|
|
2159
2299
|
setSelectedStrokes((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-15), id]);
|
|
@@ -2161,16 +2301,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2161
2301
|
const toggleProposal = (id) => {
|
|
2162
2302
|
setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
|
|
2163
2303
|
};
|
|
2164
|
-
return /* @__PURE__ */ (0,
|
|
2165
|
-
/* @__PURE__ */ (0,
|
|
2166
|
-
/* @__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: [
|
|
2167
2307
|
"Evolution (",
|
|
2168
2308
|
eligibleStrokes.length,
|
|
2169
2309
|
")"
|
|
2170
2310
|
] }),
|
|
2171
|
-
/* @__PURE__ */ (0,
|
|
2172
|
-
/* @__PURE__ */ (0,
|
|
2173
|
-
/* @__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)(
|
|
2174
2314
|
"input",
|
|
2175
2315
|
{
|
|
2176
2316
|
type: "number",
|
|
@@ -2184,9 +2324,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2184
2324
|
)
|
|
2185
2325
|
] }) })
|
|
2186
2326
|
] }),
|
|
2187
|
-
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) => {
|
|
2188
2328
|
const on = effectiveStrokeIds.includes(s.id);
|
|
2189
|
-
return /* @__PURE__ */ (0,
|
|
2329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2190
2330
|
"button",
|
|
2191
2331
|
{
|
|
2192
2332
|
type: "button",
|
|
@@ -2200,9 +2340,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2200
2340
|
s.id
|
|
2201
2341
|
);
|
|
2202
2342
|
}) }),
|
|
2203
|
-
|
|
2343
|
+
import_paint_editor15.EVOLUTION_SLIDERS.map((c) => {
|
|
2204
2344
|
const key = c.path;
|
|
2205
|
-
return /* @__PURE__ */ (0,
|
|
2345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2206
2346
|
PaintSlider,
|
|
2207
2347
|
{
|
|
2208
2348
|
control: c,
|
|
@@ -2212,8 +2352,8 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2212
2352
|
c.path
|
|
2213
2353
|
);
|
|
2214
2354
|
}),
|
|
2215
|
-
/* @__PURE__ */ (0,
|
|
2216
|
-
/* @__PURE__ */ (0,
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2356
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2217
2357
|
"button",
|
|
2218
2358
|
{
|
|
2219
2359
|
type: "button",
|
|
@@ -2226,7 +2366,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2226
2366
|
children: "Breed strokes"
|
|
2227
2367
|
}
|
|
2228
2368
|
),
|
|
2229
|
-
activeProposalIds.length === 2 && /* @__PURE__ */ (0,
|
|
2369
|
+
activeProposalIds.length === 2 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2230
2370
|
"button",
|
|
2231
2371
|
{
|
|
2232
2372
|
type: "button",
|
|
@@ -2239,29 +2379,29 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2239
2379
|
children: "Cross over (2)"
|
|
2240
2380
|
}
|
|
2241
2381
|
),
|
|
2242
|
-
variants.length > 0 && /* @__PURE__ */ (0,
|
|
2382
|
+
variants.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2243
2383
|
"button",
|
|
2244
2384
|
{
|
|
2245
2385
|
type: "button",
|
|
2246
2386
|
className: button,
|
|
2247
2387
|
onClick: () => attempt(() => {
|
|
2248
|
-
const sheet = (0,
|
|
2388
|
+
const sheet = (0, import_paint_editor15.exportProposalContactSheetPng)(controller, variants);
|
|
2249
2389
|
setContactSheetUrl(`data:image/png;base64,${sheet.base64}`);
|
|
2250
2390
|
}),
|
|
2251
2391
|
children: "Contact sheet"
|
|
2252
2392
|
}
|
|
2253
2393
|
)
|
|
2254
2394
|
] }),
|
|
2255
|
-
variants.length > 0 && /* @__PURE__ */ (0,
|
|
2256
|
-
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);
|
|
2257
2397
|
const picked = activeProposalIds.includes(p.id);
|
|
2258
|
-
return /* @__PURE__ */ (0,
|
|
2398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2259
2399
|
"div",
|
|
2260
2400
|
{
|
|
2261
2401
|
"data-testid": `evolution-variant-${p.id}`,
|
|
2262
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"}`,
|
|
2263
2403
|
children: [
|
|
2264
|
-
/* @__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)(
|
|
2265
2405
|
"button",
|
|
2266
2406
|
{
|
|
2267
2407
|
type: "button",
|
|
@@ -2271,10 +2411,10 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2271
2411
|
children: p.title
|
|
2272
2412
|
}
|
|
2273
2413
|
) }),
|
|
2274
|
-
g && /* @__PURE__ */ (0,
|
|
2275
|
-
p.rationale && /* @__PURE__ */ (0,
|
|
2276
|
-
/* @__PURE__ */ (0,
|
|
2277
|
-
/* @__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)(
|
|
2278
2418
|
"button",
|
|
2279
2419
|
{
|
|
2280
2420
|
type: "button",
|
|
@@ -2287,42 +2427,42 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
2287
2427
|
children: "Breed from"
|
|
2288
2428
|
}
|
|
2289
2429
|
),
|
|
2290
|
-
/* @__PURE__ */ (0,
|
|
2291
|
-
/* @__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" })
|
|
2292
2432
|
] })
|
|
2293
2433
|
]
|
|
2294
2434
|
},
|
|
2295
2435
|
p.id
|
|
2296
2436
|
);
|
|
2297
2437
|
}) }),
|
|
2298
|
-
contactSheetUrl && /* @__PURE__ */ (0,
|
|
2299
|
-
/* @__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 })
|
|
2300
2440
|
] });
|
|
2301
2441
|
};
|
|
2302
2442
|
|
|
2303
2443
|
// src/paint-editor/PaintEditor.tsx
|
|
2304
|
-
var
|
|
2305
|
-
var
|
|
2444
|
+
var import_react32 = require("react");
|
|
2445
|
+
var import_paint_editor17 = require("@pixerate/editor/paint-editor");
|
|
2306
2446
|
|
|
2307
2447
|
// src/playback/AgentPlaybackContext.tsx
|
|
2308
|
-
var
|
|
2309
|
-
var
|
|
2310
|
-
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);
|
|
2311
2451
|
function useAgentPlayback() {
|
|
2312
|
-
return (0,
|
|
2452
|
+
return (0, import_react19.useContext)(AgentPlaybackContext);
|
|
2313
2453
|
}
|
|
2314
2454
|
|
|
2315
2455
|
// src/playback/usePlaybackSurface.ts
|
|
2316
|
-
var
|
|
2456
|
+
var import_react20 = require("react");
|
|
2317
2457
|
var import_tools = require("@pixerate/editor/tools");
|
|
2318
2458
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
2319
2459
|
const ambient = useAgentPlayback();
|
|
2320
2460
|
const target = playback === void 0 ? ambient : playback;
|
|
2321
|
-
const [ownPresence] = (0,
|
|
2461
|
+
const [ownPresence] = (0, import_react20.useState)(() => new import_tools.PresenceStore());
|
|
2322
2462
|
const presence = sharedPresence ?? ownPresence;
|
|
2323
|
-
const latest = (0,
|
|
2463
|
+
const latest = (0, import_react20.useRef)(options);
|
|
2324
2464
|
latest.current = options;
|
|
2325
|
-
(0,
|
|
2465
|
+
(0, import_react20.useEffect)(() => {
|
|
2326
2466
|
if (!target || !id) return;
|
|
2327
2467
|
const o = () => latest.current;
|
|
2328
2468
|
const surface = {
|
|
@@ -2354,13 +2494,13 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
2354
2494
|
}
|
|
2355
2495
|
|
|
2356
2496
|
// src/playback/PresenceLayer.tsx
|
|
2357
|
-
var
|
|
2358
|
-
var
|
|
2497
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
2498
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2359
2499
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
2360
|
-
const { actors } = (0,
|
|
2500
|
+
const { actors } = (0, import_react21.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
2361
2501
|
if (!actors.length) return null;
|
|
2362
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;
|
|
2363
|
-
return /* @__PURE__ */ (0,
|
|
2503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2364
2504
|
"div",
|
|
2365
2505
|
{
|
|
2366
2506
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -2374,19 +2514,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
2374
2514
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
2375
2515
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
2376
2516
|
})();
|
|
2377
|
-
return /* @__PURE__ */ (0,
|
|
2378
|
-
ring && /* @__PURE__ */ (0,
|
|
2517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react21.default.Fragment, { children: [
|
|
2518
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2379
2519
|
"div",
|
|
2380
2520
|
{
|
|
2381
2521
|
"data-actor-focus": a.id,
|
|
2382
2522
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
2383
2523
|
}
|
|
2384
2524
|
),
|
|
2385
|
-
/* @__PURE__ */ (0,
|
|
2386
|
-
/* @__PURE__ */ (0,
|
|
2387
|
-
/* @__PURE__ */ (0,
|
|
2388
|
-
/* @__PURE__ */ (0,
|
|
2389
|
-
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 })
|
|
2390
2530
|
] })
|
|
2391
2531
|
] }) })
|
|
2392
2532
|
] }, a.id);
|
|
@@ -2396,16 +2536,16 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
2396
2536
|
}
|
|
2397
2537
|
|
|
2398
2538
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
2399
|
-
var
|
|
2400
|
-
var
|
|
2539
|
+
var import_react31 = require("react");
|
|
2540
|
+
var import_paint_editor16 = require("@pixerate/editor/paint-editor");
|
|
2401
2541
|
var import_effects4 = require("@pixerate/editor/effects");
|
|
2402
2542
|
|
|
2403
2543
|
// src/effects/useEffects.ts
|
|
2404
|
-
var
|
|
2544
|
+
var import_react22 = require("react");
|
|
2405
2545
|
function useEffectDescription(provider, effect) {
|
|
2406
|
-
const [state, setState] = (0,
|
|
2546
|
+
const [state, setState] = (0, import_react22.useState)({ key: "", description: null, error: null });
|
|
2407
2547
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
2408
|
-
(0,
|
|
2548
|
+
(0, import_react22.useEffect)(() => {
|
|
2409
2549
|
if (!provider || !effect) return;
|
|
2410
2550
|
let live = true;
|
|
2411
2551
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -2420,14 +2560,14 @@ function useEffectDescription(provider, effect) {
|
|
|
2420
2560
|
}
|
|
2421
2561
|
|
|
2422
2562
|
// src/effects/EffectThumbnail.tsx
|
|
2423
|
-
var
|
|
2563
|
+
var import_react23 = require("react");
|
|
2424
2564
|
var import_effects = require("@pixerate/editor/effects");
|
|
2425
|
-
var
|
|
2565
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2426
2566
|
var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing" };
|
|
2427
2567
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
2428
|
-
const ref = (0,
|
|
2429
|
-
const [failed, setFailed] = (0,
|
|
2430
|
-
(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)(() => {
|
|
2431
2571
|
if (effect.kind in LABELS) return;
|
|
2432
2572
|
let live = true;
|
|
2433
2573
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -2442,28 +2582,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
2442
2582
|
live = false;
|
|
2443
2583
|
};
|
|
2444
2584
|
}, [provider, effect, width, height]);
|
|
2445
|
-
return /* @__PURE__ */ (0,
|
|
2585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2446
2586
|
"div",
|
|
2447
2587
|
{
|
|
2448
2588
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
2449
2589
|
style: { aspectRatio: `${width} / ${height}` },
|
|
2450
2590
|
"data-effect-thumbnail": effect.id,
|
|
2451
|
-
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" })
|
|
2452
2592
|
}
|
|
2453
2593
|
);
|
|
2454
2594
|
}
|
|
2455
2595
|
|
|
2456
2596
|
// src/effects/EffectsBrowser.tsx
|
|
2457
|
-
var
|
|
2597
|
+
var import_react24 = require("react");
|
|
2458
2598
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
2459
|
-
var
|
|
2599
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2460
2600
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
2461
|
-
const [all, setAll] = (0,
|
|
2462
|
-
const [query, setQuery] = (0,
|
|
2463
|
-
const [category, setCategory] = (0,
|
|
2464
|
-
const [use, setUse] = (0,
|
|
2465
|
-
const [error, setError] = (0,
|
|
2466
|
-
(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)(() => {
|
|
2467
2607
|
if (!provider) return setAll([]);
|
|
2468
2608
|
let live = true;
|
|
2469
2609
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -2474,8 +2614,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2474
2614
|
live = false;
|
|
2475
2615
|
};
|
|
2476
2616
|
}, [provider]);
|
|
2477
|
-
const [found, setFound] = (0,
|
|
2478
|
-
(0,
|
|
2617
|
+
const [found, setFound] = (0, import_react24.useState)([]);
|
|
2618
|
+
(0, import_react24.useEffect)(() => {
|
|
2479
2619
|
if (!provider) return setFound([]);
|
|
2480
2620
|
let live = true;
|
|
2481
2621
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -2484,14 +2624,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2484
2624
|
};
|
|
2485
2625
|
}, [provider, query, category, use]);
|
|
2486
2626
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
2487
|
-
const categories = (0,
|
|
2627
|
+
const categories = (0, import_react24.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
2488
2628
|
const shown = found.filter(allowed);
|
|
2489
2629
|
if (!provider)
|
|
2490
|
-
return /* @__PURE__ */ (0,
|
|
2491
|
-
return /* @__PURE__ */ (0,
|
|
2492
|
-
title && /* @__PURE__ */ (0,
|
|
2493
|
-
/* @__PURE__ */ (0,
|
|
2494
|
-
/* @__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)(
|
|
2495
2635
|
"input",
|
|
2496
2636
|
{
|
|
2497
2637
|
type: "search",
|
|
@@ -2502,17 +2642,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2502
2642
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
2503
2643
|
}
|
|
2504
2644
|
),
|
|
2505
|
-
/* @__PURE__ */ (0,
|
|
2506
|
-
/* @__PURE__ */ (0,
|
|
2507
|
-
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))
|
|
2508
2648
|
] }),
|
|
2509
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
2510
|
-
/* @__PURE__ */ (0,
|
|
2511
|
-
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))
|
|
2512
2652
|
] })
|
|
2513
2653
|
] }),
|
|
2514
|
-
error && /* @__PURE__ */ (0,
|
|
2515
|
-
/* @__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)(
|
|
2516
2656
|
"button",
|
|
2517
2657
|
{
|
|
2518
2658
|
type: "button",
|
|
@@ -2521,23 +2661,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2521
2661
|
"data-effect-id": e.id,
|
|
2522
2662
|
onClick: () => onPick(e),
|
|
2523
2663
|
children: [
|
|
2524
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
2525
|
-
/* @__PURE__ */ (0,
|
|
2526
|
-
/* @__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 ") })
|
|
2527
2667
|
]
|
|
2528
2668
|
}
|
|
2529
2669
|
) }, e.id)) }),
|
|
2530
|
-
!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." })
|
|
2531
2671
|
] });
|
|
2532
2672
|
}
|
|
2533
2673
|
|
|
2534
2674
|
// src/effects/EffectParameters.tsx
|
|
2535
|
-
var
|
|
2675
|
+
var import_react30 = __toESM(require("react"), 1);
|
|
2536
2676
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
2537
2677
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
2538
2678
|
|
|
2539
2679
|
// src/parameters/fields.tsx
|
|
2540
|
-
var
|
|
2680
|
+
var import_react29 = require("react");
|
|
2541
2681
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
2542
2682
|
|
|
2543
2683
|
// src/color/index.ts
|
|
@@ -2550,9 +2690,9 @@ __export(color_exports, {
|
|
|
2550
2690
|
});
|
|
2551
2691
|
|
|
2552
2692
|
// src/color/ColorPicker.tsx
|
|
2553
|
-
var
|
|
2693
|
+
var import_react25 = require("react");
|
|
2554
2694
|
var import_color = require("@pixerate/editor/color");
|
|
2555
|
-
var
|
|
2695
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2556
2696
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
2557
2697
|
function readLocalRecents() {
|
|
2558
2698
|
try {
|
|
@@ -2590,24 +2730,24 @@ var ColorPicker = ({
|
|
|
2590
2730
|
id,
|
|
2591
2731
|
"aria-label": ariaLabel = "Color picker"
|
|
2592
2732
|
}) => {
|
|
2593
|
-
const generatedId = (0,
|
|
2733
|
+
const generatedId = (0, import_react25.useId)();
|
|
2594
2734
|
const pickerId = id || generatedId;
|
|
2595
|
-
const [pickerState, setPickerState] = (0,
|
|
2735
|
+
const [pickerState, setPickerState] = (0, import_react25.useState)(
|
|
2596
2736
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
2597
2737
|
);
|
|
2598
|
-
const stateRef = (0,
|
|
2738
|
+
const stateRef = (0, import_react25.useRef)(pickerState);
|
|
2599
2739
|
stateRef.current = pickerState;
|
|
2600
|
-
(0,
|
|
2740
|
+
(0, import_react25.useEffect)(() => {
|
|
2601
2741
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
2602
2742
|
if (next) {
|
|
2603
2743
|
setPickerState(next);
|
|
2604
2744
|
}
|
|
2605
2745
|
}, [value]);
|
|
2606
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
2746
|
+
const [internalRecent, setInternalRecent] = (0, import_react25.useState)(
|
|
2607
2747
|
() => controlledRecent ? [] : readLocalRecents()
|
|
2608
2748
|
);
|
|
2609
2749
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
2610
|
-
const recordRecent = (0,
|
|
2750
|
+
const recordRecent = (0, import_react25.useCallback)(
|
|
2611
2751
|
(color) => {
|
|
2612
2752
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
2613
2753
|
if (!controlledRecent) {
|
|
@@ -2618,11 +2758,11 @@ var ColorPicker = ({
|
|
|
2618
2758
|
},
|
|
2619
2759
|
[activeRecent, controlledRecent, onRecentChange]
|
|
2620
2760
|
);
|
|
2621
|
-
const [textDraft, setTextDraft] = (0,
|
|
2622
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
2623
|
-
const [isClipped, setIsClipped] = (0,
|
|
2624
|
-
const isTypingRef = (0,
|
|
2625
|
-
(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)(() => {
|
|
2626
2766
|
if (!isTypingRef.current) {
|
|
2627
2767
|
setTextDraft(value);
|
|
2628
2768
|
setIsInvalid(false);
|
|
@@ -2630,11 +2770,11 @@ var ColorPicker = ({
|
|
|
2630
2770
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
2631
2771
|
}
|
|
2632
2772
|
}, [value]);
|
|
2633
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
2634
|
-
(0,
|
|
2773
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react25.useState)(false);
|
|
2774
|
+
(0, import_react25.useEffect)(() => {
|
|
2635
2775
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
2636
2776
|
}, []);
|
|
2637
|
-
const emitColorChange = (0,
|
|
2777
|
+
const emitColorChange = (0, import_react25.useCallback)(
|
|
2638
2778
|
(nextState) => {
|
|
2639
2779
|
setPickerState(nextState);
|
|
2640
2780
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -2642,10 +2782,10 @@ var ColorPicker = ({
|
|
|
2642
2782
|
},
|
|
2643
2783
|
[alpha, onChange]
|
|
2644
2784
|
);
|
|
2645
|
-
const latest = (0,
|
|
2785
|
+
const latest = (0, import_react25.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
2646
2786
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
2647
|
-
const endDragRef = (0,
|
|
2648
|
-
(0,
|
|
2787
|
+
const endDragRef = (0, import_react25.useRef)(null);
|
|
2788
|
+
(0, import_react25.useEffect)(() => () => endDragRef.current?.(), []);
|
|
2649
2789
|
const startDrag = (e, next) => {
|
|
2650
2790
|
if (disabled) return;
|
|
2651
2791
|
e.preventDefault();
|
|
@@ -2747,7 +2887,7 @@ var ColorPicker = ({
|
|
|
2747
2887
|
} catch {
|
|
2748
2888
|
}
|
|
2749
2889
|
};
|
|
2750
|
-
const contrastResult = (0,
|
|
2890
|
+
const contrastResult = (0, import_react25.useMemo)(() => {
|
|
2751
2891
|
if (!contrastAgainst) return null;
|
|
2752
2892
|
const fg = (0, import_color.parseColor)(value);
|
|
2753
2893
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -2759,7 +2899,7 @@ var ColorPicker = ({
|
|
|
2759
2899
|
}, [value, contrastAgainst]);
|
|
2760
2900
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
2761
2901
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
2762
|
-
return /* @__PURE__ */ (0,
|
|
2902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2763
2903
|
"div",
|
|
2764
2904
|
{
|
|
2765
2905
|
id: pickerId,
|
|
@@ -2783,7 +2923,7 @@ var ColorPicker = ({
|
|
|
2783
2923
|
pointerEvents: disabled ? "none" : "auto"
|
|
2784
2924
|
},
|
|
2785
2925
|
children: [
|
|
2786
|
-
/* @__PURE__ */ (0,
|
|
2926
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2787
2927
|
"span",
|
|
2788
2928
|
{
|
|
2789
2929
|
role: "status",
|
|
@@ -2802,7 +2942,7 @@ var ColorPicker = ({
|
|
|
2802
2942
|
children: liveDescription
|
|
2803
2943
|
}
|
|
2804
2944
|
),
|
|
2805
|
-
/* @__PURE__ */ (0,
|
|
2945
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2806
2946
|
"div",
|
|
2807
2947
|
{
|
|
2808
2948
|
role: "slider",
|
|
@@ -2824,7 +2964,7 @@ var ColorPicker = ({
|
|
|
2824
2964
|
touchAction: "none",
|
|
2825
2965
|
outline: "none"
|
|
2826
2966
|
},
|
|
2827
|
-
children: /* @__PURE__ */ (0,
|
|
2967
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2828
2968
|
"div",
|
|
2829
2969
|
{
|
|
2830
2970
|
style: {
|
|
@@ -2844,7 +2984,7 @@ var ColorPicker = ({
|
|
|
2844
2984
|
)
|
|
2845
2985
|
}
|
|
2846
2986
|
),
|
|
2847
|
-
/* @__PURE__ */ (0,
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2848
2988
|
"div",
|
|
2849
2989
|
{
|
|
2850
2990
|
role: "slider",
|
|
@@ -2867,7 +3007,7 @@ var ColorPicker = ({
|
|
|
2867
3007
|
touchAction: "none",
|
|
2868
3008
|
outline: "none"
|
|
2869
3009
|
},
|
|
2870
|
-
children: /* @__PURE__ */ (0,
|
|
3010
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2871
3011
|
"div",
|
|
2872
3012
|
{
|
|
2873
3013
|
style: {
|
|
@@ -2887,7 +3027,7 @@ var ColorPicker = ({
|
|
|
2887
3027
|
)
|
|
2888
3028
|
}
|
|
2889
3029
|
),
|
|
2890
|
-
alpha && /* @__PURE__ */ (0,
|
|
3030
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2891
3031
|
"div",
|
|
2892
3032
|
{
|
|
2893
3033
|
role: "slider",
|
|
@@ -2913,7 +3053,7 @@ var ColorPicker = ({
|
|
|
2913
3053
|
overflow: "hidden"
|
|
2914
3054
|
},
|
|
2915
3055
|
children: [
|
|
2916
|
-
/* @__PURE__ */ (0,
|
|
3056
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2917
3057
|
"div",
|
|
2918
3058
|
{
|
|
2919
3059
|
style: {
|
|
@@ -2923,7 +3063,7 @@ var ColorPicker = ({
|
|
|
2923
3063
|
}
|
|
2924
3064
|
}
|
|
2925
3065
|
),
|
|
2926
|
-
/* @__PURE__ */ (0,
|
|
3066
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2927
3067
|
"div",
|
|
2928
3068
|
{
|
|
2929
3069
|
style: {
|
|
@@ -2944,8 +3084,8 @@ var ColorPicker = ({
|
|
|
2944
3084
|
]
|
|
2945
3085
|
}
|
|
2946
3086
|
),
|
|
2947
|
-
/* @__PURE__ */ (0,
|
|
2948
|
-
/* @__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)(
|
|
2949
3089
|
"div",
|
|
2950
3090
|
{
|
|
2951
3091
|
style: {
|
|
@@ -2959,7 +3099,7 @@ var ColorPicker = ({
|
|
|
2959
3099
|
flexShrink: 0,
|
|
2960
3100
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
2961
3101
|
},
|
|
2962
|
-
children: /* @__PURE__ */ (0,
|
|
3102
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2963
3103
|
"div",
|
|
2964
3104
|
{
|
|
2965
3105
|
style: {
|
|
@@ -2971,7 +3111,7 @@ var ColorPicker = ({
|
|
|
2971
3111
|
)
|
|
2972
3112
|
}
|
|
2973
3113
|
),
|
|
2974
|
-
/* @__PURE__ */ (0,
|
|
3114
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2975
3115
|
"input",
|
|
2976
3116
|
{
|
|
2977
3117
|
type: "text",
|
|
@@ -3001,7 +3141,7 @@ var ColorPicker = ({
|
|
|
3001
3141
|
}
|
|
3002
3142
|
}
|
|
3003
3143
|
),
|
|
3004
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
3144
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3005
3145
|
"button",
|
|
3006
3146
|
{
|
|
3007
3147
|
type: "button",
|
|
@@ -3021,7 +3161,7 @@ var ColorPicker = ({
|
|
|
3021
3161
|
color: "inherit",
|
|
3022
3162
|
cursor: disabled ? "default" : "pointer"
|
|
3023
3163
|
},
|
|
3024
|
-
children: /* @__PURE__ */ (0,
|
|
3164
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3025
3165
|
"svg",
|
|
3026
3166
|
{
|
|
3027
3167
|
width: "14",
|
|
@@ -3033,16 +3173,16 @@ var ColorPicker = ({
|
|
|
3033
3173
|
strokeLinecap: "round",
|
|
3034
3174
|
strokeLinejoin: "round",
|
|
3035
3175
|
children: [
|
|
3036
|
-
/* @__PURE__ */ (0,
|
|
3037
|
-
/* @__PURE__ */ (0,
|
|
3038
|
-
/* @__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" })
|
|
3039
3179
|
]
|
|
3040
3180
|
}
|
|
3041
3181
|
)
|
|
3042
3182
|
}
|
|
3043
3183
|
)
|
|
3044
3184
|
] }),
|
|
3045
|
-
isClipped && /* @__PURE__ */ (0,
|
|
3185
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3046
3186
|
"div",
|
|
3047
3187
|
{
|
|
3048
3188
|
role: "note",
|
|
@@ -3058,10 +3198,10 @@ var ColorPicker = ({
|
|
|
3058
3198
|
borderRadius: "4px",
|
|
3059
3199
|
alignSelf: "flex-start"
|
|
3060
3200
|
},
|
|
3061
|
-
children: /* @__PURE__ */ (0,
|
|
3201
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
3062
3202
|
}
|
|
3063
3203
|
),
|
|
3064
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
3204
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3065
3205
|
"div",
|
|
3066
3206
|
{
|
|
3067
3207
|
style: {
|
|
@@ -3075,15 +3215,15 @@ var ColorPicker = ({
|
|
|
3075
3215
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
3076
3216
|
},
|
|
3077
3217
|
children: [
|
|
3078
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { children: [
|
|
3079
3219
|
"Contrast: ",
|
|
3080
|
-
/* @__PURE__ */ (0,
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("strong", { children: [
|
|
3081
3221
|
contrastResult.ratio.toFixed(2),
|
|
3082
3222
|
":1"
|
|
3083
3223
|
] })
|
|
3084
3224
|
] }),
|
|
3085
|
-
/* @__PURE__ */ (0,
|
|
3086
|
-
/* @__PURE__ */ (0,
|
|
3225
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
3226
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3087
3227
|
"span",
|
|
3088
3228
|
{
|
|
3089
3229
|
style: {
|
|
@@ -3096,7 +3236,7 @@ var ColorPicker = ({
|
|
|
3096
3236
|
]
|
|
3097
3237
|
}
|
|
3098
3238
|
),
|
|
3099
|
-
/* @__PURE__ */ (0,
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3100
3240
|
"span",
|
|
3101
3241
|
{
|
|
3102
3242
|
style: {
|
|
@@ -3113,9 +3253,9 @@ var ColorPicker = ({
|
|
|
3113
3253
|
]
|
|
3114
3254
|
}
|
|
3115
3255
|
),
|
|
3116
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
3117
|
-
/* @__PURE__ */ (0,
|
|
3118
|
-
/* @__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)(
|
|
3119
3259
|
"button",
|
|
3120
3260
|
{
|
|
3121
3261
|
type: "button",
|
|
@@ -3141,9 +3281,9 @@ var ColorPicker = ({
|
|
|
3141
3281
|
`${color}-${idx}`
|
|
3142
3282
|
)) })
|
|
3143
3283
|
] }),
|
|
3144
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
3145
|
-
/* @__PURE__ */ (0,
|
|
3146
|
-
/* @__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)(
|
|
3147
3287
|
"button",
|
|
3148
3288
|
{
|
|
3149
3289
|
type: "button",
|
|
@@ -3174,9 +3314,9 @@ var ColorPicker = ({
|
|
|
3174
3314
|
};
|
|
3175
3315
|
|
|
3176
3316
|
// src/color/DualColorPicker.tsx
|
|
3177
|
-
var
|
|
3317
|
+
var import_react26 = require("react");
|
|
3178
3318
|
var import_color2 = require("@pixerate/editor/color");
|
|
3179
|
-
var
|
|
3319
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3180
3320
|
function DualColorPicker({
|
|
3181
3321
|
value,
|
|
3182
3322
|
onChange,
|
|
@@ -3191,8 +3331,8 @@ function DualColorPicker({
|
|
|
3191
3331
|
disabled = false,
|
|
3192
3332
|
className = ""
|
|
3193
3333
|
}) {
|
|
3194
|
-
const sameId = (0,
|
|
3195
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
3334
|
+
const sameId = (0, import_react26.useId)();
|
|
3335
|
+
const [internalScheme, setInternalScheme] = (0, import_react26.useState)("light");
|
|
3196
3336
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
3197
3337
|
const handleSchemeSelect = (nextScheme) => {
|
|
3198
3338
|
if (onSchemeChange) {
|
|
@@ -3203,7 +3343,7 @@ function DualColorPicker({
|
|
|
3203
3343
|
};
|
|
3204
3344
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
3205
3345
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
3206
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
3346
|
+
const [sameInBoth, setSameInBoth] = (0, import_react26.useState)(isSame);
|
|
3207
3347
|
const handleSameToggle = (e) => {
|
|
3208
3348
|
const nextSame = e.target.checked;
|
|
3209
3349
|
setSameInBoth(nextSame);
|
|
@@ -3235,7 +3375,7 @@ function DualColorPicker({
|
|
|
3235
3375
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
3236
3376
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
3237
3377
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
3238
|
-
return /* @__PURE__ */ (0,
|
|
3378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3239
3379
|
"div",
|
|
3240
3380
|
{
|
|
3241
3381
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -3254,7 +3394,7 @@ function DualColorPicker({
|
|
|
3254
3394
|
boxSizing: "border-box"
|
|
3255
3395
|
},
|
|
3256
3396
|
children: [
|
|
3257
|
-
/* @__PURE__ */ (0,
|
|
3397
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3258
3398
|
"div",
|
|
3259
3399
|
{
|
|
3260
3400
|
role: "tablist",
|
|
@@ -3267,7 +3407,7 @@ function DualColorPicker({
|
|
|
3267
3407
|
gap: "2px"
|
|
3268
3408
|
},
|
|
3269
3409
|
children: [
|
|
3270
|
-
/* @__PURE__ */ (0,
|
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3271
3411
|
"button",
|
|
3272
3412
|
{
|
|
3273
3413
|
type: "button",
|
|
@@ -3290,7 +3430,7 @@ function DualColorPicker({
|
|
|
3290
3430
|
children: "Light"
|
|
3291
3431
|
}
|
|
3292
3432
|
),
|
|
3293
|
-
/* @__PURE__ */ (0,
|
|
3433
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3294
3434
|
"button",
|
|
3295
3435
|
{
|
|
3296
3436
|
type: "button",
|
|
@@ -3316,8 +3456,8 @@ function DualColorPicker({
|
|
|
3316
3456
|
]
|
|
3317
3457
|
}
|
|
3318
3458
|
),
|
|
3319
|
-
/* @__PURE__ */ (0,
|
|
3320
|
-
/* @__PURE__ */ (0,
|
|
3459
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3321
3461
|
"button",
|
|
3322
3462
|
{
|
|
3323
3463
|
type: "button",
|
|
@@ -3339,7 +3479,7 @@ function DualColorPicker({
|
|
|
3339
3479
|
outline: "none"
|
|
3340
3480
|
},
|
|
3341
3481
|
children: [
|
|
3342
|
-
/* @__PURE__ */ (0,
|
|
3482
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3343
3483
|
"span",
|
|
3344
3484
|
{
|
|
3345
3485
|
style: {
|
|
@@ -3351,11 +3491,11 @@ function DualColorPicker({
|
|
|
3351
3491
|
}
|
|
3352
3492
|
}
|
|
3353
3493
|
),
|
|
3354
|
-
/* @__PURE__ */ (0,
|
|
3494
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
3355
3495
|
]
|
|
3356
3496
|
}
|
|
3357
3497
|
),
|
|
3358
|
-
/* @__PURE__ */ (0,
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3359
3499
|
"button",
|
|
3360
3500
|
{
|
|
3361
3501
|
type: "button",
|
|
@@ -3377,7 +3517,7 @@ function DualColorPicker({
|
|
|
3377
3517
|
outline: "none"
|
|
3378
3518
|
},
|
|
3379
3519
|
children: [
|
|
3380
|
-
/* @__PURE__ */ (0,
|
|
3520
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3381
3521
|
"span",
|
|
3382
3522
|
{
|
|
3383
3523
|
style: {
|
|
@@ -3389,12 +3529,12 @@ function DualColorPicker({
|
|
|
3389
3529
|
}
|
|
3390
3530
|
}
|
|
3391
3531
|
),
|
|
3392
|
-
/* @__PURE__ */ (0,
|
|
3532
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
3393
3533
|
]
|
|
3394
3534
|
}
|
|
3395
3535
|
)
|
|
3396
3536
|
] }),
|
|
3397
|
-
/* @__PURE__ */ (0,
|
|
3537
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3398
3538
|
"div",
|
|
3399
3539
|
{
|
|
3400
3540
|
style: {
|
|
@@ -3405,7 +3545,7 @@ function DualColorPicker({
|
|
|
3405
3545
|
padding: "2px 0"
|
|
3406
3546
|
},
|
|
3407
3547
|
children: [
|
|
3408
|
-
/* @__PURE__ */ (0,
|
|
3548
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3409
3549
|
"label",
|
|
3410
3550
|
{
|
|
3411
3551
|
htmlFor: sameId,
|
|
@@ -3419,7 +3559,7 @@ function DualColorPicker({
|
|
|
3419
3559
|
color: "#c4cad4"
|
|
3420
3560
|
},
|
|
3421
3561
|
children: [
|
|
3422
|
-
/* @__PURE__ */ (0,
|
|
3562
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3423
3563
|
"input",
|
|
3424
3564
|
{
|
|
3425
3565
|
id: sameId,
|
|
@@ -3430,11 +3570,11 @@ function DualColorPicker({
|
|
|
3430
3570
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
3431
3571
|
}
|
|
3432
3572
|
),
|
|
3433
|
-
/* @__PURE__ */ (0,
|
|
3573
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Same in both" })
|
|
3434
3574
|
]
|
|
3435
3575
|
}
|
|
3436
3576
|
),
|
|
3437
|
-
/* @__PURE__ */ (0,
|
|
3577
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3438
3578
|
"button",
|
|
3439
3579
|
{
|
|
3440
3580
|
type: "button",
|
|
@@ -3456,7 +3596,7 @@ function DualColorPicker({
|
|
|
3456
3596
|
]
|
|
3457
3597
|
}
|
|
3458
3598
|
),
|
|
3459
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
3599
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3460
3600
|
"div",
|
|
3461
3601
|
{
|
|
3462
3602
|
"data-testid": "dual-contrast-summary",
|
|
@@ -3470,20 +3610,20 @@ function DualColorPicker({
|
|
|
3470
3610
|
color: "#8c95a6"
|
|
3471
3611
|
},
|
|
3472
3612
|
children: [
|
|
3473
|
-
/* @__PURE__ */ (0,
|
|
3613
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
3474
3614
|
"Light:",
|
|
3475
3615
|
" ",
|
|
3476
|
-
/* @__PURE__ */ (0,
|
|
3616
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
3477
3617
|
dualContrast.light.ratio.toFixed(2),
|
|
3478
3618
|
" (",
|
|
3479
3619
|
dualContrast.light.level,
|
|
3480
3620
|
")"
|
|
3481
3621
|
] })
|
|
3482
3622
|
] }),
|
|
3483
|
-
/* @__PURE__ */ (0,
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
3484
3624
|
"Dark:",
|
|
3485
3625
|
" ",
|
|
3486
|
-
/* @__PURE__ */ (0,
|
|
3626
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
3487
3627
|
dualContrast.dark.ratio.toFixed(2),
|
|
3488
3628
|
" (",
|
|
3489
3629
|
dualContrast.dark.level,
|
|
@@ -3493,7 +3633,7 @@ function DualColorPicker({
|
|
|
3493
3633
|
]
|
|
3494
3634
|
}
|
|
3495
3635
|
),
|
|
3496
|
-
/* @__PURE__ */ (0,
|
|
3636
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3497
3637
|
ColorPicker,
|
|
3498
3638
|
{
|
|
3499
3639
|
value: activeColor,
|
|
@@ -3512,7 +3652,7 @@ function DualColorPicker({
|
|
|
3512
3652
|
}
|
|
3513
3653
|
|
|
3514
3654
|
// src/color/useColorScheme.ts
|
|
3515
|
-
var
|
|
3655
|
+
var import_react27 = require("react");
|
|
3516
3656
|
var import_color3 = require("@pixerate/editor/color");
|
|
3517
3657
|
function getSnapshot(attribute) {
|
|
3518
3658
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -3537,7 +3677,7 @@ function getServerSnapshot() {
|
|
|
3537
3677
|
function useColorScheme(options) {
|
|
3538
3678
|
const override = options?.override;
|
|
3539
3679
|
const attribute = options?.attribute;
|
|
3540
|
-
const subscribe = (0,
|
|
3680
|
+
const subscribe = (0, import_react27.useMemo)(() => {
|
|
3541
3681
|
return (callback) => {
|
|
3542
3682
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
3543
3683
|
return () => {
|
|
@@ -3563,7 +3703,7 @@ function useColorScheme(options) {
|
|
|
3563
3703
|
};
|
|
3564
3704
|
};
|
|
3565
3705
|
}, [attribute]);
|
|
3566
|
-
const detected = (0,
|
|
3706
|
+
const detected = (0, import_react27.useSyncExternalStore)(
|
|
3567
3707
|
subscribe,
|
|
3568
3708
|
() => getSnapshot(attribute),
|
|
3569
3709
|
getServerSnapshot
|
|
@@ -3580,11 +3720,11 @@ function useResolvedColor(value, scheme) {
|
|
|
3580
3720
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
3581
3721
|
|
|
3582
3722
|
// src/parameters/controls.tsx
|
|
3583
|
-
var
|
|
3584
|
-
var
|
|
3585
|
-
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)({});
|
|
3586
3726
|
function useParameterComponents() {
|
|
3587
|
-
return (0,
|
|
3727
|
+
return (0, import_react28.useContext)(ParameterComponentsContext);
|
|
3588
3728
|
}
|
|
3589
3729
|
function resolveParameterComponents(explicit, context) {
|
|
3590
3730
|
return {
|
|
@@ -3596,7 +3736,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
3596
3736
|
}
|
|
3597
3737
|
|
|
3598
3738
|
// src/parameters/fields.tsx
|
|
3599
|
-
var
|
|
3739
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3600
3740
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
3601
3741
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
3602
3742
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -3605,9 +3745,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
3605
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";
|
|
3606
3746
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
3607
3747
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
3608
|
-
const inputRef = (0,
|
|
3609
|
-
const lastCommitted = (0,
|
|
3610
|
-
(0,
|
|
3748
|
+
const inputRef = (0, import_react29.useRef)(null);
|
|
3749
|
+
const lastCommitted = (0, import_react29.useRef)(null);
|
|
3750
|
+
(0, import_react29.useLayoutEffect)(() => {
|
|
3611
3751
|
lastCommitted.current = null;
|
|
3612
3752
|
const el = inputRef.current;
|
|
3613
3753
|
if (el && el.value !== value) el.value = value;
|
|
@@ -3618,9 +3758,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3618
3758
|
onCommit(text, el);
|
|
3619
3759
|
lastCommitted.current = el.value === text ? text : null;
|
|
3620
3760
|
};
|
|
3621
|
-
const commitRef = (0,
|
|
3761
|
+
const commitRef = (0, import_react29.useRef)(commit);
|
|
3622
3762
|
commitRef.current = commit;
|
|
3623
|
-
(0,
|
|
3763
|
+
(0, import_react29.useEffect)(() => {
|
|
3624
3764
|
const el = inputRef.current;
|
|
3625
3765
|
if (!el) return;
|
|
3626
3766
|
const change = () => commitRef.current(el);
|
|
@@ -3651,7 +3791,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3651
3791
|
if (typeof forwarded === "function") forwarded(el);
|
|
3652
3792
|
else if (forwarded) forwarded.current = el;
|
|
3653
3793
|
};
|
|
3654
|
-
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 });
|
|
3655
3795
|
}
|
|
3656
3796
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
3657
3797
|
function ParameterNumberInput(props) {
|
|
@@ -3685,9 +3825,9 @@ function ParameterNumberInput(props) {
|
|
|
3685
3825
|
onCommit: handleCommit,
|
|
3686
3826
|
onKeyDown: handleKeyDown
|
|
3687
3827
|
};
|
|
3688
|
-
return /* @__PURE__ */ (0,
|
|
3689
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
3690
|
-
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 })
|
|
3691
3831
|
] });
|
|
3692
3832
|
}
|
|
3693
3833
|
function ParameterSlider(props) {
|
|
@@ -3695,7 +3835,7 @@ function ParameterSlider(props) {
|
|
|
3695
3835
|
const ctx = useParameterComponents();
|
|
3696
3836
|
const resolved = resolveParameterComponents(components, ctx);
|
|
3697
3837
|
const CustomSlider = resolved.slider;
|
|
3698
|
-
const dragging = (0,
|
|
3838
|
+
const dragging = (0, import_react29.useRef)(false);
|
|
3699
3839
|
const start = () => {
|
|
3700
3840
|
if (dragging.current) return;
|
|
3701
3841
|
dragging.current = true;
|
|
@@ -3706,7 +3846,7 @@ function ParameterSlider(props) {
|
|
|
3706
3846
|
dragging.current = false;
|
|
3707
3847
|
onGestureEnd?.();
|
|
3708
3848
|
};
|
|
3709
|
-
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 });
|
|
3710
3850
|
const step = (0, import_parameters.parameterStep)(field);
|
|
3711
3851
|
const sliderProps = {
|
|
3712
3852
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -3720,8 +3860,8 @@ function ParameterSlider(props) {
|
|
|
3720
3860
|
className: rangeClass,
|
|
3721
3861
|
style: parameterRangeStyle
|
|
3722
3862
|
};
|
|
3723
|
-
return /* @__PURE__ */ (0,
|
|
3724
|
-
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)(
|
|
3725
3865
|
CustomSlider,
|
|
3726
3866
|
{
|
|
3727
3867
|
...sliderProps,
|
|
@@ -3731,7 +3871,7 @@ function ParameterSlider(props) {
|
|
|
3731
3871
|
onGestureStart: start,
|
|
3732
3872
|
onGestureEnd: end
|
|
3733
3873
|
}
|
|
3734
|
-
) : /* @__PURE__ */ (0,
|
|
3874
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3735
3875
|
"input",
|
|
3736
3876
|
{
|
|
3737
3877
|
type: "range",
|
|
@@ -3743,11 +3883,11 @@ function ParameterSlider(props) {
|
|
|
3743
3883
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
3744
3884
|
}
|
|
3745
3885
|
),
|
|
3746
|
-
/* @__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` }) })
|
|
3747
3887
|
] });
|
|
3748
3888
|
}
|
|
3749
3889
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
3750
|
-
return /* @__PURE__ */ (0,
|
|
3890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3751
3891
|
"button",
|
|
3752
3892
|
{
|
|
3753
3893
|
type: "button",
|
|
@@ -3758,7 +3898,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
3758
3898
|
disabled: disabled || field.readOnly,
|
|
3759
3899
|
onClick: () => onChange(!value),
|
|
3760
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"}`,
|
|
3761
|
-
children: /* @__PURE__ */ (0,
|
|
3901
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3762
3902
|
"span",
|
|
3763
3903
|
{
|
|
3764
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"}`
|
|
@@ -3775,7 +3915,7 @@ function ParameterSelect(props) {
|
|
|
3775
3915
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
3776
3916
|
const off = disabled || field.readOnly;
|
|
3777
3917
|
if (field.control === "segmented") {
|
|
3778
|
-
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)(
|
|
3779
3919
|
"button",
|
|
3780
3920
|
{
|
|
3781
3921
|
type: "button",
|
|
@@ -3792,7 +3932,7 @@ function ParameterSelect(props) {
|
|
|
3792
3932
|
}
|
|
3793
3933
|
if (CustomSelect) {
|
|
3794
3934
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
3795
|
-
return /* @__PURE__ */ (0,
|
|
3935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3796
3936
|
CustomSelect,
|
|
3797
3937
|
{
|
|
3798
3938
|
id,
|
|
@@ -3808,7 +3948,7 @@ function ParameterSelect(props) {
|
|
|
3808
3948
|
);
|
|
3809
3949
|
}
|
|
3810
3950
|
const index = options.findIndex((o) => o.value === value);
|
|
3811
|
-
return /* @__PURE__ */ (0,
|
|
3951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3812
3952
|
"select",
|
|
3813
3953
|
{
|
|
3814
3954
|
id,
|
|
@@ -3821,23 +3961,23 @@ function ParameterSelect(props) {
|
|
|
3821
3961
|
},
|
|
3822
3962
|
className: parameterInputClass,
|
|
3823
3963
|
style: parameterSelectStyle,
|
|
3824
|
-
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)))
|
|
3825
3965
|
}
|
|
3826
3966
|
);
|
|
3827
3967
|
}
|
|
3828
3968
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
3829
3969
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
3830
|
-
const [open, setOpen] = (0,
|
|
3831
|
-
const containerRef = (0,
|
|
3832
|
-
const buttonRef = (0,
|
|
3833
|
-
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);
|
|
3834
3974
|
const alpha = !!field.alpha;
|
|
3835
3975
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
3836
3976
|
const rgb = hex.slice(0, 7);
|
|
3837
3977
|
const shown = alpha ? hex : rgb;
|
|
3838
3978
|
const off = disabled || field.readOnly;
|
|
3839
3979
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3840
|
-
(0,
|
|
3980
|
+
(0, import_react29.useEffect)(() => {
|
|
3841
3981
|
if (!open) return;
|
|
3842
3982
|
const onPointerDown = (e) => {
|
|
3843
3983
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3859,7 +3999,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3859
3999
|
};
|
|
3860
4000
|
}, [open]);
|
|
3861
4001
|
if (CustomColor) {
|
|
3862
|
-
return /* @__PURE__ */ (0,
|
|
4002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3863
4003
|
CustomColor,
|
|
3864
4004
|
{
|
|
3865
4005
|
id,
|
|
@@ -3874,9 +4014,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3874
4014
|
}
|
|
3875
4015
|
);
|
|
3876
4016
|
}
|
|
3877
|
-
return /* @__PURE__ */ (0,
|
|
3878
|
-
/* @__PURE__ */ (0,
|
|
3879
|
-
/* @__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)(
|
|
3880
4020
|
"button",
|
|
3881
4021
|
{
|
|
3882
4022
|
ref: buttonRef,
|
|
@@ -3887,10 +4027,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3887
4027
|
disabled: off,
|
|
3888
4028
|
onClick: () => setOpen((prev) => !prev),
|
|
3889
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",
|
|
3890
|
-
children: /* @__PURE__ */ (0,
|
|
4030
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3891
4031
|
}
|
|
3892
4032
|
),
|
|
3893
|
-
/* @__PURE__ */ (0,
|
|
4033
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3894
4034
|
ParameterCommitInput,
|
|
3895
4035
|
{
|
|
3896
4036
|
id,
|
|
@@ -3906,7 +4046,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3906
4046
|
}
|
|
3907
4047
|
)
|
|
3908
4048
|
] }),
|
|
3909
|
-
open && /* @__PURE__ */ (0,
|
|
4049
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3910
4050
|
"div",
|
|
3911
4051
|
{
|
|
3912
4052
|
ref: popoverRef,
|
|
@@ -3920,7 +4060,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3920
4060
|
},
|
|
3921
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",
|
|
3922
4062
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3923
|
-
children: /* @__PURE__ */ (0,
|
|
4063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3924
4064
|
ColorPicker,
|
|
3925
4065
|
{
|
|
3926
4066
|
value: shown,
|
|
@@ -3938,11 +4078,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3938
4078
|
}
|
|
3939
4079
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
3940
4080
|
const size = (0, import_parameters.vectorSize)(field);
|
|
3941
|
-
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) => {
|
|
3942
4082
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
3943
|
-
return /* @__PURE__ */ (0,
|
|
3944
|
-
/* @__PURE__ */ (0,
|
|
3945
|
-
/* @__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)(
|
|
3946
4086
|
ParameterNumberInput,
|
|
3947
4087
|
{
|
|
3948
4088
|
field: component,
|
|
@@ -3960,11 +4100,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
3960
4100
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
3961
4101
|
const off = disabled || field.readOnly;
|
|
3962
4102
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3963
|
-
return /* @__PURE__ */ (0,
|
|
3964
|
-
/* @__PURE__ */ (0,
|
|
3965
|
-
/* @__PURE__ */ (0,
|
|
3966
|
-
/* @__PURE__ */ (0,
|
|
3967
|
-
/* @__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)(
|
|
3968
4108
|
ParameterCommitInput,
|
|
3969
4109
|
{
|
|
3970
4110
|
id,
|
|
@@ -3975,15 +4115,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3975
4115
|
onCommit: (text) => onChange(text.trim())
|
|
3976
4116
|
}
|
|
3977
4117
|
),
|
|
3978
|
-
/* @__PURE__ */ (0,
|
|
3979
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
4118
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex gap-1", children: [
|
|
4119
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3980
4120
|
"label",
|
|
3981
4121
|
{
|
|
3982
4122
|
style: parameterButtonStyle,
|
|
3983
4123
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3984
4124
|
children: [
|
|
3985
4125
|
"Choose file\u2026",
|
|
3986
|
-
/* @__PURE__ */ (0,
|
|
4126
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3987
4127
|
"input",
|
|
3988
4128
|
{
|
|
3989
4129
|
type: "file",
|
|
@@ -4001,7 +4141,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4001
4141
|
]
|
|
4002
4142
|
}
|
|
4003
4143
|
),
|
|
4004
|
-
value && /* @__PURE__ */ (0,
|
|
4144
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4005
4145
|
"button",
|
|
4006
4146
|
{
|
|
4007
4147
|
type: "button",
|
|
@@ -4016,7 +4156,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4016
4156
|
] })
|
|
4017
4157
|
] })
|
|
4018
4158
|
] }),
|
|
4019
|
-
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)(
|
|
4020
4160
|
"button",
|
|
4021
4161
|
{
|
|
4022
4162
|
type: "button",
|
|
@@ -4026,14 +4166,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
4026
4166
|
disabled: off,
|
|
4027
4167
|
onClick: () => onChange(o.url),
|
|
4028
4168
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
4029
|
-
children: /* @__PURE__ */ (0,
|
|
4169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
4030
4170
|
},
|
|
4031
4171
|
o.url
|
|
4032
4172
|
)) })
|
|
4033
4173
|
] });
|
|
4034
4174
|
}
|
|
4035
4175
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
4036
|
-
return /* @__PURE__ */ (0,
|
|
4176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4037
4177
|
ParameterCommitInput,
|
|
4038
4178
|
{
|
|
4039
4179
|
id,
|
|
@@ -4052,24 +4192,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
4052
4192
|
switch (field.type) {
|
|
4053
4193
|
case "number":
|
|
4054
4194
|
case "int":
|
|
4055
|
-
return /* @__PURE__ */ (0,
|
|
4195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
4056
4196
|
case "boolean":
|
|
4057
|
-
return /* @__PURE__ */ (0,
|
|
4197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
4058
4198
|
case "choice":
|
|
4059
|
-
return /* @__PURE__ */ (0,
|
|
4199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
4060
4200
|
case "color":
|
|
4061
|
-
return /* @__PURE__ */ (0,
|
|
4201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
4062
4202
|
case "vector":
|
|
4063
|
-
return /* @__PURE__ */ (0,
|
|
4203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
4064
4204
|
case "image":
|
|
4065
|
-
return /* @__PURE__ */ (0,
|
|
4205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
4066
4206
|
case "text":
|
|
4067
|
-
return /* @__PURE__ */ (0,
|
|
4207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
4068
4208
|
}
|
|
4069
4209
|
}
|
|
4070
4210
|
|
|
4071
4211
|
// src/effects/EffectParameters.tsx
|
|
4072
|
-
var
|
|
4212
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4073
4213
|
function EffectParameters({
|
|
4074
4214
|
description,
|
|
4075
4215
|
values,
|
|
@@ -4084,10 +4224,10 @@ function EffectParameters({
|
|
|
4084
4224
|
className = "",
|
|
4085
4225
|
components
|
|
4086
4226
|
}) {
|
|
4087
|
-
const fields = (0,
|
|
4088
|
-
const idBase = (0,
|
|
4089
|
-
const gesture =
|
|
4090
|
-
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);
|
|
4091
4231
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
4092
4232
|
const handlePresetSelect = (name) => {
|
|
4093
4233
|
if (!name) return;
|
|
@@ -4098,8 +4238,8 @@ function EffectParameters({
|
|
|
4098
4238
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
4099
4239
|
}
|
|
4100
4240
|
};
|
|
4101
|
-
return /* @__PURE__ */ (0,
|
|
4102
|
-
(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)(
|
|
4103
4243
|
CustomPresetSelect,
|
|
4104
4244
|
{
|
|
4105
4245
|
"aria-label": `${description.name} presets`,
|
|
@@ -4114,7 +4254,7 @@ function EffectParameters({
|
|
|
4114
4254
|
],
|
|
4115
4255
|
onChange: (name) => handlePresetSelect(String(name))
|
|
4116
4256
|
}
|
|
4117
|
-
) : /* @__PURE__ */ (0,
|
|
4257
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
4118
4258
|
"select",
|
|
4119
4259
|
{
|
|
4120
4260
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -4124,8 +4264,8 @@ function EffectParameters({
|
|
|
4124
4264
|
disabled,
|
|
4125
4265
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
4126
4266
|
children: [
|
|
4127
|
-
/* @__PURE__ */ (0,
|
|
4128
|
-
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))
|
|
4129
4269
|
]
|
|
4130
4270
|
}
|
|
4131
4271
|
)),
|
|
@@ -4135,14 +4275,14 @@ function EffectParameters({
|
|
|
4135
4275
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
4136
4276
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
4137
4277
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
4138
|
-
return /* @__PURE__ */ (0,
|
|
4139
|
-
/* @__PURE__ */ (0,
|
|
4140
|
-
/* @__PURE__ */ (0,
|
|
4141
|
-
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" }),
|
|
4142
4282
|
renderControlAddon?.(field.id),
|
|
4143
|
-
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" })
|
|
4144
4284
|
] }),
|
|
4145
|
-
/* @__PURE__ */ (0,
|
|
4285
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4146
4286
|
ParameterFieldControl,
|
|
4147
4287
|
{
|
|
4148
4288
|
field,
|
|
@@ -4157,15 +4297,15 @@ function EffectParameters({
|
|
|
4157
4297
|
)
|
|
4158
4298
|
] }, field.id);
|
|
4159
4299
|
}),
|
|
4160
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
4300
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
4161
4301
|
] });
|
|
4162
4302
|
}
|
|
4163
4303
|
|
|
4164
4304
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
4165
|
-
var
|
|
4305
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
4166
4306
|
function usePaintEffectsProvider(controller) {
|
|
4167
|
-
const [provider, setProvider] = (0,
|
|
4168
|
-
(0,
|
|
4307
|
+
const [provider, setProvider] = (0, import_react31.useState)(controller.effectsProvider);
|
|
4308
|
+
(0, import_react31.useEffect)(() => {
|
|
4169
4309
|
setProvider(controller.effectsProvider);
|
|
4170
4310
|
return controller.effects.subscribe(setProvider);
|
|
4171
4311
|
}, [controller]);
|
|
@@ -4173,27 +4313,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
4173
4313
|
}
|
|
4174
4314
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
4175
4315
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
4176
|
-
(0,
|
|
4316
|
+
(0, import_react31.useEffect)(() => {
|
|
4177
4317
|
if (!registry) return;
|
|
4178
|
-
return registry.register((0,
|
|
4318
|
+
return registry.register((0, import_paint_editor16.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
4179
4319
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
4180
4320
|
}
|
|
4181
4321
|
function Controls({ provider, effect, name, values, apply }) {
|
|
4182
4322
|
const { description, error } = useEffectDescription(provider, effect);
|
|
4183
|
-
const drags = (0,
|
|
4184
|
-
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: [
|
|
4185
4325
|
'No effects provider: "',
|
|
4186
4326
|
name ?? effect,
|
|
4187
4327
|
'" is kept as it was drawn.'
|
|
4188
4328
|
] });
|
|
4189
|
-
if (error) return /* @__PURE__ */ (0,
|
|
4190
|
-
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" });
|
|
4191
4331
|
const commit = (gesture) => {
|
|
4192
4332
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
4193
4333
|
drags.current.add(gesture);
|
|
4194
4334
|
return true;
|
|
4195
4335
|
};
|
|
4196
|
-
return /* @__PURE__ */ (0,
|
|
4336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4197
4337
|
EffectParameters,
|
|
4198
4338
|
{
|
|
4199
4339
|
description,
|
|
@@ -4215,8 +4355,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4215
4355
|
const state = usePaintEditorState(controller);
|
|
4216
4356
|
const provider = usePaintEffectsProvider(controller);
|
|
4217
4357
|
const [error, attempt] = useAttempt();
|
|
4218
|
-
const [browse, setBrowse] = (0,
|
|
4219
|
-
const [busy, setBusy] = (0,
|
|
4358
|
+
const [browse, setBrowse] = (0, import_react31.useState)(null);
|
|
4359
|
+
const [busy, setBusy] = (0, import_react31.useState)(false);
|
|
4220
4360
|
const paper = controller.getPaperEffect();
|
|
4221
4361
|
const activeId = state.document.activeLayerId;
|
|
4222
4362
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -4230,7 +4370,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4230
4370
|
if (!effectPaint) return;
|
|
4231
4371
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
4232
4372
|
};
|
|
4233
|
-
const thumbnail = (0,
|
|
4373
|
+
const thumbnail = (0, import_react31.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
4234
4374
|
const run = (work) => attempt(() => {
|
|
4235
4375
|
setBusy(true);
|
|
4236
4376
|
return work().finally(() => setBusy(false));
|
|
@@ -4246,28 +4386,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4246
4386
|
};
|
|
4247
4387
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
4248
4388
|
const pixel = active?.type === "pixel";
|
|
4249
|
-
return /* @__PURE__ */ (0,
|
|
4250
|
-
/* @__PURE__ */ (0,
|
|
4251
|
-
/* @__PURE__ */ (0,
|
|
4252
|
-
/* @__PURE__ */ (0,
|
|
4253
|
-
/* @__PURE__ */ (0,
|
|
4254
|
-
/* @__PURE__ */ (0,
|
|
4255
|
-
/* @__PURE__ */ (0,
|
|
4256
|
-
/* @__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" })
|
|
4257
4397
|
] }),
|
|
4258
|
-
!provider && /* @__PURE__ */ (0,
|
|
4259
|
-
browse && /* @__PURE__ */ (0,
|
|
4260
|
-
paper && /* @__PURE__ */ (0,
|
|
4261
|
-
/* @__PURE__ */ (0,
|
|
4262
|
-
/* @__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: [
|
|
4263
4403
|
"Paper: ",
|
|
4264
4404
|
paper.name ?? paper.effect
|
|
4265
4405
|
] }),
|
|
4266
|
-
/* @__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" })
|
|
4267
4407
|
] }),
|
|
4268
|
-
/* @__PURE__ */ (0,
|
|
4269
|
-
/* @__PURE__ */ (0,
|
|
4270
|
-
/* @__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)(
|
|
4271
4411
|
"input",
|
|
4272
4412
|
{
|
|
4273
4413
|
type: "range",
|
|
@@ -4289,43 +4429,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4289
4429
|
`o${paper.opacity}`
|
|
4290
4430
|
)
|
|
4291
4431
|
] }),
|
|
4292
|
-
/* @__PURE__ */ (0,
|
|
4293
|
-
/* @__PURE__ */ (0,
|
|
4294
|
-
/* @__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) => {
|
|
4295
4435
|
const blend = e.currentTarget.value;
|
|
4296
4436
|
run(() => controller.updatePaperEffect({ blend }));
|
|
4297
|
-
}, children:
|
|
4437
|
+
}, children: import_paint_editor16.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: b, children: b }, b)) })
|
|
4298
4438
|
] }),
|
|
4299
|
-
/* @__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)) })
|
|
4300
4440
|
] }),
|
|
4301
|
-
effectPaint && /* @__PURE__ */ (0,
|
|
4302
|
-
/* @__PURE__ */ (0,
|
|
4303
|
-
thumbnail ? /* @__PURE__ */ (0,
|
|
4304
|
-
/* @__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: [
|
|
4305
4445
|
"Paint: ",
|
|
4306
4446
|
effectPaint.effect,
|
|
4307
4447
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
4308
4448
|
] }),
|
|
4309
|
-
/* @__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" })
|
|
4310
4450
|
] }),
|
|
4311
|
-
/* @__PURE__ */ (0,
|
|
4312
|
-
/* @__PURE__ */ (0,
|
|
4313
|
-
/* @__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" } }) }),
|
|
4314
4454
|
"Along the stroke"
|
|
4315
4455
|
] }),
|
|
4316
|
-
hasPathControl && /* @__PURE__ */ (0,
|
|
4317
|
-
/* @__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" } }) }),
|
|
4318
4458
|
"Along the stroke (native)"
|
|
4319
4459
|
] }),
|
|
4320
|
-
/* @__PURE__ */ (0,
|
|
4321
|
-
/* @__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 }) }),
|
|
4322
4462
|
"Live"
|
|
4323
4463
|
] })
|
|
4324
4464
|
] }),
|
|
4325
|
-
effectPaint.map?.by === "stroke" && /* @__PURE__ */ (0,
|
|
4326
|
-
/* @__PURE__ */ (0,
|
|
4327
|
-
/* @__PURE__ */ (0,
|
|
4328
|
-
/* @__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)(
|
|
4329
4469
|
"input",
|
|
4330
4470
|
{
|
|
4331
4471
|
type: "number",
|
|
@@ -4339,56 +4479,56 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
4339
4479
|
effectPaint.map.length
|
|
4340
4480
|
)
|
|
4341
4481
|
] }),
|
|
4342
|
-
/* @__PURE__ */ (0,
|
|
4343
|
-
/* @__PURE__ */ (0,
|
|
4344
|
-
/* @__PURE__ */ (0,
|
|
4345
|
-
/* @__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" })
|
|
4346
4486
|
] })
|
|
4347
4487
|
] }),
|
|
4348
|
-
/* @__PURE__ */ (0,
|
|
4488
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
4349
4489
|
] }),
|
|
4350
|
-
animation && /* @__PURE__ */ (0,
|
|
4351
|
-
/* @__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: [
|
|
4352
4492
|
"Live paint: ",
|
|
4353
4493
|
animation.strokes,
|
|
4354
4494
|
" ",
|
|
4355
4495
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
4356
4496
|
] }),
|
|
4357
|
-
/* @__PURE__ */ (0,
|
|
4358
|
-
/* @__PURE__ */ (0,
|
|
4359
|
-
/* @__PURE__ */ (0,
|
|
4360
|
-
/* @__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" })
|
|
4361
4501
|
] })
|
|
4362
4502
|
] }),
|
|
4363
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
4364
|
-
/* @__PURE__ */ (0,
|
|
4365
|
-
/* @__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: [
|
|
4366
4506
|
"Layer: ",
|
|
4367
4507
|
layerEffect.name ?? layerEffect.effect
|
|
4368
4508
|
] }),
|
|
4369
|
-
/* @__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" })
|
|
4370
4510
|
] }),
|
|
4371
|
-
/* @__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)) })
|
|
4372
4512
|
] }),
|
|
4373
|
-
/* @__PURE__ */ (0,
|
|
4513
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ErrorLine, { error })
|
|
4374
4514
|
] });
|
|
4375
4515
|
};
|
|
4376
4516
|
|
|
4377
4517
|
// src/paint-editor/PaintEditor.tsx
|
|
4378
|
-
var
|
|
4518
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
4379
4519
|
var PAINT_CONTROLS = {
|
|
4380
4520
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
4381
4521
|
lighting: '[data-testid="light-panel"]',
|
|
4382
4522
|
symmetry: '[aria-label="Symmetry"]'
|
|
4383
4523
|
};
|
|
4384
4524
|
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4385
|
-
const [tool, setTool] = (0,
|
|
4386
|
-
const [fillOptions, setFillOptions] = (0,
|
|
4387
|
-
const [tab, setTab] = (0,
|
|
4388
|
-
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);
|
|
4389
4529
|
tabRef.current = tab;
|
|
4390
|
-
const rootRef = (0,
|
|
4391
|
-
const [ownPresence] = (0,
|
|
4530
|
+
const rootRef = (0, import_react32.useRef)(null);
|
|
4531
|
+
const [ownPresence] = (0, import_react32.useState)(() => new import_paint_editor17.PaintPresence());
|
|
4392
4532
|
const ambientPlayback = useAgentPlayback();
|
|
4393
4533
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
4394
4534
|
const viewBox = () => {
|
|
@@ -4399,12 +4539,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4399
4539
|
const docToClient = (p) => {
|
|
4400
4540
|
const r = viewBox();
|
|
4401
4541
|
if (!r) return null;
|
|
4402
|
-
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);
|
|
4403
4543
|
return { x: r.left + q.x, y: r.top + q.y };
|
|
4404
4544
|
};
|
|
4405
4545
|
const clientToDoc = (p) => {
|
|
4406
4546
|
const r = viewBox();
|
|
4407
|
-
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;
|
|
4408
4548
|
};
|
|
4409
4549
|
const elementRect = (selector) => {
|
|
4410
4550
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -4444,30 +4584,30 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4444
4584
|
const box = rootRef.current?.getBoundingClientRect();
|
|
4445
4585
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
4446
4586
|
};
|
|
4447
|
-
const [error, setError] = (0,
|
|
4587
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
4448
4588
|
const effects = usePaintEffectsProvider(controller);
|
|
4449
4589
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
4450
|
-
return /* @__PURE__ */ (0,
|
|
4451
|
-
playing && /* @__PURE__ */ (0,
|
|
4452
|
-
/* @__PURE__ */ (0,
|
|
4453
|
-
/* @__PURE__ */ (0,
|
|
4454
|
-
/* @__PURE__ */ (0,
|
|
4455
|
-
/* @__PURE__ */ (0,
|
|
4456
|
-
/* @__PURE__ */ (0,
|
|
4457
|
-
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 })
|
|
4458
4598
|
] }),
|
|
4459
|
-
/* @__PURE__ */ (0,
|
|
4460
|
-
/* @__PURE__ */ (0,
|
|
4461
|
-
/* @__PURE__ */ (0,
|
|
4462
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
4463
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
4464
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
4465
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4466
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4467
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4468
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4469
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
4470
|
-
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 })
|
|
4471
4611
|
] })
|
|
4472
4612
|
] })
|
|
4473
4613
|
] })
|
|
@@ -4480,6 +4620,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4480
4620
|
BrushPanel,
|
|
4481
4621
|
ColorPanel,
|
|
4482
4622
|
EvolutionPanel,
|
|
4623
|
+
FerroPanel,
|
|
4483
4624
|
PaintCanvas,
|
|
4484
4625
|
PaintEditor,
|
|
4485
4626
|
PaintEffectsPanel,
|