@pixerate/editor-react 0.167.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/{chunk-65EL63YS.js → chunk-2UD3JH4W.js} +1137 -1376
- package/dist/chunk-EP6C5N54.js +406 -0
- package/dist/image-editor/LayerEffectsPanel.d.cts +3 -2
- package/dist/image-editor/LayerEffectsPanel.d.ts +3 -2
- package/dist/image-editor/index.cjs +121 -121
- package/dist/image-editor/index.js +10 -9
- package/dist/index.cjs +121 -121
- package/dist/index.js +10 -9
- package/dist/paint-editor/PaintLayersPanel.d.cts +2 -1
- package/dist/paint-editor/PaintLayersPanel.d.ts +2 -1
- 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 +947 -626
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +464 -373
- package/package.json +3 -3
- package/dist/chunk-AJCWF6SN.js +0 -125
|
@@ -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,120 +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)) })
|
|
860
|
+
] }),
|
|
861
|
+
brush.particle.render === "ribbon" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
862
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Ribbon joins" }),
|
|
863
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Ribbon pairs", value: brush.particle.ribbonPairs, onChange: (e) => controller.setBrush({ particle: { ribbonPairs: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.RIBBON_PAIRS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.RIBBON_PAIR_LABELS[k] }, k)) })
|
|
864
|
+
] }),
|
|
865
|
+
(brush.particle.render === "dot" || brush.particle.render === "sequence") && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": "Dot textures", title: "Stamps drawn instead of round dots (up to 4; none: round)", children: import_paint_editor6.STAMP_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
867
|
+
"button",
|
|
868
|
+
{
|
|
869
|
+
type: "button",
|
|
870
|
+
"aria-pressed": brush.particle.dotTextures.includes(k),
|
|
871
|
+
className: `px-1.5 py-0.5 rounded text-[10px] ${brush.particle.dotTextures.includes(k) ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
872
|
+
onClick: () => controller.setBrush({ particle: { dotTextures: (0, import_paint_editor6.toggleDotTexture)(brush.particle.dotTextures, k) } }),
|
|
873
|
+
children: import_paint_editor6.STAMP_LABELS[k]
|
|
874
|
+
},
|
|
875
|
+
k
|
|
876
|
+
)) }),
|
|
877
|
+
brush.particle.dotTextures.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Texture order" }),
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Dot texture order", value: brush.particle.dotTextureOrder, onChange: (e) => controller.setBrush({ particle: { dotTextureOrder: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.DOT_TEXTURE_ORDERS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.DOT_TEXTURE_ORDER_LABELS[k] }, k)) })
|
|
881
|
+
] }),
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
883
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-slate-400", children: "Texture turn" }),
|
|
884
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { "aria-label": "Dot rotation", value: brush.particle.dotRotation, onChange: (e) => controller.setBrush({ particle: { dotRotation: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor6.DOT_ROTATIONS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: k, children: import_paint_editor6.DOT_ROTATION_LABELS[k] }, k)) })
|
|
885
|
+
] })
|
|
886
|
+
] })
|
|
806
887
|
] })
|
|
807
888
|
] }),
|
|
808
|
-
engine.stickerStamps && /* @__PURE__ */ (0,
|
|
809
|
-
|
|
810
|
-
{
|
|
811
|
-
|
|
812
|
-
"aria-pressed": brush.sticker.stamps.includes(k),
|
|
813
|
-
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"}`,
|
|
814
|
-
onClick: () => controller.setBrush({ sticker: { stamps: (0, import_paint_editor5.toggleStamp)(brush.sticker.stamps, k) } }),
|
|
815
|
-
children: import_paint_editor5.STAMP_LABELS[k]
|
|
816
|
-
},
|
|
817
|
-
k
|
|
818
|
-
)) }),
|
|
819
|
-
engine.impastoTool && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
820
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-slate-400", children: "Tool" }),
|
|
821
|
-
/* @__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)) })
|
|
822
893
|
] }),
|
|
823
|
-
engine.sliders.map((c) => /* @__PURE__ */ (0,
|
|
824
|
-
engine.mixingPath && /* @__PURE__ */ (0,
|
|
825
|
-
/* @__PURE__ */ (0,
|
|
826
|
-
/* @__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)(
|
|
827
898
|
"select",
|
|
828
899
|
{
|
|
829
900
|
"aria-label": "Brush mixing",
|
|
830
901
|
value: engine.mixingPath === "blender.mixing" ? brush.blender.mixing : engine.mixingPath === "smudge.mixing" ? brush.smudge.mixing : brush.behavior.mixing,
|
|
831
|
-
onChange: (e) => controller.setBrush((0,
|
|
902
|
+
onChange: (e) => controller.setBrush((0, import_paint_editor6.patchBrushValue)(brush, engine.mixingPath, e.target.value)),
|
|
832
903
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
833
904
|
children: [
|
|
834
|
-
/* @__PURE__ */ (0,
|
|
835
|
-
/* @__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" })
|
|
836
907
|
]
|
|
837
908
|
}
|
|
838
909
|
)
|
|
839
910
|
] }),
|
|
840
|
-
engine.light && brush.light.amount > 0 && /* @__PURE__ */ (0,
|
|
841
|
-
/* @__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 } }) }),
|
|
842
913
|
" Light follows pressure"
|
|
843
914
|
] }),
|
|
844
|
-
engine.dirty && /* @__PURE__ */ (0,
|
|
845
|
-
/* @__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 } }) }),
|
|
846
917
|
" Dirty brush"
|
|
847
918
|
] }),
|
|
848
|
-
(0,
|
|
849
|
-
/* @__PURE__ */ (0,
|
|
850
|
-
/* @__PURE__ */ (0,
|
|
851
|
-
/* @__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)(
|
|
852
923
|
"button",
|
|
853
924
|
{
|
|
854
925
|
type: "button",
|
|
855
926
|
"aria-pressed": brush.paint !== null,
|
|
856
927
|
className: chip(brush.paint !== null),
|
|
857
|
-
onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null :
|
|
928
|
+
onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : import_paint_editor7.DEFAULT_PAINT_GRADIENT })),
|
|
858
929
|
children: brush.paint ? "On" : "Off"
|
|
859
930
|
}
|
|
860
931
|
)
|
|
861
932
|
] }),
|
|
862
|
-
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 })) })
|
|
863
934
|
] }),
|
|
864
|
-
engine.load && /* @__PURE__ */ (0,
|
|
865
|
-
/* @__PURE__ */ (0,
|
|
866
|
-
/* @__PURE__ */ (0,
|
|
867
|
-
brush.engine === "mixer" && /* @__PURE__ */ (0,
|
|
868
|
-
/* @__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" })
|
|
869
940
|
] })
|
|
870
941
|
] }),
|
|
871
|
-
/* @__PURE__ */ (0,
|
|
872
|
-
/* @__PURE__ */ (0,
|
|
873
|
-
/* @__PURE__ */ (0,
|
|
874
|
-
/* @__PURE__ */ (0,
|
|
875
|
-
/* @__PURE__ */ (0,
|
|
876
|
-
/* @__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)(
|
|
877
948
|
"input",
|
|
878
949
|
{
|
|
879
950
|
ref: fileRef,
|
|
@@ -889,24 +960,24 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
889
960
|
}
|
|
890
961
|
)
|
|
891
962
|
] }),
|
|
892
|
-
/* @__PURE__ */ (0,
|
|
963
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ErrorLine, { error })
|
|
893
964
|
] });
|
|
894
965
|
};
|
|
895
966
|
|
|
896
967
|
// src/paint-editor/PaperPanel.tsx
|
|
897
|
-
var
|
|
898
|
-
var
|
|
899
|
-
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");
|
|
900
971
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
901
972
|
var PaperPanel = ({ controller, className }) => {
|
|
902
973
|
const state = usePaintEditorState(controller);
|
|
903
974
|
const [error, attempt] = useAttempt();
|
|
904
975
|
const paper = state.document.paper;
|
|
905
|
-
const previews = (0,
|
|
906
|
-
return /* @__PURE__ */ (0,
|
|
907
|
-
|
|
908
|
-
/* @__PURE__ */ (0,
|
|
909
|
-
/* @__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)(
|
|
910
981
|
"button",
|
|
911
982
|
{
|
|
912
983
|
type: "button",
|
|
@@ -915,98 +986,98 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
915
986
|
title: p.name,
|
|
916
987
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
917
988
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
918
|
-
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 } })
|
|
919
990
|
},
|
|
920
991
|
p.preset
|
|
921
992
|
)) })
|
|
922
993
|
] }, family)),
|
|
923
|
-
/* @__PURE__ */ (0,
|
|
924
|
-
/* @__PURE__ */ (0,
|
|
925
|
-
/* @__PURE__ */ (0,
|
|
926
|
-
/* @__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" })
|
|
927
998
|
] }),
|
|
928
|
-
|
|
929
|
-
/* @__PURE__ */ (0,
|
|
930
|
-
/* @__PURE__ */ (0,
|
|
931
|
-
/* @__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" })
|
|
932
1003
|
] }),
|
|
933
|
-
/* @__PURE__ */ (0,
|
|
934
|
-
/* @__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" })) }),
|
|
935
1006
|
" Mirror tiling"
|
|
936
1007
|
] }),
|
|
937
|
-
/* @__PURE__ */ (0,
|
|
938
|
-
/* @__PURE__ */ (0,
|
|
939
|
-
/* @__PURE__ */ (0,
|
|
940
|
-
|
|
941
|
-
/* @__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" })
|
|
942
1013
|
] }),
|
|
943
|
-
/* @__PURE__ */ (0,
|
|
1014
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorLine, { error })
|
|
944
1015
|
] });
|
|
945
1016
|
};
|
|
946
1017
|
|
|
947
1018
|
// src/paint-editor/ColorPanel.tsx
|
|
948
|
-
var
|
|
949
|
-
var import_paint_editor8 = require("@pixerate/editor/paint-editor");
|
|
1019
|
+
var import_react9 = require("react");
|
|
950
1020
|
var import_paint_editor9 = require("@pixerate/editor/paint-editor");
|
|
951
|
-
var
|
|
1021
|
+
var import_paint_editor10 = require("@pixerate/editor/paint-editor");
|
|
1022
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
952
1023
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
953
1024
|
const state = usePaintEditorState(controller);
|
|
954
1025
|
const [error, attempt] = useAttempt();
|
|
955
|
-
const [wheel, setWheel] = (0,
|
|
956
|
-
const [kind, setKind] = (0,
|
|
957
|
-
const [padTool, setPadTool] = (0,
|
|
958
|
-
const [sample, setSample] = (0,
|
|
959
|
-
const [parts, setParts] = (0,
|
|
960
|
-
const [padName, setPadName] = (0,
|
|
961
|
-
const padPoints = (0,
|
|
962
|
-
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]);
|
|
963
1034
|
const color = state.color;
|
|
964
|
-
const harmony = (0,
|
|
965
|
-
const [r, g, b] = (0,
|
|
966
|
-
const hsv = (0,
|
|
967
|
-
const effectWell = (0,
|
|
968
|
-
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]);
|
|
969
1040
|
const R = wheelSize / 2;
|
|
970
1041
|
const mid = R * 0.82;
|
|
971
|
-
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)));
|
|
972
1043
|
const padPoint = (e) => {
|
|
973
1044
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
974
|
-
const kx =
|
|
975
|
-
const ky =
|
|
976
|
-
const x = Math.min(
|
|
977
|
-
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));
|
|
978
1049
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
979
1050
|
};
|
|
980
|
-
return /* @__PURE__ */ (0,
|
|
981
|
-
/* @__PURE__ */ (0,
|
|
982
|
-
/* @__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)(
|
|
983
1054
|
"div",
|
|
984
1055
|
{
|
|
985
1056
|
role: "slider",
|
|
986
1057
|
"aria-label": "Hue wheel",
|
|
987
1058
|
"aria-valuemin": 0,
|
|
988
1059
|
"aria-valuemax": 360,
|
|
989
|
-
"aria-valuenow": Math.round((0,
|
|
1060
|
+
"aria-valuenow": Math.round((0, import_paint_editor9.hueToWheel)(hsv.h, wheel)),
|
|
990
1061
|
tabIndex: 0,
|
|
991
1062
|
className: "absolute inset-0 cursor-crosshair",
|
|
992
1063
|
onPointerDown: (e) => {
|
|
993
1064
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
994
|
-
controller.setColor((0,
|
|
1065
|
+
controller.setColor((0, import_paint_editor9.wheelPick)(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
995
1066
|
},
|
|
996
|
-
children: /* @__PURE__ */ (0,
|
|
1067
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
997
1068
|
}
|
|
998
1069
|
),
|
|
999
|
-
/* @__PURE__ */ (0,
|
|
1000
|
-
const p = (0,
|
|
1001
|
-
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);
|
|
1002
1073
|
}) }),
|
|
1003
|
-
/* @__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 } })
|
|
1004
1075
|
] }),
|
|
1005
|
-
/* @__PURE__ */ (0,
|
|
1006
|
-
/* @__PURE__ */ (0,
|
|
1007
|
-
/* @__PURE__ */ (0,
|
|
1008
|
-
/* @__PURE__ */ (0,
|
|
1009
|
-
/* @__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)(
|
|
1010
1081
|
"input",
|
|
1011
1082
|
{
|
|
1012
1083
|
"aria-label": "Hex colour",
|
|
@@ -1017,49 +1088,49 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1017
1088
|
color
|
|
1018
1089
|
)
|
|
1019
1090
|
] }),
|
|
1020
|
-
/* @__PURE__ */ (0,
|
|
1021
|
-
/* @__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)(
|
|
1022
1093
|
"span",
|
|
1023
1094
|
{
|
|
1024
1095
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
1025
1096
|
"aria-label": state.effectPaint ? `Effect paint: ${state.effectPaint.effect}` : state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
|
|
1026
1097
|
"data-testid": "paint-well",
|
|
1027
1098
|
"data-effect-paint": state.effectPaint ? state.effectPaint.effect : void 0,
|
|
1028
|
-
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 }) }
|
|
1029
1100
|
}
|
|
1030
1101
|
),
|
|
1031
|
-
/* @__PURE__ */ (0,
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1032
1103
|
"button",
|
|
1033
1104
|
{
|
|
1034
1105
|
type: "button",
|
|
1035
1106
|
className: chip(state.paint.type === "gradient"),
|
|
1036
1107
|
"aria-pressed": state.paint.type === "gradient",
|
|
1037
1108
|
title: "Paint that changes colour as the stroke goes",
|
|
1038
|
-
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)),
|
|
1039
1110
|
children: "Gradient"
|
|
1040
1111
|
}
|
|
1041
1112
|
)
|
|
1042
1113
|
] }),
|
|
1043
|
-
state.paint.type === "gradient" && /* @__PURE__ */ (0,
|
|
1044
|
-
/* @__PURE__ */ (0,
|
|
1045
|
-
/* @__PURE__ */ (0,
|
|
1046
|
-
/* @__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" })
|
|
1047
1118
|
] }),
|
|
1048
|
-
/* @__PURE__ */ (0,
|
|
1049
|
-
/* @__PURE__ */ (0,
|
|
1050
|
-
/* @__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" })
|
|
1051
1122
|
] }),
|
|
1052
|
-
/* @__PURE__ */ (0,
|
|
1053
|
-
/* @__PURE__ */ (0,
|
|
1054
|
-
/* @__PURE__ */ (0,
|
|
1055
|
-
/* @__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" })
|
|
1056
1127
|
] }),
|
|
1057
|
-
/* @__PURE__ */ (0,
|
|
1058
|
-
harmony.map((h, i) => /* @__PURE__ */ (0,
|
|
1059
|
-
/* @__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" })
|
|
1060
1131
|
] }),
|
|
1061
|
-
/* @__PURE__ */ (0,
|
|
1062
|
-
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)(
|
|
1063
1134
|
"button",
|
|
1064
1135
|
{
|
|
1065
1136
|
type: "button",
|
|
@@ -1068,7 +1139,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1068
1139
|
"aria-label": s.name ?? (s.paint ? "Gradient" : s.color),
|
|
1069
1140
|
title: `${s.name ?? (s.paint ? "Gradient" : s.color)} (right-click to remove)`,
|
|
1070
1141
|
className: "h-5 w-5 rounded ring-1 ring-slate-700",
|
|
1071
|
-
style: { background: s.paint ? (0,
|
|
1142
|
+
style: { background: s.paint ? (0, import_paint_editor10.paintSourceCss)(s.paint, { paint: color, secondary: state.secondaryColor }) : s.color },
|
|
1072
1143
|
onClick: () => attempt(() => s.paint ? controller.setPaint(s.paint) : controller.setColor(s.color)),
|
|
1073
1144
|
onContextMenu: (e) => {
|
|
1074
1145
|
e.preventDefault();
|
|
@@ -1077,15 +1148,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1077
1148
|
},
|
|
1078
1149
|
i
|
|
1079
1150
|
)),
|
|
1080
|
-
/* @__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: "+" })
|
|
1081
1152
|
] }),
|
|
1082
|
-
mixingPad && /* @__PURE__ */ (0,
|
|
1083
|
-
/* @__PURE__ */ (0,
|
|
1084
|
-
/* @__PURE__ */ (0,
|
|
1085
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ (0,
|
|
1086
|
-
/* @__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" })
|
|
1087
1158
|
] }),
|
|
1088
|
-
/* @__PURE__ */ (0,
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1089
1160
|
"div",
|
|
1090
1161
|
{
|
|
1091
1162
|
role: "application",
|
|
@@ -1094,7 +1165,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1094
1165
|
onPointerDown: (e) => {
|
|
1095
1166
|
const p = padPoint(e);
|
|
1096
1167
|
if (padTool === "pick") {
|
|
1097
|
-
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) }));
|
|
1098
1169
|
return;
|
|
1099
1170
|
}
|
|
1100
1171
|
padPoints.current = [p];
|
|
@@ -1106,20 +1177,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1106
1177
|
padPoints.current = null;
|
|
1107
1178
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1108
1179
|
},
|
|
1109
|
-
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}` } })
|
|
1110
1181
|
}
|
|
1111
1182
|
),
|
|
1112
|
-
/* @__PURE__ */ (0,
|
|
1113
|
-
/* @__PURE__ */ (0,
|
|
1114
|
-
/* @__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)) })
|
|
1115
1186
|
] }) }),
|
|
1116
|
-
/* @__PURE__ */ (0,
|
|
1117
|
-
/* @__PURE__ */ (0,
|
|
1118
|
-
/* @__PURE__ */ (0,
|
|
1119
|
-
/* @__PURE__ */ (0,
|
|
1120
|
-
/* @__PURE__ */ (0,
|
|
1121
|
-
/* @__PURE__ */ (0,
|
|
1122
|
-
/* @__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)(
|
|
1123
1194
|
"button",
|
|
1124
1195
|
{
|
|
1125
1196
|
type: "button",
|
|
@@ -1138,23 +1209,260 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1138
1209
|
}
|
|
1139
1210
|
)
|
|
1140
1211
|
] }),
|
|
1141
|
-
/* @__PURE__ */ (0,
|
|
1142
|
-
/* @__PURE__ */ (0,
|
|
1143
|
-
/* @__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" })
|
|
1144
1215
|
] }),
|
|
1145
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */ (0,
|
|
1146
|
-
/* @__PURE__ */ (0,
|
|
1147
|
-
/* @__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" })
|
|
1148
1219
|
] }, p.id)) })
|
|
1149
1220
|
] }),
|
|
1150
|
-
/* @__PURE__ */ (0,
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ErrorLine, { error })
|
|
1151
1222
|
] });
|
|
1152
1223
|
};
|
|
1153
1224
|
|
|
1154
1225
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1155
|
-
var
|
|
1156
|
-
var
|
|
1157
|
-
|
|
1226
|
+
var import_react12 = require("react");
|
|
1227
|
+
var import_paint_editor11 = require("@pixerate/editor/paint-editor");
|
|
1228
|
+
|
|
1229
|
+
// src/image-editor/LayerEffectsPanel.tsx
|
|
1230
|
+
var import_react11 = require("react");
|
|
1231
|
+
var import_raster = require("@pixerate/editor/raster");
|
|
1232
|
+
|
|
1233
|
+
// src/image-editor/styles.ts
|
|
1234
|
+
var imageIconButtonClass = "px-1.5 py-0.5 rounded text-[10px] bg-muted text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
|
|
1235
|
+
var imageSelectClass = "rounded border border-input bg-background px-1.5 py-1 text-foreground";
|
|
1236
|
+
var imageColorInputClass = "h-6 w-8 rounded border border-border bg-transparent";
|
|
1237
|
+
|
|
1238
|
+
// src/image-editor/controls/controls.tsx
|
|
1239
|
+
var import_react10 = require("react");
|
|
1240
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1241
|
+
var ControlsContext = (0, import_react10.createContext)({});
|
|
1242
|
+
function useImageEditorControls() {
|
|
1243
|
+
return (0, import_react10.useContext)(ControlsContext);
|
|
1244
|
+
}
|
|
1245
|
+
function ImageCheckbox(props) {
|
|
1246
|
+
const Host = useImageEditorControls().Checkbox;
|
|
1247
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1248
|
+
const { checked, label, disabled, onChange, className = "" } = props;
|
|
1249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1250
|
+
"input",
|
|
1251
|
+
{
|
|
1252
|
+
type: "checkbox",
|
|
1253
|
+
"aria-label": label,
|
|
1254
|
+
checked,
|
|
1255
|
+
disabled,
|
|
1256
|
+
onChange: (e) => onChange(e.target.checked),
|
|
1257
|
+
className: `accent-primary ${className}`
|
|
1258
|
+
}
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
function ImageRange(props) {
|
|
1262
|
+
const Host = useImageEditorControls().Range;
|
|
1263
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1264
|
+
const { value, min, max, step, label, disabled, onChange, onStart, onEnd, className = "" } = props;
|
|
1265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1266
|
+
"input",
|
|
1267
|
+
{
|
|
1268
|
+
type: "range",
|
|
1269
|
+
"aria-label": label,
|
|
1270
|
+
min,
|
|
1271
|
+
max,
|
|
1272
|
+
step,
|
|
1273
|
+
value,
|
|
1274
|
+
disabled,
|
|
1275
|
+
onPointerDown: () => onStart?.(),
|
|
1276
|
+
onPointerUp: () => onEnd?.(),
|
|
1277
|
+
onKeyDown: () => onStart?.(),
|
|
1278
|
+
onKeyUp: () => onEnd?.(),
|
|
1279
|
+
onChange: (e) => onChange(Number(e.target.value)),
|
|
1280
|
+
className: `w-full accent-primary disabled:opacity-40 ${className}`
|
|
1281
|
+
}
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
function ImageSelect(props) {
|
|
1285
|
+
const Host = useImageEditorControls().Select;
|
|
1286
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1287
|
+
const { value, options, label, placeholder, disabled, onChange, className = "" } = props;
|
|
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))
|
|
1291
|
+
] });
|
|
1292
|
+
}
|
|
1293
|
+
function ImageColor(props) {
|
|
1294
|
+
const Host = useImageEditorControls().Color;
|
|
1295
|
+
if (Host) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Host, { ...props });
|
|
1296
|
+
const { value, label, alpha, disabled, onChange, className = "" } = props;
|
|
1297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1298
|
+
"input",
|
|
1299
|
+
{
|
|
1300
|
+
type: "color",
|
|
1301
|
+
"aria-label": label,
|
|
1302
|
+
value: value.slice(0, 7),
|
|
1303
|
+
disabled,
|
|
1304
|
+
onChange: (e) => onChange(e.target.value + (alpha ? value.slice(7, 9) : "")),
|
|
1305
|
+
className: `${imageColorInputClass} ${className}`
|
|
1306
|
+
}
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/image-editor/LayerEffectsPanel.tsx
|
|
1311
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1312
|
+
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
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);
|
|
1318
|
+
const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
|
|
1319
|
+
const model = (0, import_raster.layerEffectsPanel)(layer);
|
|
1320
|
+
const id = layer?.id;
|
|
1321
|
+
const attempt = (fn) => {
|
|
1322
|
+
try {
|
|
1323
|
+
setError(null);
|
|
1324
|
+
fn();
|
|
1325
|
+
} catch (err) {
|
|
1326
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
if (!model.available || !id) {
|
|
1330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `text-xs text-muted-foreground ${className ?? ""}`, "data-testid": "layer-effects", children: model.reason });
|
|
1331
|
+
}
|
|
1332
|
+
const effects = controller.getLayerEffects(id);
|
|
1333
|
+
const patterns = controller.getDocumentPatterns();
|
|
1334
|
+
const change = (effectId, control, value, drag = false) => attempt(() => {
|
|
1335
|
+
const effect = controller.getLayerEffects(id).items.find((e) => e.id === effectId);
|
|
1336
|
+
controller.updateLayerEffect(id, effectId, (0, import_raster.effectControlChange)(effect, control.key, value, patterns), drag ? commitNext.current : true);
|
|
1337
|
+
if (drag) commitNext.current = false;
|
|
1338
|
+
});
|
|
1339
|
+
const renderControl = (effectId, c) => {
|
|
1340
|
+
const label = `${c.label}`;
|
|
1341
|
+
switch (c.type) {
|
|
1342
|
+
case "range": {
|
|
1343
|
+
const k = c.percent ? 100 : 1;
|
|
1344
|
+
const shown = Math.round(c.value * k * 100) / 100;
|
|
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: [
|
|
1347
|
+
label,
|
|
1348
|
+
" ",
|
|
1349
|
+
shown,
|
|
1350
|
+
c.unit
|
|
1351
|
+
] }),
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1353
|
+
ImageRange,
|
|
1354
|
+
{
|
|
1355
|
+
label,
|
|
1356
|
+
min: c.min * k,
|
|
1357
|
+
max: c.max * k,
|
|
1358
|
+
step: c.step * k,
|
|
1359
|
+
value: shown,
|
|
1360
|
+
disabled: model.readOnly,
|
|
1361
|
+
onStart: () => commitNext.current = true,
|
|
1362
|
+
onEnd: () => commitNext.current = true,
|
|
1363
|
+
onChange: (v) => change(effectId, c, v / k, true)
|
|
1364
|
+
}
|
|
1365
|
+
)
|
|
1366
|
+
] }, c.key);
|
|
1367
|
+
}
|
|
1368
|
+
case "color":
|
|
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) }),
|
|
1371
|
+
label
|
|
1372
|
+
] }, c.key);
|
|
1373
|
+
case "checkbox":
|
|
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) }),
|
|
1376
|
+
label
|
|
1377
|
+
] }, c.key);
|
|
1378
|
+
case "select":
|
|
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)(
|
|
1382
|
+
ImageSelect,
|
|
1383
|
+
{
|
|
1384
|
+
label,
|
|
1385
|
+
value: String(c.value),
|
|
1386
|
+
disabled: model.readOnly,
|
|
1387
|
+
options: c.options.map((o) => ({ value: String(o.value), label: o.label })),
|
|
1388
|
+
onChange: (v) => change(effectId, c, v)
|
|
1389
|
+
}
|
|
1390
|
+
)
|
|
1391
|
+
] }, c.key);
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
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)) }),
|
|
1399
|
+
"On"
|
|
1400
|
+
] }),
|
|
1401
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
1402
|
+
"Scale",
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1404
|
+
"input",
|
|
1405
|
+
{
|
|
1406
|
+
type: "number",
|
|
1407
|
+
"aria-label": "Scale effects",
|
|
1408
|
+
min: 1,
|
|
1409
|
+
max: 1e3,
|
|
1410
|
+
step: 1,
|
|
1411
|
+
value: Math.round(model.scale * 100),
|
|
1412
|
+
disabled: model.readOnly,
|
|
1413
|
+
onChange: (e) => {
|
|
1414
|
+
const v = Number(e.target.value);
|
|
1415
|
+
if (v >= 1 && v <= 1e3) attempt(() => controller.setLayerEffectsEnabled(id, model.enabled, v / 100));
|
|
1416
|
+
},
|
|
1417
|
+
className: "w-14 bg-muted border border-border rounded px-1"
|
|
1418
|
+
}
|
|
1419
|
+
),
|
|
1420
|
+
"%"
|
|
1421
|
+
] }),
|
|
1422
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1423
|
+
ImageSelect,
|
|
1424
|
+
{
|
|
1425
|
+
label: "Add style",
|
|
1426
|
+
value: "",
|
|
1427
|
+
placeholder: "Add style\u2026",
|
|
1428
|
+
disabled: model.readOnly,
|
|
1429
|
+
options: import_raster.LAYER_EFFECT_MENU.map((m) => ({ value: m.kind, label: m.label })),
|
|
1430
|
+
onChange: (v) => {
|
|
1431
|
+
const kind = v;
|
|
1432
|
+
if (!kind) return;
|
|
1433
|
+
attempt(() => setOpen(controller.addLayerEffect(id, kind).effect.id));
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
)
|
|
1437
|
+
] }),
|
|
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) => {
|
|
1440
|
+
const effect = effects.items.find((e) => e.id === row.id);
|
|
1441
|
+
const expanded = open === row.id;
|
|
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)(
|
|
1446
|
+
"button",
|
|
1447
|
+
{
|
|
1448
|
+
type: "button",
|
|
1449
|
+
"aria-expanded": expanded,
|
|
1450
|
+
className: `flex-1 text-left ${row.enabled && model.enabled ? "" : "text-muted-foreground"}`,
|
|
1451
|
+
onClick: () => setOpen(expanded ? null : row.id),
|
|
1452
|
+
children: row.label
|
|
1453
|
+
}
|
|
1454
|
+
),
|
|
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" })
|
|
1456
|
+
] }),
|
|
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)) })
|
|
1458
|
+
] }, row.id);
|
|
1459
|
+
}) }),
|
|
1460
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
1461
|
+
] });
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
// src/paint-editor/PaintLayersPanel.tsx
|
|
1465
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1158
1466
|
function siblingIndex(layers, l) {
|
|
1159
1467
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1160
1468
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1162,7 +1470,7 @@ function siblingIndex(layers, l) {
|
|
|
1162
1470
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1163
1471
|
usePaintEditorState(controller);
|
|
1164
1472
|
const [error, attempt] = useAttempt();
|
|
1165
|
-
const [renaming, setRenaming] = (0,
|
|
1473
|
+
const [renaming, setRenaming] = (0, import_react12.useState)(null);
|
|
1166
1474
|
const layers = controller.listLayers();
|
|
1167
1475
|
const active = layers.find((l) => l.active) ?? null;
|
|
1168
1476
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1172,18 +1480,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1172
1480
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1173
1481
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1174
1482
|
};
|
|
1175
|
-
return /* @__PURE__ */ (0,
|
|
1176
|
-
/* @__PURE__ */ (0,
|
|
1177
|
-
/* @__PURE__ */ (0,
|
|
1178
|
-
/* @__PURE__ */ (0,
|
|
1179
|
-
/* @__PURE__ */ (0,
|
|
1180
|
-
/* @__PURE__ */ (0,
|
|
1181
|
-
/* @__PURE__ */ (0,
|
|
1182
|
-
/* @__PURE__ */ (0,
|
|
1183
|
-
/* @__PURE__ */ (0,
|
|
1184
|
-
/* @__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" })
|
|
1185
1493
|
] }),
|
|
1186
|
-
/* @__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)(
|
|
1187
1495
|
"li",
|
|
1188
1496
|
{
|
|
1189
1497
|
role: "treeitem",
|
|
@@ -1192,7 +1500,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1192
1500
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1193
1501
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1194
1502
|
children: [
|
|
1195
|
-
/* @__PURE__ */ (0,
|
|
1503
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1196
1504
|
"button",
|
|
1197
1505
|
{
|
|
1198
1506
|
type: "button",
|
|
@@ -1205,7 +1513,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1205
1513
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1206
1514
|
}
|
|
1207
1515
|
),
|
|
1208
|
-
renaming === l.id ? /* @__PURE__ */ (0,
|
|
1516
|
+
renaming === l.id ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1209
1517
|
"input",
|
|
1210
1518
|
{
|
|
1211
1519
|
autoFocus: true,
|
|
@@ -1222,23 +1530,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1222
1530
|
if (e.key === "Escape") setRenaming(null);
|
|
1223
1531
|
}
|
|
1224
1532
|
}
|
|
1225
|
-
) : /* @__PURE__ */ (0,
|
|
1533
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1226
1534
|
l.type === "group" ? "\u25B8 " : "",
|
|
1227
|
-
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: [
|
|
1228
1536
|
"\u270E",
|
|
1229
1537
|
" "
|
|
1230
1538
|
] }),
|
|
1231
1539
|
l.name
|
|
1232
1540
|
] }),
|
|
1233
|
-
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
|
|
1234
1542
|
]
|
|
1235
1543
|
},
|
|
1236
1544
|
l.id
|
|
1237
1545
|
)) }),
|
|
1238
|
-
active && /* @__PURE__ */ (0,
|
|
1239
|
-
/* @__PURE__ */ (0,
|
|
1240
|
-
/* @__PURE__ */ (0,
|
|
1241
|
-
/* @__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)(
|
|
1242
1550
|
"input",
|
|
1243
1551
|
{
|
|
1244
1552
|
type: "range",
|
|
@@ -1252,39 +1560,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1252
1560
|
}
|
|
1253
1561
|
)
|
|
1254
1562
|
] }),
|
|
1255
|
-
/* @__PURE__ */ (0,
|
|
1256
|
-
/* @__PURE__ */ (0,
|
|
1257
|
-
/* @__PURE__ */ (0,
|
|
1258
|
-
active.type === "group" && /* @__PURE__ */ (0,
|
|
1259
|
-
|
|
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))
|
|
1260
1568
|
] })
|
|
1261
1569
|
] }),
|
|
1262
|
-
/* @__PURE__ */ (0,
|
|
1263
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */ (0,
|
|
1264
|
-
/* @__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" })
|
|
1265
1573
|
] }),
|
|
1266
|
-
light?.hasLight && /* @__PURE__ */ (0,
|
|
1267
|
-
/* @__PURE__ */ (0,
|
|
1268
|
-
/* @__PURE__ */ (0,
|
|
1269
|
-
/* @__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" })
|
|
1270
1578
|
] }),
|
|
1271
|
-
/* @__PURE__ */ (0,
|
|
1272
|
-
/* @__PURE__ */ (0,
|
|
1273
|
-
/* @__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" })
|
|
1274
1582
|
] }),
|
|
1275
|
-
/* @__PURE__ */ (0,
|
|
1276
|
-
/* @__PURE__ */ (0,
|
|
1277
|
-
/* @__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" })
|
|
1278
1586
|
] })
|
|
1279
|
-
] })
|
|
1587
|
+
] }),
|
|
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 }) })
|
|
1280
1589
|
] }),
|
|
1281
|
-
/* @__PURE__ */ (0,
|
|
1590
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorLine, { error })
|
|
1282
1591
|
] });
|
|
1283
1592
|
};
|
|
1284
1593
|
|
|
1285
1594
|
// src/paint-editor/WetPanel.tsx
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1595
|
+
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
1596
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1288
1597
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1289
1598
|
var WetPanel = ({ controller, className }) => {
|
|
1290
1599
|
const state = usePaintEditorState(controller);
|
|
@@ -1293,31 +1602,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1293
1602
|
const layerId = state.document.activeLayerId;
|
|
1294
1603
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1295
1604
|
const backend = controller.wetState();
|
|
1296
|
-
return /* @__PURE__ */ (0,
|
|
1297
|
-
/* @__PURE__ */ (0,
|
|
1298
|
-
/* @__PURE__ */ (0,
|
|
1299
|
-
/* @__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: [
|
|
1300
1609
|
"step ",
|
|
1301
1610
|
wet.clock
|
|
1302
1611
|
] })
|
|
1303
1612
|
] }),
|
|
1304
|
-
/* @__PURE__ */ (0,
|
|
1305
|
-
/* @__PURE__ */ (0,
|
|
1306
|
-
/* @__PURE__ */ (0,
|
|
1307
|
-
/* @__PURE__ */ (0,
|
|
1308
|
-
/* @__PURE__ */ (0,
|
|
1309
|
-
/* @__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" })
|
|
1310
1619
|
] }),
|
|
1311
|
-
/* @__PURE__ */ (0,
|
|
1312
|
-
|
|
1313
|
-
info && /* @__PURE__ */ (0,
|
|
1314
|
-
/* @__PURE__ */ (0,
|
|
1315
|
-
|
|
1316
|
-
/* @__PURE__ */ (0,
|
|
1317
|
-
/* @__PURE__ */ (0,
|
|
1318
|
-
/* @__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)) })
|
|
1319
1628
|
] }),
|
|
1320
|
-
info.flow.kind !== "none" && /* @__PURE__ */ (0,
|
|
1629
|
+
info.flow.kind !== "none" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1321
1630
|
PaintSlider,
|
|
1322
1631
|
{
|
|
1323
1632
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1326,20 +1635,20 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1326
1635
|
}
|
|
1327
1636
|
)
|
|
1328
1637
|
] }),
|
|
1329
|
-
backend.message && /* @__PURE__ */ (0,
|
|
1330
|
-
backend.backend && /* @__PURE__ */ (0,
|
|
1331
|
-
/* @__PURE__ */ (0,
|
|
1332
|
-
/* @__PURE__ */ (0,
|
|
1333
|
-
/* @__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)) })
|
|
1334
1643
|
] }),
|
|
1335
|
-
/* @__PURE__ */ (0,
|
|
1336
|
-
/* @__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 })
|
|
1337
1646
|
] });
|
|
1338
1647
|
};
|
|
1339
1648
|
|
|
1340
1649
|
// src/paint-editor/StickerPanel.tsx
|
|
1341
|
-
var
|
|
1342
|
-
var
|
|
1650
|
+
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
1651
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1343
1652
|
var StickerPanel = ({ controller, className }) => {
|
|
1344
1653
|
const state = usePaintEditorState(controller);
|
|
1345
1654
|
const [error, attempt] = useAttempt();
|
|
@@ -1349,21 +1658,32 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1349
1658
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1350
1659
|
if (!stickers.length) return null;
|
|
1351
1660
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1352
|
-
return /* @__PURE__ */ (0,
|
|
1353
|
-
/* @__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: [
|
|
1354
1663
|
"Stickers (",
|
|
1355
1664
|
stickers.length,
|
|
1356
1665
|
")"
|
|
1357
1666
|
] }),
|
|
1358
|
-
/* @__PURE__ */ (0,
|
|
1359
|
-
sel && /* @__PURE__ */ (0,
|
|
1360
|
-
/* @__PURE__ */ (0,
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
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)(
|
|
1367
1687
|
"input",
|
|
1368
1688
|
{
|
|
1369
1689
|
type: "number",
|
|
@@ -1377,24 +1697,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1377
1697
|
`${sel.id}-${k}-${sel[k]}`
|
|
1378
1698
|
)) })
|
|
1379
1699
|
] }),
|
|
1380
|
-
|
|
1381
|
-
/* @__PURE__ */ (0,
|
|
1382
|
-
/* @__PURE__ */ (0,
|
|
1383
|
-
/* @__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" })
|
|
1384
1704
|
] }),
|
|
1385
|
-
/* @__PURE__ */ (0,
|
|
1386
|
-
/* @__PURE__ */ (0,
|
|
1387
|
-
/* @__PURE__ */ (0,
|
|
1388
|
-
/* @__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" })
|
|
1389
1709
|
] })
|
|
1390
1710
|
] }),
|
|
1391
|
-
/* @__PURE__ */ (0,
|
|
1711
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ErrorLine, { error })
|
|
1392
1712
|
] });
|
|
1393
1713
|
};
|
|
1394
1714
|
|
|
1395
1715
|
// src/paint-editor/StrokePanel.tsx
|
|
1396
|
-
var
|
|
1397
|
-
var
|
|
1716
|
+
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
1717
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1398
1718
|
var StrokePanel = ({ controller, className }) => {
|
|
1399
1719
|
const state = usePaintEditorState(controller);
|
|
1400
1720
|
const [error, attempt] = useAttempt();
|
|
@@ -1403,17 +1723,17 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1403
1723
|
if (!layerId || !strokes) return null;
|
|
1404
1724
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1405
1725
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1406
|
-
const brushes = state.brushes.filter((b) => !(0,
|
|
1407
|
-
return /* @__PURE__ */ (0,
|
|
1408
|
-
/* @__PURE__ */ (0,
|
|
1409
|
-
/* @__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: [
|
|
1410
1730
|
"Strokes (",
|
|
1411
1731
|
strokes.length,
|
|
1412
1732
|
")"
|
|
1413
1733
|
] }),
|
|
1414
|
-
/* @__PURE__ */ (0,
|
|
1734
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1415
1735
|
] }),
|
|
1416
|
-
/* @__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)(
|
|
1417
1737
|
"button",
|
|
1418
1738
|
{
|
|
1419
1739
|
type: "button",
|
|
@@ -1426,10 +1746,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1426
1746
|
},
|
|
1427
1747
|
s.id
|
|
1428
1748
|
)) }),
|
|
1429
|
-
sel && /* @__PURE__ */ (0,
|
|
1430
|
-
/* @__PURE__ */ (0,
|
|
1431
|
-
/* @__PURE__ */ (0,
|
|
1432
|
-
/* @__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)(
|
|
1433
1753
|
"select",
|
|
1434
1754
|
{
|
|
1435
1755
|
"aria-label": "Stroke brush",
|
|
@@ -1437,51 +1757,51 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1437
1757
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1438
1758
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1439
1759
|
children: [
|
|
1440
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0,
|
|
1441
|
-
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))
|
|
1442
1762
|
]
|
|
1443
1763
|
}
|
|
1444
1764
|
)
|
|
1445
1765
|
] }),
|
|
1446
|
-
|
|
1447
|
-
/* @__PURE__ */ (0,
|
|
1448
|
-
/* @__PURE__ */ (0,
|
|
1449
|
-
/* @__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" })
|
|
1450
1770
|
] }),
|
|
1451
|
-
/* @__PURE__ */ (0,
|
|
1452
|
-
/* @__PURE__ */ (0,
|
|
1453
|
-
/* @__PURE__ */ (0,
|
|
1454
|
-
/* @__PURE__ */ (0,
|
|
1455
|
-
/* @__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" })
|
|
1456
1776
|
] })
|
|
1457
1777
|
] }),
|
|
1458
|
-
/* @__PURE__ */ (0,
|
|
1778
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ErrorLine, { error })
|
|
1459
1779
|
] });
|
|
1460
1780
|
};
|
|
1461
1781
|
|
|
1462
1782
|
// src/paint-editor/PaintEditor.tsx
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1783
|
+
var import_react26 = require("react");
|
|
1784
|
+
var import_paint_editor16 = require("@pixerate/editor/paint-editor");
|
|
1465
1785
|
|
|
1466
1786
|
// src/playback/AgentPlaybackContext.tsx
|
|
1467
|
-
var
|
|
1468
|
-
var
|
|
1469
|
-
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);
|
|
1470
1790
|
function useAgentPlayback() {
|
|
1471
|
-
return (0,
|
|
1791
|
+
return (0, import_react13.useContext)(AgentPlaybackContext);
|
|
1472
1792
|
}
|
|
1473
1793
|
|
|
1474
1794
|
// src/playback/usePlaybackSurface.ts
|
|
1475
|
-
var
|
|
1795
|
+
var import_react14 = require("react");
|
|
1476
1796
|
var import_tools = require("@pixerate/editor/tools");
|
|
1477
1797
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
1478
1798
|
const ambient = useAgentPlayback();
|
|
1479
1799
|
const target = playback === void 0 ? ambient : playback;
|
|
1480
|
-
const [ownPresence] = (0,
|
|
1800
|
+
const [ownPresence] = (0, import_react14.useState)(() => new import_tools.PresenceStore());
|
|
1481
1801
|
const presence = sharedPresence ?? ownPresence;
|
|
1482
|
-
const latest = (0,
|
|
1802
|
+
const latest = (0, import_react14.useRef)(options);
|
|
1483
1803
|
latest.current = options;
|
|
1484
|
-
(0,
|
|
1804
|
+
(0, import_react14.useEffect)(() => {
|
|
1485
1805
|
if (!target || !id) return;
|
|
1486
1806
|
const o = () => latest.current;
|
|
1487
1807
|
const surface = {
|
|
@@ -1513,13 +1833,13 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
1513
1833
|
}
|
|
1514
1834
|
|
|
1515
1835
|
// src/playback/PresenceLayer.tsx
|
|
1516
|
-
var
|
|
1517
|
-
var
|
|
1836
|
+
var import_react15 = __toESM(require("react"), 1);
|
|
1837
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1518
1838
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
1519
|
-
const { actors } = (0,
|
|
1839
|
+
const { actors } = (0, import_react15.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
1520
1840
|
if (!actors.length) return null;
|
|
1521
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;
|
|
1522
|
-
return /* @__PURE__ */ (0,
|
|
1842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1523
1843
|
"div",
|
|
1524
1844
|
{
|
|
1525
1845
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -1533,19 +1853,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1533
1853
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
1534
1854
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
1535
1855
|
})();
|
|
1536
|
-
return /* @__PURE__ */ (0,
|
|
1537
|
-
ring && /* @__PURE__ */ (0,
|
|
1856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react15.default.Fragment, { children: [
|
|
1857
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1538
1858
|
"div",
|
|
1539
1859
|
{
|
|
1540
1860
|
"data-actor-focus": a.id,
|
|
1541
1861
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
1542
1862
|
}
|
|
1543
1863
|
),
|
|
1544
|
-
/* @__PURE__ */ (0,
|
|
1545
|
-
/* @__PURE__ */ (0,
|
|
1546
|
-
/* @__PURE__ */ (0,
|
|
1547
|
-
/* @__PURE__ */ (0,
|
|
1548
|
-
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 })
|
|
1549
1869
|
] })
|
|
1550
1870
|
] }) })
|
|
1551
1871
|
] }, a.id);
|
|
@@ -1555,15 +1875,15 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1555
1875
|
}
|
|
1556
1876
|
|
|
1557
1877
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1558
|
-
var
|
|
1559
|
-
var
|
|
1878
|
+
var import_react25 = require("react");
|
|
1879
|
+
var import_paint_editor15 = require("@pixerate/editor/paint-editor");
|
|
1560
1880
|
|
|
1561
1881
|
// src/effects/useEffects.ts
|
|
1562
|
-
var
|
|
1882
|
+
var import_react16 = require("react");
|
|
1563
1883
|
function useEffectDescription(provider, effect) {
|
|
1564
|
-
const [state, setState] = (0,
|
|
1884
|
+
const [state, setState] = (0, import_react16.useState)({ key: "", description: null, error: null });
|
|
1565
1885
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1566
|
-
(0,
|
|
1886
|
+
(0, import_react16.useEffect)(() => {
|
|
1567
1887
|
if (!provider || !effect) return;
|
|
1568
1888
|
let live = true;
|
|
1569
1889
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1578,14 +1898,14 @@ function useEffectDescription(provider, effect) {
|
|
|
1578
1898
|
}
|
|
1579
1899
|
|
|
1580
1900
|
// src/effects/EffectThumbnail.tsx
|
|
1581
|
-
var
|
|
1901
|
+
var import_react17 = require("react");
|
|
1582
1902
|
var import_effects = require("@pixerate/editor/effects");
|
|
1583
|
-
var
|
|
1903
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1584
1904
|
var LABELS = { motion: "Motion", camera: "Camera" };
|
|
1585
1905
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1586
|
-
const ref = (0,
|
|
1587
|
-
const [failed, setFailed] = (0,
|
|
1588
|
-
(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)(() => {
|
|
1589
1909
|
if (effect.kind in LABELS) return;
|
|
1590
1910
|
let live = true;
|
|
1591
1911
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1600,28 +1920,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1600
1920
|
live = false;
|
|
1601
1921
|
};
|
|
1602
1922
|
}, [provider, effect, width, height]);
|
|
1603
|
-
return /* @__PURE__ */ (0,
|
|
1923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1604
1924
|
"div",
|
|
1605
1925
|
{
|
|
1606
1926
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1607
1927
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1608
1928
|
"data-effect-thumbnail": effect.id,
|
|
1609
|
-
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" })
|
|
1610
1930
|
}
|
|
1611
1931
|
);
|
|
1612
1932
|
}
|
|
1613
1933
|
|
|
1614
1934
|
// src/effects/EffectsBrowser.tsx
|
|
1615
|
-
var
|
|
1935
|
+
var import_react18 = require("react");
|
|
1616
1936
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1617
|
-
var
|
|
1937
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1618
1938
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1619
|
-
const [all, setAll] = (0,
|
|
1620
|
-
const [query, setQuery] = (0,
|
|
1621
|
-
const [category, setCategory] = (0,
|
|
1622
|
-
const [use, setUse] = (0,
|
|
1623
|
-
const [error, setError] = (0,
|
|
1624
|
-
(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)(() => {
|
|
1625
1945
|
if (!provider) return setAll([]);
|
|
1626
1946
|
let live = true;
|
|
1627
1947
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1632,8 +1952,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1632
1952
|
live = false;
|
|
1633
1953
|
};
|
|
1634
1954
|
}, [provider]);
|
|
1635
|
-
const [found, setFound] = (0,
|
|
1636
|
-
(0,
|
|
1955
|
+
const [found, setFound] = (0, import_react18.useState)([]);
|
|
1956
|
+
(0, import_react18.useEffect)(() => {
|
|
1637
1957
|
if (!provider) return setFound([]);
|
|
1638
1958
|
let live = true;
|
|
1639
1959
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1642,14 +1962,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1642
1962
|
};
|
|
1643
1963
|
}, [provider, query, category, use]);
|
|
1644
1964
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
1645
|
-
const categories = (0,
|
|
1965
|
+
const categories = (0, import_react18.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1646
1966
|
const shown = found.filter(allowed);
|
|
1647
1967
|
if (!provider)
|
|
1648
|
-
return /* @__PURE__ */ (0,
|
|
1649
|
-
return /* @__PURE__ */ (0,
|
|
1650
|
-
title && /* @__PURE__ */ (0,
|
|
1651
|
-
/* @__PURE__ */ (0,
|
|
1652
|
-
/* @__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)(
|
|
1653
1973
|
"input",
|
|
1654
1974
|
{
|
|
1655
1975
|
type: "search",
|
|
@@ -1660,17 +1980,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1660
1980
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1661
1981
|
}
|
|
1662
1982
|
),
|
|
1663
|
-
/* @__PURE__ */ (0,
|
|
1664
|
-
/* @__PURE__ */ (0,
|
|
1665
|
-
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))
|
|
1666
1986
|
] }),
|
|
1667
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1668
|
-
/* @__PURE__ */ (0,
|
|
1669
|
-
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))
|
|
1670
1990
|
] })
|
|
1671
1991
|
] }),
|
|
1672
|
-
error && /* @__PURE__ */ (0,
|
|
1673
|
-
/* @__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)(
|
|
1674
1994
|
"button",
|
|
1675
1995
|
{
|
|
1676
1996
|
type: "button",
|
|
@@ -1679,23 +1999,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1679
1999
|
"data-effect-id": e.id,
|
|
1680
2000
|
onClick: () => onPick(e),
|
|
1681
2001
|
children: [
|
|
1682
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1683
|
-
/* @__PURE__ */ (0,
|
|
1684
|
-
/* @__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 ") })
|
|
1685
2005
|
]
|
|
1686
2006
|
}
|
|
1687
2007
|
) }, e.id)) }),
|
|
1688
|
-
!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." })
|
|
1689
2009
|
] });
|
|
1690
2010
|
}
|
|
1691
2011
|
|
|
1692
2012
|
// src/effects/EffectParameters.tsx
|
|
1693
|
-
var
|
|
2013
|
+
var import_react24 = __toESM(require("react"), 1);
|
|
1694
2014
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1695
2015
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1696
2016
|
|
|
1697
2017
|
// src/parameters/fields.tsx
|
|
1698
|
-
var
|
|
2018
|
+
var import_react23 = require("react");
|
|
1699
2019
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1700
2020
|
|
|
1701
2021
|
// src/color/index.ts
|
|
@@ -1708,9 +2028,9 @@ __export(color_exports, {
|
|
|
1708
2028
|
});
|
|
1709
2029
|
|
|
1710
2030
|
// src/color/ColorPicker.tsx
|
|
1711
|
-
var
|
|
2031
|
+
var import_react19 = require("react");
|
|
1712
2032
|
var import_color = require("@pixerate/editor/color");
|
|
1713
|
-
var
|
|
2033
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1714
2034
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
1715
2035
|
function readLocalRecents() {
|
|
1716
2036
|
try {
|
|
@@ -1748,24 +2068,24 @@ var ColorPicker = ({
|
|
|
1748
2068
|
id,
|
|
1749
2069
|
"aria-label": ariaLabel = "Color picker"
|
|
1750
2070
|
}) => {
|
|
1751
|
-
const generatedId = (0,
|
|
2071
|
+
const generatedId = (0, import_react19.useId)();
|
|
1752
2072
|
const pickerId = id || generatedId;
|
|
1753
|
-
const [pickerState, setPickerState] = (0,
|
|
2073
|
+
const [pickerState, setPickerState] = (0, import_react19.useState)(
|
|
1754
2074
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
1755
2075
|
);
|
|
1756
|
-
const stateRef = (0,
|
|
2076
|
+
const stateRef = (0, import_react19.useRef)(pickerState);
|
|
1757
2077
|
stateRef.current = pickerState;
|
|
1758
|
-
(0,
|
|
2078
|
+
(0, import_react19.useEffect)(() => {
|
|
1759
2079
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
1760
2080
|
if (next) {
|
|
1761
2081
|
setPickerState(next);
|
|
1762
2082
|
}
|
|
1763
2083
|
}, [value]);
|
|
1764
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
2084
|
+
const [internalRecent, setInternalRecent] = (0, import_react19.useState)(
|
|
1765
2085
|
() => controlledRecent ? [] : readLocalRecents()
|
|
1766
2086
|
);
|
|
1767
2087
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
1768
|
-
const recordRecent = (0,
|
|
2088
|
+
const recordRecent = (0, import_react19.useCallback)(
|
|
1769
2089
|
(color) => {
|
|
1770
2090
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
1771
2091
|
if (!controlledRecent) {
|
|
@@ -1776,11 +2096,11 @@ var ColorPicker = ({
|
|
|
1776
2096
|
},
|
|
1777
2097
|
[activeRecent, controlledRecent, onRecentChange]
|
|
1778
2098
|
);
|
|
1779
|
-
const [textDraft, setTextDraft] = (0,
|
|
1780
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
1781
|
-
const [isClipped, setIsClipped] = (0,
|
|
1782
|
-
const isTypingRef = (0,
|
|
1783
|
-
(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)(() => {
|
|
1784
2104
|
if (!isTypingRef.current) {
|
|
1785
2105
|
setTextDraft(value);
|
|
1786
2106
|
setIsInvalid(false);
|
|
@@ -1788,11 +2108,11 @@ var ColorPicker = ({
|
|
|
1788
2108
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
1789
2109
|
}
|
|
1790
2110
|
}, [value]);
|
|
1791
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
1792
|
-
(0,
|
|
2111
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react19.useState)(false);
|
|
2112
|
+
(0, import_react19.useEffect)(() => {
|
|
1793
2113
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
1794
2114
|
}, []);
|
|
1795
|
-
const emitColorChange = (0,
|
|
2115
|
+
const emitColorChange = (0, import_react19.useCallback)(
|
|
1796
2116
|
(nextState) => {
|
|
1797
2117
|
setPickerState(nextState);
|
|
1798
2118
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -1800,10 +2120,10 @@ var ColorPicker = ({
|
|
|
1800
2120
|
},
|
|
1801
2121
|
[alpha, onChange]
|
|
1802
2122
|
);
|
|
1803
|
-
const latest = (0,
|
|
2123
|
+
const latest = (0, import_react19.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
1804
2124
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
1805
|
-
const endDragRef = (0,
|
|
1806
|
-
(0,
|
|
2125
|
+
const endDragRef = (0, import_react19.useRef)(null);
|
|
2126
|
+
(0, import_react19.useEffect)(() => () => endDragRef.current?.(), []);
|
|
1807
2127
|
const startDrag = (e, next) => {
|
|
1808
2128
|
if (disabled) return;
|
|
1809
2129
|
e.preventDefault();
|
|
@@ -1905,7 +2225,7 @@ var ColorPicker = ({
|
|
|
1905
2225
|
} catch {
|
|
1906
2226
|
}
|
|
1907
2227
|
};
|
|
1908
|
-
const contrastResult = (0,
|
|
2228
|
+
const contrastResult = (0, import_react19.useMemo)(() => {
|
|
1909
2229
|
if (!contrastAgainst) return null;
|
|
1910
2230
|
const fg = (0, import_color.parseColor)(value);
|
|
1911
2231
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -1917,7 +2237,7 @@ var ColorPicker = ({
|
|
|
1917
2237
|
}, [value, contrastAgainst]);
|
|
1918
2238
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
1919
2239
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
1920
|
-
return /* @__PURE__ */ (0,
|
|
2240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1921
2241
|
"div",
|
|
1922
2242
|
{
|
|
1923
2243
|
id: pickerId,
|
|
@@ -1941,7 +2261,7 @@ var ColorPicker = ({
|
|
|
1941
2261
|
pointerEvents: disabled ? "none" : "auto"
|
|
1942
2262
|
},
|
|
1943
2263
|
children: [
|
|
1944
|
-
/* @__PURE__ */ (0,
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1945
2265
|
"span",
|
|
1946
2266
|
{
|
|
1947
2267
|
role: "status",
|
|
@@ -1960,7 +2280,7 @@ var ColorPicker = ({
|
|
|
1960
2280
|
children: liveDescription
|
|
1961
2281
|
}
|
|
1962
2282
|
),
|
|
1963
|
-
/* @__PURE__ */ (0,
|
|
2283
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1964
2284
|
"div",
|
|
1965
2285
|
{
|
|
1966
2286
|
role: "slider",
|
|
@@ -1982,7 +2302,7 @@ var ColorPicker = ({
|
|
|
1982
2302
|
touchAction: "none",
|
|
1983
2303
|
outline: "none"
|
|
1984
2304
|
},
|
|
1985
|
-
children: /* @__PURE__ */ (0,
|
|
2305
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1986
2306
|
"div",
|
|
1987
2307
|
{
|
|
1988
2308
|
style: {
|
|
@@ -2002,7 +2322,7 @@ var ColorPicker = ({
|
|
|
2002
2322
|
)
|
|
2003
2323
|
}
|
|
2004
2324
|
),
|
|
2005
|
-
/* @__PURE__ */ (0,
|
|
2325
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2006
2326
|
"div",
|
|
2007
2327
|
{
|
|
2008
2328
|
role: "slider",
|
|
@@ -2025,7 +2345,7 @@ var ColorPicker = ({
|
|
|
2025
2345
|
touchAction: "none",
|
|
2026
2346
|
outline: "none"
|
|
2027
2347
|
},
|
|
2028
|
-
children: /* @__PURE__ */ (0,
|
|
2348
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2029
2349
|
"div",
|
|
2030
2350
|
{
|
|
2031
2351
|
style: {
|
|
@@ -2045,7 +2365,7 @@ var ColorPicker = ({
|
|
|
2045
2365
|
)
|
|
2046
2366
|
}
|
|
2047
2367
|
),
|
|
2048
|
-
alpha && /* @__PURE__ */ (0,
|
|
2368
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2049
2369
|
"div",
|
|
2050
2370
|
{
|
|
2051
2371
|
role: "slider",
|
|
@@ -2071,7 +2391,7 @@ var ColorPicker = ({
|
|
|
2071
2391
|
overflow: "hidden"
|
|
2072
2392
|
},
|
|
2073
2393
|
children: [
|
|
2074
|
-
/* @__PURE__ */ (0,
|
|
2394
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2075
2395
|
"div",
|
|
2076
2396
|
{
|
|
2077
2397
|
style: {
|
|
@@ -2081,7 +2401,7 @@ var ColorPicker = ({
|
|
|
2081
2401
|
}
|
|
2082
2402
|
}
|
|
2083
2403
|
),
|
|
2084
|
-
/* @__PURE__ */ (0,
|
|
2404
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2085
2405
|
"div",
|
|
2086
2406
|
{
|
|
2087
2407
|
style: {
|
|
@@ -2102,8 +2422,8 @@ var ColorPicker = ({
|
|
|
2102
2422
|
]
|
|
2103
2423
|
}
|
|
2104
2424
|
),
|
|
2105
|
-
/* @__PURE__ */ (0,
|
|
2106
|
-
/* @__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)(
|
|
2107
2427
|
"div",
|
|
2108
2428
|
{
|
|
2109
2429
|
style: {
|
|
@@ -2117,7 +2437,7 @@ var ColorPicker = ({
|
|
|
2117
2437
|
flexShrink: 0,
|
|
2118
2438
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
2119
2439
|
},
|
|
2120
|
-
children: /* @__PURE__ */ (0,
|
|
2440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2121
2441
|
"div",
|
|
2122
2442
|
{
|
|
2123
2443
|
style: {
|
|
@@ -2129,7 +2449,7 @@ var ColorPicker = ({
|
|
|
2129
2449
|
)
|
|
2130
2450
|
}
|
|
2131
2451
|
),
|
|
2132
|
-
/* @__PURE__ */ (0,
|
|
2452
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2133
2453
|
"input",
|
|
2134
2454
|
{
|
|
2135
2455
|
type: "text",
|
|
@@ -2159,7 +2479,7 @@ var ColorPicker = ({
|
|
|
2159
2479
|
}
|
|
2160
2480
|
}
|
|
2161
2481
|
),
|
|
2162
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
2482
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2163
2483
|
"button",
|
|
2164
2484
|
{
|
|
2165
2485
|
type: "button",
|
|
@@ -2179,7 +2499,7 @@ var ColorPicker = ({
|
|
|
2179
2499
|
color: "inherit",
|
|
2180
2500
|
cursor: disabled ? "default" : "pointer"
|
|
2181
2501
|
},
|
|
2182
|
-
children: /* @__PURE__ */ (0,
|
|
2502
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2183
2503
|
"svg",
|
|
2184
2504
|
{
|
|
2185
2505
|
width: "14",
|
|
@@ -2191,16 +2511,16 @@ var ColorPicker = ({
|
|
|
2191
2511
|
strokeLinecap: "round",
|
|
2192
2512
|
strokeLinejoin: "round",
|
|
2193
2513
|
children: [
|
|
2194
|
-
/* @__PURE__ */ (0,
|
|
2195
|
-
/* @__PURE__ */ (0,
|
|
2196
|
-
/* @__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" })
|
|
2197
2517
|
]
|
|
2198
2518
|
}
|
|
2199
2519
|
)
|
|
2200
2520
|
}
|
|
2201
2521
|
)
|
|
2202
2522
|
] }),
|
|
2203
|
-
isClipped && /* @__PURE__ */ (0,
|
|
2523
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2204
2524
|
"div",
|
|
2205
2525
|
{
|
|
2206
2526
|
role: "note",
|
|
@@ -2216,10 +2536,10 @@ var ColorPicker = ({
|
|
|
2216
2536
|
borderRadius: "4px",
|
|
2217
2537
|
alignSelf: "flex-start"
|
|
2218
2538
|
},
|
|
2219
|
-
children: /* @__PURE__ */ (0,
|
|
2539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
2220
2540
|
}
|
|
2221
2541
|
),
|
|
2222
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
2542
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2223
2543
|
"div",
|
|
2224
2544
|
{
|
|
2225
2545
|
style: {
|
|
@@ -2233,15 +2553,15 @@ var ColorPicker = ({
|
|
|
2233
2553
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
2234
2554
|
},
|
|
2235
2555
|
children: [
|
|
2236
|
-
/* @__PURE__ */ (0,
|
|
2556
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
2237
2557
|
"Contrast: ",
|
|
2238
|
-
/* @__PURE__ */ (0,
|
|
2558
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("strong", { children: [
|
|
2239
2559
|
contrastResult.ratio.toFixed(2),
|
|
2240
2560
|
":1"
|
|
2241
2561
|
] })
|
|
2242
2562
|
] }),
|
|
2243
|
-
/* @__PURE__ */ (0,
|
|
2244
|
-
/* @__PURE__ */ (0,
|
|
2563
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2245
2565
|
"span",
|
|
2246
2566
|
{
|
|
2247
2567
|
style: {
|
|
@@ -2254,7 +2574,7 @@ var ColorPicker = ({
|
|
|
2254
2574
|
]
|
|
2255
2575
|
}
|
|
2256
2576
|
),
|
|
2257
|
-
/* @__PURE__ */ (0,
|
|
2577
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2258
2578
|
"span",
|
|
2259
2579
|
{
|
|
2260
2580
|
style: {
|
|
@@ -2271,9 +2591,9 @@ var ColorPicker = ({
|
|
|
2271
2591
|
]
|
|
2272
2592
|
}
|
|
2273
2593
|
),
|
|
2274
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2275
|
-
/* @__PURE__ */ (0,
|
|
2276
|
-
/* @__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)(
|
|
2277
2597
|
"button",
|
|
2278
2598
|
{
|
|
2279
2599
|
type: "button",
|
|
@@ -2299,9 +2619,9 @@ var ColorPicker = ({
|
|
|
2299
2619
|
`${color}-${idx}`
|
|
2300
2620
|
)) })
|
|
2301
2621
|
] }),
|
|
2302
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
2303
|
-
/* @__PURE__ */ (0,
|
|
2304
|
-
/* @__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)(
|
|
2305
2625
|
"button",
|
|
2306
2626
|
{
|
|
2307
2627
|
type: "button",
|
|
@@ -2332,9 +2652,9 @@ var ColorPicker = ({
|
|
|
2332
2652
|
};
|
|
2333
2653
|
|
|
2334
2654
|
// src/color/DualColorPicker.tsx
|
|
2335
|
-
var
|
|
2655
|
+
var import_react20 = require("react");
|
|
2336
2656
|
var import_color2 = require("@pixerate/editor/color");
|
|
2337
|
-
var
|
|
2657
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2338
2658
|
function DualColorPicker({
|
|
2339
2659
|
value,
|
|
2340
2660
|
onChange,
|
|
@@ -2349,8 +2669,8 @@ function DualColorPicker({
|
|
|
2349
2669
|
disabled = false,
|
|
2350
2670
|
className = ""
|
|
2351
2671
|
}) {
|
|
2352
|
-
const sameId = (0,
|
|
2353
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
2672
|
+
const sameId = (0, import_react20.useId)();
|
|
2673
|
+
const [internalScheme, setInternalScheme] = (0, import_react20.useState)("light");
|
|
2354
2674
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
2355
2675
|
const handleSchemeSelect = (nextScheme) => {
|
|
2356
2676
|
if (onSchemeChange) {
|
|
@@ -2361,7 +2681,7 @@ function DualColorPicker({
|
|
|
2361
2681
|
};
|
|
2362
2682
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
2363
2683
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
2364
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
2684
|
+
const [sameInBoth, setSameInBoth] = (0, import_react20.useState)(isSame);
|
|
2365
2685
|
const handleSameToggle = (e) => {
|
|
2366
2686
|
const nextSame = e.target.checked;
|
|
2367
2687
|
setSameInBoth(nextSame);
|
|
@@ -2393,7 +2713,7 @@ function DualColorPicker({
|
|
|
2393
2713
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
2394
2714
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
2395
2715
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
2396
|
-
return /* @__PURE__ */ (0,
|
|
2716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2397
2717
|
"div",
|
|
2398
2718
|
{
|
|
2399
2719
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -2412,7 +2732,7 @@ function DualColorPicker({
|
|
|
2412
2732
|
boxSizing: "border-box"
|
|
2413
2733
|
},
|
|
2414
2734
|
children: [
|
|
2415
|
-
/* @__PURE__ */ (0,
|
|
2735
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2416
2736
|
"div",
|
|
2417
2737
|
{
|
|
2418
2738
|
role: "tablist",
|
|
@@ -2425,7 +2745,7 @@ function DualColorPicker({
|
|
|
2425
2745
|
gap: "2px"
|
|
2426
2746
|
},
|
|
2427
2747
|
children: [
|
|
2428
|
-
/* @__PURE__ */ (0,
|
|
2748
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2429
2749
|
"button",
|
|
2430
2750
|
{
|
|
2431
2751
|
type: "button",
|
|
@@ -2448,7 +2768,7 @@ function DualColorPicker({
|
|
|
2448
2768
|
children: "Light"
|
|
2449
2769
|
}
|
|
2450
2770
|
),
|
|
2451
|
-
/* @__PURE__ */ (0,
|
|
2771
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2452
2772
|
"button",
|
|
2453
2773
|
{
|
|
2454
2774
|
type: "button",
|
|
@@ -2474,8 +2794,8 @@ function DualColorPicker({
|
|
|
2474
2794
|
]
|
|
2475
2795
|
}
|
|
2476
2796
|
),
|
|
2477
|
-
/* @__PURE__ */ (0,
|
|
2478
|
-
/* @__PURE__ */ (0,
|
|
2797
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2479
2799
|
"button",
|
|
2480
2800
|
{
|
|
2481
2801
|
type: "button",
|
|
@@ -2497,7 +2817,7 @@ function DualColorPicker({
|
|
|
2497
2817
|
outline: "none"
|
|
2498
2818
|
},
|
|
2499
2819
|
children: [
|
|
2500
|
-
/* @__PURE__ */ (0,
|
|
2820
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2501
2821
|
"span",
|
|
2502
2822
|
{
|
|
2503
2823
|
style: {
|
|
@@ -2509,11 +2829,11 @@ function DualColorPicker({
|
|
|
2509
2829
|
}
|
|
2510
2830
|
}
|
|
2511
2831
|
),
|
|
2512
|
-
/* @__PURE__ */ (0,
|
|
2832
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2513
2833
|
]
|
|
2514
2834
|
}
|
|
2515
2835
|
),
|
|
2516
|
-
/* @__PURE__ */ (0,
|
|
2836
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2517
2837
|
"button",
|
|
2518
2838
|
{
|
|
2519
2839
|
type: "button",
|
|
@@ -2535,7 +2855,7 @@ function DualColorPicker({
|
|
|
2535
2855
|
outline: "none"
|
|
2536
2856
|
},
|
|
2537
2857
|
children: [
|
|
2538
|
-
/* @__PURE__ */ (0,
|
|
2858
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2539
2859
|
"span",
|
|
2540
2860
|
{
|
|
2541
2861
|
style: {
|
|
@@ -2547,12 +2867,12 @@ function DualColorPicker({
|
|
|
2547
2867
|
}
|
|
2548
2868
|
}
|
|
2549
2869
|
),
|
|
2550
|
-
/* @__PURE__ */ (0,
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2551
2871
|
]
|
|
2552
2872
|
}
|
|
2553
2873
|
)
|
|
2554
2874
|
] }),
|
|
2555
|
-
/* @__PURE__ */ (0,
|
|
2875
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2556
2876
|
"div",
|
|
2557
2877
|
{
|
|
2558
2878
|
style: {
|
|
@@ -2563,7 +2883,7 @@ function DualColorPicker({
|
|
|
2563
2883
|
padding: "2px 0"
|
|
2564
2884
|
},
|
|
2565
2885
|
children: [
|
|
2566
|
-
/* @__PURE__ */ (0,
|
|
2886
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2567
2887
|
"label",
|
|
2568
2888
|
{
|
|
2569
2889
|
htmlFor: sameId,
|
|
@@ -2577,7 +2897,7 @@ function DualColorPicker({
|
|
|
2577
2897
|
color: "#c4cad4"
|
|
2578
2898
|
},
|
|
2579
2899
|
children: [
|
|
2580
|
-
/* @__PURE__ */ (0,
|
|
2900
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2581
2901
|
"input",
|
|
2582
2902
|
{
|
|
2583
2903
|
id: sameId,
|
|
@@ -2588,11 +2908,11 @@ function DualColorPicker({
|
|
|
2588
2908
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2589
2909
|
}
|
|
2590
2910
|
),
|
|
2591
|
-
/* @__PURE__ */ (0,
|
|
2911
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: "Same in both" })
|
|
2592
2912
|
]
|
|
2593
2913
|
}
|
|
2594
2914
|
),
|
|
2595
|
-
/* @__PURE__ */ (0,
|
|
2915
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2596
2916
|
"button",
|
|
2597
2917
|
{
|
|
2598
2918
|
type: "button",
|
|
@@ -2614,7 +2934,7 @@ function DualColorPicker({
|
|
|
2614
2934
|
]
|
|
2615
2935
|
}
|
|
2616
2936
|
),
|
|
2617
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
2937
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2618
2938
|
"div",
|
|
2619
2939
|
{
|
|
2620
2940
|
"data-testid": "dual-contrast-summary",
|
|
@@ -2628,20 +2948,20 @@ function DualColorPicker({
|
|
|
2628
2948
|
color: "#8c95a6"
|
|
2629
2949
|
},
|
|
2630
2950
|
children: [
|
|
2631
|
-
/* @__PURE__ */ (0,
|
|
2951
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { children: [
|
|
2632
2952
|
"Light:",
|
|
2633
2953
|
" ",
|
|
2634
|
-
/* @__PURE__ */ (0,
|
|
2954
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2635
2955
|
dualContrast.light.ratio.toFixed(2),
|
|
2636
2956
|
" (",
|
|
2637
2957
|
dualContrast.light.level,
|
|
2638
2958
|
")"
|
|
2639
2959
|
] })
|
|
2640
2960
|
] }),
|
|
2641
|
-
/* @__PURE__ */ (0,
|
|
2961
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { children: [
|
|
2642
2962
|
"Dark:",
|
|
2643
2963
|
" ",
|
|
2644
|
-
/* @__PURE__ */ (0,
|
|
2964
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2645
2965
|
dualContrast.dark.ratio.toFixed(2),
|
|
2646
2966
|
" (",
|
|
2647
2967
|
dualContrast.dark.level,
|
|
@@ -2651,7 +2971,7 @@ function DualColorPicker({
|
|
|
2651
2971
|
]
|
|
2652
2972
|
}
|
|
2653
2973
|
),
|
|
2654
|
-
/* @__PURE__ */ (0,
|
|
2974
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2655
2975
|
ColorPicker,
|
|
2656
2976
|
{
|
|
2657
2977
|
value: activeColor,
|
|
@@ -2670,7 +2990,7 @@ function DualColorPicker({
|
|
|
2670
2990
|
}
|
|
2671
2991
|
|
|
2672
2992
|
// src/color/useColorScheme.ts
|
|
2673
|
-
var
|
|
2993
|
+
var import_react21 = require("react");
|
|
2674
2994
|
var import_color3 = require("@pixerate/editor/color");
|
|
2675
2995
|
function getSnapshot(attribute) {
|
|
2676
2996
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -2695,7 +3015,7 @@ function getServerSnapshot() {
|
|
|
2695
3015
|
function useColorScheme(options) {
|
|
2696
3016
|
const override = options?.override;
|
|
2697
3017
|
const attribute = options?.attribute;
|
|
2698
|
-
const subscribe = (0,
|
|
3018
|
+
const subscribe = (0, import_react21.useMemo)(() => {
|
|
2699
3019
|
return (callback) => {
|
|
2700
3020
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2701
3021
|
return () => {
|
|
@@ -2721,7 +3041,7 @@ function useColorScheme(options) {
|
|
|
2721
3041
|
};
|
|
2722
3042
|
};
|
|
2723
3043
|
}, [attribute]);
|
|
2724
|
-
const detected = (0,
|
|
3044
|
+
const detected = (0, import_react21.useSyncExternalStore)(
|
|
2725
3045
|
subscribe,
|
|
2726
3046
|
() => getSnapshot(attribute),
|
|
2727
3047
|
getServerSnapshot
|
|
@@ -2738,11 +3058,11 @@ function useResolvedColor(value, scheme) {
|
|
|
2738
3058
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2739
3059
|
|
|
2740
3060
|
// src/parameters/controls.tsx
|
|
2741
|
-
var
|
|
2742
|
-
var
|
|
2743
|
-
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)({});
|
|
2744
3064
|
function useParameterComponents() {
|
|
2745
|
-
return (0,
|
|
3065
|
+
return (0, import_react22.useContext)(ParameterComponentsContext);
|
|
2746
3066
|
}
|
|
2747
3067
|
function resolveParameterComponents(explicit, context) {
|
|
2748
3068
|
return {
|
|
@@ -2754,7 +3074,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
2754
3074
|
}
|
|
2755
3075
|
|
|
2756
3076
|
// src/parameters/fields.tsx
|
|
2757
|
-
var
|
|
3077
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2758
3078
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2759
3079
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2760
3080
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -2763,9 +3083,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
2763
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";
|
|
2764
3084
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2765
3085
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2766
|
-
const inputRef = (0,
|
|
2767
|
-
const lastCommitted = (0,
|
|
2768
|
-
(0,
|
|
3086
|
+
const inputRef = (0, import_react23.useRef)(null);
|
|
3087
|
+
const lastCommitted = (0, import_react23.useRef)(null);
|
|
3088
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
2769
3089
|
lastCommitted.current = null;
|
|
2770
3090
|
const el = inputRef.current;
|
|
2771
3091
|
if (el && el.value !== value) el.value = value;
|
|
@@ -2776,9 +3096,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2776
3096
|
onCommit(text, el);
|
|
2777
3097
|
lastCommitted.current = el.value === text ? text : null;
|
|
2778
3098
|
};
|
|
2779
|
-
const commitRef = (0,
|
|
3099
|
+
const commitRef = (0, import_react23.useRef)(commit);
|
|
2780
3100
|
commitRef.current = commit;
|
|
2781
|
-
(0,
|
|
3101
|
+
(0, import_react23.useEffect)(() => {
|
|
2782
3102
|
const el = inputRef.current;
|
|
2783
3103
|
if (!el) return;
|
|
2784
3104
|
const change = () => commitRef.current(el);
|
|
@@ -2809,7 +3129,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2809
3129
|
if (typeof forwarded === "function") forwarded(el);
|
|
2810
3130
|
else if (forwarded) forwarded.current = el;
|
|
2811
3131
|
};
|
|
2812
|
-
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 });
|
|
2813
3133
|
}
|
|
2814
3134
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
2815
3135
|
function ParameterNumberInput(props) {
|
|
@@ -2843,9 +3163,9 @@ function ParameterNumberInput(props) {
|
|
|
2843
3163
|
onCommit: handleCommit,
|
|
2844
3164
|
onKeyDown: handleKeyDown
|
|
2845
3165
|
};
|
|
2846
|
-
return /* @__PURE__ */ (0,
|
|
2847
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
2848
|
-
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 })
|
|
2849
3169
|
] });
|
|
2850
3170
|
}
|
|
2851
3171
|
function ParameterSlider(props) {
|
|
@@ -2853,7 +3173,7 @@ function ParameterSlider(props) {
|
|
|
2853
3173
|
const ctx = useParameterComponents();
|
|
2854
3174
|
const resolved = resolveParameterComponents(components, ctx);
|
|
2855
3175
|
const CustomSlider = resolved.slider;
|
|
2856
|
-
const dragging = (0,
|
|
3176
|
+
const dragging = (0, import_react23.useRef)(false);
|
|
2857
3177
|
const start = () => {
|
|
2858
3178
|
if (dragging.current) return;
|
|
2859
3179
|
dragging.current = true;
|
|
@@ -2864,7 +3184,7 @@ function ParameterSlider(props) {
|
|
|
2864
3184
|
dragging.current = false;
|
|
2865
3185
|
onGestureEnd?.();
|
|
2866
3186
|
};
|
|
2867
|
-
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 });
|
|
2868
3188
|
const step = (0, import_parameters.parameterStep)(field);
|
|
2869
3189
|
const sliderProps = {
|
|
2870
3190
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -2878,8 +3198,8 @@ function ParameterSlider(props) {
|
|
|
2878
3198
|
className: rangeClass,
|
|
2879
3199
|
style: parameterRangeStyle
|
|
2880
3200
|
};
|
|
2881
|
-
return /* @__PURE__ */ (0,
|
|
2882
|
-
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)(
|
|
2883
3203
|
CustomSlider,
|
|
2884
3204
|
{
|
|
2885
3205
|
...sliderProps,
|
|
@@ -2889,7 +3209,7 @@ function ParameterSlider(props) {
|
|
|
2889
3209
|
onGestureStart: start,
|
|
2890
3210
|
onGestureEnd: end
|
|
2891
3211
|
}
|
|
2892
|
-
) : /* @__PURE__ */ (0,
|
|
3212
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2893
3213
|
"input",
|
|
2894
3214
|
{
|
|
2895
3215
|
type: "range",
|
|
@@ -2901,11 +3221,11 @@ function ParameterSlider(props) {
|
|
|
2901
3221
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
2902
3222
|
}
|
|
2903
3223
|
),
|
|
2904
|
-
/* @__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` }) })
|
|
2905
3225
|
] });
|
|
2906
3226
|
}
|
|
2907
3227
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
2908
|
-
return /* @__PURE__ */ (0,
|
|
3228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2909
3229
|
"button",
|
|
2910
3230
|
{
|
|
2911
3231
|
type: "button",
|
|
@@ -2916,7 +3236,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2916
3236
|
disabled: disabled || field.readOnly,
|
|
2917
3237
|
onClick: () => onChange(!value),
|
|
2918
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"}`,
|
|
2919
|
-
children: /* @__PURE__ */ (0,
|
|
3239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2920
3240
|
"span",
|
|
2921
3241
|
{
|
|
2922
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"}`
|
|
@@ -2933,7 +3253,7 @@ function ParameterSelect(props) {
|
|
|
2933
3253
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
2934
3254
|
const off = disabled || field.readOnly;
|
|
2935
3255
|
if (field.control === "segmented") {
|
|
2936
|
-
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)(
|
|
2937
3257
|
"button",
|
|
2938
3258
|
{
|
|
2939
3259
|
type: "button",
|
|
@@ -2950,7 +3270,7 @@ function ParameterSelect(props) {
|
|
|
2950
3270
|
}
|
|
2951
3271
|
if (CustomSelect) {
|
|
2952
3272
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
2953
|
-
return /* @__PURE__ */ (0,
|
|
3273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2954
3274
|
CustomSelect,
|
|
2955
3275
|
{
|
|
2956
3276
|
id,
|
|
@@ -2966,7 +3286,7 @@ function ParameterSelect(props) {
|
|
|
2966
3286
|
);
|
|
2967
3287
|
}
|
|
2968
3288
|
const index = options.findIndex((o) => o.value === value);
|
|
2969
|
-
return /* @__PURE__ */ (0,
|
|
3289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2970
3290
|
"select",
|
|
2971
3291
|
{
|
|
2972
3292
|
id,
|
|
@@ -2979,23 +3299,23 @@ function ParameterSelect(props) {
|
|
|
2979
3299
|
},
|
|
2980
3300
|
className: parameterInputClass,
|
|
2981
3301
|
style: parameterSelectStyle,
|
|
2982
|
-
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)))
|
|
2983
3303
|
}
|
|
2984
3304
|
);
|
|
2985
3305
|
}
|
|
2986
3306
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
2987
3307
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
2988
|
-
const [open, setOpen] = (0,
|
|
2989
|
-
const containerRef = (0,
|
|
2990
|
-
const buttonRef = (0,
|
|
2991
|
-
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);
|
|
2992
3312
|
const alpha = !!field.alpha;
|
|
2993
3313
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2994
3314
|
const rgb = hex.slice(0, 7);
|
|
2995
3315
|
const shown = alpha ? hex : rgb;
|
|
2996
3316
|
const off = disabled || field.readOnly;
|
|
2997
3317
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2998
|
-
(0,
|
|
3318
|
+
(0, import_react23.useEffect)(() => {
|
|
2999
3319
|
if (!open) return;
|
|
3000
3320
|
const onPointerDown = (e) => {
|
|
3001
3321
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3017,7 +3337,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3017
3337
|
};
|
|
3018
3338
|
}, [open]);
|
|
3019
3339
|
if (CustomColor) {
|
|
3020
|
-
return /* @__PURE__ */ (0,
|
|
3340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3021
3341
|
CustomColor,
|
|
3022
3342
|
{
|
|
3023
3343
|
id,
|
|
@@ -3032,9 +3352,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3032
3352
|
}
|
|
3033
3353
|
);
|
|
3034
3354
|
}
|
|
3035
|
-
return /* @__PURE__ */ (0,
|
|
3036
|
-
/* @__PURE__ */ (0,
|
|
3037
|
-
/* @__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)(
|
|
3038
3358
|
"button",
|
|
3039
3359
|
{
|
|
3040
3360
|
ref: buttonRef,
|
|
@@ -3045,10 +3365,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3045
3365
|
disabled: off,
|
|
3046
3366
|
onClick: () => setOpen((prev) => !prev),
|
|
3047
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",
|
|
3048
|
-
children: /* @__PURE__ */ (0,
|
|
3368
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3049
3369
|
}
|
|
3050
3370
|
),
|
|
3051
|
-
/* @__PURE__ */ (0,
|
|
3371
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3052
3372
|
ParameterCommitInput,
|
|
3053
3373
|
{
|
|
3054
3374
|
id,
|
|
@@ -3064,7 +3384,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3064
3384
|
}
|
|
3065
3385
|
)
|
|
3066
3386
|
] }),
|
|
3067
|
-
open && /* @__PURE__ */ (0,
|
|
3387
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3068
3388
|
"div",
|
|
3069
3389
|
{
|
|
3070
3390
|
ref: popoverRef,
|
|
@@ -3078,7 +3398,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3078
3398
|
},
|
|
3079
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",
|
|
3080
3400
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3081
|
-
children: /* @__PURE__ */ (0,
|
|
3401
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3082
3402
|
ColorPicker,
|
|
3083
3403
|
{
|
|
3084
3404
|
value: shown,
|
|
@@ -3096,11 +3416,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3096
3416
|
}
|
|
3097
3417
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
3098
3418
|
const size = (0, import_parameters.vectorSize)(field);
|
|
3099
|
-
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) => {
|
|
3100
3420
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
3101
|
-
return /* @__PURE__ */ (0,
|
|
3102
|
-
/* @__PURE__ */ (0,
|
|
3103
|
-
/* @__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)(
|
|
3104
3424
|
ParameterNumberInput,
|
|
3105
3425
|
{
|
|
3106
3426
|
field: component,
|
|
@@ -3118,11 +3438,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
3118
3438
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
3119
3439
|
const off = disabled || field.readOnly;
|
|
3120
3440
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3121
|
-
return /* @__PURE__ */ (0,
|
|
3122
|
-
/* @__PURE__ */ (0,
|
|
3123
|
-
/* @__PURE__ */ (0,
|
|
3124
|
-
/* @__PURE__ */ (0,
|
|
3125
|
-
/* @__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)(
|
|
3126
3446
|
ParameterCommitInput,
|
|
3127
3447
|
{
|
|
3128
3448
|
id,
|
|
@@ -3133,15 +3453,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3133
3453
|
onCommit: (text) => onChange(text.trim())
|
|
3134
3454
|
}
|
|
3135
3455
|
),
|
|
3136
|
-
/* @__PURE__ */ (0,
|
|
3137
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3456
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex gap-1", children: [
|
|
3457
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3138
3458
|
"label",
|
|
3139
3459
|
{
|
|
3140
3460
|
style: parameterButtonStyle,
|
|
3141
3461
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3142
3462
|
children: [
|
|
3143
3463
|
"Choose file\u2026",
|
|
3144
|
-
/* @__PURE__ */ (0,
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3145
3465
|
"input",
|
|
3146
3466
|
{
|
|
3147
3467
|
type: "file",
|
|
@@ -3159,7 +3479,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3159
3479
|
]
|
|
3160
3480
|
}
|
|
3161
3481
|
),
|
|
3162
|
-
value && /* @__PURE__ */ (0,
|
|
3482
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3163
3483
|
"button",
|
|
3164
3484
|
{
|
|
3165
3485
|
type: "button",
|
|
@@ -3174,7 +3494,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3174
3494
|
] })
|
|
3175
3495
|
] })
|
|
3176
3496
|
] }),
|
|
3177
|
-
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)(
|
|
3178
3498
|
"button",
|
|
3179
3499
|
{
|
|
3180
3500
|
type: "button",
|
|
@@ -3184,14 +3504,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3184
3504
|
disabled: off,
|
|
3185
3505
|
onClick: () => onChange(o.url),
|
|
3186
3506
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
3187
|
-
children: /* @__PURE__ */ (0,
|
|
3507
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
3188
3508
|
},
|
|
3189
3509
|
o.url
|
|
3190
3510
|
)) })
|
|
3191
3511
|
] });
|
|
3192
3512
|
}
|
|
3193
3513
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
3194
|
-
return /* @__PURE__ */ (0,
|
|
3514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3195
3515
|
ParameterCommitInput,
|
|
3196
3516
|
{
|
|
3197
3517
|
id,
|
|
@@ -3210,24 +3530,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
3210
3530
|
switch (field.type) {
|
|
3211
3531
|
case "number":
|
|
3212
3532
|
case "int":
|
|
3213
|
-
return /* @__PURE__ */ (0,
|
|
3533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
3214
3534
|
case "boolean":
|
|
3215
|
-
return /* @__PURE__ */ (0,
|
|
3535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
3216
3536
|
case "choice":
|
|
3217
|
-
return /* @__PURE__ */ (0,
|
|
3537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
3218
3538
|
case "color":
|
|
3219
|
-
return /* @__PURE__ */ (0,
|
|
3539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
3220
3540
|
case "vector":
|
|
3221
|
-
return /* @__PURE__ */ (0,
|
|
3541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
3222
3542
|
case "image":
|
|
3223
|
-
return /* @__PURE__ */ (0,
|
|
3543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
3224
3544
|
case "text":
|
|
3225
|
-
return /* @__PURE__ */ (0,
|
|
3545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
3226
3546
|
}
|
|
3227
3547
|
}
|
|
3228
3548
|
|
|
3229
3549
|
// src/effects/EffectParameters.tsx
|
|
3230
|
-
var
|
|
3550
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3231
3551
|
function EffectParameters({
|
|
3232
3552
|
description,
|
|
3233
3553
|
values,
|
|
@@ -3242,10 +3562,10 @@ function EffectParameters({
|
|
|
3242
3562
|
className = "",
|
|
3243
3563
|
components
|
|
3244
3564
|
}) {
|
|
3245
|
-
const fields = (0,
|
|
3246
|
-
const idBase = (0,
|
|
3247
|
-
const gesture =
|
|
3248
|
-
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);
|
|
3249
3569
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3250
3570
|
const handlePresetSelect = (name) => {
|
|
3251
3571
|
if (!name) return;
|
|
@@ -3256,8 +3576,8 @@ function EffectParameters({
|
|
|
3256
3576
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3257
3577
|
}
|
|
3258
3578
|
};
|
|
3259
|
-
return /* @__PURE__ */ (0,
|
|
3260
|
-
(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)(
|
|
3261
3581
|
CustomPresetSelect,
|
|
3262
3582
|
{
|
|
3263
3583
|
"aria-label": `${description.name} presets`,
|
|
@@ -3272,7 +3592,7 @@ function EffectParameters({
|
|
|
3272
3592
|
],
|
|
3273
3593
|
onChange: (name) => handlePresetSelect(String(name))
|
|
3274
3594
|
}
|
|
3275
|
-
) : /* @__PURE__ */ (0,
|
|
3595
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
3276
3596
|
"select",
|
|
3277
3597
|
{
|
|
3278
3598
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -3282,8 +3602,8 @@ function EffectParameters({
|
|
|
3282
3602
|
disabled,
|
|
3283
3603
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3284
3604
|
children: [
|
|
3285
|
-
/* @__PURE__ */ (0,
|
|
3286
|
-
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))
|
|
3287
3607
|
]
|
|
3288
3608
|
}
|
|
3289
3609
|
)),
|
|
@@ -3293,14 +3613,14 @@ function EffectParameters({
|
|
|
3293
3613
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
3294
3614
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
3295
3615
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
3296
|
-
return /* @__PURE__ */ (0,
|
|
3297
|
-
/* @__PURE__ */ (0,
|
|
3298
|
-
/* @__PURE__ */ (0,
|
|
3299
|
-
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" }),
|
|
3300
3620
|
renderControlAddon?.(field.id),
|
|
3301
|
-
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" })
|
|
3302
3622
|
] }),
|
|
3303
|
-
/* @__PURE__ */ (0,
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3304
3624
|
ParameterFieldControl,
|
|
3305
3625
|
{
|
|
3306
3626
|
field,
|
|
@@ -3315,15 +3635,15 @@ function EffectParameters({
|
|
|
3315
3635
|
)
|
|
3316
3636
|
] }, field.id);
|
|
3317
3637
|
}),
|
|
3318
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3638
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3319
3639
|
] });
|
|
3320
3640
|
}
|
|
3321
3641
|
|
|
3322
3642
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
3323
|
-
var
|
|
3643
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3324
3644
|
function usePaintEffectsProvider(controller) {
|
|
3325
|
-
const [provider, setProvider] = (0,
|
|
3326
|
-
(0,
|
|
3645
|
+
const [provider, setProvider] = (0, import_react25.useState)(controller.effectsProvider);
|
|
3646
|
+
(0, import_react25.useEffect)(() => {
|
|
3327
3647
|
setProvider(controller.effectsProvider);
|
|
3328
3648
|
return controller.effects.subscribe(setProvider);
|
|
3329
3649
|
}, [controller]);
|
|
@@ -3331,27 +3651,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
3331
3651
|
}
|
|
3332
3652
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
3333
3653
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
3334
|
-
(0,
|
|
3654
|
+
(0, import_react25.useEffect)(() => {
|
|
3335
3655
|
if (!registry) return;
|
|
3336
|
-
return registry.register((0,
|
|
3656
|
+
return registry.register((0, import_paint_editor15.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
3337
3657
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
3338
3658
|
}
|
|
3339
3659
|
function Controls({ provider, effect, name, values, apply }) {
|
|
3340
3660
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3341
|
-
const drags = (0,
|
|
3342
|
-
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: [
|
|
3343
3663
|
'No effects provider: "',
|
|
3344
3664
|
name ?? effect,
|
|
3345
3665
|
'" is kept as it was drawn.'
|
|
3346
3666
|
] });
|
|
3347
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3348
|
-
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" });
|
|
3349
3669
|
const commit = (gesture) => {
|
|
3350
3670
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
3351
3671
|
drags.current.add(gesture);
|
|
3352
3672
|
return true;
|
|
3353
3673
|
};
|
|
3354
|
-
return /* @__PURE__ */ (0,
|
|
3674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3355
3675
|
EffectParameters,
|
|
3356
3676
|
{
|
|
3357
3677
|
description,
|
|
@@ -3373,8 +3693,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3373
3693
|
const state = usePaintEditorState(controller);
|
|
3374
3694
|
const provider = usePaintEffectsProvider(controller);
|
|
3375
3695
|
const [error, attempt] = useAttempt();
|
|
3376
|
-
const [browse, setBrowse] = (0,
|
|
3377
|
-
const [busy, setBusy] = (0,
|
|
3696
|
+
const [browse, setBrowse] = (0, import_react25.useState)(null);
|
|
3697
|
+
const [busy, setBusy] = (0, import_react25.useState)(false);
|
|
3378
3698
|
const paper = controller.getPaperEffect();
|
|
3379
3699
|
const activeId = state.document.activeLayerId;
|
|
3380
3700
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -3386,7 +3706,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3386
3706
|
if (!effectPaint) return;
|
|
3387
3707
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
3388
3708
|
};
|
|
3389
|
-
const thumbnail = (0,
|
|
3709
|
+
const thumbnail = (0, import_react25.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
3390
3710
|
const run = (work) => attempt(() => {
|
|
3391
3711
|
setBusy(true);
|
|
3392
3712
|
return work().finally(() => setBusy(false));
|
|
@@ -3402,28 +3722,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3402
3722
|
};
|
|
3403
3723
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
3404
3724
|
const pixel = active?.type === "pixel";
|
|
3405
|
-
return /* @__PURE__ */ (0,
|
|
3406
|
-
/* @__PURE__ */ (0,
|
|
3407
|
-
/* @__PURE__ */ (0,
|
|
3408
|
-
/* @__PURE__ */ (0,
|
|
3409
|
-
/* @__PURE__ */ (0,
|
|
3410
|
-
/* @__PURE__ */ (0,
|
|
3411
|
-
/* @__PURE__ */ (0,
|
|
3412
|
-
/* @__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" })
|
|
3413
3733
|
] }),
|
|
3414
|
-
!provider && /* @__PURE__ */ (0,
|
|
3415
|
-
browse && /* @__PURE__ */ (0,
|
|
3416
|
-
paper && /* @__PURE__ */ (0,
|
|
3417
|
-
/* @__PURE__ */ (0,
|
|
3418
|
-
/* @__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: [
|
|
3419
3739
|
"Paper: ",
|
|
3420
3740
|
paper.name ?? paper.effect
|
|
3421
3741
|
] }),
|
|
3422
|
-
/* @__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" })
|
|
3423
3743
|
] }),
|
|
3424
|
-
/* @__PURE__ */ (0,
|
|
3425
|
-
/* @__PURE__ */ (0,
|
|
3426
|
-
/* @__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)(
|
|
3427
3747
|
"input",
|
|
3428
3748
|
{
|
|
3429
3749
|
type: "range",
|
|
@@ -3445,39 +3765,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3445
3765
|
`o${paper.opacity}`
|
|
3446
3766
|
)
|
|
3447
3767
|
] }),
|
|
3448
|
-
/* @__PURE__ */ (0,
|
|
3449
|
-
/* @__PURE__ */ (0,
|
|
3450
|
-
/* @__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) => {
|
|
3451
3771
|
const blend = e.currentTarget.value;
|
|
3452
3772
|
run(() => controller.updatePaperEffect({ blend }));
|
|
3453
|
-
}, children:
|
|
3773
|
+
}, children: import_paint_editor15.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: b, children: b }, b)) })
|
|
3454
3774
|
] }),
|
|
3455
|
-
/* @__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)) })
|
|
3456
3776
|
] }),
|
|
3457
|
-
effectPaint && /* @__PURE__ */ (0,
|
|
3458
|
-
/* @__PURE__ */ (0,
|
|
3459
|
-
thumbnail ? /* @__PURE__ */ (0,
|
|
3460
|
-
/* @__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: [
|
|
3461
3781
|
"Paint: ",
|
|
3462
3782
|
effectPaint.effect,
|
|
3463
3783
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
3464
3784
|
] }),
|
|
3465
|
-
/* @__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" })
|
|
3466
3786
|
] }),
|
|
3467
|
-
/* @__PURE__ */ (0,
|
|
3468
|
-
/* @__PURE__ */ (0,
|
|
3469
|
-
/* @__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" } }) }),
|
|
3470
3790
|
"Along the stroke"
|
|
3471
3791
|
] }),
|
|
3472
|
-
/* @__PURE__ */ (0,
|
|
3473
|
-
/* @__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 }) }),
|
|
3474
3794
|
"Live"
|
|
3475
3795
|
] })
|
|
3476
3796
|
] }),
|
|
3477
|
-
effectPaint.map && /* @__PURE__ */ (0,
|
|
3478
|
-
/* @__PURE__ */ (0,
|
|
3479
|
-
/* @__PURE__ */ (0,
|
|
3480
|
-
/* @__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)(
|
|
3481
3801
|
"input",
|
|
3482
3802
|
{
|
|
3483
3803
|
type: "number",
|
|
@@ -3491,55 +3811,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3491
3811
|
effectPaint.map.length
|
|
3492
3812
|
)
|
|
3493
3813
|
] }),
|
|
3494
|
-
/* @__PURE__ */ (0,
|
|
3495
|
-
/* @__PURE__ */ (0,
|
|
3496
|
-
/* @__PURE__ */ (0,
|
|
3497
|
-
/* @__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" })
|
|
3498
3818
|
] })
|
|
3499
3819
|
] }),
|
|
3500
|
-
/* @__PURE__ */ (0,
|
|
3820
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
3501
3821
|
] }),
|
|
3502
|
-
animation && /* @__PURE__ */ (0,
|
|
3503
|
-
/* @__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: [
|
|
3504
3824
|
"Live paint: ",
|
|
3505
3825
|
animation.strokes,
|
|
3506
3826
|
" ",
|
|
3507
3827
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
3508
3828
|
] }),
|
|
3509
|
-
/* @__PURE__ */ (0,
|
|
3510
|
-
/* @__PURE__ */ (0,
|
|
3511
|
-
/* @__PURE__ */ (0,
|
|
3512
|
-
/* @__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" })
|
|
3513
3833
|
] })
|
|
3514
3834
|
] }),
|
|
3515
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
3516
|
-
/* @__PURE__ */ (0,
|
|
3517
|
-
/* @__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: [
|
|
3518
3838
|
"Layer: ",
|
|
3519
3839
|
layerEffect.name ?? layerEffect.effect
|
|
3520
3840
|
] }),
|
|
3521
|
-
/* @__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" })
|
|
3522
3842
|
] }),
|
|
3523
|
-
/* @__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)) })
|
|
3524
3844
|
] }),
|
|
3525
|
-
/* @__PURE__ */ (0,
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ErrorLine, { error })
|
|
3526
3846
|
] });
|
|
3527
3847
|
};
|
|
3528
3848
|
|
|
3529
3849
|
// src/paint-editor/PaintEditor.tsx
|
|
3530
|
-
var
|
|
3850
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3531
3851
|
var PAINT_CONTROLS = {
|
|
3532
3852
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
3533
3853
|
lighting: '[data-testid="light-panel"]',
|
|
3534
3854
|
symmetry: '[aria-label="Symmetry"]'
|
|
3535
3855
|
};
|
|
3536
3856
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
3537
|
-
const [tool, setTool] = (0,
|
|
3538
|
-
const [tab, setTab] = (0,
|
|
3539
|
-
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);
|
|
3540
3860
|
tabRef.current = tab;
|
|
3541
|
-
const rootRef = (0,
|
|
3542
|
-
const [ownPresence] = (0,
|
|
3861
|
+
const rootRef = (0, import_react26.useRef)(null);
|
|
3862
|
+
const [ownPresence] = (0, import_react26.useState)(() => new import_paint_editor16.PaintPresence());
|
|
3543
3863
|
const ambientPlayback = useAgentPlayback();
|
|
3544
3864
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
3545
3865
|
const viewBox = () => {
|
|
@@ -3550,12 +3870,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3550
3870
|
const docToClient = (p) => {
|
|
3551
3871
|
const r = viewBox();
|
|
3552
3872
|
if (!r) return null;
|
|
3553
|
-
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);
|
|
3554
3874
|
return { x: r.left + q.x, y: r.top + q.y };
|
|
3555
3875
|
};
|
|
3556
3876
|
const clientToDoc = (p) => {
|
|
3557
3877
|
const r = viewBox();
|
|
3558
|
-
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;
|
|
3559
3879
|
};
|
|
3560
3880
|
const elementRect = (selector) => {
|
|
3561
3881
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -3595,28 +3915,28 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3595
3915
|
const box = rootRef.current?.getBoundingClientRect();
|
|
3596
3916
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
3597
3917
|
};
|
|
3598
|
-
const [error, setError] = (0,
|
|
3918
|
+
const [error, setError] = (0, import_react26.useState)(null);
|
|
3599
3919
|
const effects = usePaintEffectsProvider(controller);
|
|
3600
3920
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
3601
|
-
return /* @__PURE__ */ (0,
|
|
3602
|
-
playing && /* @__PURE__ */ (0,
|
|
3603
|
-
/* @__PURE__ */ (0,
|
|
3604
|
-
/* @__PURE__ */ (0,
|
|
3605
|
-
/* @__PURE__ */ (0,
|
|
3606
|
-
/* @__PURE__ */ (0,
|
|
3607
|
-
/* @__PURE__ */ (0,
|
|
3608
|
-
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 })
|
|
3609
3929
|
] }),
|
|
3610
|
-
/* @__PURE__ */ (0,
|
|
3611
|
-
/* @__PURE__ */ (0,
|
|
3612
|
-
/* @__PURE__ */ (0,
|
|
3613
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
3614
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
3615
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
3616
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3617
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3618
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3619
|
-
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 })
|
|
3620
3940
|
] })
|
|
3621
3941
|
] })
|
|
3622
3942
|
] })
|
|
@@ -3636,6 +3956,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3636
3956
|
PaintToolbar,
|
|
3637
3957
|
PaperPanel,
|
|
3638
3958
|
StickerPanel,
|
|
3959
|
+
StickerPicker,
|
|
3639
3960
|
StrokePanel,
|
|
3640
3961
|
WetPanel,
|
|
3641
3962
|
usePaintDirector,
|