@pixerate/editor-react 0.160.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.
@@ -5,8 +5,8 @@ export interface StickerPanelProps {
5
5
  className?: string;
6
6
  }
7
7
  /**
8
- * The active layer's stickers: pick one to change its stamp, size, rotation, opacity and colour,
9
- * bring it to the front or back, or delete it (each change one undo step). Shows nothing for a
10
- * layer without stickers.
8
+ * The active layer's stickers: pick one (here, or with the Stickers tool on the canvas) to change
9
+ * its stamp, place, size, rotation, opacity and colour, bring it to the front or back, or delete it
10
+ * (each change one undo step). Shows nothing for a layer without stickers.
11
11
  */
12
12
  export declare const StickerPanel: React.FC<StickerPanelProps>;
@@ -5,8 +5,8 @@ export interface StickerPanelProps {
5
5
  className?: string;
6
6
  }
7
7
  /**
8
- * The active layer's stickers: pick one to change its stamp, size, rotation, opacity and colour,
9
- * bring it to the front or back, or delete it (each change one undo step). Shows nothing for a
10
- * layer without stickers.
8
+ * The active layer's stickers: pick one (here, or with the Stickers tool on the canvas) to change
9
+ * its stamp, place, size, rotation, opacity and colour, bring it to the front or back, or delete it
10
+ * (each change one undo step). Shows nothing for a layer without stickers.
11
11
  */
12
12
  export declare const StickerPanel: React.FC<StickerPanelProps>;
@@ -203,8 +203,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
203
203
  y1: l.from.y,
204
204
  x2: l.to.x,
205
205
  y2: l.to.y,
206
- stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : "#f472b6",
207
- strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" ? 0.8 : 0.35,
206
+ stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "sticker" ? "#818cf8" : "#f472b6",
207
+ strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "sticker" ? 0.8 : 0.35,
208
208
  strokeWidth: 1 / state.view.zoom,
209
209
  strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
210
210
  },
@@ -1300,13 +1300,13 @@ var WetPanel = ({ controller, className }) => {
1300
1300
  };
1301
1301
 
1302
1302
  // src/paint-editor/StickerPanel.tsx
1303
- var import_react10 = require("react");
1304
1303
  var import_paint_editor12 = require("@pixerate/editor/paint-editor");
1305
1304
  var import_jsx_runtime11 = require("react/jsx-runtime");
1306
1305
  var StickerPanel = ({ controller, className }) => {
1307
1306
  const state = usePaintEditorState(controller);
1308
1307
  const [error, attempt] = useAttempt();
1309
- const [picked, setPicked] = (0, import_react10.useState)(null);
1308
+ const picked = state.selectedSticker;
1309
+ const setPicked = (id) => controller.selectSticker(id);
1310
1310
  const layerId = state.document.activeLayerId;
1311
1311
  const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
1312
1312
  if (!stickers.length) return null;
@@ -1323,6 +1323,22 @@ var StickerPanel = ({ controller, className }) => {
1323
1323
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Stamp" }),
1324
1324
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("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: import_paint_editor12.STAMP_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k, children: import_paint_editor12.STAMP_LABELS[k] }, k)) })
1325
1325
  ] }),
1326
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
1327
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Position" }),
1328
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1329
+ "input",
1330
+ {
1331
+ type: "number",
1332
+ "aria-label": `Sticker ${k}`,
1333
+ defaultValue: sel[k],
1334
+ step: 1,
1335
+ onBlur: (e) => Number(e.target.value) !== sel[k] && attempt(() => controller.updateSticker(layerId, sel.id, { [k]: Number(e.target.value) })),
1336
+ onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
1337
+ className: "w-16 rounded bg-slate-800 px-1 py-0.5"
1338
+ },
1339
+ `${sel.id}-${k}-${sel[k]}`
1340
+ )) })
1341
+ ] }),
1326
1342
  import_paint_editor12.STICKER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor12.readPath)(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
1327
1343
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center justify-between", children: [
1328
1344
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Colour" }),
@@ -1339,28 +1355,28 @@ var StickerPanel = ({ controller, className }) => {
1339
1355
  };
1340
1356
 
1341
1357
  // src/paint-editor/PaintEditor.tsx
1342
- var import_react24 = require("react");
1358
+ var import_react23 = require("react");
1343
1359
  var import_paint_editor14 = require("@pixerate/editor/paint-editor");
1344
1360
 
1345
1361
  // src/playback/AgentPlaybackContext.tsx
1346
- var import_react11 = require("react");
1362
+ var import_react10 = require("react");
1347
1363
  var import_jsx_runtime12 = require("react/jsx-runtime");
1348
- var AgentPlaybackContext = (0, import_react11.createContext)(null);
1364
+ var AgentPlaybackContext = (0, import_react10.createContext)(null);
1349
1365
  function useAgentPlayback() {
1350
- return (0, import_react11.useContext)(AgentPlaybackContext);
1366
+ return (0, import_react10.useContext)(AgentPlaybackContext);
1351
1367
  }
1352
1368
 
1353
1369
  // src/playback/usePlaybackSurface.ts
1354
- var import_react12 = require("react");
1370
+ var import_react11 = require("react");
1355
1371
  var import_tools = require("@pixerate/editor/tools");
1356
1372
  function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1357
1373
  const ambient = useAgentPlayback();
1358
1374
  const target = playback === void 0 ? ambient : playback;
1359
- const [ownPresence] = (0, import_react12.useState)(() => new import_tools.PresenceStore());
1375
+ const [ownPresence] = (0, import_react11.useState)(() => new import_tools.PresenceStore());
1360
1376
  const presence = sharedPresence ?? ownPresence;
1361
- const latest = (0, import_react12.useRef)(options);
1377
+ const latest = (0, import_react11.useRef)(options);
1362
1378
  latest.current = options;
1363
- (0, import_react12.useEffect)(() => {
1379
+ (0, import_react11.useEffect)(() => {
1364
1380
  if (!target || !id) return;
1365
1381
  const o = () => latest.current;
1366
1382
  const surface = {
@@ -1392,10 +1408,10 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1392
1408
  }
1393
1409
 
1394
1410
  // src/playback/PresenceLayer.tsx
1395
- var import_react13 = __toESM(require("react"), 1);
1411
+ var import_react12 = __toESM(require("react"), 1);
1396
1412
  var import_jsx_runtime13 = require("react/jsx-runtime");
1397
1413
  function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
1398
- const { actors } = (0, import_react13.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1414
+ const { actors } = (0, import_react12.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1399
1415
  if (!actors.length) return null;
1400
1416
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
1401
1417
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
@@ -1412,7 +1428,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
1412
1428
  const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
1413
1429
  return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
1414
1430
  })();
1415
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react13.default.Fragment, { children: [
1431
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react12.default.Fragment, { children: [
1416
1432
  ring && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1417
1433
  "div",
1418
1434
  {
@@ -1434,15 +1450,15 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
1434
1450
  }
1435
1451
 
1436
1452
  // src/paint-editor/PaintEffectsPanel.tsx
1437
- var import_react23 = require("react");
1453
+ var import_react22 = require("react");
1438
1454
  var import_paint_editor13 = require("@pixerate/editor/paint-editor");
1439
1455
 
1440
1456
  // src/effects/useEffects.ts
1441
- var import_react14 = require("react");
1457
+ var import_react13 = require("react");
1442
1458
  function useEffectDescription(provider, effect) {
1443
- const [state, setState] = (0, import_react14.useState)({ key: "", description: null, error: null });
1459
+ const [state, setState] = (0, import_react13.useState)({ key: "", description: null, error: null });
1444
1460
  const key = provider && effect ? `${provider.id}:${effect}` : "";
1445
- (0, import_react14.useEffect)(() => {
1461
+ (0, import_react13.useEffect)(() => {
1446
1462
  if (!provider || !effect) return;
1447
1463
  let live = true;
1448
1464
  Promise.resolve().then(() => provider.describe(effect)).then(
@@ -1457,14 +1473,14 @@ function useEffectDescription(provider, effect) {
1457
1473
  }
1458
1474
 
1459
1475
  // src/effects/EffectThumbnail.tsx
1460
- var import_react15 = require("react");
1476
+ var import_react14 = require("react");
1461
1477
  var import_effects = require("@pixerate/editor/effects");
1462
1478
  var import_jsx_runtime14 = require("react/jsx-runtime");
1463
1479
  var LABELS = { motion: "Motion", camera: "Camera" };
1464
1480
  function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
1465
- const ref = (0, import_react15.useRef)(null);
1466
- const [failed, setFailed] = (0, import_react15.useState)(effect.kind in LABELS);
1467
- (0, import_react15.useEffect)(() => {
1481
+ const ref = (0, import_react14.useRef)(null);
1482
+ const [failed, setFailed] = (0, import_react14.useState)(effect.kind in LABELS);
1483
+ (0, import_react14.useEffect)(() => {
1468
1484
  if (effect.kind in LABELS) return;
1469
1485
  let live = true;
1470
1486
  (0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
@@ -1491,16 +1507,16 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
1491
1507
  }
1492
1508
 
1493
1509
  // src/effects/EffectsBrowser.tsx
1494
- var import_react16 = require("react");
1510
+ var import_react15 = require("react");
1495
1511
  var import_effects2 = require("@pixerate/editor/effects");
1496
1512
  var import_jsx_runtime15 = require("react/jsx-runtime");
1497
1513
  function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
1498
- const [all, setAll] = (0, import_react16.useState)([]);
1499
- const [query, setQuery] = (0, import_react16.useState)("");
1500
- const [category, setCategory] = (0, import_react16.useState)("");
1501
- const [use, setUse] = (0, import_react16.useState)("");
1502
- const [error, setError] = (0, import_react16.useState)(null);
1503
- (0, import_react16.useEffect)(() => {
1514
+ const [all, setAll] = (0, import_react15.useState)([]);
1515
+ const [query, setQuery] = (0, import_react15.useState)("");
1516
+ const [category, setCategory] = (0, import_react15.useState)("");
1517
+ const [use, setUse] = (0, import_react15.useState)("");
1518
+ const [error, setError] = (0, import_react15.useState)(null);
1519
+ (0, import_react15.useEffect)(() => {
1504
1520
  if (!provider) return setAll([]);
1505
1521
  let live = true;
1506
1522
  Promise.resolve().then(() => provider.list()).then(
@@ -1511,8 +1527,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1511
1527
  live = false;
1512
1528
  };
1513
1529
  }, [provider]);
1514
- const [found, setFound] = (0, import_react16.useState)([]);
1515
- (0, import_react16.useEffect)(() => {
1530
+ const [found, setFound] = (0, import_react15.useState)([]);
1531
+ (0, import_react15.useEffect)(() => {
1516
1532
  if (!provider) return setFound([]);
1517
1533
  let live = true;
1518
1534
  Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
@@ -1521,7 +1537,7 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1521
1537
  };
1522
1538
  }, [provider, query, category, use]);
1523
1539
  const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
1524
- const categories = (0, import_react16.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
1540
+ const categories = (0, import_react15.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
1525
1541
  const shown = found.filter(allowed);
1526
1542
  if (!provider)
1527
1543
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
@@ -1569,12 +1585,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1569
1585
  }
1570
1586
 
1571
1587
  // src/effects/EffectParameters.tsx
1572
- var import_react22 = __toESM(require("react"), 1);
1588
+ var import_react21 = __toESM(require("react"), 1);
1573
1589
  var import_effects3 = require("@pixerate/editor/effects");
1574
1590
  var import_parameters2 = require("@pixerate/editor/parameters");
1575
1591
 
1576
1592
  // src/parameters/fields.tsx
1577
- var import_react21 = require("react");
1593
+ var import_react20 = require("react");
1578
1594
  var import_parameters = require("@pixerate/editor/parameters");
1579
1595
 
1580
1596
  // src/color/index.ts
@@ -1587,7 +1603,7 @@ __export(color_exports, {
1587
1603
  });
1588
1604
 
1589
1605
  // src/color/ColorPicker.tsx
1590
- var import_react17 = require("react");
1606
+ var import_react16 = require("react");
1591
1607
  var import_color = require("@pixerate/editor/color");
1592
1608
  var import_jsx_runtime16 = require("react/jsx-runtime");
1593
1609
  var LOCAL_STORAGE_KEY = "pixerate:color:recent";
@@ -1627,24 +1643,24 @@ var ColorPicker = ({
1627
1643
  id,
1628
1644
  "aria-label": ariaLabel = "Color picker"
1629
1645
  }) => {
1630
- const generatedId = (0, import_react17.useId)();
1646
+ const generatedId = (0, import_react16.useId)();
1631
1647
  const pickerId = id || generatedId;
1632
- const [pickerState, setPickerState] = (0, import_react17.useState)(
1648
+ const [pickerState, setPickerState] = (0, import_react16.useState)(
1633
1649
  () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
1634
1650
  );
1635
- const stateRef = (0, import_react17.useRef)(pickerState);
1651
+ const stateRef = (0, import_react16.useRef)(pickerState);
1636
1652
  stateRef.current = pickerState;
1637
- (0, import_react17.useEffect)(() => {
1653
+ (0, import_react16.useEffect)(() => {
1638
1654
  const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
1639
1655
  if (next) {
1640
1656
  setPickerState(next);
1641
1657
  }
1642
1658
  }, [value]);
1643
- const [internalRecent, setInternalRecent] = (0, import_react17.useState)(
1659
+ const [internalRecent, setInternalRecent] = (0, import_react16.useState)(
1644
1660
  () => controlledRecent ? [] : readLocalRecents()
1645
1661
  );
1646
1662
  const activeRecent = controlledRecent ?? internalRecent;
1647
- const recordRecent = (0, import_react17.useCallback)(
1663
+ const recordRecent = (0, import_react16.useCallback)(
1648
1664
  (color) => {
1649
1665
  const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
1650
1666
  if (!controlledRecent) {
@@ -1655,11 +1671,11 @@ var ColorPicker = ({
1655
1671
  },
1656
1672
  [activeRecent, controlledRecent, onRecentChange]
1657
1673
  );
1658
- const [textDraft, setTextDraft] = (0, import_react17.useState)(value);
1659
- const [isInvalid, setIsInvalid] = (0, import_react17.useState)(false);
1660
- const [isClipped, setIsClipped] = (0, import_react17.useState)(false);
1661
- const isTypingRef = (0, import_react17.useRef)(false);
1662
- (0, import_react17.useEffect)(() => {
1674
+ const [textDraft, setTextDraft] = (0, import_react16.useState)(value);
1675
+ const [isInvalid, setIsInvalid] = (0, import_react16.useState)(false);
1676
+ const [isClipped, setIsClipped] = (0, import_react16.useState)(false);
1677
+ const isTypingRef = (0, import_react16.useRef)(false);
1678
+ (0, import_react16.useEffect)(() => {
1663
1679
  if (!isTypingRef.current) {
1664
1680
  setTextDraft(value);
1665
1681
  setIsInvalid(false);
@@ -1667,11 +1683,11 @@ var ColorPicker = ({
1667
1683
  setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
1668
1684
  }
1669
1685
  }, [value]);
1670
- const [hasEyeDropper, setHasEyeDropper] = (0, import_react17.useState)(false);
1671
- (0, import_react17.useEffect)(() => {
1686
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react16.useState)(false);
1687
+ (0, import_react16.useEffect)(() => {
1672
1688
  setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
1673
1689
  }, []);
1674
- const emitColorChange = (0, import_react17.useCallback)(
1690
+ const emitColorChange = (0, import_react16.useCallback)(
1675
1691
  (nextState) => {
1676
1692
  setPickerState(nextState);
1677
1693
  const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
@@ -1679,10 +1695,10 @@ var ColorPicker = ({
1679
1695
  },
1680
1696
  [alpha, onChange]
1681
1697
  );
1682
- const latest = (0, import_react17.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
1698
+ const latest = (0, import_react16.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
1683
1699
  latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
1684
- const endDragRef = (0, import_react17.useRef)(null);
1685
- (0, import_react17.useEffect)(() => () => endDragRef.current?.(), []);
1700
+ const endDragRef = (0, import_react16.useRef)(null);
1701
+ (0, import_react16.useEffect)(() => () => endDragRef.current?.(), []);
1686
1702
  const startDrag = (e, next) => {
1687
1703
  if (disabled) return;
1688
1704
  e.preventDefault();
@@ -1784,7 +1800,7 @@ var ColorPicker = ({
1784
1800
  } catch {
1785
1801
  }
1786
1802
  };
1787
- const contrastResult = (0, import_react17.useMemo)(() => {
1803
+ const contrastResult = (0, import_react16.useMemo)(() => {
1788
1804
  if (!contrastAgainst) return null;
1789
1805
  const fg = (0, import_color.parseColor)(value);
1790
1806
  const bg = (0, import_color.parseColor)(contrastAgainst);
@@ -2211,7 +2227,7 @@ var ColorPicker = ({
2211
2227
  };
2212
2228
 
2213
2229
  // src/color/DualColorPicker.tsx
2214
- var import_react18 = require("react");
2230
+ var import_react17 = require("react");
2215
2231
  var import_color2 = require("@pixerate/editor/color");
2216
2232
  var import_jsx_runtime17 = require("react/jsx-runtime");
2217
2233
  function DualColorPicker({
@@ -2228,8 +2244,8 @@ function DualColorPicker({
2228
2244
  disabled = false,
2229
2245
  className = ""
2230
2246
  }) {
2231
- const sameId = (0, import_react18.useId)();
2232
- const [internalScheme, setInternalScheme] = (0, import_react18.useState)("light");
2247
+ const sameId = (0, import_react17.useId)();
2248
+ const [internalScheme, setInternalScheme] = (0, import_react17.useState)("light");
2233
2249
  const activeScheme = controlledScheme ?? internalScheme;
2234
2250
  const handleSchemeSelect = (nextScheme) => {
2235
2251
  if (onSchemeChange) {
@@ -2240,7 +2256,7 @@ function DualColorPicker({
2240
2256
  };
2241
2257
  const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
2242
2258
  const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
2243
- const [sameInBoth, setSameInBoth] = (0, import_react18.useState)(isSame);
2259
+ const [sameInBoth, setSameInBoth] = (0, import_react17.useState)(isSame);
2244
2260
  const handleSameToggle = (e) => {
2245
2261
  const nextSame = e.target.checked;
2246
2262
  setSameInBoth(nextSame);
@@ -2549,7 +2565,7 @@ function DualColorPicker({
2549
2565
  }
2550
2566
 
2551
2567
  // src/color/useColorScheme.ts
2552
- var import_react19 = require("react");
2568
+ var import_react18 = require("react");
2553
2569
  var import_color3 = require("@pixerate/editor/color");
2554
2570
  function getSnapshot(attribute) {
2555
2571
  if (typeof window === "undefined" || typeof document === "undefined") {
@@ -2574,7 +2590,7 @@ function getServerSnapshot() {
2574
2590
  function useColorScheme(options) {
2575
2591
  const override = options?.override;
2576
2592
  const attribute = options?.attribute;
2577
- const subscribe = (0, import_react19.useMemo)(() => {
2593
+ const subscribe = (0, import_react18.useMemo)(() => {
2578
2594
  return (callback) => {
2579
2595
  if (typeof window === "undefined" || typeof document === "undefined") {
2580
2596
  return () => {
@@ -2600,7 +2616,7 @@ function useColorScheme(options) {
2600
2616
  };
2601
2617
  };
2602
2618
  }, [attribute]);
2603
- const detected = (0, import_react19.useSyncExternalStore)(
2619
+ const detected = (0, import_react18.useSyncExternalStore)(
2604
2620
  subscribe,
2605
2621
  () => getSnapshot(attribute),
2606
2622
  getServerSnapshot
@@ -2617,11 +2633,11 @@ function useResolvedColor(value, scheme) {
2617
2633
  __reExport(color_exports, require("@pixerate/editor/color"));
2618
2634
 
2619
2635
  // src/parameters/controls.tsx
2620
- var import_react20 = require("react");
2636
+ var import_react19 = require("react");
2621
2637
  var import_jsx_runtime18 = require("react/jsx-runtime");
2622
- var ParameterComponentsContext = (0, import_react20.createContext)({});
2638
+ var ParameterComponentsContext = (0, import_react19.createContext)({});
2623
2639
  function useParameterComponents() {
2624
- return (0, import_react20.useContext)(ParameterComponentsContext);
2640
+ return (0, import_react19.useContext)(ParameterComponentsContext);
2625
2641
  }
2626
2642
  function resolveParameterComponents(explicit, context) {
2627
2643
  return {
@@ -2642,9 +2658,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
2642
2658
  var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
2643
2659
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
2644
2660
  function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
2645
- const inputRef = (0, import_react21.useRef)(null);
2646
- const lastCommitted = (0, import_react21.useRef)(null);
2647
- (0, import_react21.useLayoutEffect)(() => {
2661
+ const inputRef = (0, import_react20.useRef)(null);
2662
+ const lastCommitted = (0, import_react20.useRef)(null);
2663
+ (0, import_react20.useLayoutEffect)(() => {
2648
2664
  lastCommitted.current = null;
2649
2665
  const el = inputRef.current;
2650
2666
  if (el && el.value !== value) el.value = value;
@@ -2655,9 +2671,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
2655
2671
  onCommit(text, el);
2656
2672
  lastCommitted.current = el.value === text ? text : null;
2657
2673
  };
2658
- const commitRef = (0, import_react21.useRef)(commit);
2674
+ const commitRef = (0, import_react20.useRef)(commit);
2659
2675
  commitRef.current = commit;
2660
- (0, import_react21.useEffect)(() => {
2676
+ (0, import_react20.useEffect)(() => {
2661
2677
  const el = inputRef.current;
2662
2678
  if (!el) return;
2663
2679
  const change = () => commitRef.current(el);
@@ -2732,7 +2748,7 @@ function ParameterSlider(props) {
2732
2748
  const ctx = useParameterComponents();
2733
2749
  const resolved = resolveParameterComponents(components, ctx);
2734
2750
  const CustomSlider = resolved.slider;
2735
- const dragging = (0, import_react21.useRef)(false);
2751
+ const dragging = (0, import_react20.useRef)(false);
2736
2752
  const start = () => {
2737
2753
  if (dragging.current) return;
2738
2754
  dragging.current = true;
@@ -2864,17 +2880,17 @@ function ParameterSelect(props) {
2864
2880
  }
2865
2881
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
2866
2882
  const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
2867
- const [open, setOpen] = (0, import_react21.useState)(false);
2868
- const containerRef = (0, import_react21.useRef)(null);
2869
- const buttonRef = (0, import_react21.useRef)(null);
2870
- const popoverRef = (0, import_react21.useRef)(null);
2883
+ const [open, setOpen] = (0, import_react20.useState)(false);
2884
+ const containerRef = (0, import_react20.useRef)(null);
2885
+ const buttonRef = (0, import_react20.useRef)(null);
2886
+ const popoverRef = (0, import_react20.useRef)(null);
2871
2887
  const alpha = !!field.alpha;
2872
2888
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
2873
2889
  const rgb = hex.slice(0, 7);
2874
2890
  const shown = alpha ? hex : rgb;
2875
2891
  const off = disabled || field.readOnly;
2876
2892
  const name = (0, import_parameters.parameterLabel)(field);
2877
- (0, import_react21.useEffect)(() => {
2893
+ (0, import_react20.useEffect)(() => {
2878
2894
  if (!open) return;
2879
2895
  const onPointerDown = (e) => {
2880
2896
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -3121,10 +3137,10 @@ function EffectParameters({
3121
3137
  className = "",
3122
3138
  components
3123
3139
  }) {
3124
- const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
3125
- const idBase = (0, import_react22.useId)();
3126
- const gesture = import_react22.default.useRef(null);
3127
- const count = import_react22.default.useRef(0);
3140
+ const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
3141
+ const idBase = (0, import_react21.useId)();
3142
+ const gesture = import_react21.default.useRef(null);
3143
+ const count = import_react21.default.useRef(0);
3128
3144
  const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
3129
3145
  const handlePresetSelect = (name) => {
3130
3146
  if (!name) return;
@@ -3201,8 +3217,8 @@ function EffectParameters({
3201
3217
  // src/paint-editor/PaintEffectsPanel.tsx
3202
3218
  var import_jsx_runtime21 = require("react/jsx-runtime");
3203
3219
  function usePaintEffectsProvider(controller) {
3204
- const [provider, setProvider] = (0, import_react23.useState)(controller.effectsProvider);
3205
- (0, import_react23.useEffect)(() => {
3220
+ const [provider, setProvider] = (0, import_react22.useState)(controller.effectsProvider);
3221
+ (0, import_react22.useEffect)(() => {
3206
3222
  setProvider(controller.effectsProvider);
3207
3223
  return controller.effects.subscribe(setProvider);
3208
3224
  }, [controller]);
@@ -3210,14 +3226,14 @@ function usePaintEffectsProvider(controller) {
3210
3226
  }
3211
3227
  function usePaintEffectsTools(registry, controller, options = {}) {
3212
3228
  const { id, namespace, readOnly, playbackSurface } = options;
3213
- (0, import_react23.useEffect)(() => {
3229
+ (0, import_react22.useEffect)(() => {
3214
3230
  if (!registry) return;
3215
3231
  return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
3216
3232
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
3217
3233
  }
3218
3234
  function Controls({ provider, effect, name, values, apply }) {
3219
3235
  const { description, error } = useEffectDescription(provider, effect);
3220
- const drags = (0, import_react23.useRef)(/* @__PURE__ */ new Set());
3236
+ const drags = (0, import_react22.useRef)(/* @__PURE__ */ new Set());
3221
3237
  if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
3222
3238
  'No effects provider: "',
3223
3239
  name ?? effect,
@@ -3252,14 +3268,14 @@ var PaintEffectsPanel = ({ controller, className }) => {
3252
3268
  const state = usePaintEditorState(controller);
3253
3269
  const provider = usePaintEffectsProvider(controller);
3254
3270
  const [error, attempt] = useAttempt();
3255
- const [browse, setBrowse] = (0, import_react23.useState)(null);
3256
- const [busy, setBusy] = (0, import_react23.useState)(false);
3271
+ const [browse, setBrowse] = (0, import_react22.useState)(null);
3272
+ const [busy, setBusy] = (0, import_react22.useState)(false);
3257
3273
  const paper = controller.getPaperEffect();
3258
3274
  const activeId = state.document.activeLayerId;
3259
3275
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
3260
3276
  const active = activeId ? controller.getLayer(activeId) : void 0;
3261
3277
  const effectPaint = state.effectPaint;
3262
- const thumbnail = (0, import_react23.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
3278
+ const thumbnail = (0, import_react22.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
3263
3279
  const run = (work) => attempt(() => {
3264
3280
  setBusy(true);
3265
3281
  return work().finally(() => setBusy(false));
@@ -3361,12 +3377,12 @@ var PAINT_CONTROLS = {
3361
3377
  symmetry: '[aria-label="Symmetry"]'
3362
3378
  };
3363
3379
  var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
3364
- const [tool, setTool] = (0, import_react24.useState)("brush");
3365
- const [tab, setTab] = (0, import_react24.useState)("color");
3366
- const tabRef = (0, import_react24.useRef)(tab);
3380
+ const [tool, setTool] = (0, import_react23.useState)("brush");
3381
+ const [tab, setTab] = (0, import_react23.useState)("color");
3382
+ const tabRef = (0, import_react23.useRef)(tab);
3367
3383
  tabRef.current = tab;
3368
- const rootRef = (0, import_react24.useRef)(null);
3369
- const [ownPresence] = (0, import_react24.useState)(() => new import_paint_editor14.PaintPresence());
3384
+ const rootRef = (0, import_react23.useRef)(null);
3385
+ const [ownPresence] = (0, import_react23.useState)(() => new import_paint_editor14.PaintPresence());
3370
3386
  const ambientPlayback = useAgentPlayback();
3371
3387
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
3372
3388
  const viewBox = () => {
@@ -3422,7 +3438,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
3422
3438
  const box = rootRef.current?.getBoundingClientRect();
3423
3439
  return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
3424
3440
  };
3425
- const [error, setError] = (0, import_react24.useState)(null);
3441
+ const [error, setError] = (0, import_react23.useState)(null);
3426
3442
  const effects = usePaintEffectsProvider(controller);
3427
3443
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
3428
3444
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("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: [
@@ -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.160.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.237.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.237.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",