@pixerate/editor-react 0.181.0 → 0.183.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/animation-editor/index.cjs +128 -4
- package/dist/animation-editor/index.js +128 -4
- package/dist/brushes/BrushEditor.d.cts +8 -1
- package/dist/brushes/BrushEditor.d.ts +8 -1
- package/dist/brushes/BrushLibraryEditor.d.cts +1 -1
- package/dist/brushes/BrushLibraryEditor.d.ts +1 -1
- package/dist/brushes/index.cjs +57 -5
- package/dist/brushes/index.js +2 -2
- package/dist/canvas/index.cjs +8 -2
- package/dist/canvas/index.js +8 -2
- package/dist/canvas/useCanvasDraw.d.cts +9 -1
- package/dist/canvas/useCanvasDraw.d.ts +9 -1
- package/dist/{chunk-THMOZMEE.js → chunk-2QXGKOVK.js} +16 -3
- package/dist/{chunk-WCSMREA4.js → chunk-BICTULEJ.js} +2 -2
- package/dist/{chunk-XORL5PGL.js → chunk-GUBRH2OO.js} +34 -5
- package/dist/image-editor/index.cjs +47 -5
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +47 -5
- package/dist/index.js +3 -3
- package/dist/paint-editor/BrushPanel.d.cts +2 -1
- package/dist/paint-editor/BrushPanel.d.ts +2 -1
- package/dist/paint-editor/index.cjs +35 -4
- package/dist/paint-editor/index.js +4 -2
- package/dist/vector/index.cjs +53 -6
- package/dist/vector/index.js +8 -3
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
|
|
1
|
+
import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushChoice, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
|
|
2
2
|
export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
|
|
3
3
|
nodes: TNode[];
|
|
4
4
|
setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
|
|
@@ -11,6 +11,8 @@ export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
|
|
|
11
11
|
brushLibrary?: CanvasDrawControllerOptions<TNode>['brushLibrary'];
|
|
12
12
|
/** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
|
|
13
13
|
colorScheme?: 'light' | 'dark';
|
|
14
|
+
/** Start with the colour locked ("Keep my colour"); change it with `setColorLocked`. */
|
|
15
|
+
initialColorLocked?: boolean;
|
|
14
16
|
onStrokeComplete?: (node: TNode) => void;
|
|
15
17
|
onNodesErase?: (erasedNodes: TNode[]) => void;
|
|
16
18
|
}
|
|
@@ -19,6 +21,8 @@ export interface CanvasDrawState {
|
|
|
19
21
|
style: FreehandStrokeStyle;
|
|
20
22
|
activeStroke: FreehandStroke | null;
|
|
21
23
|
isDrawing: boolean;
|
|
24
|
+
/** "Keep my colour": choosing a brush keeps the stroke colour. */
|
|
25
|
+
colorLocked: boolean;
|
|
22
26
|
}
|
|
23
27
|
export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
|
|
24
28
|
setTool: (tool: FreehandTool) => void;
|
|
@@ -47,6 +51,10 @@ export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
|
|
|
47
51
|
selectBrush: (id: string | null, choice?: {
|
|
48
52
|
keepColour?: boolean;
|
|
49
53
|
}) => Promise<CanvasBrushPreset | null>;
|
|
54
|
+
/** Locks the stroke colour ("Keep my colour"): `selectBrush` then keeps it. */
|
|
55
|
+
setColorLocked: (locked: boolean) => void;
|
|
56
|
+
/** What the brush picker is set to (brush, colour, scheme, lock), read now; `canvas.selectBrush` returns it. */
|
|
57
|
+
brushSettings: () => CanvasBrushChoice;
|
|
50
58
|
}
|
|
51
59
|
export type CanvasDraw<TNode extends CanvasNode = CanvasNode> = CanvasDrawState & CanvasDrawActions<TNode>;
|
|
52
60
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
|
|
1
|
+
import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushChoice, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
|
|
2
2
|
export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
|
|
3
3
|
nodes: TNode[];
|
|
4
4
|
setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
|
|
@@ -11,6 +11,8 @@ export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
|
|
|
11
11
|
brushLibrary?: CanvasDrawControllerOptions<TNode>['brushLibrary'];
|
|
12
12
|
/** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
|
|
13
13
|
colorScheme?: 'light' | 'dark';
|
|
14
|
+
/** Start with the colour locked ("Keep my colour"); change it with `setColorLocked`. */
|
|
15
|
+
initialColorLocked?: boolean;
|
|
14
16
|
onStrokeComplete?: (node: TNode) => void;
|
|
15
17
|
onNodesErase?: (erasedNodes: TNode[]) => void;
|
|
16
18
|
}
|
|
@@ -19,6 +21,8 @@ export interface CanvasDrawState {
|
|
|
19
21
|
style: FreehandStrokeStyle;
|
|
20
22
|
activeStroke: FreehandStroke | null;
|
|
21
23
|
isDrawing: boolean;
|
|
24
|
+
/** "Keep my colour": choosing a brush keeps the stroke colour. */
|
|
25
|
+
colorLocked: boolean;
|
|
22
26
|
}
|
|
23
27
|
export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
|
|
24
28
|
setTool: (tool: FreehandTool) => void;
|
|
@@ -47,6 +51,10 @@ export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
|
|
|
47
51
|
selectBrush: (id: string | null, choice?: {
|
|
48
52
|
keepColour?: boolean;
|
|
49
53
|
}) => Promise<CanvasBrushPreset | null>;
|
|
54
|
+
/** Locks the stroke colour ("Keep my colour"): `selectBrush` then keeps it. */
|
|
55
|
+
setColorLocked: (locked: boolean) => void;
|
|
56
|
+
/** What the brush picker is set to (brush, colour, scheme, lock), read now; `canvas.selectBrush` returns it. */
|
|
57
|
+
brushSettings: () => CanvasBrushChoice;
|
|
50
58
|
}
|
|
51
59
|
export type CanvasDraw<TNode extends CanvasNode = CanvasNode> = CanvasDrawState & CanvasDrawActions<TNode>;
|
|
52
60
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrushEditor,
|
|
3
3
|
button
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GUBRH2OO.js";
|
|
5
5
|
|
|
6
6
|
// src/brushes/BrushLibraryEditor.tsx
|
|
7
7
|
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { brushPreviewColours, checkBrushEdit, newBrushFor, saveBrushEdit } from "@pixerate/editor/brushes";
|
|
8
|
+
import { addBrushSourceFromFile, brushPreviewColours, checkBrushEdit, newBrushFor, saveBrushEdit } from "@pixerate/editor/brushes";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
11
11
|
const [original, setOriginal] = useState(null);
|
|
@@ -13,6 +13,17 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
13
13
|
const [draft, setDraft] = useState(null);
|
|
14
14
|
const [status, setStatus] = useState(null);
|
|
15
15
|
const [preview, setPreview] = useState(null);
|
|
16
|
+
const [sources, setSources] = useState([]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
let live = true;
|
|
19
|
+
const read = () => void library.listSources().then((list) => live && setSources(list), () => void 0);
|
|
20
|
+
read();
|
|
21
|
+
const off = library.subscribe(read);
|
|
22
|
+
return () => {
|
|
23
|
+
live = false;
|
|
24
|
+
off();
|
|
25
|
+
};
|
|
26
|
+
}, [library]);
|
|
16
27
|
useEffect(() => {
|
|
17
28
|
let live = true;
|
|
18
29
|
setStatus(null);
|
|
@@ -84,7 +95,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
84
95
|
},
|
|
85
96
|
onSave: original ? () => save() : void 0,
|
|
86
97
|
saveLabel: builtin ? "Save a copy" : "Save",
|
|
87
|
-
onSaveAs: (name) => save(name)
|
|
98
|
+
onSaveAs: (name) => save(name),
|
|
99
|
+
sources,
|
|
100
|
+
onAddSource: async (file) => (await addBrushSourceFromFile(library, file)).ref
|
|
88
101
|
}
|
|
89
102
|
),
|
|
90
103
|
errors.length > 0 && /* @__PURE__ */ jsx("ul", { className: "text-[11px] text-rose-400", "data-testid": "brush-library-editor-issues", children: errors.map((i) => /* @__PURE__ */ jsxs("li", { children: [
|
|
@@ -44,10 +44,10 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
BrushLibraryEditor,
|
|
46
46
|
useBrushLibrary
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-2QXGKOVK.js";
|
|
48
48
|
import {
|
|
49
49
|
BrushLibraryBrowser
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-GUBRH2OO.js";
|
|
51
51
|
|
|
52
52
|
// src/image-editor/useImageEditor.ts
|
|
53
53
|
import { useRef, useState, useEffect, useCallback, useMemo } from "react";
|
|
@@ -140,11 +140,11 @@ var CommitColorInput = ({ value, label, onCommit, className }) => {
|
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
// src/brushes/BrushEditor.tsx
|
|
143
|
-
import { useMemo as useMemo2, useState as useState3 } from "react";
|
|
144
|
-
import { brushEditorScope, brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
|
|
143
|
+
import React3, { useMemo as useMemo2, useState as useState3 } from "react";
|
|
144
|
+
import { brushEditorScope, brushEditorSections, PAINT_PROFILE, setBrushEditorValue, withBrushSource } from "@pixerate/editor/brushes";
|
|
145
145
|
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
146
|
-
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
147
|
-
const sections = useMemo2(() => brushEditorSections(brush, profile), [brush, profile]);
|
|
146
|
+
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
|
|
147
|
+
const sections = useMemo2(() => brushEditorSections(brush, profile, { sources }), [brush, profile, sources]);
|
|
148
148
|
const scope = useMemo2(() => brushEditorScope(brush, profile), [brush, profile]);
|
|
149
149
|
const [problems, setProblems] = useState3(null);
|
|
150
150
|
const [name, setName] = useState3("");
|
|
@@ -162,12 +162,24 @@ var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, previewB
|
|
|
162
162
|
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
163
163
|
if (r.brush !== brush) onChange(r.brush);
|
|
164
164
|
};
|
|
165
|
+
const addSource = onAddSource ? async (file, as) => {
|
|
166
|
+
try {
|
|
167
|
+
const r = withBrushSource(brush, await onAddSource(file), as);
|
|
168
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
169
|
+
onChange(r.brush);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
setProblems(e.message);
|
|
172
|
+
}
|
|
173
|
+
} : void 0;
|
|
165
174
|
return /* @__PURE__ */ jsxs3("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
166
175
|
typeof preview === "string" ? /* @__PURE__ */ jsx3("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ jsx3(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
167
176
|
scope.note && /* @__PURE__ */ jsx3("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
168
177
|
sections.map((s) => /* @__PURE__ */ jsxs3("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
169
178
|
/* @__PURE__ */ jsx3("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
170
|
-
s.controls.map((c) => /* @__PURE__ */
|
|
179
|
+
s.controls.map((c) => /* @__PURE__ */ jsxs3(React3.Fragment, { children: [
|
|
180
|
+
/* @__PURE__ */ jsx3(EditorControl, { control: c, onSet: set }),
|
|
181
|
+
addSource && (c.path === "tip.stamps" || c.path === "tip.grain.source") && /* @__PURE__ */ jsx3(AddImage, { label: c.path === "tip.stamps" ? "Add image tip\u2026" : "Add grain image\u2026", onFile: (f) => addSource(f, c.path === "tip.stamps" ? "tip" : "grain") })
|
|
182
|
+
] }, c.path)),
|
|
171
183
|
renderExtra?.(s.id)
|
|
172
184
|
] }, s.id)),
|
|
173
185
|
(onSave || onSaveAs) && /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
@@ -180,6 +192,23 @@ var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, previewB
|
|
|
180
192
|
/* @__PURE__ */ jsx3(ErrorLine, { error: problems })
|
|
181
193
|
] });
|
|
182
194
|
};
|
|
195
|
+
var AddImage = ({ label, onFile }) => /* @__PURE__ */ jsxs3("label", { className: `${button} cursor-pointer self-start`, children: [
|
|
196
|
+
label,
|
|
197
|
+
/* @__PURE__ */ jsx3(
|
|
198
|
+
"input",
|
|
199
|
+
{
|
|
200
|
+
type: "file",
|
|
201
|
+
accept: "image/*",
|
|
202
|
+
"aria-label": label,
|
|
203
|
+
className: "sr-only",
|
|
204
|
+
onChange: (e) => {
|
|
205
|
+
const file = e.target.files?.[0];
|
|
206
|
+
e.target.value = "";
|
|
207
|
+
if (file) onFile(file);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
] });
|
|
183
212
|
var EditorControl = ({ control: c, onSet }) => {
|
|
184
213
|
const note = c.note ? /* @__PURE__ */ jsx3("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
185
214
|
switch (c.kind) {
|
|
@@ -4710,11 +4710,11 @@ var PaintSlider = ({ control, value, onChange, onCommit }) => {
|
|
|
4710
4710
|
var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: error }) : null;
|
|
4711
4711
|
|
|
4712
4712
|
// src/brushes/BrushEditor.tsx
|
|
4713
|
-
var import_react27 = require("react");
|
|
4713
|
+
var import_react27 = __toESM(require("react"), 1);
|
|
4714
4714
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
4715
4715
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4716
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
4717
|
-
const sections = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
4716
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
|
|
4717
|
+
const sections = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
|
|
4718
4718
|
const scope = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
4719
4719
|
const [problems, setProblems] = (0, import_react27.useState)(null);
|
|
4720
4720
|
const [name, setName] = (0, import_react27.useState)("");
|
|
@@ -4732,12 +4732,24 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
4732
4732
|
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
4733
4733
|
if (r.brush !== brush) onChange(r.brush);
|
|
4734
4734
|
};
|
|
4735
|
+
const addSource = onAddSource ? async (file, as) => {
|
|
4736
|
+
try {
|
|
4737
|
+
const r = (0, import_brushes2.withBrushSource)(brush, await onAddSource(file), as);
|
|
4738
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
4739
|
+
onChange(r.brush);
|
|
4740
|
+
} catch (e) {
|
|
4741
|
+
setProblems(e.message);
|
|
4742
|
+
}
|
|
4743
|
+
} : void 0;
|
|
4735
4744
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
4736
4745
|
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
4737
4746
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
4738
4747
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
4739
4748
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
4740
|
-
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.
|
|
4749
|
+
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_react27.default.Fragment, { children: [
|
|
4750
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EditorControl, { control: c, onSet: set }),
|
|
4751
|
+
addSource && (c.path === "tip.stamps" || c.path === "tip.grain.source") && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AddImage, { label: c.path === "tip.stamps" ? "Add image tip\u2026" : "Add grain image\u2026", onFile: (f) => addSource(f, c.path === "tip.stamps" ? "tip" : "grain") })
|
|
4752
|
+
] }, c.path)),
|
|
4741
4753
|
renderExtra?.(s.id)
|
|
4742
4754
|
] }, s.id)),
|
|
4743
4755
|
(onSave || onSaveAs) && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
@@ -4750,6 +4762,23 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
4750
4762
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ErrorLine, { error: problems })
|
|
4751
4763
|
] });
|
|
4752
4764
|
};
|
|
4765
|
+
var AddImage = ({ label, onFile }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: `${button2} cursor-pointer self-start`, children: [
|
|
4766
|
+
label,
|
|
4767
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4768
|
+
"input",
|
|
4769
|
+
{
|
|
4770
|
+
type: "file",
|
|
4771
|
+
accept: "image/*",
|
|
4772
|
+
"aria-label": label,
|
|
4773
|
+
className: "sr-only",
|
|
4774
|
+
onChange: (e) => {
|
|
4775
|
+
const file = e.target.files?.[0];
|
|
4776
|
+
e.target.value = "";
|
|
4777
|
+
if (file) onFile(file);
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
)
|
|
4781
|
+
] });
|
|
4753
4782
|
var EditorControl = ({ control: c, onSet }) => {
|
|
4754
4783
|
const note = c.note ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
4755
4784
|
switch (c.kind) {
|
|
@@ -4827,6 +4856,17 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
4827
4856
|
const [draft, setDraft] = (0, import_react28.useState)(null);
|
|
4828
4857
|
const [status, setStatus] = (0, import_react28.useState)(null);
|
|
4829
4858
|
const [preview, setPreview] = (0, import_react28.useState)(null);
|
|
4859
|
+
const [sources, setSources] = (0, import_react28.useState)([]);
|
|
4860
|
+
(0, import_react28.useEffect)(() => {
|
|
4861
|
+
let live = true;
|
|
4862
|
+
const read = () => void library.listSources().then((list) => live && setSources(list), () => void 0);
|
|
4863
|
+
read();
|
|
4864
|
+
const off = library.subscribe(read);
|
|
4865
|
+
return () => {
|
|
4866
|
+
live = false;
|
|
4867
|
+
off();
|
|
4868
|
+
};
|
|
4869
|
+
}, [library]);
|
|
4830
4870
|
(0, import_react28.useEffect)(() => {
|
|
4831
4871
|
let live = true;
|
|
4832
4872
|
setStatus(null);
|
|
@@ -4898,7 +4938,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
4898
4938
|
},
|
|
4899
4939
|
onSave: original ? () => save() : void 0,
|
|
4900
4940
|
saveLabel: builtin ? "Save a copy" : "Save",
|
|
4901
|
-
onSaveAs: (name) => save(name)
|
|
4941
|
+
onSaveAs: (name) => save(name),
|
|
4942
|
+
sources,
|
|
4943
|
+
onAddSource: async (file) => (await (0, import_brushes3.addBrushSourceFromFile)(library, file)).ref
|
|
4902
4944
|
}
|
|
4903
4945
|
),
|
|
4904
4946
|
errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "text-[11px] text-rose-400", "data-testid": "brush-library-editor-issues", children: errors.map((i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("li", { children: [
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
useImageEditor,
|
|
30
30
|
useImageEffectsTools,
|
|
31
31
|
useImageHistogram
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-BICTULEJ.js";
|
|
33
33
|
import {
|
|
34
34
|
ImageCheckbox,
|
|
35
35
|
ImageColor,
|
|
@@ -44,8 +44,8 @@ import "../chunk-5RPB4WGT.js";
|
|
|
44
44
|
import "../chunk-KIRIU53A.js";
|
|
45
45
|
import "../chunk-3I7FOSLF.js";
|
|
46
46
|
import "../chunk-W5CMGX3I.js";
|
|
47
|
-
import "../chunk-
|
|
48
|
-
import "../chunk-
|
|
47
|
+
import "../chunk-2QXGKOVK.js";
|
|
48
|
+
import "../chunk-GUBRH2OO.js";
|
|
49
49
|
export {
|
|
50
50
|
AdjustmentLayersPanel,
|
|
51
51
|
BrushOptionsBar,
|
package/dist/index.cjs
CHANGED
|
@@ -8474,11 +8474,11 @@ var PaintSlider = ({ control, value, onChange, onCommit }) => {
|
|
|
8474
8474
|
var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: error }) : null;
|
|
8475
8475
|
|
|
8476
8476
|
// src/brushes/BrushEditor.tsx
|
|
8477
|
-
var import_react63 = require("react");
|
|
8477
|
+
var import_react63 = __toESM(require("react"), 1);
|
|
8478
8478
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
8479
8479
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8480
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
8481
|
-
const sections = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
8480
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
|
|
8481
|
+
const sections = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
|
|
8482
8482
|
const scope = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
8483
8483
|
const [problems, setProblems] = (0, import_react63.useState)(null);
|
|
8484
8484
|
const [name, setName] = (0, import_react63.useState)("");
|
|
@@ -8496,12 +8496,24 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
8496
8496
|
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
8497
8497
|
if (r.brush !== brush) onChange(r.brush);
|
|
8498
8498
|
};
|
|
8499
|
+
const addSource = onAddSource ? async (file, as) => {
|
|
8500
|
+
try {
|
|
8501
|
+
const r = (0, import_brushes2.withBrushSource)(brush, await onAddSource(file), as);
|
|
8502
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
8503
|
+
onChange(r.brush);
|
|
8504
|
+
} catch (e) {
|
|
8505
|
+
setProblems(e.message);
|
|
8506
|
+
}
|
|
8507
|
+
} : void 0;
|
|
8499
8508
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
8500
8509
|
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
8501
8510
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
8502
8511
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
8503
8512
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
8504
|
-
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime44.
|
|
8513
|
+
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_react63.default.Fragment, { children: [
|
|
8514
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(EditorControl, { control: c, onSet: set }),
|
|
8515
|
+
addSource && (c.path === "tip.stamps" || c.path === "tip.grain.source") && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AddImage, { label: c.path === "tip.stamps" ? "Add image tip\u2026" : "Add grain image\u2026", onFile: (f) => addSource(f, c.path === "tip.stamps" ? "tip" : "grain") })
|
|
8516
|
+
] }, c.path)),
|
|
8505
8517
|
renderExtra?.(s.id)
|
|
8506
8518
|
] }, s.id)),
|
|
8507
8519
|
(onSave || onSaveAs) && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
@@ -8514,6 +8526,23 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
8514
8526
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ErrorLine, { error: problems })
|
|
8515
8527
|
] });
|
|
8516
8528
|
};
|
|
8529
|
+
var AddImage = ({ label, onFile }) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: `${button2} cursor-pointer self-start`, children: [
|
|
8530
|
+
label,
|
|
8531
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8532
|
+
"input",
|
|
8533
|
+
{
|
|
8534
|
+
type: "file",
|
|
8535
|
+
accept: "image/*",
|
|
8536
|
+
"aria-label": label,
|
|
8537
|
+
className: "sr-only",
|
|
8538
|
+
onChange: (e) => {
|
|
8539
|
+
const file = e.target.files?.[0];
|
|
8540
|
+
e.target.value = "";
|
|
8541
|
+
if (file) onFile(file);
|
|
8542
|
+
}
|
|
8543
|
+
}
|
|
8544
|
+
)
|
|
8545
|
+
] });
|
|
8517
8546
|
var EditorControl = ({ control: c, onSet }) => {
|
|
8518
8547
|
const note = c.note ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
8519
8548
|
switch (c.kind) {
|
|
@@ -8591,6 +8620,17 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
8591
8620
|
const [draft, setDraft] = (0, import_react64.useState)(null);
|
|
8592
8621
|
const [status, setStatus] = (0, import_react64.useState)(null);
|
|
8593
8622
|
const [preview, setPreview] = (0, import_react64.useState)(null);
|
|
8623
|
+
const [sources, setSources] = (0, import_react64.useState)([]);
|
|
8624
|
+
(0, import_react64.useEffect)(() => {
|
|
8625
|
+
let live = true;
|
|
8626
|
+
const read = () => void library.listSources().then((list) => live && setSources(list), () => void 0);
|
|
8627
|
+
read();
|
|
8628
|
+
const off = library.subscribe(read);
|
|
8629
|
+
return () => {
|
|
8630
|
+
live = false;
|
|
8631
|
+
off();
|
|
8632
|
+
};
|
|
8633
|
+
}, [library]);
|
|
8594
8634
|
(0, import_react64.useEffect)(() => {
|
|
8595
8635
|
let live = true;
|
|
8596
8636
|
setStatus(null);
|
|
@@ -8662,7 +8702,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
8662
8702
|
},
|
|
8663
8703
|
onSave: original ? () => save() : void 0,
|
|
8664
8704
|
saveLabel: builtin ? "Save a copy" : "Save",
|
|
8665
|
-
onSaveAs: (name) => save(name)
|
|
8705
|
+
onSaveAs: (name) => save(name),
|
|
8706
|
+
sources,
|
|
8707
|
+
onAddSource: async (file) => (await (0, import_brushes3.addBrushSourceFromFile)(library, file)).ref
|
|
8666
8708
|
}
|
|
8667
8709
|
),
|
|
8668
8710
|
errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("ul", { className: "text-[11px] text-rose-400", "data-testid": "brush-library-editor-issues", children: errors.map((i) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("li", { children: [
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
useImageEditor,
|
|
63
63
|
useImageEffectsTools,
|
|
64
64
|
useImageHistogram
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-BICTULEJ.js";
|
|
66
66
|
import {
|
|
67
67
|
ImageCheckbox,
|
|
68
68
|
ImageColor,
|
|
@@ -82,8 +82,8 @@ import {
|
|
|
82
82
|
useAgentPlayback,
|
|
83
83
|
usePlaybackSurface
|
|
84
84
|
} from "./chunk-W5CMGX3I.js";
|
|
85
|
-
import "./chunk-
|
|
86
|
-
import "./chunk-
|
|
85
|
+
import "./chunk-2QXGKOVK.js";
|
|
86
|
+
import "./chunk-GUBRH2OO.js";
|
|
87
87
|
import {
|
|
88
88
|
CommandPalette,
|
|
89
89
|
useCommandPalette,
|
|
@@ -12,6 +12,7 @@ export interface BrushPanelProps {
|
|
|
12
12
|
* grouped by medium and variety, tools apart) and the active brush in the `BrushEditor`: its
|
|
13
13
|
* facets with a live preview, and "Save brush" into the editor's brush library. The paint
|
|
14
14
|
* editor adds the brush's own gradient, the sticker stamps, what the brush carries (Load /
|
|
15
|
-
* Clean), and import and export of library files.
|
|
15
|
+
* Clean), and import and export of library files. Images picked for an image tip or grain are
|
|
16
|
+
* added to the brush library as sources.
|
|
16
17
|
*/
|
|
17
18
|
export declare const BrushPanel: React.FC<BrushPanelProps>;
|
|
@@ -12,6 +12,7 @@ export interface BrushPanelProps {
|
|
|
12
12
|
* grouped by medium and variety, tools apart) and the active brush in the `BrushEditor`: its
|
|
13
13
|
* facets with a live preview, and "Save brush" into the editor's brush library. The paint
|
|
14
14
|
* editor adds the brush's own gradient, the sticker stamps, what the brush carries (Load /
|
|
15
|
-
* Clean), and import and export of library files.
|
|
15
|
+
* Clean), and import and export of library files. Images picked for an image tip or grain are
|
|
16
|
+
* added to the brush library as sources.
|
|
16
17
|
*/
|
|
17
18
|
export declare const BrushPanel: React.FC<BrushPanelProps>;
|
|
@@ -664,11 +664,11 @@ var import_paint_editor5 = require("@pixerate/editor/paint-editor");
|
|
|
664
664
|
var import_brushes3 = require("@pixerate/editor/brushes");
|
|
665
665
|
|
|
666
666
|
// src/brushes/BrushEditor.tsx
|
|
667
|
-
var import_react5 = require("react");
|
|
667
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
668
668
|
var import_brushes = require("@pixerate/editor/brushes");
|
|
669
669
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
670
|
-
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
671
|
-
const sections = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
670
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
|
|
671
|
+
const sections = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
|
|
672
672
|
const scope = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
673
673
|
const [problems, setProblems] = (0, import_react5.useState)(null);
|
|
674
674
|
const [name, setName] = (0, import_react5.useState)("");
|
|
@@ -686,12 +686,24 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
686
686
|
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
687
687
|
if (r.brush !== brush) onChange(r.brush);
|
|
688
688
|
};
|
|
689
|
+
const addSource = onAddSource ? async (file, as) => {
|
|
690
|
+
try {
|
|
691
|
+
const r = (0, import_brushes.withBrushSource)(brush, await onAddSource(file), as);
|
|
692
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
693
|
+
onChange(r.brush);
|
|
694
|
+
} catch (e) {
|
|
695
|
+
setProblems(e.message);
|
|
696
|
+
}
|
|
697
|
+
} : void 0;
|
|
689
698
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
690
699
|
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
691
700
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
692
701
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
693
702
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
694
|
-
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.
|
|
703
|
+
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react5.default.Fragment, { children: [
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EditorControl, { control: c, onSet: set }),
|
|
705
|
+
addSource && (c.path === "tip.stamps" || c.path === "tip.grain.source") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AddImage, { label: c.path === "tip.stamps" ? "Add image tip\u2026" : "Add grain image\u2026", onFile: (f) => addSource(f, c.path === "tip.stamps" ? "tip" : "grain") })
|
|
706
|
+
] }, c.path)),
|
|
695
707
|
renderExtra?.(s.id)
|
|
696
708
|
] }, s.id)),
|
|
697
709
|
(onSave || onSaveAs) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
@@ -704,6 +716,23 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
704
716
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorLine, { error: problems })
|
|
705
717
|
] });
|
|
706
718
|
};
|
|
719
|
+
var AddImage = ({ label, onFile }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: `${button} cursor-pointer self-start`, children: [
|
|
720
|
+
label,
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
722
|
+
"input",
|
|
723
|
+
{
|
|
724
|
+
type: "file",
|
|
725
|
+
accept: "image/*",
|
|
726
|
+
"aria-label": label,
|
|
727
|
+
className: "sr-only",
|
|
728
|
+
onChange: (e) => {
|
|
729
|
+
const file = e.target.files?.[0];
|
|
730
|
+
e.target.value = "";
|
|
731
|
+
if (file) onFile(file);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
)
|
|
735
|
+
] });
|
|
707
736
|
var EditorControl = ({ control: c, onSet }) => {
|
|
708
737
|
const note = c.note ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
709
738
|
switch (c.kind) {
|
|
@@ -1070,6 +1099,8 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
1070
1099
|
preview,
|
|
1071
1100
|
onChange: (next) => attempt(() => controller.setBrushSpec(next)),
|
|
1072
1101
|
onSaveAs: (name) => controller.saveBrush({ id: slug(name), name }),
|
|
1102
|
+
sources: controller.brushSources.all(),
|
|
1103
|
+
onAddSource: async (file) => (await (0, import_brushes3.addBrushSourceFromFile)(controller.brushLibrary, file)).ref,
|
|
1073
1104
|
renderExtra: (section) => {
|
|
1074
1105
|
if (section === "shape" && brush.engine === "sticker")
|
|
1075
1106
|
return /* @__PURE__ */ (0, import_jsx_runtime10.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) } }) });
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
chip,
|
|
30
30
|
panel,
|
|
31
31
|
useAttempt
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-GUBRH2OO.js";
|
|
33
33
|
|
|
34
34
|
// src/paint-editor/usePaintEditor.ts
|
|
35
35
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -559,7 +559,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
559
559
|
// src/paint-editor/BrushPanel.tsx
|
|
560
560
|
import { useMemo as useMemo3, useRef as useRef4 } from "react";
|
|
561
561
|
import { brushLoadColor, brushTakesPaint, downloadBytes as downloadBytes2, toggleStickerRef, DEFAULT_PAINT_GRADIENT } from "@pixerate/editor/paint-editor";
|
|
562
|
-
import { brushColourHex, brushPreviewColours, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
562
|
+
import { addBrushSourceFromFile, brushColourHex, brushPreviewColours, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
563
563
|
|
|
564
564
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
565
565
|
import { PAINT_GRADIENT_KIT } from "@pixerate/editor/paint-editor";
|
|
@@ -622,6 +622,8 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
622
622
|
preview,
|
|
623
623
|
onChange: (next) => attempt(() => controller.setBrushSpec(next)),
|
|
624
624
|
onSaveAs: (name) => controller.saveBrush({ id: slug(name), name }),
|
|
625
|
+
sources: controller.brushSources.all(),
|
|
626
|
+
onAddSource: async (file) => (await addBrushSourceFromFile(controller.brushLibrary, file)).ref,
|
|
625
627
|
renderExtra: (section) => {
|
|
626
628
|
if (section === "shape" && brush.engine === "sticker")
|
|
627
629
|
return /* @__PURE__ */ jsx5(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) });
|