@pixerate/editor-react 0.174.0 → 0.176.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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type PaintEditorController, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
2
+ import { type PaintEditorController, type PaintAgentStrokes, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
3
3
  export interface PaintCanvasProps {
4
4
  controller: PaintEditorController;
5
5
  /** The active tool (default brush). */
@@ -14,6 +14,8 @@ export interface PaintCanvasProps {
14
14
  presence?: PaintPresence;
15
15
  /** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
16
16
  proposals?: PaintProposals;
17
+ /** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
18
+ agentStrokes?: PaintAgentStrokes;
17
19
  className?: string;
18
20
  }
19
21
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type PaintEditorController, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
2
+ import { type PaintEditorController, type PaintAgentStrokes, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
3
3
  export interface PaintCanvasProps {
4
4
  controller: PaintEditorController;
5
5
  /** The active tool (default brush). */
@@ -14,6 +14,8 @@ export interface PaintCanvasProps {
14
14
  presence?: PaintPresence;
15
15
  /** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
16
16
  proposals?: PaintProposals;
17
+ /** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
18
+ agentStrokes?: PaintAgentStrokes;
17
19
  className?: string;
18
20
  }
19
21
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { PaintPresence, type PaintEditorController, type PaintProposals } from '@pixerate/editor/paint-editor';
2
+ import { PaintPresence, type PaintEditorController, type PaintProposals, type PaintAgentStrokes } from '@pixerate/editor/paint-editor';
3
3
  import type { AgentPlayback } from '@pixerate/editor/tools';
4
4
  export interface PaintEditorProps {
5
5
  controller: PaintEditorController;
@@ -11,6 +11,8 @@ export interface PaintEditorProps {
11
11
  presence?: PaintPresence;
12
12
  /** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
13
13
  proposals?: PaintProposals;
14
+ /** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
15
+ agentStrokes?: PaintAgentStrokes;
14
16
  className?: string;
15
17
  /**
16
18
  * Agent playback: act out the paint tools' calls here with the agent's cursor, opening the panel
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { PaintPresence, type PaintEditorController, type PaintProposals } from '@pixerate/editor/paint-editor';
2
+ import { PaintPresence, type PaintEditorController, type PaintProposals, type PaintAgentStrokes } from '@pixerate/editor/paint-editor';
3
3
  import type { AgentPlayback } from '@pixerate/editor/tools';
4
4
  export interface PaintEditorProps {
5
5
  controller: PaintEditorController;
@@ -11,6 +11,8 @@ export interface PaintEditorProps {
11
11
  presence?: PaintPresence;
12
12
  /** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
13
13
  proposals?: PaintProposals;
14
+ /** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
15
+ agentStrokes?: PaintAgentStrokes;
14
16
  className?: string;
15
17
  /**
16
18
  * Agent playback: act out the paint tools' calls here with the agent's cursor, opening the panel
@@ -109,7 +109,7 @@ function usePaintChangeFeed(controller, options = {}) {
109
109
  var import_react2 = require("react");
110
110
  var import_paint_editor2 = require("@pixerate/editor/paint-editor");
111
111
  var import_jsx_runtime = require("react/jsx-runtime");
112
- var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, className }) => {
112
+ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
113
113
  const state = usePaintEditorState(controller);
114
114
  const viewport = (0, import_react2.useRef)(null);
115
115
  const canvas = (0, import_react2.useRef)(null);
@@ -247,6 +247,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
247
247
  },
248
248
  i
249
249
  )),
250
+ agentStrokes && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaintAgentStrokeLines, { strokes: agentStrokes }),
250
251
  predicted.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: predicted.map((p) => `${p.x},${p.y}`).join(" "), fill: "none", stroke: state.color, strokeOpacity: 0.5, strokeWidth: Math.max(1, state.brush.tip.size / 2), strokeLinecap: "round" })
251
252
  ] }),
252
253
  state.guides.references.filter((r) => r.visible).map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferencePanel, { controller, id: r.id }, r.id)),
@@ -353,6 +354,10 @@ var PaintProposalGhost = ({ proposal, transform, zoom }) => {
353
354
  }
354
355
  );
355
356
  };
357
+ var PaintAgentStrokeLines = ({ strokes }) => {
358
+ const { strokes: list } = (0, import_react2.useSyncExternalStore)(strokes.subscribe, strokes.getState, strokes.getState);
359
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: list.map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { "data-agent-stroke": s.id, points: (0, import_paint_editor2.paintAgentStrokePoints)(s), fill: "none", stroke: s.color, strokeOpacity: s.opacity ?? 0.6, strokeWidth: s.size, strokeLinecap: "round", strokeLinejoin: "round" }, s.id)) });
360
+ };
356
361
 
357
362
  // src/paint-editor/PaintToolbar.tsx
358
363
  var import_react4 = require("react");
@@ -725,20 +730,43 @@ var EditorControl = ({ control: c, onSet }) => {
725
730
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
726
731
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": c.ariaLabel, defaultValue: c.value, placeholder: c.placeholder, onBlur: (e) => e.target.value !== c.value && onSet(c.path, e.target.value.trim().toLowerCase()), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }, c.value)
727
732
  ] });
728
- case "colour":
729
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
730
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
731
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex items-center gap-1", children: [
732
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": c.ariaLabel, value: c.value ?? "#000000", onChange: (e) => onSet(c.path, e.target.value), className: "h-5 w-8" }),
733
- c.value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
733
+ case "colour": {
734
+ const set = (light, dark) => onSet(c.path, dark === null ? light : { light, dark });
735
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col gap-1", children: [
736
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
737
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
738
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex items-center gap-1", children: [
739
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": c.ariaLabel, title: c.dark !== null ? "On light backgrounds" : void 0, value: c.value ?? "#000000", onChange: (e) => set(e.target.value, c.dark), className: "h-5 w-8" }),
740
+ c.dark !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": `${c.ariaLabel} (dark)`, title: "On dark backgrounds", value: c.dark, onChange: (e) => set(c.value ?? "#000000", e.target.value), className: "h-5 w-8" }),
741
+ (c.value || c.gradient) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
742
+ ] })
743
+ ] }),
744
+ c.gradient ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-[10px] text-slate-500", children: "A gradient (its own paint)." }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex items-center gap-2", children: [
745
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", "aria-label": `${c.ariaLabel}: light and dark`, checked: c.dark !== null, onChange: (e) => set(c.value ?? "#000000", e.target.checked ? c.value ?? "#ffffff" : null) }),
746
+ " Light / dark"
734
747
  ] })
735
748
  ] });
736
- case "palette":
737
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": c.ariaLabel, children: [
749
+ }
750
+ case "palette": {
751
+ const at = (i, entry) => onSet(c.path, c.value.map((x, j) => j === i ? entry : x));
752
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col gap-1", role: "group", "aria-label": c.ariaLabel, children: [
738
753
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
739
- c.value.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", title: `Remove ${col}`, "aria-label": `Remove ${col}`, className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: col }, onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)) }, `${col}-${i}`)),
740
- c.value.length < c.max && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": "Add a palette colour", onChange: (e) => onSet(c.path, [...c.value, e.target.value]), className: "h-4 w-6" })
754
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
755
+ c.value.map((col, i) => {
756
+ const light = typeof col === "string" ? col : col.light;
757
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex items-center gap-0.5 rounded bg-slate-900 p-0.5", children: [
758
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": `Palette colour ${i + 1}`, value: light, onChange: (e) => at(i, typeof col === "string" ? e.target.value : { ...col, light: e.target.value }), className: "h-4 w-5" }),
759
+ typeof col !== "string" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": `Palette colour ${i + 1} (dark)`, value: col.dark, onChange: (e) => at(i, { ...col, dark: e.target.value }), className: "h-4 w-5" }),
760
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-label": `Remove palette colour ${i + 1}`, className: "px-0.5 text-slate-400 hover:text-white", onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)), children: "\xD7" })
761
+ ] }, i);
762
+ }),
763
+ c.value.length < c.max && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
764
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "color", "aria-label": "Add a palette colour", onChange: (e) => onSet(c.path, [...c.value, e.target.value]), className: "h-4 w-6" }),
765
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, onClick: () => onSet(c.path, [...c.value, { light: "#334155", dark: "#e2e8f0" }]), children: "Add light / dark pair" })
766
+ ] })
767
+ ] })
741
768
  ] });
769
+ }
742
770
  case "stamps":
743
771
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": c.ariaLabel, title: `Up to ${c.max}`, children: c.options.map((o) => {
744
772
  const on = c.value.includes(o.value);
@@ -1019,6 +1047,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
1019
1047
  const own = typeof spec.colour?.default === "string" && /^#[0-9a-f]{6}/i.test(spec.colour.default) ? spec.colour.default.slice(0, 7) : void 0;
1020
1048
  const preview = (0, import_react10.useMemo)(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
1021
1049
  const carried = (0, import_paint_editor5.brushLoadColor)(state.mixerLoad);
1050
+ const palette = (spec.colour?.palette ?? []).flatMap((c) => (0, import_brushes3.brushColourHex)(c, state.colorScheme) ?? []);
1022
1051
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
1023
1052
  const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
1024
1053
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
@@ -1041,13 +1070,20 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
1041
1070
  brush.engine === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
1042
1071
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
1043
1072
  ] });
1044
- if (section === "colour" && (0, import_paint_editor5.brushTakesPaint)(brush))
1045
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
1046
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
1047
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-slate-400", title: "A gradient of the brush's own, used instead of the paint (the multi-colour brush)", children: "Brush gradient" }),
1048
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-pressed": brush.paint !== null, className: chip(brush.paint !== null), onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : import_paint_editor5.DEFAULT_PAINT_GRADIENT })), children: brush.paint ? "On" : "Off" })
1073
+ if (section === "colour")
1074
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1075
+ palette.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Paint with a palette colour", children: palette.map((hex, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-label": `Paint with ${hex}`, title: hex, "aria-pressed": state.color === hex, className: `h-5 w-5 rounded ring-1 ${state.color === hex ? "ring-white" : "ring-slate-700"}`, style: { background: hex }, onClick: () => controller.setColor(hex) }, `${hex}-${i}`)) }),
1076
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { className: "flex items-center gap-2", title: "Choosing a brush with a default colour (the highlighter's yellow) makes it your colour unless this is on", children: [
1077
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { type: "checkbox", "aria-label": "Keep my colour", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
1078
+ " Keep my colour when choosing a brush"
1049
1079
  ] }),
1050
- brush.paint && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
1080
+ (0, import_paint_editor5.brushTakesPaint)(brush) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
1081
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
1082
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-slate-400", title: "A gradient of the brush's own, used instead of the paint (the multi-colour brush)", children: "Brush gradient" }),
1083
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-pressed": brush.paint !== null, className: chip(brush.paint !== null), onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : import_paint_editor5.DEFAULT_PAINT_GRADIENT })), children: brush.paint ? "On" : "Off" })
1084
+ ] }),
1085
+ brush.paint && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
1086
+ ] })
1051
1087
  ] });
1052
1088
  return null;
1053
1089
  }
@@ -3965,7 +4001,7 @@ var PAINT_CONTROLS = {
3965
4001
  lighting: '[data-testid="light-panel"]',
3966
4002
  symmetry: '[aria-label="Symmetry"]'
3967
4003
  };
3968
- var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, className, playback, playbackId = "paint", onPlaybackReveal }) => {
4004
+ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
3969
4005
  const [tool, setTool] = (0, import_react29.useState)("brush");
3970
4006
  const [tab, setTab] = (0, import_react29.useState)("color");
3971
4007
  const tabRef = (0, import_react29.useRef)(tab);
@@ -4036,7 +4072,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, cl
4036
4072
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
4037
4073
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
4038
4074
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
4039
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, className: "flex-1 rounded-lg" }),
4075
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
4040
4076
  error && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
4041
4077
  ] }),
4042
4078
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
@@ -87,10 +87,11 @@ import {
87
87
  guideOverlay,
88
88
  handlePaintShortcut,
89
89
  viewCssTransform,
90
+ paintAgentStrokePoints,
90
91
  paintProposalGhost
91
92
  } from "@pixerate/editor/paint-editor";
92
93
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
93
- var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, className }) => {
94
+ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
94
95
  const state = usePaintEditorState(controller);
95
96
  const viewport = useRef2(null);
96
97
  const canvas = useRef2(null);
@@ -228,6 +229,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
228
229
  },
229
230
  i
230
231
  )),
232
+ agentStrokes && /* @__PURE__ */ jsx(PaintAgentStrokeLines, { strokes: agentStrokes }),
231
233
  predicted.length > 0 && /* @__PURE__ */ jsx("polyline", { points: predicted.map((p) => `${p.x},${p.y}`).join(" "), fill: "none", stroke: state.color, strokeOpacity: 0.5, strokeWidth: Math.max(1, state.brush.tip.size / 2), strokeLinecap: "round" })
232
234
  ] }),
233
235
  state.guides.references.filter((r) => r.visible).map((r) => /* @__PURE__ */ jsx(ReferencePanel, { controller, id: r.id }, r.id)),
@@ -334,6 +336,10 @@ var PaintProposalGhost = ({ proposal, transform, zoom }) => {
334
336
  }
335
337
  );
336
338
  };
339
+ var PaintAgentStrokeLines = ({ strokes }) => {
340
+ const { strokes: list } = useSyncExternalStore2(strokes.subscribe, strokes.getState, strokes.getState);
341
+ return /* @__PURE__ */ jsx(Fragment, { children: list.map((s) => /* @__PURE__ */ jsx("polyline", { "data-agent-stroke": s.id, points: paintAgentStrokePoints(s), fill: "none", stroke: s.color, strokeOpacity: s.opacity ?? 0.6, strokeWidth: s.size, strokeLinecap: "round", strokeLinejoin: "round" }, s.id)) });
342
+ };
337
343
 
338
344
  // src/paint-editor/PaintToolbar.tsx
339
345
  import { useRef as useRef4, useState as useState4 } from "react";
@@ -636,12 +642,12 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
636
642
  // src/paint-editor/BrushPanel.tsx
637
643
  import { useMemo as useMemo4, useRef as useRef5 } from "react";
638
644
  import { brushLoadColor, brushTakesPaint, downloadBytes as downloadBytes2, toggleStickerRef, DEFAULT_PAINT_GRADIENT } from "@pixerate/editor/paint-editor";
639
- import { PAINT_PROFILE as PAINT_PROFILE2 } from "@pixerate/editor/brushes";
645
+ import { brushColourHex, PAINT_PROFILE as PAINT_PROFILE2 } from "@pixerate/editor/brushes";
640
646
 
641
647
  // src/paint-editor/BrushEditor.tsx
642
648
  import { useMemo as useMemo3, useState as useState5 } from "react";
643
649
  import { brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
644
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
650
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
645
651
  var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSaveAs, renderExtra, className }) => {
646
652
  const sections = useMemo3(() => brushEditorSections(brush, profile), [brush, profile]);
647
653
  const [problems, setProblems] = useState5(null);
@@ -706,20 +712,43 @@ var EditorControl = ({ control: c, onSet }) => {
706
712
  /* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
707
713
  /* @__PURE__ */ jsx4("input", { "aria-label": c.ariaLabel, defaultValue: c.value, placeholder: c.placeholder, onBlur: (e) => e.target.value !== c.value && onSet(c.path, e.target.value.trim().toLowerCase()), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }, c.value)
708
714
  ] });
709
- case "colour":
710
- return /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
711
- /* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
712
- /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-1", children: [
713
- /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": c.ariaLabel, value: c.value ?? "#000000", onChange: (e) => onSet(c.path, e.target.value), className: "h-5 w-8" }),
714
- c.value && /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
715
+ case "colour": {
716
+ const set = (light, dark) => onSet(c.path, dark === null ? light : { light, dark });
717
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1", children: [
718
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
719
+ /* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
720
+ /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-1", children: [
721
+ /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": c.ariaLabel, title: c.dark !== null ? "On light backgrounds" : void 0, value: c.value ?? "#000000", onChange: (e) => set(e.target.value, c.dark), className: "h-5 w-8" }),
722
+ c.dark !== null && /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `${c.ariaLabel} (dark)`, title: "On dark backgrounds", value: c.dark, onChange: (e) => set(c.value ?? "#000000", e.target.value), className: "h-5 w-8" }),
723
+ (c.value || c.gradient) && /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
724
+ ] })
725
+ ] }),
726
+ c.gradient ? /* @__PURE__ */ jsx4("span", { className: "text-[10px] text-slate-500", children: "A gradient (its own paint)." }) : /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", children: [
727
+ /* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": `${c.ariaLabel}: light and dark`, checked: c.dark !== null, onChange: (e) => set(c.value ?? "#000000", e.target.checked ? c.value ?? "#ffffff" : null) }),
728
+ " Light / dark"
715
729
  ] })
716
730
  ] });
717
- case "palette":
718
- return /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": c.ariaLabel, children: [
731
+ }
732
+ case "palette": {
733
+ const at = (i, entry) => onSet(c.path, c.value.map((x, j) => j === i ? entry : x));
734
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1", role: "group", "aria-label": c.ariaLabel, children: [
719
735
  /* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
720
- c.value.map((col, i) => /* @__PURE__ */ jsx4("button", { type: "button", title: `Remove ${col}`, "aria-label": `Remove ${col}`, className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: col }, onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)) }, `${col}-${i}`)),
721
- c.value.length < c.max && /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": "Add a palette colour", onChange: (e) => onSet(c.path, [...c.value, e.target.value]), className: "h-4 w-6" })
736
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
737
+ c.value.map((col, i) => {
738
+ const light = typeof col === "string" ? col : col.light;
739
+ return /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-0.5 rounded bg-slate-900 p-0.5", children: [
740
+ /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `Palette colour ${i + 1}`, value: light, onChange: (e) => at(i, typeof col === "string" ? e.target.value : { ...col, light: e.target.value }), className: "h-4 w-5" }),
741
+ typeof col !== "string" && /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `Palette colour ${i + 1} (dark)`, value: col.dark, onChange: (e) => at(i, { ...col, dark: e.target.value }), className: "h-4 w-5" }),
742
+ /* @__PURE__ */ jsx4("button", { type: "button", "aria-label": `Remove palette colour ${i + 1}`, className: "px-0.5 text-slate-400 hover:text-white", onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)), children: "\xD7" })
743
+ ] }, i);
744
+ }),
745
+ c.value.length < c.max && /* @__PURE__ */ jsxs4(Fragment3, { children: [
746
+ /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": "Add a palette colour", onChange: (e) => onSet(c.path, [...c.value, e.target.value]), className: "h-4 w-6" }),
747
+ /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, [...c.value, { light: "#334155", dark: "#e2e8f0" }]), children: "Add light / dark pair" })
748
+ ] })
749
+ ] })
722
750
  ] });
751
+ }
723
752
  case "stamps":
724
753
  return /* @__PURE__ */ jsx4("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": c.ariaLabel, title: `Up to ${c.max}`, children: c.options.map((o) => {
725
754
  const on = c.value.includes(o.value);
@@ -757,7 +786,7 @@ var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
757
786
  };
758
787
 
759
788
  // src/paint-editor/BrushPanel.tsx
760
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
789
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
761
790
  var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
762
791
  const state = usePaintEditorState(controller);
763
792
  const [error, attempt] = useAttempt();
@@ -775,6 +804,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
775
804
  const own = typeof spec.colour?.default === "string" && /^#[0-9a-f]{6}/i.test(spec.colour.default) ? spec.colour.default.slice(0, 7) : void 0;
776
805
  const preview = useMemo4(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
777
806
  const carried = brushLoadColor(state.mixerLoad);
807
+ const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
778
808
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
779
809
  const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
780
810
  return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
@@ -797,13 +827,20 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
797
827
  brush.engine === "mixer" && /* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
798
828
  /* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
799
829
  ] });
800
- if (section === "colour" && brushTakesPaint(brush))
801
- return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
802
- /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-2", children: [
803
- /* @__PURE__ */ jsx7("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" }),
804
- /* @__PURE__ */ jsx7("button", { type: "button", "aria-pressed": brush.paint !== null, className: chip(brush.paint !== null), onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : DEFAULT_PAINT_GRADIENT })), children: brush.paint ? "On" : "Off" })
830
+ if (section === "colour")
831
+ return /* @__PURE__ */ jsxs6(Fragment4, { children: [
832
+ palette.length > 0 && /* @__PURE__ */ jsx7("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Paint with a palette colour", children: palette.map((hex, i) => /* @__PURE__ */ jsx7("button", { type: "button", "aria-label": `Paint with ${hex}`, title: hex, "aria-pressed": state.color === hex, className: `h-5 w-5 rounded ring-1 ${state.color === hex ? "ring-white" : "ring-slate-700"}`, style: { background: hex }, onClick: () => controller.setColor(hex) }, `${hex}-${i}`)) }),
833
+ /* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", title: "Choosing a brush with a default colour (the highlighter's yellow) makes it your colour unless this is on", children: [
834
+ /* @__PURE__ */ jsx7("input", { type: "checkbox", "aria-label": "Keep my colour", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
835
+ " Keep my colour when choosing a brush"
805
836
  ] }),
806
- brush.paint && /* @__PURE__ */ jsx7(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
837
+ brushTakesPaint(brush) && /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
838
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-2", children: [
839
+ /* @__PURE__ */ jsx7("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" }),
840
+ /* @__PURE__ */ jsx7("button", { type: "button", "aria-pressed": brush.paint !== null, className: chip(brush.paint !== null), onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : DEFAULT_PAINT_GRADIENT })), children: brush.paint ? "On" : "Off" })
841
+ ] }),
842
+ brush.paint && /* @__PURE__ */ jsx7(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
843
+ ] })
807
844
  ] });
808
845
  return null;
809
846
  }
@@ -1644,7 +1681,7 @@ var PAINT_CONTROLS = {
1644
1681
  lighting: '[data-testid="light-panel"]',
1645
1682
  symmetry: '[aria-label="Symmetry"]'
1646
1683
  };
1647
- var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, className, playback, playbackId = "paint", onPlaybackReveal }) => {
1684
+ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
1648
1685
  const [tool, setTool] = useState10("brush");
1649
1686
  const [tab, setTab] = useState10("color");
1650
1687
  const tabRef = useRef8(tab);
@@ -1715,7 +1752,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, cl
1715
1752
  /* @__PURE__ */ jsxs14("div", { className: "flex min-h-0 flex-1 gap-2", children: [
1716
1753
  /* @__PURE__ */ jsx15(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
1717
1754
  /* @__PURE__ */ jsxs14("div", { className: "flex min-w-0 flex-1 flex-col", children: [
1718
- /* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, className: "flex-1 rounded-lg" }),
1755
+ /* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
1719
1756
  error && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
1720
1757
  ] }),
1721
1758
  /* @__PURE__ */ jsxs14("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.174.0",
3
+ "version": "0.176.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -277,7 +277,7 @@
277
277
  "dependencies": {},
278
278
  "peerDependencies": {
279
279
  "@dagrejs/dagre": "^1.1.8",
280
- "@pixerate/editor": ">=0.256.0 <1.0.0-0",
280
+ "@pixerate/editor": ">=0.258.0 <1.0.0-0",
281
281
  "@tiptap/core": "^2.27.3",
282
282
  "@tiptap/extension-bubble-menu": "^2.27.3",
283
283
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -328,7 +328,7 @@
328
328
  "tsup": "^9.0.0",
329
329
  "typescript": "^5.7.3",
330
330
  "vitest": "^5.0.5",
331
- "@pixerate/editor": "0.256.0"
331
+ "@pixerate/editor": "0.258.0"
332
332
  },
333
333
  "scripts": {
334
334
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",