@pixerate/editor-react 0.178.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.
Files changed (33) hide show
  1. package/dist/{paint-editor → brushes}/BrushEditor.d.cts +14 -5
  2. package/dist/{paint-editor → brushes}/BrushEditor.d.ts +14 -5
  3. package/dist/brushes/BrushLibraryEditor.d.cts +26 -0
  4. package/dist/brushes/BrushLibraryEditor.d.ts +26 -0
  5. package/dist/brushes/index.cjs +289 -20
  6. package/dist/brushes/index.d.cts +2 -0
  7. package/dist/brushes/index.d.ts +2 -0
  8. package/dist/brushes/index.js +6 -2
  9. package/dist/chunk-76JBZXLM.js +263 -0
  10. package/dist/chunk-QIJJCDYW.js +119 -0
  11. package/dist/{chunk-UR4KL7WE.js → chunk-XAPJMT3W.js} +26 -6
  12. package/dist/{chunk-KYMDNWSX.js → chunk-ZX7JOPBO.js} +13 -2
  13. package/dist/image-editor/BrushOptionsBar.d.cts +6 -1
  14. package/dist/image-editor/BrushOptionsBar.d.ts +6 -1
  15. package/dist/image-editor/index.cjs +1178 -894
  16. package/dist/image-editor/index.js +3 -3
  17. package/dist/index.cjs +1719 -1435
  18. package/dist/index.js +3 -3
  19. package/dist/paint-editor/index.cjs +33 -25
  20. package/dist/paint-editor/index.d.cts +1 -1
  21. package/dist/paint-editor/index.d.ts +1 -1
  22. package/dist/paint-editor/index.js +414 -610
  23. package/dist/stickers/StickerLibraryPicker.d.cts +2 -2
  24. package/dist/stickers/StickerLibraryPicker.d.ts +2 -2
  25. package/dist/stickers/index.cjs +13 -2
  26. package/dist/stickers/index.js +1 -1
  27. package/dist/vector/VectorAppearancePanel.d.cts +8 -2
  28. package/dist/vector/VectorAppearancePanel.d.ts +8 -2
  29. package/dist/vector/index.cjs +1110 -748
  30. package/dist/vector/index.js +90 -59
  31. package/package.json +3 -3
  32. package/dist/chunk-62FMEDGG.js +0 -54
  33. 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-UR4KL7WE.js";
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-PQK2UMAY.js";
86
- import "./chunk-62FMEDGG.js";
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/paint-editor/BrushEditor.tsx
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)("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" }),
688
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
689
- "button",
690
- {
691
- type: "button",
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
  ] });
@@ -963,6 +960,7 @@ var import_react9 = require("react");
963
960
  var import_react8 = require("react");
964
961
  var import_stickers = require("@pixerate/editor/stickers");
965
962
  var import_jsx_runtime8 = require("react/jsx-runtime");
963
+ var tooltip = (it) => `${it.name} (${it.ref}) \xB7 ${it.licence.name}${it.licence.attribution ? ` \xB7 ${it.licence.attribution}` : ""}${it.aiGenerated ? " \xB7 AI-generated" : ""}${it.variants?.includes("dark") ? " \xB7 light and dark" : ""}`;
966
964
  var StickerLibraryPicker = ({ provider, selected = [], onPick, label = "Stickers", footer, className }) => {
967
965
  const browser = (0, import_react8.useMemo)(() => new import_stickers.StickerBrowser(() => provider), [provider]);
968
966
  const [, setTick] = (0, import_react8.useState)(0);
@@ -978,6 +976,15 @@ var StickerLibraryPicker = ({ provider, selected = [], onPick, label = "Stickers
978
976
  s.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { "aria-label": "Sticker category", value: s.category, onChange: (e) => void browser.setCategory(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: [
979
977
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "All" }),
980
978
  s.categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: c.id, children: c.name }, c.id))
979
+ ] }),
980
+ s.collections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { "aria-label": "Sticker collection", value: s.collection, onChange: (e) => void browser.setCollection(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: [
981
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "All collections" }),
982
+ s.collections.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("option", { value: c.id, title: c.description, children: [
983
+ c.name,
984
+ " (",
985
+ c.count,
986
+ ")"
987
+ ] }, c.id))
981
988
  ] })
982
989
  ] }),
983
990
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex max-h-32 flex-wrap gap-1 overflow-y-auto", role: "group", "aria-label": label, children: s.items.map((it) => {
@@ -987,12 +994,13 @@ var StickerLibraryPicker = ({ provider, selected = [], onPick, label = "Stickers
987
994
  {
988
995
  type: "button",
989
996
  "aria-pressed": on,
990
- title: `${it.name} (${it.ref}) \xB7 ${it.licence.name}${it.licence.attribution ? ` \xB7 ${it.licence.attribution}` : ""}`,
997
+ title: tooltip(it),
991
998
  className: `flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
992
999
  onClick: () => onPick(it),
993
1000
  children: [
994
1001
  it.thumbnail && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: it.thumbnail, alt: "", className: "h-4 w-4" }),
995
- it.name
1002
+ it.name,
1003
+ it.aiGenerated && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rounded bg-slate-700 px-0.5 text-[8px] text-slate-200", "aria-label": "AI-generated", children: "AI" })
996
1004
  ]
997
1005
  },
998
1006
  it.ref
@@ -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 './BrushEditor.cjs';
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 './BrushEditor.js';
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';