@aivex/ui 1.2.0-dev.20 → 1.2.0-dev.21

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.
@@ -1582,10 +1582,10 @@ function Jt(e, t, n, r = 300) {
1582
1582
  //#endregion
1583
1583
  //#region src/components/ShapeEditor/_state/createInteractionController.ts
1584
1584
  function Yt(e) {
1585
- let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = "", N = null, P = (e) => e === W.RECTANGLE || e === W.ROTATED_RECTANGLE || e === W.CIRCLE, ee = (e) => e === W.ASSISTANT_POLYGON || e === W.ASSISTANT_RECT, te = (e) => e === W.POLYGON, ne = (e, t) => {
1585
+ let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = "", N = null, P = null, ee = (e) => e === W.RECTANGLE || e === W.ROTATED_RECTANGLE || e === W.CIRCLE, te = (e) => e === W.ASSISTANT_POLYGON || e === W.ASSISTANT_RECT, ne = (e) => e === W.POLYGON, re = (e, t) => {
1586
1586
  let n = !1;
1587
- D && !P(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== W.PATH || O === "scalar" && t !== W.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== W.SELECT && (A = null, j = null, e.clearMarquee(), n = !0), n && b("idle");
1588
- }, re = () => r.current.get(n.current), ie = (e, t, n, r) => ({
1587
+ D && !ee(t) && !te(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== W.PATH || O === "scalar" && t !== W.BRUSH) && (O = null, n = !0), k && !ne(t) && (k = null, n = !0), A && t !== W.SELECT && (A = null, j = null, e.clearMarquee(), n = !0), N && t !== W.POINT && (N = null, n = !0), n && b("idle");
1588
+ }, ie = () => r.current.get(n.current), ae = (e, t, n, r) => ({
1589
1589
  point: t,
1590
1590
  targetId: r,
1591
1591
  event: n,
@@ -1599,7 +1599,7 @@ function Yt(e) {
1599
1599
  let p = t.current;
1600
1600
  if (!p) return;
1601
1601
  let _ = n.current;
1602
- if (ne(p, _), u.button === 1 || i.current) {
1602
+ if (N = null, re(p, _), u.button === 1 || i.current) {
1603
1603
  b("panning"), y(null), E = {
1604
1604
  px: u.global.x,
1605
1605
  py: u.global.y
@@ -1613,9 +1613,9 @@ function Yt(e) {
1613
1613
  }
1614
1614
  return;
1615
1615
  }
1616
- let v = re();
1616
+ let v = ie();
1617
1617
  if (v) {
1618
- w().reset(), m.current([]), v.onPointerDown?.(ie(p, e, u, r));
1618
+ w().reset(), m.current([]), v.onPointerDown?.(ae(p, e, u, r));
1619
1619
  return;
1620
1620
  }
1621
1621
  if (d.current) {
@@ -1626,7 +1626,7 @@ function Yt(e) {
1626
1626
  u.altKey ? T().addPoint(e, u.button !== 2) : T().newPolygon(e);
1627
1627
  return;
1628
1628
  }
1629
- if (ee(_) && c.current) {
1629
+ if (te(_) && c.current) {
1630
1630
  D = e, b("drawing");
1631
1631
  return;
1632
1632
  }
@@ -1645,8 +1645,8 @@ function Yt(e) {
1645
1645
  if (r && _ === W.SELECT) {
1646
1646
  let t = o.current.getShapes().find((e) => e.id === r);
1647
1647
  if (!t || !I(t)) return;
1648
- let n = typeof performance < "u" ? performance.now() : 0, i = !!N && N.id === r && n - N.t < 300;
1649
- N = {
1648
+ let n = typeof performance < "u" ? performance.now() : 0, i = !!P && P.id === r && n - P.t < 300;
1649
+ P = {
1650
1650
  id: r,
1651
1651
  t: n
1652
1652
  };
@@ -1663,11 +1663,11 @@ function Yt(e) {
1663
1663
  m.current(u), !l.current && L(t) && p.beginMove(e, u);
1664
1664
  return;
1665
1665
  }
1666
- if (P(_) && c.current) {
1666
+ if (ee(_) && c.current) {
1667
1667
  D = e, b("drawing");
1668
1668
  return;
1669
1669
  }
1670
- if (te(_) && c.current) {
1670
+ if (ne(_) && c.current) {
1671
1671
  if (!w().getDraftPointsSnapshot().length && s.current.length && m.current([]), w().tryClosePolygon(e, 12 / p.viewport.scale)) return;
1672
1672
  let t = w().hitDraftPoint(e);
1673
1673
  if (t >= 0) {
@@ -1696,6 +1696,14 @@ function Yt(e) {
1696
1696
  O = "scalar", b("drawing"), w().beginStroke(e);
1697
1697
  return;
1698
1698
  }
1699
+ if (_ === W.POINT && c.current && u.button === 0) {
1700
+ N = {
1701
+ pointerId: u.pointerId,
1702
+ global: u.global,
1703
+ cancelled: !1
1704
+ };
1705
+ return;
1706
+ }
1699
1707
  if (_ === W.SELECT) {
1700
1708
  if (j = g.current ? a.current ? p.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
1701
1709
  let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && L(e));
@@ -1713,7 +1721,7 @@ function Yt(e) {
1713
1721
  onPointerMove: (e, r) => {
1714
1722
  let i = t.current;
1715
1723
  if (!i) return;
1716
- if (E) {
1724
+ if (N && N.pointerId === r.pointerId && Math.hypot(r.global.x - N.global.x, r.global.y - N.global.y) > 4 && (N.cancelled = !0), E) {
1717
1725
  i.applyViewport({
1718
1726
  scale: i.viewport.scale,
1719
1727
  x: i.viewport.x + (r.global.x - E.px),
@@ -1722,10 +1730,10 @@ function Yt(e) {
1722
1730
  return;
1723
1731
  }
1724
1732
  let s = n.current;
1725
- ne(i, s);
1726
- let l = re();
1733
+ re(i, s);
1734
+ let l = ie();
1727
1735
  if (l) {
1728
- l.onPointerMove?.(ie(i, e, r));
1736
+ l.onPointerMove?.(ae(i, e, r));
1729
1737
  return;
1730
1738
  }
1731
1739
  if (k) {
@@ -1733,12 +1741,12 @@ function Yt(e) {
1733
1741
  k.moved = k.moved || Math.hypot(t, n) > .5, w().moveDraftPoints(k.base, k.indices, t, n);
1734
1742
  return;
1735
1743
  }
1736
- if (D && (P(s) || ee(s))) {
1744
+ if (D && (ee(s) || te(s))) {
1737
1745
  let t = a.current ? le(D, e) : e;
1738
1746
  i.previewBox(s === W.CIRCLE ? "ellipse" : "rect", D, t, {
1739
1747
  ...c.current,
1740
1748
  color: c.current?.color ?? "#00e5ff"
1741
- }), P(s) && C({
1749
+ }), ee(s) && C({
1742
1750
  type: s === W.CIRCLE ? F.ELLIPSE : F.RECTANGLE,
1743
1751
  points: [D, t]
1744
1752
  });
@@ -1748,7 +1756,7 @@ function Yt(e) {
1748
1756
  w().appendStrokePoint(e, 2 / i.viewport.scale);
1749
1757
  return;
1750
1758
  }
1751
- if (te(s) && w().hasDraftPoints()) {
1759
+ if (ne(s) && w().hasDraftPoints()) {
1752
1760
  w().setDraftCursor(e);
1753
1761
  return;
1754
1762
  }
@@ -1769,24 +1777,26 @@ function Yt(e) {
1769
1777
  r !== M && (M = r, m.current(n));
1770
1778
  }
1771
1779
  },
1772
- onPointerUp: (e) => {
1773
- let r = t.current;
1774
- if (!r) return;
1775
- if (E) {
1780
+ onPointerUp: (e, r) => {
1781
+ let i = t.current;
1782
+ if (!i) return;
1783
+ let o = N;
1784
+ if (N = null, E) {
1776
1785
  E = null, b("idle");
1777
1786
  return;
1778
1787
  }
1779
- let i = n.current;
1780
- if (ne(r, i), k) {
1788
+ let l = n.current;
1789
+ if (re(i, l), k) {
1781
1790
  w().commitDraftPointDrag(k.moved), k = null, b("idle");
1782
1791
  return;
1783
1792
  }
1784
- let o = re();
1785
- if (o) {
1786
- o.onPointerUp?.(ie(r, e, {}));
1793
+ let u = ie();
1794
+ if (u) {
1795
+ u.onPointerUp?.(ae(i, e, r));
1787
1796
  return;
1788
1797
  }
1789
- if (i === W.POINT && c.current) {
1798
+ let d = o ? Math.hypot(r.global.x - o.global.x, r.global.y - o.global.y) : Infinity;
1799
+ if (l === W.POINT && c.current && o && !o.cancelled && o.pointerId === r.pointerId && r.insideCanvas && d <= 4) {
1790
1800
  p.current(F.POINT, [e]);
1791
1801
  return;
1792
1802
  }
@@ -1795,26 +1805,26 @@ function Yt(e) {
1795
1805
  O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
1796
1806
  return;
1797
1807
  }
1798
- if (D && ee(i)) {
1808
+ if (D && te(l)) {
1799
1809
  let t = D;
1800
- D = null, b("idle"), r.clearPreview();
1810
+ D = null, b("idle"), i.clearPreview();
1801
1811
  let n = {
1802
1812
  x: Math.min(t.x, e.x),
1803
1813
  y: Math.min(t.y, e.y),
1804
1814
  width: Math.abs(e.x - t.x),
1805
1815
  height: Math.abs(e.y - t.y)
1806
1816
  };
1807
- n.width > 2 && n.height > 2 && T().beginBox(n, i === W.ASSISTANT_RECT ? "rect" : "polygon");
1817
+ n.width > 2 && n.height > 2 && T().beginBox(n, l === W.ASSISTANT_RECT ? "rect" : "polygon");
1808
1818
  return;
1809
1819
  }
1810
- if (D && P(i)) {
1820
+ if (D && ee(l)) {
1811
1821
  let t = a.current ? le(D, e) : e, n = D;
1812
- D = null, b("idle"), r.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i === W.ROTATED_RECTANGLE ? p.current(F.ROTATED_RECTANGLE, de([n, t])) : i === W.CIRCLE ? p.current(F.POLYGON, fe(n, t)) : p.current(F.RECTANGLE, [n, t]));
1822
+ D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l === W.ROTATED_RECTANGLE ? p.current(F.ROTATED_RECTANGLE, de([n, t])) : l === W.CIRCLE ? p.current(F.POLYGON, fe(n, t)) : p.current(F.RECTANGLE, [n, t]));
1813
1823
  return;
1814
1824
  }
1815
1825
  if (A) {
1816
1826
  let t = Math.abs(e.x - A.x) > 3 || Math.abs(e.y - A.y) > 3, n = j !== null;
1817
- if (A = null, j = null, r.clearMarquee(), b("idle"), n && t) return;
1827
+ if (A = null, j = null, i.clearMarquee(), b("idle"), n && t) return;
1818
1828
  !t && s.current.length && m.current([]);
1819
1829
  }
1820
1830
  },
@@ -3005,6 +3015,7 @@ var nr = 2, rr = "#1e88e5", ir = "#669def", ar = class {
3005
3015
  }
3006
3016
  async init() {
3007
3017
  let e = (e) => ({
3018
+ pointerId: 1,
3008
3019
  button: e.evt.button,
3009
3020
  shiftKey: e.evt.shiftKey,
3010
3021
  altKey: e.evt.altKey,
@@ -3023,19 +3034,36 @@ var nr = 2, rr = "#1e88e5", ir = "#669def", ar = class {
3023
3034
  this.lastDragImg = this.lastImg, this.dragTransform(this.lastImg);
3024
3035
  return;
3025
3036
  }
3026
- this.cb.onPointerMove(this.lastImg, { global: this.stage.getPointerPosition() ?? {
3027
- x: 0,
3028
- y: 0
3029
- } });
3037
+ this.cb.onPointerMove(this.lastImg, {
3038
+ pointerId: 1,
3039
+ global: this.stage.getPointerPosition() ?? {
3040
+ x: 0,
3041
+ y: 0
3042
+ }
3043
+ });
3030
3044
  });
3031
- let t = () => {
3032
- if (this.activeDrag) {
3033
- this.endTransform();
3034
- return;
3045
+ let t = null, n = (e, n) => {
3046
+ if (t !== e) {
3047
+ if (t = e, this.activeDrag) {
3048
+ this.endTransform();
3049
+ return;
3050
+ }
3051
+ this.cb.onPointerUp(this.lastImg, {
3052
+ pointerId: 1,
3053
+ global: this.stage.getPointerPosition() ?? {
3054
+ x: 0,
3055
+ y: 0
3056
+ },
3057
+ insideCanvas: n
3058
+ });
3035
3059
  }
3036
- this.cb.onPointerUp(this.lastImg);
3037
3060
  };
3038
- this.stage.on("mouseup", t), window.addEventListener("mouseup", t), this.upCleanup = () => window.removeEventListener("mouseup", t), this.ro = new ResizeObserver(() => {
3061
+ this.stage.on("mouseup", (e) => n(e.evt, !0));
3062
+ let r = (e) => {
3063
+ let t = e.target;
3064
+ n(e, t instanceof Node && this.host.contains(t));
3065
+ };
3066
+ window.addEventListener("mouseup", r), this.upCleanup = () => window.removeEventListener("mouseup", r), this.ro = new ResizeObserver(() => {
3039
3067
  this.stage.size({
3040
3068
  width: this.host.clientWidth || 1,
3041
3069
  height: this.host.clientHeight || 1
@@ -3804,6 +3832,7 @@ var lr = class {
3804
3832
  }
3805
3833
  ev(e) {
3806
3834
  return {
3835
+ pointerId: e.pointerId,
3807
3836
  button: e.button,
3808
3837
  shiftKey: e.shiftKey,
3809
3838
  altKey: e.altKey,
@@ -3839,14 +3868,21 @@ var lr = class {
3839
3868
  }
3840
3869
  this.cb.onPointerMove(this.toImage(e), this.ev(e));
3841
3870
  });
3842
- let e = (e) => {
3871
+ let e = (e, t) => {
3843
3872
  if (this.activeDrag) {
3844
3873
  this.endTransform();
3845
3874
  return;
3846
3875
  }
3847
- this.cb.onPointerUp(this.toImage(e));
3876
+ this.cb.onPointerUp(this.toImage(e), {
3877
+ pointerId: e.pointerId,
3878
+ global: {
3879
+ x: e.global.x,
3880
+ y: e.global.y
3881
+ },
3882
+ insideCanvas: t
3883
+ });
3848
3884
  };
3849
- this.app.stage.on("pointerup", e), this.app.stage.on("pointerupoutside", e), this.app.renderer.on("resize", () => this.syncHitArea());
3885
+ this.app.stage.on("pointerup", (t) => e(t, !0)), this.app.stage.on("pointerupoutside", (t) => e(t, !1)), this.app.renderer.on("resize", () => this.syncHitArea());
3850
3886
  }
3851
3887
  syncHitArea() {
3852
3888
  let { w: e, h: t } = this.screenSize;