@pixerate/editor-react 0.179.0 → 0.180.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/{paint-editor → brushes}/BrushEditor.d.cts +14 -5
- package/dist/{paint-editor → brushes}/BrushEditor.d.ts +14 -5
- package/dist/brushes/BrushLibraryEditor.d.cts +26 -0
- package/dist/brushes/BrushLibraryEditor.d.ts +26 -0
- package/dist/brushes/index.cjs +289 -20
- package/dist/brushes/index.d.cts +2 -0
- package/dist/brushes/index.d.ts +2 -0
- package/dist/brushes/index.js +6 -2
- package/dist/chunk-76JBZXLM.js +263 -0
- package/dist/chunk-QIJJCDYW.js +119 -0
- package/dist/{chunk-UR4KL7WE.js → chunk-XAPJMT3W.js} +26 -6
- package/dist/image-editor/BrushOptionsBar.d.cts +6 -1
- package/dist/image-editor/BrushOptionsBar.d.ts +6 -1
- package/dist/image-editor/index.cjs +1178 -894
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1719 -1435
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +20 -23
- package/dist/paint-editor/index.d.cts +1 -1
- package/dist/paint-editor/index.d.ts +1 -1
- package/dist/paint-editor/index.js +413 -609
- package/dist/vector/VectorAppearancePanel.d.cts +8 -2
- package/dist/vector/VectorAppearancePanel.d.ts +8 -2
- package/dist/vector/index.cjs +1110 -748
- package/dist/vector/index.js +90 -59
- package/package.json +3 -3
- package/dist/chunk-62FMEDGG.js +0 -54
- package/dist/chunk-PQK2UMAY.js +0 -23
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-XAPJMT3W.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-QIJJCDYW.js";
|
|
86
|
+
import "./chunk-76JBZXLM.js";
|
|
87
87
|
import {
|
|
88
88
|
CommandPalette,
|
|
89
89
|
useCommandPalette,
|
|
@@ -663,46 +663,43 @@ var import_react10 = require("react");
|
|
|
663
663
|
var import_paint_editor5 = require("@pixerate/editor/paint-editor");
|
|
664
664
|
var import_brushes3 = require("@pixerate/editor/brushes");
|
|
665
665
|
|
|
666
|
-
// src/
|
|
666
|
+
// src/brushes/BrushEditor.tsx
|
|
667
667
|
var import_react5 = require("react");
|
|
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, onSaveAs, renderExtra, className }) => {
|
|
670
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
671
671
|
const sections = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
672
|
+
const scope = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
672
673
|
const [problems, setProblems] = (0, import_react5.useState)(null);
|
|
673
674
|
const [name, setName] = (0, import_react5.useState)("");
|
|
675
|
+
const save = async (fn, after) => {
|
|
676
|
+
try {
|
|
677
|
+
await fn();
|
|
678
|
+
after?.();
|
|
679
|
+
setProblems(null);
|
|
680
|
+
} catch (e) {
|
|
681
|
+
setProblems(e.message);
|
|
682
|
+
}
|
|
683
|
+
};
|
|
674
684
|
const set = (path, value) => {
|
|
675
685
|
const r = (0, import_brushes.setBrushEditorValue)(brush, path, value);
|
|
676
686
|
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
677
687
|
if (r.brush !== brush) onChange(r.brush);
|
|
678
688
|
};
|
|
679
689
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
680
|
-
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" } }),
|
|
690
|
+
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" } }) : 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
|
+
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 }),
|
|
681
692
|
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: [
|
|
682
693
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
683
694
|
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EditorControl, { control: c, onSet: set }, c.path)),
|
|
684
695
|
renderExtra?.(s.id)
|
|
685
696
|
] }, s.id)),
|
|
686
|
-
onSaveAs && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
687
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("
|
|
688
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
689
|
-
"
|
|
690
|
-
{
|
|
691
|
-
|
|
692
|
-
className: button,
|
|
693
|
-
disabled: !name.trim(),
|
|
694
|
-
onClick: async () => {
|
|
695
|
-
try {
|
|
696
|
-
await onSaveAs(name.trim());
|
|
697
|
-
setName("");
|
|
698
|
-
setProblems(null);
|
|
699
|
-
} catch (e) {
|
|
700
|
-
setProblems(e.message);
|
|
701
|
-
}
|
|
702
|
-
},
|
|
703
|
-
children: "Save brush"
|
|
704
|
-
}
|
|
705
|
-
)
|
|
697
|
+
(onSave || onSaveAs) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
698
|
+
onSave && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, onClick: () => save(onSave), children: saveLabel }),
|
|
699
|
+
onSaveAs && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
700
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { value: name, placeholder: "Brush name", "aria-label": "Brush name", onChange: (e) => setName(e.target.value), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
701
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: button, disabled: !name.trim(), onClick: () => save(() => onSaveAs(name.trim()), () => setName("")), children: "Save brush" })
|
|
702
|
+
] })
|
|
706
703
|
] }),
|
|
707
704
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorLine, { error: problems })
|
|
708
705
|
] });
|
|
@@ -2,7 +2,7 @@ export * from './usePaintEditor.cjs';
|
|
|
2
2
|
export * from './PaintCanvas.cjs';
|
|
3
3
|
export * from './PaintToolbar.cjs';
|
|
4
4
|
export * from './BrushPanel.cjs';
|
|
5
|
-
export * from '
|
|
5
|
+
export * from '../brushes/BrushEditor.cjs';
|
|
6
6
|
export { BrushLibraryBrowser, type BrushLibraryBrowserProps } from '../brushes/BrushLibraryBrowser.cjs';
|
|
7
7
|
export * from './PaperPanel.cjs';
|
|
8
8
|
export * from './ColorPanel.cjs';
|
|
@@ -2,7 +2,7 @@ export * from './usePaintEditor.js';
|
|
|
2
2
|
export * from './PaintCanvas.js';
|
|
3
3
|
export * from './PaintToolbar.js';
|
|
4
4
|
export * from './BrushPanel.js';
|
|
5
|
-
export * from '
|
|
5
|
+
export * from '../brushes/BrushEditor.js';
|
|
6
6
|
export { BrushLibraryBrowser, type BrushLibraryBrowserProps } from '../brushes/BrushLibraryBrowser.js';
|
|
7
7
|
export * from './PaperPanel.js';
|
|
8
8
|
export * from './ColorPanel.js';
|