@pixerate/editor-react 0.174.0 → 0.175.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.
@@ -725,20 +725,43 @@ var EditorControl = ({ control: c, onSet }) => {
725
725
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
726
726
  /* @__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
727
  ] });
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" })
728
+ case "colour": {
729
+ const set = (light, dark) => onSet(c.path, dark === null ? light : { light, dark });
730
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col gap-1", children: [
731
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
732
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-slate-400", children: c.label }),
733
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex items-center gap-1", children: [
734
+ /* @__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" }),
735
+ 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" }),
736
+ (c.value || c.gradient) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
737
+ ] })
738
+ ] }),
739
+ 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: [
740
+ /* @__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) }),
741
+ " Light / dark"
734
742
  ] })
735
743
  ] });
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: [
744
+ }
745
+ case "palette": {
746
+ const at = (i, entry) => onSet(c.path, c.value.map((x, j) => j === i ? entry : x));
747
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col gap-1", role: "group", "aria-label": c.ariaLabel, children: [
738
748
  /* @__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" })
749
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
750
+ c.value.map((col, i) => {
751
+ const light = typeof col === "string" ? col : col.light;
752
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex items-center gap-0.5 rounded bg-slate-900 p-0.5", children: [
753
+ /* @__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" }),
754
+ 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" }),
755
+ /* @__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" })
756
+ ] }, i);
757
+ }),
758
+ c.value.length < c.max && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
759
+ /* @__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" }),
760
+ /* @__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" })
761
+ ] })
762
+ ] })
741
763
  ] });
764
+ }
742
765
  case "stamps":
743
766
  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
767
  const on = c.value.includes(o.value);
@@ -1019,6 +1042,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
1019
1042
  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
1043
  const preview = (0, import_react10.useMemo)(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
1021
1044
  const carried = (0, import_paint_editor5.brushLoadColor)(state.mixerLoad);
1045
+ const palette = (spec.colour?.palette ?? []).flatMap((c) => (0, import_brushes3.brushColourHex)(c, state.colorScheme) ?? []);
1022
1046
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
1023
1047
  const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
1024
1048
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
@@ -1041,13 +1065,20 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
1041
1065
  brush.engine === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
1042
1066
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
1043
1067
  ] });
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" })
1068
+ if (section === "colour")
1069
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1070
+ 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}`)) }),
1071
+ /* @__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: [
1072
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { type: "checkbox", "aria-label": "Keep my colour", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
1073
+ " Keep my colour when choosing a brush"
1049
1074
  ] }),
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 })) })
1075
+ (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: [
1076
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
1077
+ /* @__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" }),
1078
+ /* @__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" })
1079
+ ] }),
1080
+ 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 })) })
1081
+ ] })
1051
1082
  ] });
1052
1083
  return null;
1053
1084
  }
@@ -636,12 +636,12 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
636
636
  // src/paint-editor/BrushPanel.tsx
637
637
  import { useMemo as useMemo4, useRef as useRef5 } from "react";
638
638
  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";
639
+ import { brushColourHex, PAINT_PROFILE as PAINT_PROFILE2 } from "@pixerate/editor/brushes";
640
640
 
641
641
  // src/paint-editor/BrushEditor.tsx
642
642
  import { useMemo as useMemo3, useState as useState5 } from "react";
643
643
  import { brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
644
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
644
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
645
645
  var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSaveAs, renderExtra, className }) => {
646
646
  const sections = useMemo3(() => brushEditorSections(brush, profile), [brush, profile]);
647
647
  const [problems, setProblems] = useState5(null);
@@ -706,20 +706,43 @@ var EditorControl = ({ control: c, onSet }) => {
706
706
  /* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
707
707
  /* @__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
708
  ] });
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" })
709
+ case "colour": {
710
+ const set = (light, dark) => onSet(c.path, dark === null ? light : { light, dark });
711
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1", children: [
712
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
713
+ /* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
714
+ /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-1", children: [
715
+ /* @__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" }),
716
+ 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" }),
717
+ (c.value || c.gradient) && /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
718
+ ] })
719
+ ] }),
720
+ 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: [
721
+ /* @__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) }),
722
+ " Light / dark"
715
723
  ] })
716
724
  ] });
717
- case "palette":
718
- return /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": c.ariaLabel, children: [
725
+ }
726
+ case "palette": {
727
+ const at = (i, entry) => onSet(c.path, c.value.map((x, j) => j === i ? entry : x));
728
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1", role: "group", "aria-label": c.ariaLabel, children: [
719
729
  /* @__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" })
730
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
731
+ c.value.map((col, i) => {
732
+ const light = typeof col === "string" ? col : col.light;
733
+ return /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-0.5 rounded bg-slate-900 p-0.5", children: [
734
+ /* @__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" }),
735
+ 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" }),
736
+ /* @__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" })
737
+ ] }, i);
738
+ }),
739
+ c.value.length < c.max && /* @__PURE__ */ jsxs4(Fragment3, { children: [
740
+ /* @__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" }),
741
+ /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, [...c.value, { light: "#334155", dark: "#e2e8f0" }]), children: "Add light / dark pair" })
742
+ ] })
743
+ ] })
722
744
  ] });
745
+ }
723
746
  case "stamps":
724
747
  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
748
  const on = c.value.includes(o.value);
@@ -757,7 +780,7 @@ var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
757
780
  };
758
781
 
759
782
  // src/paint-editor/BrushPanel.tsx
760
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
783
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
761
784
  var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
762
785
  const state = usePaintEditorState(controller);
763
786
  const [error, attempt] = useAttempt();
@@ -775,6 +798,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
775
798
  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
799
  const preview = useMemo4(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
777
800
  const carried = brushLoadColor(state.mixerLoad);
801
+ const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
778
802
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
779
803
  const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
780
804
  return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
@@ -797,13 +821,20 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
797
821
  brush.engine === "mixer" && /* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
798
822
  /* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
799
823
  ] });
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" })
824
+ if (section === "colour")
825
+ return /* @__PURE__ */ jsxs6(Fragment4, { children: [
826
+ 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}`)) }),
827
+ /* @__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: [
828
+ /* @__PURE__ */ jsx7("input", { type: "checkbox", "aria-label": "Keep my colour", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
829
+ " Keep my colour when choosing a brush"
805
830
  ] }),
806
- brush.paint && /* @__PURE__ */ jsx7(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
831
+ brushTakesPaint(brush) && /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
832
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-2", children: [
833
+ /* @__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" }),
834
+ /* @__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" })
835
+ ] }),
836
+ brush.paint && /* @__PURE__ */ jsx7(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
837
+ ] })
807
838
  ] });
808
839
  return null;
809
840
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.174.0",
3
+ "version": "0.175.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.257.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.257.0"
332
332
  },
333
333
  "scripts": {
334
334
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",