@sheetxl/grid-react 0.8.0-beta.3 → 0.8.0-beta.4

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.8.0-beta.3
2
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.8.0-beta.4
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -1657,7 +1657,7 @@ var at = !1, ct = (e, t, n, o) => ({
1657
1657
  if (!e) throw new Error("useSticky must be used within a <StickyAnchor>");
1658
1658
  return e;
1659
1659
  }, It = () => a(St), Ct = (e) => {
1660
- const { anchor: t, placement: n = ht, boundary: o = "data", whenOff: r = "hide", minVisible: l = 0, children: i } = e, { reference: a, getBoundaryRect: c, anchorPoint: d, owner: h, clipped: p, slid: m, outOfView: w, pane: v } = ((e, t) => {
1660
+ const { anchor: t, placement: n = ht, boundary: o = "data", whenOff: r = "hide", minVisible: l = 0, children: i } = e, { reference: a, getBoundaryRect: c, getAnchorPoint: d, anchorPoint: h, owner: p, clipped: m, slid: w, outOfView: v, pane: y } = ((e, t) => {
1661
1661
  const n = Qe(), o = t?.pane ?? n, r = t?.boundary ?? "data", l = t?.minVisible ?? 0, i = t?.placement ?? ht, s = t?.whenOff ?? "hide", a = f({
1662
1662
  pane: o,
1663
1663
  anchor: e,
@@ -1687,11 +1687,16 @@ var at = !1, ct = (e, t, n, o) => ({
1687
1687
  getBoundaryRect: () => {
1688
1688
  const e = a.current;
1689
1689
  return bt(e.pane, e.anchor, e.boundary, e.minVisible, e.placement, e.whenOff).boundaryRect;
1690
+ },
1691
+ getAnchorPoint: () => {
1692
+ const e = a.current;
1693
+ return bt(e.pane, e.anchor, e.boundary, e.minVisible, e.placement, e.whenOff).anchorPoint;
1690
1694
  }
1691
1695
  }), []), d = bt(o, e, r, l, i, s);
1692
1696
  return {
1693
1697
  reference: c.reference,
1694
1698
  getBoundaryRect: c.getBoundaryRect,
1699
+ getAnchorPoint: c.getAnchorPoint,
1695
1700
  clipped: d.clipped,
1696
1701
  clampedTo: d.clampedTo,
1697
1702
  anchorPoint: d.anchorPoint,
@@ -1705,83 +1710,85 @@ var at = !1, ct = (e, t, n, o) => ({
1705
1710
  whenOff: r,
1706
1711
  minVisible: l,
1707
1712
  placement: n
1708
- }), y = null != v && (null != h ? v.getAnchor() === h : v.getAnchor() === _.Center);
1709
- let b = null;
1710
- y && v && ("range" in t ? b = v.getBoundsFromRange(t.range) : "cell" in t ? b = v.getBoundsFromRange({
1713
+ }), b = null != y && (null != p ? y.getAnchor() === p : y.getAnchor() === _.Center);
1714
+ let S = null;
1715
+ b && y && ("range" in t ? S = y.getBoundsFromRange(t.range) : "cell" in t ? S = y.getBoundsFromRange({
1711
1716
  rowStart: t.cell.rowIndex,
1712
1717
  colStart: t.cell.colIndex,
1713
1718
  rowEnd: t.cell.rowIndex,
1714
1719
  colEnd: t.cell.colIndex
1715
- }) : "bounds" in t && (b = t.bounds));
1716
- const S = f(t);
1717
- S.current = t;
1718
- const E = f(v);
1719
- E.current = v;
1720
- const I = s((e) => {
1721
- const t = Rt(S.current), n = E.current;
1720
+ }) : "bounds" in t && (S = t.bounds));
1721
+ const E = f(t);
1722
+ E.current = t;
1723
+ const I = f(y);
1724
+ I.current = y;
1725
+ const C = s((e) => {
1726
+ const t = Rt(E.current), n = I.current;
1722
1727
  return n && t ? n.scrollCellCoordsIntoView(t, e) : Promise.resolve(void 0);
1723
- }, []), C = g(() => ({
1728
+ }, []), R = g(() => ({
1724
1729
  reference: a,
1725
1730
  getBoundaryRect: c,
1726
- anchorPoint: d,
1727
- bounds: b,
1728
- owner: h,
1729
- isOwner: y,
1730
- clipped: p,
1731
- slid: m,
1732
- outOfView: w,
1731
+ getAnchorPoint: d,
1732
+ anchorPoint: h,
1733
+ bounds: S,
1734
+ owner: p,
1735
+ isOwner: b,
1736
+ clipped: m,
1737
+ slid: w,
1738
+ outOfView: v,
1733
1739
  placement: n,
1734
- pane: v,
1735
- scrollIntoView: I
1740
+ pane: y,
1741
+ scrollIntoView: C
1736
1742
  }), [
1737
1743
  a,
1738
1744
  c,
1739
- d.x,
1740
- d.y,
1741
- b?.x,
1742
- b?.y,
1743
- b?.width,
1744
- b?.height,
1745
- h,
1746
- y,
1745
+ d,
1746
+ h.x,
1747
+ h.y,
1748
+ S?.x,
1749
+ S?.y,
1750
+ S?.width,
1751
+ S?.height,
1747
1752
  p,
1753
+ b,
1748
1754
  m,
1749
1755
  w,
1756
+ v,
1750
1757
  n.side,
1751
1758
  n.align,
1752
- v,
1753
- I
1754
- ]), R = y && !p && null != v, M = "function" != typeof i, P = f(null), k = f(null);
1755
- let D = null;
1756
- if (R && !M) D = i(C);
1757
- else if (R) {
1758
- const e = v.getElement()?.getBoundingClientRect();
1759
- D = x("div", {
1760
- ref: P,
1759
+ y,
1760
+ C
1761
+ ]), M = b && !m && null != y, P = "function" != typeof i, k = f(null), D = f(null);
1762
+ let T = null;
1763
+ if (M && !P) T = i(R);
1764
+ else if (M) {
1765
+ const e = y.getElement()?.getBoundingClientRect();
1766
+ T = x("div", {
1767
+ ref: k,
1761
1768
  className: "sticky-layer",
1762
1769
  style: {
1763
1770
  position: "absolute",
1764
1771
  left: 0,
1765
1772
  top: 0,
1766
- transform: `translate3d(${d.x - (e?.left ?? 0)}px, ${d.y - (e?.top ?? 0)}px, 0) ${Mt(n)}`,
1773
+ transform: `translate3d(${h.x - (e?.left ?? 0)}px, ${h.y - (e?.top ?? 0)}px, 0) ${Mt(n)}`,
1767
1774
  willChange: "transform"
1768
1775
  },
1769
1776
  children: x("div", {
1770
- ref: k,
1777
+ ref: D,
1771
1778
  children: i
1772
1779
  })
1773
1780
  });
1774
1781
  }
1775
1782
  return u(() => {
1776
- const e = P.current, t = k.current;
1777
- if (!(e && t && R && v)) return;
1778
- const n = e.getBoundingClientRect(), o = v.getElement()?.getBoundingClientRect();
1783
+ const e = k.current, t = D.current;
1784
+ if (!(e && t && M && y)) return;
1785
+ const n = e.getBoundingClientRect(), o = y.getElement()?.getBoundingClientRect();
1779
1786
  if (!o) return;
1780
1787
  let r = 0, l = 0;
1781
1788
  n.left < o.left ? r = o.left - n.left : n.right > o.right && (r = Math.min(0, o.right - n.right)), n.top < o.top ? l = o.top - n.top : n.bottom > o.bottom && (l = Math.min(0, o.bottom - n.bottom)), t.style.transform = r || l ? `translate(${r}px, ${l}px)` : "";
1782
1789
  }), x(St.Provider, {
1783
- value: C,
1784
- children: D
1790
+ value: R,
1791
+ children: T
1785
1792
  });
1786
1793
  }, Rt = (e) => "range" in e ? {
1787
1794
  rowIndex: e.range.rowStart,
@@ -3753,22 +3760,53 @@ var bo = (e) => {
3753
3760
  })
3754
3761
  });
3755
3762
  }, So = (e) => {
3756
- const { state: t, size: n, color: o, dragging: r, pin: l, onBeginDrag: i } = e, { getPortalContainer: s } = L(), { className: a, attrs: c } = Pt(t.pane);
3757
- let { x: d, y: u } = t.anchorPoint;
3758
- if (l) {
3759
- const e = t.pane?.getElement()?.getBoundingClientRect();
3760
- e && ("v" === l ? u = e.top + e.height / 2 : d = e.left + e.width / 2);
3761
- }
3762
- return q(x("div", {
3763
+ const { state: t, size: n, color: o, dragging: r, pin: l, onBeginDrag: i } = e, { getPortalContainer: s } = L(), { className: a, attrs: c } = Pt(t.pane), d = f({
3764
+ state: t,
3765
+ pin: l
3766
+ });
3767
+ d.current = {
3768
+ state: t,
3769
+ pin: l
3770
+ };
3771
+ const h = g(() => ({
3772
+ get contextElement() {
3773
+ return d.current.state.reference.contextElement;
3774
+ },
3775
+ getBoundingClientRect: () => {
3776
+ const { state: e, pin: t } = d.current;
3777
+ let { x: n, y: o } = e.getAnchorPoint();
3778
+ if (t) {
3779
+ const r = e.pane?.getElement()?.getBoundingClientRect();
3780
+ r && ("v" === t ? o = r.top + r.height / 2 : n = r.left + r.width / 2);
3781
+ }
3782
+ return {
3783
+ x: n,
3784
+ y: o,
3785
+ width: 0,
3786
+ height: 0,
3787
+ top: o,
3788
+ left: n,
3789
+ right: n,
3790
+ bottom: o
3791
+ };
3792
+ }
3793
+ }), []), p = g(() => [Q(({ rects: e }) => -e.floating.height / 2)], []), { refs: m, floatingStyles: w, update: v } = te({
3794
+ placement: "bottom",
3795
+ strategy: "fixed",
3796
+ elements: { reference: h },
3797
+ whileElementsMounted: Z,
3798
+ middleware: p
3799
+ });
3800
+ return u(() => {
3801
+ v();
3802
+ }, [t, v]), q(x("div", {
3803
+ ref: m.setFloating,
3763
3804
  className: ["touch-select-grip", a].filter(Boolean).join(" "),
3764
3805
  ...c,
3765
3806
  style: {
3766
- position: "fixed",
3767
- left: d,
3768
- top: u,
3807
+ ...w,
3769
3808
  width: n,
3770
3809
  height: n,
3771
- transform: "translate(-50%, -50%)",
3772
3810
  background: "var(--sxl-color-base-100, white)",
3773
3811
  border: `3px solid ${o}`,
3774
3812
  borderRadius: "50%",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sheetxl/grid-react",
3
3
  "description": "Grid React - Advanced grid component for React",
4
- "version": "0.8.0-beta.3",
4
+ "version": "0.8.0-beta.4",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
6
6
  "type": "module",
7
7
  "exports": {
@@ -42,8 +42,8 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@floating-ui/react-dom": "^2.1.9",
45
- "@sheetxl/utils": "^0.8.0-beta.3",
46
- "@sheetxl/utils-react": "^0.8.0-beta.3",
45
+ "@sheetxl/utils": "^0.8.0-beta.4",
46
+ "@sheetxl/utils-react": "^0.8.0-beta.4",
47
47
  "clsx": "^2.1.1",
48
48
  "react-merge-refs": "^3.0.2",
49
49
  "react-use": "^17.6.1",
@@ -17,8 +17,10 @@ export interface StickyState {
17
17
  reference: GridAnchorReference;
18
18
  /** Client-space boundary rect (for `flip`/`shift`/`hide` limiters). */
19
19
  getBoundaryRect: () => DOMRect;
20
- /** The placement's anchor pixel (client px). */
20
+ /** The placement's anchor pixel (client px) — a render-time snapshot. */
21
21
  anchorPoint: Point;
22
+ /** Live accessor for the anchor pixel (client px); stable identity, reads between renders. */
23
+ getAnchorPoint: () => Point;
22
24
  /** Pane-relative range bounds (for an in-grid child) — only meaningful on the owner pane, else null. */
23
25
  bounds: Bounds | null;
24
26
  /** The pane that owns the anchor pixel (null when clipped off every pane). */
@@ -134,6 +134,11 @@ export interface UseGridAnchorResult {
134
134
  reference: GridAnchorReference;
135
135
  /** Live accessor for the boundary rect (for `shift`/`flip`/`hide` limiters). */
136
136
  getBoundaryRect: () => DOMRect;
137
+ /**
138
+ * Live accessor for the placement's anchor pixel (client px) — the live counterpart of
139
+ * {@link anchorPoint}, for a child that positions itself on the point between React renders.
140
+ */
141
+ getAnchorPoint: () => Point;
137
142
  /** Render-time snapshot: anchor outside the boundary. Updates each scroll frame (pane re-render). */
138
143
  clipped: boolean;
139
144
  /** Render-time snapshot: which side the anchor is off, when clipped. */