@pixerate/editor-react 0.159.0 → 0.161.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.
@@ -176,8 +176,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
176
176
  y1: l.from.y,
177
177
  x2: l.to.x,
178
178
  y2: l.to.y,
179
- stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : "#f472b6",
180
- strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" ? 0.8 : 0.35,
179
+ stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "sticker" ? "#818cf8" : "#f472b6",
180
+ strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "sticker" ? 0.8 : 0.35,
181
181
  strokeWidth: 1 / state.view.zoom,
182
182
  strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
183
183
  },
@@ -1187,13 +1187,13 @@ var WetPanel = ({ controller, className }) => {
1187
1187
  };
1188
1188
 
1189
1189
  // src/paint-editor/StickerPanel.tsx
1190
- import { useState as useState8 } from "react";
1191
1190
  import { STAMP_KINDS as STAMP_KINDS2, STAMP_LABELS as STAMP_LABELS2, STICKER_SLIDERS, readPath as readPath4 } from "@pixerate/editor/paint-editor";
1192
1191
  import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1193
1192
  var StickerPanel = ({ controller, className }) => {
1194
1193
  const state = usePaintEditorState(controller);
1195
1194
  const [error, attempt] = useAttempt();
1196
- const [picked, setPicked] = useState8(null);
1195
+ const picked = state.selectedSticker;
1196
+ const setPicked = (id) => controller.selectSticker(id);
1197
1197
  const layerId = state.document.activeLayerId;
1198
1198
  const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
1199
1199
  if (!stickers.length) return null;
@@ -1210,6 +1210,22 @@ var StickerPanel = ({ controller, className }) => {
1210
1210
  /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Stamp" }),
1211
1211
  /* @__PURE__ */ jsx10("select", { "aria-label": "Sticker stamp", value: sel.stamp, onChange: (e) => attempt(() => controller.updateSticker(layerId, sel.id, { stamp: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: STAMP_KINDS2.map((k) => /* @__PURE__ */ jsx10("option", { value: k, children: STAMP_LABELS2[k] }, k)) })
1212
1212
  ] }),
1213
+ /* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between gap-2", children: [
1214
+ /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Position" }),
1215
+ /* @__PURE__ */ jsx10("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx10(
1216
+ "input",
1217
+ {
1218
+ type: "number",
1219
+ "aria-label": `Sticker ${k}`,
1220
+ defaultValue: sel[k],
1221
+ step: 1,
1222
+ onBlur: (e) => Number(e.target.value) !== sel[k] && attempt(() => controller.updateSticker(layerId, sel.id, { [k]: Number(e.target.value) })),
1223
+ onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
1224
+ className: "w-16 rounded bg-slate-800 px-1 py-0.5"
1225
+ },
1226
+ `${sel.id}-${k}-${sel[k]}`
1227
+ )) })
1228
+ ] }),
1213
1229
  STICKER_SLIDERS.map((c) => /* @__PURE__ */ jsx10(PaintSlider, { control: c, value: readPath4(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
1214
1230
  /* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between", children: [
1215
1231
  /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Colour" }),
@@ -1226,15 +1242,15 @@ var StickerPanel = ({ controller, className }) => {
1226
1242
  };
1227
1243
 
1228
1244
  // src/paint-editor/PaintEditor.tsx
1229
- import { useRef as useRef7, useState as useState10 } from "react";
1245
+ import { useRef as useRef7, useState as useState9 } from "react";
1230
1246
  import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
1231
1247
 
1232
1248
  // src/paint-editor/PaintEffectsPanel.tsx
1233
- import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState9 } from "react";
1249
+ import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
1234
1250
  import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
1235
1251
  import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1236
1252
  function usePaintEffectsProvider(controller) {
1237
- const [provider, setProvider] = useState9(controller.effectsProvider);
1253
+ const [provider, setProvider] = useState8(controller.effectsProvider);
1238
1254
  useEffect4(() => {
1239
1255
  setProvider(controller.effectsProvider);
1240
1256
  return controller.effects.subscribe(setProvider);
@@ -1285,8 +1301,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1285
1301
  const state = usePaintEditorState(controller);
1286
1302
  const provider = usePaintEffectsProvider(controller);
1287
1303
  const [error, attempt] = useAttempt();
1288
- const [browse, setBrowse] = useState9(null);
1289
- const [busy, setBusy] = useState9(false);
1304
+ const [browse, setBrowse] = useState8(null);
1305
+ const [busy, setBusy] = useState8(false);
1290
1306
  const paper = controller.getPaperEffect();
1291
1307
  const activeId = state.document.activeLayerId;
1292
1308
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
@@ -1394,12 +1410,12 @@ var PAINT_CONTROLS = {
1394
1410
  symmetry: '[aria-label="Symmetry"]'
1395
1411
  };
1396
1412
  var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
1397
- const [tool, setTool] = useState10("brush");
1398
- const [tab, setTab] = useState10("color");
1413
+ const [tool, setTool] = useState9("brush");
1414
+ const [tab, setTab] = useState9("color");
1399
1415
  const tabRef = useRef7(tab);
1400
1416
  tabRef.current = tab;
1401
1417
  const rootRef = useRef7(null);
1402
- const [ownPresence] = useState10(() => new PaintPresence2());
1418
+ const [ownPresence] = useState9(() => new PaintPresence2());
1403
1419
  const ambientPlayback = useAgentPlayback();
1404
1420
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
1405
1421
  const viewBox = () => {
@@ -1455,7 +1471,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
1455
1471
  const box = rootRef.current?.getBoundingClientRect();
1456
1472
  return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
1457
1473
  };
1458
- const [error, setError] = useState10(null);
1474
+ const [error, setError] = useState9(null);
1459
1475
  const effects = usePaintEffectsProvider(controller);
1460
1476
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
1461
1477
  return /* @__PURE__ */ jsxs11("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.159.0",
3
+ "version": "0.161.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -254,7 +254,7 @@
254
254
  "dependencies": {},
255
255
  "peerDependencies": {
256
256
  "@dagrejs/dagre": "^1.1.8",
257
- "@pixerate/editor": ">=0.235.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.238.0 <1.0.0-0",
258
258
  "@tiptap/core": "^2.27.3",
259
259
  "@tiptap/extension-bubble-menu": "^2.27.3",
260
260
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -305,7 +305,7 @@
305
305
  "tsup": "^9.0.0",
306
306
  "typescript": "^5.7.3",
307
307
  "vitest": "^5.0.5",
308
- "@pixerate/editor": "0.235.0"
308
+ "@pixerate/editor": "0.238.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",