@pixerate/editor-react 0.170.0 → 0.172.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/chunk-KYMDNWSX.js +51 -0
- package/dist/paint-editor/BrushEditor.d.cts +29 -0
- package/dist/paint-editor/BrushEditor.d.ts +29 -0
- package/dist/paint-editor/BrushLibraryBrowser.d.cts +24 -0
- package/dist/paint-editor/BrushLibraryBrowser.d.ts +24 -0
- package/dist/paint-editor/BrushPanel.d.cts +5 -6
- package/dist/paint-editor/BrushPanel.d.ts +5 -6
- package/dist/paint-editor/StickerPicker.d.cts +4 -4
- package/dist/paint-editor/StickerPicker.d.ts +4 -4
- package/dist/paint-editor/index.cjs +861 -814
- package/dist/paint-editor/index.d.cts +2 -0
- package/dist/paint-editor/index.d.ts +2 -0
- package/dist/paint-editor/index.js +492 -525
- package/dist/stickers/StickerInsertPanel.d.cts +16 -0
- package/dist/stickers/StickerInsertPanel.d.ts +16 -0
- package/dist/stickers/StickerLibraryPicker.d.cts +21 -0
- package/dist/stickers/StickerLibraryPicker.d.ts +21 -0
- package/dist/stickers/index.cjs +110 -0
- package/dist/stickers/index.d.cts +2 -0
- package/dist/stickers/index.d.ts +2 -0
- package/dist/stickers/index.js +38 -0
- package/package.json +13 -3
|
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/paint-editor/index.ts
|
|
32
32
|
var paint_editor_exports = {};
|
|
33
33
|
__export(paint_editor_exports, {
|
|
34
|
+
BrushEditor: () => BrushEditor,
|
|
35
|
+
BrushLibraryBrowser: () => BrushLibraryBrowser,
|
|
34
36
|
BrushPanel: () => BrushPanel,
|
|
35
37
|
ColorPanel: () => ColorPanel,
|
|
36
38
|
PaintCanvas: () => PaintCanvas,
|
|
@@ -599,16 +601,142 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
599
601
|
};
|
|
600
602
|
|
|
601
603
|
// src/paint-editor/BrushPanel.tsx
|
|
602
|
-
var
|
|
603
|
-
var
|
|
604
|
-
var
|
|
604
|
+
var import_react10 = require("react");
|
|
605
|
+
var import_paint_editor5 = require("@pixerate/editor/paint-editor");
|
|
606
|
+
var import_brushes3 = require("@pixerate/editor/brushes");
|
|
607
|
+
|
|
608
|
+
// src/paint-editor/BrushEditor.tsx
|
|
609
|
+
var import_react5 = require("react");
|
|
610
|
+
var import_brushes = require("@pixerate/editor/brushes");
|
|
611
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
612
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, onSaveAs, renderExtra, className }) => {
|
|
613
|
+
const sections = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
614
|
+
const [problems, setProblems] = (0, import_react5.useState)(null);
|
|
615
|
+
const [name, setName] = (0, import_react5.useState)("");
|
|
616
|
+
const set = (path, value) => {
|
|
617
|
+
const r = (0, import_brushes.setBrushEditorValue)(brush, path, value);
|
|
618
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
619
|
+
if (r.brush !== brush) onChange(r.brush);
|
|
620
|
+
};
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
622
|
+
preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
623
|
+
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
624
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
625
|
+
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EditorControl, { control: c, onSet: set }, c.path)),
|
|
626
|
+
renderExtra?.(s.id)
|
|
627
|
+
] }, s.id)),
|
|
628
|
+
onSaveAs && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
629
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { value: name, placeholder: "Brush name", "aria-label": "Brush name", onChange: (e) => setName(e.target.value), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
631
|
+
"button",
|
|
632
|
+
{
|
|
633
|
+
type: "button",
|
|
634
|
+
className: button,
|
|
635
|
+
disabled: !name.trim(),
|
|
636
|
+
onClick: async () => {
|
|
637
|
+
try {
|
|
638
|
+
await onSaveAs(name.trim());
|
|
639
|
+
setName("");
|
|
640
|
+
setProblems(null);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
setProblems(e.message);
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
children: "Save brush"
|
|
646
|
+
}
|
|
647
|
+
)
|
|
648
|
+
] }),
|
|
649
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorLine, { error: problems })
|
|
650
|
+
] });
|
|
651
|
+
};
|
|
652
|
+
var EditorControl = ({ control: c, onSet }) => {
|
|
653
|
+
const note = c.note ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
654
|
+
switch (c.kind) {
|
|
655
|
+
case "slider":
|
|
656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { title: c.note, children: [
|
|
657
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PaintSlider, { control: c, value: c.value, onChange: (v) => onSet(c.path, v) }),
|
|
658
|
+
note
|
|
659
|
+
] });
|
|
660
|
+
case "choice":
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex items-center justify-between gap-2", title: c.note, children: [
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": c.ariaLabel, value: c.value, onChange: (e) => onSet(c.path, e.target.value), className: "max-w-[60%] rounded bg-slate-800 px-1 py-0.5", children: c.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: o.value, children: o.label }, o.value)) })
|
|
664
|
+
] });
|
|
665
|
+
case "toggle":
|
|
666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex items-center gap-2", title: c.note, children: [
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", "aria-label": c.ariaLabel, checked: c.value, onChange: (e) => onSet(c.path, e.target.checked) }),
|
|
668
|
+
" ",
|
|
669
|
+
c.label
|
|
670
|
+
] });
|
|
671
|
+
case "text":
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": c.ariaLabel, defaultValue: c.value, placeholder: c.placeholder, onBlur: (e) => e.target.value !== c.value && onSet(c.path, e.target.value.trim().toLowerCase()), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }, c.value)
|
|
675
|
+
] });
|
|
676
|
+
case "colour":
|
|
677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
678
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex items-center gap-1", children: [
|
|
680
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": c.ariaLabel, value: c.value ?? "#000000", onChange: (e) => onSet(c.path, e.target.value), className: "h-5 w-8" }),
|
|
681
|
+
c.value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
|
|
682
|
+
] })
|
|
683
|
+
] });
|
|
684
|
+
case "palette":
|
|
685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": c.ariaLabel, children: [
|
|
686
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
|
|
687
|
+
c.value.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", title: `Remove ${col}`, "aria-label": `Remove ${col}`, className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: col }, onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)) }, `${col}-${i}`)),
|
|
688
|
+
c.value.length < c.max && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": "Add a palette colour", onChange: (e) => onSet(c.path, [...c.value, e.target.value]), className: "h-4 w-6" })
|
|
689
|
+
] });
|
|
690
|
+
case "stamps":
|
|
691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": c.ariaLabel, title: `Up to ${c.max}`, children: c.options.map((o) => {
|
|
692
|
+
const on = c.value.includes(o.value);
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-pressed": on, className: chip(on), onClick: () => onSet(c.path, on ? c.value.filter((v) => v !== o.value) : [...c.value, o.value].slice(-c.max)), children: o.label }, o.value);
|
|
694
|
+
}) });
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/paint-editor/BrushLibraryBrowser.tsx
|
|
699
|
+
var import_react6 = require("react");
|
|
700
|
+
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
701
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
702
|
+
var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
703
|
+
const [text, setText] = (0, import_react6.useState)("");
|
|
704
|
+
const groups = (0, import_react6.useMemo)(() => (0, import_brushes2.brushLibraryGroups)(entries, { text, profile }), [entries, text, profile]);
|
|
705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "brush-library", children: [
|
|
706
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "search", value: text, placeholder: "Find a brush", "aria-label": "Find a brush", onChange: (e) => setText(e.target.value), className: "rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
707
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-1.5", role: "listbox", "aria-label": "Brushes", children: [
|
|
708
|
+
groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "group", "aria-label": g.title, className: "flex flex-col gap-0.5", children: [
|
|
709
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] uppercase tracking-wide text-slate-500", children: g.title }),
|
|
710
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-2 gap-1", children: g.varieties.flatMap(
|
|
711
|
+
(v) => v.entries.map((e) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
712
|
+
"button",
|
|
713
|
+
{
|
|
714
|
+
type: "button",
|
|
715
|
+
role: "option",
|
|
716
|
+
"aria-selected": activeId === e.brush.id,
|
|
717
|
+
title: [e.brush.name, v.title.toLowerCase() === e.brush.name.toLowerCase() ? "" : v.title, e.builtin ? "" : "saved"].filter(Boolean).join(" \xB7 "),
|
|
718
|
+
className: `flex flex-col items-start gap-0.5 rounded p-1 text-left ${activeId === e.brush.id ? "bg-indigo-600/30 ring-1 ring-indigo-500" : "bg-slate-900 hover:bg-slate-800"}`,
|
|
719
|
+
onClick: () => onSelect(e.brush.id),
|
|
720
|
+
children: [
|
|
721
|
+
thumbnail && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PixelCanvas, { pixels: thumbnail(e.brush.id), label: `${e.brush.name} thumbnail`, className: "rounded", style: { width: "100%", aspectRatio: `${thumbnailWidth} / ${thumbnailHeight}` } }),
|
|
722
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate text-[10px] text-slate-300", children: e.brush.name })
|
|
723
|
+
]
|
|
724
|
+
},
|
|
725
|
+
e.brush.id
|
|
726
|
+
))
|
|
727
|
+
) })
|
|
728
|
+
] }, g.id)),
|
|
729
|
+
!groups.length && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-slate-500", children: "No brush matches." })
|
|
730
|
+
] })
|
|
731
|
+
] });
|
|
732
|
+
};
|
|
605
733
|
|
|
606
734
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
607
735
|
var import_paint_editor4 = require("@pixerate/editor/paint-editor");
|
|
608
736
|
|
|
609
737
|
// src/paint-editor/PaintGradientEditorView.tsx
|
|
610
|
-
var
|
|
611
|
-
var
|
|
738
|
+
var import_react7 = require("react");
|
|
739
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
612
740
|
var button2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
|
|
613
741
|
var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
|
|
614
742
|
var number = "w-16 rounded bg-slate-800 px-1 py-0.5 text-[11px]";
|
|
@@ -629,7 +757,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
|
629
757
|
reversePaintGradient,
|
|
630
758
|
updatePaintGradientStop
|
|
631
759
|
} = kit;
|
|
632
|
-
const [selected, setSelected] = (0,
|
|
760
|
+
const [selected, setSelected] = (0, import_react7.useState)(0);
|
|
633
761
|
const sel = Math.min(selected, value.stops.length - 1);
|
|
634
762
|
const stop = value.stops[sel];
|
|
635
763
|
const map = value.map;
|
|
@@ -639,15 +767,15 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
|
639
767
|
setSelected(r.index);
|
|
640
768
|
onChange(r.paint);
|
|
641
769
|
};
|
|
642
|
-
return /* @__PURE__ */ (0,
|
|
643
|
-
/* @__PURE__ */ (0,
|
|
644
|
-
/* @__PURE__ */ (0,
|
|
645
|
-
/* @__PURE__ */ (0,
|
|
646
|
-
PAINT_GRADIENT_PRESETS.map((p, i) => /* @__PURE__ */ (0,
|
|
770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "paint-gradient-editor", "aria-label": "Gradient paint", children: [
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
772
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("select", { "aria-label": "Gradient preset", className: select, value: "", onChange: (e) => e.target.value && (setSelected(0), onChange(PAINT_GRADIENT_PRESETS[Number(e.target.value)].paint)), children: [
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: "Presets\u2026" }),
|
|
774
|
+
PAINT_GRADIENT_PRESETS.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: i, children: p.name }, p.name))
|
|
647
775
|
] }),
|
|
648
|
-
/* @__PURE__ */ (0,
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: button2, onClick: () => onChange(reversePaintGradient(value)), children: "Reverse" })
|
|
649
777
|
] }),
|
|
650
|
-
/* @__PURE__ */ (0,
|
|
778
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
651
779
|
"div",
|
|
652
780
|
{
|
|
653
781
|
role: "slider",
|
|
@@ -669,7 +797,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
|
669
797
|
}
|
|
670
798
|
}
|
|
671
799
|
),
|
|
672
|
-
/* @__PURE__ */ (0,
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "relative h-4", "aria-label": "Stops", children: value.stops.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
673
801
|
"button",
|
|
674
802
|
{
|
|
675
803
|
type: "button",
|
|
@@ -681,270 +809,187 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
|
681
809
|
},
|
|
682
810
|
i
|
|
683
811
|
)) }),
|
|
684
|
-
/* @__PURE__ */ (0,
|
|
685
|
-
/* @__PURE__ */ (0,
|
|
686
|
-
/* @__PURE__ */ (0,
|
|
687
|
-
/* @__PURE__ */ (0,
|
|
688
|
-
/* @__PURE__ */ (0,
|
|
812
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-stop", children: [
|
|
813
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("select", { "aria-label": "Stop colour source", className: select, value: stop.color === "paint" || stop.color === "secondary" ? stop.color : "color", onChange: (e) => patchStop({ color: e.target.value === "color" ? stopHex(stop.color) : e.target.value }), children: [
|
|
814
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "color", children: "Colour" }),
|
|
815
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "paint", children: "Paint colour" }),
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "secondary", children: "Second colour" })
|
|
689
817
|
] }),
|
|
690
|
-
stop.color !== "paint" && stop.color !== "secondary" && /* @__PURE__ */ (0,
|
|
691
|
-
/* @__PURE__ */ (0,
|
|
818
|
+
stop.color !== "paint" && stop.color !== "secondary" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "color", "aria-label": "Stop colour", value: stop.color, onChange: (e) => patchStop({ color: e.target.value }), className: "h-6 w-8 rounded bg-transparent" }),
|
|
819
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
692
820
|
"At",
|
|
693
|
-
/* @__PURE__ */ (0,
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "number", "aria-label": "Stop position", min: 0, max: 100, step: 1, value: pct(stop.offset), onChange: (e) => patchStop({ offset: Number(e.target.value) / 100 }), className: number }),
|
|
694
822
|
"%"
|
|
695
823
|
] }),
|
|
696
|
-
/* @__PURE__ */ (0,
|
|
824
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
697
825
|
"Opacity",
|
|
698
|
-
/* @__PURE__ */ (0,
|
|
826
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "number", "aria-label": "Stop opacity", min: 0, max: 100, step: 5, value: pct(stop.opacity ?? 1), onChange: (e) => patchStop({ opacity: Number(e.target.value) / 100 }), className: number }),
|
|
699
827
|
"%"
|
|
700
828
|
] }),
|
|
701
|
-
sel < value.stops.length - 1 && /* @__PURE__ */ (0,
|
|
829
|
+
sel < value.stops.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
702
830
|
"Midpoint",
|
|
703
|
-
/* @__PURE__ */ (0,
|
|
831
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "number", "aria-label": "Stop midpoint", min: 5, max: 95, step: 1, value: pct(stop.midpoint ?? 0.5), onChange: (e) => patchStop({ midpoint: Number(e.target.value) / 100 }), className: number }),
|
|
704
832
|
"%"
|
|
705
833
|
] }),
|
|
706
|
-
/* @__PURE__ */ (0,
|
|
834
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: button2, disabled: value.stops.length <= 2, onClick: () => (setSelected(Math.max(0, sel - 1)), onChange(removePaintGradientStop(value, sel))), children: "Remove stop" })
|
|
707
835
|
] }),
|
|
708
|
-
/* @__PURE__ */ (0,
|
|
709
|
-
/* @__PURE__ */ (0,
|
|
710
|
-
map.by === "distance" && /* @__PURE__ */ (0,
|
|
711
|
-
/* @__PURE__ */ (0,
|
|
712
|
-
/* @__PURE__ */ (0,
|
|
713
|
-
/* @__PURE__ */ (0,
|
|
714
|
-
/* @__PURE__ */ (0,
|
|
836
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-mapping", children: [
|
|
837
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Gradient follows", className: select, value: map.by, onChange: (e) => onChange({ ...value, map: paintGradientMappingFor(e.target.value, map) }), children: PAINT_GRADIENT_MAPPINGS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: m, children: PAINT_GRADIENT_MAPPING_LABELS[m] }, m)) }),
|
|
838
|
+
map.by === "distance" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "number", "aria-label": "Gradient length", min: 1, max: 1e5, value: map.length, onChange: (e) => onChange({ ...value, map: { ...map, length: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
|
|
840
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("select", { "aria-label": "Gradient length unit", className: select, value: map.unit ?? "px", onChange: (e) => onChange({ ...value, map: { ...map, unit: e.target.value } }), children: [
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "px", children: "px" }),
|
|
842
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "dabs", children: "dabs" })
|
|
715
843
|
] })
|
|
716
844
|
] }),
|
|
717
|
-
map.by === "time" && /* @__PURE__ */ (0,
|
|
718
|
-
map.by === "random" && /* @__PURE__ */ (0,
|
|
719
|
-
(map.by === "distance" || map.by === "time") && /* @__PURE__ */ (0,
|
|
845
|
+
map.by === "time" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "number", "aria-label": "Gradient duration", min: 1, max: 6e5, value: map.duration, onChange: (e) => onChange({ ...value, map: { ...map, duration: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
|
|
846
|
+
map.by === "random" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "number", "aria-label": "Dabs per pick", min: 1, max: 500, value: map.every ?? 1, onChange: (e) => onChange({ ...value, map: { ...map, every: Math.max(1, Math.round(Number(e.target.value) || 1)) } }), className: number }),
|
|
847
|
+
(map.by === "distance" || map.by === "time") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Gradient repeat", className: select, value: map.repeat ?? "clamp", onChange: (e) => onChange({ ...value, map: { ...map, repeat: e.target.value } }), children: PAINT_GRADIENT_REPEATS.map((r) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: r, children: PAINT_GRADIENT_REPEAT_LABELS[r] }, r)) })
|
|
720
848
|
] }),
|
|
721
|
-
/* @__PURE__ */ (0,
|
|
722
|
-
/* @__PURE__ */ (0,
|
|
723
|
-
/* @__PURE__ */ (0,
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
850
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Gradient mixing", className: select, value: value.space, onChange: (e) => onChange({ ...value, space: e.target.value }), children: PAINT_GRADIENT_SPACES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: s, children: PAINT_GRADIENT_SPACE_LABELS[s] }, s)) }),
|
|
851
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex flex-1 items-center gap-1", children: [
|
|
724
852
|
"Softness",
|
|
725
|
-
/* @__PURE__ */ (0,
|
|
853
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "range", "aria-label": "Gradient softness", min: 0, max: 1, step: 0.05, value: value.softness ?? 1, onChange: (e) => onChange({ ...value, softness: Number(e.target.value) }), className: "flex-1 accent-indigo-500" })
|
|
726
854
|
] })
|
|
727
855
|
] })
|
|
728
856
|
] });
|
|
729
857
|
};
|
|
730
858
|
|
|
731
859
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
732
|
-
var
|
|
733
|
-
var PaintGradientEditor = (props) => /* @__PURE__ */ (0,
|
|
860
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
861
|
+
var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PaintGradientEditorView, { ...props, kit: import_paint_editor4.PAINT_GRADIENT_KIT });
|
|
734
862
|
|
|
735
863
|
// src/paint-editor/StickerPicker.tsx
|
|
736
|
-
var
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
var
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
(0,
|
|
864
|
+
var import_react9 = require("react");
|
|
865
|
+
|
|
866
|
+
// src/stickers/StickerLibraryPicker.tsx
|
|
867
|
+
var import_react8 = require("react");
|
|
868
|
+
var import_stickers = require("@pixerate/editor/stickers");
|
|
869
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
870
|
+
var StickerLibraryPicker = ({ provider, selected = [], onPick, label = "Stickers", footer, className }) => {
|
|
871
|
+
const browser = (0, import_react8.useMemo)(() => new import_stickers.StickerBrowser(() => provider), [provider]);
|
|
872
|
+
const [, setTick] = (0, import_react8.useState)(0);
|
|
873
|
+
(0, import_react8.useEffect)(() => {
|
|
874
|
+
const off = browser.subscribe(() => setTick((n) => n + 1));
|
|
744
875
|
void browser.refresh();
|
|
745
|
-
return
|
|
746
|
-
}, [browser
|
|
876
|
+
return off;
|
|
877
|
+
}, [browser]);
|
|
747
878
|
const s = browser.state;
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
/* @__PURE__ */ (0,
|
|
752
|
-
|
|
753
|
-
/* @__PURE__ */ (0,
|
|
754
|
-
s.categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: c.id, children: c.name }, c.id))
|
|
879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "sticker-picker", children: [
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
881
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { type: "search", "aria-label": `Search ${label.toLowerCase()}`, placeholder: `Search ${s.provider}`, value: s.query, onChange: (e) => void browser.setQuery(e.target.value), className: "min-w-0 flex-1 rounded bg-slate-800 px-1 py-0.5" }),
|
|
882
|
+
s.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { "aria-label": "Sticker category", value: s.category, onChange: (e) => void browser.setCategory(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: [
|
|
883
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "All" }),
|
|
884
|
+
s.categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: c.id, children: c.name }, c.id))
|
|
755
885
|
] })
|
|
756
886
|
] }),
|
|
757
|
-
/* @__PURE__ */ (0,
|
|
887
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex max-h-32 flex-wrap gap-1 overflow-y-auto", role: "group", "aria-label": label, children: s.items.map((it) => {
|
|
758
888
|
const on = selected.includes(it.ref);
|
|
759
|
-
return /* @__PURE__ */ (0,
|
|
889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
760
890
|
"button",
|
|
761
891
|
{
|
|
762
892
|
type: "button",
|
|
763
893
|
"aria-pressed": on,
|
|
764
|
-
title: `${it.name} (${it.ref}) \xB7 ${it.licence.name}`,
|
|
894
|
+
title: `${it.name} (${it.ref}) \xB7 ${it.licence.name}${it.licence.attribution ? ` \xB7 ${it.licence.attribution}` : ""}`,
|
|
765
895
|
className: `flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
766
|
-
onClick: () => onPick(it
|
|
896
|
+
onClick: () => onPick(it),
|
|
767
897
|
children: [
|
|
768
|
-
it.thumbnail && /* @__PURE__ */ (0,
|
|
898
|
+
it.thumbnail && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: it.thumbnail, alt: "", className: "h-4 w-4" }),
|
|
769
899
|
it.name
|
|
770
900
|
]
|
|
771
901
|
},
|
|
772
902
|
it.ref
|
|
773
903
|
);
|
|
774
904
|
}) }),
|
|
775
|
-
/* @__PURE__ */ (0,
|
|
776
|
-
/* @__PURE__ */ (0,
|
|
777
|
-
s.hasMore && /* @__PURE__ */ (0,
|
|
905
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between text-[10px] text-slate-500", children: [
|
|
906
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: s.loading ? "Loading\u2026" : `${s.items.length} of ${s.total}` }),
|
|
907
|
+
s.hasMore && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "text-indigo-300", onClick: () => void browser.more(), children: "More" })
|
|
778
908
|
] }),
|
|
779
|
-
s.error && /* @__PURE__ */ (0,
|
|
780
|
-
|
|
781
|
-
f.ref,
|
|
782
|
-
": ",
|
|
783
|
-
f.error
|
|
784
|
-
] }, f.ref))
|
|
909
|
+
s.error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: s.error }),
|
|
910
|
+
footer
|
|
785
911
|
] });
|
|
786
912
|
};
|
|
787
913
|
|
|
914
|
+
// src/paint-editor/StickerPicker.tsx
|
|
915
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
916
|
+
var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
917
|
+
const [provider, setProvider] = (0, import_react9.useState)(() => controller.stickersProvider);
|
|
918
|
+
(0, import_react9.useEffect)(() => controller.stickers.subscribe(setProvider), [controller]);
|
|
919
|
+
const failed = selected.map((ref) => ({ ref, ...controller.stickerArtStatus(ref) })).filter((x) => x.status === "failed");
|
|
920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
921
|
+
StickerLibraryPicker,
|
|
922
|
+
{
|
|
923
|
+
provider,
|
|
924
|
+
selected,
|
|
925
|
+
label,
|
|
926
|
+
onPick: (it) => onPick(it.ref),
|
|
927
|
+
footer: failed.map((f) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { role: "alert", className: "text-[11px] text-rose-400", children: [
|
|
928
|
+
f.ref,
|
|
929
|
+
": ",
|
|
930
|
+
f.error
|
|
931
|
+
] }, f.ref))
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
};
|
|
935
|
+
|
|
788
936
|
// src/paint-editor/BrushPanel.tsx
|
|
789
|
-
var
|
|
937
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
790
938
|
var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
791
939
|
const state = usePaintEditorState(controller);
|
|
792
940
|
const [error, attempt] = useAttempt();
|
|
793
|
-
const
|
|
794
|
-
const fileRef = (0, import_react7.useRef)(null);
|
|
941
|
+
const fileRef = (0, import_react10.useRef)(null);
|
|
795
942
|
const { brush, brushes } = state;
|
|
796
943
|
const paper = state.document.paper;
|
|
797
|
-
const thumbs = (0,
|
|
944
|
+
const thumbs = (0, import_react10.useMemo)(
|
|
798
945
|
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: "#26324a" })])),
|
|
799
946
|
// Thumbnails follow the library and the paper.
|
|
800
947
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
801
948
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
802
949
|
);
|
|
803
|
-
const
|
|
804
|
-
const
|
|
950
|
+
const entries = (0, import_react10.useMemo)(() => brushes.map((b) => ({ brush: controller.getBrushSpec(b.id), builtin: Boolean(b.builtin) })), [controller, brushes]);
|
|
951
|
+
const spec = (0, import_react10.useMemo)(() => controller.getBrushSpec(), [controller, brush]);
|
|
952
|
+
const own = typeof spec.colour?.default === "string" && /^#[0-9a-f]{6}/i.test(spec.colour.default) ? spec.colour.default.slice(0, 7) : void 0;
|
|
953
|
+
const preview = (0, import_react10.useMemo)(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
|
|
954
|
+
const carried = (0, import_paint_editor5.brushLoadColor)(state.mixerLoad);
|
|
805
955
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
956
|
+
const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
|
|
957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
|
|
959
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
960
|
+
BrushEditor,
|
|
809
961
|
{
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
] }),
|
|
842
|
-
engine && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-engine", children: [
|
|
843
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-medium text-slate-300", children: engine.title }),
|
|
844
|
-
engine.wetTool && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
845
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Wet tool" }),
|
|
846
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Wet tool", value: brush.wet.tool, onChange: (e) => controller.setBrush({ wet: { tool: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.WET_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: t, children: import_paint_editor6.WET_TOOL_LABELS[t] }, t)) })
|
|
847
|
-
] }),
|
|
848
|
-
engine.wetTool && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
849
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Medium" }),
|
|
850
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Wet medium", value: brush.wet.medium, onChange: (e) => controller.setBrush({ wet: { medium: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.WET_MEDIA.map((m) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: m, children: import_paint_editor6.WET_MEDIUM_LABELS[m] }, m)) })
|
|
851
|
-
] }),
|
|
852
|
-
engine.particleMenus && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
853
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
854
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Particles" }),
|
|
855
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Particle kind", value: brush.particle.kind, onChange: (e) => controller.setBrush({ particle: { kind: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.PARTICLE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.PARTICLE_KIND_LABELS[k] }, k)) })
|
|
856
|
-
] }),
|
|
857
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
858
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Drawn as" }),
|
|
859
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Particle render", value: brush.particle.render, onChange: (e) => controller.setBrush({ particle: { render: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.PARTICLE_RENDERS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.PARTICLE_RENDER_LABELS[k] }, k)) })
|
|
860
|
-
] }),
|
|
861
|
-
brush.particle.render === "ribbon" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
862
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Ribbon joins" }),
|
|
863
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Ribbon pairs", value: brush.particle.ribbonPairs, onChange: (e) => controller.setBrush({ particle: { ribbonPairs: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.RIBBON_PAIRS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.RIBBON_PAIR_LABELS[k] }, k)) })
|
|
864
|
-
] }),
|
|
865
|
-
(brush.particle.render === "dot" || brush.particle.render === "sequence") && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
866
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": "Dot textures", title: "Stamps drawn instead of round dots (up to 4; none: round)", children: import_paint_editor6.STAMP_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
867
|
-
"button",
|
|
868
|
-
{
|
|
869
|
-
type: "button",
|
|
870
|
-
"aria-pressed": brush.particle.dotTextures.includes(k),
|
|
871
|
-
className: `px-1.5 py-0.5 rounded text-[10px] ${brush.particle.dotTextures.includes(k) ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
872
|
-
onClick: () => controller.setBrush({ particle: { dotTextures: (0, import_paint_editor6.toggleDotTexture)(brush.particle.dotTextures, k) } }),
|
|
873
|
-
children: import_paint_editor6.STAMP_LABELS[k]
|
|
874
|
-
},
|
|
875
|
-
k
|
|
876
|
-
)) }),
|
|
877
|
-
brush.particle.dotTextures.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
878
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
879
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Texture order" }),
|
|
880
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Dot texture order", value: brush.particle.dotTextureOrder, onChange: (e) => controller.setBrush({ particle: { dotTextureOrder: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.DOT_TEXTURE_ORDERS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.DOT_TEXTURE_ORDER_LABELS[k] }, k)) })
|
|
881
|
-
] }),
|
|
882
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
883
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Texture turn" }),
|
|
884
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Dot rotation", value: brush.particle.dotRotation, onChange: (e) => controller.setBrush({ particle: { dotRotation: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.DOT_ROTATIONS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.DOT_ROTATION_LABELS[k] }, k)) })
|
|
885
|
-
] })
|
|
886
|
-
] })
|
|
887
|
-
] })
|
|
888
|
-
] }),
|
|
889
|
-
engine.stickerStamps && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: (0, import_paint_editor6.toggleStickerRef)(brush.sticker.stamps, ref) } }) }),
|
|
890
|
-
engine.impastoTool && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
891
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Tool" }),
|
|
892
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Impasto tool", value: brush.impasto.tool, onChange: (e) => controller.setBrush({ impasto: { tool: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.IMPASTO_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: t, children: import_paint_editor6.IMPASTO_TOOL_LABELS[t] }, t)) })
|
|
893
|
-
] }),
|
|
894
|
-
engine.sliders.map((c) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor6.readPath)(brush, c.path), onChange: (v) => controller.setBrush((0, import_paint_editor6.patchPath)(brush, c.path, v)) }, c.path)),
|
|
895
|
-
engine.mixingPath && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
896
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Mixing" }),
|
|
897
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
898
|
-
"select",
|
|
899
|
-
{
|
|
900
|
-
"aria-label": "Brush mixing",
|
|
901
|
-
value: engine.mixingPath === "blender.mixing" ? brush.blender.mixing : engine.mixingPath === "smudge.mixing" ? brush.smudge.mixing : brush.behavior.mixing,
|
|
902
|
-
onChange: (e) => controller.setBrush((0, import_paint_editor6.patchBrushValue)(brush, engine.mixingPath, e.target.value)),
|
|
903
|
-
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
904
|
-
children: [
|
|
905
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "pigment", children: "Pigment" }),
|
|
906
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "rgb", children: "RGB" })
|
|
907
|
-
]
|
|
908
|
-
}
|
|
909
|
-
)
|
|
910
|
-
] }),
|
|
911
|
-
engine.light && brush.light.amount > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center gap-2", title: "Pressure scales the light the brush lays", children: [
|
|
912
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "checkbox", "aria-label": "Light follows pressure", checked: brush.light.pressure, onChange: (e) => controller.setBrush({ light: { pressure: e.target.checked } }) }),
|
|
913
|
-
" Light follows pressure"
|
|
914
|
-
] }),
|
|
915
|
-
engine.dirty && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center gap-2", title: "Keep the colour the brush picked up for the next stroke (needs Pick-up above 0)", children: [
|
|
916
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "checkbox", "aria-label": "Dirty brush", checked: brush.behavior.dirty, onChange: (e) => controller.setBrush({ behavior: { dirty: e.target.checked } }) }),
|
|
917
|
-
" Dirty brush"
|
|
918
|
-
] }),
|
|
919
|
-
(0, import_paint_editor6.brushTakesPaint)(brush) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
|
|
920
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
921
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", title: "A gradient of the brush's own, used instead of the paint (the multi-colour brush)", children: "Brush gradient" }),
|
|
922
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
923
|
-
"button",
|
|
924
|
-
{
|
|
925
|
-
type: "button",
|
|
926
|
-
"aria-pressed": brush.paint !== null,
|
|
927
|
-
className: chip(brush.paint !== null),
|
|
928
|
-
onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : import_paint_editor7.DEFAULT_PAINT_GRADIENT })),
|
|
929
|
-
children: brush.paint ? "On" : "Off"
|
|
930
|
-
}
|
|
931
|
-
)
|
|
932
|
-
] }),
|
|
933
|
-
brush.paint && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
|
|
934
|
-
] }),
|
|
935
|
-
engine.load && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
936
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Carries" }),
|
|
937
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
938
|
-
brush.engine === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
939
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
940
|
-
] })
|
|
941
|
-
] }),
|
|
942
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
943
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { value: saveName, placeholder: "Brush name", "aria-label": "Brush name", onChange: (e) => setSaveName(e.target.value), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
944
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: button, disabled: !saveName.trim(), onClick: () => attempt(() => (controller.saveBrush({ id: slug(saveName), name: saveName.trim() }), setSaveName(""))), children: "Save brush" }),
|
|
945
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (0, import_paint_editor6.downloadBytes)(JSON.stringify(controller.exportBrushes(), null, 2), "brushes.json", "application/json")), children: "Export" }),
|
|
946
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: button, onClick: () => fileRef.current?.click(), children: "Import\u2026" }),
|
|
947
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
962
|
+
brush: spec,
|
|
963
|
+
profile: import_brushes3.PAINT_PROFILE,
|
|
964
|
+
preview,
|
|
965
|
+
onChange: (next) => attempt(() => controller.setBrushSpec(next)),
|
|
966
|
+
onSaveAs: (name) => controller.saveBrush({ id: slug(name), name }),
|
|
967
|
+
renderExtra: (section) => {
|
|
968
|
+
if (section === "shape" && brush.engine === "sticker")
|
|
969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: (0, import_paint_editor5.toggleStickerRef)(brush.sticker.stamps, ref) } }) });
|
|
970
|
+
if (section === "behaviour" && loads)
|
|
971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
972
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-slate-400", children: "Carries" }),
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
974
|
+
brush.engine === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
975
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
976
|
+
] });
|
|
977
|
+
if (section === "colour" && (0, import_paint_editor5.brushTakesPaint)(brush))
|
|
978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-slate-400", title: "A gradient of the brush's own, used instead of the paint (the multi-colour brush)", children: "Brush gradient" }),
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-pressed": brush.paint !== null, className: chip(brush.paint !== null), onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : import_paint_editor5.DEFAULT_PAINT_GRADIENT })), children: brush.paint ? "On" : "Off" })
|
|
982
|
+
] }),
|
|
983
|
+
brush.paint && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
|
|
984
|
+
] });
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
),
|
|
989
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
990
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => attempt(async () => (0, import_paint_editor5.downloadBytes)(JSON.stringify(await controller.exportBrushes(), null, 2), "brushes.json", "application/json")), children: "Export" }),
|
|
991
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => fileRef.current?.click(), children: "Import\u2026" }),
|
|
992
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
948
993
|
"input",
|
|
949
994
|
{
|
|
950
995
|
ref: fileRef,
|
|
@@ -960,24 +1005,24 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
960
1005
|
}
|
|
961
1006
|
)
|
|
962
1007
|
] }),
|
|
963
|
-
/* @__PURE__ */ (0,
|
|
1008
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ErrorLine, { error })
|
|
964
1009
|
] });
|
|
965
1010
|
};
|
|
966
1011
|
|
|
967
1012
|
// src/paint-editor/PaperPanel.tsx
|
|
968
|
-
var
|
|
969
|
-
var
|
|
970
|
-
var
|
|
1013
|
+
var import_react11 = require("react");
|
|
1014
|
+
var import_paint_editor6 = require("@pixerate/editor/paint-editor");
|
|
1015
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
971
1016
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
972
1017
|
var PaperPanel = ({ controller, className }) => {
|
|
973
1018
|
const state = usePaintEditorState(controller);
|
|
974
1019
|
const [error, attempt] = useAttempt();
|
|
975
1020
|
const paper = state.document.paper;
|
|
976
|
-
const previews = (0,
|
|
977
|
-
return /* @__PURE__ */ (0,
|
|
978
|
-
|
|
979
|
-
/* @__PURE__ */ (0,
|
|
980
|
-
/* @__PURE__ */ (0,
|
|
1021
|
+
const previews = (0, import_react11.useMemo)(() => new Map(import_paint_editor6.PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: (0, import_paint_editor6.renderPaper)({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
1022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
1023
|
+
import_paint_editor6.PAPER_FAMILIES.map((family) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
|
|
1024
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
1025
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: import_paint_editor6.PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
981
1026
|
"button",
|
|
982
1027
|
{
|
|
983
1028
|
type: "button",
|
|
@@ -986,98 +1031,98 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
986
1031
|
title: p.name,
|
|
987
1032
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
988
1033
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
989
|
-
children: /* @__PURE__ */ (0,
|
|
1034
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
990
1035
|
},
|
|
991
1036
|
p.preset
|
|
992
1037
|
)) })
|
|
993
1038
|
] }, family)),
|
|
994
|
-
/* @__PURE__ */ (0,
|
|
995
|
-
/* @__PURE__ */ (0,
|
|
996
|
-
/* @__PURE__ */ (0,
|
|
997
|
-
/* @__PURE__ */ (0,
|
|
1039
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "text-slate-300", children: paper.name }),
|
|
1040
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1041
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
998
1043
|
] }),
|
|
999
|
-
|
|
1000
|
-
/* @__PURE__ */ (0,
|
|
1001
|
-
/* @__PURE__ */ (0,
|
|
1002
|
-
/* @__PURE__ */ (0,
|
|
1044
|
+
import_paint_editor6.PAPER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor6.readPath)(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper((0, import_paint_editor6.patchPath)(paper, c.path, v))) }, c.path)),
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
1047
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CommitColorInput, { label: "Backlight colour", value: paper.backlightColor ?? import_paint_editor6.DEFAULT_BACKLIGHT_COLOR, onCommit: (v) => attempt(() => controller.setPaper({ backlightColor: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1003
1048
|
] }),
|
|
1004
|
-
/* @__PURE__ */ (0,
|
|
1005
|
-
/* @__PURE__ */ (0,
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1050
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
1006
1051
|
" Mirror tiling"
|
|
1007
1052
|
] }),
|
|
1008
|
-
/* @__PURE__ */ (0,
|
|
1009
|
-
/* @__PURE__ */ (0,
|
|
1010
|
-
/* @__PURE__ */ (0,
|
|
1011
|
-
|
|
1012
|
-
/* @__PURE__ */ (0,
|
|
1053
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.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" }),
|
|
1054
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
1055
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
1056
|
+
import_paint_editor6.LIGHT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor6.readPath)(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.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" })
|
|
1013
1058
|
] }),
|
|
1014
|
-
/* @__PURE__ */ (0,
|
|
1059
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ErrorLine, { error })
|
|
1015
1060
|
] });
|
|
1016
1061
|
};
|
|
1017
1062
|
|
|
1018
1063
|
// src/paint-editor/ColorPanel.tsx
|
|
1019
|
-
var
|
|
1020
|
-
var
|
|
1021
|
-
var
|
|
1022
|
-
var
|
|
1064
|
+
var import_react12 = require("react");
|
|
1065
|
+
var import_paint_editor7 = require("@pixerate/editor/paint-editor");
|
|
1066
|
+
var import_paint_editor8 = require("@pixerate/editor/paint-editor");
|
|
1067
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1023
1068
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
1024
1069
|
const state = usePaintEditorState(controller);
|
|
1025
1070
|
const [error, attempt] = useAttempt();
|
|
1026
|
-
const [wheel, setWheel] = (0,
|
|
1027
|
-
const [kind, setKind] = (0,
|
|
1028
|
-
const [padTool, setPadTool] = (0,
|
|
1029
|
-
const [sample, setSample] = (0,
|
|
1030
|
-
const [parts, setParts] = (0,
|
|
1031
|
-
const [padName, setPadName] = (0,
|
|
1032
|
-
const padPoints = (0,
|
|
1033
|
-
const ring = (0,
|
|
1071
|
+
const [wheel, setWheel] = (0, import_react12.useState)("ryb");
|
|
1072
|
+
const [kind, setKind] = (0, import_react12.useState)("complementary");
|
|
1073
|
+
const [padTool, setPadTool] = (0, import_react12.useState)("paint");
|
|
1074
|
+
const [sample, setSample] = (0, import_react12.useState)(3);
|
|
1075
|
+
const [parts, setParts] = (0, import_react12.useState)([1, 1]);
|
|
1076
|
+
const [padName, setPadName] = (0, import_react12.useState)("");
|
|
1077
|
+
const padPoints = (0, import_react12.useRef)(null);
|
|
1078
|
+
const ring = (0, import_react12.useMemo)(() => (0, import_paint_editor7.renderColorWheel)(wheelSize, wheel), [wheelSize, wheel]);
|
|
1034
1079
|
const color = state.color;
|
|
1035
|
-
const harmony = (0,
|
|
1036
|
-
const [r, g, b] = (0,
|
|
1037
|
-
const hsv = (0,
|
|
1038
|
-
const effectWell = (0,
|
|
1039
|
-
const pad = (0,
|
|
1080
|
+
const harmony = (0, import_react12.useMemo)(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
1081
|
+
const [r, g, b] = (0, import_paint_editor7.parseHexColor)(color);
|
|
1082
|
+
const hsv = (0, import_paint_editor7.rgbToHsv)(r, g, b);
|
|
1083
|
+
const effectWell = (0, import_react12.useMemo)(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
1084
|
+
const pad = (0, import_react12.useMemo)(() => ({ width: import_paint_editor7.MIXING_PAD_WIDTH, height: import_paint_editor7.MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
1040
1085
|
const R = wheelSize / 2;
|
|
1041
1086
|
const mid = R * 0.82;
|
|
1042
|
-
const setHsv = (s, v) => controller.setColor((0,
|
|
1087
|
+
const setHsv = (s, v) => controller.setColor((0, import_paint_editor7.rgbToHexColor)(...(0, import_paint_editor7.hsvToRgb)(hsv.h, s, v)));
|
|
1043
1088
|
const padPoint = (e) => {
|
|
1044
1089
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1045
|
-
const kx =
|
|
1046
|
-
const ky =
|
|
1047
|
-
const x = Math.min(
|
|
1048
|
-
const y = Math.min(
|
|
1090
|
+
const kx = import_paint_editor7.MIXING_PAD_WIDTH / (rect.width || import_paint_editor7.MIXING_PAD_WIDTH);
|
|
1091
|
+
const ky = import_paint_editor7.MIXING_PAD_HEIGHT / (rect.height || import_paint_editor7.MIXING_PAD_HEIGHT);
|
|
1092
|
+
const x = Math.min(import_paint_editor7.MIXING_PAD_WIDTH, Math.max(0, (e.clientX - rect.left) * kx));
|
|
1093
|
+
const y = Math.min(import_paint_editor7.MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
1049
1094
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
1050
1095
|
};
|
|
1051
|
-
return /* @__PURE__ */ (0,
|
|
1052
|
-
/* @__PURE__ */ (0,
|
|
1053
|
-
/* @__PURE__ */ (0,
|
|
1096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
1098
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1054
1099
|
"div",
|
|
1055
1100
|
{
|
|
1056
1101
|
role: "slider",
|
|
1057
1102
|
"aria-label": "Hue wheel",
|
|
1058
1103
|
"aria-valuemin": 0,
|
|
1059
1104
|
"aria-valuemax": 360,
|
|
1060
|
-
"aria-valuenow": Math.round((0,
|
|
1105
|
+
"aria-valuenow": Math.round((0, import_paint_editor7.hueToWheel)(hsv.h, wheel)),
|
|
1061
1106
|
tabIndex: 0,
|
|
1062
1107
|
className: "absolute inset-0 cursor-crosshair",
|
|
1063
1108
|
onPointerDown: (e) => {
|
|
1064
1109
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1065
|
-
controller.setColor((0,
|
|
1110
|
+
controller.setColor((0, import_paint_editor7.wheelPick)(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
1066
1111
|
},
|
|
1067
|
-
children: /* @__PURE__ */ (0,
|
|
1112
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
1068
1113
|
}
|
|
1069
1114
|
),
|
|
1070
|
-
/* @__PURE__ */ (0,
|
|
1071
|
-
const p = (0,
|
|
1072
|
-
return /* @__PURE__ */ (0,
|
|
1115
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
1116
|
+
const p = (0, import_paint_editor7.wheelPoint)(h.angle, mid);
|
|
1117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.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);
|
|
1073
1118
|
}) }),
|
|
1074
|
-
/* @__PURE__ */ (0,
|
|
1119
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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 } })
|
|
1075
1120
|
] }),
|
|
1076
|
-
/* @__PURE__ */ (0,
|
|
1077
|
-
/* @__PURE__ */ (0,
|
|
1078
|
-
/* @__PURE__ */ (0,
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1080
|
-
/* @__PURE__ */ (0,
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1122
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" }),
|
|
1123
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" }),
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1081
1126
|
"input",
|
|
1082
1127
|
{
|
|
1083
1128
|
"aria-label": "Hex colour",
|
|
@@ -1088,49 +1133,49 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1088
1133
|
color
|
|
1089
1134
|
)
|
|
1090
1135
|
] }),
|
|
1091
|
-
/* @__PURE__ */ (0,
|
|
1092
|
-
/* @__PURE__ */ (0,
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
1137
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1093
1138
|
"span",
|
|
1094
1139
|
{
|
|
1095
1140
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
1096
1141
|
"aria-label": state.effectPaint ? `Effect paint: ${state.effectPaint.effect}` : state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
|
|
1097
1142
|
"data-testid": "paint-well",
|
|
1098
1143
|
"data-effect-paint": state.effectPaint ? state.effectPaint.effect : void 0,
|
|
1099
|
-
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0,
|
|
1144
|
+
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0, import_paint_editor8.paintSourceCss)(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1100
1145
|
}
|
|
1101
1146
|
),
|
|
1102
|
-
/* @__PURE__ */ (0,
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1103
1148
|
"button",
|
|
1104
1149
|
{
|
|
1105
1150
|
type: "button",
|
|
1106
1151
|
className: chip(state.paint.type === "gradient"),
|
|
1107
1152
|
"aria-pressed": state.paint.type === "gradient",
|
|
1108
1153
|
title: "Paint that changes colour as the stroke goes",
|
|
1109
|
-
onClick: () => attempt(() => state.paint.type === "gradient" ? controller.setColor(color) : controller.setPaint(
|
|
1154
|
+
onClick: () => attempt(() => state.paint.type === "gradient" ? controller.setColor(color) : controller.setPaint(import_paint_editor8.DEFAULT_PAINT_GRADIENT)),
|
|
1110
1155
|
children: "Gradient"
|
|
1111
1156
|
}
|
|
1112
1157
|
)
|
|
1113
1158
|
] }),
|
|
1114
|
-
state.paint.type === "gradient" && /* @__PURE__ */ (0,
|
|
1115
|
-
/* @__PURE__ */ (0,
|
|
1116
|
-
/* @__PURE__ */ (0,
|
|
1117
|
-
/* @__PURE__ */ (0,
|
|
1159
|
+
state.paint.type === "gradient" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
1160
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1161
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
1162
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" })
|
|
1118
1163
|
] }),
|
|
1119
|
-
/* @__PURE__ */ (0,
|
|
1120
|
-
/* @__PURE__ */ (0,
|
|
1121
|
-
/* @__PURE__ */ (0,
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
1166
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" })
|
|
1122
1167
|
] }),
|
|
1123
|
-
/* @__PURE__ */ (0,
|
|
1124
|
-
/* @__PURE__ */ (0,
|
|
1125
|
-
/* @__PURE__ */ (0,
|
|
1126
|
-
/* @__PURE__ */ (0,
|
|
1168
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1169
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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_editor7.HARMONY_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: k, children: k }, k)) }),
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
1171
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1127
1172
|
] }),
|
|
1128
|
-
/* @__PURE__ */ (0,
|
|
1129
|
-
harmony.map((h, i) => /* @__PURE__ */ (0,
|
|
1130
|
-
/* @__PURE__ */ (0,
|
|
1173
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
1174
|
+
harmony.map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime12.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)),
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1131
1176
|
] }),
|
|
1132
|
-
/* @__PURE__ */ (0,
|
|
1133
|
-
state.swatches.map((s, i) => /* @__PURE__ */ (0,
|
|
1177
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
1178
|
+
state.swatches.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1134
1179
|
"button",
|
|
1135
1180
|
{
|
|
1136
1181
|
type: "button",
|
|
@@ -1139,7 +1184,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1139
1184
|
"aria-label": s.name ?? (s.paint ? "Gradient" : s.color),
|
|
1140
1185
|
title: `${s.name ?? (s.paint ? "Gradient" : s.color)} (right-click to remove)`,
|
|
1141
1186
|
className: "h-5 w-5 rounded ring-1 ring-slate-700",
|
|
1142
|
-
style: { background: s.paint ? (0,
|
|
1187
|
+
style: { background: s.paint ? (0, import_paint_editor8.paintSourceCss)(s.paint, { paint: color, secondary: state.secondaryColor }) : s.color },
|
|
1143
1188
|
onClick: () => attempt(() => s.paint ? controller.setPaint(s.paint) : controller.setColor(s.color)),
|
|
1144
1189
|
onContextMenu: (e) => {
|
|
1145
1190
|
e.preventDefault();
|
|
@@ -1148,15 +1193,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1148
1193
|
},
|
|
1149
1194
|
i
|
|
1150
1195
|
)),
|
|
1151
|
-
/* @__PURE__ */ (0,
|
|
1196
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1152
1197
|
] }),
|
|
1153
|
-
mixingPad && /* @__PURE__ */ (0,
|
|
1154
|
-
/* @__PURE__ */ (0,
|
|
1155
|
-
/* @__PURE__ */ (0,
|
|
1156
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0,
|
|
1157
|
-
/* @__PURE__ */ (0,
|
|
1198
|
+
mixingPad && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1199
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1200
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1201
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
1202
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1158
1203
|
] }),
|
|
1159
|
-
/* @__PURE__ */ (0,
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1160
1205
|
"div",
|
|
1161
1206
|
{
|
|
1162
1207
|
role: "application",
|
|
@@ -1165,7 +1210,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1165
1210
|
onPointerDown: (e) => {
|
|
1166
1211
|
const p = padPoint(e);
|
|
1167
1212
|
if (padTool === "pick") {
|
|
1168
|
-
attempt(() => controller.mixingPadPick(p.x, p.y, { setColor: true, radius: (0,
|
|
1213
|
+
attempt(() => controller.mixingPadPick(p.x, p.y, { setColor: true, radius: (0, import_paint_editor7.padSampleRadius)(sample) }));
|
|
1169
1214
|
return;
|
|
1170
1215
|
}
|
|
1171
1216
|
padPoints.current = [p];
|
|
@@ -1177,20 +1222,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1177
1222
|
padPoints.current = null;
|
|
1178
1223
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1179
1224
|
},
|
|
1180
|
-
children: /* @__PURE__ */ (0,
|
|
1225
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${import_paint_editor7.MIXING_PAD_WIDTH} / ${import_paint_editor7.MIXING_PAD_HEIGHT}` } })
|
|
1181
1226
|
}
|
|
1182
1227
|
),
|
|
1183
|
-
/* @__PURE__ */ (0,
|
|
1184
|
-
/* @__PURE__ */ (0,
|
|
1185
|
-
/* @__PURE__ */ (0,
|
|
1228
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
1229
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Sample" }),
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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_editor7.PAD_SAMPLE_SIZES.map((n) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1186
1231
|
] }) }),
|
|
1187
|
-
/* @__PURE__ */ (0,
|
|
1188
|
-
/* @__PURE__ */ (0,
|
|
1189
|
-
/* @__PURE__ */ (0,
|
|
1190
|
-
/* @__PURE__ */ (0,
|
|
1191
|
-
/* @__PURE__ */ (0,
|
|
1192
|
-
/* @__PURE__ */ (0,
|
|
1193
|
-
/* @__PURE__ */ (0,
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1233
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1234
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" }),
|
|
1235
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-500", children: ":" }),
|
|
1236
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" }),
|
|
1237
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1238
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1194
1239
|
"button",
|
|
1195
1240
|
{
|
|
1196
1241
|
type: "button",
|
|
@@ -1209,25 +1254,25 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1209
1254
|
}
|
|
1210
1255
|
)
|
|
1211
1256
|
] }),
|
|
1212
|
-
/* @__PURE__ */ (0,
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1214
|
-
/* @__PURE__ */ (0,
|
|
1257
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1258
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" }),
|
|
1259
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1215
1260
|
] }),
|
|
1216
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0,
|
|
1217
|
-
/* @__PURE__ */ (0,
|
|
1218
|
-
/* @__PURE__ */ (0,
|
|
1261
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { className: "flex items-center gap-1", children: [
|
|
1262
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1219
1264
|
] }, p.id)) })
|
|
1220
1265
|
] }),
|
|
1221
|
-
/* @__PURE__ */ (0,
|
|
1266
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorLine, { error })
|
|
1222
1267
|
] });
|
|
1223
1268
|
};
|
|
1224
1269
|
|
|
1225
1270
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1226
|
-
var
|
|
1227
|
-
var
|
|
1271
|
+
var import_react15 = require("react");
|
|
1272
|
+
var import_paint_editor9 = require("@pixerate/editor/paint-editor");
|
|
1228
1273
|
|
|
1229
1274
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
1230
|
-
var
|
|
1275
|
+
var import_react14 = require("react");
|
|
1231
1276
|
var import_raster = require("@pixerate/editor/raster");
|
|
1232
1277
|
|
|
1233
1278
|
// src/image-editor/styles.ts
|
|
@@ -1236,17 +1281,17 @@ var imageSelectClass = "rounded border border-input bg-background px-1.5 py-1 te
|
|
|
1236
1281
|
var imageColorInputClass = "h-6 w-8 rounded border border-border bg-transparent";
|
|
1237
1282
|
|
|
1238
1283
|
// src/image-editor/controls/controls.tsx
|
|
1239
|
-
var
|
|
1240
|
-
var
|
|
1241
|
-
var ControlsContext = (0,
|
|
1284
|
+
var import_react13 = require("react");
|
|
1285
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1286
|
+
var ControlsContext = (0, import_react13.createContext)({});
|
|
1242
1287
|
function useImageEditorControls() {
|
|
1243
|
-
return (0,
|
|
1288
|
+
return (0, import_react13.useContext)(ControlsContext);
|
|
1244
1289
|
}
|
|
1245
1290
|
function ImageCheckbox(props) {
|
|
1246
1291
|
const Host = useImageEditorControls().Checkbox;
|
|
1247
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1292
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Host, { ...props });
|
|
1248
1293
|
const { checked, label, disabled, onChange, className = "" } = props;
|
|
1249
|
-
return /* @__PURE__ */ (0,
|
|
1294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1250
1295
|
"input",
|
|
1251
1296
|
{
|
|
1252
1297
|
type: "checkbox",
|
|
@@ -1260,9 +1305,9 @@ function ImageCheckbox(props) {
|
|
|
1260
1305
|
}
|
|
1261
1306
|
function ImageRange(props) {
|
|
1262
1307
|
const Host = useImageEditorControls().Range;
|
|
1263
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1308
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Host, { ...props });
|
|
1264
1309
|
const { value, min, max, step, label, disabled, onChange, onStart, onEnd, className = "" } = props;
|
|
1265
|
-
return /* @__PURE__ */ (0,
|
|
1310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1266
1311
|
"input",
|
|
1267
1312
|
{
|
|
1268
1313
|
type: "range",
|
|
@@ -1283,18 +1328,18 @@ function ImageRange(props) {
|
|
|
1283
1328
|
}
|
|
1284
1329
|
function ImageSelect(props) {
|
|
1285
1330
|
const Host = useImageEditorControls().Select;
|
|
1286
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1331
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Host, { ...props });
|
|
1287
1332
|
const { value, options, label, placeholder, disabled, onChange, className = "" } = props;
|
|
1288
|
-
return /* @__PURE__ */ (0,
|
|
1289
|
-
placeholder !== void 0 && /* @__PURE__ */ (0,
|
|
1290
|
-
options.map((o) => /* @__PURE__ */ (0,
|
|
1333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { "aria-label": label, value, disabled, onChange: (e) => onChange(e.target.value), className: `${imageSelectClass} ${className}`, children: [
|
|
1334
|
+
placeholder !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: placeholder }),
|
|
1335
|
+
options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: o.value, children: o.label }, o.value))
|
|
1291
1336
|
] });
|
|
1292
1337
|
}
|
|
1293
1338
|
function ImageColor(props) {
|
|
1294
1339
|
const Host = useImageEditorControls().Color;
|
|
1295
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1340
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Host, { ...props });
|
|
1296
1341
|
const { value, label, alpha, disabled, onChange, className = "" } = props;
|
|
1297
|
-
return /* @__PURE__ */ (0,
|
|
1342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1298
1343
|
"input",
|
|
1299
1344
|
{
|
|
1300
1345
|
type: "color",
|
|
@@ -1308,13 +1353,13 @@ function ImageColor(props) {
|
|
|
1308
1353
|
}
|
|
1309
1354
|
|
|
1310
1355
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
1311
|
-
var
|
|
1356
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1312
1357
|
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
1313
|
-
const [, setTick] = (0,
|
|
1314
|
-
(0,
|
|
1315
|
-
const [open, setOpen] = (0,
|
|
1316
|
-
const [error, setError] = (0,
|
|
1317
|
-
const commitNext = (0,
|
|
1358
|
+
const [, setTick] = (0, import_react14.useState)(0);
|
|
1359
|
+
(0, import_react14.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
1360
|
+
const [open, setOpen] = (0, import_react14.useState)(null);
|
|
1361
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1362
|
+
const commitNext = (0, import_react14.useRef)(true);
|
|
1318
1363
|
const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
|
|
1319
1364
|
const model = (0, import_raster.layerEffectsPanel)(layer);
|
|
1320
1365
|
const id = layer?.id;
|
|
@@ -1327,7 +1372,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1327
1372
|
}
|
|
1328
1373
|
};
|
|
1329
1374
|
if (!model.available || !id) {
|
|
1330
|
-
return /* @__PURE__ */ (0,
|
|
1375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: `text-xs text-muted-foreground ${className ?? ""}`, "data-testid": "layer-effects", children: model.reason });
|
|
1331
1376
|
}
|
|
1332
1377
|
const effects = controller.getLayerEffects(id);
|
|
1333
1378
|
const patterns = controller.getDocumentPatterns();
|
|
@@ -1342,14 +1387,14 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1342
1387
|
case "range": {
|
|
1343
1388
|
const k = c.percent ? 100 : 1;
|
|
1344
1389
|
const shown = Math.round(c.value * k * 100) / 100;
|
|
1345
|
-
return /* @__PURE__ */ (0,
|
|
1346
|
-
/* @__PURE__ */ (0,
|
|
1390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
|
|
1391
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
1347
1392
|
label,
|
|
1348
1393
|
" ",
|
|
1349
1394
|
shown,
|
|
1350
1395
|
c.unit
|
|
1351
1396
|
] }),
|
|
1352
|
-
/* @__PURE__ */ (0,
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1353
1398
|
ImageRange,
|
|
1354
1399
|
{
|
|
1355
1400
|
label,
|
|
@@ -1366,19 +1411,19 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1366
1411
|
] }, c.key);
|
|
1367
1412
|
}
|
|
1368
1413
|
case "color":
|
|
1369
|
-
return /* @__PURE__ */ (0,
|
|
1370
|
-
/* @__PURE__ */ (0,
|
|
1414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
|
|
1415
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ImageColor, { label, value: c.value, disabled: model.readOnly, onChange: (v) => change(effectId, c, v) }),
|
|
1371
1416
|
label
|
|
1372
1417
|
] }, c.key);
|
|
1373
1418
|
case "checkbox":
|
|
1374
|
-
return /* @__PURE__ */ (0,
|
|
1375
|
-
/* @__PURE__ */ (0,
|
|
1419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
|
|
1420
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ImageCheckbox, { label, checked: c.value, disabled: model.readOnly, onChange: (on) => change(effectId, c, on) }),
|
|
1376
1421
|
label
|
|
1377
1422
|
] }, c.key);
|
|
1378
1423
|
case "select":
|
|
1379
|
-
return /* @__PURE__ */ (0,
|
|
1380
|
-
/* @__PURE__ */ (0,
|
|
1381
|
-
/* @__PURE__ */ (0,
|
|
1424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-muted-foreground", children: label }),
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1382
1427
|
ImageSelect,
|
|
1383
1428
|
{
|
|
1384
1429
|
label,
|
|
@@ -1391,16 +1436,16 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1391
1436
|
] }, c.key);
|
|
1392
1437
|
}
|
|
1393
1438
|
};
|
|
1394
|
-
return /* @__PURE__ */ (0,
|
|
1395
|
-
/* @__PURE__ */ (0,
|
|
1396
|
-
/* @__PURE__ */ (0,
|
|
1397
|
-
/* @__PURE__ */ (0,
|
|
1398
|
-
/* @__PURE__ */ (0,
|
|
1439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.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: [
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1441
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "font-semibold text-foreground", children: heading ? "Layer Style" : "Styles" }),
|
|
1442
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1 text-foreground", children: [
|
|
1443
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ImageCheckbox, { label: "Effects on", checked: model.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.setLayerEffectsEnabled(id, on)) }),
|
|
1399
1444
|
"On"
|
|
1400
1445
|
] }),
|
|
1401
|
-
/* @__PURE__ */ (0,
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
1402
1447
|
"Scale",
|
|
1403
|
-
/* @__PURE__ */ (0,
|
|
1448
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1404
1449
|
"input",
|
|
1405
1450
|
{
|
|
1406
1451
|
type: "number",
|
|
@@ -1419,7 +1464,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1419
1464
|
),
|
|
1420
1465
|
"%"
|
|
1421
1466
|
] }),
|
|
1422
|
-
heading && /* @__PURE__ */ (0,
|
|
1467
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1423
1468
|
ImageSelect,
|
|
1424
1469
|
{
|
|
1425
1470
|
label: "Add style",
|
|
@@ -1435,14 +1480,14 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1435
1480
|
}
|
|
1436
1481
|
)
|
|
1437
1482
|
] }),
|
|
1438
|
-
model.readOnly && model.reason && /* @__PURE__ */ (0,
|
|
1439
|
-
/* @__PURE__ */ (0,
|
|
1483
|
+
model.readOnly && model.reason && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-muted-foreground", children: model.reason }),
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { className: "flex flex-col gap-1", "aria-label": "Effects", children: model.rows.map((row) => {
|
|
1440
1485
|
const effect = effects.items.find((e) => e.id === row.id);
|
|
1441
1486
|
const expanded = open === row.id;
|
|
1442
|
-
return /* @__PURE__ */ (0,
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1444
|
-
/* @__PURE__ */ (0,
|
|
1445
|
-
/* @__PURE__ */ (0,
|
|
1487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", { "data-effect-id": row.id, className: "rounded bg-background/60 ring-1 ring-border", children: [
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1.5 px-1.5 py-1", children: [
|
|
1489
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ImageCheckbox, { label: `${row.label} on`, checked: row.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.updateLayerEffect(id, row.id, { enabled: on })) }),
|
|
1490
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1446
1491
|
"button",
|
|
1447
1492
|
{
|
|
1448
1493
|
type: "button",
|
|
@@ -1452,17 +1497,17 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1452
1497
|
children: row.label
|
|
1453
1498
|
}
|
|
1454
1499
|
),
|
|
1455
|
-
/* @__PURE__ */ (0,
|
|
1500
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: imageIconButtonClass, "aria-label": `Remove ${row.label}`, disabled: model.readOnly, onClick: () => attempt(() => controller.removeLayerEffect(id, row.id)), children: "\u2715" })
|
|
1456
1501
|
] }),
|
|
1457
|
-
expanded && /* @__PURE__ */ (0,
|
|
1502
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime14.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)) })
|
|
1458
1503
|
] }, row.id);
|
|
1459
1504
|
}) }),
|
|
1460
|
-
error && /* @__PURE__ */ (0,
|
|
1505
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
1461
1506
|
] });
|
|
1462
1507
|
};
|
|
1463
1508
|
|
|
1464
1509
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1465
|
-
var
|
|
1510
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1466
1511
|
function siblingIndex(layers, l) {
|
|
1467
1512
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1468
1513
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1470,7 +1515,7 @@ function siblingIndex(layers, l) {
|
|
|
1470
1515
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1471
1516
|
usePaintEditorState(controller);
|
|
1472
1517
|
const [error, attempt] = useAttempt();
|
|
1473
|
-
const [renaming, setRenaming] = (0,
|
|
1518
|
+
const [renaming, setRenaming] = (0, import_react15.useState)(null);
|
|
1474
1519
|
const layers = controller.listLayers();
|
|
1475
1520
|
const active = layers.find((l) => l.active) ?? null;
|
|
1476
1521
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1480,18 +1525,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1480
1525
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1481
1526
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1482
1527
|
};
|
|
1483
|
-
return /* @__PURE__ */ (0,
|
|
1484
|
-
/* @__PURE__ */ (0,
|
|
1485
|
-
/* @__PURE__ */ (0,
|
|
1486
|
-
/* @__PURE__ */ (0,
|
|
1487
|
-
/* @__PURE__ */ (0,
|
|
1488
|
-
/* @__PURE__ */ (0,
|
|
1489
|
-
/* @__PURE__ */ (0,
|
|
1490
|
-
/* @__PURE__ */ (0,
|
|
1491
|
-
/* @__PURE__ */ (0,
|
|
1492
|
-
/* @__PURE__ */ (0,
|
|
1528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1531
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1532
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1536
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1493
1538
|
] }),
|
|
1494
|
-
/* @__PURE__ */ (0,
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1495
1540
|
"li",
|
|
1496
1541
|
{
|
|
1497
1542
|
role: "treeitem",
|
|
@@ -1500,7 +1545,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1500
1545
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1501
1546
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1502
1547
|
children: [
|
|
1503
|
-
/* @__PURE__ */ (0,
|
|
1548
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1504
1549
|
"button",
|
|
1505
1550
|
{
|
|
1506
1551
|
type: "button",
|
|
@@ -1513,7 +1558,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1513
1558
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1514
1559
|
}
|
|
1515
1560
|
),
|
|
1516
|
-
renaming === l.id ? /* @__PURE__ */ (0,
|
|
1561
|
+
renaming === l.id ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1517
1562
|
"input",
|
|
1518
1563
|
{
|
|
1519
1564
|
autoFocus: true,
|
|
@@ -1530,23 +1575,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1530
1575
|
if (e.key === "Escape") setRenaming(null);
|
|
1531
1576
|
}
|
|
1532
1577
|
}
|
|
1533
|
-
) : /* @__PURE__ */ (0,
|
|
1578
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1534
1579
|
l.type === "group" ? "\u25B8 " : "",
|
|
1535
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */ (0,
|
|
1580
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1536
1581
|
"\u270E",
|
|
1537
1582
|
" "
|
|
1538
1583
|
] }),
|
|
1539
1584
|
l.name
|
|
1540
1585
|
] }),
|
|
1541
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0,
|
|
1586
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1542
1587
|
]
|
|
1543
1588
|
},
|
|
1544
1589
|
l.id
|
|
1545
1590
|
)) }),
|
|
1546
|
-
active && /* @__PURE__ */ (0,
|
|
1547
|
-
/* @__PURE__ */ (0,
|
|
1548
|
-
/* @__PURE__ */ (0,
|
|
1549
|
-
/* @__PURE__ */ (0,
|
|
1591
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
1592
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1594
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1550
1595
|
"input",
|
|
1551
1596
|
{
|
|
1552
1597
|
type: "range",
|
|
@@ -1560,40 +1605,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1560
1605
|
}
|
|
1561
1606
|
)
|
|
1562
1607
|
] }),
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1564
|
-
/* @__PURE__ */ (0,
|
|
1565
|
-
/* @__PURE__ */ (0,
|
|
1566
|
-
active.type === "group" && /* @__PURE__ */ (0,
|
|
1567
|
-
|
|
1608
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1609
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1610
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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: [
|
|
1611
|
+
active.type === "group" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "pass-through", children: "Pass through" }),
|
|
1612
|
+
import_paint_editor9.BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1568
1613
|
] })
|
|
1569
1614
|
] }),
|
|
1570
|
-
/* @__PURE__ */ (0,
|
|
1571
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0,
|
|
1572
|
-
/* @__PURE__ */ (0,
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex gap-1", children: [
|
|
1616
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime15.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)),
|
|
1617
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1573
1618
|
] }),
|
|
1574
|
-
light?.hasLight && /* @__PURE__ */ (0,
|
|
1575
|
-
/* @__PURE__ */ (0,
|
|
1576
|
-
/* @__PURE__ */ (0,
|
|
1577
|
-
/* @__PURE__ */ (0,
|
|
1619
|
+
light?.hasLight && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
1620
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1578
1623
|
] }),
|
|
1579
|
-
/* @__PURE__ */ (0,
|
|
1580
|
-
/* @__PURE__ */ (0,
|
|
1581
|
-
/* @__PURE__ */ (0,
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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: [
|
|
1625
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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" })
|
|
1582
1627
|
] }),
|
|
1583
|
-
/* @__PURE__ */ (0,
|
|
1584
|
-
/* @__PURE__ */ (0,
|
|
1585
|
-
/* @__PURE__ */ (0,
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1629
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1630
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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" })
|
|
1586
1631
|
] })
|
|
1587
1632
|
] }),
|
|
1588
|
-
/* @__PURE__ */ (0,
|
|
1633
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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_runtime15.jsx)(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1589
1634
|
] }),
|
|
1590
|
-
/* @__PURE__ */ (0,
|
|
1635
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ErrorLine, { error })
|
|
1591
1636
|
] });
|
|
1592
1637
|
};
|
|
1593
1638
|
|
|
1594
1639
|
// src/paint-editor/WetPanel.tsx
|
|
1595
|
-
var
|
|
1596
|
-
var
|
|
1640
|
+
var import_paint_editor10 = require("@pixerate/editor/paint-editor");
|
|
1641
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1597
1642
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1598
1643
|
var WetPanel = ({ controller, className }) => {
|
|
1599
1644
|
const state = usePaintEditorState(controller);
|
|
@@ -1602,31 +1647,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1602
1647
|
const layerId = state.document.activeLayerId;
|
|
1603
1648
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1604
1649
|
const backend = controller.wetState();
|
|
1605
|
-
return /* @__PURE__ */ (0,
|
|
1606
|
-
/* @__PURE__ */ (0,
|
|
1607
|
-
/* @__PURE__ */ (0,
|
|
1608
|
-
/* @__PURE__ */ (0,
|
|
1650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1651
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1652
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "text-[10px] text-slate-500", children: [
|
|
1609
1654
|
"step ",
|
|
1610
1655
|
wet.clock
|
|
1611
1656
|
] })
|
|
1612
1657
|
] }),
|
|
1613
|
-
/* @__PURE__ */ (0,
|
|
1614
|
-
/* @__PURE__ */ (0,
|
|
1615
|
-
/* @__PURE__ */ (0,
|
|
1616
|
-
/* @__PURE__ */ (0,
|
|
1617
|
-
/* @__PURE__ */ (0,
|
|
1618
|
-
/* @__PURE__ */ (0,
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1659
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.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" }),
|
|
1663
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1619
1664
|
] }),
|
|
1620
|
-
/* @__PURE__ */ (0,
|
|
1621
|
-
|
|
1622
|
-
info && /* @__PURE__ */ (0,
|
|
1623
|
-
/* @__PURE__ */ (0,
|
|
1624
|
-
|
|
1625
|
-
/* @__PURE__ */ (0,
|
|
1626
|
-
/* @__PURE__ */ (0,
|
|
1627
|
-
/* @__PURE__ */ (0,
|
|
1665
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaintSlider, { control: import_paint_editor10.WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1666
|
+
import_paint_editor10.WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor10.readPath)(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
1667
|
+
info && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1669
|
+
import_paint_editor10.WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor10.readPath)(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1671
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1672
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.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_editor10.WET_FLOW_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1628
1673
|
] }),
|
|
1629
|
-
info.flow.kind !== "none" && /* @__PURE__ */ (0,
|
|
1674
|
+
info.flow.kind !== "none" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1630
1675
|
PaintSlider,
|
|
1631
1676
|
{
|
|
1632
1677
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1635,20 +1680,20 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1635
1680
|
}
|
|
1636
1681
|
)
|
|
1637
1682
|
] }),
|
|
1638
|
-
backend.message && /* @__PURE__ */ (0,
|
|
1639
|
-
backend.backend && /* @__PURE__ */ (0,
|
|
1640
|
-
/* @__PURE__ */ (0,
|
|
1641
|
-
/* @__PURE__ */ (0,
|
|
1642
|
-
/* @__PURE__ */ (0,
|
|
1683
|
+
backend.message && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1684
|
+
backend.backend && /* @__PURE__ */ (0, import_jsx_runtime16.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" }),
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1686
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", children: "Engine" }),
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.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_editor10.WET_GPU_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: o.value, children: o.label }, o.value)) })
|
|
1643
1688
|
] }),
|
|
1644
|
-
/* @__PURE__ */ (0,
|
|
1645
|
-
/* @__PURE__ */ (0,
|
|
1689
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: (0, import_paint_editor10.wetEngineSummary)(backend.engine) }),
|
|
1690
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ErrorLine, { error })
|
|
1646
1691
|
] });
|
|
1647
1692
|
};
|
|
1648
1693
|
|
|
1649
1694
|
// src/paint-editor/StickerPanel.tsx
|
|
1650
|
-
var
|
|
1651
|
-
var
|
|
1695
|
+
var import_paint_editor11 = require("@pixerate/editor/paint-editor");
|
|
1696
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1652
1697
|
var StickerPanel = ({ controller, className }) => {
|
|
1653
1698
|
const state = usePaintEditorState(controller);
|
|
1654
1699
|
const [error, attempt] = useAttempt();
|
|
@@ -1658,16 +1703,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1658
1703
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1659
1704
|
if (!stickers.length) return null;
|
|
1660
1705
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1661
|
-
return /* @__PURE__ */ (0,
|
|
1662
|
-
/* @__PURE__ */ (0,
|
|
1706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1707
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
1663
1708
|
"Stickers (",
|
|
1664
1709
|
stickers.length,
|
|
1665
1710
|
")"
|
|
1666
1711
|
] }),
|
|
1667
|
-
/* @__PURE__ */ (0,
|
|
1668
|
-
sel && /* @__PURE__ */ (0,
|
|
1669
|
-
/* @__PURE__ */ (0,
|
|
1670
|
-
/* @__PURE__ */ (0,
|
|
1712
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.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_runtime17.jsx)("button", { type: "button", role: "option", "aria-selected": s.id === picked, title: `${(0, import_paint_editor11.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)) }),
|
|
1713
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1714
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1715
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1671
1716
|
StickerPicker,
|
|
1672
1717
|
{
|
|
1673
1718
|
controller,
|
|
@@ -1681,9 +1726,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1681
1726
|
)
|
|
1682
1727
|
}
|
|
1683
1728
|
),
|
|
1684
|
-
/* @__PURE__ */ (0,
|
|
1685
|
-
/* @__PURE__ */ (0,
|
|
1686
|
-
/* @__PURE__ */ (0,
|
|
1729
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1730
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Position" }),
|
|
1731
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1687
1732
|
"input",
|
|
1688
1733
|
{
|
|
1689
1734
|
type: "number",
|
|
@@ -1697,24 +1742,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1697
1742
|
`${sel.id}-${k}-${sel[k]}`
|
|
1698
1743
|
)) })
|
|
1699
1744
|
] }),
|
|
1700
|
-
|
|
1701
|
-
/* @__PURE__ */ (0,
|
|
1702
|
-
/* @__PURE__ */ (0,
|
|
1703
|
-
/* @__PURE__ */ (0,
|
|
1745
|
+
import_paint_editor11.STICKER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor11.readPath)(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1746
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1747
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.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" })
|
|
1704
1749
|
] }),
|
|
1705
|
-
/* @__PURE__ */ (0,
|
|
1706
|
-
/* @__PURE__ */ (0,
|
|
1707
|
-
/* @__PURE__ */ (0,
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1750
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1751
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1752
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1709
1754
|
] })
|
|
1710
1755
|
] }),
|
|
1711
|
-
/* @__PURE__ */ (0,
|
|
1756
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorLine, { error })
|
|
1712
1757
|
] });
|
|
1713
1758
|
};
|
|
1714
1759
|
|
|
1715
1760
|
// src/paint-editor/StrokePanel.tsx
|
|
1716
|
-
var
|
|
1717
|
-
var
|
|
1761
|
+
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
1762
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1718
1763
|
var StrokePanel = ({ controller, className }) => {
|
|
1719
1764
|
const state = usePaintEditorState(controller);
|
|
1720
1765
|
const [error, attempt] = useAttempt();
|
|
@@ -1723,17 +1768,17 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1723
1768
|
if (!layerId || !strokes) return null;
|
|
1724
1769
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1725
1770
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1726
|
-
const brushes = state.brushes.filter((b) => !(0,
|
|
1727
|
-
return /* @__PURE__ */ (0,
|
|
1728
|
-
/* @__PURE__ */ (0,
|
|
1729
|
-
/* @__PURE__ */ (0,
|
|
1771
|
+
const brushes = state.brushes.filter((b) => !(0, import_paint_editor12.liveStrokeRefusal)(b));
|
|
1772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1773
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
1730
1775
|
"Strokes (",
|
|
1731
1776
|
strokes.length,
|
|
1732
1777
|
")"
|
|
1733
1778
|
] }),
|
|
1734
|
-
/* @__PURE__ */ (0,
|
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1735
1780
|
] }),
|
|
1736
|
-
/* @__PURE__ */ (0,
|
|
1781
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.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_runtime18.jsx)(
|
|
1737
1782
|
"button",
|
|
1738
1783
|
{
|
|
1739
1784
|
type: "button",
|
|
@@ -1746,10 +1791,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1746
1791
|
},
|
|
1747
1792
|
s.id
|
|
1748
1793
|
)) }),
|
|
1749
|
-
sel && /* @__PURE__ */ (0,
|
|
1750
|
-
/* @__PURE__ */ (0,
|
|
1751
|
-
/* @__PURE__ */ (0,
|
|
1752
|
-
/* @__PURE__ */ (0,
|
|
1794
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1795
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1796
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "Brush" }),
|
|
1797
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1753
1798
|
"select",
|
|
1754
1799
|
{
|
|
1755
1800
|
"aria-label": "Stroke brush",
|
|
@@ -1757,51 +1802,51 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1757
1802
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1758
1803
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1759
1804
|
children: [
|
|
1760
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0,
|
|
1761
|
-
brushes.map((b) => /* @__PURE__ */ (0,
|
|
1805
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: sel.brush.name }),
|
|
1806
|
+
brushes.map((b) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: b.id, children: b.name }, b.id))
|
|
1762
1807
|
]
|
|
1763
1808
|
}
|
|
1764
1809
|
)
|
|
1765
1810
|
] }),
|
|
1766
|
-
|
|
1767
|
-
/* @__PURE__ */ (0,
|
|
1768
|
-
/* @__PURE__ */ (0,
|
|
1769
|
-
/* @__PURE__ */ (0,
|
|
1811
|
+
import_paint_editor12.STROKE_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor12.readPath)(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.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" })
|
|
1770
1815
|
] }),
|
|
1771
|
-
/* @__PURE__ */ (0,
|
|
1772
|
-
/* @__PURE__ */ (0,
|
|
1773
|
-
/* @__PURE__ */ (0,
|
|
1774
|
-
/* @__PURE__ */ (0,
|
|
1775
|
-
/* @__PURE__ */ (0,
|
|
1816
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1817
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1818
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.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" }),
|
|
1819
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1820
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1776
1821
|
] })
|
|
1777
1822
|
] }),
|
|
1778
|
-
/* @__PURE__ */ (0,
|
|
1823
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ErrorLine, { error })
|
|
1779
1824
|
] });
|
|
1780
1825
|
};
|
|
1781
1826
|
|
|
1782
1827
|
// src/paint-editor/PaintEditor.tsx
|
|
1783
|
-
var
|
|
1784
|
-
var
|
|
1828
|
+
var import_react29 = require("react");
|
|
1829
|
+
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
1785
1830
|
|
|
1786
1831
|
// src/playback/AgentPlaybackContext.tsx
|
|
1787
|
-
var
|
|
1788
|
-
var
|
|
1789
|
-
var AgentPlaybackContext = (0,
|
|
1832
|
+
var import_react16 = require("react");
|
|
1833
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1834
|
+
var AgentPlaybackContext = (0, import_react16.createContext)(null);
|
|
1790
1835
|
function useAgentPlayback() {
|
|
1791
|
-
return (0,
|
|
1836
|
+
return (0, import_react16.useContext)(AgentPlaybackContext);
|
|
1792
1837
|
}
|
|
1793
1838
|
|
|
1794
1839
|
// src/playback/usePlaybackSurface.ts
|
|
1795
|
-
var
|
|
1840
|
+
var import_react17 = require("react");
|
|
1796
1841
|
var import_tools = require("@pixerate/editor/tools");
|
|
1797
1842
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
1798
1843
|
const ambient = useAgentPlayback();
|
|
1799
1844
|
const target = playback === void 0 ? ambient : playback;
|
|
1800
|
-
const [ownPresence] = (0,
|
|
1845
|
+
const [ownPresence] = (0, import_react17.useState)(() => new import_tools.PresenceStore());
|
|
1801
1846
|
const presence = sharedPresence ?? ownPresence;
|
|
1802
|
-
const latest = (0,
|
|
1847
|
+
const latest = (0, import_react17.useRef)(options);
|
|
1803
1848
|
latest.current = options;
|
|
1804
|
-
(0,
|
|
1849
|
+
(0, import_react17.useEffect)(() => {
|
|
1805
1850
|
if (!target || !id) return;
|
|
1806
1851
|
const o = () => latest.current;
|
|
1807
1852
|
const surface = {
|
|
@@ -1833,13 +1878,13 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
1833
1878
|
}
|
|
1834
1879
|
|
|
1835
1880
|
// src/playback/PresenceLayer.tsx
|
|
1836
|
-
var
|
|
1837
|
-
var
|
|
1881
|
+
var import_react18 = __toESM(require("react"), 1);
|
|
1882
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1838
1883
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
1839
|
-
const { actors } = (0,
|
|
1884
|
+
const { actors } = (0, import_react18.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
1840
1885
|
if (!actors.length) return null;
|
|
1841
1886
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
1842
|
-
return /* @__PURE__ */ (0,
|
|
1887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1843
1888
|
"div",
|
|
1844
1889
|
{
|
|
1845
1890
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -1853,19 +1898,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1853
1898
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
1854
1899
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
1855
1900
|
})();
|
|
1856
|
-
return /* @__PURE__ */ (0,
|
|
1857
|
-
ring && /* @__PURE__ */ (0,
|
|
1901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_react18.default.Fragment, { children: [
|
|
1902
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1858
1903
|
"div",
|
|
1859
1904
|
{
|
|
1860
1905
|
"data-actor-focus": a.id,
|
|
1861
1906
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
1862
1907
|
}
|
|
1863
1908
|
),
|
|
1864
|
-
/* @__PURE__ */ (0,
|
|
1865
|
-
/* @__PURE__ */ (0,
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1868
|
-
a.message && /* @__PURE__ */ (0,
|
|
1909
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
1910
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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_runtime20.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 } }) }),
|
|
1911
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
1912
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
1913
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime20.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 })
|
|
1869
1914
|
] })
|
|
1870
1915
|
] }) })
|
|
1871
1916
|
] }, a.id);
|
|
@@ -1875,15 +1920,15 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1875
1920
|
}
|
|
1876
1921
|
|
|
1877
1922
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1878
|
-
var
|
|
1879
|
-
var
|
|
1923
|
+
var import_react28 = require("react");
|
|
1924
|
+
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
1880
1925
|
|
|
1881
1926
|
// src/effects/useEffects.ts
|
|
1882
|
-
var
|
|
1927
|
+
var import_react19 = require("react");
|
|
1883
1928
|
function useEffectDescription(provider, effect) {
|
|
1884
|
-
const [state, setState] = (0,
|
|
1929
|
+
const [state, setState] = (0, import_react19.useState)({ key: "", description: null, error: null });
|
|
1885
1930
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1886
|
-
(0,
|
|
1931
|
+
(0, import_react19.useEffect)(() => {
|
|
1887
1932
|
if (!provider || !effect) return;
|
|
1888
1933
|
let live = true;
|
|
1889
1934
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1898,14 +1943,14 @@ function useEffectDescription(provider, effect) {
|
|
|
1898
1943
|
}
|
|
1899
1944
|
|
|
1900
1945
|
// src/effects/EffectThumbnail.tsx
|
|
1901
|
-
var
|
|
1946
|
+
var import_react20 = require("react");
|
|
1902
1947
|
var import_effects = require("@pixerate/editor/effects");
|
|
1903
|
-
var
|
|
1948
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1904
1949
|
var LABELS = { motion: "Motion", camera: "Camera" };
|
|
1905
1950
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1906
|
-
const ref = (0,
|
|
1907
|
-
const [failed, setFailed] = (0,
|
|
1908
|
-
(0,
|
|
1951
|
+
const ref = (0, import_react20.useRef)(null);
|
|
1952
|
+
const [failed, setFailed] = (0, import_react20.useState)(effect.kind in LABELS);
|
|
1953
|
+
(0, import_react20.useEffect)(() => {
|
|
1909
1954
|
if (effect.kind in LABELS) return;
|
|
1910
1955
|
let live = true;
|
|
1911
1956
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1920,28 +1965,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1920
1965
|
live = false;
|
|
1921
1966
|
};
|
|
1922
1967
|
}, [provider, effect, width, height]);
|
|
1923
|
-
return /* @__PURE__ */ (0,
|
|
1968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1924
1969
|
"div",
|
|
1925
1970
|
{
|
|
1926
1971
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1927
1972
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1928
1973
|
"data-effect-thumbnail": effect.id,
|
|
1929
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1974
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime21.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_runtime21.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
1930
1975
|
}
|
|
1931
1976
|
);
|
|
1932
1977
|
}
|
|
1933
1978
|
|
|
1934
1979
|
// src/effects/EffectsBrowser.tsx
|
|
1935
|
-
var
|
|
1980
|
+
var import_react21 = require("react");
|
|
1936
1981
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1937
|
-
var
|
|
1982
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1938
1983
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1939
|
-
const [all, setAll] = (0,
|
|
1940
|
-
const [query, setQuery] = (0,
|
|
1941
|
-
const [category, setCategory] = (0,
|
|
1942
|
-
const [use, setUse] = (0,
|
|
1943
|
-
const [error, setError] = (0,
|
|
1944
|
-
(0,
|
|
1984
|
+
const [all, setAll] = (0, import_react21.useState)([]);
|
|
1985
|
+
const [query, setQuery] = (0, import_react21.useState)("");
|
|
1986
|
+
const [category, setCategory] = (0, import_react21.useState)("");
|
|
1987
|
+
const [use, setUse] = (0, import_react21.useState)("");
|
|
1988
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
1989
|
+
(0, import_react21.useEffect)(() => {
|
|
1945
1990
|
if (!provider) return setAll([]);
|
|
1946
1991
|
let live = true;
|
|
1947
1992
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1952,8 +1997,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1952
1997
|
live = false;
|
|
1953
1998
|
};
|
|
1954
1999
|
}, [provider]);
|
|
1955
|
-
const [found, setFound] = (0,
|
|
1956
|
-
(0,
|
|
2000
|
+
const [found, setFound] = (0, import_react21.useState)([]);
|
|
2001
|
+
(0, import_react21.useEffect)(() => {
|
|
1957
2002
|
if (!provider) return setFound([]);
|
|
1958
2003
|
let live = true;
|
|
1959
2004
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1962,14 +2007,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1962
2007
|
};
|
|
1963
2008
|
}, [provider, query, category, use]);
|
|
1964
2009
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
1965
|
-
const categories = (0,
|
|
2010
|
+
const categories = (0, import_react21.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1966
2011
|
const shown = found.filter(allowed);
|
|
1967
2012
|
if (!provider)
|
|
1968
|
-
return /* @__PURE__ */ (0,
|
|
1969
|
-
return /* @__PURE__ */ (0,
|
|
1970
|
-
title && /* @__PURE__ */ (0,
|
|
1971
|
-
/* @__PURE__ */ (0,
|
|
1972
|
-
/* @__PURE__ */ (0,
|
|
2013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.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." });
|
|
2014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
2015
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
2016
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
2017
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1973
2018
|
"input",
|
|
1974
2019
|
{
|
|
1975
2020
|
type: "search",
|
|
@@ -1980,17 +2025,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1980
2025
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1981
2026
|
}
|
|
1982
2027
|
),
|
|
1983
|
-
/* @__PURE__ */ (0,
|
|
1984
|
-
/* @__PURE__ */ (0,
|
|
1985
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
2028
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.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: [
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "All categories" }),
|
|
2030
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: c, children: c }, c))
|
|
1986
2031
|
] }),
|
|
1987
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1988
|
-
/* @__PURE__ */ (0,
|
|
1989
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
2032
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime22.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: [
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Any use" }),
|
|
2034
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1990
2035
|
] })
|
|
1991
2036
|
] }),
|
|
1992
|
-
error && /* @__PURE__ */ (0,
|
|
1993
|
-
/* @__PURE__ */ (0,
|
|
2037
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
2038
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.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_runtime22.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1994
2039
|
"button",
|
|
1995
2040
|
{
|
|
1996
2041
|
type: "button",
|
|
@@ -1999,23 +2044,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1999
2044
|
"data-effect-id": e.id,
|
|
2000
2045
|
onClick: () => onPick(e),
|
|
2001
2046
|
children: [
|
|
2002
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
2003
|
-
/* @__PURE__ */ (0,
|
|
2004
|
-
/* @__PURE__ */ (0,
|
|
2047
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
2005
2050
|
]
|
|
2006
2051
|
}
|
|
2007
2052
|
) }, e.id)) }),
|
|
2008
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
2053
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
2009
2054
|
] });
|
|
2010
2055
|
}
|
|
2011
2056
|
|
|
2012
2057
|
// src/effects/EffectParameters.tsx
|
|
2013
|
-
var
|
|
2058
|
+
var import_react27 = __toESM(require("react"), 1);
|
|
2014
2059
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
2015
2060
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
2016
2061
|
|
|
2017
2062
|
// src/parameters/fields.tsx
|
|
2018
|
-
var
|
|
2063
|
+
var import_react26 = require("react");
|
|
2019
2064
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
2020
2065
|
|
|
2021
2066
|
// src/color/index.ts
|
|
@@ -2028,9 +2073,9 @@ __export(color_exports, {
|
|
|
2028
2073
|
});
|
|
2029
2074
|
|
|
2030
2075
|
// src/color/ColorPicker.tsx
|
|
2031
|
-
var
|
|
2076
|
+
var import_react22 = require("react");
|
|
2032
2077
|
var import_color = require("@pixerate/editor/color");
|
|
2033
|
-
var
|
|
2078
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2034
2079
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
2035
2080
|
function readLocalRecents() {
|
|
2036
2081
|
try {
|
|
@@ -2068,24 +2113,24 @@ var ColorPicker = ({
|
|
|
2068
2113
|
id,
|
|
2069
2114
|
"aria-label": ariaLabel = "Color picker"
|
|
2070
2115
|
}) => {
|
|
2071
|
-
const generatedId = (0,
|
|
2116
|
+
const generatedId = (0, import_react22.useId)();
|
|
2072
2117
|
const pickerId = id || generatedId;
|
|
2073
|
-
const [pickerState, setPickerState] = (0,
|
|
2118
|
+
const [pickerState, setPickerState] = (0, import_react22.useState)(
|
|
2074
2119
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
2075
2120
|
);
|
|
2076
|
-
const stateRef = (0,
|
|
2121
|
+
const stateRef = (0, import_react22.useRef)(pickerState);
|
|
2077
2122
|
stateRef.current = pickerState;
|
|
2078
|
-
(0,
|
|
2123
|
+
(0, import_react22.useEffect)(() => {
|
|
2079
2124
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
2080
2125
|
if (next) {
|
|
2081
2126
|
setPickerState(next);
|
|
2082
2127
|
}
|
|
2083
2128
|
}, [value]);
|
|
2084
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
2129
|
+
const [internalRecent, setInternalRecent] = (0, import_react22.useState)(
|
|
2085
2130
|
() => controlledRecent ? [] : readLocalRecents()
|
|
2086
2131
|
);
|
|
2087
2132
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
2088
|
-
const recordRecent = (0,
|
|
2133
|
+
const recordRecent = (0, import_react22.useCallback)(
|
|
2089
2134
|
(color) => {
|
|
2090
2135
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
2091
2136
|
if (!controlledRecent) {
|
|
@@ -2096,11 +2141,11 @@ var ColorPicker = ({
|
|
|
2096
2141
|
},
|
|
2097
2142
|
[activeRecent, controlledRecent, onRecentChange]
|
|
2098
2143
|
);
|
|
2099
|
-
const [textDraft, setTextDraft] = (0,
|
|
2100
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
2101
|
-
const [isClipped, setIsClipped] = (0,
|
|
2102
|
-
const isTypingRef = (0,
|
|
2103
|
-
(0,
|
|
2144
|
+
const [textDraft, setTextDraft] = (0, import_react22.useState)(value);
|
|
2145
|
+
const [isInvalid, setIsInvalid] = (0, import_react22.useState)(false);
|
|
2146
|
+
const [isClipped, setIsClipped] = (0, import_react22.useState)(false);
|
|
2147
|
+
const isTypingRef = (0, import_react22.useRef)(false);
|
|
2148
|
+
(0, import_react22.useEffect)(() => {
|
|
2104
2149
|
if (!isTypingRef.current) {
|
|
2105
2150
|
setTextDraft(value);
|
|
2106
2151
|
setIsInvalid(false);
|
|
@@ -2108,11 +2153,11 @@ var ColorPicker = ({
|
|
|
2108
2153
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
2109
2154
|
}
|
|
2110
2155
|
}, [value]);
|
|
2111
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
2112
|
-
(0,
|
|
2156
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react22.useState)(false);
|
|
2157
|
+
(0, import_react22.useEffect)(() => {
|
|
2113
2158
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
2114
2159
|
}, []);
|
|
2115
|
-
const emitColorChange = (0,
|
|
2160
|
+
const emitColorChange = (0, import_react22.useCallback)(
|
|
2116
2161
|
(nextState) => {
|
|
2117
2162
|
setPickerState(nextState);
|
|
2118
2163
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -2120,10 +2165,10 @@ var ColorPicker = ({
|
|
|
2120
2165
|
},
|
|
2121
2166
|
[alpha, onChange]
|
|
2122
2167
|
);
|
|
2123
|
-
const latest = (0,
|
|
2168
|
+
const latest = (0, import_react22.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
2124
2169
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
2125
|
-
const endDragRef = (0,
|
|
2126
|
-
(0,
|
|
2170
|
+
const endDragRef = (0, import_react22.useRef)(null);
|
|
2171
|
+
(0, import_react22.useEffect)(() => () => endDragRef.current?.(), []);
|
|
2127
2172
|
const startDrag = (e, next) => {
|
|
2128
2173
|
if (disabled) return;
|
|
2129
2174
|
e.preventDefault();
|
|
@@ -2225,7 +2270,7 @@ var ColorPicker = ({
|
|
|
2225
2270
|
} catch {
|
|
2226
2271
|
}
|
|
2227
2272
|
};
|
|
2228
|
-
const contrastResult = (0,
|
|
2273
|
+
const contrastResult = (0, import_react22.useMemo)(() => {
|
|
2229
2274
|
if (!contrastAgainst) return null;
|
|
2230
2275
|
const fg = (0, import_color.parseColor)(value);
|
|
2231
2276
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -2237,7 +2282,7 @@ var ColorPicker = ({
|
|
|
2237
2282
|
}, [value, contrastAgainst]);
|
|
2238
2283
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
2239
2284
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
2240
|
-
return /* @__PURE__ */ (0,
|
|
2285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2241
2286
|
"div",
|
|
2242
2287
|
{
|
|
2243
2288
|
id: pickerId,
|
|
@@ -2261,7 +2306,7 @@ var ColorPicker = ({
|
|
|
2261
2306
|
pointerEvents: disabled ? "none" : "auto"
|
|
2262
2307
|
},
|
|
2263
2308
|
children: [
|
|
2264
|
-
/* @__PURE__ */ (0,
|
|
2309
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2265
2310
|
"span",
|
|
2266
2311
|
{
|
|
2267
2312
|
role: "status",
|
|
@@ -2280,7 +2325,7 @@ var ColorPicker = ({
|
|
|
2280
2325
|
children: liveDescription
|
|
2281
2326
|
}
|
|
2282
2327
|
),
|
|
2283
|
-
/* @__PURE__ */ (0,
|
|
2328
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2284
2329
|
"div",
|
|
2285
2330
|
{
|
|
2286
2331
|
role: "slider",
|
|
@@ -2302,7 +2347,7 @@ var ColorPicker = ({
|
|
|
2302
2347
|
touchAction: "none",
|
|
2303
2348
|
outline: "none"
|
|
2304
2349
|
},
|
|
2305
|
-
children: /* @__PURE__ */ (0,
|
|
2350
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2306
2351
|
"div",
|
|
2307
2352
|
{
|
|
2308
2353
|
style: {
|
|
@@ -2322,7 +2367,7 @@ var ColorPicker = ({
|
|
|
2322
2367
|
)
|
|
2323
2368
|
}
|
|
2324
2369
|
),
|
|
2325
|
-
/* @__PURE__ */ (0,
|
|
2370
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2326
2371
|
"div",
|
|
2327
2372
|
{
|
|
2328
2373
|
role: "slider",
|
|
@@ -2345,7 +2390,7 @@ var ColorPicker = ({
|
|
|
2345
2390
|
touchAction: "none",
|
|
2346
2391
|
outline: "none"
|
|
2347
2392
|
},
|
|
2348
|
-
children: /* @__PURE__ */ (0,
|
|
2393
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2349
2394
|
"div",
|
|
2350
2395
|
{
|
|
2351
2396
|
style: {
|
|
@@ -2365,7 +2410,7 @@ var ColorPicker = ({
|
|
|
2365
2410
|
)
|
|
2366
2411
|
}
|
|
2367
2412
|
),
|
|
2368
|
-
alpha && /* @__PURE__ */ (0,
|
|
2413
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2369
2414
|
"div",
|
|
2370
2415
|
{
|
|
2371
2416
|
role: "slider",
|
|
@@ -2391,7 +2436,7 @@ var ColorPicker = ({
|
|
|
2391
2436
|
overflow: "hidden"
|
|
2392
2437
|
},
|
|
2393
2438
|
children: [
|
|
2394
|
-
/* @__PURE__ */ (0,
|
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2395
2440
|
"div",
|
|
2396
2441
|
{
|
|
2397
2442
|
style: {
|
|
@@ -2401,7 +2446,7 @@ var ColorPicker = ({
|
|
|
2401
2446
|
}
|
|
2402
2447
|
}
|
|
2403
2448
|
),
|
|
2404
|
-
/* @__PURE__ */ (0,
|
|
2449
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2405
2450
|
"div",
|
|
2406
2451
|
{
|
|
2407
2452
|
style: {
|
|
@@ -2422,8 +2467,8 @@ var ColorPicker = ({
|
|
|
2422
2467
|
]
|
|
2423
2468
|
}
|
|
2424
2469
|
),
|
|
2425
|
-
/* @__PURE__ */ (0,
|
|
2426
|
-
/* @__PURE__ */ (0,
|
|
2470
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
2471
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2427
2472
|
"div",
|
|
2428
2473
|
{
|
|
2429
2474
|
style: {
|
|
@@ -2437,7 +2482,7 @@ var ColorPicker = ({
|
|
|
2437
2482
|
flexShrink: 0,
|
|
2438
2483
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
2439
2484
|
},
|
|
2440
|
-
children: /* @__PURE__ */ (0,
|
|
2485
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2441
2486
|
"div",
|
|
2442
2487
|
{
|
|
2443
2488
|
style: {
|
|
@@ -2449,7 +2494,7 @@ var ColorPicker = ({
|
|
|
2449
2494
|
)
|
|
2450
2495
|
}
|
|
2451
2496
|
),
|
|
2452
|
-
/* @__PURE__ */ (0,
|
|
2497
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2453
2498
|
"input",
|
|
2454
2499
|
{
|
|
2455
2500
|
type: "text",
|
|
@@ -2479,7 +2524,7 @@ var ColorPicker = ({
|
|
|
2479
2524
|
}
|
|
2480
2525
|
}
|
|
2481
2526
|
),
|
|
2482
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
2527
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2483
2528
|
"button",
|
|
2484
2529
|
{
|
|
2485
2530
|
type: "button",
|
|
@@ -2499,7 +2544,7 @@ var ColorPicker = ({
|
|
|
2499
2544
|
color: "inherit",
|
|
2500
2545
|
cursor: disabled ? "default" : "pointer"
|
|
2501
2546
|
},
|
|
2502
|
-
children: /* @__PURE__ */ (0,
|
|
2547
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2503
2548
|
"svg",
|
|
2504
2549
|
{
|
|
2505
2550
|
width: "14",
|
|
@@ -2511,16 +2556,16 @@ var ColorPicker = ({
|
|
|
2511
2556
|
strokeLinecap: "round",
|
|
2512
2557
|
strokeLinejoin: "round",
|
|
2513
2558
|
children: [
|
|
2514
|
-
/* @__PURE__ */ (0,
|
|
2515
|
-
/* @__PURE__ */ (0,
|
|
2516
|
-
/* @__PURE__ */ (0,
|
|
2559
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.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" }),
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "m14 6 4 4" })
|
|
2517
2562
|
]
|
|
2518
2563
|
}
|
|
2519
2564
|
)
|
|
2520
2565
|
}
|
|
2521
2566
|
)
|
|
2522
2567
|
] }),
|
|
2523
|
-
isClipped && /* @__PURE__ */ (0,
|
|
2568
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2524
2569
|
"div",
|
|
2525
2570
|
{
|
|
2526
2571
|
role: "note",
|
|
@@ -2536,10 +2581,10 @@ var ColorPicker = ({
|
|
|
2536
2581
|
borderRadius: "4px",
|
|
2537
2582
|
alignSelf: "flex-start"
|
|
2538
2583
|
},
|
|
2539
|
-
children: /* @__PURE__ */ (0,
|
|
2584
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
2540
2585
|
}
|
|
2541
2586
|
),
|
|
2542
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
2587
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2543
2588
|
"div",
|
|
2544
2589
|
{
|
|
2545
2590
|
style: {
|
|
@@ -2553,15 +2598,15 @@ var ColorPicker = ({
|
|
|
2553
2598
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
2554
2599
|
},
|
|
2555
2600
|
children: [
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { children: [
|
|
2557
2602
|
"Contrast: ",
|
|
2558
|
-
/* @__PURE__ */ (0,
|
|
2603
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("strong", { children: [
|
|
2559
2604
|
contrastResult.ratio.toFixed(2),
|
|
2560
2605
|
":1"
|
|
2561
2606
|
] })
|
|
2562
2607
|
] }),
|
|
2563
|
-
/* @__PURE__ */ (0,
|
|
2564
|
-
/* @__PURE__ */ (0,
|
|
2608
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2565
2610
|
"span",
|
|
2566
2611
|
{
|
|
2567
2612
|
style: {
|
|
@@ -2574,7 +2619,7 @@ var ColorPicker = ({
|
|
|
2574
2619
|
]
|
|
2575
2620
|
}
|
|
2576
2621
|
),
|
|
2577
|
-
/* @__PURE__ */ (0,
|
|
2622
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2578
2623
|
"span",
|
|
2579
2624
|
{
|
|
2580
2625
|
style: {
|
|
@@ -2591,9 +2636,9 @@ var ColorPicker = ({
|
|
|
2591
2636
|
]
|
|
2592
2637
|
}
|
|
2593
2638
|
),
|
|
2594
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2595
|
-
/* @__PURE__ */ (0,
|
|
2596
|
-
/* @__PURE__ */ (0,
|
|
2639
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2640
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2597
2642
|
"button",
|
|
2598
2643
|
{
|
|
2599
2644
|
type: "button",
|
|
@@ -2619,9 +2664,9 @@ var ColorPicker = ({
|
|
|
2619
2664
|
`${color}-${idx}`
|
|
2620
2665
|
)) })
|
|
2621
2666
|
] }),
|
|
2622
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
2623
|
-
/* @__PURE__ */ (0,
|
|
2624
|
-
/* @__PURE__ */ (0,
|
|
2667
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2668
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
2669
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2625
2670
|
"button",
|
|
2626
2671
|
{
|
|
2627
2672
|
type: "button",
|
|
@@ -2652,9 +2697,9 @@ var ColorPicker = ({
|
|
|
2652
2697
|
};
|
|
2653
2698
|
|
|
2654
2699
|
// src/color/DualColorPicker.tsx
|
|
2655
|
-
var
|
|
2700
|
+
var import_react23 = require("react");
|
|
2656
2701
|
var import_color2 = require("@pixerate/editor/color");
|
|
2657
|
-
var
|
|
2702
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2658
2703
|
function DualColorPicker({
|
|
2659
2704
|
value,
|
|
2660
2705
|
onChange,
|
|
@@ -2669,8 +2714,8 @@ function DualColorPicker({
|
|
|
2669
2714
|
disabled = false,
|
|
2670
2715
|
className = ""
|
|
2671
2716
|
}) {
|
|
2672
|
-
const sameId = (0,
|
|
2673
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
2717
|
+
const sameId = (0, import_react23.useId)();
|
|
2718
|
+
const [internalScheme, setInternalScheme] = (0, import_react23.useState)("light");
|
|
2674
2719
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
2675
2720
|
const handleSchemeSelect = (nextScheme) => {
|
|
2676
2721
|
if (onSchemeChange) {
|
|
@@ -2681,7 +2726,7 @@ function DualColorPicker({
|
|
|
2681
2726
|
};
|
|
2682
2727
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
2683
2728
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
2684
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
2729
|
+
const [sameInBoth, setSameInBoth] = (0, import_react23.useState)(isSame);
|
|
2685
2730
|
const handleSameToggle = (e) => {
|
|
2686
2731
|
const nextSame = e.target.checked;
|
|
2687
2732
|
setSameInBoth(nextSame);
|
|
@@ -2713,7 +2758,7 @@ function DualColorPicker({
|
|
|
2713
2758
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
2714
2759
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
2715
2760
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
2716
|
-
return /* @__PURE__ */ (0,
|
|
2761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2717
2762
|
"div",
|
|
2718
2763
|
{
|
|
2719
2764
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -2732,7 +2777,7 @@ function DualColorPicker({
|
|
|
2732
2777
|
boxSizing: "border-box"
|
|
2733
2778
|
},
|
|
2734
2779
|
children: [
|
|
2735
|
-
/* @__PURE__ */ (0,
|
|
2780
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2736
2781
|
"div",
|
|
2737
2782
|
{
|
|
2738
2783
|
role: "tablist",
|
|
@@ -2745,7 +2790,7 @@ function DualColorPicker({
|
|
|
2745
2790
|
gap: "2px"
|
|
2746
2791
|
},
|
|
2747
2792
|
children: [
|
|
2748
|
-
/* @__PURE__ */ (0,
|
|
2793
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2749
2794
|
"button",
|
|
2750
2795
|
{
|
|
2751
2796
|
type: "button",
|
|
@@ -2768,7 +2813,7 @@ function DualColorPicker({
|
|
|
2768
2813
|
children: "Light"
|
|
2769
2814
|
}
|
|
2770
2815
|
),
|
|
2771
|
-
/* @__PURE__ */ (0,
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2772
2817
|
"button",
|
|
2773
2818
|
{
|
|
2774
2819
|
type: "button",
|
|
@@ -2794,8 +2839,8 @@ function DualColorPicker({
|
|
|
2794
2839
|
]
|
|
2795
2840
|
}
|
|
2796
2841
|
),
|
|
2797
|
-
/* @__PURE__ */ (0,
|
|
2798
|
-
/* @__PURE__ */ (0,
|
|
2842
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2843
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2799
2844
|
"button",
|
|
2800
2845
|
{
|
|
2801
2846
|
type: "button",
|
|
@@ -2817,7 +2862,7 @@ function DualColorPicker({
|
|
|
2817
2862
|
outline: "none"
|
|
2818
2863
|
},
|
|
2819
2864
|
children: [
|
|
2820
|
-
/* @__PURE__ */ (0,
|
|
2865
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2821
2866
|
"span",
|
|
2822
2867
|
{
|
|
2823
2868
|
style: {
|
|
@@ -2829,11 +2874,11 @@ function DualColorPicker({
|
|
|
2829
2874
|
}
|
|
2830
2875
|
}
|
|
2831
2876
|
),
|
|
2832
|
-
/* @__PURE__ */ (0,
|
|
2877
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2833
2878
|
]
|
|
2834
2879
|
}
|
|
2835
2880
|
),
|
|
2836
|
-
/* @__PURE__ */ (0,
|
|
2881
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2837
2882
|
"button",
|
|
2838
2883
|
{
|
|
2839
2884
|
type: "button",
|
|
@@ -2855,7 +2900,7 @@ function DualColorPicker({
|
|
|
2855
2900
|
outline: "none"
|
|
2856
2901
|
},
|
|
2857
2902
|
children: [
|
|
2858
|
-
/* @__PURE__ */ (0,
|
|
2903
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2859
2904
|
"span",
|
|
2860
2905
|
{
|
|
2861
2906
|
style: {
|
|
@@ -2867,12 +2912,12 @@ function DualColorPicker({
|
|
|
2867
2912
|
}
|
|
2868
2913
|
}
|
|
2869
2914
|
),
|
|
2870
|
-
/* @__PURE__ */ (0,
|
|
2915
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2871
2916
|
]
|
|
2872
2917
|
}
|
|
2873
2918
|
)
|
|
2874
2919
|
] }),
|
|
2875
|
-
/* @__PURE__ */ (0,
|
|
2920
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2876
2921
|
"div",
|
|
2877
2922
|
{
|
|
2878
2923
|
style: {
|
|
@@ -2883,7 +2928,7 @@ function DualColorPicker({
|
|
|
2883
2928
|
padding: "2px 0"
|
|
2884
2929
|
},
|
|
2885
2930
|
children: [
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2931
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2887
2932
|
"label",
|
|
2888
2933
|
{
|
|
2889
2934
|
htmlFor: sameId,
|
|
@@ -2897,7 +2942,7 @@ function DualColorPicker({
|
|
|
2897
2942
|
color: "#c4cad4"
|
|
2898
2943
|
},
|
|
2899
2944
|
children: [
|
|
2900
|
-
/* @__PURE__ */ (0,
|
|
2945
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2901
2946
|
"input",
|
|
2902
2947
|
{
|
|
2903
2948
|
id: sameId,
|
|
@@ -2908,11 +2953,11 @@ function DualColorPicker({
|
|
|
2908
2953
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2909
2954
|
}
|
|
2910
2955
|
),
|
|
2911
|
-
/* @__PURE__ */ (0,
|
|
2956
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: "Same in both" })
|
|
2912
2957
|
]
|
|
2913
2958
|
}
|
|
2914
2959
|
),
|
|
2915
|
-
/* @__PURE__ */ (0,
|
|
2960
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2916
2961
|
"button",
|
|
2917
2962
|
{
|
|
2918
2963
|
type: "button",
|
|
@@ -2934,7 +2979,7 @@ function DualColorPicker({
|
|
|
2934
2979
|
]
|
|
2935
2980
|
}
|
|
2936
2981
|
),
|
|
2937
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
2982
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2938
2983
|
"div",
|
|
2939
2984
|
{
|
|
2940
2985
|
"data-testid": "dual-contrast-summary",
|
|
@@ -2948,20 +2993,20 @@ function DualColorPicker({
|
|
|
2948
2993
|
color: "#8c95a6"
|
|
2949
2994
|
},
|
|
2950
2995
|
children: [
|
|
2951
|
-
/* @__PURE__ */ (0,
|
|
2996
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { children: [
|
|
2952
2997
|
"Light:",
|
|
2953
2998
|
" ",
|
|
2954
|
-
/* @__PURE__ */ (0,
|
|
2999
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2955
3000
|
dualContrast.light.ratio.toFixed(2),
|
|
2956
3001
|
" (",
|
|
2957
3002
|
dualContrast.light.level,
|
|
2958
3003
|
")"
|
|
2959
3004
|
] })
|
|
2960
3005
|
] }),
|
|
2961
|
-
/* @__PURE__ */ (0,
|
|
3006
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { children: [
|
|
2962
3007
|
"Dark:",
|
|
2963
3008
|
" ",
|
|
2964
|
-
/* @__PURE__ */ (0,
|
|
3009
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2965
3010
|
dualContrast.dark.ratio.toFixed(2),
|
|
2966
3011
|
" (",
|
|
2967
3012
|
dualContrast.dark.level,
|
|
@@ -2971,7 +3016,7 @@ function DualColorPicker({
|
|
|
2971
3016
|
]
|
|
2972
3017
|
}
|
|
2973
3018
|
),
|
|
2974
|
-
/* @__PURE__ */ (0,
|
|
3019
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2975
3020
|
ColorPicker,
|
|
2976
3021
|
{
|
|
2977
3022
|
value: activeColor,
|
|
@@ -2990,7 +3035,7 @@ function DualColorPicker({
|
|
|
2990
3035
|
}
|
|
2991
3036
|
|
|
2992
3037
|
// src/color/useColorScheme.ts
|
|
2993
|
-
var
|
|
3038
|
+
var import_react24 = require("react");
|
|
2994
3039
|
var import_color3 = require("@pixerate/editor/color");
|
|
2995
3040
|
function getSnapshot(attribute) {
|
|
2996
3041
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -3015,7 +3060,7 @@ function getServerSnapshot() {
|
|
|
3015
3060
|
function useColorScheme(options) {
|
|
3016
3061
|
const override = options?.override;
|
|
3017
3062
|
const attribute = options?.attribute;
|
|
3018
|
-
const subscribe = (0,
|
|
3063
|
+
const subscribe = (0, import_react24.useMemo)(() => {
|
|
3019
3064
|
return (callback) => {
|
|
3020
3065
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
3021
3066
|
return () => {
|
|
@@ -3041,7 +3086,7 @@ function useColorScheme(options) {
|
|
|
3041
3086
|
};
|
|
3042
3087
|
};
|
|
3043
3088
|
}, [attribute]);
|
|
3044
|
-
const detected = (0,
|
|
3089
|
+
const detected = (0, import_react24.useSyncExternalStore)(
|
|
3045
3090
|
subscribe,
|
|
3046
3091
|
() => getSnapshot(attribute),
|
|
3047
3092
|
getServerSnapshot
|
|
@@ -3058,11 +3103,11 @@ function useResolvedColor(value, scheme) {
|
|
|
3058
3103
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
3059
3104
|
|
|
3060
3105
|
// src/parameters/controls.tsx
|
|
3061
|
-
var
|
|
3062
|
-
var
|
|
3063
|
-
var ParameterComponentsContext = (0,
|
|
3106
|
+
var import_react25 = require("react");
|
|
3107
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3108
|
+
var ParameterComponentsContext = (0, import_react25.createContext)({});
|
|
3064
3109
|
function useParameterComponents() {
|
|
3065
|
-
return (0,
|
|
3110
|
+
return (0, import_react25.useContext)(ParameterComponentsContext);
|
|
3066
3111
|
}
|
|
3067
3112
|
function resolveParameterComponents(explicit, context) {
|
|
3068
3113
|
return {
|
|
@@ -3074,7 +3119,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
3074
3119
|
}
|
|
3075
3120
|
|
|
3076
3121
|
// src/parameters/fields.tsx
|
|
3077
|
-
var
|
|
3122
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3078
3123
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
3079
3124
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
3080
3125
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -3083,9 +3128,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
3083
3128
|
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";
|
|
3084
3129
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
3085
3130
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
3086
|
-
const inputRef = (0,
|
|
3087
|
-
const lastCommitted = (0,
|
|
3088
|
-
(0,
|
|
3131
|
+
const inputRef = (0, import_react26.useRef)(null);
|
|
3132
|
+
const lastCommitted = (0, import_react26.useRef)(null);
|
|
3133
|
+
(0, import_react26.useLayoutEffect)(() => {
|
|
3089
3134
|
lastCommitted.current = null;
|
|
3090
3135
|
const el = inputRef.current;
|
|
3091
3136
|
if (el && el.value !== value) el.value = value;
|
|
@@ -3096,9 +3141,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3096
3141
|
onCommit(text, el);
|
|
3097
3142
|
lastCommitted.current = el.value === text ? text : null;
|
|
3098
3143
|
};
|
|
3099
|
-
const commitRef = (0,
|
|
3144
|
+
const commitRef = (0, import_react26.useRef)(commit);
|
|
3100
3145
|
commitRef.current = commit;
|
|
3101
|
-
(0,
|
|
3146
|
+
(0, import_react26.useEffect)(() => {
|
|
3102
3147
|
const el = inputRef.current;
|
|
3103
3148
|
if (!el) return;
|
|
3104
3149
|
const change = () => commitRef.current(el);
|
|
@@ -3129,7 +3174,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3129
3174
|
if (typeof forwarded === "function") forwarded(el);
|
|
3130
3175
|
else if (forwarded) forwarded.current = el;
|
|
3131
3176
|
};
|
|
3132
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
3177
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
3133
3178
|
}
|
|
3134
3179
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
3135
3180
|
function ParameterNumberInput(props) {
|
|
@@ -3163,9 +3208,9 @@ function ParameterNumberInput(props) {
|
|
|
3163
3208
|
onCommit: handleCommit,
|
|
3164
3209
|
onKeyDown: handleKeyDown
|
|
3165
3210
|
};
|
|
3166
|
-
return /* @__PURE__ */ (0,
|
|
3167
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
3168
|
-
field.unit && /* @__PURE__ */ (0,
|
|
3211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
3212
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
3213
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
3169
3214
|
] });
|
|
3170
3215
|
}
|
|
3171
3216
|
function ParameterSlider(props) {
|
|
@@ -3173,7 +3218,7 @@ function ParameterSlider(props) {
|
|
|
3173
3218
|
const ctx = useParameterComponents();
|
|
3174
3219
|
const resolved = resolveParameterComponents(components, ctx);
|
|
3175
3220
|
const CustomSlider = resolved.slider;
|
|
3176
|
-
const dragging = (0,
|
|
3221
|
+
const dragging = (0, import_react26.useRef)(false);
|
|
3177
3222
|
const start = () => {
|
|
3178
3223
|
if (dragging.current) return;
|
|
3179
3224
|
dragging.current = true;
|
|
@@ -3184,7 +3229,7 @@ function ParameterSlider(props) {
|
|
|
3184
3229
|
dragging.current = false;
|
|
3185
3230
|
onGestureEnd?.();
|
|
3186
3231
|
};
|
|
3187
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
3232
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterNumberInput, { ...props });
|
|
3188
3233
|
const step = (0, import_parameters.parameterStep)(field);
|
|
3189
3234
|
const sliderProps = {
|
|
3190
3235
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -3198,8 +3243,8 @@ function ParameterSlider(props) {
|
|
|
3198
3243
|
className: rangeClass,
|
|
3199
3244
|
style: parameterRangeStyle
|
|
3200
3245
|
};
|
|
3201
|
-
return /* @__PURE__ */ (0,
|
|
3202
|
-
CustomSlider ? /* @__PURE__ */ (0,
|
|
3246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3247
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3203
3248
|
CustomSlider,
|
|
3204
3249
|
{
|
|
3205
3250
|
...sliderProps,
|
|
@@ -3209,7 +3254,7 @@ function ParameterSlider(props) {
|
|
|
3209
3254
|
onGestureStart: start,
|
|
3210
3255
|
onGestureEnd: end
|
|
3211
3256
|
}
|
|
3212
|
-
) : /* @__PURE__ */ (0,
|
|
3257
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3213
3258
|
"input",
|
|
3214
3259
|
{
|
|
3215
3260
|
type: "range",
|
|
@@ -3221,11 +3266,11 @@ function ParameterSlider(props) {
|
|
|
3221
3266
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
3222
3267
|
}
|
|
3223
3268
|
),
|
|
3224
|
-
/* @__PURE__ */ (0,
|
|
3269
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
3225
3270
|
] });
|
|
3226
3271
|
}
|
|
3227
3272
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
3228
|
-
return /* @__PURE__ */ (0,
|
|
3273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3229
3274
|
"button",
|
|
3230
3275
|
{
|
|
3231
3276
|
type: "button",
|
|
@@ -3236,7 +3281,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
3236
3281
|
disabled: disabled || field.readOnly,
|
|
3237
3282
|
onClick: () => onChange(!value),
|
|
3238
3283
|
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"}`,
|
|
3239
|
-
children: /* @__PURE__ */ (0,
|
|
3284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3240
3285
|
"span",
|
|
3241
3286
|
{
|
|
3242
3287
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -3253,7 +3298,7 @@ function ParameterSelect(props) {
|
|
|
3253
3298
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
3254
3299
|
const off = disabled || field.readOnly;
|
|
3255
3300
|
if (field.control === "segmented") {
|
|
3256
|
-
return /* @__PURE__ */ (0,
|
|
3301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsx)(
|
|
3257
3302
|
"button",
|
|
3258
3303
|
{
|
|
3259
3304
|
type: "button",
|
|
@@ -3270,7 +3315,7 @@ function ParameterSelect(props) {
|
|
|
3270
3315
|
}
|
|
3271
3316
|
if (CustomSelect) {
|
|
3272
3317
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
3273
|
-
return /* @__PURE__ */ (0,
|
|
3318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3274
3319
|
CustomSelect,
|
|
3275
3320
|
{
|
|
3276
3321
|
id,
|
|
@@ -3286,7 +3331,7 @@ function ParameterSelect(props) {
|
|
|
3286
3331
|
);
|
|
3287
3332
|
}
|
|
3288
3333
|
const index = options.findIndex((o) => o.value === value);
|
|
3289
|
-
return /* @__PURE__ */ (0,
|
|
3334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3290
3335
|
"select",
|
|
3291
3336
|
{
|
|
3292
3337
|
id,
|
|
@@ -3299,23 +3344,23 @@ function ParameterSelect(props) {
|
|
|
3299
3344
|
},
|
|
3300
3345
|
className: parameterInputClass,
|
|
3301
3346
|
style: parameterSelectStyle,
|
|
3302
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
3347
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
3303
3348
|
}
|
|
3304
3349
|
);
|
|
3305
3350
|
}
|
|
3306
3351
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
3307
3352
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
3308
|
-
const [open, setOpen] = (0,
|
|
3309
|
-
const containerRef = (0,
|
|
3310
|
-
const buttonRef = (0,
|
|
3311
|
-
const popoverRef = (0,
|
|
3353
|
+
const [open, setOpen] = (0, import_react26.useState)(false);
|
|
3354
|
+
const containerRef = (0, import_react26.useRef)(null);
|
|
3355
|
+
const buttonRef = (0, import_react26.useRef)(null);
|
|
3356
|
+
const popoverRef = (0, import_react26.useRef)(null);
|
|
3312
3357
|
const alpha = !!field.alpha;
|
|
3313
3358
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
3314
3359
|
const rgb = hex.slice(0, 7);
|
|
3315
3360
|
const shown = alpha ? hex : rgb;
|
|
3316
3361
|
const off = disabled || field.readOnly;
|
|
3317
3362
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3318
|
-
(0,
|
|
3363
|
+
(0, import_react26.useEffect)(() => {
|
|
3319
3364
|
if (!open) return;
|
|
3320
3365
|
const onPointerDown = (e) => {
|
|
3321
3366
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3337,7 +3382,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3337
3382
|
};
|
|
3338
3383
|
}, [open]);
|
|
3339
3384
|
if (CustomColor) {
|
|
3340
|
-
return /* @__PURE__ */ (0,
|
|
3385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3341
3386
|
CustomColor,
|
|
3342
3387
|
{
|
|
3343
3388
|
id,
|
|
@@ -3352,9 +3397,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3352
3397
|
}
|
|
3353
3398
|
);
|
|
3354
3399
|
}
|
|
3355
|
-
return /* @__PURE__ */ (0,
|
|
3356
|
-
/* @__PURE__ */ (0,
|
|
3357
|
-
/* @__PURE__ */ (0,
|
|
3400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
3401
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3402
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3358
3403
|
"button",
|
|
3359
3404
|
{
|
|
3360
3405
|
ref: buttonRef,
|
|
@@ -3365,10 +3410,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3365
3410
|
disabled: off,
|
|
3366
3411
|
onClick: () => setOpen((prev) => !prev),
|
|
3367
3412
|
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",
|
|
3368
|
-
children: /* @__PURE__ */ (0,
|
|
3413
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3369
3414
|
}
|
|
3370
3415
|
),
|
|
3371
|
-
/* @__PURE__ */ (0,
|
|
3416
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3372
3417
|
ParameterCommitInput,
|
|
3373
3418
|
{
|
|
3374
3419
|
id,
|
|
@@ -3384,7 +3429,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3384
3429
|
}
|
|
3385
3430
|
)
|
|
3386
3431
|
] }),
|
|
3387
|
-
open && /* @__PURE__ */ (0,
|
|
3432
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3388
3433
|
"div",
|
|
3389
3434
|
{
|
|
3390
3435
|
ref: popoverRef,
|
|
@@ -3398,7 +3443,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3398
3443
|
},
|
|
3399
3444
|
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",
|
|
3400
3445
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3401
|
-
children: /* @__PURE__ */ (0,
|
|
3446
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3402
3447
|
ColorPicker,
|
|
3403
3448
|
{
|
|
3404
3449
|
value: shown,
|
|
@@ -3416,11 +3461,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3416
3461
|
}
|
|
3417
3462
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
3418
3463
|
const size = (0, import_parameters.vectorSize)(field);
|
|
3419
|
-
return /* @__PURE__ */ (0,
|
|
3464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
3420
3465
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
3421
|
-
return /* @__PURE__ */ (0,
|
|
3422
|
-
/* @__PURE__ */ (0,
|
|
3423
|
-
/* @__PURE__ */ (0,
|
|
3466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3467
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
3468
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3424
3469
|
ParameterNumberInput,
|
|
3425
3470
|
{
|
|
3426
3471
|
field: component,
|
|
@@ -3438,11 +3483,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
3438
3483
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
3439
3484
|
const off = disabled || field.readOnly;
|
|
3440
3485
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3441
|
-
return /* @__PURE__ */ (0,
|
|
3442
|
-
/* @__PURE__ */ (0,
|
|
3443
|
-
/* @__PURE__ */ (0,
|
|
3444
|
-
/* @__PURE__ */ (0,
|
|
3445
|
-
/* @__PURE__ */ (0,
|
|
3486
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "space-y-1.5", children: [
|
|
3487
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3488
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3489
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3490
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3446
3491
|
ParameterCommitInput,
|
|
3447
3492
|
{
|
|
3448
3493
|
id,
|
|
@@ -3453,15 +3498,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3453
3498
|
onCommit: (text) => onChange(text.trim())
|
|
3454
3499
|
}
|
|
3455
3500
|
),
|
|
3456
|
-
/* @__PURE__ */ (0,
|
|
3457
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3501
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex gap-1", children: [
|
|
3502
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3458
3503
|
"label",
|
|
3459
3504
|
{
|
|
3460
3505
|
style: parameterButtonStyle,
|
|
3461
3506
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3462
3507
|
children: [
|
|
3463
3508
|
"Choose file\u2026",
|
|
3464
|
-
/* @__PURE__ */ (0,
|
|
3509
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3465
3510
|
"input",
|
|
3466
3511
|
{
|
|
3467
3512
|
type: "file",
|
|
@@ -3479,7 +3524,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3479
3524
|
]
|
|
3480
3525
|
}
|
|
3481
3526
|
),
|
|
3482
|
-
value && /* @__PURE__ */ (0,
|
|
3527
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3483
3528
|
"button",
|
|
3484
3529
|
{
|
|
3485
3530
|
type: "button",
|
|
@@ -3494,7 +3539,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3494
3539
|
] })
|
|
3495
3540
|
] })
|
|
3496
3541
|
] }),
|
|
3497
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
3542
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3498
3543
|
"button",
|
|
3499
3544
|
{
|
|
3500
3545
|
type: "button",
|
|
@@ -3504,14 +3549,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3504
3549
|
disabled: off,
|
|
3505
3550
|
onClick: () => onChange(o.url),
|
|
3506
3551
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
3507
|
-
children: /* @__PURE__ */ (0,
|
|
3552
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
3508
3553
|
},
|
|
3509
3554
|
o.url
|
|
3510
3555
|
)) })
|
|
3511
3556
|
] });
|
|
3512
3557
|
}
|
|
3513
3558
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
3514
|
-
return /* @__PURE__ */ (0,
|
|
3559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3515
3560
|
ParameterCommitInput,
|
|
3516
3561
|
{
|
|
3517
3562
|
id,
|
|
@@ -3530,24 +3575,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
3530
3575
|
switch (field.type) {
|
|
3531
3576
|
case "number":
|
|
3532
3577
|
case "int":
|
|
3533
|
-
return /* @__PURE__ */ (0,
|
|
3578
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
3534
3579
|
case "boolean":
|
|
3535
|
-
return /* @__PURE__ */ (0,
|
|
3580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
3536
3581
|
case "choice":
|
|
3537
|
-
return /* @__PURE__ */ (0,
|
|
3582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
3538
3583
|
case "color":
|
|
3539
|
-
return /* @__PURE__ */ (0,
|
|
3584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
3540
3585
|
case "vector":
|
|
3541
|
-
return /* @__PURE__ */ (0,
|
|
3586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
3542
3587
|
case "image":
|
|
3543
|
-
return /* @__PURE__ */ (0,
|
|
3588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
3544
3589
|
case "text":
|
|
3545
|
-
return /* @__PURE__ */ (0,
|
|
3590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
3546
3591
|
}
|
|
3547
3592
|
}
|
|
3548
3593
|
|
|
3549
3594
|
// src/effects/EffectParameters.tsx
|
|
3550
|
-
var
|
|
3595
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3551
3596
|
function EffectParameters({
|
|
3552
3597
|
description,
|
|
3553
3598
|
values,
|
|
@@ -3562,10 +3607,10 @@ function EffectParameters({
|
|
|
3562
3607
|
className = "",
|
|
3563
3608
|
components
|
|
3564
3609
|
}) {
|
|
3565
|
-
const fields = (0,
|
|
3566
|
-
const idBase = (0,
|
|
3567
|
-
const gesture =
|
|
3568
|
-
const count =
|
|
3610
|
+
const fields = (0, import_react27.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3611
|
+
const idBase = (0, import_react27.useId)();
|
|
3612
|
+
const gesture = import_react27.default.useRef(null);
|
|
3613
|
+
const count = import_react27.default.useRef(0);
|
|
3569
3614
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3570
3615
|
const handlePresetSelect = (name) => {
|
|
3571
3616
|
if (!name) return;
|
|
@@ -3576,8 +3621,8 @@ function EffectParameters({
|
|
|
3576
3621
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3577
3622
|
}
|
|
3578
3623
|
};
|
|
3579
|
-
return /* @__PURE__ */ (0,
|
|
3580
|
-
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0,
|
|
3624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3625
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3581
3626
|
CustomPresetSelect,
|
|
3582
3627
|
{
|
|
3583
3628
|
"aria-label": `${description.name} presets`,
|
|
@@ -3592,7 +3637,7 @@ function EffectParameters({
|
|
|
3592
3637
|
],
|
|
3593
3638
|
onChange: (name) => handlePresetSelect(String(name))
|
|
3594
3639
|
}
|
|
3595
|
-
) : /* @__PURE__ */ (0,
|
|
3640
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3596
3641
|
"select",
|
|
3597
3642
|
{
|
|
3598
3643
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -3602,8 +3647,8 @@ function EffectParameters({
|
|
|
3602
3647
|
disabled,
|
|
3603
3648
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3604
3649
|
children: [
|
|
3605
|
-
/* @__PURE__ */ (0,
|
|
3606
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3650
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
3651
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
3607
3652
|
]
|
|
3608
3653
|
}
|
|
3609
3654
|
)),
|
|
@@ -3613,14 +3658,14 @@ function EffectParameters({
|
|
|
3613
3658
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
3614
3659
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
3615
3660
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
3616
|
-
return /* @__PURE__ */ (0,
|
|
3617
|
-
/* @__PURE__ */ (0,
|
|
3618
|
-
/* @__PURE__ */ (0,
|
|
3619
|
-
keyed && /* @__PURE__ */ (0,
|
|
3661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
3662
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3663
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
3664
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
3620
3665
|
renderControlAddon?.(field.id),
|
|
3621
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3666
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime27.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" })
|
|
3622
3667
|
] }),
|
|
3623
|
-
/* @__PURE__ */ (0,
|
|
3668
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3624
3669
|
ParameterFieldControl,
|
|
3625
3670
|
{
|
|
3626
3671
|
field,
|
|
@@ -3635,15 +3680,15 @@ function EffectParameters({
|
|
|
3635
3680
|
)
|
|
3636
3681
|
] }, field.id);
|
|
3637
3682
|
}),
|
|
3638
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3683
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3639
3684
|
] });
|
|
3640
3685
|
}
|
|
3641
3686
|
|
|
3642
3687
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
3643
|
-
var
|
|
3688
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3644
3689
|
function usePaintEffectsProvider(controller) {
|
|
3645
|
-
const [provider, setProvider] = (0,
|
|
3646
|
-
(0,
|
|
3690
|
+
const [provider, setProvider] = (0, import_react28.useState)(controller.effectsProvider);
|
|
3691
|
+
(0, import_react28.useEffect)(() => {
|
|
3647
3692
|
setProvider(controller.effectsProvider);
|
|
3648
3693
|
return controller.effects.subscribe(setProvider);
|
|
3649
3694
|
}, [controller]);
|
|
@@ -3651,27 +3696,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
3651
3696
|
}
|
|
3652
3697
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
3653
3698
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
3654
|
-
(0,
|
|
3699
|
+
(0, import_react28.useEffect)(() => {
|
|
3655
3700
|
if (!registry) return;
|
|
3656
|
-
return registry.register((0,
|
|
3701
|
+
return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
3657
3702
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
3658
3703
|
}
|
|
3659
3704
|
function Controls({ provider, effect, name, values, apply }) {
|
|
3660
3705
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3661
|
-
const drags = (0,
|
|
3662
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
3706
|
+
const drags = (0, import_react28.useRef)(/* @__PURE__ */ new Set());
|
|
3707
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
|
|
3663
3708
|
'No effects provider: "',
|
|
3664
3709
|
name ?? effect,
|
|
3665
3710
|
'" is kept as it was drawn.'
|
|
3666
3711
|
] });
|
|
3667
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3668
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
3712
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
|
|
3713
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
3669
3714
|
const commit = (gesture) => {
|
|
3670
3715
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
3671
3716
|
drags.current.add(gesture);
|
|
3672
3717
|
return true;
|
|
3673
3718
|
};
|
|
3674
|
-
return /* @__PURE__ */ (0,
|
|
3719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3675
3720
|
EffectParameters,
|
|
3676
3721
|
{
|
|
3677
3722
|
description,
|
|
@@ -3693,8 +3738,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3693
3738
|
const state = usePaintEditorState(controller);
|
|
3694
3739
|
const provider = usePaintEffectsProvider(controller);
|
|
3695
3740
|
const [error, attempt] = useAttempt();
|
|
3696
|
-
const [browse, setBrowse] = (0,
|
|
3697
|
-
const [busy, setBusy] = (0,
|
|
3741
|
+
const [browse, setBrowse] = (0, import_react28.useState)(null);
|
|
3742
|
+
const [busy, setBusy] = (0, import_react28.useState)(false);
|
|
3698
3743
|
const paper = controller.getPaperEffect();
|
|
3699
3744
|
const activeId = state.document.activeLayerId;
|
|
3700
3745
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -3706,7 +3751,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3706
3751
|
if (!effectPaint) return;
|
|
3707
3752
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
3708
3753
|
};
|
|
3709
|
-
const thumbnail = (0,
|
|
3754
|
+
const thumbnail = (0, import_react28.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
3710
3755
|
const run = (work) => attempt(() => {
|
|
3711
3756
|
setBusy(true);
|
|
3712
3757
|
return work().finally(() => setBusy(false));
|
|
@@ -3722,28 +3767,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3722
3767
|
};
|
|
3723
3768
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
3724
3769
|
const pixel = active?.type === "pixel";
|
|
3725
|
-
return /* @__PURE__ */ (0,
|
|
3726
|
-
/* @__PURE__ */ (0,
|
|
3727
|
-
/* @__PURE__ */ (0,
|
|
3728
|
-
/* @__PURE__ */ (0,
|
|
3729
|
-
/* @__PURE__ */ (0,
|
|
3730
|
-
/* @__PURE__ */ (0,
|
|
3731
|
-
/* @__PURE__ */ (0,
|
|
3732
|
-
/* @__PURE__ */ (0,
|
|
3770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
3771
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3772
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
3773
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
3774
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
3775
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
3776
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.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" }),
|
|
3777
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.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" })
|
|
3733
3778
|
] }),
|
|
3734
|
-
!provider && /* @__PURE__ */ (0,
|
|
3735
|
-
browse && /* @__PURE__ */ (0,
|
|
3736
|
-
paper && /* @__PURE__ */ (0,
|
|
3737
|
-
/* @__PURE__ */ (0,
|
|
3738
|
-
/* @__PURE__ */ (0,
|
|
3779
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
3780
|
+
browse && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
3781
|
+
paper && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
3782
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3783
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3739
3784
|
"Paper: ",
|
|
3740
3785
|
paper.name ?? paper.effect
|
|
3741
3786
|
] }),
|
|
3742
|
-
/* @__PURE__ */ (0,
|
|
3787
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
3743
3788
|
] }),
|
|
3744
|
-
/* @__PURE__ */ (0,
|
|
3745
|
-
/* @__PURE__ */ (0,
|
|
3746
|
-
/* @__PURE__ */ (0,
|
|
3789
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3790
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
3791
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3747
3792
|
"input",
|
|
3748
3793
|
{
|
|
3749
3794
|
type: "range",
|
|
@@ -3765,39 +3810,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3765
3810
|
`o${paper.opacity}`
|
|
3766
3811
|
)
|
|
3767
3812
|
] }),
|
|
3768
|
-
/* @__PURE__ */ (0,
|
|
3769
|
-
/* @__PURE__ */ (0,
|
|
3770
|
-
/* @__PURE__ */ (0,
|
|
3813
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
3815
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.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) => {
|
|
3771
3816
|
const blend = e.currentTarget.value;
|
|
3772
3817
|
run(() => controller.updatePaperEffect({ blend }));
|
|
3773
|
-
}, children:
|
|
3818
|
+
}, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: b, children: b }, b)) })
|
|
3774
3819
|
] }),
|
|
3775
|
-
/* @__PURE__ */ (0,
|
|
3820
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
3776
3821
|
] }),
|
|
3777
|
-
effectPaint && /* @__PURE__ */ (0,
|
|
3778
|
-
/* @__PURE__ */ (0,
|
|
3779
|
-
thumbnail ? /* @__PURE__ */ (0,
|
|
3780
|
-
/* @__PURE__ */ (0,
|
|
3822
|
+
effectPaint && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
3823
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3824
|
+
thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
3825
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3781
3826
|
"Paint: ",
|
|
3782
3827
|
effectPaint.effect,
|
|
3783
3828
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
3784
3829
|
] }),
|
|
3785
|
-
/* @__PURE__ */ (0,
|
|
3830
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
3786
3831
|
] }),
|
|
3787
|
-
/* @__PURE__ */ (0,
|
|
3788
|
-
/* @__PURE__ */ (0,
|
|
3789
|
-
/* @__PURE__ */ (0,
|
|
3832
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
3833
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
3834
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
3790
3835
|
"Along the stroke"
|
|
3791
3836
|
] }),
|
|
3792
|
-
/* @__PURE__ */ (0,
|
|
3793
|
-
/* @__PURE__ */ (0,
|
|
3837
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
3838
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
3794
3839
|
"Live"
|
|
3795
3840
|
] })
|
|
3796
3841
|
] }),
|
|
3797
|
-
effectPaint.map && /* @__PURE__ */ (0,
|
|
3798
|
-
/* @__PURE__ */ (0,
|
|
3799
|
-
/* @__PURE__ */ (0,
|
|
3800
|
-
/* @__PURE__ */ (0,
|
|
3842
|
+
effectPaint.map && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3843
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3844
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-slate-400", children: "Length" }),
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3801
3846
|
"input",
|
|
3802
3847
|
{
|
|
3803
3848
|
type: "number",
|
|
@@ -3811,55 +3856,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3811
3856
|
effectPaint.map.length
|
|
3812
3857
|
)
|
|
3813
3858
|
] }),
|
|
3814
|
-
/* @__PURE__ */ (0,
|
|
3815
|
-
/* @__PURE__ */ (0,
|
|
3816
|
-
/* @__PURE__ */ (0,
|
|
3817
|
-
/* @__PURE__ */ (0,
|
|
3859
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.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: [
|
|
3860
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "repeat", children: "Repeat" }),
|
|
3861
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "mirror", children: "Mirror" }),
|
|
3862
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "clamp", children: "Clamp" })
|
|
3818
3863
|
] })
|
|
3819
3864
|
] }),
|
|
3820
|
-
/* @__PURE__ */ (0,
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
3821
3866
|
] }),
|
|
3822
|
-
animation && /* @__PURE__ */ (0,
|
|
3823
|
-
/* @__PURE__ */ (0,
|
|
3867
|
+
animation && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
3868
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3824
3869
|
"Live paint: ",
|
|
3825
3870
|
animation.strokes,
|
|
3826
3871
|
" ",
|
|
3827
3872
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
3828
3873
|
] }),
|
|
3829
|
-
/* @__PURE__ */ (0,
|
|
3830
|
-
/* @__PURE__ */ (0,
|
|
3831
|
-
/* @__PURE__ */ (0,
|
|
3832
|
-
/* @__PURE__ */ (0,
|
|
3874
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
3875
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3876
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-slate-400", children: "fps" }),
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.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" })
|
|
3833
3878
|
] })
|
|
3834
3879
|
] }),
|
|
3835
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
3836
|
-
/* @__PURE__ */ (0,
|
|
3837
|
-
/* @__PURE__ */ (0,
|
|
3880
|
+
layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
3881
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3882
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3838
3883
|
"Layer: ",
|
|
3839
3884
|
layerEffect.name ?? layerEffect.effect
|
|
3840
3885
|
] }),
|
|
3841
|
-
/* @__PURE__ */ (0,
|
|
3886
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
3842
3887
|
] }),
|
|
3843
|
-
/* @__PURE__ */ (0,
|
|
3888
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
3844
3889
|
] }),
|
|
3845
|
-
/* @__PURE__ */ (0,
|
|
3890
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ErrorLine, { error })
|
|
3846
3891
|
] });
|
|
3847
3892
|
};
|
|
3848
3893
|
|
|
3849
3894
|
// src/paint-editor/PaintEditor.tsx
|
|
3850
|
-
var
|
|
3895
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3851
3896
|
var PAINT_CONTROLS = {
|
|
3852
3897
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
3853
3898
|
lighting: '[data-testid="light-panel"]',
|
|
3854
3899
|
symmetry: '[aria-label="Symmetry"]'
|
|
3855
3900
|
};
|
|
3856
3901
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
3857
|
-
const [tool, setTool] = (0,
|
|
3858
|
-
const [tab, setTab] = (0,
|
|
3859
|
-
const tabRef = (0,
|
|
3902
|
+
const [tool, setTool] = (0, import_react29.useState)("brush");
|
|
3903
|
+
const [tab, setTab] = (0, import_react29.useState)("color");
|
|
3904
|
+
const tabRef = (0, import_react29.useRef)(tab);
|
|
3860
3905
|
tabRef.current = tab;
|
|
3861
|
-
const rootRef = (0,
|
|
3862
|
-
const [ownPresence] = (0,
|
|
3906
|
+
const rootRef = (0, import_react29.useRef)(null);
|
|
3907
|
+
const [ownPresence] = (0, import_react29.useState)(() => new import_paint_editor14.PaintPresence());
|
|
3863
3908
|
const ambientPlayback = useAgentPlayback();
|
|
3864
3909
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
3865
3910
|
const viewBox = () => {
|
|
@@ -3870,12 +3915,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3870
3915
|
const docToClient = (p) => {
|
|
3871
3916
|
const r = viewBox();
|
|
3872
3917
|
if (!r) return null;
|
|
3873
|
-
const q = (0,
|
|
3918
|
+
const q = (0, import_paint_editor14.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
|
|
3874
3919
|
return { x: r.left + q.x, y: r.top + q.y };
|
|
3875
3920
|
};
|
|
3876
3921
|
const clientToDoc = (p) => {
|
|
3877
3922
|
const r = viewBox();
|
|
3878
|
-
return r ? (0,
|
|
3923
|
+
return r ? (0, import_paint_editor14.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
|
|
3879
3924
|
};
|
|
3880
3925
|
const elementRect = (selector) => {
|
|
3881
3926
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -3915,28 +3960,28 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3915
3960
|
const box = rootRef.current?.getBoundingClientRect();
|
|
3916
3961
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
3917
3962
|
};
|
|
3918
|
-
const [error, setError] = (0,
|
|
3963
|
+
const [error, setError] = (0, import_react29.useState)(null);
|
|
3919
3964
|
const effects = usePaintEffectsProvider(controller);
|
|
3920
3965
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
3921
|
-
return /* @__PURE__ */ (0,
|
|
3922
|
-
playing && /* @__PURE__ */ (0,
|
|
3923
|
-
/* @__PURE__ */ (0,
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
3925
|
-
/* @__PURE__ */ (0,
|
|
3926
|
-
/* @__PURE__ */ (0,
|
|
3927
|
-
/* @__PURE__ */ (0,
|
|
3928
|
-
error && /* @__PURE__ */ (0,
|
|
3966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.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: [
|
|
3967
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
3968
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
3969
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
3970
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
3971
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
3972
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
3973
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
3929
3974
|
] }),
|
|
3930
|
-
/* @__PURE__ */ (0,
|
|
3931
|
-
/* @__PURE__ */ (0,
|
|
3932
|
-
/* @__PURE__ */ (0,
|
|
3933
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
3934
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
3935
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
3936
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3937
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3938
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3939
|
-
tab === "effects" && effects && /* @__PURE__ */ (0,
|
|
3975
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
3976
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime29.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)) }),
|
|
3977
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
3978
|
+
tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ColorPanel, { controller }),
|
|
3979
|
+
tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(WetPanel, { controller }),
|
|
3980
|
+
tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaperPanel, { controller }),
|
|
3981
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintLayersPanel, { controller }),
|
|
3982
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(StrokePanel, { controller }),
|
|
3983
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(StickerPanel, { controller }),
|
|
3984
|
+
tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintEffectsPanel, { controller })
|
|
3940
3985
|
] })
|
|
3941
3986
|
] })
|
|
3942
3987
|
] })
|
|
@@ -3944,6 +3989,8 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3944
3989
|
};
|
|
3945
3990
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3946
3991
|
0 && (module.exports = {
|
|
3992
|
+
BrushEditor,
|
|
3993
|
+
BrushLibraryBrowser,
|
|
3947
3994
|
BrushPanel,
|
|
3948
3995
|
ColorPanel,
|
|
3949
3996
|
PaintCanvas,
|