@pixerate/editor-react 0.169.0 → 0.170.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paint-editor/StickerPanel.d.cts +1 -1
- package/dist/paint-editor/StickerPanel.d.ts +1 -1
- package/dist/paint-editor/StickerPicker.d.cts +17 -0
- package/dist/paint-editor/StickerPicker.d.ts +17 -0
- package/dist/paint-editor/index.cjs +745 -689
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +439 -384
- package/package.json +3 -3
|
@@ -43,6 +43,7 @@ __export(paint_editor_exports, {
|
|
|
43
43
|
PaintToolbar: () => PaintToolbar,
|
|
44
44
|
PaperPanel: () => PaperPanel,
|
|
45
45
|
StickerPanel: () => StickerPanel,
|
|
46
|
+
StickerPicker: () => StickerPicker,
|
|
46
47
|
StrokePanel: () => StrokePanel,
|
|
47
48
|
WetPanel: () => WetPanel,
|
|
48
49
|
usePaintDirector: () => usePaintDirector,
|
|
@@ -598,9 +599,9 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
598
599
|
};
|
|
599
600
|
|
|
600
601
|
// src/paint-editor/BrushPanel.tsx
|
|
601
|
-
var
|
|
602
|
-
var import_paint_editor5 = require("@pixerate/editor/paint-editor");
|
|
602
|
+
var import_react7 = require("react");
|
|
603
603
|
var import_paint_editor6 = require("@pixerate/editor/paint-editor");
|
|
604
|
+
var import_paint_editor7 = require("@pixerate/editor/paint-editor");
|
|
604
605
|
|
|
605
606
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
606
607
|
var import_paint_editor4 = require("@pixerate/editor/paint-editor");
|
|
@@ -731,26 +732,79 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
|
731
732
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
732
733
|
var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PaintGradientEditorView, { ...props, kit: import_paint_editor4.PAINT_GRADIENT_KIT });
|
|
733
734
|
|
|
734
|
-
// src/paint-editor/
|
|
735
|
+
// src/paint-editor/StickerPicker.tsx
|
|
736
|
+
var import_react6 = require("react");
|
|
737
|
+
var import_paint_editor5 = require("@pixerate/editor/paint-editor");
|
|
735
738
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
739
|
+
var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
740
|
+
const browser = (0, import_react6.useMemo)(() => new import_paint_editor5.StickerBrowser(() => controller.stickersProvider), [controller]);
|
|
741
|
+
const [, setTick] = (0, import_react6.useState)(0);
|
|
742
|
+
(0, import_react6.useEffect)(() => browser.subscribe(() => setTick((n) => n + 1)), [browser]);
|
|
743
|
+
(0, import_react6.useEffect)(() => {
|
|
744
|
+
void browser.refresh();
|
|
745
|
+
return controller.stickers.subscribe(() => void browser.refresh());
|
|
746
|
+
}, [browser, controller]);
|
|
747
|
+
const s = browser.state;
|
|
748
|
+
const failed = selected.map((ref) => ({ ref, ...controller.stickerArtStatus(ref) })).filter((x) => x.status === "failed");
|
|
749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col gap-1", "data-testid": "sticker-picker", children: [
|
|
750
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
751
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.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" }),
|
|
752
|
+
s.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime6.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: [
|
|
753
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: "All" }),
|
|
754
|
+
s.categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: c.id, children: c.name }, c.id))
|
|
755
|
+
] })
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.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
|
+
const on = selected.includes(it.ref);
|
|
759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
760
|
+
"button",
|
|
761
|
+
{
|
|
762
|
+
type: "button",
|
|
763
|
+
"aria-pressed": on,
|
|
764
|
+
title: `${it.name} (${it.ref}) \xB7 ${it.licence.name}`,
|
|
765
|
+
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.ref),
|
|
767
|
+
children: [
|
|
768
|
+
it.thumbnail && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: it.thumbnail, alt: "", className: "h-4 w-4" }),
|
|
769
|
+
it.name
|
|
770
|
+
]
|
|
771
|
+
},
|
|
772
|
+
it.ref
|
|
773
|
+
);
|
|
774
|
+
}) }),
|
|
775
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center justify-between text-[10px] text-slate-500", children: [
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: s.loading ? "Loading\u2026" : `${s.items.length} of ${s.total}` }),
|
|
777
|
+
s.hasMore && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "text-indigo-300", onClick: () => void browser.more(), children: "More" })
|
|
778
|
+
] }),
|
|
779
|
+
s.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: s.error }),
|
|
780
|
+
failed.map((f) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { role: "alert", className: "text-[11px] text-rose-400", children: [
|
|
781
|
+
f.ref,
|
|
782
|
+
": ",
|
|
783
|
+
f.error
|
|
784
|
+
] }, f.ref))
|
|
785
|
+
] });
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
// src/paint-editor/BrushPanel.tsx
|
|
789
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
736
790
|
var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
737
791
|
const state = usePaintEditorState(controller);
|
|
738
792
|
const [error, attempt] = useAttempt();
|
|
739
|
-
const [saveName, setSaveName] = (0,
|
|
740
|
-
const fileRef = (0,
|
|
793
|
+
const [saveName, setSaveName] = (0, import_react7.useState)("");
|
|
794
|
+
const fileRef = (0, import_react7.useRef)(null);
|
|
741
795
|
const { brush, brushes } = state;
|
|
742
796
|
const paper = state.document.paper;
|
|
743
|
-
const thumbs = (0,
|
|
797
|
+
const thumbs = (0, import_react7.useMemo)(
|
|
744
798
|
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: "#26324a" })])),
|
|
745
799
|
// Thumbnails follow the library and the paper.
|
|
746
800
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
747
801
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
748
802
|
);
|
|
749
|
-
const engine = (0,
|
|
750
|
-
const carried = (0,
|
|
803
|
+
const engine = (0, import_paint_editor6.brushEngineControls)(brush);
|
|
804
|
+
const carried = (0, import_paint_editor6.brushLoadColor)(state.mixerLoad);
|
|
751
805
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
752
|
-
return /* @__PURE__ */ (0,
|
|
753
|
-
/* @__PURE__ */ (0,
|
|
806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "grid grid-cols-2 gap-1", role: "listbox", "aria-label": "Brushes", children: brushes.map((b) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
754
808
|
"button",
|
|
755
809
|
{
|
|
756
810
|
type: "button",
|
|
@@ -760,147 +814,137 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
760
814
|
className: `flex flex-col items-start gap-0.5 rounded p-1 text-left ${brush.id === b.id ? "bg-indigo-600/30 ring-1 ring-indigo-500" : "bg-slate-900 hover:bg-slate-800"}`,
|
|
761
815
|
onClick: () => controller.setBrush({ id: b.id }),
|
|
762
816
|
children: [
|
|
763
|
-
/* @__PURE__ */ (0,
|
|
764
|
-
/* @__PURE__ */ (0,
|
|
817
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PixelCanvas, { pixels: thumbs.get(b.id) ?? null, label: `${b.name} thumbnail`, className: "rounded", style: { width: "100%", aspectRatio: `${thumbnailWidth} / ${thumbnailHeight}` } }),
|
|
818
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate text-[10px] text-slate-300", children: b.name })
|
|
765
819
|
]
|
|
766
820
|
},
|
|
767
821
|
b.id
|
|
768
822
|
)) }),
|
|
769
|
-
/* @__PURE__ */ (0,
|
|
770
|
-
|
|
771
|
-
/* @__PURE__ */ (0,
|
|
772
|
-
/* @__PURE__ */ (0,
|
|
773
|
-
/* @__PURE__ */ (0,
|
|
823
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
824
|
+
import_paint_editor6.BRUSH_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)),
|
|
825
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
826
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Rotation" }),
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Brush rotation", value: brush.rotation, onChange: (e) => controller.setBrush({ rotation: e.target.value }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.BRUSH_ROTATIONS.map((r) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: r, children: r === "stroke" ? "Follow stroke" : r === "barrel" ? "Pen barrel" : "Fixed" }, r)) })
|
|
774
828
|
] }),
|
|
775
|
-
/* @__PURE__ */ (0,
|
|
776
|
-
/* @__PURE__ */ (0,
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "checkbox", checked: brush.tip.pressureSize, onChange: (e) => controller.setBrush({ tip: { pressureSize: e.target.checked } }) }),
|
|
777
831
|
" Pressure \u2192 size"
|
|
778
832
|
] }),
|
|
779
|
-
/* @__PURE__ */ (0,
|
|
780
|
-
/* @__PURE__ */ (0,
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
834
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "checkbox", checked: brush.tip.pressureOpacity, onChange: (e) => controller.setBrush({ tip: { pressureOpacity: e.target.checked } }) }),
|
|
781
835
|
" Pressure \u2192 opacity"
|
|
782
836
|
] }),
|
|
783
|
-
brush.engine === "dab" && /* @__PURE__ */ (0,
|
|
784
|
-
/* @__PURE__ */ (0,
|
|
785
|
-
/* @__PURE__ */ (0,
|
|
837
|
+
brush.engine === "dab" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
838
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Blend" }),
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Brush blend", value: brush.tip.blend, onChange: (e) => controller.setBrush({ tip: { blend: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label)) })
|
|
786
840
|
] })
|
|
787
841
|
] }),
|
|
788
|
-
engine && /* @__PURE__ */ (0,
|
|
789
|
-
/* @__PURE__ */ (0,
|
|
790
|
-
engine.wetTool && /* @__PURE__ */ (0,
|
|
791
|
-
/* @__PURE__ */ (0,
|
|
792
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
793
847
|
] }),
|
|
794
|
-
engine.wetTool && /* @__PURE__ */ (0,
|
|
795
|
-
/* @__PURE__ */ (0,
|
|
796
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
797
851
|
] }),
|
|
798
|
-
engine.particleMenus && /* @__PURE__ */ (0,
|
|
799
|
-
/* @__PURE__ */ (0,
|
|
800
|
-
/* @__PURE__ */ (0,
|
|
801
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
802
856
|
] }),
|
|
803
|
-
/* @__PURE__ */ (0,
|
|
804
|
-
/* @__PURE__ */ (0,
|
|
805
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
806
860
|
] }),
|
|
807
|
-
brush.particle.render === "ribbon" && /* @__PURE__ */ (0,
|
|
808
|
-
/* @__PURE__ */ (0,
|
|
809
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
810
864
|
] }),
|
|
811
|
-
(brush.particle.render === "dot" || brush.particle.render === "sequence") && /* @__PURE__ */ (0,
|
|
812
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
813
867
|
"button",
|
|
814
868
|
{
|
|
815
869
|
type: "button",
|
|
816
870
|
"aria-pressed": brush.particle.dotTextures.includes(k),
|
|
817
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"}`,
|
|
818
|
-
onClick: () => controller.setBrush({ particle: { dotTextures: (0,
|
|
819
|
-
children:
|
|
872
|
+
onClick: () => controller.setBrush({ particle: { dotTextures: (0, import_paint_editor6.toggleDotTexture)(brush.particle.dotTextures, k) } }),
|
|
873
|
+
children: import_paint_editor6.STAMP_LABELS[k]
|
|
820
874
|
},
|
|
821
875
|
k
|
|
822
876
|
)) }),
|
|
823
|
-
brush.particle.dotTextures.length > 0 && /* @__PURE__ */ (0,
|
|
824
|
-
/* @__PURE__ */ (0,
|
|
825
|
-
/* @__PURE__ */ (0,
|
|
826
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
827
881
|
] }),
|
|
828
|
-
/* @__PURE__ */ (0,
|
|
829
|
-
/* @__PURE__ */ (0,
|
|
830
|
-
/* @__PURE__ */ (0,
|
|
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)) })
|
|
831
885
|
] })
|
|
832
886
|
] })
|
|
833
887
|
] })
|
|
834
888
|
] }),
|
|
835
|
-
engine.stickerStamps && /* @__PURE__ */ (0,
|
|
836
|
-
|
|
837
|
-
{
|
|
838
|
-
|
|
839
|
-
"aria-pressed": brush.sticker.stamps.includes(k),
|
|
840
|
-
className: `px-1.5 py-0.5 rounded text-[10px] ${brush.sticker.stamps.includes(k) ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
841
|
-
onClick: () => controller.setBrush({ sticker: { stamps: (0, import_paint_editor5.toggleStamp)(brush.sticker.stamps, k) } }),
|
|
842
|
-
children: import_paint_editor5.STAMP_LABELS[k]
|
|
843
|
-
},
|
|
844
|
-
k
|
|
845
|
-
)) }),
|
|
846
|
-
engine.impastoTool && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
847
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-slate-400", children: "Tool" }),
|
|
848
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.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_editor5.IMPASTO_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: t, children: import_paint_editor5.IMPASTO_TOOL_LABELS[t] }, t)) })
|
|
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)) })
|
|
849
893
|
] }),
|
|
850
|
-
engine.sliders.map((c) => /* @__PURE__ */ (0,
|
|
851
|
-
engine.mixingPath && /* @__PURE__ */ (0,
|
|
852
|
-
/* @__PURE__ */ (0,
|
|
853
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
854
898
|
"select",
|
|
855
899
|
{
|
|
856
900
|
"aria-label": "Brush mixing",
|
|
857
901
|
value: engine.mixingPath === "blender.mixing" ? brush.blender.mixing : engine.mixingPath === "smudge.mixing" ? brush.smudge.mixing : brush.behavior.mixing,
|
|
858
|
-
onChange: (e) => controller.setBrush((0,
|
|
902
|
+
onChange: (e) => controller.setBrush((0, import_paint_editor6.patchBrushValue)(brush, engine.mixingPath, e.target.value)),
|
|
859
903
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
860
904
|
children: [
|
|
861
|
-
/* @__PURE__ */ (0,
|
|
862
|
-
/* @__PURE__ */ (0,
|
|
905
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "pigment", children: "Pigment" }),
|
|
906
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "rgb", children: "RGB" })
|
|
863
907
|
]
|
|
864
908
|
}
|
|
865
909
|
)
|
|
866
910
|
] }),
|
|
867
|
-
engine.light && brush.light.amount > 0 && /* @__PURE__ */ (0,
|
|
868
|
-
/* @__PURE__ */ (0,
|
|
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 } }) }),
|
|
869
913
|
" Light follows pressure"
|
|
870
914
|
] }),
|
|
871
|
-
engine.dirty && /* @__PURE__ */ (0,
|
|
872
|
-
/* @__PURE__ */ (0,
|
|
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 } }) }),
|
|
873
917
|
" Dirty brush"
|
|
874
918
|
] }),
|
|
875
|
-
(0,
|
|
876
|
-
/* @__PURE__ */ (0,
|
|
877
|
-
/* @__PURE__ */ (0,
|
|
878
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
879
923
|
"button",
|
|
880
924
|
{
|
|
881
925
|
type: "button",
|
|
882
926
|
"aria-pressed": brush.paint !== null,
|
|
883
927
|
className: chip(brush.paint !== null),
|
|
884
|
-
onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null :
|
|
928
|
+
onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : import_paint_editor7.DEFAULT_PAINT_GRADIENT })),
|
|
885
929
|
children: brush.paint ? "On" : "Off"
|
|
886
930
|
}
|
|
887
931
|
)
|
|
888
932
|
] }),
|
|
889
|
-
brush.paint && /* @__PURE__ */ (0,
|
|
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 })) })
|
|
890
934
|
] }),
|
|
891
|
-
engine.load && /* @__PURE__ */ (0,
|
|
892
|
-
/* @__PURE__ */ (0,
|
|
893
|
-
/* @__PURE__ */ (0,
|
|
894
|
-
brush.engine === "mixer" && /* @__PURE__ */ (0,
|
|
895
|
-
/* @__PURE__ */ (0,
|
|
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" })
|
|
896
940
|
] })
|
|
897
941
|
] }),
|
|
898
|
-
/* @__PURE__ */ (0,
|
|
899
|
-
/* @__PURE__ */ (0,
|
|
900
|
-
/* @__PURE__ */ (0,
|
|
901
|
-
/* @__PURE__ */ (0,
|
|
902
|
-
/* @__PURE__ */ (0,
|
|
903
|
-
/* @__PURE__ */ (0,
|
|
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)(
|
|
904
948
|
"input",
|
|
905
949
|
{
|
|
906
950
|
ref: fileRef,
|
|
@@ -916,24 +960,24 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
916
960
|
}
|
|
917
961
|
)
|
|
918
962
|
] }),
|
|
919
|
-
/* @__PURE__ */ (0,
|
|
963
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ErrorLine, { error })
|
|
920
964
|
] });
|
|
921
965
|
};
|
|
922
966
|
|
|
923
967
|
// src/paint-editor/PaperPanel.tsx
|
|
924
|
-
var
|
|
925
|
-
var
|
|
926
|
-
var
|
|
968
|
+
var import_react8 = require("react");
|
|
969
|
+
var import_paint_editor8 = require("@pixerate/editor/paint-editor");
|
|
970
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
927
971
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
928
972
|
var PaperPanel = ({ controller, className }) => {
|
|
929
973
|
const state = usePaintEditorState(controller);
|
|
930
974
|
const [error, attempt] = useAttempt();
|
|
931
975
|
const paper = state.document.paper;
|
|
932
|
-
const previews = (0,
|
|
933
|
-
return /* @__PURE__ */ (0,
|
|
934
|
-
|
|
935
|
-
/* @__PURE__ */ (0,
|
|
936
|
-
/* @__PURE__ */ (0,
|
|
976
|
+
const previews = (0, import_react8.useMemo)(() => new Map(import_paint_editor8.PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: (0, import_paint_editor8.renderPaper)({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
978
|
+
import_paint_editor8.PAPER_FAMILIES.map((family) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: import_paint_editor8.PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
937
981
|
"button",
|
|
938
982
|
{
|
|
939
983
|
type: "button",
|
|
@@ -942,98 +986,98 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
942
986
|
title: p.name,
|
|
943
987
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
944
988
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
945
|
-
children: /* @__PURE__ */ (0,
|
|
989
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
946
990
|
},
|
|
947
991
|
p.preset
|
|
948
992
|
)) })
|
|
949
993
|
] }, family)),
|
|
950
|
-
/* @__PURE__ */ (0,
|
|
951
|
-
/* @__PURE__ */ (0,
|
|
952
|
-
/* @__PURE__ */ (0,
|
|
953
|
-
/* @__PURE__ */ (0,
|
|
994
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-slate-300", children: paper.name }),
|
|
995
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
996
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
997
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
954
998
|
] }),
|
|
955
|
-
|
|
956
|
-
/* @__PURE__ */ (0,
|
|
957
|
-
/* @__PURE__ */ (0,
|
|
958
|
-
/* @__PURE__ */ (0,
|
|
999
|
+
import_paint_editor8.PAPER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor8.readPath)(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper((0, import_paint_editor8.patchPath)(paper, c.path, v))) }, c.path)),
|
|
1000
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1001
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
1002
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommitColorInput, { label: "Backlight colour", value: paper.backlightColor ?? import_paint_editor8.DEFAULT_BACKLIGHT_COLOR, onCommit: (v) => attempt(() => controller.setPaper({ backlightColor: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
959
1003
|
] }),
|
|
960
|
-
/* @__PURE__ */ (0,
|
|
961
|
-
/* @__PURE__ */ (0,
|
|
1004
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
962
1006
|
" Mirror tiling"
|
|
963
1007
|
] }),
|
|
964
|
-
/* @__PURE__ */ (0,
|
|
965
|
-
/* @__PURE__ */ (0,
|
|
966
|
-
/* @__PURE__ */ (0,
|
|
967
|
-
|
|
968
|
-
/* @__PURE__ */ (0,
|
|
1008
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.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" }),
|
|
1009
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
1010
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
1011
|
+
import_paint_editor8.LIGHT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor8.readPath)(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
1012
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.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" })
|
|
969
1013
|
] }),
|
|
970
|
-
/* @__PURE__ */ (0,
|
|
1014
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorLine, { error })
|
|
971
1015
|
] });
|
|
972
1016
|
};
|
|
973
1017
|
|
|
974
1018
|
// src/paint-editor/ColorPanel.tsx
|
|
975
|
-
var
|
|
976
|
-
var import_paint_editor8 = require("@pixerate/editor/paint-editor");
|
|
1019
|
+
var import_react9 = require("react");
|
|
977
1020
|
var import_paint_editor9 = require("@pixerate/editor/paint-editor");
|
|
978
|
-
var
|
|
1021
|
+
var import_paint_editor10 = require("@pixerate/editor/paint-editor");
|
|
1022
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
979
1023
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
980
1024
|
const state = usePaintEditorState(controller);
|
|
981
1025
|
const [error, attempt] = useAttempt();
|
|
982
|
-
const [wheel, setWheel] = (0,
|
|
983
|
-
const [kind, setKind] = (0,
|
|
984
|
-
const [padTool, setPadTool] = (0,
|
|
985
|
-
const [sample, setSample] = (0,
|
|
986
|
-
const [parts, setParts] = (0,
|
|
987
|
-
const [padName, setPadName] = (0,
|
|
988
|
-
const padPoints = (0,
|
|
989
|
-
const ring = (0,
|
|
1026
|
+
const [wheel, setWheel] = (0, import_react9.useState)("ryb");
|
|
1027
|
+
const [kind, setKind] = (0, import_react9.useState)("complementary");
|
|
1028
|
+
const [padTool, setPadTool] = (0, import_react9.useState)("paint");
|
|
1029
|
+
const [sample, setSample] = (0, import_react9.useState)(3);
|
|
1030
|
+
const [parts, setParts] = (0, import_react9.useState)([1, 1]);
|
|
1031
|
+
const [padName, setPadName] = (0, import_react9.useState)("");
|
|
1032
|
+
const padPoints = (0, import_react9.useRef)(null);
|
|
1033
|
+
const ring = (0, import_react9.useMemo)(() => (0, import_paint_editor9.renderColorWheel)(wheelSize, wheel), [wheelSize, wheel]);
|
|
990
1034
|
const color = state.color;
|
|
991
|
-
const harmony = (0,
|
|
992
|
-
const [r, g, b] = (0,
|
|
993
|
-
const hsv = (0,
|
|
994
|
-
const effectWell = (0,
|
|
995
|
-
const pad = (0,
|
|
1035
|
+
const harmony = (0, import_react9.useMemo)(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
1036
|
+
const [r, g, b] = (0, import_paint_editor9.parseHexColor)(color);
|
|
1037
|
+
const hsv = (0, import_paint_editor9.rgbToHsv)(r, g, b);
|
|
1038
|
+
const effectWell = (0, import_react9.useMemo)(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
1039
|
+
const pad = (0, import_react9.useMemo)(() => ({ width: import_paint_editor9.MIXING_PAD_WIDTH, height: import_paint_editor9.MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
996
1040
|
const R = wheelSize / 2;
|
|
997
1041
|
const mid = R * 0.82;
|
|
998
|
-
const setHsv = (s, v) => controller.setColor((0,
|
|
1042
|
+
const setHsv = (s, v) => controller.setColor((0, import_paint_editor9.rgbToHexColor)(...(0, import_paint_editor9.hsvToRgb)(hsv.h, s, v)));
|
|
999
1043
|
const padPoint = (e) => {
|
|
1000
1044
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1001
|
-
const kx =
|
|
1002
|
-
const ky =
|
|
1003
|
-
const x = Math.min(
|
|
1004
|
-
const y = Math.min(
|
|
1045
|
+
const kx = import_paint_editor9.MIXING_PAD_WIDTH / (rect.width || import_paint_editor9.MIXING_PAD_WIDTH);
|
|
1046
|
+
const ky = import_paint_editor9.MIXING_PAD_HEIGHT / (rect.height || import_paint_editor9.MIXING_PAD_HEIGHT);
|
|
1047
|
+
const x = Math.min(import_paint_editor9.MIXING_PAD_WIDTH, Math.max(0, (e.clientX - rect.left) * kx));
|
|
1048
|
+
const y = Math.min(import_paint_editor9.MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
1005
1049
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
1006
1050
|
};
|
|
1007
|
-
return /* @__PURE__ */ (0,
|
|
1008
|
-
/* @__PURE__ */ (0,
|
|
1009
|
-
/* @__PURE__ */ (0,
|
|
1051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
1052
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
1053
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1010
1054
|
"div",
|
|
1011
1055
|
{
|
|
1012
1056
|
role: "slider",
|
|
1013
1057
|
"aria-label": "Hue wheel",
|
|
1014
1058
|
"aria-valuemin": 0,
|
|
1015
1059
|
"aria-valuemax": 360,
|
|
1016
|
-
"aria-valuenow": Math.round((0,
|
|
1060
|
+
"aria-valuenow": Math.round((0, import_paint_editor9.hueToWheel)(hsv.h, wheel)),
|
|
1017
1061
|
tabIndex: 0,
|
|
1018
1062
|
className: "absolute inset-0 cursor-crosshair",
|
|
1019
1063
|
onPointerDown: (e) => {
|
|
1020
1064
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1021
|
-
controller.setColor((0,
|
|
1065
|
+
controller.setColor((0, import_paint_editor9.wheelPick)(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
1022
1066
|
},
|
|
1023
|
-
children: /* @__PURE__ */ (0,
|
|
1067
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
1024
1068
|
}
|
|
1025
1069
|
),
|
|
1026
|
-
/* @__PURE__ */ (0,
|
|
1027
|
-
const p = (0,
|
|
1028
|
-
return /* @__PURE__ */ (0,
|
|
1070
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
1071
|
+
const p = (0, import_paint_editor9.wheelPoint)(h.angle, mid);
|
|
1072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.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);
|
|
1029
1073
|
}) }),
|
|
1030
|
-
/* @__PURE__ */ (0,
|
|
1074
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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 } })
|
|
1031
1075
|
] }),
|
|
1032
|
-
/* @__PURE__ */ (0,
|
|
1033
|
-
/* @__PURE__ */ (0,
|
|
1034
|
-
/* @__PURE__ */ (0,
|
|
1035
|
-
/* @__PURE__ */ (0,
|
|
1036
|
-
/* @__PURE__ */ (0,
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" }),
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" }),
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1037
1081
|
"input",
|
|
1038
1082
|
{
|
|
1039
1083
|
"aria-label": "Hex colour",
|
|
@@ -1044,49 +1088,49 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1044
1088
|
color
|
|
1045
1089
|
)
|
|
1046
1090
|
] }),
|
|
1047
|
-
/* @__PURE__ */ (0,
|
|
1048
|
-
/* @__PURE__ */ (0,
|
|
1091
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
1092
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1049
1093
|
"span",
|
|
1050
1094
|
{
|
|
1051
1095
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
1052
1096
|
"aria-label": state.effectPaint ? `Effect paint: ${state.effectPaint.effect}` : state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
|
|
1053
1097
|
"data-testid": "paint-well",
|
|
1054
1098
|
"data-effect-paint": state.effectPaint ? state.effectPaint.effect : void 0,
|
|
1055
|
-
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0,
|
|
1099
|
+
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0, import_paint_editor10.paintSourceCss)(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1056
1100
|
}
|
|
1057
1101
|
),
|
|
1058
|
-
/* @__PURE__ */ (0,
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1059
1103
|
"button",
|
|
1060
1104
|
{
|
|
1061
1105
|
type: "button",
|
|
1062
1106
|
className: chip(state.paint.type === "gradient"),
|
|
1063
1107
|
"aria-pressed": state.paint.type === "gradient",
|
|
1064
1108
|
title: "Paint that changes colour as the stroke goes",
|
|
1065
|
-
onClick: () => attempt(() => state.paint.type === "gradient" ? controller.setColor(color) : controller.setPaint(
|
|
1109
|
+
onClick: () => attempt(() => state.paint.type === "gradient" ? controller.setColor(color) : controller.setPaint(import_paint_editor10.DEFAULT_PAINT_GRADIENT)),
|
|
1066
1110
|
children: "Gradient"
|
|
1067
1111
|
}
|
|
1068
1112
|
)
|
|
1069
1113
|
] }),
|
|
1070
|
-
state.paint.type === "gradient" && /* @__PURE__ */ (0,
|
|
1071
|
-
/* @__PURE__ */ (0,
|
|
1072
|
-
/* @__PURE__ */ (0,
|
|
1073
|
-
/* @__PURE__ */ (0,
|
|
1114
|
+
state.paint.type === "gradient" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
1115
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" })
|
|
1074
1118
|
] }),
|
|
1075
|
-
/* @__PURE__ */ (0,
|
|
1076
|
-
/* @__PURE__ */ (0,
|
|
1077
|
-
/* @__PURE__ */ (0,
|
|
1119
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1120
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" })
|
|
1078
1122
|
] }),
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1080
|
-
/* @__PURE__ */ (0,
|
|
1081
|
-
/* @__PURE__ */ (0,
|
|
1082
|
-
/* @__PURE__ */ (0,
|
|
1123
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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_editor9.HARMONY_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: k, children: k }, k)) }),
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1083
1127
|
] }),
|
|
1084
|
-
/* @__PURE__ */ (0,
|
|
1085
|
-
harmony.map((h, i) => /* @__PURE__ */ (0,
|
|
1086
|
-
/* @__PURE__ */ (0,
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
1129
|
+
harmony.map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime9.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)),
|
|
1130
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1087
1131
|
] }),
|
|
1088
|
-
/* @__PURE__ */ (0,
|
|
1089
|
-
state.swatches.map((s, i) => /* @__PURE__ */ (0,
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
1133
|
+
state.swatches.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1090
1134
|
"button",
|
|
1091
1135
|
{
|
|
1092
1136
|
type: "button",
|
|
@@ -1095,7 +1139,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1095
1139
|
"aria-label": s.name ?? (s.paint ? "Gradient" : s.color),
|
|
1096
1140
|
title: `${s.name ?? (s.paint ? "Gradient" : s.color)} (right-click to remove)`,
|
|
1097
1141
|
className: "h-5 w-5 rounded ring-1 ring-slate-700",
|
|
1098
|
-
style: { background: s.paint ? (0,
|
|
1142
|
+
style: { background: s.paint ? (0, import_paint_editor10.paintSourceCss)(s.paint, { paint: color, secondary: state.secondaryColor }) : s.color },
|
|
1099
1143
|
onClick: () => attempt(() => s.paint ? controller.setPaint(s.paint) : controller.setColor(s.color)),
|
|
1100
1144
|
onContextMenu: (e) => {
|
|
1101
1145
|
e.preventDefault();
|
|
@@ -1104,15 +1148,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1104
1148
|
},
|
|
1105
1149
|
i
|
|
1106
1150
|
)),
|
|
1107
|
-
/* @__PURE__ */ (0,
|
|
1151
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1108
1152
|
] }),
|
|
1109
|
-
mixingPad && /* @__PURE__ */ (0,
|
|
1110
|
-
/* @__PURE__ */ (0,
|
|
1111
|
-
/* @__PURE__ */ (0,
|
|
1112
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0,
|
|
1113
|
-
/* @__PURE__ */ (0,
|
|
1153
|
+
mixingPad && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1156
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1114
1158
|
] }),
|
|
1115
|
-
/* @__PURE__ */ (0,
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1116
1160
|
"div",
|
|
1117
1161
|
{
|
|
1118
1162
|
role: "application",
|
|
@@ -1121,7 +1165,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1121
1165
|
onPointerDown: (e) => {
|
|
1122
1166
|
const p = padPoint(e);
|
|
1123
1167
|
if (padTool === "pick") {
|
|
1124
|
-
attempt(() => controller.mixingPadPick(p.x, p.y, { setColor: true, radius: (0,
|
|
1168
|
+
attempt(() => controller.mixingPadPick(p.x, p.y, { setColor: true, radius: (0, import_paint_editor9.padSampleRadius)(sample) }));
|
|
1125
1169
|
return;
|
|
1126
1170
|
}
|
|
1127
1171
|
padPoints.current = [p];
|
|
@@ -1133,20 +1177,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1133
1177
|
padPoints.current = null;
|
|
1134
1178
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1135
1179
|
},
|
|
1136
|
-
children: /* @__PURE__ */ (0,
|
|
1180
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${import_paint_editor9.MIXING_PAD_WIDTH} / ${import_paint_editor9.MIXING_PAD_HEIGHT}` } })
|
|
1137
1181
|
}
|
|
1138
1182
|
),
|
|
1139
|
-
/* @__PURE__ */ (0,
|
|
1140
|
-
/* @__PURE__ */ (0,
|
|
1141
|
-
/* @__PURE__ */ (0,
|
|
1183
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
1184
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-slate-400", children: "Sample" }),
|
|
1185
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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_editor9.PAD_SAMPLE_SIZES.map((n) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1142
1186
|
] }) }),
|
|
1143
|
-
/* @__PURE__ */ (0,
|
|
1144
|
-
/* @__PURE__ */ (0,
|
|
1145
|
-
/* @__PURE__ */ (0,
|
|
1146
|
-
/* @__PURE__ */ (0,
|
|
1147
|
-
/* @__PURE__ */ (0,
|
|
1148
|
-
/* @__PURE__ */ (0,
|
|
1149
|
-
/* @__PURE__ */ (0,
|
|
1187
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1188
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1189
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" }),
|
|
1190
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-slate-500", children: ":" }),
|
|
1191
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" }),
|
|
1192
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1193
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1150
1194
|
"button",
|
|
1151
1195
|
{
|
|
1152
1196
|
type: "button",
|
|
@@ -1165,25 +1209,25 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1165
1209
|
}
|
|
1166
1210
|
)
|
|
1167
1211
|
] }),
|
|
1168
|
-
/* @__PURE__ */ (0,
|
|
1169
|
-
/* @__PURE__ */ (0,
|
|
1170
|
-
/* @__PURE__ */ (0,
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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" }),
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1171
1215
|
] }),
|
|
1172
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0,
|
|
1173
|
-
/* @__PURE__ */ (0,
|
|
1174
|
-
/* @__PURE__ */ (0,
|
|
1216
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { className: "flex items-center gap-1", children: [
|
|
1217
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1175
1219
|
] }, p.id)) })
|
|
1176
1220
|
] }),
|
|
1177
|
-
/* @__PURE__ */ (0,
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ErrorLine, { error })
|
|
1178
1222
|
] });
|
|
1179
1223
|
};
|
|
1180
1224
|
|
|
1181
1225
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1182
|
-
var
|
|
1183
|
-
var
|
|
1226
|
+
var import_react12 = require("react");
|
|
1227
|
+
var import_paint_editor11 = require("@pixerate/editor/paint-editor");
|
|
1184
1228
|
|
|
1185
1229
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
1186
|
-
var
|
|
1230
|
+
var import_react11 = require("react");
|
|
1187
1231
|
var import_raster = require("@pixerate/editor/raster");
|
|
1188
1232
|
|
|
1189
1233
|
// src/image-editor/styles.ts
|
|
@@ -1192,17 +1236,17 @@ var imageSelectClass = "rounded border border-input bg-background px-1.5 py-1 te
|
|
|
1192
1236
|
var imageColorInputClass = "h-6 w-8 rounded border border-border bg-transparent";
|
|
1193
1237
|
|
|
1194
1238
|
// src/image-editor/controls/controls.tsx
|
|
1195
|
-
var
|
|
1196
|
-
var
|
|
1197
|
-
var ControlsContext = (0,
|
|
1239
|
+
var import_react10 = require("react");
|
|
1240
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1241
|
+
var ControlsContext = (0, import_react10.createContext)({});
|
|
1198
1242
|
function useImageEditorControls() {
|
|
1199
|
-
return (0,
|
|
1243
|
+
return (0, import_react10.useContext)(ControlsContext);
|
|
1200
1244
|
}
|
|
1201
1245
|
function ImageCheckbox(props) {
|
|
1202
1246
|
const Host = useImageEditorControls().Checkbox;
|
|
1203
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1247
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1204
1248
|
const { checked, label, disabled, onChange, className = "" } = props;
|
|
1205
|
-
return /* @__PURE__ */ (0,
|
|
1249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1206
1250
|
"input",
|
|
1207
1251
|
{
|
|
1208
1252
|
type: "checkbox",
|
|
@@ -1216,9 +1260,9 @@ function ImageCheckbox(props) {
|
|
|
1216
1260
|
}
|
|
1217
1261
|
function ImageRange(props) {
|
|
1218
1262
|
const Host = useImageEditorControls().Range;
|
|
1219
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1263
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1220
1264
|
const { value, min, max, step, label, disabled, onChange, onStart, onEnd, className = "" } = props;
|
|
1221
|
-
return /* @__PURE__ */ (0,
|
|
1265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1222
1266
|
"input",
|
|
1223
1267
|
{
|
|
1224
1268
|
type: "range",
|
|
@@ -1239,18 +1283,18 @@ function ImageRange(props) {
|
|
|
1239
1283
|
}
|
|
1240
1284
|
function ImageSelect(props) {
|
|
1241
1285
|
const Host = useImageEditorControls().Select;
|
|
1242
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1286
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1243
1287
|
const { value, options, label, placeholder, disabled, onChange, className = "" } = props;
|
|
1244
|
-
return /* @__PURE__ */ (0,
|
|
1245
|
-
placeholder !== void 0 && /* @__PURE__ */ (0,
|
|
1246
|
-
options.map((o) => /* @__PURE__ */ (0,
|
|
1288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("select", { "aria-label": label, value, disabled, onChange: (e) => onChange(e.target.value), className: `${imageSelectClass} ${className}`, children: [
|
|
1289
|
+
placeholder !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", children: placeholder }),
|
|
1290
|
+
options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: o.value, children: o.label }, o.value))
|
|
1247
1291
|
] });
|
|
1248
1292
|
}
|
|
1249
1293
|
function ImageColor(props) {
|
|
1250
1294
|
const Host = useImageEditorControls().Color;
|
|
1251
|
-
if (Host) return /* @__PURE__ */ (0,
|
|
1295
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1252
1296
|
const { value, label, alpha, disabled, onChange, className = "" } = props;
|
|
1253
|
-
return /* @__PURE__ */ (0,
|
|
1297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1254
1298
|
"input",
|
|
1255
1299
|
{
|
|
1256
1300
|
type: "color",
|
|
@@ -1264,13 +1308,13 @@ function ImageColor(props) {
|
|
|
1264
1308
|
}
|
|
1265
1309
|
|
|
1266
1310
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
1267
|
-
var
|
|
1311
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1268
1312
|
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
1269
|
-
const [, setTick] = (0,
|
|
1270
|
-
(0,
|
|
1271
|
-
const [open, setOpen] = (0,
|
|
1272
|
-
const [error, setError] = (0,
|
|
1273
|
-
const commitNext = (0,
|
|
1313
|
+
const [, setTick] = (0, import_react11.useState)(0);
|
|
1314
|
+
(0, import_react11.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
1315
|
+
const [open, setOpen] = (0, import_react11.useState)(null);
|
|
1316
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
1317
|
+
const commitNext = (0, import_react11.useRef)(true);
|
|
1274
1318
|
const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
|
|
1275
1319
|
const model = (0, import_raster.layerEffectsPanel)(layer);
|
|
1276
1320
|
const id = layer?.id;
|
|
@@ -1283,7 +1327,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1283
1327
|
}
|
|
1284
1328
|
};
|
|
1285
1329
|
if (!model.available || !id) {
|
|
1286
|
-
return /* @__PURE__ */ (0,
|
|
1330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `text-xs text-muted-foreground ${className ?? ""}`, "data-testid": "layer-effects", children: model.reason });
|
|
1287
1331
|
}
|
|
1288
1332
|
const effects = controller.getLayerEffects(id);
|
|
1289
1333
|
const patterns = controller.getDocumentPatterns();
|
|
@@ -1298,14 +1342,14 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1298
1342
|
case "range": {
|
|
1299
1343
|
const k = c.percent ? 100 : 1;
|
|
1300
1344
|
const shown = Math.round(c.value * k * 100) / 100;
|
|
1301
|
-
return /* @__PURE__ */ (0,
|
|
1302
|
-
/* @__PURE__ */ (0,
|
|
1345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
|
|
1346
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
1303
1347
|
label,
|
|
1304
1348
|
" ",
|
|
1305
1349
|
shown,
|
|
1306
1350
|
c.unit
|
|
1307
1351
|
] }),
|
|
1308
|
-
/* @__PURE__ */ (0,
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1309
1353
|
ImageRange,
|
|
1310
1354
|
{
|
|
1311
1355
|
label,
|
|
@@ -1322,19 +1366,19 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1322
1366
|
] }, c.key);
|
|
1323
1367
|
}
|
|
1324
1368
|
case "color":
|
|
1325
|
-
return /* @__PURE__ */ (0,
|
|
1326
|
-
/* @__PURE__ */ (0,
|
|
1369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
|
|
1370
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ImageColor, { label, value: c.value, disabled: model.readOnly, onChange: (v) => change(effectId, c, v) }),
|
|
1327
1371
|
label
|
|
1328
1372
|
] }, c.key);
|
|
1329
1373
|
case "checkbox":
|
|
1330
|
-
return /* @__PURE__ */ (0,
|
|
1331
|
-
/* @__PURE__ */ (0,
|
|
1374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ImageCheckbox, { label, checked: c.value, disabled: model.readOnly, onChange: (on) => change(effectId, c, on) }),
|
|
1332
1376
|
label
|
|
1333
1377
|
] }, c.key);
|
|
1334
1378
|
case "select":
|
|
1335
|
-
return /* @__PURE__ */ (0,
|
|
1336
|
-
/* @__PURE__ */ (0,
|
|
1337
|
-
/* @__PURE__ */ (0,
|
|
1379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
|
|
1380
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-muted-foreground", children: label }),
|
|
1381
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1338
1382
|
ImageSelect,
|
|
1339
1383
|
{
|
|
1340
1384
|
label,
|
|
@@ -1347,16 +1391,16 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1347
1391
|
] }, c.key);
|
|
1348
1392
|
}
|
|
1349
1393
|
};
|
|
1350
|
-
return /* @__PURE__ */ (0,
|
|
1351
|
-
/* @__PURE__ */ (0,
|
|
1352
|
-
/* @__PURE__ */ (0,
|
|
1353
|
-
/* @__PURE__ */ (0,
|
|
1354
|
-
/* @__PURE__ */ (0,
|
|
1394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.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: [
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1396
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-semibold text-foreground", children: heading ? "Layer Style" : "Styles" }),
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1 text-foreground", children: [
|
|
1398
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ImageCheckbox, { label: "Effects on", checked: model.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.setLayerEffectsEnabled(id, on)) }),
|
|
1355
1399
|
"On"
|
|
1356
1400
|
] }),
|
|
1357
|
-
/* @__PURE__ */ (0,
|
|
1401
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
1358
1402
|
"Scale",
|
|
1359
|
-
/* @__PURE__ */ (0,
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1360
1404
|
"input",
|
|
1361
1405
|
{
|
|
1362
1406
|
type: "number",
|
|
@@ -1375,7 +1419,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1375
1419
|
),
|
|
1376
1420
|
"%"
|
|
1377
1421
|
] }),
|
|
1378
|
-
heading && /* @__PURE__ */ (0,
|
|
1422
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1379
1423
|
ImageSelect,
|
|
1380
1424
|
{
|
|
1381
1425
|
label: "Add style",
|
|
@@ -1391,14 +1435,14 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1391
1435
|
}
|
|
1392
1436
|
)
|
|
1393
1437
|
] }),
|
|
1394
|
-
model.readOnly && model.reason && /* @__PURE__ */ (0,
|
|
1395
|
-
/* @__PURE__ */ (0,
|
|
1438
|
+
model.readOnly && model.reason && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-muted-foreground", children: model.reason }),
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { className: "flex flex-col gap-1", "aria-label": "Effects", children: model.rows.map((row) => {
|
|
1396
1440
|
const effect = effects.items.find((e) => e.id === row.id);
|
|
1397
1441
|
const expanded = open === row.id;
|
|
1398
|
-
return /* @__PURE__ */ (0,
|
|
1399
|
-
/* @__PURE__ */ (0,
|
|
1400
|
-
/* @__PURE__ */ (0,
|
|
1401
|
-
/* @__PURE__ */ (0,
|
|
1442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { "data-effect-id": row.id, className: "rounded bg-background/60 ring-1 ring-border", children: [
|
|
1443
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1.5 px-1.5 py-1", children: [
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ImageCheckbox, { label: `${row.label} on`, checked: row.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.updateLayerEffect(id, row.id, { enabled: on })) }),
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1402
1446
|
"button",
|
|
1403
1447
|
{
|
|
1404
1448
|
type: "button",
|
|
@@ -1408,17 +1452,17 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
|
|
|
1408
1452
|
children: row.label
|
|
1409
1453
|
}
|
|
1410
1454
|
),
|
|
1411
|
-
/* @__PURE__ */ (0,
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: imageIconButtonClass, "aria-label": `Remove ${row.label}`, disabled: model.readOnly, onClick: () => attempt(() => controller.removeLayerEffect(id, row.id)), children: "\u2715" })
|
|
1412
1456
|
] }),
|
|
1413
|
-
expanded && /* @__PURE__ */ (0,
|
|
1457
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime11.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)) })
|
|
1414
1458
|
] }, row.id);
|
|
1415
1459
|
}) }),
|
|
1416
|
-
error && /* @__PURE__ */ (0,
|
|
1460
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
1417
1461
|
] });
|
|
1418
1462
|
};
|
|
1419
1463
|
|
|
1420
1464
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1421
|
-
var
|
|
1465
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1422
1466
|
function siblingIndex(layers, l) {
|
|
1423
1467
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1424
1468
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1426,7 +1470,7 @@ function siblingIndex(layers, l) {
|
|
|
1426
1470
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1427
1471
|
usePaintEditorState(controller);
|
|
1428
1472
|
const [error, attempt] = useAttempt();
|
|
1429
|
-
const [renaming, setRenaming] = (0,
|
|
1473
|
+
const [renaming, setRenaming] = (0, import_react12.useState)(null);
|
|
1430
1474
|
const layers = controller.listLayers();
|
|
1431
1475
|
const active = layers.find((l) => l.active) ?? null;
|
|
1432
1476
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1436,18 +1480,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1436
1480
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1437
1481
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1438
1482
|
};
|
|
1439
|
-
return /* @__PURE__ */ (0,
|
|
1440
|
-
/* @__PURE__ */ (0,
|
|
1441
|
-
/* @__PURE__ */ (0,
|
|
1442
|
-
/* @__PURE__ */ (0,
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1444
|
-
/* @__PURE__ */ (0,
|
|
1445
|
-
/* @__PURE__ */ (0,
|
|
1446
|
-
/* @__PURE__ */ (0,
|
|
1447
|
-
/* @__PURE__ */ (0,
|
|
1448
|
-
/* @__PURE__ */ (0,
|
|
1483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1485
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1487
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1489
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1490
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1491
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1492
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1449
1493
|
] }),
|
|
1450
|
-
/* @__PURE__ */ (0,
|
|
1494
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1451
1495
|
"li",
|
|
1452
1496
|
{
|
|
1453
1497
|
role: "treeitem",
|
|
@@ -1456,7 +1500,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1456
1500
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1457
1501
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1458
1502
|
children: [
|
|
1459
|
-
/* @__PURE__ */ (0,
|
|
1503
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1460
1504
|
"button",
|
|
1461
1505
|
{
|
|
1462
1506
|
type: "button",
|
|
@@ -1469,7 +1513,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1469
1513
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1470
1514
|
}
|
|
1471
1515
|
),
|
|
1472
|
-
renaming === l.id ? /* @__PURE__ */ (0,
|
|
1516
|
+
renaming === l.id ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1473
1517
|
"input",
|
|
1474
1518
|
{
|
|
1475
1519
|
autoFocus: true,
|
|
@@ -1486,23 +1530,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1486
1530
|
if (e.key === "Escape") setRenaming(null);
|
|
1487
1531
|
}
|
|
1488
1532
|
}
|
|
1489
|
-
) : /* @__PURE__ */ (0,
|
|
1533
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1490
1534
|
l.type === "group" ? "\u25B8 " : "",
|
|
1491
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */ (0,
|
|
1535
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1492
1536
|
"\u270E",
|
|
1493
1537
|
" "
|
|
1494
1538
|
] }),
|
|
1495
1539
|
l.name
|
|
1496
1540
|
] }),
|
|
1497
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0,
|
|
1541
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1498
1542
|
]
|
|
1499
1543
|
},
|
|
1500
1544
|
l.id
|
|
1501
1545
|
)) }),
|
|
1502
|
-
active && /* @__PURE__ */ (0,
|
|
1503
|
-
/* @__PURE__ */ (0,
|
|
1504
|
-
/* @__PURE__ */ (0,
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1546
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
1547
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1548
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1549
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1506
1550
|
"input",
|
|
1507
1551
|
{
|
|
1508
1552
|
type: "range",
|
|
@@ -1516,40 +1560,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1516
1560
|
}
|
|
1517
1561
|
)
|
|
1518
1562
|
] }),
|
|
1519
|
-
/* @__PURE__ */ (0,
|
|
1520
|
-
/* @__PURE__ */ (0,
|
|
1521
|
-
/* @__PURE__ */ (0,
|
|
1522
|
-
active.type === "group" && /* @__PURE__ */ (0,
|
|
1523
|
-
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1565
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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: [
|
|
1566
|
+
active.type === "group" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "pass-through", children: "Pass through" }),
|
|
1567
|
+
import_paint_editor11.BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1524
1568
|
] })
|
|
1525
1569
|
] }),
|
|
1526
|
-
/* @__PURE__ */ (0,
|
|
1527
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0,
|
|
1528
|
-
/* @__PURE__ */ (0,
|
|
1570
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex gap-1", children: [
|
|
1571
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime12.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)),
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1529
1573
|
] }),
|
|
1530
|
-
light?.hasLight && /* @__PURE__ */ (0,
|
|
1531
|
-
/* @__PURE__ */ (0,
|
|
1532
|
-
/* @__PURE__ */ (0,
|
|
1533
|
-
/* @__PURE__ */ (0,
|
|
1574
|
+
light?.hasLight && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
1575
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1576
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1577
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1534
1578
|
] }),
|
|
1535
|
-
/* @__PURE__ */ (0,
|
|
1536
|
-
/* @__PURE__ */ (0,
|
|
1537
|
-
/* @__PURE__ */ (0,
|
|
1579
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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: [
|
|
1580
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1581
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" })
|
|
1538
1582
|
] }),
|
|
1539
|
-
/* @__PURE__ */ (0,
|
|
1540
|
-
/* @__PURE__ */ (0,
|
|
1541
|
-
/* @__PURE__ */ (0,
|
|
1583
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1584
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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" })
|
|
1542
1586
|
] })
|
|
1543
1587
|
] }),
|
|
1544
|
-
/* @__PURE__ */ (0,
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsx)(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1545
1589
|
] }),
|
|
1546
|
-
/* @__PURE__ */ (0,
|
|
1590
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorLine, { error })
|
|
1547
1591
|
] });
|
|
1548
1592
|
};
|
|
1549
1593
|
|
|
1550
1594
|
// src/paint-editor/WetPanel.tsx
|
|
1551
|
-
var
|
|
1552
|
-
var
|
|
1595
|
+
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
1596
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1553
1597
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1554
1598
|
var WetPanel = ({ controller, className }) => {
|
|
1555
1599
|
const state = usePaintEditorState(controller);
|
|
@@ -1558,31 +1602,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1558
1602
|
const layerId = state.document.activeLayerId;
|
|
1559
1603
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1560
1604
|
const backend = controller.wetState();
|
|
1561
|
-
return /* @__PURE__ */ (0,
|
|
1562
|
-
/* @__PURE__ */ (0,
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1564
|
-
/* @__PURE__ */ (0,
|
|
1605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1606
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1607
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
1608
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "text-[10px] text-slate-500", children: [
|
|
1565
1609
|
"step ",
|
|
1566
1610
|
wet.clock
|
|
1567
1611
|
] })
|
|
1568
1612
|
] }),
|
|
1569
|
-
/* @__PURE__ */ (0,
|
|
1570
|
-
/* @__PURE__ */ (0,
|
|
1571
|
-
/* @__PURE__ */ (0,
|
|
1572
|
-
/* @__PURE__ */ (0,
|
|
1573
|
-
/* @__PURE__ */ (0,
|
|
1574
|
-
/* @__PURE__ */ (0,
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1617
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.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" }),
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1575
1619
|
] }),
|
|
1576
|
-
/* @__PURE__ */ (0,
|
|
1577
|
-
|
|
1578
|
-
info && /* @__PURE__ */ (0,
|
|
1579
|
-
/* @__PURE__ */ (0,
|
|
1580
|
-
|
|
1581
|
-
/* @__PURE__ */ (0,
|
|
1582
|
-
/* @__PURE__ */ (0,
|
|
1583
|
-
/* @__PURE__ */ (0,
|
|
1620
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaintSlider, { control: import_paint_editor12.WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1621
|
+
import_paint_editor12.WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor12.readPath)(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
1622
|
+
info && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1624
|
+
import_paint_editor12.WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor12.readPath)(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
1625
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1627
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.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_editor12.WET_FLOW_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1584
1628
|
] }),
|
|
1585
|
-
info.flow.kind !== "none" && /* @__PURE__ */ (0,
|
|
1629
|
+
info.flow.kind !== "none" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1586
1630
|
PaintSlider,
|
|
1587
1631
|
{
|
|
1588
1632
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1591,20 +1635,20 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1591
1635
|
}
|
|
1592
1636
|
)
|
|
1593
1637
|
] }),
|
|
1594
|
-
backend.message && /* @__PURE__ */ (0,
|
|
1595
|
-
backend.backend && /* @__PURE__ */ (0,
|
|
1596
|
-
/* @__PURE__ */ (0,
|
|
1597
|
-
/* @__PURE__ */ (0,
|
|
1598
|
-
/* @__PURE__ */ (0,
|
|
1638
|
+
backend.message && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1639
|
+
backend.backend && /* @__PURE__ */ (0, import_jsx_runtime13.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" }),
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-slate-400", children: "Engine" }),
|
|
1642
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.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_editor12.WET_GPU_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: o.value, children: o.label }, o.value)) })
|
|
1599
1643
|
] }),
|
|
1600
|
-
/* @__PURE__ */ (0,
|
|
1601
|
-
/* @__PURE__ */ (0,
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: (0, import_paint_editor12.wetEngineSummary)(backend.engine) }),
|
|
1645
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ErrorLine, { error })
|
|
1602
1646
|
] });
|
|
1603
1647
|
};
|
|
1604
1648
|
|
|
1605
1649
|
// src/paint-editor/StickerPanel.tsx
|
|
1606
|
-
var
|
|
1607
|
-
var
|
|
1650
|
+
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
1651
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1608
1652
|
var StickerPanel = ({ controller, className }) => {
|
|
1609
1653
|
const state = usePaintEditorState(controller);
|
|
1610
1654
|
const [error, attempt] = useAttempt();
|
|
@@ -1614,21 +1658,32 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1614
1658
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1615
1659
|
if (!stickers.length) return null;
|
|
1616
1660
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1617
|
-
return /* @__PURE__ */ (0,
|
|
1618
|
-
/* @__PURE__ */ (0,
|
|
1661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
1619
1663
|
"Stickers (",
|
|
1620
1664
|
stickers.length,
|
|
1621
1665
|
")"
|
|
1622
1666
|
] }),
|
|
1623
|
-
/* @__PURE__ */ (0,
|
|
1624
|
-
sel && /* @__PURE__ */ (0,
|
|
1625
|
-
/* @__PURE__ */ (0,
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1667
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.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_runtime14.jsx)("button", { type: "button", role: "option", "aria-selected": s.id === picked, title: `${(0, import_paint_editor13.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)) }),
|
|
1668
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1671
|
+
StickerPicker,
|
|
1672
|
+
{
|
|
1673
|
+
controller,
|
|
1674
|
+
label: "Sticker art",
|
|
1675
|
+
selected: [sel.ref],
|
|
1676
|
+
onPick: (ref) => (
|
|
1677
|
+
// The layer is redrawn, so the new sticker's art (and every other's) loads first.
|
|
1678
|
+
void controller.prepareStickers([ref, ...stickers.map((x) => x.ref)]).then(() => attempt(() => controller.updateSticker(layerId, sel.id, { ref }))).catch((e) => attempt(() => {
|
|
1679
|
+
throw e;
|
|
1680
|
+
}))
|
|
1681
|
+
)
|
|
1682
|
+
}
|
|
1683
|
+
),
|
|
1684
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-slate-400", children: "Position" }),
|
|
1686
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1632
1687
|
"input",
|
|
1633
1688
|
{
|
|
1634
1689
|
type: "number",
|
|
@@ -1642,24 +1697,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1642
1697
|
`${sel.id}-${k}-${sel[k]}`
|
|
1643
1698
|
)) })
|
|
1644
1699
|
] }),
|
|
1645
|
-
|
|
1646
|
-
/* @__PURE__ */ (0,
|
|
1647
|
-
/* @__PURE__ */ (0,
|
|
1648
|
-
/* @__PURE__ */ (0,
|
|
1700
|
+
import_paint_editor13.STICKER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor13.readPath)(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1702
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.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" })
|
|
1649
1704
|
] }),
|
|
1650
|
-
/* @__PURE__ */ (0,
|
|
1651
|
-
/* @__PURE__ */ (0,
|
|
1652
|
-
/* @__PURE__ */ (0,
|
|
1653
|
-
/* @__PURE__ */ (0,
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1707
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1708
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1654
1709
|
] })
|
|
1655
1710
|
] }),
|
|
1656
|
-
/* @__PURE__ */ (0,
|
|
1711
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ErrorLine, { error })
|
|
1657
1712
|
] });
|
|
1658
1713
|
};
|
|
1659
1714
|
|
|
1660
1715
|
// src/paint-editor/StrokePanel.tsx
|
|
1661
|
-
var
|
|
1662
|
-
var
|
|
1716
|
+
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
1717
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1663
1718
|
var StrokePanel = ({ controller, className }) => {
|
|
1664
1719
|
const state = usePaintEditorState(controller);
|
|
1665
1720
|
const [error, attempt] = useAttempt();
|
|
@@ -1668,17 +1723,17 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1668
1723
|
if (!layerId || !strokes) return null;
|
|
1669
1724
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1670
1725
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1671
|
-
const brushes = state.brushes.filter((b) => !(0,
|
|
1672
|
-
return /* @__PURE__ */ (0,
|
|
1673
|
-
/* @__PURE__ */ (0,
|
|
1674
|
-
/* @__PURE__ */ (0,
|
|
1726
|
+
const brushes = state.brushes.filter((b) => !(0, import_paint_editor14.liveStrokeRefusal)(b));
|
|
1727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1729
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "font-medium text-slate-300", children: [
|
|
1675
1730
|
"Strokes (",
|
|
1676
1731
|
strokes.length,
|
|
1677
1732
|
")"
|
|
1678
1733
|
] }),
|
|
1679
|
-
/* @__PURE__ */ (0,
|
|
1734
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1680
1735
|
] }),
|
|
1681
|
-
/* @__PURE__ */ (0,
|
|
1736
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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_runtime15.jsx)(
|
|
1682
1737
|
"button",
|
|
1683
1738
|
{
|
|
1684
1739
|
type: "button",
|
|
@@ -1691,10 +1746,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1691
1746
|
},
|
|
1692
1747
|
s.id
|
|
1693
1748
|
)) }),
|
|
1694
|
-
sel && /* @__PURE__ */ (0,
|
|
1695
|
-
/* @__PURE__ */ (0,
|
|
1696
|
-
/* @__PURE__ */ (0,
|
|
1697
|
-
/* @__PURE__ */ (0,
|
|
1749
|
+
sel && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1750
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1751
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-slate-400", children: "Brush" }),
|
|
1752
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1698
1753
|
"select",
|
|
1699
1754
|
{
|
|
1700
1755
|
"aria-label": "Stroke brush",
|
|
@@ -1702,51 +1757,51 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1702
1757
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1703
1758
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1704
1759
|
children: [
|
|
1705
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0,
|
|
1706
|
-
brushes.map((b) => /* @__PURE__ */ (0,
|
|
1760
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: sel.brush.name }),
|
|
1761
|
+
brushes.map((b) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: b.id, children: b.name }, b.id))
|
|
1707
1762
|
]
|
|
1708
1763
|
}
|
|
1709
1764
|
)
|
|
1710
1765
|
] }),
|
|
1711
|
-
|
|
1712
|
-
/* @__PURE__ */ (0,
|
|
1713
|
-
/* @__PURE__ */ (0,
|
|
1714
|
-
/* @__PURE__ */ (0,
|
|
1766
|
+
import_paint_editor14.STROKE_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor14.readPath)(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1768
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
1769
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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" })
|
|
1715
1770
|
] }),
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
1717
|
-
/* @__PURE__ */ (0,
|
|
1718
|
-
/* @__PURE__ */ (0,
|
|
1719
|
-
/* @__PURE__ */ (0,
|
|
1720
|
-
/* @__PURE__ */ (0,
|
|
1771
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1772
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1773
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.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" }),
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1721
1776
|
] })
|
|
1722
1777
|
] }),
|
|
1723
|
-
/* @__PURE__ */ (0,
|
|
1778
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ErrorLine, { error })
|
|
1724
1779
|
] });
|
|
1725
1780
|
};
|
|
1726
1781
|
|
|
1727
1782
|
// src/paint-editor/PaintEditor.tsx
|
|
1728
|
-
var
|
|
1729
|
-
var
|
|
1783
|
+
var import_react26 = require("react");
|
|
1784
|
+
var import_paint_editor16 = require("@pixerate/editor/paint-editor");
|
|
1730
1785
|
|
|
1731
1786
|
// src/playback/AgentPlaybackContext.tsx
|
|
1732
|
-
var
|
|
1733
|
-
var
|
|
1734
|
-
var AgentPlaybackContext = (0,
|
|
1787
|
+
var import_react13 = require("react");
|
|
1788
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1789
|
+
var AgentPlaybackContext = (0, import_react13.createContext)(null);
|
|
1735
1790
|
function useAgentPlayback() {
|
|
1736
|
-
return (0,
|
|
1791
|
+
return (0, import_react13.useContext)(AgentPlaybackContext);
|
|
1737
1792
|
}
|
|
1738
1793
|
|
|
1739
1794
|
// src/playback/usePlaybackSurface.ts
|
|
1740
|
-
var
|
|
1795
|
+
var import_react14 = require("react");
|
|
1741
1796
|
var import_tools = require("@pixerate/editor/tools");
|
|
1742
1797
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
1743
1798
|
const ambient = useAgentPlayback();
|
|
1744
1799
|
const target = playback === void 0 ? ambient : playback;
|
|
1745
|
-
const [ownPresence] = (0,
|
|
1800
|
+
const [ownPresence] = (0, import_react14.useState)(() => new import_tools.PresenceStore());
|
|
1746
1801
|
const presence = sharedPresence ?? ownPresence;
|
|
1747
|
-
const latest = (0,
|
|
1802
|
+
const latest = (0, import_react14.useRef)(options);
|
|
1748
1803
|
latest.current = options;
|
|
1749
|
-
(0,
|
|
1804
|
+
(0, import_react14.useEffect)(() => {
|
|
1750
1805
|
if (!target || !id) return;
|
|
1751
1806
|
const o = () => latest.current;
|
|
1752
1807
|
const surface = {
|
|
@@ -1778,13 +1833,13 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
1778
1833
|
}
|
|
1779
1834
|
|
|
1780
1835
|
// src/playback/PresenceLayer.tsx
|
|
1781
|
-
var
|
|
1782
|
-
var
|
|
1836
|
+
var import_react15 = __toESM(require("react"), 1);
|
|
1837
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1783
1838
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
1784
|
-
const { actors } = (0,
|
|
1839
|
+
const { actors } = (0, import_react15.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
1785
1840
|
if (!actors.length) return null;
|
|
1786
1841
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
1787
|
-
return /* @__PURE__ */ (0,
|
|
1842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1788
1843
|
"div",
|
|
1789
1844
|
{
|
|
1790
1845
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -1798,19 +1853,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1798
1853
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
1799
1854
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
1800
1855
|
})();
|
|
1801
|
-
return /* @__PURE__ */ (0,
|
|
1802
|
-
ring && /* @__PURE__ */ (0,
|
|
1856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react15.default.Fragment, { children: [
|
|
1857
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1803
1858
|
"div",
|
|
1804
1859
|
{
|
|
1805
1860
|
"data-actor-focus": a.id,
|
|
1806
1861
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
1807
1862
|
}
|
|
1808
1863
|
),
|
|
1809
|
-
/* @__PURE__ */ (0,
|
|
1810
|
-
/* @__PURE__ */ (0,
|
|
1811
|
-
/* @__PURE__ */ (0,
|
|
1812
|
-
/* @__PURE__ */ (0,
|
|
1813
|
-
a.message && /* @__PURE__ */ (0,
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.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_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.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_runtime17.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 } }) }),
|
|
1866
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
1867
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
1868
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime17.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 })
|
|
1814
1869
|
] })
|
|
1815
1870
|
] }) })
|
|
1816
1871
|
] }, a.id);
|
|
@@ -1820,15 +1875,15 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1820
1875
|
}
|
|
1821
1876
|
|
|
1822
1877
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1823
|
-
var
|
|
1824
|
-
var
|
|
1878
|
+
var import_react25 = require("react");
|
|
1879
|
+
var import_paint_editor15 = require("@pixerate/editor/paint-editor");
|
|
1825
1880
|
|
|
1826
1881
|
// src/effects/useEffects.ts
|
|
1827
|
-
var
|
|
1882
|
+
var import_react16 = require("react");
|
|
1828
1883
|
function useEffectDescription(provider, effect) {
|
|
1829
|
-
const [state, setState] = (0,
|
|
1884
|
+
const [state, setState] = (0, import_react16.useState)({ key: "", description: null, error: null });
|
|
1830
1885
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1831
|
-
(0,
|
|
1886
|
+
(0, import_react16.useEffect)(() => {
|
|
1832
1887
|
if (!provider || !effect) return;
|
|
1833
1888
|
let live = true;
|
|
1834
1889
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1843,14 +1898,14 @@ function useEffectDescription(provider, effect) {
|
|
|
1843
1898
|
}
|
|
1844
1899
|
|
|
1845
1900
|
// src/effects/EffectThumbnail.tsx
|
|
1846
|
-
var
|
|
1901
|
+
var import_react17 = require("react");
|
|
1847
1902
|
var import_effects = require("@pixerate/editor/effects");
|
|
1848
|
-
var
|
|
1903
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1849
1904
|
var LABELS = { motion: "Motion", camera: "Camera" };
|
|
1850
1905
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1851
|
-
const ref = (0,
|
|
1852
|
-
const [failed, setFailed] = (0,
|
|
1853
|
-
(0,
|
|
1906
|
+
const ref = (0, import_react17.useRef)(null);
|
|
1907
|
+
const [failed, setFailed] = (0, import_react17.useState)(effect.kind in LABELS);
|
|
1908
|
+
(0, import_react17.useEffect)(() => {
|
|
1854
1909
|
if (effect.kind in LABELS) return;
|
|
1855
1910
|
let live = true;
|
|
1856
1911
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1865,28 +1920,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1865
1920
|
live = false;
|
|
1866
1921
|
};
|
|
1867
1922
|
}, [provider, effect, width, height]);
|
|
1868
|
-
return /* @__PURE__ */ (0,
|
|
1923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1869
1924
|
"div",
|
|
1870
1925
|
{
|
|
1871
1926
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1872
1927
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1873
1928
|
"data-effect-thumbnail": effect.id,
|
|
1874
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1929
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime18.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_runtime18.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
1875
1930
|
}
|
|
1876
1931
|
);
|
|
1877
1932
|
}
|
|
1878
1933
|
|
|
1879
1934
|
// src/effects/EffectsBrowser.tsx
|
|
1880
|
-
var
|
|
1935
|
+
var import_react18 = require("react");
|
|
1881
1936
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1882
|
-
var
|
|
1937
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1883
1938
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1884
|
-
const [all, setAll] = (0,
|
|
1885
|
-
const [query, setQuery] = (0,
|
|
1886
|
-
const [category, setCategory] = (0,
|
|
1887
|
-
const [use, setUse] = (0,
|
|
1888
|
-
const [error, setError] = (0,
|
|
1889
|
-
(0,
|
|
1939
|
+
const [all, setAll] = (0, import_react18.useState)([]);
|
|
1940
|
+
const [query, setQuery] = (0, import_react18.useState)("");
|
|
1941
|
+
const [category, setCategory] = (0, import_react18.useState)("");
|
|
1942
|
+
const [use, setUse] = (0, import_react18.useState)("");
|
|
1943
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
1944
|
+
(0, import_react18.useEffect)(() => {
|
|
1890
1945
|
if (!provider) return setAll([]);
|
|
1891
1946
|
let live = true;
|
|
1892
1947
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1897,8 +1952,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1897
1952
|
live = false;
|
|
1898
1953
|
};
|
|
1899
1954
|
}, [provider]);
|
|
1900
|
-
const [found, setFound] = (0,
|
|
1901
|
-
(0,
|
|
1955
|
+
const [found, setFound] = (0, import_react18.useState)([]);
|
|
1956
|
+
(0, import_react18.useEffect)(() => {
|
|
1902
1957
|
if (!provider) return setFound([]);
|
|
1903
1958
|
let live = true;
|
|
1904
1959
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1907,14 +1962,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1907
1962
|
};
|
|
1908
1963
|
}, [provider, query, category, use]);
|
|
1909
1964
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
1910
|
-
const categories = (0,
|
|
1965
|
+
const categories = (0, import_react18.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1911
1966
|
const shown = found.filter(allowed);
|
|
1912
1967
|
if (!provider)
|
|
1913
|
-
return /* @__PURE__ */ (0,
|
|
1914
|
-
return /* @__PURE__ */ (0,
|
|
1915
|
-
title && /* @__PURE__ */ (0,
|
|
1916
|
-
/* @__PURE__ */ (0,
|
|
1917
|
-
/* @__PURE__ */ (0,
|
|
1968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.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." });
|
|
1969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
1970
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1972
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1918
1973
|
"input",
|
|
1919
1974
|
{
|
|
1920
1975
|
type: "search",
|
|
@@ -1925,17 +1980,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1925
1980
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1926
1981
|
}
|
|
1927
1982
|
),
|
|
1928
|
-
/* @__PURE__ */ (0,
|
|
1929
|
-
/* @__PURE__ */ (0,
|
|
1930
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
1983
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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: [
|
|
1984
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "All categories" }),
|
|
1985
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: c, children: c }, c))
|
|
1931
1986
|
] }),
|
|
1932
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1933
|
-
/* @__PURE__ */ (0,
|
|
1934
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
1987
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime19.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: [
|
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "Any use" }),
|
|
1989
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1935
1990
|
] })
|
|
1936
1991
|
] }),
|
|
1937
|
-
error && /* @__PURE__ */ (0,
|
|
1938
|
-
/* @__PURE__ */ (0,
|
|
1992
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
1993
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1939
1994
|
"button",
|
|
1940
1995
|
{
|
|
1941
1996
|
type: "button",
|
|
@@ -1944,23 +1999,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1944
1999
|
"data-effect-id": e.id,
|
|
1945
2000
|
onClick: () => onPick(e),
|
|
1946
2001
|
children: [
|
|
1947
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
1949
|
-
/* @__PURE__ */ (0,
|
|
2002
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
2003
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
2004
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
1950
2005
|
]
|
|
1951
2006
|
}
|
|
1952
2007
|
) }, e.id)) }),
|
|
1953
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
2008
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
1954
2009
|
] });
|
|
1955
2010
|
}
|
|
1956
2011
|
|
|
1957
2012
|
// src/effects/EffectParameters.tsx
|
|
1958
|
-
var
|
|
2013
|
+
var import_react24 = __toESM(require("react"), 1);
|
|
1959
2014
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1960
2015
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1961
2016
|
|
|
1962
2017
|
// src/parameters/fields.tsx
|
|
1963
|
-
var
|
|
2018
|
+
var import_react23 = require("react");
|
|
1964
2019
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1965
2020
|
|
|
1966
2021
|
// src/color/index.ts
|
|
@@ -1973,9 +2028,9 @@ __export(color_exports, {
|
|
|
1973
2028
|
});
|
|
1974
2029
|
|
|
1975
2030
|
// src/color/ColorPicker.tsx
|
|
1976
|
-
var
|
|
2031
|
+
var import_react19 = require("react");
|
|
1977
2032
|
var import_color = require("@pixerate/editor/color");
|
|
1978
|
-
var
|
|
2033
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1979
2034
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
1980
2035
|
function readLocalRecents() {
|
|
1981
2036
|
try {
|
|
@@ -2013,24 +2068,24 @@ var ColorPicker = ({
|
|
|
2013
2068
|
id,
|
|
2014
2069
|
"aria-label": ariaLabel = "Color picker"
|
|
2015
2070
|
}) => {
|
|
2016
|
-
const generatedId = (0,
|
|
2071
|
+
const generatedId = (0, import_react19.useId)();
|
|
2017
2072
|
const pickerId = id || generatedId;
|
|
2018
|
-
const [pickerState, setPickerState] = (0,
|
|
2073
|
+
const [pickerState, setPickerState] = (0, import_react19.useState)(
|
|
2019
2074
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
2020
2075
|
);
|
|
2021
|
-
const stateRef = (0,
|
|
2076
|
+
const stateRef = (0, import_react19.useRef)(pickerState);
|
|
2022
2077
|
stateRef.current = pickerState;
|
|
2023
|
-
(0,
|
|
2078
|
+
(0, import_react19.useEffect)(() => {
|
|
2024
2079
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
2025
2080
|
if (next) {
|
|
2026
2081
|
setPickerState(next);
|
|
2027
2082
|
}
|
|
2028
2083
|
}, [value]);
|
|
2029
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
2084
|
+
const [internalRecent, setInternalRecent] = (0, import_react19.useState)(
|
|
2030
2085
|
() => controlledRecent ? [] : readLocalRecents()
|
|
2031
2086
|
);
|
|
2032
2087
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
2033
|
-
const recordRecent = (0,
|
|
2088
|
+
const recordRecent = (0, import_react19.useCallback)(
|
|
2034
2089
|
(color) => {
|
|
2035
2090
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
2036
2091
|
if (!controlledRecent) {
|
|
@@ -2041,11 +2096,11 @@ var ColorPicker = ({
|
|
|
2041
2096
|
},
|
|
2042
2097
|
[activeRecent, controlledRecent, onRecentChange]
|
|
2043
2098
|
);
|
|
2044
|
-
const [textDraft, setTextDraft] = (0,
|
|
2045
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
2046
|
-
const [isClipped, setIsClipped] = (0,
|
|
2047
|
-
const isTypingRef = (0,
|
|
2048
|
-
(0,
|
|
2099
|
+
const [textDraft, setTextDraft] = (0, import_react19.useState)(value);
|
|
2100
|
+
const [isInvalid, setIsInvalid] = (0, import_react19.useState)(false);
|
|
2101
|
+
const [isClipped, setIsClipped] = (0, import_react19.useState)(false);
|
|
2102
|
+
const isTypingRef = (0, import_react19.useRef)(false);
|
|
2103
|
+
(0, import_react19.useEffect)(() => {
|
|
2049
2104
|
if (!isTypingRef.current) {
|
|
2050
2105
|
setTextDraft(value);
|
|
2051
2106
|
setIsInvalid(false);
|
|
@@ -2053,11 +2108,11 @@ var ColorPicker = ({
|
|
|
2053
2108
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
2054
2109
|
}
|
|
2055
2110
|
}, [value]);
|
|
2056
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
2057
|
-
(0,
|
|
2111
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react19.useState)(false);
|
|
2112
|
+
(0, import_react19.useEffect)(() => {
|
|
2058
2113
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
2059
2114
|
}, []);
|
|
2060
|
-
const emitColorChange = (0,
|
|
2115
|
+
const emitColorChange = (0, import_react19.useCallback)(
|
|
2061
2116
|
(nextState) => {
|
|
2062
2117
|
setPickerState(nextState);
|
|
2063
2118
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -2065,10 +2120,10 @@ var ColorPicker = ({
|
|
|
2065
2120
|
},
|
|
2066
2121
|
[alpha, onChange]
|
|
2067
2122
|
);
|
|
2068
|
-
const latest = (0,
|
|
2123
|
+
const latest = (0, import_react19.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
2069
2124
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
2070
|
-
const endDragRef = (0,
|
|
2071
|
-
(0,
|
|
2125
|
+
const endDragRef = (0, import_react19.useRef)(null);
|
|
2126
|
+
(0, import_react19.useEffect)(() => () => endDragRef.current?.(), []);
|
|
2072
2127
|
const startDrag = (e, next) => {
|
|
2073
2128
|
if (disabled) return;
|
|
2074
2129
|
e.preventDefault();
|
|
@@ -2170,7 +2225,7 @@ var ColorPicker = ({
|
|
|
2170
2225
|
} catch {
|
|
2171
2226
|
}
|
|
2172
2227
|
};
|
|
2173
|
-
const contrastResult = (0,
|
|
2228
|
+
const contrastResult = (0, import_react19.useMemo)(() => {
|
|
2174
2229
|
if (!contrastAgainst) return null;
|
|
2175
2230
|
const fg = (0, import_color.parseColor)(value);
|
|
2176
2231
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -2182,7 +2237,7 @@ var ColorPicker = ({
|
|
|
2182
2237
|
}, [value, contrastAgainst]);
|
|
2183
2238
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
2184
2239
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
2185
|
-
return /* @__PURE__ */ (0,
|
|
2240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2186
2241
|
"div",
|
|
2187
2242
|
{
|
|
2188
2243
|
id: pickerId,
|
|
@@ -2206,7 +2261,7 @@ var ColorPicker = ({
|
|
|
2206
2261
|
pointerEvents: disabled ? "none" : "auto"
|
|
2207
2262
|
},
|
|
2208
2263
|
children: [
|
|
2209
|
-
/* @__PURE__ */ (0,
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2210
2265
|
"span",
|
|
2211
2266
|
{
|
|
2212
2267
|
role: "status",
|
|
@@ -2225,7 +2280,7 @@ var ColorPicker = ({
|
|
|
2225
2280
|
children: liveDescription
|
|
2226
2281
|
}
|
|
2227
2282
|
),
|
|
2228
|
-
/* @__PURE__ */ (0,
|
|
2283
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2229
2284
|
"div",
|
|
2230
2285
|
{
|
|
2231
2286
|
role: "slider",
|
|
@@ -2247,7 +2302,7 @@ var ColorPicker = ({
|
|
|
2247
2302
|
touchAction: "none",
|
|
2248
2303
|
outline: "none"
|
|
2249
2304
|
},
|
|
2250
|
-
children: /* @__PURE__ */ (0,
|
|
2305
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2251
2306
|
"div",
|
|
2252
2307
|
{
|
|
2253
2308
|
style: {
|
|
@@ -2267,7 +2322,7 @@ var ColorPicker = ({
|
|
|
2267
2322
|
)
|
|
2268
2323
|
}
|
|
2269
2324
|
),
|
|
2270
|
-
/* @__PURE__ */ (0,
|
|
2325
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2271
2326
|
"div",
|
|
2272
2327
|
{
|
|
2273
2328
|
role: "slider",
|
|
@@ -2290,7 +2345,7 @@ var ColorPicker = ({
|
|
|
2290
2345
|
touchAction: "none",
|
|
2291
2346
|
outline: "none"
|
|
2292
2347
|
},
|
|
2293
|
-
children: /* @__PURE__ */ (0,
|
|
2348
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2294
2349
|
"div",
|
|
2295
2350
|
{
|
|
2296
2351
|
style: {
|
|
@@ -2310,7 +2365,7 @@ var ColorPicker = ({
|
|
|
2310
2365
|
)
|
|
2311
2366
|
}
|
|
2312
2367
|
),
|
|
2313
|
-
alpha && /* @__PURE__ */ (0,
|
|
2368
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2314
2369
|
"div",
|
|
2315
2370
|
{
|
|
2316
2371
|
role: "slider",
|
|
@@ -2336,7 +2391,7 @@ var ColorPicker = ({
|
|
|
2336
2391
|
overflow: "hidden"
|
|
2337
2392
|
},
|
|
2338
2393
|
children: [
|
|
2339
|
-
/* @__PURE__ */ (0,
|
|
2394
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2340
2395
|
"div",
|
|
2341
2396
|
{
|
|
2342
2397
|
style: {
|
|
@@ -2346,7 +2401,7 @@ var ColorPicker = ({
|
|
|
2346
2401
|
}
|
|
2347
2402
|
}
|
|
2348
2403
|
),
|
|
2349
|
-
/* @__PURE__ */ (0,
|
|
2404
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2350
2405
|
"div",
|
|
2351
2406
|
{
|
|
2352
2407
|
style: {
|
|
@@ -2367,8 +2422,8 @@ var ColorPicker = ({
|
|
|
2367
2422
|
]
|
|
2368
2423
|
}
|
|
2369
2424
|
),
|
|
2370
|
-
/* @__PURE__ */ (0,
|
|
2371
|
-
/* @__PURE__ */ (0,
|
|
2425
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
2426
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2372
2427
|
"div",
|
|
2373
2428
|
{
|
|
2374
2429
|
style: {
|
|
@@ -2382,7 +2437,7 @@ var ColorPicker = ({
|
|
|
2382
2437
|
flexShrink: 0,
|
|
2383
2438
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
2384
2439
|
},
|
|
2385
|
-
children: /* @__PURE__ */ (0,
|
|
2440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2386
2441
|
"div",
|
|
2387
2442
|
{
|
|
2388
2443
|
style: {
|
|
@@ -2394,7 +2449,7 @@ var ColorPicker = ({
|
|
|
2394
2449
|
)
|
|
2395
2450
|
}
|
|
2396
2451
|
),
|
|
2397
|
-
/* @__PURE__ */ (0,
|
|
2452
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2398
2453
|
"input",
|
|
2399
2454
|
{
|
|
2400
2455
|
type: "text",
|
|
@@ -2424,7 +2479,7 @@ var ColorPicker = ({
|
|
|
2424
2479
|
}
|
|
2425
2480
|
}
|
|
2426
2481
|
),
|
|
2427
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
2482
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2428
2483
|
"button",
|
|
2429
2484
|
{
|
|
2430
2485
|
type: "button",
|
|
@@ -2444,7 +2499,7 @@ var ColorPicker = ({
|
|
|
2444
2499
|
color: "inherit",
|
|
2445
2500
|
cursor: disabled ? "default" : "pointer"
|
|
2446
2501
|
},
|
|
2447
|
-
children: /* @__PURE__ */ (0,
|
|
2502
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2448
2503
|
"svg",
|
|
2449
2504
|
{
|
|
2450
2505
|
width: "14",
|
|
@@ -2456,16 +2511,16 @@ var ColorPicker = ({
|
|
|
2456
2511
|
strokeLinecap: "round",
|
|
2457
2512
|
strokeLinejoin: "round",
|
|
2458
2513
|
children: [
|
|
2459
|
-
/* @__PURE__ */ (0,
|
|
2460
|
-
/* @__PURE__ */ (0,
|
|
2461
|
-
/* @__PURE__ */ (0,
|
|
2514
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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" }),
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
2516
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "m14 6 4 4" })
|
|
2462
2517
|
]
|
|
2463
2518
|
}
|
|
2464
2519
|
)
|
|
2465
2520
|
}
|
|
2466
2521
|
)
|
|
2467
2522
|
] }),
|
|
2468
|
-
isClipped && /* @__PURE__ */ (0,
|
|
2523
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2469
2524
|
"div",
|
|
2470
2525
|
{
|
|
2471
2526
|
role: "note",
|
|
@@ -2481,10 +2536,10 @@ var ColorPicker = ({
|
|
|
2481
2536
|
borderRadius: "4px",
|
|
2482
2537
|
alignSelf: "flex-start"
|
|
2483
2538
|
},
|
|
2484
|
-
children: /* @__PURE__ */ (0,
|
|
2539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
2485
2540
|
}
|
|
2486
2541
|
),
|
|
2487
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
2542
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2488
2543
|
"div",
|
|
2489
2544
|
{
|
|
2490
2545
|
style: {
|
|
@@ -2498,15 +2553,15 @@ var ColorPicker = ({
|
|
|
2498
2553
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
2499
2554
|
},
|
|
2500
2555
|
children: [
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
2556
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
2502
2557
|
"Contrast: ",
|
|
2503
|
-
/* @__PURE__ */ (0,
|
|
2558
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("strong", { children: [
|
|
2504
2559
|
contrastResult.ratio.toFixed(2),
|
|
2505
2560
|
":1"
|
|
2506
2561
|
] })
|
|
2507
2562
|
] }),
|
|
2508
|
-
/* @__PURE__ */ (0,
|
|
2509
|
-
/* @__PURE__ */ (0,
|
|
2563
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2510
2565
|
"span",
|
|
2511
2566
|
{
|
|
2512
2567
|
style: {
|
|
@@ -2519,7 +2574,7 @@ var ColorPicker = ({
|
|
|
2519
2574
|
]
|
|
2520
2575
|
}
|
|
2521
2576
|
),
|
|
2522
|
-
/* @__PURE__ */ (0,
|
|
2577
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2523
2578
|
"span",
|
|
2524
2579
|
{
|
|
2525
2580
|
style: {
|
|
@@ -2536,9 +2591,9 @@ var ColorPicker = ({
|
|
|
2536
2591
|
]
|
|
2537
2592
|
}
|
|
2538
2593
|
),
|
|
2539
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2540
|
-
/* @__PURE__ */ (0,
|
|
2541
|
-
/* @__PURE__ */ (0,
|
|
2594
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2595
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2542
2597
|
"button",
|
|
2543
2598
|
{
|
|
2544
2599
|
type: "button",
|
|
@@ -2564,9 +2619,9 @@ var ColorPicker = ({
|
|
|
2564
2619
|
`${color}-${idx}`
|
|
2565
2620
|
)) })
|
|
2566
2621
|
] }),
|
|
2567
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
2568
|
-
/* @__PURE__ */ (0,
|
|
2569
|
-
/* @__PURE__ */ (0,
|
|
2622
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2623
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
2624
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2570
2625
|
"button",
|
|
2571
2626
|
{
|
|
2572
2627
|
type: "button",
|
|
@@ -2597,9 +2652,9 @@ var ColorPicker = ({
|
|
|
2597
2652
|
};
|
|
2598
2653
|
|
|
2599
2654
|
// src/color/DualColorPicker.tsx
|
|
2600
|
-
var
|
|
2655
|
+
var import_react20 = require("react");
|
|
2601
2656
|
var import_color2 = require("@pixerate/editor/color");
|
|
2602
|
-
var
|
|
2657
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2603
2658
|
function DualColorPicker({
|
|
2604
2659
|
value,
|
|
2605
2660
|
onChange,
|
|
@@ -2614,8 +2669,8 @@ function DualColorPicker({
|
|
|
2614
2669
|
disabled = false,
|
|
2615
2670
|
className = ""
|
|
2616
2671
|
}) {
|
|
2617
|
-
const sameId = (0,
|
|
2618
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
2672
|
+
const sameId = (0, import_react20.useId)();
|
|
2673
|
+
const [internalScheme, setInternalScheme] = (0, import_react20.useState)("light");
|
|
2619
2674
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
2620
2675
|
const handleSchemeSelect = (nextScheme) => {
|
|
2621
2676
|
if (onSchemeChange) {
|
|
@@ -2626,7 +2681,7 @@ function DualColorPicker({
|
|
|
2626
2681
|
};
|
|
2627
2682
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
2628
2683
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
2629
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
2684
|
+
const [sameInBoth, setSameInBoth] = (0, import_react20.useState)(isSame);
|
|
2630
2685
|
const handleSameToggle = (e) => {
|
|
2631
2686
|
const nextSame = e.target.checked;
|
|
2632
2687
|
setSameInBoth(nextSame);
|
|
@@ -2658,7 +2713,7 @@ function DualColorPicker({
|
|
|
2658
2713
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
2659
2714
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
2660
2715
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
2661
|
-
return /* @__PURE__ */ (0,
|
|
2716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2662
2717
|
"div",
|
|
2663
2718
|
{
|
|
2664
2719
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -2677,7 +2732,7 @@ function DualColorPicker({
|
|
|
2677
2732
|
boxSizing: "border-box"
|
|
2678
2733
|
},
|
|
2679
2734
|
children: [
|
|
2680
|
-
/* @__PURE__ */ (0,
|
|
2735
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2681
2736
|
"div",
|
|
2682
2737
|
{
|
|
2683
2738
|
role: "tablist",
|
|
@@ -2690,7 +2745,7 @@ function DualColorPicker({
|
|
|
2690
2745
|
gap: "2px"
|
|
2691
2746
|
},
|
|
2692
2747
|
children: [
|
|
2693
|
-
/* @__PURE__ */ (0,
|
|
2748
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2694
2749
|
"button",
|
|
2695
2750
|
{
|
|
2696
2751
|
type: "button",
|
|
@@ -2713,7 +2768,7 @@ function DualColorPicker({
|
|
|
2713
2768
|
children: "Light"
|
|
2714
2769
|
}
|
|
2715
2770
|
),
|
|
2716
|
-
/* @__PURE__ */ (0,
|
|
2771
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2717
2772
|
"button",
|
|
2718
2773
|
{
|
|
2719
2774
|
type: "button",
|
|
@@ -2739,8 +2794,8 @@ function DualColorPicker({
|
|
|
2739
2794
|
]
|
|
2740
2795
|
}
|
|
2741
2796
|
),
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
2743
|
-
/* @__PURE__ */ (0,
|
|
2797
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2744
2799
|
"button",
|
|
2745
2800
|
{
|
|
2746
2801
|
type: "button",
|
|
@@ -2762,7 +2817,7 @@ function DualColorPicker({
|
|
|
2762
2817
|
outline: "none"
|
|
2763
2818
|
},
|
|
2764
2819
|
children: [
|
|
2765
|
-
/* @__PURE__ */ (0,
|
|
2820
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2766
2821
|
"span",
|
|
2767
2822
|
{
|
|
2768
2823
|
style: {
|
|
@@ -2774,11 +2829,11 @@ function DualColorPicker({
|
|
|
2774
2829
|
}
|
|
2775
2830
|
}
|
|
2776
2831
|
),
|
|
2777
|
-
/* @__PURE__ */ (0,
|
|
2832
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2778
2833
|
]
|
|
2779
2834
|
}
|
|
2780
2835
|
),
|
|
2781
|
-
/* @__PURE__ */ (0,
|
|
2836
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2782
2837
|
"button",
|
|
2783
2838
|
{
|
|
2784
2839
|
type: "button",
|
|
@@ -2800,7 +2855,7 @@ function DualColorPicker({
|
|
|
2800
2855
|
outline: "none"
|
|
2801
2856
|
},
|
|
2802
2857
|
children: [
|
|
2803
|
-
/* @__PURE__ */ (0,
|
|
2858
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2804
2859
|
"span",
|
|
2805
2860
|
{
|
|
2806
2861
|
style: {
|
|
@@ -2812,12 +2867,12 @@ function DualColorPicker({
|
|
|
2812
2867
|
}
|
|
2813
2868
|
}
|
|
2814
2869
|
),
|
|
2815
|
-
/* @__PURE__ */ (0,
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2816
2871
|
]
|
|
2817
2872
|
}
|
|
2818
2873
|
)
|
|
2819
2874
|
] }),
|
|
2820
|
-
/* @__PURE__ */ (0,
|
|
2875
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2821
2876
|
"div",
|
|
2822
2877
|
{
|
|
2823
2878
|
style: {
|
|
@@ -2828,7 +2883,7 @@ function DualColorPicker({
|
|
|
2828
2883
|
padding: "2px 0"
|
|
2829
2884
|
},
|
|
2830
2885
|
children: [
|
|
2831
|
-
/* @__PURE__ */ (0,
|
|
2886
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2832
2887
|
"label",
|
|
2833
2888
|
{
|
|
2834
2889
|
htmlFor: sameId,
|
|
@@ -2842,7 +2897,7 @@ function DualColorPicker({
|
|
|
2842
2897
|
color: "#c4cad4"
|
|
2843
2898
|
},
|
|
2844
2899
|
children: [
|
|
2845
|
-
/* @__PURE__ */ (0,
|
|
2900
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2846
2901
|
"input",
|
|
2847
2902
|
{
|
|
2848
2903
|
id: sameId,
|
|
@@ -2853,11 +2908,11 @@ function DualColorPicker({
|
|
|
2853
2908
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2854
2909
|
}
|
|
2855
2910
|
),
|
|
2856
|
-
/* @__PURE__ */ (0,
|
|
2911
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: "Same in both" })
|
|
2857
2912
|
]
|
|
2858
2913
|
}
|
|
2859
2914
|
),
|
|
2860
|
-
/* @__PURE__ */ (0,
|
|
2915
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2861
2916
|
"button",
|
|
2862
2917
|
{
|
|
2863
2918
|
type: "button",
|
|
@@ -2879,7 +2934,7 @@ function DualColorPicker({
|
|
|
2879
2934
|
]
|
|
2880
2935
|
}
|
|
2881
2936
|
),
|
|
2882
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
2937
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2883
2938
|
"div",
|
|
2884
2939
|
{
|
|
2885
2940
|
"data-testid": "dual-contrast-summary",
|
|
@@ -2893,20 +2948,20 @@ function DualColorPicker({
|
|
|
2893
2948
|
color: "#8c95a6"
|
|
2894
2949
|
},
|
|
2895
2950
|
children: [
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
2951
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { children: [
|
|
2897
2952
|
"Light:",
|
|
2898
2953
|
" ",
|
|
2899
|
-
/* @__PURE__ */ (0,
|
|
2954
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2900
2955
|
dualContrast.light.ratio.toFixed(2),
|
|
2901
2956
|
" (",
|
|
2902
2957
|
dualContrast.light.level,
|
|
2903
2958
|
")"
|
|
2904
2959
|
] })
|
|
2905
2960
|
] }),
|
|
2906
|
-
/* @__PURE__ */ (0,
|
|
2961
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { children: [
|
|
2907
2962
|
"Dark:",
|
|
2908
2963
|
" ",
|
|
2909
|
-
/* @__PURE__ */ (0,
|
|
2964
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2910
2965
|
dualContrast.dark.ratio.toFixed(2),
|
|
2911
2966
|
" (",
|
|
2912
2967
|
dualContrast.dark.level,
|
|
@@ -2916,7 +2971,7 @@ function DualColorPicker({
|
|
|
2916
2971
|
]
|
|
2917
2972
|
}
|
|
2918
2973
|
),
|
|
2919
|
-
/* @__PURE__ */ (0,
|
|
2974
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2920
2975
|
ColorPicker,
|
|
2921
2976
|
{
|
|
2922
2977
|
value: activeColor,
|
|
@@ -2935,7 +2990,7 @@ function DualColorPicker({
|
|
|
2935
2990
|
}
|
|
2936
2991
|
|
|
2937
2992
|
// src/color/useColorScheme.ts
|
|
2938
|
-
var
|
|
2993
|
+
var import_react21 = require("react");
|
|
2939
2994
|
var import_color3 = require("@pixerate/editor/color");
|
|
2940
2995
|
function getSnapshot(attribute) {
|
|
2941
2996
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -2960,7 +3015,7 @@ function getServerSnapshot() {
|
|
|
2960
3015
|
function useColorScheme(options) {
|
|
2961
3016
|
const override = options?.override;
|
|
2962
3017
|
const attribute = options?.attribute;
|
|
2963
|
-
const subscribe = (0,
|
|
3018
|
+
const subscribe = (0, import_react21.useMemo)(() => {
|
|
2964
3019
|
return (callback) => {
|
|
2965
3020
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2966
3021
|
return () => {
|
|
@@ -2986,7 +3041,7 @@ function useColorScheme(options) {
|
|
|
2986
3041
|
};
|
|
2987
3042
|
};
|
|
2988
3043
|
}, [attribute]);
|
|
2989
|
-
const detected = (0,
|
|
3044
|
+
const detected = (0, import_react21.useSyncExternalStore)(
|
|
2990
3045
|
subscribe,
|
|
2991
3046
|
() => getSnapshot(attribute),
|
|
2992
3047
|
getServerSnapshot
|
|
@@ -3003,11 +3058,11 @@ function useResolvedColor(value, scheme) {
|
|
|
3003
3058
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
3004
3059
|
|
|
3005
3060
|
// src/parameters/controls.tsx
|
|
3006
|
-
var
|
|
3007
|
-
var
|
|
3008
|
-
var ParameterComponentsContext = (0,
|
|
3061
|
+
var import_react22 = require("react");
|
|
3062
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3063
|
+
var ParameterComponentsContext = (0, import_react22.createContext)({});
|
|
3009
3064
|
function useParameterComponents() {
|
|
3010
|
-
return (0,
|
|
3065
|
+
return (0, import_react22.useContext)(ParameterComponentsContext);
|
|
3011
3066
|
}
|
|
3012
3067
|
function resolveParameterComponents(explicit, context) {
|
|
3013
3068
|
return {
|
|
@@ -3019,7 +3074,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
3019
3074
|
}
|
|
3020
3075
|
|
|
3021
3076
|
// src/parameters/fields.tsx
|
|
3022
|
-
var
|
|
3077
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3023
3078
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
3024
3079
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
3025
3080
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -3028,9 +3083,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
3028
3083
|
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";
|
|
3029
3084
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
3030
3085
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
3031
|
-
const inputRef = (0,
|
|
3032
|
-
const lastCommitted = (0,
|
|
3033
|
-
(0,
|
|
3086
|
+
const inputRef = (0, import_react23.useRef)(null);
|
|
3087
|
+
const lastCommitted = (0, import_react23.useRef)(null);
|
|
3088
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
3034
3089
|
lastCommitted.current = null;
|
|
3035
3090
|
const el = inputRef.current;
|
|
3036
3091
|
if (el && el.value !== value) el.value = value;
|
|
@@ -3041,9 +3096,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3041
3096
|
onCommit(text, el);
|
|
3042
3097
|
lastCommitted.current = el.value === text ? text : null;
|
|
3043
3098
|
};
|
|
3044
|
-
const commitRef = (0,
|
|
3099
|
+
const commitRef = (0, import_react23.useRef)(commit);
|
|
3045
3100
|
commitRef.current = commit;
|
|
3046
|
-
(0,
|
|
3101
|
+
(0, import_react23.useEffect)(() => {
|
|
3047
3102
|
const el = inputRef.current;
|
|
3048
3103
|
if (!el) return;
|
|
3049
3104
|
const change = () => commitRef.current(el);
|
|
@@ -3074,7 +3129,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3074
3129
|
if (typeof forwarded === "function") forwarded(el);
|
|
3075
3130
|
else if (forwarded) forwarded.current = el;
|
|
3076
3131
|
};
|
|
3077
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
3132
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
3078
3133
|
}
|
|
3079
3134
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
3080
3135
|
function ParameterNumberInput(props) {
|
|
@@ -3108,9 +3163,9 @@ function ParameterNumberInput(props) {
|
|
|
3108
3163
|
onCommit: handleCommit,
|
|
3109
3164
|
onKeyDown: handleKeyDown
|
|
3110
3165
|
};
|
|
3111
|
-
return /* @__PURE__ */ (0,
|
|
3112
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
3113
|
-
field.unit && /* @__PURE__ */ (0,
|
|
3166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
3167
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
3168
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
3114
3169
|
] });
|
|
3115
3170
|
}
|
|
3116
3171
|
function ParameterSlider(props) {
|
|
@@ -3118,7 +3173,7 @@ function ParameterSlider(props) {
|
|
|
3118
3173
|
const ctx = useParameterComponents();
|
|
3119
3174
|
const resolved = resolveParameterComponents(components, ctx);
|
|
3120
3175
|
const CustomSlider = resolved.slider;
|
|
3121
|
-
const dragging = (0,
|
|
3176
|
+
const dragging = (0, import_react23.useRef)(false);
|
|
3122
3177
|
const start = () => {
|
|
3123
3178
|
if (dragging.current) return;
|
|
3124
3179
|
dragging.current = true;
|
|
@@ -3129,7 +3184,7 @@ function ParameterSlider(props) {
|
|
|
3129
3184
|
dragging.current = false;
|
|
3130
3185
|
onGestureEnd?.();
|
|
3131
3186
|
};
|
|
3132
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
3187
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterNumberInput, { ...props });
|
|
3133
3188
|
const step = (0, import_parameters.parameterStep)(field);
|
|
3134
3189
|
const sliderProps = {
|
|
3135
3190
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -3143,8 +3198,8 @@ function ParameterSlider(props) {
|
|
|
3143
3198
|
className: rangeClass,
|
|
3144
3199
|
style: parameterRangeStyle
|
|
3145
3200
|
};
|
|
3146
|
-
return /* @__PURE__ */ (0,
|
|
3147
|
-
CustomSlider ? /* @__PURE__ */ (0,
|
|
3201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3202
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3148
3203
|
CustomSlider,
|
|
3149
3204
|
{
|
|
3150
3205
|
...sliderProps,
|
|
@@ -3154,7 +3209,7 @@ function ParameterSlider(props) {
|
|
|
3154
3209
|
onGestureStart: start,
|
|
3155
3210
|
onGestureEnd: end
|
|
3156
3211
|
}
|
|
3157
|
-
) : /* @__PURE__ */ (0,
|
|
3212
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3158
3213
|
"input",
|
|
3159
3214
|
{
|
|
3160
3215
|
type: "range",
|
|
@@ -3166,11 +3221,11 @@ function ParameterSlider(props) {
|
|
|
3166
3221
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
3167
3222
|
}
|
|
3168
3223
|
),
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3224
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
3170
3225
|
] });
|
|
3171
3226
|
}
|
|
3172
3227
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
3173
|
-
return /* @__PURE__ */ (0,
|
|
3228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3174
3229
|
"button",
|
|
3175
3230
|
{
|
|
3176
3231
|
type: "button",
|
|
@@ -3181,7 +3236,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
3181
3236
|
disabled: disabled || field.readOnly,
|
|
3182
3237
|
onClick: () => onChange(!value),
|
|
3183
3238
|
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"}`,
|
|
3184
|
-
children: /* @__PURE__ */ (0,
|
|
3239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3185
3240
|
"span",
|
|
3186
3241
|
{
|
|
3187
3242
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -3198,7 +3253,7 @@ function ParameterSelect(props) {
|
|
|
3198
3253
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
3199
3254
|
const off = disabled || field.readOnly;
|
|
3200
3255
|
if (field.control === "segmented") {
|
|
3201
|
-
return /* @__PURE__ */ (0,
|
|
3256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.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_runtime23.jsx)(
|
|
3202
3257
|
"button",
|
|
3203
3258
|
{
|
|
3204
3259
|
type: "button",
|
|
@@ -3215,7 +3270,7 @@ function ParameterSelect(props) {
|
|
|
3215
3270
|
}
|
|
3216
3271
|
if (CustomSelect) {
|
|
3217
3272
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
3218
|
-
return /* @__PURE__ */ (0,
|
|
3273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3219
3274
|
CustomSelect,
|
|
3220
3275
|
{
|
|
3221
3276
|
id,
|
|
@@ -3231,7 +3286,7 @@ function ParameterSelect(props) {
|
|
|
3231
3286
|
);
|
|
3232
3287
|
}
|
|
3233
3288
|
const index = options.findIndex((o) => o.value === value);
|
|
3234
|
-
return /* @__PURE__ */ (0,
|
|
3289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3235
3290
|
"select",
|
|
3236
3291
|
{
|
|
3237
3292
|
id,
|
|
@@ -3244,23 +3299,23 @@ function ParameterSelect(props) {
|
|
|
3244
3299
|
},
|
|
3245
3300
|
className: parameterInputClass,
|
|
3246
3301
|
style: parameterSelectStyle,
|
|
3247
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
3302
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
3248
3303
|
}
|
|
3249
3304
|
);
|
|
3250
3305
|
}
|
|
3251
3306
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
3252
3307
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
3253
|
-
const [open, setOpen] = (0,
|
|
3254
|
-
const containerRef = (0,
|
|
3255
|
-
const buttonRef = (0,
|
|
3256
|
-
const popoverRef = (0,
|
|
3308
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
3309
|
+
const containerRef = (0, import_react23.useRef)(null);
|
|
3310
|
+
const buttonRef = (0, import_react23.useRef)(null);
|
|
3311
|
+
const popoverRef = (0, import_react23.useRef)(null);
|
|
3257
3312
|
const alpha = !!field.alpha;
|
|
3258
3313
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
3259
3314
|
const rgb = hex.slice(0, 7);
|
|
3260
3315
|
const shown = alpha ? hex : rgb;
|
|
3261
3316
|
const off = disabled || field.readOnly;
|
|
3262
3317
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3263
|
-
(0,
|
|
3318
|
+
(0, import_react23.useEffect)(() => {
|
|
3264
3319
|
if (!open) return;
|
|
3265
3320
|
const onPointerDown = (e) => {
|
|
3266
3321
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3282,7 +3337,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3282
3337
|
};
|
|
3283
3338
|
}, [open]);
|
|
3284
3339
|
if (CustomColor) {
|
|
3285
|
-
return /* @__PURE__ */ (0,
|
|
3340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3286
3341
|
CustomColor,
|
|
3287
3342
|
{
|
|
3288
3343
|
id,
|
|
@@ -3297,9 +3352,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3297
3352
|
}
|
|
3298
3353
|
);
|
|
3299
3354
|
}
|
|
3300
|
-
return /* @__PURE__ */ (0,
|
|
3301
|
-
/* @__PURE__ */ (0,
|
|
3302
|
-
/* @__PURE__ */ (0,
|
|
3355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
3356
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3357
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3303
3358
|
"button",
|
|
3304
3359
|
{
|
|
3305
3360
|
ref: buttonRef,
|
|
@@ -3310,10 +3365,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3310
3365
|
disabled: off,
|
|
3311
3366
|
onClick: () => setOpen((prev) => !prev),
|
|
3312
3367
|
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",
|
|
3313
|
-
children: /* @__PURE__ */ (0,
|
|
3368
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3314
3369
|
}
|
|
3315
3370
|
),
|
|
3316
|
-
/* @__PURE__ */ (0,
|
|
3371
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3317
3372
|
ParameterCommitInput,
|
|
3318
3373
|
{
|
|
3319
3374
|
id,
|
|
@@ -3329,7 +3384,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3329
3384
|
}
|
|
3330
3385
|
)
|
|
3331
3386
|
] }),
|
|
3332
|
-
open && /* @__PURE__ */ (0,
|
|
3387
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3333
3388
|
"div",
|
|
3334
3389
|
{
|
|
3335
3390
|
ref: popoverRef,
|
|
@@ -3343,7 +3398,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3343
3398
|
},
|
|
3344
3399
|
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",
|
|
3345
3400
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3346
|
-
children: /* @__PURE__ */ (0,
|
|
3401
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3347
3402
|
ColorPicker,
|
|
3348
3403
|
{
|
|
3349
3404
|
value: shown,
|
|
@@ -3361,11 +3416,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3361
3416
|
}
|
|
3362
3417
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
3363
3418
|
const size = (0, import_parameters.vectorSize)(field);
|
|
3364
|
-
return /* @__PURE__ */ (0,
|
|
3419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
3365
3420
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
3366
|
-
return /* @__PURE__ */ (0,
|
|
3367
|
-
/* @__PURE__ */ (0,
|
|
3368
|
-
/* @__PURE__ */ (0,
|
|
3421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3422
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
3423
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3369
3424
|
ParameterNumberInput,
|
|
3370
3425
|
{
|
|
3371
3426
|
field: component,
|
|
@@ -3383,11 +3438,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
3383
3438
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
3384
3439
|
const off = disabled || field.readOnly;
|
|
3385
3440
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3386
|
-
return /* @__PURE__ */ (0,
|
|
3387
|
-
/* @__PURE__ */ (0,
|
|
3388
|
-
/* @__PURE__ */ (0,
|
|
3389
|
-
/* @__PURE__ */ (0,
|
|
3390
|
-
/* @__PURE__ */ (0,
|
|
3441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "space-y-1.5", children: [
|
|
3442
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3443
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.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_runtime23.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3444
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3445
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3391
3446
|
ParameterCommitInput,
|
|
3392
3447
|
{
|
|
3393
3448
|
id,
|
|
@@ -3398,15 +3453,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3398
3453
|
onCommit: (text) => onChange(text.trim())
|
|
3399
3454
|
}
|
|
3400
3455
|
),
|
|
3401
|
-
/* @__PURE__ */ (0,
|
|
3402
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3456
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex gap-1", children: [
|
|
3457
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3403
3458
|
"label",
|
|
3404
3459
|
{
|
|
3405
3460
|
style: parameterButtonStyle,
|
|
3406
3461
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3407
3462
|
children: [
|
|
3408
3463
|
"Choose file\u2026",
|
|
3409
|
-
/* @__PURE__ */ (0,
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3410
3465
|
"input",
|
|
3411
3466
|
{
|
|
3412
3467
|
type: "file",
|
|
@@ -3424,7 +3479,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3424
3479
|
]
|
|
3425
3480
|
}
|
|
3426
3481
|
),
|
|
3427
|
-
value && /* @__PURE__ */ (0,
|
|
3482
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3428
3483
|
"button",
|
|
3429
3484
|
{
|
|
3430
3485
|
type: "button",
|
|
@@ -3439,7 +3494,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3439
3494
|
] })
|
|
3440
3495
|
] })
|
|
3441
3496
|
] }),
|
|
3442
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
3497
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3443
3498
|
"button",
|
|
3444
3499
|
{
|
|
3445
3500
|
type: "button",
|
|
@@ -3449,14 +3504,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3449
3504
|
disabled: off,
|
|
3450
3505
|
onClick: () => onChange(o.url),
|
|
3451
3506
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
3452
|
-
children: /* @__PURE__ */ (0,
|
|
3507
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
3453
3508
|
},
|
|
3454
3509
|
o.url
|
|
3455
3510
|
)) })
|
|
3456
3511
|
] });
|
|
3457
3512
|
}
|
|
3458
3513
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
3459
|
-
return /* @__PURE__ */ (0,
|
|
3514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3460
3515
|
ParameterCommitInput,
|
|
3461
3516
|
{
|
|
3462
3517
|
id,
|
|
@@ -3475,24 +3530,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
3475
3530
|
switch (field.type) {
|
|
3476
3531
|
case "number":
|
|
3477
3532
|
case "int":
|
|
3478
|
-
return /* @__PURE__ */ (0,
|
|
3533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
3479
3534
|
case "boolean":
|
|
3480
|
-
return /* @__PURE__ */ (0,
|
|
3535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
3481
3536
|
case "choice":
|
|
3482
|
-
return /* @__PURE__ */ (0,
|
|
3537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
3483
3538
|
case "color":
|
|
3484
|
-
return /* @__PURE__ */ (0,
|
|
3539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
3485
3540
|
case "vector":
|
|
3486
|
-
return /* @__PURE__ */ (0,
|
|
3541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
3487
3542
|
case "image":
|
|
3488
|
-
return /* @__PURE__ */ (0,
|
|
3543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
3489
3544
|
case "text":
|
|
3490
|
-
return /* @__PURE__ */ (0,
|
|
3545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
3491
3546
|
}
|
|
3492
3547
|
}
|
|
3493
3548
|
|
|
3494
3549
|
// src/effects/EffectParameters.tsx
|
|
3495
|
-
var
|
|
3550
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3496
3551
|
function EffectParameters({
|
|
3497
3552
|
description,
|
|
3498
3553
|
values,
|
|
@@ -3507,10 +3562,10 @@ function EffectParameters({
|
|
|
3507
3562
|
className = "",
|
|
3508
3563
|
components
|
|
3509
3564
|
}) {
|
|
3510
|
-
const fields = (0,
|
|
3511
|
-
const idBase = (0,
|
|
3512
|
-
const gesture =
|
|
3513
|
-
const count =
|
|
3565
|
+
const fields = (0, import_react24.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3566
|
+
const idBase = (0, import_react24.useId)();
|
|
3567
|
+
const gesture = import_react24.default.useRef(null);
|
|
3568
|
+
const count = import_react24.default.useRef(0);
|
|
3514
3569
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3515
3570
|
const handlePresetSelect = (name) => {
|
|
3516
3571
|
if (!name) return;
|
|
@@ -3521,8 +3576,8 @@ function EffectParameters({
|
|
|
3521
3576
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3522
3577
|
}
|
|
3523
3578
|
};
|
|
3524
|
-
return /* @__PURE__ */ (0,
|
|
3525
|
-
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0,
|
|
3579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3580
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3526
3581
|
CustomPresetSelect,
|
|
3527
3582
|
{
|
|
3528
3583
|
"aria-label": `${description.name} presets`,
|
|
@@ -3537,7 +3592,7 @@ function EffectParameters({
|
|
|
3537
3592
|
],
|
|
3538
3593
|
onChange: (name) => handlePresetSelect(String(name))
|
|
3539
3594
|
}
|
|
3540
|
-
) : /* @__PURE__ */ (0,
|
|
3595
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
3541
3596
|
"select",
|
|
3542
3597
|
{
|
|
3543
3598
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -3547,8 +3602,8 @@ function EffectParameters({
|
|
|
3547
3602
|
disabled,
|
|
3548
3603
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3549
3604
|
children: [
|
|
3550
|
-
/* @__PURE__ */ (0,
|
|
3551
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3605
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
3606
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
3552
3607
|
]
|
|
3553
3608
|
}
|
|
3554
3609
|
)),
|
|
@@ -3558,14 +3613,14 @@ function EffectParameters({
|
|
|
3558
3613
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
3559
3614
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
3560
3615
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
3561
|
-
return /* @__PURE__ */ (0,
|
|
3562
|
-
/* @__PURE__ */ (0,
|
|
3563
|
-
/* @__PURE__ */ (0,
|
|
3564
|
-
keyed && /* @__PURE__ */ (0,
|
|
3616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
3617
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3618
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
3619
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
3565
3620
|
renderControlAddon?.(field.id),
|
|
3566
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3621
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime24.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" })
|
|
3567
3622
|
] }),
|
|
3568
|
-
/* @__PURE__ */ (0,
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3569
3624
|
ParameterFieldControl,
|
|
3570
3625
|
{
|
|
3571
3626
|
field,
|
|
@@ -3580,15 +3635,15 @@ function EffectParameters({
|
|
|
3580
3635
|
)
|
|
3581
3636
|
] }, field.id);
|
|
3582
3637
|
}),
|
|
3583
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3638
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3584
3639
|
] });
|
|
3585
3640
|
}
|
|
3586
3641
|
|
|
3587
3642
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
3588
|
-
var
|
|
3643
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3589
3644
|
function usePaintEffectsProvider(controller) {
|
|
3590
|
-
const [provider, setProvider] = (0,
|
|
3591
|
-
(0,
|
|
3645
|
+
const [provider, setProvider] = (0, import_react25.useState)(controller.effectsProvider);
|
|
3646
|
+
(0, import_react25.useEffect)(() => {
|
|
3592
3647
|
setProvider(controller.effectsProvider);
|
|
3593
3648
|
return controller.effects.subscribe(setProvider);
|
|
3594
3649
|
}, [controller]);
|
|
@@ -3596,27 +3651,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
3596
3651
|
}
|
|
3597
3652
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
3598
3653
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
3599
|
-
(0,
|
|
3654
|
+
(0, import_react25.useEffect)(() => {
|
|
3600
3655
|
if (!registry) return;
|
|
3601
|
-
return registry.register((0,
|
|
3656
|
+
return registry.register((0, import_paint_editor15.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
3602
3657
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
3603
3658
|
}
|
|
3604
3659
|
function Controls({ provider, effect, name, values, apply }) {
|
|
3605
3660
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3606
|
-
const drags = (0,
|
|
3607
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
3661
|
+
const drags = (0, import_react25.useRef)(/* @__PURE__ */ new Set());
|
|
3662
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
|
|
3608
3663
|
'No effects provider: "',
|
|
3609
3664
|
name ?? effect,
|
|
3610
3665
|
'" is kept as it was drawn.'
|
|
3611
3666
|
] });
|
|
3612
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3613
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
3667
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
|
|
3668
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
3614
3669
|
const commit = (gesture) => {
|
|
3615
3670
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
3616
3671
|
drags.current.add(gesture);
|
|
3617
3672
|
return true;
|
|
3618
3673
|
};
|
|
3619
|
-
return /* @__PURE__ */ (0,
|
|
3674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3620
3675
|
EffectParameters,
|
|
3621
3676
|
{
|
|
3622
3677
|
description,
|
|
@@ -3638,8 +3693,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3638
3693
|
const state = usePaintEditorState(controller);
|
|
3639
3694
|
const provider = usePaintEffectsProvider(controller);
|
|
3640
3695
|
const [error, attempt] = useAttempt();
|
|
3641
|
-
const [browse, setBrowse] = (0,
|
|
3642
|
-
const [busy, setBusy] = (0,
|
|
3696
|
+
const [browse, setBrowse] = (0, import_react25.useState)(null);
|
|
3697
|
+
const [busy, setBusy] = (0, import_react25.useState)(false);
|
|
3643
3698
|
const paper = controller.getPaperEffect();
|
|
3644
3699
|
const activeId = state.document.activeLayerId;
|
|
3645
3700
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -3651,7 +3706,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3651
3706
|
if (!effectPaint) return;
|
|
3652
3707
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
3653
3708
|
};
|
|
3654
|
-
const thumbnail = (0,
|
|
3709
|
+
const thumbnail = (0, import_react25.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
3655
3710
|
const run = (work) => attempt(() => {
|
|
3656
3711
|
setBusy(true);
|
|
3657
3712
|
return work().finally(() => setBusy(false));
|
|
@@ -3667,28 +3722,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3667
3722
|
};
|
|
3668
3723
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
3669
3724
|
const pixel = active?.type === "pixel";
|
|
3670
|
-
return /* @__PURE__ */ (0,
|
|
3671
|
-
/* @__PURE__ */ (0,
|
|
3672
|
-
/* @__PURE__ */ (0,
|
|
3673
|
-
/* @__PURE__ */ (0,
|
|
3674
|
-
/* @__PURE__ */ (0,
|
|
3675
|
-
/* @__PURE__ */ (0,
|
|
3676
|
-
/* @__PURE__ */ (0,
|
|
3677
|
-
/* @__PURE__ */ (0,
|
|
3725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
3726
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3727
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
3728
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
3729
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
3730
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
3731
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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" }),
|
|
3732
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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" })
|
|
3678
3733
|
] }),
|
|
3679
|
-
!provider && /* @__PURE__ */ (0,
|
|
3680
|
-
browse && /* @__PURE__ */ (0,
|
|
3681
|
-
paper && /* @__PURE__ */ (0,
|
|
3682
|
-
/* @__PURE__ */ (0,
|
|
3683
|
-
/* @__PURE__ */ (0,
|
|
3734
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
3735
|
+
browse && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
3736
|
+
paper && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3738
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3684
3739
|
"Paper: ",
|
|
3685
3740
|
paper.name ?? paper.effect
|
|
3686
3741
|
] }),
|
|
3687
|
-
/* @__PURE__ */ (0,
|
|
3742
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
3688
3743
|
] }),
|
|
3689
|
-
/* @__PURE__ */ (0,
|
|
3690
|
-
/* @__PURE__ */ (0,
|
|
3691
|
-
/* @__PURE__ */ (0,
|
|
3744
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3745
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
3746
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3692
3747
|
"input",
|
|
3693
3748
|
{
|
|
3694
3749
|
type: "range",
|
|
@@ -3710,39 +3765,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3710
3765
|
`o${paper.opacity}`
|
|
3711
3766
|
)
|
|
3712
3767
|
] }),
|
|
3713
|
-
/* @__PURE__ */ (0,
|
|
3714
|
-
/* @__PURE__ */ (0,
|
|
3715
|
-
/* @__PURE__ */ (0,
|
|
3768
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3769
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
3770
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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) => {
|
|
3716
3771
|
const blend = e.currentTarget.value;
|
|
3717
3772
|
run(() => controller.updatePaperEffect({ blend }));
|
|
3718
|
-
}, children:
|
|
3773
|
+
}, children: import_paint_editor15.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: b, children: b }, b)) })
|
|
3719
3774
|
] }),
|
|
3720
|
-
/* @__PURE__ */ (0,
|
|
3775
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
3721
3776
|
] }),
|
|
3722
|
-
effectPaint && /* @__PURE__ */ (0,
|
|
3723
|
-
/* @__PURE__ */ (0,
|
|
3724
|
-
thumbnail ? /* @__PURE__ */ (0,
|
|
3725
|
-
/* @__PURE__ */ (0,
|
|
3777
|
+
effectPaint && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
3778
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3779
|
+
thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
3780
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3726
3781
|
"Paint: ",
|
|
3727
3782
|
effectPaint.effect,
|
|
3728
3783
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
3729
3784
|
] }),
|
|
3730
|
-
/* @__PURE__ */ (0,
|
|
3785
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
3731
3786
|
] }),
|
|
3732
|
-
/* @__PURE__ */ (0,
|
|
3733
|
-
/* @__PURE__ */ (0,
|
|
3734
|
-
/* @__PURE__ */ (0,
|
|
3787
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
3788
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
3789
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
3735
3790
|
"Along the stroke"
|
|
3736
3791
|
] }),
|
|
3737
|
-
/* @__PURE__ */ (0,
|
|
3738
|
-
/* @__PURE__ */ (0,
|
|
3792
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
3793
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
3739
3794
|
"Live"
|
|
3740
3795
|
] })
|
|
3741
3796
|
] }),
|
|
3742
|
-
effectPaint.map && /* @__PURE__ */ (0,
|
|
3743
|
-
/* @__PURE__ */ (0,
|
|
3744
|
-
/* @__PURE__ */ (0,
|
|
3745
|
-
/* @__PURE__ */ (0,
|
|
3797
|
+
effectPaint.map && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3798
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3799
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-slate-400", children: "Length" }),
|
|
3800
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3746
3801
|
"input",
|
|
3747
3802
|
{
|
|
3748
3803
|
type: "number",
|
|
@@ -3756,55 +3811,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3756
3811
|
effectPaint.map.length
|
|
3757
3812
|
)
|
|
3758
3813
|
] }),
|
|
3759
|
-
/* @__PURE__ */ (0,
|
|
3760
|
-
/* @__PURE__ */ (0,
|
|
3761
|
-
/* @__PURE__ */ (0,
|
|
3762
|
-
/* @__PURE__ */ (0,
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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: [
|
|
3815
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "repeat", children: "Repeat" }),
|
|
3816
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "mirror", children: "Mirror" }),
|
|
3817
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "clamp", children: "Clamp" })
|
|
3763
3818
|
] })
|
|
3764
3819
|
] }),
|
|
3765
|
-
/* @__PURE__ */ (0,
|
|
3820
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
3766
3821
|
] }),
|
|
3767
|
-
animation && /* @__PURE__ */ (0,
|
|
3768
|
-
/* @__PURE__ */ (0,
|
|
3822
|
+
animation && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
3823
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3769
3824
|
"Live paint: ",
|
|
3770
3825
|
animation.strokes,
|
|
3771
3826
|
" ",
|
|
3772
3827
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
3773
3828
|
] }),
|
|
3774
|
-
/* @__PURE__ */ (0,
|
|
3775
|
-
/* @__PURE__ */ (0,
|
|
3776
|
-
/* @__PURE__ */ (0,
|
|
3777
|
-
/* @__PURE__ */ (0,
|
|
3829
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
3830
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3831
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-slate-400", children: "fps" }),
|
|
3832
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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" })
|
|
3778
3833
|
] })
|
|
3779
3834
|
] }),
|
|
3780
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
3781
|
-
/* @__PURE__ */ (0,
|
|
3782
|
-
/* @__PURE__ */ (0,
|
|
3835
|
+
layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
3836
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3837
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3783
3838
|
"Layer: ",
|
|
3784
3839
|
layerEffect.name ?? layerEffect.effect
|
|
3785
3840
|
] }),
|
|
3786
|
-
/* @__PURE__ */ (0,
|
|
3841
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
3787
3842
|
] }),
|
|
3788
|
-
/* @__PURE__ */ (0,
|
|
3843
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
3789
3844
|
] }),
|
|
3790
|
-
/* @__PURE__ */ (0,
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ErrorLine, { error })
|
|
3791
3846
|
] });
|
|
3792
3847
|
};
|
|
3793
3848
|
|
|
3794
3849
|
// src/paint-editor/PaintEditor.tsx
|
|
3795
|
-
var
|
|
3850
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3796
3851
|
var PAINT_CONTROLS = {
|
|
3797
3852
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
3798
3853
|
lighting: '[data-testid="light-panel"]',
|
|
3799
3854
|
symmetry: '[aria-label="Symmetry"]'
|
|
3800
3855
|
};
|
|
3801
3856
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
3802
|
-
const [tool, setTool] = (0,
|
|
3803
|
-
const [tab, setTab] = (0,
|
|
3804
|
-
const tabRef = (0,
|
|
3857
|
+
const [tool, setTool] = (0, import_react26.useState)("brush");
|
|
3858
|
+
const [tab, setTab] = (0, import_react26.useState)("color");
|
|
3859
|
+
const tabRef = (0, import_react26.useRef)(tab);
|
|
3805
3860
|
tabRef.current = tab;
|
|
3806
|
-
const rootRef = (0,
|
|
3807
|
-
const [ownPresence] = (0,
|
|
3861
|
+
const rootRef = (0, import_react26.useRef)(null);
|
|
3862
|
+
const [ownPresence] = (0, import_react26.useState)(() => new import_paint_editor16.PaintPresence());
|
|
3808
3863
|
const ambientPlayback = useAgentPlayback();
|
|
3809
3864
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
3810
3865
|
const viewBox = () => {
|
|
@@ -3815,12 +3870,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3815
3870
|
const docToClient = (p) => {
|
|
3816
3871
|
const r = viewBox();
|
|
3817
3872
|
if (!r) return null;
|
|
3818
|
-
const q = (0,
|
|
3873
|
+
const q = (0, import_paint_editor16.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
|
|
3819
3874
|
return { x: r.left + q.x, y: r.top + q.y };
|
|
3820
3875
|
};
|
|
3821
3876
|
const clientToDoc = (p) => {
|
|
3822
3877
|
const r = viewBox();
|
|
3823
|
-
return r ? (0,
|
|
3878
|
+
return r ? (0, import_paint_editor16.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
|
|
3824
3879
|
};
|
|
3825
3880
|
const elementRect = (selector) => {
|
|
3826
3881
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -3860,28 +3915,28 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3860
3915
|
const box = rootRef.current?.getBoundingClientRect();
|
|
3861
3916
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
3862
3917
|
};
|
|
3863
|
-
const [error, setError] = (0,
|
|
3918
|
+
const [error, setError] = (0, import_react26.useState)(null);
|
|
3864
3919
|
const effects = usePaintEffectsProvider(controller);
|
|
3865
3920
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
3866
|
-
return /* @__PURE__ */ (0,
|
|
3867
|
-
playing && /* @__PURE__ */ (0,
|
|
3868
|
-
/* @__PURE__ */ (0,
|
|
3869
|
-
/* @__PURE__ */ (0,
|
|
3870
|
-
/* @__PURE__ */ (0,
|
|
3871
|
-
/* @__PURE__ */ (0,
|
|
3872
|
-
/* @__PURE__ */ (0,
|
|
3873
|
-
error && /* @__PURE__ */ (0,
|
|
3921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.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: [
|
|
3922
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
3924
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
3925
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
3926
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
3927
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
3928
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
3874
3929
|
] }),
|
|
3875
|
-
/* @__PURE__ */ (0,
|
|
3876
|
-
/* @__PURE__ */ (0,
|
|
3877
|
-
/* @__PURE__ */ (0,
|
|
3878
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
3879
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
3880
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
3881
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3882
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3883
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3884
|
-
tab === "effects" && effects && /* @__PURE__ */ (0,
|
|
3930
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
3931
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime26.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)) }),
|
|
3932
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
3933
|
+
tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ColorPanel, { controller }),
|
|
3934
|
+
tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(WetPanel, { controller }),
|
|
3935
|
+
tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaperPanel, { controller }),
|
|
3936
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaintLayersPanel, { controller }),
|
|
3937
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(StrokePanel, { controller }),
|
|
3938
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(StickerPanel, { controller }),
|
|
3939
|
+
tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaintEffectsPanel, { controller })
|
|
3885
3940
|
] })
|
|
3886
3941
|
] })
|
|
3887
3942
|
] })
|
|
@@ -3901,6 +3956,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3901
3956
|
PaintToolbar,
|
|
3902
3957
|
PaperPanel,
|
|
3903
3958
|
StickerPanel,
|
|
3959
|
+
StickerPicker,
|
|
3904
3960
|
StrokePanel,
|
|
3905
3961
|
WetPanel,
|
|
3906
3962
|
usePaintDirector,
|