@sheetxl/grid-react 0.4.21 → 0.5.0

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.4.21
2
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.5.0
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.
@@ -1372,8 +1372,8 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1372
1372
  if (!n2) return null;
1373
1373
  const { x: o2, y: r3 } = n2;
1374
1374
  let l3 = null;
1375
- const i2 = ke;
1376
- for (let e3 = 0; !l3 && e3 < i2.length; e3++) {
1375
+ const i2 = ke, c3 = i2.length;
1376
+ for (let e3 = 0; !l3 && e3 < c3; e3++) {
1377
1377
  const t3 = st[i2[e3]];
1378
1378
  t3 && se(o2, r3, t3.getBounds()) && (l3 = t3);
1379
1379
  }
@@ -1407,10 +1407,10 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1407
1407
  }, [dt, Qe, ut, et]), Ct = v((e2) => {
1408
1408
  let t2 = null;
1409
1409
  if (Object.keys(st).length > 1) {
1410
- const n2 = ke;
1411
- for (let o2 = 0; !t2 && o2 < n2.length; o2++) {
1412
- const r3 = st[n2[o2]];
1413
- r3 && k.isCellWithinRange(e2, r3.getVisibleRangeCoords()) && (t2 = r3);
1410
+ const n2 = ke, o2 = n2.length;
1411
+ for (let r3 = 0; !t2 && r3 < o2; r3++) {
1412
+ const o3 = st[n2[r3]];
1413
+ o3 && k.isCellWithinRange(e2, o3.getVisibleRangeCoords()) && (t2 = o3);
1414
1414
  }
1415
1415
  }
1416
1416
  return t2 || (t2 = st[O.Center]), t2;
@@ -1466,10 +1466,10 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1466
1466
  return e("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${i2.width}px`, height: `${i2.height}px`, overflow: "hidden" }, children: l3 }, `overlay-${t3.getAnchor()}-${o2}`);
1467
1467
  })(t2, 0));
1468
1468
  }, Dt = y(() => {
1469
- const e2 = {}, t2 = Object.keys(st);
1470
- for (let n2 = 0; n2 < t2.length; n2++) {
1471
- const o2 = t2[n2], r3 = [];
1472
- Pt(st[o2], r3), e2[o2] = { overlays: r3 };
1469
+ const e2 = {}, t2 = Object.keys(st), n2 = t2.length;
1470
+ for (let o2 = 0; o2 < n2; o2++) {
1471
+ const n3 = t2[o2], r3 = [];
1472
+ Pt(st[n3], r3), e2[n3] = { overlays: r3 };
1473
1473
  }
1474
1474
  return e2;
1475
1475
  }, [Le2, X2, a2, d2, rt, lt]), Tt = (t2, n2, o2, r3, l3, c3, s3) => {
@@ -1480,11 +1480,15 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1480
1480
  if (ue2) u3 = ue2(t2);
1481
1481
  else {
1482
1482
  u3 = [];
1483
- for (let e2 = 0; e2 < d3.length; e2++) for (let t3 = 0; t3 < a3.length; t3++) {
1484
- const n3 = { rowIndex: d3[e2], colIndex: a3[t3] };
1485
- if (ae2?.(n3)) continue;
1486
- const o3 = { coords: n3, range: we2(n3) };
1487
- u3.push(o3);
1483
+ const e2 = d3.length, t3 = a3.length;
1484
+ for (let n3 = 0; n3 < e2; n3++) {
1485
+ const e3 = d3[n3];
1486
+ for (let n4 = 0; n4 < t3; n4++) {
1487
+ const t4 = { rowIndex: e3, colIndex: a3[n4] };
1488
+ if (ae2?.(t4)) continue;
1489
+ const o3 = { coords: t4, range: we2(t4) };
1490
+ u3.push(o3);
1491
+ }
1488
1492
  }
1489
1493
  }
1490
1494
  const h3 = t2.getVisibleColumnOffsets(), g2 = t2.getVisibleRowOffsets(), f3 = t2.getScrollTopLeft(), w2 = t2.getFreezeTopLeft(), x2 = f3.left + w2.left, p2 = f3.top + w2.top, m2 = Math.trunc(x2 / De), v2 = Math.trunc(p2 / De), S2 = {}, y2 = (e2, t3, n3, o3, r4) => {
@@ -1498,8 +1502,8 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1498
1502
  f4 = N2({ key: l4, coords: t3, bounds: o3, zoom: he2, range: n3, view: e2, value: r4, style: { left: i.boundPixel(c4), top: i.boundPixel(s4), width: i.boundPixel(o3.width, true), height: i.boundPixel(o3.height, true) } });
1499
1503
  }
1500
1504
  s3?.set(l4, f4), g3.push(f4);
1501
- };
1502
- for (let e2 = 0; u3 && e2 < u3.length; e2++) {
1505
+ }, b3 = u3.length;
1506
+ for (let e2 = 0; u3 && e2 < b3; e2++) {
1503
1507
  const n3 = u3[e2], i2 = n3?.coords ?? n3;
1504
1508
  if (!i2) continue;
1505
1509
  const c4 = n3?.range ?? { rowStart: i2.rowIndex, colStart: i2.colIndex, rowEnd: i2.rowIndex, colEnd: i2.colIndex }, s4 = t2.getVisibleRangeCoords();
@@ -1521,23 +1525,23 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1521
1525
  const v3 = n3?.value;
1522
1526
  y2(t2, i2, c4, p3, v3);
1523
1527
  }
1524
- const b3 = x2 % De, C3 = p2 % De, I2 = Object.keys(S2);
1525
- for (let o3 = 0; o3 < I2.length; o3++) {
1526
- const r4 = S2[I2[o3]];
1527
- if (!r4) continue;
1528
- const l4 = Object.keys(r4);
1529
- for (let c4 = 0; c4 < l4.length; c4++) {
1530
- const s4 = r4[l4[c4]];
1531
- if (!s4) continue;
1532
- const a4 = parseInt(I2[o3]), d4 = parseInt(l4[c4]), u4 = a4 + v2, h4 = d4 + m2, g3 = `view:${t2.getAnchor()}:segment:${h4}:${u4}`;
1533
- n2.push(e("div", { className: "cell-container", style: { transform: `translate(${i.boundPixel(d4 * De - b3, true)}px, ${i.boundPixel(a4 * De - C3, true)}px)`, willChange: "transform" }, children: s4 }, g3));
1528
+ const C3 = x2 % De, I2 = p2 % De, E3 = Object.keys(S2), R2 = E3.length;
1529
+ for (let o3 = 0; o3 < R2; o3++) {
1530
+ const r4 = E3[o3], l4 = S2[r4];
1531
+ if (!l4) continue;
1532
+ const c4 = Object.keys(l4), s4 = c4.length;
1533
+ for (let o4 = 0; o4 < s4; o4++) {
1534
+ const s5 = c4[o4], a4 = l4[s5];
1535
+ if (!a4) continue;
1536
+ const d4 = parseInt(r4), u4 = parseInt(s5), h4 = d4 + v2, g3 = u4 + m2, f4 = `view:${t2.getAnchor()}:segment:${g3}:${h4}`;
1537
+ n2.push(e("div", { className: "cell-container", style: { transform: `translate(${i.boundPixel(u4 * De - C3, true)}px, ${i.boundPixel(d4 * De - I2, true)}px)`, willChange: "transform" }, children: a4 }, f4));
1534
1538
  }
1535
1539
  }
1536
1540
  }, Ot = y(() => {
1537
- const e2 = je2.current, t2 = /* @__PURE__ */ new Map(), n2 = {}, o2 = Object.keys(st);
1538
- for (let r3 = 0; r3 < o2.length; r3++) {
1539
- const l3 = o2[r3], i2 = [], c3 = [], s3 = [];
1540
- Tt(st[l3], s3, i2, c3, /* @__PURE__ */ new Set(), e2, t2), n2[l3] = { cells: s3, rangesH: i2, rangesV: c3 };
1541
+ const e2 = je2.current, t2 = /* @__PURE__ */ new Map(), n2 = {}, o2 = Object.keys(st), r3 = o2.length;
1542
+ for (let l3 = 0; l3 < r3; l3++) {
1543
+ const r4 = o2[l3], i2 = [], c3 = [], s3 = [];
1544
+ Tt(st[r4], s3, i2, c3, /* @__PURE__ */ new Set(), e2, t2), n2[r4] = { cells: s3, rangesH: i2, rangesV: c3 };
1541
1545
  }
1542
1546
  return je2.current = t2, n2;
1543
1547
  }, [Le2, a2, d2, rt, lt, z2, pe2, F2, ae2, ue2, we2]), zt = (t2, n2, o2, r3, l3) => {
@@ -1558,48 +1562,50 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1558
1562
  g2 && (a3 = a3.sort(k.columnFirstRangeComparator));
1559
1563
  const f3 = t2.getLayout(), w2 = f3.getRowOffset(h3 + 1);
1560
1564
  let x2 = c3;
1561
- for (let t3 = 0; t3 < a3.length + 1; t3++) {
1565
+ const p2 = a3.length;
1566
+ for (let t3 = 0; t3 < p2 + 1; t3++) {
1562
1567
  let n4 = x2, l5 = s3;
1563
1568
  const c4 = a3[t3];
1564
- t3 < a3.length && (l5 = Math.min(s3, f3.getColOffset(c4.colStart)), x2 = Math.min(s3, f3.getColOffset(c4.colEnd + 1))), r3.push(I("path", { d: `M ${i.boundPixel(n4)} ${i.boundPixel(w2, false, o2)} L ${i.boundPixel(l5)} ${i.boundPixel(w2, false, o2)}`, stroke: L2, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...$2, key: e2 + h3 + ":" + t3 }));
1569
+ t3 < p2 && (l5 = Math.min(s3, f3.getColOffset(c4.colStart)), x2 = Math.min(s3, f3.getColOffset(c4.colEnd + 1))), r3.push(I("path", { d: `M ${i.boundPixel(n4)} ${i.boundPixel(w2, false, o2)} L ${i.boundPixel(l5)} ${i.boundPixel(w2, false, o2)}`, stroke: L2, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...$2, key: e2 + h3 + ":" + t3 }));
1565
1570
  }
1566
- for (let e3 = a3.length - 1; e3 >= 0; e3--) a3[e3].rowEnd <= n3[l4 + 1] && a3.splice(e3, 1);
1571
+ for (let e3 = p2 - 1; e3 >= 0; e3--) a3[e3].rowEnd <= n3[l4 + 1] && a3.splice(e3, 1);
1567
1572
  }
1568
1573
  } else {
1569
1574
  const n3 = `view:${t2.getAnchor()}:vl:`, c3 = t2.getVisibleColumns();
1570
1575
  if (!c3 || 0 === c3.length) return;
1571
1576
  const s3 = 0, a3 = t2.getBounds().height;
1572
1577
  let d3 = [];
1573
- const u3 = l3.sort(k.columnFirstRangeComparator), h3 = t2.getVisibleRangeCoords();
1574
- for (let l4 = 0; l4 < c3.length && c3[l4] <= h3.colEnd; l4++) {
1575
- const g2 = c3[l4];
1576
- if (g2 < h3.colStart) continue;
1578
+ const u3 = l3.sort(k.columnFirstRangeComparator), h3 = t2.getVisibleRangeCoords(), g2 = c3.length;
1579
+ for (let l4 = 0; l4 < g2 && c3[l4] <= h3.colEnd; l4++) {
1580
+ const g3 = c3[l4];
1581
+ if (g3 < h3.colStart) continue;
1577
1582
  let f3 = false;
1578
- for (; u3.length > 0 && u3[0].colStart <= g2; ) {
1583
+ for (; u3.length > 0 && u3[0].colStart <= g3; ) {
1579
1584
  const e2 = u3.shift();
1580
- e2.colEnd > g2 && (d3.push(e2), f3 = true);
1585
+ e2.colEnd > g3 && (d3.push(e2), f3 = true);
1581
1586
  }
1582
1587
  f3 && (d3 = d3.sort(k.rowFirstRangeComparator));
1583
- const w2 = t2.getLayout(), x2 = w2.getColOffset(g2 + 1);
1588
+ const w2 = t2.getLayout(), x2 = w2.getColOffset(g3 + 1);
1584
1589
  let p2 = s3;
1585
- for (let t3 = 0; t3 < d3.length + 1; t3++) {
1590
+ const m2 = d3.length;
1591
+ for (let t3 = 0; t3 < m2 + 1; t3++) {
1586
1592
  let l5 = p2, c4 = a3;
1587
1593
  const s4 = d3[t3];
1588
- t3 < d3.length && (c4 = Math.min(a3, w2.getRowOffset(s4.rowStart)), p2 = Math.min(a3, w2.getRowOffset(s4.rowEnd + 1)));
1594
+ t3 < m2 && (c4 = Math.min(a3, w2.getRowOffset(s4.rowStart)), p2 = Math.min(a3, w2.getRowOffset(s4.rowEnd + 1)));
1589
1595
  let u4 = L2;
1590
- r3.push(e("path", { d: `M ${i.boundPixel(x2, false, o2)} ${i.boundPixel(l5)} L ${i.boundPixel(x2, false, o2)} ${i.boundPixel(c4)}`, stroke: u4, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...B2 }, n3 + g2 + ":" + t3));
1596
+ r3.push(e("path", { d: `M ${i.boundPixel(x2, false, o2)} ${i.boundPixel(l5)} L ${i.boundPixel(x2, false, o2)} ${i.boundPixel(c4)}`, stroke: u4, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...B2 }, n3 + g3 + ":" + t3));
1591
1597
  }
1592
- for (let e2 = d3.length - 1; e2 >= 0; e2--) d3[e2].colEnd <= c3[l4 + 1] && d3.splice(e2, 1);
1598
+ for (let e2 = m2 - 1; e2 >= 0; e2--) d3[e2].colEnd <= c3[l4 + 1] && d3.splice(e2, 1);
1593
1599
  }
1594
1600
  }
1595
1601
  }, Lt = (t2) => {
1596
1602
  if (!Ot) return;
1597
- const n2 = {};
1598
- for (let o2 = 0; o2 < at.length; o2++) {
1599
- const r3 = at[o2], l3 = st[r3], i2 = [];
1600
- zt(l3, t2, 0, i2, t2 ? Ot[r3].rangesH : Ot[r3].rangesV);
1603
+ const n2 = {}, o2 = at.length;
1604
+ for (let r3 = 0; r3 < o2; r3++) {
1605
+ const o3 = at[r3], l3 = st[o3], i2 = [];
1606
+ zt(l3, t2, 0, i2, t2 ? Ot[o3].rangesH : Ot[o3].rangesV);
1601
1607
  const c3 = l3.getRangeCoordsBounds(), s3 = Math.ceil(c3.width), a3 = Math.ceil(c3.height);
1602
- n2[r3] = e("svg", { width: `${s3}`, height: `${a3}`, viewBox: `0 0 ${s3} ${a3}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: i2 });
1608
+ n2[o3] = e("svg", { width: `${s3}`, height: `${a3}`, viewBox: `0 0 ${s3} ${a3}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: i2 });
1603
1609
  }
1604
1610
  return n2;
1605
1611
  }, $t = y(() => true === z2 || true === z2?.horizontal ? Lt(true) : null, [Le2, z2, rt, U2, A2, L2, $2, a2, d2, Qe, dt, Ot]), Bt = y(() => true === z2 || true === z2?.vertical ? Lt(false) : null, [Le2, z2, lt, U2, A2, L2, B2, a2, d2, et, ut, Ot]), Ft = y(() => 0 === ht.left ? null : e(de, { linePoints: [0, 0, 0, et + 1], bounds: { x: ht.left, y: 0, width: 1, height: et + 1 }, ...H2 }), [Le2, ht.left, et, H2]), Wt = y(() => 0 === ht.top ? null : e(de, { linePoints: [0, 0, Qe + 1, 0], bounds: { x: 0, y: ht.top, width: Qe + 1, height: 1 }, ...K2 }), [Le2, ht.top, Qe, K2]), At = y(() => {
@@ -1607,28 +1613,28 @@ const xe = -10, pe = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
1607
1613
  if (!e2 || !st[e2]) return;
1608
1614
  const n2 = st[e2].getBounds();
1609
1615
  return t("div", { style: { position: "absolute", pointerEvents: "none", left: n2.x, top: n2.y, width: n2.width, height: n2.height, clip: `rect(0, ${n2.width + 1}px, ${n2.height + 1}px, 0)` }, className: `view view-${e2}`, children: [$t?.[e2], Bt?.[e2], Ot?.[e2].cells] }, `view:${e2}`);
1610
- };
1611
- for (let e2 = 0; e2 < at.length; e2++) o2.push(r3(at[e2]));
1616
+ }, l3 = at.length;
1617
+ for (let e2 = 0; e2 < l3; e2++) o2.push(r3(at[e2]));
1612
1618
  return e(n, { children: o2 });
1613
1619
  }, [st, $t, Bt, Ot]), Vt = y(() => {
1614
1620
  if (!l2) return;
1615
1621
  const e2 = (e3, t2, n3, o3) => {
1616
1622
  if (!o3 || 0 === o3.length) return;
1617
- const r4 = [];
1618
- for (let l3 = 0; l3 < o3.length; l3++) {
1619
- const i3 = o3[l3];
1620
- let c4 = e3?.get(i3);
1621
- c4 !== Te && (c4 = i3(n3) ?? Te), t2.set(i3, c4), c4 && c4 !== Te && r4.push(c4);
1623
+ const r4 = [], l3 = o3.length;
1624
+ for (let i3 = 0; i3 < l3; i3++) {
1625
+ const l4 = o3[i3];
1626
+ let c4 = e3?.get(l4);
1627
+ c4 !== Te && (c4 = l4(n3) ?? Te), t2.set(l4, c4), c4 && c4 !== Te && r4.push(c4);
1622
1628
  }
1623
1629
  return r4;
1624
1630
  }, n2 = (n3, o3, r4) => {
1625
1631
  if (!r4) return;
1626
1632
  const l3 = r4.getBounds(), i3 = r4.getInsets(), c4 = r4.getAnchor();
1627
1633
  return t("div", { className: M("view", `view-${c4}`, Ie.view), style: { position: "absolute", pointerEvents: "none", left: l3.x - i3.left, top: l3.y - i3.top, width: l3.width - (i3.left + i3.right), height: l3.height - (i3.top + i3.bottom), clipPath: J2 ? "inset(-2px)" : "inset(0px)" }, children: [e2(n3, o3, r4, G2), Dt?.[c4].overlays] }, `view:${c4}`);
1628
- }, o2 = it.current, r3 = {}, i2 = [], c3 = Object.keys(st);
1629
- for (let e3 = 0; e3 < c3.length; e3++) {
1630
- const t2 = c3[e3], l3 = o2?.[t2], s3 = r3[t2] = /* @__PURE__ */ new Map();
1631
- i2.push(n2(l3, s3, st[t2]));
1634
+ }, o2 = it.current, r3 = {}, i2 = [], c3 = Object.keys(st), s3 = c3.length;
1635
+ for (let e3 = 0; e3 < s3; e3++) {
1636
+ const t2 = c3[e3], l3 = o2?.[t2], s4 = r3[t2] = /* @__PURE__ */ new Map();
1637
+ i2.push(n2(l3, s4, st[t2]));
1632
1638
  }
1633
1639
  return it.current = r3, i2;
1634
1640
  }, [Le2, st, J2, G2]), Ut = y(() => {
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.4.21",
4
+ "version": "0.5.0",
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.4.21",
34
- "@sheetxl/utils-react": "^0.4.21",
33
+ "@sheetxl/utils": "^0.5.0",
34
+ "@sheetxl/utils-react": "^0.5.0",
35
35
  "clsx": "^2.1.1",
36
36
  "react-merge-refs": "^3.0.2",
37
37
  "react-use": "^17.6.0",