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