@sheetxl/grid-react 0.3.3 → 0.3.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
  Name: @sheetxl/utils
2
- Version: 0.3.3
2
+ Version: 0.3.4
3
3
  License: SEE LICENSE IN <LICENSE>
4
4
  Private: false
5
5
  Description: Utils - Utilities used by most SheetXL components.
@@ -21,7 +21,7 @@ https://www.sheetxl.com/licensing-pricing
21
21
  ---
22
22
 
23
23
  Name: @sheetxl/utils-react
24
- Version: 0.3.3
24
+ Version: 0.3.4
25
25
  License: SEE LICENSE IN <LICENSE>
26
26
  Private: false
27
27
  Description: Utils React - Utilities for React capabilities needed for all SheetXL components.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.3
2
+ * @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.4
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -1585,38 +1585,38 @@ const kn = () => "sheetxl-ui-" + Mn++, Rn = o["useId".toString()], Pn = null !=
1585
1585
  return { x: u2.x ?? 0, y: u2.y ?? 0, height: Math.min(p2 - u2.y, u2.height) + 1, width: Math.min(f3 - u2.x, u2.width) + 1 };
1586
1586
  }, [E2]), k2 = Tt(o2, [o2]), R2 = i(() => {
1587
1587
  n2?.getStage()?.focus();
1588
- }, [n2]), P2 = Tt((e5) => {
1589
- c2?.(e5), W2(), I2(true);
1590
- }, [c2]), O2 = Tt((e5) => {
1588
+ }, [n2]), P2 = l(null), O2 = Tt((e5) => {
1589
+ c2?.(e5), H2(), I2(true), P2.current = null;
1590
+ }, [c2]), L2 = Tt((e5) => {
1591
1591
  a2?.(e5.coords);
1592
- }, [a2]), L2 = Tt((e5) => {
1593
- e5.isSubmitted || e5.isCancelled || (A2.current.isEditorClosed = true, R2(), e5.isCancelled = true, f2?.(e5.coords), W2());
1594
- }, [f2]), D2 = Tt((e5) => {
1592
+ }, [a2]), D2 = Tt((e5) => {
1593
+ e5.isSubmitted || e5.isCancelled || ($2.current.isEditorClosed = true, R2(), e5.isCancelled = true, f2?.(e5.coords), H2());
1594
+ }, [f2]), z2 = Tt((e5) => {
1595
1595
  if (e5.isSubmitted || e5.isCancelled) return false;
1596
1596
  try {
1597
- return e5.isEditorClosing = true, e5.isSubmitted = true, e5.isEditorSubmitted || (e5.isEditorSubmitted = true, e5.editorRefs[0]?.submitEdit?.()), e5.coords, d2?.(e5.coords), e5.isEditorClosed = true, R2(), W2(), true;
1597
+ return P2.current = e5.coords, e5.isEditorClosing = true, e5.isSubmitted = true, e5.isEditorSubmitted || (e5.isEditorSubmitted = true, e5.editorRefs[0]?.submitEdit?.()), e5.coords, d2?.(e5.coords), e5.isEditorClosed = true, R2(), H2(), true;
1598
1598
  } catch (t3) {
1599
1599
  throw e5.isEditorClosing = false, e5.isSubmitted = false, t3;
1600
1600
  }
1601
- }, [d2]), z2 = Tt((e5) => {
1602
- I2(false), g2?.(e5.coords), W2();
1603
- }, [g2]), A2 = l(null), $2 = l(null), B2 = l(null), F2 = l([]), [j2, V2] = p((e5) => e5 + 1, 0), W2 = i((e5) => {
1604
- e5 && F2.current.push(e5), V2();
1605
- }, []), H2 = Tt((e5) => {
1601
+ }, [d2]), A2 = Tt((e5) => {
1602
+ I2(false), g2?.(e5.coords), H2();
1603
+ }, [g2]), $2 = l(null), B2 = l(null), F2 = l(null), j2 = l([]), [V2, W2] = p((e5) => e5 + 1, 0), H2 = i((e5) => {
1604
+ e5 && j2.current.push(e5), W2();
1605
+ }, []), N2 = Tt((e5) => {
1606
1606
  if (e5.defaultPrevented || e5.isSynthetic) return;
1607
1607
  if (!n2) return;
1608
1608
  const t3 = n2?.getCellCoordsFromClient(e5.clientX, e5.clientY);
1609
1609
  if (!t3) return;
1610
- W2({ eventType: "pointer", event: e5, coords: t3 });
1611
- }, [n2]), N2 = Tt((e5) => {
1612
- const t3 = e5.nativeEvent;
1613
- H2(t3);
1610
+ H2({ eventType: "pointer", event: e5, coords: t3 });
1614
1611
  }, [n2]), U2 = Tt((e5) => {
1612
+ const t3 = e5.nativeEvent;
1613
+ N2(t3);
1614
+ }, [n2]), K2 = Tt((e5) => {
1615
1615
  if (e5.defaultPrevented || e5.isSynthetic) return;
1616
1616
  if (!n2?.getStage()) return;
1617
- const t3 = $2.current;
1617
+ const t3 = B2.current;
1618
1618
  w2(e5, t3) && (e5.stopPropagation(), e5.preventDefault()), e5.key;
1619
- W2({ eventType: "keyboard", event: e5, coords: t3 });
1619
+ H2({ eventType: "keyboard", event: e5, coords: t3 });
1620
1620
  }, [n2]);
1621
1621
  u(() => {
1622
1622
  const e5 = (e6, t4) => {
@@ -1624,20 +1624,20 @@ const kn = () => "sheetxl-ui-" + Mn++, Rn = o["useId".toString()], Pn = null !=
1624
1624
  if (!o4) return null;
1625
1625
  const r3 = o4;
1626
1626
  if (!k2(o4)) return null;
1627
- P2?.(o4);
1627
+ O2?.(o4);
1628
1628
  const i2 = Me.uuidV4();
1629
- t4 = Object.freeze({ autoFocus: true, ...t4 }), B2.current = o4;
1629
+ t4 = Object.freeze({ autoFocus: true, ...t4 }), F2.current = o4;
1630
1630
  const l2 = { coords: r3, startEvent: t4, uuid: i2, isMounted: false, isStarted: false, isSubmitted: false, isEditorSubmitted: false, isEditorClosing: false, isEditorClosed: false, isCancelled: false, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (e7) => {
1631
- l2.isMounted || (l2.isMounted = true, W2());
1631
+ l2.isMounted || (l2.isMounted = true, H2());
1632
1632
  }, onUnmount: (e7) => {
1633
1633
  if (0 === l2.editorRefs.length) {
1634
1634
  const e8 = () => {
1635
- l2.isMounted = false, W2();
1635
+ l2.isMounted = false, H2();
1636
1636
  };
1637
1637
  if (document.activeElement !== document.body) e8();
1638
1638
  else {
1639
1639
  const t5 = (e9) => {
1640
- e9.defaultPrevented || e9.target !== document.body || U2(e9);
1640
+ e9.defaultPrevented || e9.target !== document.body || K2(e9);
1641
1641
  };
1642
1642
  window.addEventListener("keydown", t5, true), n2.getStage()?.addEventListener("focusin", () => {
1643
1643
  window.removeEventListener("keydown", t5), e8();
@@ -1647,102 +1647,103 @@ const kn = () => "sheetxl-ui-" + Mn++, Rn = o["useId".toString()], Pn = null !=
1647
1647
  } };
1648
1648
  return l2;
1649
1649
  };
1650
- if (F2.current.length <= 0 && !A2.current) return;
1651
- const t3 = F2.current[0];
1650
+ if (j2.current.length <= 0 && !$2.current) return;
1651
+ const t3 = j2.current[0];
1652
1652
  Bn(t3), ((e6) => {
1653
1653
  const t4 = [], n3 = e6?.length ?? 0;
1654
1654
  for (let o4 = 0; o4 < n3; o4++) {
1655
1655
  const n4 = e6[o4];
1656
1656
  t4.push(Bn(n4));
1657
1657
  }
1658
- })(F2.current), A2.current, A2.current;
1659
- let o3 = A2.current;
1660
- if (A2.current) {
1661
- if (A2.current.isDone) A2.current = null;
1662
- else if (A2.current.isSubmitted || A2.current.isCancelled) {
1663
- if (A2.current.isMounted) return;
1664
- A2.current.isDone || (z2(A2.current), A2.current.isDone = true);
1658
+ })(j2.current), $2.current, $2.current;
1659
+ let o3 = $2.current;
1660
+ if ($2.current) {
1661
+ if ($2.current.isDone) $2.current = null;
1662
+ else if ($2.current.isSubmitted || $2.current.isCancelled) {
1663
+ if ($2.current.isMounted) return;
1664
+ $2.current.isDone || (A2($2.current), $2.current.isDone = true);
1665
1665
  }
1666
1666
  }
1667
1667
  if (t3) {
1668
1668
  if ("start" === t3.eventType) {
1669
- const n3 = t3, o4 = n3.startEvent?.cell ?? $2.current;
1670
- A2.current && ne.isEqualCells(A2.current.coords, o4) || (A2.current = e5(o4, n3.startEvent));
1669
+ const n3 = t3, o4 = n3.startEvent?.cell ?? B2.current;
1670
+ $2.current && ne.isEqualCells($2.current.coords, o4) || ($2.current = e5(o4, n3.startEvent));
1671
1671
  } else if ("keyboard" === t3.eventType) {
1672
1672
  const n3 = t3.event;
1673
- if (A2.current) {
1674
- n3.key, A2.current.events, A2.current.events.push(t3);
1675
- for (let e6 = 0; e6 < A2.current.editorRefsDispatchEditorEvent.length; e6++) A2.current.editorRefsDispatchEditorEvent[e6](t3);
1673
+ if ($2.current) {
1674
+ n3.key, $2.current.events, $2.current.events.push(t3);
1675
+ for (let e6 = 0; e6 < $2.current.editorRefsDispatchEditorEvent.length; e6++) $2.current.editorRefsDispatchEditorEvent[e6](t3);
1676
1676
  } else {
1677
1677
  if (w2(n3, t3.coords)) {
1678
1678
  let n4;
1679
- const o4 = e5(n4?.cell ?? $2.current, n4);
1680
- o4 && o4.events.push(t3), A2.current = o4;
1679
+ const o4 = e5(n4?.cell ?? B2.current, n4);
1680
+ o4 && o4.events.push(t3), $2.current = o4;
1681
1681
  }
1682
1682
  }
1683
1683
  } else if ("pointer" === t3.eventType) {
1684
1684
  const n3 = t3.event;
1685
- if (A2.current) {
1686
- A2.current.events.push(t3);
1687
- for (let e6 = 0; e6 < A2.current.editorRefsDispatchEditorEvent.length; e6++) A2.current.editorRefsDispatchEditorEvent[e6](t3);
1685
+ if ($2.current) {
1686
+ $2.current.events.push(t3);
1687
+ for (let e6 = 0; e6 < $2.current.editorRefsDispatchEditorEvent.length; e6++) $2.current.editorRefsDispatchEditorEvent[e6](t3);
1688
1688
  } else {
1689
- const o4 = t3?.coords ?? $2.current, r3 = m2(n3, o4);
1689
+ const o4 = t3?.coords ?? B2.current, r3 = m2(n3, o4);
1690
1690
  if (r3) {
1691
1691
  let n4;
1692
1692
  "boolean" != typeof n4 && (n4 = r3);
1693
1693
  const i2 = e5(o4, n4);
1694
- i2 && i2.events.push(t3), A2.current = i2;
1694
+ i2 && i2.events.push(t3), $2.current = i2;
1695
1695
  }
1696
1696
  }
1697
1697
  } else if ("submit" === t3.eventType) {
1698
- if (A2.current && !A2.current.isSubmitted && !A2.current.isCancelled) {
1699
- if (!A2.current.isMounted) return;
1700
- D2(A2.current);
1698
+ if ($2.current && !$2.current.isSubmitted && !$2.current.isCancelled) {
1699
+ if (!$2.current.isMounted) return;
1700
+ z2($2.current);
1701
1701
  }
1702
1702
  } else if ("cancel" === t3.eventType) {
1703
- if (A2.current && !A2.current.isSubmitted && !A2.current.isCancelled) {
1704
- if (!A2.current.isMounted) return;
1705
- L2(A2.current);
1703
+ if ($2.current && !$2.current.isSubmitted && !$2.current.isCancelled) {
1704
+ if (!$2.current.isMounted) return;
1705
+ D2($2.current);
1706
1706
  }
1707
1707
  } else if ("coordsChange" === t3.eventType) {
1708
1708
  const e6 = t3;
1709
- if ($2.current = e6.activeCoords, A2.current, A2.current && !A2.current.isSubmitted && !A2.current.isCancelled) {
1710
- if (!A2.current.isMounted) return;
1709
+ if (B2.current = e6.activeCoords, $2.current, $2.current && !$2.current.isSubmitted && !$2.current.isCancelled) {
1710
+ if (!$2.current.isMounted) return;
1711
1711
  try {
1712
- D2(A2.current);
1712
+ z2($2.current);
1713
1713
  } catch (e7) {
1714
1714
  }
1715
1715
  }
1716
1716
  }
1717
1717
  }
1718
- F2.current.length > 0 && (F2.current.shift(), W2()), 0 === F2.current.length && (!A2.current || A2.current.isEditorClosing || A2.current.isEditorClosed ? !A2.current && o3 && R2() : A2.current.isMounted && !A2.current.isStarted && (A2.current.isStarted = true, A2.current.startEvent.autoFocus && ("string" == typeof A2.current.startEvent.autoFocus ? A2.current.editorRefs[0]?.autoFocus(A2.current.startEvent.autoFocus) : A2.current.editorRefs[0]?.autoFocus()), O2?.(A2.current), requestAnimationFrame(() => {
1719
- n2 && A2.current?.coords && n2.scrollCellCoordsIntoView(A2.current.coords);
1718
+ j2.current.length > 0 && (j2.current.shift(), H2()), 0 === j2.current.length && (!$2.current || $2.current.isEditorClosing || $2.current.isEditorClosed ? !$2.current && o3 && R2() : $2.current.isMounted && !$2.current.isStarted && ($2.current.isStarted = true, $2.current.startEvent.autoFocus && ("string" == typeof $2.current.startEvent.autoFocus ? $2.current.editorRefs[0]?.autoFocus($2.current.startEvent.autoFocus) : $2.current.editorRefs[0]?.autoFocus()), L2?.($2.current), requestAnimationFrame(() => {
1719
+ n2 && $2.current?.coords && n2.scrollCellCoordsIntoView($2.current.coords);
1720
1720
  })));
1721
- }, [j2]), s(() => {
1722
- B2.current = S2;
1723
- const e5 = A2.current?.coords;
1721
+ }, [V2]), s(() => {
1722
+ if (P2.current && ne.isEqualCells(P2.current, S2)) return;
1723
+ F2.current = S2;
1724
+ const e5 = $2.current?.coords;
1724
1725
  if (!ne.isEqualCells(e5, S2)) {
1725
- A2.current && (A2.current.isEditorClosing = true);
1726
- W2({ eventType: "coordsChange", activeCoords: S2 });
1726
+ $2.current && ($2.current.isEditorClosing = true);
1727
+ H2({ eventType: "coordsChange", activeCoords: S2 });
1727
1728
  }
1728
1729
  }, [S2]);
1729
- const K2 = i((e5) => {
1730
- U2(e5.nativeEvent);
1731
- }, []), { width: q2 = 0, height: Y2 = 0 } = C2 ?? { width: 0, height: 0 }, X2 = Tt(r2, [r2]);
1730
+ const q2 = i((e5) => {
1731
+ K2(e5.nativeEvent);
1732
+ }, []), { width: Y2 = 0, height: X2 = 0 } = C2 ?? { width: 0, height: 0 }, G2 = Tt(r2, [r2]);
1732
1733
  return { overlay: Tt((t3) => {
1733
- if (!A2.current || A2.current.isEditorClosed) return A2.current, null;
1734
- A2.current.coords;
1735
- let n3 = T2(t3, A2.current.coords, q2, Y2, b2, E2), o3 = true;
1736
- n3 && 0 !== n3.width && 0 !== n3.height || (n3 = { x: 0, y: 0, width: q2, height: q2 }, o3 = false);
1734
+ if (!$2.current || $2.current.isEditorClosed) return $2.current, null;
1735
+ $2.current.coords;
1736
+ let n3 = T2(t3, $2.current.coords, Y2, X2, b2, E2), o3 = true;
1737
+ n3 && 0 !== n3.width && 0 !== n3.height || (n3 = { x: 0, y: 0, width: Y2, height: Y2 }, o3 = false);
1737
1738
  const r3 = t3.getZoom(), i2 = { containerBounds: { x: 0, y: 0, width: n3.width / r3, height: n3.height / r3 }, setNaturalDimensions: M2, zoom: r3 };
1738
- return e(Wn, { session: A2.current, refLatestCoords: B2, handleSubmitEdit: D2, handleCancelEdit: L2, cellBounds: n3, borderStrokeWidth: v2, borderStrokeFill: y2, isInBounds: o3, getCellEditor: X2, propsEditor: i2, alignment: E2, ...x2 }, "editor:" + A2.current.uuid);
1739
- }, [r2, b2, j2, q2, Y2, E2, v2, y2]), startEdit: i((e5) => {
1740
- W2({ eventType: "start", startEvent: e5 });
1739
+ return e(Wn, { session: $2.current, refLatestCoords: F2, handleSubmitEdit: z2, handleCancelEdit: D2, cellBounds: n3, borderStrokeWidth: v2, borderStrokeFill: y2, isInBounds: o3, getCellEditor: G2, propsEditor: i2, alignment: E2, ...x2 }, "editor:" + $2.current.uuid);
1740
+ }, [r2, b2, V2, Y2, X2, E2, v2, y2]), startEdit: i((e5) => {
1741
+ H2({ eventType: "start", startEvent: e5 });
1741
1742
  }, []), submitEdit: i(() => {
1742
- W2({ eventType: "submit" });
1743
+ H2({ eventType: "submit" });
1743
1744
  }, []), cancelEdit: i(() => {
1744
- W2({ eventType: "cancel" });
1745
- }, []), onKeyboardEvent: K2, onPointerEvent: N2, onKeyboardEventNative: U2, onPointerEventNative: H2, isEditing: _2 };
1745
+ H2({ eventType: "cancel" });
1746
+ }, []), onKeyboardEvent: q2, onPointerEvent: U2, onKeyboardEventNative: K2, onPointerEventNative: N2, isEditing: _2 };
1746
1747
  }, Nn = ({ gridRef: e5, gridMainRef: t2, orientation: n2 = $, headerCount: o2, selectionPolicy: r2 = "multiple", newSelectionMode: s2 = "clear", alwaysScrollToActiveCoords: c2 = true, onDragStart: a2, onDragEnd: u2, pointerDownInterceptor: h2, pointerMoveInterceptor: f2, onPointerUp: p2, newSelection: g2, modifySelection: w2, appendSelection: m2, clearSelections: x2 }) => {
1747
1748
  const y2 = o2 ?? ((n2 === $ ? e5.current?.rowCount : e5.current?.columnCount) || 0), v2 = l(null), b2 = l(null), S2 = l(false), E2 = l(null), _2 = i((e6) => n2 === A ? { rowIndex: 0, colIndex: e6.colIndex } : { rowIndex: e6.rowIndex, colIndex: 0 }, [n2]), I2 = i((e6) => n2 === A ? { rowIndex: t2.current ? t2.current.rowCount - 1 : 0, colIndex: e6.colIndex } : { rowIndex: e6.rowIndex, colIndex: t2.current ? t2.current.columnCount - 1 : 0 }, [n2]), C2 = (e6) => {
1748
1749
  b2.current = I2(e6), w2(b2.current, v2.current);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sheetxl/grid-react",
3
3
  "description": "Grid - Advanced data grid component for React",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
6
6
  "type": "module",
7
7
  "exports": {
@@ -30,8 +30,8 @@
30
30
  "table"
31
31
  ],
32
32
  "dependencies": {
33
- "@sheetxl/utils": "^0.3.3",
34
- "@sheetxl/utils-react": "^0.3.3",
33
+ "@sheetxl/utils": "^0.3.4",
34
+ "@sheetxl/utils-react": "^0.3.4",
35
35
  "clsx": "^2.1.1",
36
36
  "react-merge-refs": "^3.0.2",
37
37
  "react-use": "^17.6.0",