@pixerate/editor-react 0.21.0 → 0.22.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.
@@ -31,6 +31,7 @@ __export(canvas_exports, {
31
31
  AnimationPlayer: () => import_canvas26.AnimationPlayer,
32
32
  AnimationTimeline: () => AnimationTimeline,
33
33
  CANVAS_COMPONENT_DRAG_TYPE: () => import_canvas27.CANVAS_COMPONENT_DRAG_TYPE,
34
+ CANVAS_GRADIENT_PRESETS: () => import_canvas27.CANVAS_GRADIENT_PRESETS,
34
35
  CANVAS_TOKEN_PROPERTIES: () => import_canvas25.CANVAS_TOKEN_PROPERTIES,
35
36
  CHILD_LAYOUT_DATA_KEY: () => import_canvas24.CHILD_LAYOUT_DATA_KEY,
36
37
  CONNECTION_LINE_TYPES: () => import_canvas20.CONNECTION_LINE_TYPES,
@@ -57,6 +58,7 @@ __export(canvas_exports, {
57
58
  addCanvasVariant: () => import_canvas27.addCanvasVariant,
58
59
  addKeyframesAtTime: () => import_canvas26.addKeyframesAtTime,
59
60
  alignNodes: () => import_canvas20.alignNodes,
61
+ angleToSvgLinearCoords: () => import_canvas27.angleToSvgLinearCoords,
60
62
  animateNode: () => import_canvas26.animateNode,
61
63
  applyAnimation: () => import_canvas26.applyAnimation,
62
64
  applyAnimationOverrides: () => import_canvas26.applyAnimationOverrides,
@@ -178,6 +180,7 @@ __export(canvas_exports, {
178
180
  getTimelineTicks: () => import_canvas26.getTimelineTicks,
179
181
  getTokenPropertyScope: () => import_canvas25.getTokenPropertyScope,
180
182
  getTokensForProperty: () => import_canvas25.getTokensForProperty,
183
+ gradientToSvgDef: () => import_canvas27.gradientToSvgDef,
181
184
  handlePoint: () => import_canvas20.handlePoint,
182
185
  hasVisibleStroke: () => import_canvas22.hasVisibleStroke,
183
186
  inferResizeHandle: () => import_canvas19.inferResizeHandle,
@@ -192,6 +195,7 @@ __export(canvas_exports, {
192
195
  isAutoLayoutFrame: () => import_canvas24.isAutoLayoutFrame,
193
196
  isCanvasComponent: () => import_canvas27.isCanvasComponent,
194
197
  isCanvasComponentSet: () => import_canvas27.isCanvasComponentSet,
198
+ isCanvasGradient: () => import_canvas27.isCanvasGradient,
195
199
  isCanvasInstance: () => import_canvas27.isCanvasInstance,
196
200
  isCssExportExact: () => import_canvas26.isCssExportExact,
197
201
  isEventFromTextInput: () => import_canvas23.isEventFromTextInput,
@@ -239,6 +243,7 @@ __export(canvas_exports, {
239
243
  parseCanvasClipboardData: () => import_canvas23.parseCanvasClipboardData,
240
244
  parseCanvasScenes: () => import_canvas20.parseCanvasScenes,
241
245
  parseCssEasing: () => import_canvas26.parseCssEasing,
246
+ parseCssGradient: () => import_canvas27.parseCssGradient,
242
247
  parseKeyframeClipboard: () => import_canvas26.parseKeyframeClipboard,
243
248
  parseOklab: () => import_canvas26.parseOklab,
244
249
  parseSvgPath: () => import_canvas21.parseSvgPath,
@@ -270,6 +275,7 @@ __export(canvas_exports, {
270
275
  repositionNodesTo: () => import_canvas23.repositionNodesTo,
271
276
  resetCanvasInstanceOverrides: () => import_canvas27.resetCanvasInstanceOverrides,
272
277
  resizeHandleAxes: () => import_canvas19.resizeHandleAxes,
278
+ resolveCanvasGradient: () => import_canvas27.resolveCanvasGradient,
273
279
  resolveCanvasTokens: () => import_canvas25.resolveCanvasTokens,
274
280
  resolveEasing: () => import_canvas26.resolveEasing,
275
281
  resolvePadding: () => import_canvas24.resolvePadding,
@@ -1446,6 +1452,9 @@ function CanvasDrawLayer({
1446
1452
  };
1447
1453
  const resolvedCursor = cursor ? cursor : spaceHeld ? "grab" : draw.tool === "eraser" ? "crosshair" : draw.tool === "pen" || draw.tool === "highlighter" ? "crosshair" : "default";
1448
1454
  const strokePath = draw.activeStroke ? (0, import_canvas9.strokePointsToPathData)(draw.activeStroke.points) : null;
1455
+ const activeGradient = draw.activeStroke ? (0, import_canvas9.resolveCanvasGradient)(draw.activeStroke.style.gradient ?? draw.activeStroke.style.color) : null;
1456
+ const resolvedGradientDef = activeGradient ? (0, import_canvas9.gradientToSvgDef)(activeGradient, "active-draw-stroke-gradient") : null;
1457
+ const strokePaint = resolvedGradientDef ? `url(#${resolvedGradientDef.id})` : draw.activeStroke ? draw.activeStroke.style.color : "currentColor";
1449
1458
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1450
1459
  "svg",
1451
1460
  {
@@ -1468,12 +1477,17 @@ function CanvasDrawLayer({
1468
1477
  onPointerUp: handlePointerUp,
1469
1478
  onPointerLeave: handlePointerLeave,
1470
1479
  children: [
1480
+ resolvedGradientDef && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("defs", { children: [
1481
+ resolvedGradientDef.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("linearGradient", { id: resolvedGradientDef.id, ...resolvedGradientDef.attrs, children: resolvedGradientDef.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
1482
+ resolvedGradientDef.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("radialGradient", { id: resolvedGradientDef.id, ...resolvedGradientDef.attrs, children: resolvedGradientDef.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
1483
+ ] }),
1471
1484
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("g", { transform: `translate(${viewport.x}, ${viewport.y}) scale(${viewport.zoom})`, children: draw.activeStroke && strokePath && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1472
1485
  "path",
1473
1486
  {
1487
+ className: "pixerate-canvas-draw-active",
1474
1488
  d: strokePath,
1475
1489
  fill: "none",
1476
- stroke: draw.activeStroke.style.color,
1490
+ stroke: strokePaint,
1477
1491
  strokeWidth: draw.activeStroke.style.width,
1478
1492
  opacity: draw.activeStroke.style.opacity,
1479
1493
  strokeLinecap: draw.activeStroke.style.cap ?? "round",
@@ -1560,10 +1574,10 @@ var import_canvas20 = require("@pixerate/editor/canvas");
1560
1574
  // src/canvas/ShapeNode.tsx
1561
1575
  var import_canvas11 = require("@pixerate/editor/canvas");
1562
1576
  var import_jsx_runtime4 = require("react/jsx-runtime");
1563
- function ShapeNode({ data, width, height, selected, className = "", children }) {
1577
+ function ShapeNode({ id, data, width, height, selected, className = "", children }) {
1564
1578
  const shape = data?.shape;
1565
1579
  if (!(0, import_canvas11.isShapeDescription)(shape)) return null;
1566
- const render = (0, import_canvas11.getShapeRenderData)(shape, { width, height });
1580
+ const render = (0, import_canvas11.getShapeRenderData)(shape, { width, height }, { id: id || data?.id });
1567
1581
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1568
1582
  "div",
1569
1583
  {
@@ -1572,7 +1586,7 @@ function ShapeNode({ data, width, height, selected, className = "", children })
1572
1586
  "data-selected": selected ? "true" : void 0,
1573
1587
  style: { position: "relative", width: "100%", height: "100%" },
1574
1588
  children: [
1575
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1589
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1576
1590
  "svg",
1577
1591
  {
1578
1592
  viewBox: render.viewBox,
@@ -1581,19 +1595,29 @@ function ShapeNode({ data, width, height, selected, className = "", children })
1581
1595
  height: "100%",
1582
1596
  style: { display: "block", overflow: "visible" },
1583
1597
  "aria-hidden": "true",
1584
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1585
- "path",
1586
- {
1587
- d: render.d,
1588
- transform: render.transform,
1589
- fill: render.fill,
1590
- fillRule: render.fillRule,
1591
- stroke: render.stroke,
1592
- strokeWidth: render.strokeWidth,
1593
- opacity: render.opacity,
1594
- vectorEffect: "non-scaling-stroke"
1595
- }
1596
- )
1598
+ children: [
1599
+ (render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("defs", { children: [
1600
+ render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("linearGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
1601
+ render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("radialGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
1602
+ render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("linearGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
1603
+ render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("radialGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
1604
+ ] }),
1605
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1606
+ "path",
1607
+ {
1608
+ d: render.d,
1609
+ transform: render.transform,
1610
+ fill: render.fill,
1611
+ fillRule: render.fillRule,
1612
+ stroke: render.stroke,
1613
+ strokeWidth: render.strokeWidth,
1614
+ strokeLinecap: render.strokeLinecap,
1615
+ strokeLinejoin: render.strokeLinejoin,
1616
+ opacity: render.opacity,
1617
+ vectorEffect: "non-scaling-stroke"
1618
+ }
1619
+ )
1620
+ ]
1597
1621
  }
1598
1622
  ),
1599
1623
  children
@@ -2497,6 +2521,7 @@ var import_canvas27 = require("@pixerate/editor/canvas");
2497
2521
  AnimationPlayer,
2498
2522
  AnimationTimeline,
2499
2523
  CANVAS_COMPONENT_DRAG_TYPE,
2524
+ CANVAS_GRADIENT_PRESETS,
2500
2525
  CANVAS_TOKEN_PROPERTIES,
2501
2526
  CHILD_LAYOUT_DATA_KEY,
2502
2527
  CONNECTION_LINE_TYPES,
@@ -2523,6 +2548,7 @@ var import_canvas27 = require("@pixerate/editor/canvas");
2523
2548
  addCanvasVariant,
2524
2549
  addKeyframesAtTime,
2525
2550
  alignNodes,
2551
+ angleToSvgLinearCoords,
2526
2552
  animateNode,
2527
2553
  applyAnimation,
2528
2554
  applyAnimationOverrides,
@@ -2644,6 +2670,7 @@ var import_canvas27 = require("@pixerate/editor/canvas");
2644
2670
  getTimelineTicks,
2645
2671
  getTokenPropertyScope,
2646
2672
  getTokensForProperty,
2673
+ gradientToSvgDef,
2647
2674
  handlePoint,
2648
2675
  hasVisibleStroke,
2649
2676
  inferResizeHandle,
@@ -2658,6 +2685,7 @@ var import_canvas27 = require("@pixerate/editor/canvas");
2658
2685
  isAutoLayoutFrame,
2659
2686
  isCanvasComponent,
2660
2687
  isCanvasComponentSet,
2688
+ isCanvasGradient,
2661
2689
  isCanvasInstance,
2662
2690
  isCssExportExact,
2663
2691
  isEventFromTextInput,
@@ -2705,6 +2733,7 @@ var import_canvas27 = require("@pixerate/editor/canvas");
2705
2733
  parseCanvasClipboardData,
2706
2734
  parseCanvasScenes,
2707
2735
  parseCssEasing,
2736
+ parseCssGradient,
2708
2737
  parseKeyframeClipboard,
2709
2738
  parseOklab,
2710
2739
  parseSvgPath,
@@ -2736,6 +2765,7 @@ var import_canvas27 = require("@pixerate/editor/canvas");
2736
2765
  repositionNodesTo,
2737
2766
  resetCanvasInstanceOverrides,
2738
2767
  resizeHandleAxes,
2768
+ resolveCanvasGradient,
2739
2769
  resolveCanvasTokens,
2740
2770
  resolveEasing,
2741
2771
  resolvePadding,