@pixerate/editor-react 0.87.0 → 0.88.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.
@@ -277,7 +277,12 @@ var VectorSceneNode = React2.memo(function VectorSceneNode2({ node }) {
277
277
  if (node.layers)
278
278
  return (
279
279
  // Fill and stroke stacks: each layer in order, bottom to top.
280
- /* @__PURE__ */ jsx2("g", { "data-vector-id": node.id, transform: node.transform, opacity: node.opacity < 1 ? node.opacity : void 0, filter: node.filter, style: blendStyle(node.blendMode), children: node.layers.map((layer) => /* @__PURE__ */ jsx2(VectorPaintPath, { paint: layer, d: node.d, fillRule: node.fillRule, layer: `${layer.kind}-${layer.index}` }, `${layer.kind}-${layer.index}`)) })
280
+ /* @__PURE__ */ jsx2("g", { "data-vector-id": node.id, transform: node.transform, opacity: node.opacity < 1 ? node.opacity : void 0, filter: node.filter, style: blendStyle(node.blendMode), children: node.layers.map(
281
+ (layer) => layer.kind === "brushstroke" ? (
282
+ // A brushstroke: its rendered brush images over their boxes.
283
+ /* @__PURE__ */ jsx2("g", { "data-vector-layer": `brushstroke-${layer.index}`, opacity: layer.opacity < 1 ? layer.opacity : void 0, style: blendStyle(layer.blendMode), children: (layer.images ?? []).map((im, i) => /* @__PURE__ */ jsx2("image", { href: im.href, x: im.x, y: im.y, width: im.width, height: im.height, preserveAspectRatio: "none" }, i)) }, `${layer.kind}-${layer.index}`)
284
+ ) : /* @__PURE__ */ jsx2(VectorPaintPath, { paint: layer, d: node.d, fillRule: node.fillRule, layer: `${layer.kind}-${layer.index}` }, `${layer.kind}-${layer.index}`)
285
+ ) })
281
286
  );
282
287
  return /* @__PURE__ */ jsx2(VectorPaintPath, { paint: node, d: node.d, fillRule: node.fillRule, id: node.id, transform: node.transform, filter: node.filter, blendMode: node.blendMode });
283
288
  });
@@ -1004,7 +1009,8 @@ import {
1004
1009
  VECTOR_BLEND_MODE_MENU,
1005
1010
  VECTOR_FILTER_MENU,
1006
1011
  VECTOR_STROKE_ALIGN_LABELS,
1007
- getVectorAppearancePanel
1012
+ getVectorAppearancePanel,
1013
+ vectorBrushstrokeBrushes
1008
1014
  } from "@pixerate/editor/vector";
1009
1015
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1010
1016
  var buttonClass2 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
@@ -1021,6 +1027,30 @@ function VectorAppearancePanel({ controller, className }) {
1021
1027
  const update = (l, patch, merge = false) => controller.updatePaintLayer(l.kind, l.index, patch, { ids, merge });
1022
1028
  const layerRow = (l, count) => {
1023
1029
  const name = `${l.kind === "fill" ? "Fill" : "Stroke"} ${l.index + 1}`;
1030
+ if (l.brushstroke)
1031
+ return /* @__PURE__ */ jsx4("div", { className: "space-y-1 rounded border border-border p-1", "data-vector-layer": `${l.kind}-${l.index}`, "data-vector-brushstroke": "", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
1032
+ /* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": `${name} visible`, title: "Show", checked: l.visible, onChange: (e) => update(l, { visible: e.target.checked }) }),
1033
+ /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `${name} colour`, className: "h-7 w-10 cursor-pointer rounded border border-border bg-background", value: l.color ?? "#000000", onChange: (e) => controller.setBrushstroke(l.index, { color: e.target.value }, { ids, merge: true }), onBlur: end }),
1034
+ /* @__PURE__ */ jsx4("select", { "aria-label": `${name} brush`, className: selectClass2, value: l.brushstroke.brushId, onChange: (e) => controller.setBrushstroke(l.index, { brushId: e.target.value }, { ids }), children: vectorBrushstrokeBrushes().map((b) => /* @__PURE__ */ jsx4("option", { value: b.id, children: b.name }, b.id)) }),
1035
+ /* @__PURE__ */ jsx4(
1036
+ "input",
1037
+ {
1038
+ type: "number",
1039
+ min: 0.5,
1040
+ step: 0.5,
1041
+ "aria-label": `${name} brush size`,
1042
+ title: "Brush size",
1043
+ className: numberClass2,
1044
+ value: l.brushstroke.size,
1045
+ onChange: (e) => {
1046
+ const n = parseFloat(e.target.value);
1047
+ if (Number.isFinite(n) && n > 0) controller.setBrushstroke(l.index, { size: Math.min(500, n) }, { ids, merge: true });
1048
+ },
1049
+ onBlur: end
1050
+ }
1051
+ ),
1052
+ /* @__PURE__ */ jsx4("button", { type: "button", className: buttonClass2, title: "Remove", "aria-label": `Remove ${name}`, onClick: () => controller.removePaintLayer("stroke", l.index, { ids }), children: "\xD7" })
1053
+ ] }) }, `${l.kind}-${l.index}`);
1024
1054
  if (l.unknownKind)
1025
1055
  return /* @__PURE__ */ jsxs4("div", { className: "text-[11px] text-muted-foreground", "data-vector-layer": `${l.kind}-${l.index}`, children: [
1026
1056
  name,
@@ -1116,7 +1146,8 @@ function VectorAppearancePanel({ controller, className }) {
1116
1146
  onClick: () => controller.addPaintLayer(kind, {}, { ids }),
1117
1147
  children: "+"
1118
1148
  }
1119
- )
1149
+ ),
1150
+ kind === "stroke" && /* @__PURE__ */ jsx4("button", { type: "button", className: buttonClass2, title: "Add a brushstroke (a natural-media brush along the path)", "aria-label": "Add brushstroke", "data-vector-add-brushstroke": "", disabled: !ids.length, onClick: () => controller.addBrushstroke({ brushId: vectorBrushstrokeBrushes()[0].id }, { ids }), children: "\u270E+" })
1120
1151
  ] }),
1121
1152
  [...layers].reverse().map((l) => layerRow(l, layers.length))
1122
1153
  ] });