@1urso/generic-editor 0.1.69 → 0.1.70

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.
@@ -8853,7 +8853,7 @@ function Ot({ children: n, className: _, elementRef: E, id: O, style: A, ...j })
8853
8853
  Ot.displayName = "Separator";
8854
8854
  var package_default = {
8855
8855
  name: "@1urso/generic-editor",
8856
- version: "0.1.69",
8856
+ version: "0.1.70",
8857
8857
  publishConfig: { access: "public" },
8858
8858
  type: "module",
8859
8859
  main: "./dist/generic-editor.umd.cjs",
@@ -11647,19 +11647,68 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
11647
11647
  label: "Brilho",
11648
11648
  value: "0 0 16px rgba(0, 0, 0, 0.35)"
11649
11649
  }
11650
- ], OI = (n, _) => {
11651
- if (!n || n === "none") return `0 4px 12px ${_}`;
11652
- let E = n.split(","), O = E[E.length - 1].trim(), A = /(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/, j = A.test(O) ? O.replace(A, _) : `${O} ${_}`;
11653
- return E[E.length - 1] = j, E.join(", ");
11654
- }, kI = (n, _) => {
11650
+ ], OI = [
11651
+ {
11652
+ label: "Cima",
11653
+ x: 0,
11654
+ y: -6
11655
+ },
11656
+ {
11657
+ label: "Baixo",
11658
+ x: 0,
11659
+ y: 6
11660
+ },
11661
+ {
11662
+ label: "Esquerda",
11663
+ x: -6,
11664
+ y: 0
11665
+ },
11666
+ {
11667
+ label: "Direita",
11668
+ x: 6,
11669
+ y: 0
11670
+ },
11671
+ {
11672
+ label: "Diagonal",
11673
+ x: 6,
11674
+ y: 6
11675
+ }
11676
+ ], kI = (n) => {
11677
+ if (!n || n === "none") return;
11678
+ let _ = n.match(/(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/);
11679
+ return _ ? _[1] : void 0;
11680
+ }, AI = (n) => {
11681
+ let _ = {
11682
+ x: 0,
11683
+ y: 4,
11684
+ blur: 12,
11685
+ spread: 0,
11686
+ color: "rgba(0, 0, 0, 0.25)"
11687
+ };
11688
+ if (!n || n === "none") return _;
11689
+ let E = (n.match(/-?\d+px/g) || []).map((n) => parseInt(n, 10)), O = kI(n) || _.color;
11690
+ return {
11691
+ x: E[0] ?? _.x,
11692
+ y: E[1] ?? _.y,
11693
+ blur: E[2] ?? _.blur,
11694
+ spread: E[3] ?? _.spread,
11695
+ color: O
11696
+ };
11697
+ }, jI = (n) => `${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${n.color}`, MI = (n, _) => {
11698
+ let E = /(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/;
11699
+ return !n || n === "none" ? jI({
11700
+ ...AI(void 0),
11701
+ color: _
11702
+ }) : E.test(n) ? n.replace(E, _) : `${n} ${_}`;
11703
+ }, NI = (n, _) => {
11655
11704
  rI({
11656
11705
  open: !0,
11657
11706
  prop: n,
11658
11707
  value: _
11659
11708
  });
11660
- }, AI = () => {
11709
+ }, PI = () => {
11661
11710
  if (nI.prop === "boxShadowColor") {
11662
- bI({ boxShadow: OI(_.style?.boxShadow, nI.value) }), rI((n) => ({
11711
+ bI({ boxShadow: MI(_.style?.boxShadow, nI.value) }), rI((n) => ({
11663
11712
  ...n,
11664
11713
  open: !1
11665
11714
  }));
@@ -11669,11 +11718,13 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
11669
11718
  ...n,
11670
11719
  open: !1
11671
11720
  }));
11672
- }, jI = (n) => {
11721
+ }, FI = (n) => {
11673
11722
  if (n === 0) {
11674
11723
  bI({
11724
+ border: "none",
11675
11725
  borderWidth: "0px",
11676
- borderStyle: "none"
11726
+ borderStyle: "none",
11727
+ borderColor: "transparent"
11677
11728
  });
11678
11729
  return;
11679
11730
  }
@@ -11681,7 +11732,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
11681
11732
  borderWidth: `${n}px`,
11682
11733
  borderStyle: _.style?.borderStyle || "solid"
11683
11734
  });
11684
- }, MI = (n) => {
11735
+ }, II = (n) => {
11685
11736
  if (!parseInt(_.style?.borderWidth || "0", 10)) {
11686
11737
  bI({
11687
11738
  borderStyle: n,
@@ -11690,7 +11741,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
11690
11741
  return;
11691
11742
  }
11692
11743
  bI({ borderStyle: n });
11693
- }, NI = (n) => {
11744
+ }, LI = (n) => {
11694
11745
  if (!parseInt(_.style?.borderWidth || "0", 10)) {
11695
11746
  bI({
11696
11747
  borderColor: n,
@@ -11700,10 +11751,16 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
11700
11751
  return;
11701
11752
  }
11702
11753
  bI({ borderColor: n });
11703
- }, PI = (n) => {
11754
+ }, RI = (n) => {
11704
11755
  bI({ boxShadow: n });
11705
- }, FI = (n) => {
11706
- bI({ boxShadow: OI(_.style?.boxShadow, n) });
11756
+ }, BI = (n) => {
11757
+ bI({ boxShadow: MI(_.style?.boxShadow, n) });
11758
+ }, HI = (n, E) => {
11759
+ bI({ boxShadow: jI({
11760
+ ...AI(_.style?.boxShadow),
11761
+ x: n,
11762
+ y: E
11763
+ }) });
11707
11764
  };
11708
11765
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
11709
11766
  /* @__PURE__ */ jsx(s$4, {
@@ -11855,7 +11912,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
11855
11912
  color: "gray",
11856
11913
  children: "Cancelar"
11857
11914
  }) }), /* @__PURE__ */ jsx(o, {
11858
- onClick: AI,
11915
+ onClick: PI,
11859
11916
  children: "Aplicar"
11860
11917
  })]
11861
11918
  })
@@ -12215,7 +12272,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12215
12272
  /* @__PURE__ */ jsx(Item2$1, {
12216
12273
  className: "ContextMenuItem",
12217
12274
  onPointerDown: stopProp,
12218
- onSelect: () => kI("color", _.style?.color || "#000000"),
12275
+ onSelect: () => NI("color", _.style?.color || "#000000"),
12219
12276
  children: "Outra Cor..."
12220
12277
  })
12221
12278
  ]
@@ -12348,7 +12405,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12348
12405
  /* @__PURE__ */ jsx(Item2$1, {
12349
12406
  className: "ContextMenuItem",
12350
12407
  onPointerDown: stopProp,
12351
- onSelect: () => kI("backgroundColor", _.style?.backgroundColor || "transparent"),
12408
+ onSelect: () => NI("backgroundColor", _.style?.backgroundColor || "transparent"),
12352
12409
  children: "Outra Cor..."
12353
12410
  })
12354
12411
  ]
@@ -12368,14 +12425,21 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12368
12425
  DI.map((n) => /* @__PURE__ */ jsx(Item2$1, {
12369
12426
  className: "ContextMenuItem",
12370
12427
  onPointerDown: stopProp,
12371
- onSelect: () => PI(n.value),
12428
+ onSelect: () => RI(n.value),
12429
+ children: n.label
12430
+ }, n.label)),
12431
+ /* @__PURE__ */ jsx(Separator2$1, { className: "ContextMenuSeparator" }),
12432
+ OI.map((n) => /* @__PURE__ */ jsx(Item2$1, {
12433
+ className: "ContextMenuItem",
12434
+ onPointerDown: stopProp,
12435
+ onSelect: () => HI(n.x, n.y),
12372
12436
  children: n.label
12373
12437
  }, n.label)),
12374
12438
  /* @__PURE__ */ jsx(Separator2$1, { className: "ContextMenuSeparator" }),
12375
12439
  wI.filter((n) => n !== "transparent").map((n) => /* @__PURE__ */ jsxs(Item2$1, {
12376
12440
  className: "ContextMenuItem",
12377
12441
  onPointerDown: stopProp,
12378
- onSelect: () => FI(n),
12442
+ onSelect: () => BI(n),
12379
12443
  children: [/* @__PURE__ */ jsx("div", { style: {
12380
12444
  width: 12,
12381
12445
  height: 12,
@@ -12388,7 +12452,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12388
12452
  /* @__PURE__ */ jsx(Item2$1, {
12389
12453
  className: "ContextMenuItem",
12390
12454
  onPointerDown: stopProp,
12391
- onSelect: () => kI("boxShadowColor", "#000000"),
12455
+ onSelect: () => NI("boxShadowColor", "#000000"),
12392
12456
  children: "Outra Cor..."
12393
12457
  })
12394
12458
  ]
@@ -12408,21 +12472,21 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12408
12472
  TI.map((n) => /* @__PURE__ */ jsx(Item2$1, {
12409
12473
  className: "ContextMenuItem",
12410
12474
  onPointerDown: stopProp,
12411
- onSelect: () => jI(n),
12475
+ onSelect: () => FI(n),
12412
12476
  children: n === 0 ? "Sem Borda" : `${n}px`
12413
12477
  }, n)),
12414
12478
  /* @__PURE__ */ jsx(Separator2$1, { className: "ContextMenuSeparator" }),
12415
12479
  EI.map((n) => /* @__PURE__ */ jsx(Item2$1, {
12416
12480
  className: "ContextMenuItem",
12417
12481
  onPointerDown: stopProp,
12418
- onSelect: () => MI(n),
12482
+ onSelect: () => II(n),
12419
12483
  children: n
12420
12484
  }, n)),
12421
12485
  /* @__PURE__ */ jsx(Separator2$1, { className: "ContextMenuSeparator" }),
12422
12486
  wI.map((n) => /* @__PURE__ */ jsxs(Item2$1, {
12423
12487
  className: "ContextMenuItem",
12424
12488
  onPointerDown: stopProp,
12425
- onSelect: () => NI(n),
12489
+ onSelect: () => LI(n),
12426
12490
  children: [/* @__PURE__ */ jsx("div", { style: {
12427
12491
  width: 12,
12428
12492
  height: 12,
@@ -12435,7 +12499,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12435
12499
  /* @__PURE__ */ jsx(Item2$1, {
12436
12500
  className: "ContextMenuItem",
12437
12501
  onPointerDown: stopProp,
12438
- onSelect: () => kI("borderColor", _.style?.borderColor || "#000000"),
12502
+ onSelect: () => NI("borderColor", _.style?.borderColor || "#000000"),
12439
12503
  children: "Outra Cor..."
12440
12504
  })
12441
12505
  ]
@@ -12525,9 +12589,8 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
12525
12589
  x: 0,
12526
12590
  y: 0
12527
12591
  }), nI = useRef(!1), rI = j.canvasHeight || 150, iI = j.isList ? j.mockData.length > 0 ? j.mockData[0] : null : j.singleMockData, aI = n.content, cI = {}, lI = (n, _) => {
12528
- if (!n || n === "none") return `0 4px 12px ${_}`;
12529
- let E = n.split(","), O = E[E.length - 1].trim(), A = /(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/, j = A.test(O) ? O.replace(A, _) : `${O} ${_}`;
12530
- return E[E.length - 1] = j, E.join(", ");
12592
+ let E = /(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/;
12593
+ return !n || n === "none" ? `0 4px 12px 0 ${_}` : E.test(n) ? n.replace(E, _) : `${n} ${_}`;
12531
12594
  };
12532
12595
  if (iI) {
12533
12596
  if (n.type === "text" || n.type === "text-container") aI = aI.replace(/\{\{(.*?)\}\}/g, (_, E) => {
@@ -22264,9 +22327,8 @@ var camelToKebab = (n) => n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toL
22264
22327
  return typeof A == "string" && /^#([0-9a-fA-F]{8})$/.test(A) && (A = hex8ToRgba(A)), `${O}: ${A}`;
22265
22328
  }).filter(Boolean).join("; ");
22266
22329
  }, applyShadowColor = (n, _) => {
22267
- if (!n || n === "none") return `0 4px 12px ${_}`;
22268
- let E = n.split(","), O = E[E.length - 1].trim(), A = /(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/, j = A.test(O) ? O.replace(A, _) : `${O} ${_}`;
22269
- return E[E.length - 1] = j, E.join(", ");
22330
+ let E = /(rgba?\([^)]+\)|#(?:[0-9a-fA-F]{3,8})|[a-zA-Z]+)\s*$/;
22331
+ return !n || n === "none" ? `0 4px 12px 0 ${_}` : E.test(n) ? n.replace(E, _) : `${n} ${_}`;
22270
22332
  }, measureTextHeight = (n, _, E, O, A = 1.2) => {
22271
22333
  if (!n) return 0;
22272
22334
  try {