@sheetxl/grid-react 0.3.3 → 0.3.5
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.
- package/browser/cjs/index.cjs +5 -5
- package/browser/esm/index.mjs +1434 -1422
- package/licenses/dependencies.txt +2 -2
- package/node/esm/index.mjs +86 -74
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Name: @sheetxl/utils
|
|
2
|
-
Version: 0.3.
|
|
2
|
+
Version: 0.3.5
|
|
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.
|
|
24
|
+
Version: 0.3.5
|
|
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.
|
package/node/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.
|
|
2
|
+
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.5
|
|
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),
|
|
1590
|
-
}, [c2]),
|
|
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]),
|
|
1593
|
-
e5.isSubmitted || e5.isCancelled || (
|
|
1594
|
-
}, [f2]),
|
|
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(),
|
|
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]),
|
|
1602
|
-
I2(false), g2?.(e5.coords),
|
|
1603
|
-
}, [g2]),
|
|
1604
|
-
e5 &&
|
|
1605
|
-
}, []),
|
|
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
|
-
|
|
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 =
|
|
1617
|
+
const t3 = B2.current;
|
|
1618
1618
|
w2(e5, t3) && (e5.stopPropagation(), e5.preventDefault()), e5.key;
|
|
1619
|
-
|
|
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
|
-
|
|
1627
|
+
O2?.(o4);
|
|
1628
1628
|
const i2 = Me.uuidV4();
|
|
1629
|
-
t4 = Object.freeze({ autoFocus: true, ...t4 }),
|
|
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,
|
|
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,
|
|
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 ||
|
|
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,114 @@ const kn = () => "sheetxl-ui-" + Mn++, Rn = o["useId".toString()], Pn = null !=
|
|
|
1647
1647
|
} };
|
|
1648
1648
|
return l2;
|
|
1649
1649
|
};
|
|
1650
|
-
if (
|
|
1651
|
-
const t3 =
|
|
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
|
-
})(
|
|
1659
|
-
let o3 =
|
|
1660
|
-
if (
|
|
1661
|
-
if (
|
|
1662
|
-
else if (
|
|
1663
|
-
if (
|
|
1664
|
-
|
|
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 ??
|
|
1670
|
-
|
|
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 (
|
|
1674
|
-
|
|
1675
|
-
|
|
1673
|
+
if ($2.current) {
|
|
1674
|
+
let e6 = false;
|
|
1675
|
+
switch (n3.which) {
|
|
1676
|
+
case bt:
|
|
1677
|
+
case Et:
|
|
1678
|
+
case St:
|
|
1679
|
+
case _t:
|
|
1680
|
+
case yt:
|
|
1681
|
+
case xt:
|
|
1682
|
+
e6 = true;
|
|
1683
|
+
}
|
|
1684
|
+
if (!e6) {
|
|
1685
|
+
$2.current.events.push(t3);
|
|
1686
|
+
for (let e7 = 0; e7 < $2.current.editorRefsDispatchEditorEvent.length; e7++) $2.current.editorRefsDispatchEditorEvent[e7](t3);
|
|
1687
|
+
}
|
|
1676
1688
|
} else {
|
|
1677
1689
|
if (w2(n3, t3.coords)) {
|
|
1678
1690
|
let n4;
|
|
1679
|
-
const o4 = e5(n4?.cell ??
|
|
1680
|
-
o4 && o4.events.push(t3),
|
|
1691
|
+
const o4 = e5(n4?.cell ?? B2.current, n4);
|
|
1692
|
+
o4 && o4.events.push(t3), $2.current = o4;
|
|
1681
1693
|
}
|
|
1682
1694
|
}
|
|
1683
1695
|
} else if ("pointer" === t3.eventType) {
|
|
1684
1696
|
const n3 = t3.event;
|
|
1685
|
-
if (
|
|
1686
|
-
|
|
1687
|
-
for (let e6 = 0; e6 <
|
|
1697
|
+
if ($2.current) {
|
|
1698
|
+
$2.current.events.push(t3);
|
|
1699
|
+
for (let e6 = 0; e6 < $2.current.editorRefsDispatchEditorEvent.length; e6++) $2.current.editorRefsDispatchEditorEvent[e6](t3);
|
|
1688
1700
|
} else {
|
|
1689
|
-
const o4 = t3?.coords ??
|
|
1701
|
+
const o4 = t3?.coords ?? B2.current, r3 = m2(n3, o4);
|
|
1690
1702
|
if (r3) {
|
|
1691
1703
|
let n4;
|
|
1692
1704
|
"boolean" != typeof n4 && (n4 = r3);
|
|
1693
1705
|
const i2 = e5(o4, n4);
|
|
1694
|
-
i2 && i2.events.push(t3),
|
|
1706
|
+
i2 && i2.events.push(t3), $2.current = i2;
|
|
1695
1707
|
}
|
|
1696
1708
|
}
|
|
1697
1709
|
} else if ("submit" === t3.eventType) {
|
|
1698
|
-
if (
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1710
|
+
if ($2.current && !$2.current.isSubmitted && !$2.current.isCancelled) {
|
|
1711
|
+
if (!$2.current.isMounted) return;
|
|
1712
|
+
z2($2.current);
|
|
1701
1713
|
}
|
|
1702
1714
|
} else if ("cancel" === t3.eventType) {
|
|
1703
|
-
if (
|
|
1704
|
-
if (
|
|
1705
|
-
|
|
1715
|
+
if ($2.current && !$2.current.isSubmitted && !$2.current.isCancelled) {
|
|
1716
|
+
if (!$2.current.isMounted) return;
|
|
1717
|
+
D2($2.current);
|
|
1706
1718
|
}
|
|
1707
1719
|
} else if ("coordsChange" === t3.eventType) {
|
|
1708
1720
|
const e6 = t3;
|
|
1709
|
-
if (
|
|
1710
|
-
if (
|
|
1721
|
+
if (B2.current = e6.activeCoords, $2.current, $2.current && !$2.current.isSubmitted && !$2.current.isCancelled) {
|
|
1722
|
+
if (!$2.current.isMounted) return;
|
|
1711
1723
|
try {
|
|
1712
|
-
|
|
1724
|
+
z2($2.current);
|
|
1713
1725
|
} catch (e7) {
|
|
1714
1726
|
}
|
|
1715
1727
|
}
|
|
1716
1728
|
}
|
|
1717
1729
|
}
|
|
1718
|
-
|
|
1719
|
-
n2 &&
|
|
1730
|
+
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(() => {
|
|
1731
|
+
n2 && $2.current?.coords && n2.scrollCellCoordsIntoView($2.current.coords);
|
|
1720
1732
|
})));
|
|
1721
|
-
}, [
|
|
1722
|
-
|
|
1723
|
-
const e5 =
|
|
1733
|
+
}, [V2]), s(() => {
|
|
1734
|
+
F2.current = S2;
|
|
1735
|
+
const e5 = $2.current?.coords;
|
|
1724
1736
|
if (!ne.isEqualCells(e5, S2)) {
|
|
1725
|
-
|
|
1726
|
-
|
|
1737
|
+
$2.current && ($2.current.isEditorClosing = true);
|
|
1738
|
+
H2({ eventType: "coordsChange", activeCoords: S2 });
|
|
1727
1739
|
}
|
|
1728
1740
|
}, [S2]);
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
}, []), { width:
|
|
1741
|
+
const q2 = i((e5) => {
|
|
1742
|
+
K2(e5.nativeEvent);
|
|
1743
|
+
}, []), { width: Y2 = 0, height: X2 = 0 } = C2 ?? { width: 0, height: 0 }, G2 = Tt(r2, [r2]);
|
|
1732
1744
|
return { overlay: Tt((t3) => {
|
|
1733
|
-
if (
|
|
1734
|
-
|
|
1735
|
-
let n3 = T2(t3,
|
|
1736
|
-
n3 && 0 !== n3.width && 0 !== n3.height || (n3 = { x: 0, y: 0, width:
|
|
1745
|
+
if (!$2.current || $2.current.isEditorClosed) return $2.current, null;
|
|
1746
|
+
$2.current.coords;
|
|
1747
|
+
let n3 = T2(t3, $2.current.coords, Y2, X2, b2, E2), o3 = true;
|
|
1748
|
+
n3 && 0 !== n3.width && 0 !== n3.height || (n3 = { x: 0, y: 0, width: Y2, height: Y2 }, o3 = false);
|
|
1737
1749
|
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:
|
|
1739
|
-
}, [r2, b2,
|
|
1740
|
-
|
|
1750
|
+
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);
|
|
1751
|
+
}, [r2, b2, V2, Y2, X2, E2, v2, y2]), startEdit: i((e5) => {
|
|
1752
|
+
H2({ eventType: "start", startEvent: e5 });
|
|
1741
1753
|
}, []), submitEdit: i(() => {
|
|
1742
|
-
|
|
1754
|
+
H2({ eventType: "submit" });
|
|
1743
1755
|
}, []), cancelEdit: i(() => {
|
|
1744
|
-
|
|
1745
|
-
}, []), onKeyboardEvent:
|
|
1756
|
+
H2({ eventType: "cancel" });
|
|
1757
|
+
}, []), onKeyboardEvent: q2, onPointerEvent: U2, onKeyboardEventNative: K2, onPointerEventNative: N2, isEditing: _2 };
|
|
1746
1758
|
}, 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
1759
|
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
1760
|
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.
|
|
4
|
+
"version": "0.3.5",
|
|
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.
|
|
34
|
-
"@sheetxl/utils-react": "^0.3.
|
|
33
|
+
"@sheetxl/utils": "^0.3.5",
|
|
34
|
+
"@sheetxl/utils-react": "^0.3.5",
|
|
35
35
|
"clsx": "^2.1.1",
|
|
36
36
|
"react-merge-refs": "^3.0.2",
|
|
37
37
|
"react-use": "^17.6.0",
|