@sage-bionetworks/react-datasheet-grid 4.11.5-sage.12 → 4.11.5-sage.13
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +409 -389
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -322,19 +322,19 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
322
322
|
}, he = (e, t) => e ? {
|
|
323
323
|
min: pe(e.min, t),
|
|
324
324
|
max: pe(e.max, t)
|
|
325
|
-
} : null, ge = () => Array.from(document.querySelectorAll("*")).filter((e) => e instanceof HTMLElement && typeof e.tabIndex == "number" && e.tabIndex >= 0 && !e.disabled && (!(e instanceof HTMLAnchorElement) || !!e.href || e.getAttribute("tabIndex") !== null) && getComputedStyle(e).visibility !== "collapse"), _e = ({ children: e, gutter: t, stickyRight: n, stickyLeft: r, active: i, disabled: a, className: o, width: s, left: c }) => /* @__PURE__ */ u("div", {
|
|
325
|
+
} : null, ge = () => Array.from(document.querySelectorAll("*")).filter((e) => e instanceof HTMLElement && typeof e.tabIndex == "number" && e.tabIndex >= 0 && !e.disabled && (!(e instanceof HTMLAnchorElement) || !!e.href || e.getAttribute("tabIndex") !== null) && getComputedStyle(e).visibility !== "collapse"), _e = (e, t) => e.key?.toLowerCase() === t, ve = (e) => (e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey && _e(e, "z"), ye = (e) => !e.altKey && (e.ctrlKey && !e.shiftKey && _e(e, "y") || (e.ctrlKey || e.metaKey) && e.shiftKey && _e(e, "z")), be = ({ children: e, gutter: t, stickyRight: n, stickyLeft: r, active: i, disabled: a, className: o, width: s, left: c }) => /* @__PURE__ */ u("div", {
|
|
326
326
|
className: v("dsg-cell", t && "dsg-cell-gutter", a && "dsg-cell-disabled", t && i && "dsg-cell-gutter-active", n && "dsg-cell-sticky-right", r && "dsg-cell-sticky-left", o),
|
|
327
327
|
style: {
|
|
328
328
|
width: s,
|
|
329
329
|
left: n ? void 0 : c
|
|
330
330
|
},
|
|
331
331
|
children: e
|
|
332
|
-
}),
|
|
332
|
+
}), xe = (e, t) => a(() => {
|
|
333
333
|
let n = /* @__PURE__ */ new Map();
|
|
334
334
|
return (r) => (n.has(r) || n.set(r, (...n) => {
|
|
335
335
|
e(r, ...n.slice(0, t));
|
|
336
336
|
}), n.get(r));
|
|
337
|
-
}, [t, e]),
|
|
337
|
+
}, [t, e]), Se = ({ data: e, columns: r, outerRef: i, innerRef: a, columnWidths: o, hasStickyRightColumn: s, pinFirstColumn: c, displayHeight: l, headerRowHeight: f, rowHeight: p, getRowSize: m, rowKey: h, fullWidth: y, selection: b, activeCell: x, rowClassName: S, cellClassName: C, children: w, editing: T, getContextMenuItems: E, setRowData: D, deleteRows: O, duplicateRows: ee, insertRowAfter: k, stopEditing: A, onScroll: te }) => {
|
|
338
338
|
let j = t((t) => {
|
|
339
339
|
if (h && t > 0) {
|
|
340
340
|
let n = e[t - 1];
|
|
@@ -376,7 +376,7 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
376
376
|
}, [N, o]), n(() => {
|
|
377
377
|
M.measure();
|
|
378
378
|
}, [M, p]);
|
|
379
|
-
let ne =
|
|
379
|
+
let ne = xe(D, 1), re = xe(O, 0), P = xe(ee, 0), F = xe(k, 0), ie = (e) => {
|
|
380
380
|
if (!r[e].stickyLeft) return 0;
|
|
381
381
|
if (!o?.length) {
|
|
382
382
|
let t = N.getOffsetForIndex(e);
|
|
@@ -406,7 +406,7 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
406
406
|
},
|
|
407
407
|
children: N.getVirtualItems().map((e) => {
|
|
408
408
|
let t = !!r[e.index].stickyLeft;
|
|
409
|
-
return /* @__PURE__ */ u(
|
|
409
|
+
return /* @__PURE__ */ u(be, {
|
|
410
410
|
gutter: e.index === 0,
|
|
411
411
|
stickyRight: s && e.index === r.length - 1,
|
|
412
412
|
stickyLeft: t,
|
|
@@ -437,7 +437,7 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
437
437
|
rowData: e[t.index],
|
|
438
438
|
rowIndex: t.index
|
|
439
439
|
}), d = x?.row === t.index && x.col === i.index - 1, f = !!r[i.index].stickyLeft;
|
|
440
|
-
return /* @__PURE__ */ u(
|
|
440
|
+
return /* @__PURE__ */ u(be, {
|
|
441
441
|
gutter: i.index === 0,
|
|
442
442
|
stickyRight: s && i.index === r.length - 1,
|
|
443
443
|
stickyLeft: f,
|
|
@@ -477,13 +477,13 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
477
477
|
]
|
|
478
478
|
})
|
|
479
479
|
});
|
|
480
|
-
},
|
|
480
|
+
}, Ce = (e, t, n, r) => [
|
|
481
481
|
[r, e],
|
|
482
482
|
[t, e],
|
|
483
483
|
[t, n],
|
|
484
484
|
[r, n],
|
|
485
485
|
[r, e]
|
|
486
|
-
],
|
|
486
|
+
], we = (e, t, n, r) => `polygon(evenodd, ${[...Ce(0, "100%", "100%", 0), ...Ce(e, t, n, r)].map((e) => e.map((e) => typeof e == "number" && e !== 0 ? e + "px" : e).join(" ")).join(",")})`, Te = e.memo(({ columnWidths: e, columnRights: t, headerRowHeight: n, selection: r, rowHeight: i, activeCell: o, hasStickyRightColumn: s, dataLength: c, viewWidth: f, viewHeight: p, contentWidth: m, edges: h, isCellDisabled: g, editing: _, expandSelection: y, stickyLeftColumns: b, getStickyLeftOffset: x }) => {
|
|
487
487
|
let S = o ? g(o) : !1, C = a(() => {
|
|
488
488
|
if (!r) return S;
|
|
489
489
|
for (let e = r.min.col; e <= r.max.col; ++e) for (let t = r.min.row; t <= r.max.row; ++t) if (!g({
|
|
@@ -615,7 +615,7 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
615
615
|
className: v("dsg-selection-rect", C && "dsg-selection-rect-disabled"),
|
|
616
616
|
style: {
|
|
617
617
|
...D,
|
|
618
|
-
clipPath:
|
|
618
|
+
clipPath: we(E.top - D.top, E.left - D.left, E.top + E.height - D.top, E.left + E.width - D.left)
|
|
619
619
|
}
|
|
620
620
|
}),
|
|
621
621
|
D && E && k && /* @__PURE__ */ u("div", {
|
|
@@ -635,7 +635,7 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
635
635
|
width: D.width,
|
|
636
636
|
height: "100%",
|
|
637
637
|
background: "var(--dsg-selection-background-color)",
|
|
638
|
-
clipPath:
|
|
638
|
+
clipPath: we(E.top - D.top, ee - A, E.top + E.height - D.top, ee + E.width - A)
|
|
639
639
|
}
|
|
640
640
|
})
|
|
641
641
|
}),
|
|
@@ -687,9 +687,9 @@ var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
687
687
|
})
|
|
688
688
|
] });
|
|
689
689
|
});
|
|
690
|
-
|
|
690
|
+
Te.displayName = "SelectionRect";
|
|
691
691
|
// src/hooks/useRowHeights.ts
|
|
692
|
-
var
|
|
692
|
+
var Ee = ({ value: e, rowHeight: t }) => {
|
|
693
693
|
let n = o([]), [, r] = s(0);
|
|
694
694
|
return a(() => {
|
|
695
695
|
let i = (r) => {
|
|
@@ -752,81 +752,81 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
752
752
|
}
|
|
753
753
|
};
|
|
754
754
|
}, [t, e]);
|
|
755
|
-
},
|
|
756
|
-
let
|
|
755
|
+
}, De = [], Oe = [], ke = () => ({}), Ae = () => null, je = ({ rowData: e }) => ({ ...e }), Me = e.memo(e.forwardRef(({ value: e = De, className: i, style: l, height: f = 400, onChange: p = Ae, columns: h = Oe, rowHeight: g = 40, headerRowHeight: _ = typeof g == "number" ? g : 40, gutterColumn: v, stickyRightColumn: y, rowKey: b, addRowsComponent: S = ne, createRow: C = ke, autoAddRow: w = !1, lockRows: T = !1, disableExpandSelection: E = !1, disableSmartDelete: D = !1, duplicateRow: O = je, contextMenuComponent: ee = ie, disableContextMenu: N = !1, onFocus: P = Ae, onBlur: F = Ae, onActiveCellChange: ae = Ae, onSelectionChange: oe = Ae, rowClassName: _e, cellClassName: be, onScroll: xe, pinFirstColumn: Ce = !1, onUndo: we, onRedo: Me }, Ne) => {
|
|
756
|
+
let Pe = o(null), Fe = N || T, I = k(h, v, y, Ce), L = !!y, Ie = Ce || !!I[1]?.stickyLeft, Le = o(null), R = o(null), Re = o(null), ze = o(null), [Be, Ve] = re(1, 100), { getRowSize: He, totalSize: Ue, getRowIndex: We } = Ee({
|
|
757
757
|
value: e,
|
|
758
758
|
rowHeight: g
|
|
759
|
-
}),
|
|
759
|
+
}), Ge = Math.min(f, _ + Ue(f) + Be), { width: Ke, height: qe } = c({
|
|
760
760
|
targetRef: R,
|
|
761
761
|
refreshMode: "throttle",
|
|
762
762
|
refreshRate: 100
|
|
763
763
|
});
|
|
764
|
-
|
|
765
|
-
let
|
|
764
|
+
Ve(qe ? Ge - qe : 0);
|
|
765
|
+
let Je = te(R, Ke, qe), { fullWidth: Ye, totalWidth: Xe, columnWidths: z, columnRights: B } = x(I, Ke), Ze = a(() => I.slice(1).map((e) => !!e.stickyLeft), [I]), Qe = t((e) => {
|
|
766
766
|
if (!I[e]?.stickyLeft) return 0;
|
|
767
|
-
if (!
|
|
767
|
+
if (!z?.length) {
|
|
768
768
|
let t = 0;
|
|
769
769
|
for (let n = 0; n < e; n++) (I[n].stickyLeft || n === 0) && (t += I[n].basis || I[n].minWidth || 100);
|
|
770
770
|
return t;
|
|
771
771
|
}
|
|
772
772
|
let t = 0;
|
|
773
|
-
for (let n = 0; n < e; n++) (I[n].stickyLeft || n === 0) && (t +=
|
|
773
|
+
for (let n = 0; n < e; n++) (I[n].stickyLeft || n === 0) && (t += z[n]);
|
|
774
774
|
return t;
|
|
775
|
-
}, [I,
|
|
775
|
+
}, [I, z]), [$e, V] = s(null), [et, tt] = s([]), [H, U] = s(!1), [nt, rt] = s(0), [it, at] = s(null), [W, G] = A(null), [K, q] = A(null), J = a(() => W && K && {
|
|
776
776
|
min: {
|
|
777
|
-
col: Math.min(
|
|
778
|
-
row: Math.min(
|
|
777
|
+
col: Math.min(W.col, K.col),
|
|
778
|
+
row: Math.min(W.row, K.row)
|
|
779
779
|
},
|
|
780
780
|
max: {
|
|
781
|
-
col: Math.max(
|
|
782
|
-
row: Math.max(
|
|
781
|
+
col: Math.max(W.col, K.col),
|
|
782
|
+
row: Math.max(W.row, K.row)
|
|
783
783
|
}
|
|
784
|
-
}, [
|
|
784
|
+
}, [W, K]), [Y, ot] = A({
|
|
785
785
|
columns: !1,
|
|
786
786
|
rows: !1,
|
|
787
787
|
active: !1
|
|
788
|
-
}),
|
|
788
|
+
}), st = E || H || Y.active || W?.row === e?.length - 1 || J?.max.row === e?.length - 1 || W && I.slice((J?.min.col ?? W.col) + 1, (J?.max.col ?? W.col) + 2).every((e) => e.disabled === !0) ? null : nt, ct = M(Le), lt = M(R);
|
|
789
789
|
n(() => {
|
|
790
|
-
|
|
791
|
-
}, [
|
|
792
|
-
let
|
|
793
|
-
let r =
|
|
794
|
-
if (r &&
|
|
790
|
+
W !== null && (document.activeElement.blur(), window.getSelection()?.removeAllRanges());
|
|
791
|
+
}, [W !== null]);
|
|
792
|
+
let ut = t((e, t = !1, n = !1) => {
|
|
793
|
+
let r = ct(t), i = n && lt(t);
|
|
794
|
+
if (r && B && z) {
|
|
795
795
|
let t = e.clientX - r.left, n = e.clientY - r.top;
|
|
796
|
-
return i && (e.clientY - i.top <= _ && (n = 0), e.clientX - i.left <=
|
|
797
|
-
col:
|
|
798
|
-
row:
|
|
796
|
+
return i && (e.clientY - i.top <= _ && (n = 0), e.clientX - i.left <= z[0] && (t = 0), Ie && e.clientX - i.left <= z[0] + z[1] && (t = B[0] + 1), L && i.right - e.clientX <= z.at(-1) && (t = B.at(-2) + 1)), {
|
|
797
|
+
col: B.findIndex((e) => t < e) - 1,
|
|
798
|
+
row: We(n - _)
|
|
799
799
|
};
|
|
800
800
|
}
|
|
801
801
|
return null;
|
|
802
802
|
}, [
|
|
803
|
-
V,
|
|
804
803
|
B,
|
|
804
|
+
z,
|
|
805
805
|
e.length,
|
|
806
|
-
|
|
807
|
-
|
|
806
|
+
ct,
|
|
807
|
+
lt,
|
|
808
808
|
_,
|
|
809
809
|
L,
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
]),
|
|
813
|
-
|
|
814
|
-
let
|
|
810
|
+
Ie,
|
|
811
|
+
We
|
|
812
|
+
]), X = o(e);
|
|
813
|
+
X.current = e;
|
|
814
|
+
let Z = t((e) => {
|
|
815
815
|
let t = I[e.col + 1].disabled;
|
|
816
816
|
return !!(typeof t == "function" ? t({
|
|
817
|
-
rowData:
|
|
817
|
+
rowData: X.current[e.row],
|
|
818
818
|
rowIndex: e.row
|
|
819
819
|
}) : t);
|
|
820
|
-
}, [I]),
|
|
821
|
-
T || (
|
|
822
|
-
...
|
|
820
|
+
}, [I]), Q = t((e, t = 1) => {
|
|
821
|
+
T || (q(null), U(!1), p([
|
|
822
|
+
...X.current.slice(0, e + 1),
|
|
823
823
|
...Array(t).fill(0).map(C),
|
|
824
|
-
...
|
|
824
|
+
...X.current.slice(e + 1)
|
|
825
825
|
], [{
|
|
826
826
|
type: "CREATE",
|
|
827
827
|
fromRowIndex: e + 1,
|
|
828
828
|
toRowIndex: e + 1 + t
|
|
829
|
-
}]),
|
|
829
|
+
}]), G((n) => ({
|
|
830
830
|
col: n?.col || 0,
|
|
831
831
|
row: e + t,
|
|
832
832
|
doNotScrollX: !0
|
|
@@ -835,80 +835,80 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
835
835
|
C,
|
|
836
836
|
T,
|
|
837
837
|
p,
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
]),
|
|
838
|
+
G,
|
|
839
|
+
q
|
|
840
|
+
]), dt = t((e, t = e) => {
|
|
841
841
|
T || (p([
|
|
842
|
-
...
|
|
843
|
-
...
|
|
842
|
+
...X.current.slice(0, t + 1),
|
|
843
|
+
...X.current.slice(e, t + 1).map((t, n) => O({
|
|
844
844
|
rowData: t,
|
|
845
845
|
rowIndex: n + e
|
|
846
846
|
})),
|
|
847
|
-
...
|
|
847
|
+
...X.current.slice(t + 1)
|
|
848
848
|
], [{
|
|
849
849
|
type: "CREATE",
|
|
850
850
|
fromRowIndex: t + 1,
|
|
851
851
|
toRowIndex: t + 2 + t - e
|
|
852
|
-
}]),
|
|
852
|
+
}]), G({
|
|
853
853
|
col: 0,
|
|
854
854
|
row: t + 1,
|
|
855
855
|
doNotScrollX: !0
|
|
856
|
-
}),
|
|
856
|
+
}), q({
|
|
857
857
|
col: I.length - (L ? 3 : 2),
|
|
858
858
|
row: 2 * t - e + 1,
|
|
859
859
|
doNotScrollX: !0
|
|
860
|
-
}),
|
|
860
|
+
}), U(!1));
|
|
861
861
|
}, [
|
|
862
862
|
I.length,
|
|
863
863
|
O,
|
|
864
864
|
T,
|
|
865
865
|
p,
|
|
866
|
-
|
|
867
|
-
|
|
866
|
+
G,
|
|
867
|
+
q,
|
|
868
868
|
L
|
|
869
|
-
]),
|
|
870
|
-
if (
|
|
869
|
+
]), $ = t((e) => {
|
|
870
|
+
if (qe && Ke) {
|
|
871
871
|
if (!e.doNotScrollY) {
|
|
872
|
-
let t =
|
|
872
|
+
let t = He(e.row).top, n = He(e.row).top + He(e.row).height + _ - qe + 1, r = R.current.scrollTop;
|
|
873
873
|
r > t ? R.current.scrollTop = t : r < n && (R.current.scrollTop = n);
|
|
874
874
|
}
|
|
875
|
-
if (
|
|
876
|
-
let t =
|
|
875
|
+
if (B && z && R.current && !e.doNotScrollX) {
|
|
876
|
+
let t = B[e.col] - B[0], n = B[e.col] + z[e.col + 1] + (L ? z.at(-1) : 0) - Ke + 1, r = R.current.scrollLeft;
|
|
877
877
|
r > t ? R.current.scrollLeft = t : r < n && (R.current.scrollLeft = n);
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
}, [
|
|
881
|
-
|
|
882
|
-
|
|
881
|
+
qe,
|
|
882
|
+
Ke,
|
|
883
883
|
_,
|
|
884
|
-
V,
|
|
885
884
|
B,
|
|
886
|
-
|
|
885
|
+
z,
|
|
886
|
+
He,
|
|
887
887
|
L
|
|
888
888
|
]);
|
|
889
889
|
n(() => {
|
|
890
|
-
|
|
891
|
-
}, [
|
|
892
|
-
|
|
893
|
-
}, [
|
|
894
|
-
let
|
|
890
|
+
K && $(K);
|
|
891
|
+
}, [K, $]), n(() => {
|
|
892
|
+
W && $(W);
|
|
893
|
+
}, [W, $]);
|
|
894
|
+
let ft = t((e, t) => {
|
|
895
895
|
p([
|
|
896
|
-
...
|
|
896
|
+
...X.current.slice(0, e),
|
|
897
897
|
t,
|
|
898
|
-
...
|
|
898
|
+
...X.current.slice(e + 1)
|
|
899
899
|
], [{
|
|
900
900
|
type: "UPDATE",
|
|
901
901
|
fromRowIndex: e,
|
|
902
902
|
toRowIndex: e + 1
|
|
903
903
|
}]);
|
|
904
|
-
}, [p]),
|
|
905
|
-
T || (
|
|
906
|
-
let r = Math.min(
|
|
904
|
+
}, [p]), pt = t((e, t = e) => {
|
|
905
|
+
T || (U(!1), G((n) => {
|
|
906
|
+
let r = Math.min(X.current.length - 2 - t + e, e);
|
|
907
907
|
return r < 0 ? null : n && {
|
|
908
908
|
col: n.col,
|
|
909
909
|
row: r
|
|
910
910
|
};
|
|
911
|
-
}),
|
|
911
|
+
}), q(null), p([...X.current.slice(0, e), ...X.current.slice(t + 1)], [{
|
|
912
912
|
type: "DELETE",
|
|
913
913
|
fromRowIndex: e,
|
|
914
914
|
toRowIndex: t + 1
|
|
@@ -916,21 +916,21 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
916
916
|
}, [
|
|
917
917
|
T,
|
|
918
918
|
p,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
]),
|
|
919
|
+
G,
|
|
920
|
+
q
|
|
921
|
+
]), mt = t((t = !0) => {
|
|
922
922
|
let n = t && !D;
|
|
923
|
-
if (!
|
|
924
|
-
let r =
|
|
923
|
+
if (!W) return;
|
|
924
|
+
let r = J?.min || W, i = J?.max || W;
|
|
925
925
|
if (e.slice(r.row, i.row + 1).every((e, t) => I.every((n) => n.isCellEmpty({
|
|
926
926
|
rowData: e,
|
|
927
927
|
rowIndex: t + r.row
|
|
928
928
|
})))) {
|
|
929
|
-
n &&
|
|
929
|
+
n && pt(r.row, i.row);
|
|
930
930
|
return;
|
|
931
931
|
}
|
|
932
932
|
let a = [...e];
|
|
933
|
-
for (let e = r.row; e <= i.row; ++e) for (let t = r.col; t <= i.col; ++t) if (!
|
|
933
|
+
for (let e = r.row; e <= i.row; ++e) for (let t = r.col; t <= i.col; ++t) if (!Z({
|
|
934
934
|
col: t,
|
|
935
935
|
row: e
|
|
936
936
|
})) {
|
|
@@ -940,11 +940,11 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
940
940
|
rowIndex: e
|
|
941
941
|
});
|
|
942
942
|
}
|
|
943
|
-
n && m(a, e) ? (
|
|
943
|
+
n && m(a, e) ? (G({
|
|
944
944
|
col: 0,
|
|
945
945
|
row: r.row,
|
|
946
946
|
doNotScrollX: !0
|
|
947
|
-
}),
|
|
947
|
+
}), q({
|
|
948
948
|
col: I.length - (L ? 3 : 2),
|
|
949
949
|
row: i.row,
|
|
950
950
|
doNotScrollX: !0
|
|
@@ -954,30 +954,30 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
954
954
|
toRowIndex: i.row + 1
|
|
955
955
|
}]);
|
|
956
956
|
}, [
|
|
957
|
-
|
|
957
|
+
W,
|
|
958
958
|
I,
|
|
959
959
|
e,
|
|
960
|
-
|
|
961
|
-
|
|
960
|
+
pt,
|
|
961
|
+
Z,
|
|
962
962
|
p,
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
963
|
+
J?.max,
|
|
964
|
+
J?.min,
|
|
965
|
+
G,
|
|
966
|
+
q,
|
|
967
967
|
L
|
|
968
|
-
]),
|
|
969
|
-
|
|
968
|
+
]), ht = t(({ nextRow: e = !0 } = {}) => {
|
|
969
|
+
W?.row === X.current.length - 1 ? e && w ? Q(W.row) : U(!1) : (U(!1), e && G((e) => e && {
|
|
970
970
|
col: e.col,
|
|
971
971
|
row: e.row + 1
|
|
972
972
|
}));
|
|
973
973
|
}, [
|
|
974
|
-
|
|
974
|
+
W?.row,
|
|
975
975
|
w,
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
]),
|
|
979
|
-
if (!
|
|
980
|
-
let n = [], r =
|
|
976
|
+
Q,
|
|
977
|
+
G
|
|
978
|
+
]), gt = t(async (t) => {
|
|
979
|
+
if (!H && W) {
|
|
980
|
+
let n = [], r = J?.min || W, i = J?.max || W;
|
|
981
981
|
for (let t = r.row; t <= i.row; ++t) {
|
|
982
982
|
n.push([]);
|
|
983
983
|
for (let a = r.col; a <= i.col; ++a) {
|
|
@@ -1008,25 +1008,25 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1008
1008
|
s || alert("This action is unavailable in your browser, but you can still use Ctrl+C for copy or Ctrl+X for cut");
|
|
1009
1009
|
}
|
|
1010
1010
|
}, [
|
|
1011
|
-
|
|
1011
|
+
W,
|
|
1012
1012
|
I,
|
|
1013
1013
|
e,
|
|
1014
|
-
|
|
1015
|
-
|
|
1014
|
+
H,
|
|
1015
|
+
J
|
|
1016
1016
|
]);
|
|
1017
|
-
j("copy",
|
|
1018
|
-
let
|
|
1019
|
-
!
|
|
1017
|
+
j("copy", gt);
|
|
1018
|
+
let _t = t((e) => {
|
|
1019
|
+
!H && W && (gt(e), mt(!1));
|
|
1020
1020
|
}, [
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1021
|
+
W,
|
|
1022
|
+
mt,
|
|
1023
|
+
H,
|
|
1024
|
+
gt
|
|
1025
1025
|
]);
|
|
1026
|
-
j("cut",
|
|
1027
|
-
let
|
|
1028
|
-
if (!
|
|
1029
|
-
let n =
|
|
1026
|
+
j("cut", _t);
|
|
1027
|
+
let vt = t(async (t) => {
|
|
1028
|
+
if (!H && W) {
|
|
1029
|
+
let n = J?.min || W, r = J?.max || W, i = await Promise.all(t[0].map((e, r) => {
|
|
1030
1030
|
let i = I[n.col + r + 1]?.prePasteValues, a = t.map((e) => e[r]);
|
|
1031
1031
|
return Promise.resolve(i?.(a) ?? a);
|
|
1032
1032
|
}));
|
|
@@ -1034,7 +1034,7 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1034
1034
|
let i = [...e];
|
|
1035
1035
|
for (let e = 0; e < t[0].length; e++) {
|
|
1036
1036
|
let a = I[n.col + e + 1]?.pasteValue;
|
|
1037
|
-
if (a) for (let o = n.row; o <= r.row; o++)
|
|
1037
|
+
if (a) for (let o = n.row; o <= r.row; o++) Z({
|
|
1038
1038
|
col: e + n.col,
|
|
1039
1039
|
row: o
|
|
1040
1040
|
}) || (i[o] = await a({
|
|
@@ -1047,10 +1047,10 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1047
1047
|
type: "UPDATE",
|
|
1048
1048
|
fromRowIndex: n.row,
|
|
1049
1049
|
toRowIndex: r.row + 1
|
|
1050
|
-
}]),
|
|
1050
|
+
}]), G({
|
|
1051
1051
|
col: n.col,
|
|
1052
1052
|
row: n.row
|
|
1053
|
-
}),
|
|
1053
|
+
}), q({
|
|
1054
1054
|
col: Math.min(n.col + t[0].length - 1, I.length - (L ? 3 : 2)),
|
|
1055
1055
|
row: r.row
|
|
1056
1056
|
});
|
|
@@ -1059,7 +1059,7 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1059
1059
|
i > 0 && (T ? t.splice(t.length - i, i) : r = [...r, ...Array(i).fill(0).map(() => C())]);
|
|
1060
1060
|
for (let e = 0; e < t[0].length && n.col + e < I.length - (L ? 2 : 1); e++) {
|
|
1061
1061
|
let i = I[n.col + e + 1]?.pasteValue;
|
|
1062
|
-
if (i) for (let a = 0; a < t.length; a++)
|
|
1062
|
+
if (i) for (let a = 0; a < t.length; a++) Z({
|
|
1063
1063
|
col: n.col + e,
|
|
1064
1064
|
row: n.row + a
|
|
1065
1065
|
}) || (r[n.row + a] = await i({
|
|
@@ -1077,103 +1077,103 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1077
1077
|
type: "CREATE",
|
|
1078
1078
|
fromRowIndex: n.row + t.length - i,
|
|
1079
1079
|
toRowIndex: n.row + t.length
|
|
1080
|
-
}), p(r, a),
|
|
1080
|
+
}), p(r, a), G({
|
|
1081
1081
|
col: n.col,
|
|
1082
1082
|
row: n.row
|
|
1083
|
-
}),
|
|
1083
|
+
}), q({
|
|
1084
1084
|
col: Math.min(n.col + t[0].length - 1, I.length - (L ? 3 : 2)),
|
|
1085
1085
|
row: n.row + t.length - 1
|
|
1086
1086
|
});
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
1089
|
}, [
|
|
1090
|
-
|
|
1090
|
+
W,
|
|
1091
1091
|
I,
|
|
1092
1092
|
C,
|
|
1093
1093
|
e,
|
|
1094
|
-
|
|
1094
|
+
H,
|
|
1095
1095
|
L,
|
|
1096
|
-
|
|
1096
|
+
Z,
|
|
1097
1097
|
T,
|
|
1098
1098
|
p,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1099
|
+
J?.max,
|
|
1100
|
+
J?.min,
|
|
1101
|
+
G,
|
|
1102
|
+
q
|
|
1103
1103
|
]);
|
|
1104
1104
|
j("paste", t((e) => {
|
|
1105
|
-
if (
|
|
1105
|
+
if (W && !H) {
|
|
1106
1106
|
let t = [[""]];
|
|
1107
|
-
e.clipboardData?.types.includes("text/html") ? t = se(e.clipboardData?.getData("text/html")) : e.clipboardData?.types.includes("text/plain") ? t = ce(e.clipboardData?.getData("text/plain")) : e.clipboardData?.types.includes("text") && (t = ce(e.clipboardData?.getData("text"))),
|
|
1107
|
+
e.clipboardData?.types.includes("text/html") ? t = se(e.clipboardData?.getData("text/html")) : e.clipboardData?.types.includes("text/plain") ? t = ce(e.clipboardData?.getData("text/plain")) : e.clipboardData?.types.includes("text") && (t = ce(e.clipboardData?.getData("text"))), vt(t), e.preventDefault();
|
|
1108
1108
|
}
|
|
1109
1109
|
}, [
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1110
|
+
W,
|
|
1111
|
+
vt,
|
|
1112
|
+
H
|
|
1113
1113
|
])), j("mousedown", t((t) => {
|
|
1114
|
-
if (
|
|
1115
|
-
let n = t.button === 2 || t.button === 0 && t.ctrlKey, r =
|
|
1116
|
-
if (!r &&
|
|
1114
|
+
if ($e && et.length) return;
|
|
1115
|
+
let n = t.button === 2 || t.button === 0 && t.ctrlKey, r = Le.current?.contains(t.target) || !1, i = r ? ut(t, !0, !0) : null;
|
|
1116
|
+
if (!r && H && W && I[W.col + 1].keepFocus) return;
|
|
1117
1117
|
if (t.target instanceof HTMLElement && t.target.className.includes("dsg-expand-rows-indicator")) {
|
|
1118
|
-
|
|
1118
|
+
at(Math.max(W?.row ?? 0, J?.max.row ?? 0));
|
|
1119
1119
|
return;
|
|
1120
1120
|
}
|
|
1121
|
-
let a = i &&
|
|
1122
|
-
if ((a || o) &&
|
|
1123
|
-
let s = i?.col === I.length - 2 && L, c = n &&
|
|
1124
|
-
if (n && !
|
|
1121
|
+
let a = i && W && W.col === i.col && W.row === i.row && !Z(W), o = H && t.target instanceof HTMLElement && t.target.classList.contains("dsg-input");
|
|
1122
|
+
if ((a || o) && H) return;
|
|
1123
|
+
let s = i?.col === I.length - 2 && L, c = n && J && i && i.row >= J.min.row && i.row <= J.max.row && i.col >= J.min.col && i.col <= J.max.col, l = n && J && i?.row === -1 && i.col >= J.min.col && i.col <= J.max.col, u = n && J && i && i.row >= J.min.row && i.row <= J.max.row && i.col === -1, d = s && J && i && i.row >= J.min.row && i.row <= J.max.row;
|
|
1124
|
+
if (n && !Fe && V({
|
|
1125
1125
|
x: t.clientX,
|
|
1126
1126
|
y: t.clientY,
|
|
1127
1127
|
cursorIndex: i
|
|
1128
|
-
}), (!(t.shiftKey &&
|
|
1129
|
-
col: (c || l) &&
|
|
1130
|
-
row: (c || u || d) &&
|
|
1131
|
-
doNotScrollX: !!(c &&
|
|
1132
|
-
doNotScrollY: !!(c &&
|
|
1133
|
-
}), a && !n && (
|
|
1134
|
-
columns: i.col !== -1 && !s || !!(t.shiftKey &&
|
|
1135
|
-
rows: i.row !== -1 || !!(t.shiftKey &&
|
|
1128
|
+
}), (!(t.shiftKey && W) || n) && e.length > 0 && G(i && {
|
|
1129
|
+
col: (c || l) && W ? W.col : Math.max(0, s ? 0 : i.col),
|
|
1130
|
+
row: (c || u || d) && W ? W.row : Math.max(0, i.row),
|
|
1131
|
+
doNotScrollX: !!(c && W || s || i.col === -1),
|
|
1132
|
+
doNotScrollY: !!(c && W || i.row === -1)
|
|
1133
|
+
}), a && !n && (Pe.current = W), U(!(!a || n)), ot(i && !n ? {
|
|
1134
|
+
columns: i.col !== -1 && !s || !!(t.shiftKey && W),
|
|
1135
|
+
rows: i.row !== -1 || !!(t.shiftKey && W),
|
|
1136
1136
|
active: !0
|
|
1137
1137
|
} : {
|
|
1138
1138
|
columns: !1,
|
|
1139
1139
|
rows: !1,
|
|
1140
1140
|
active: !1
|
|
1141
|
-
}), t.shiftKey &&
|
|
1141
|
+
}), t.shiftKey && W && !n) q(i && {
|
|
1142
1142
|
col: Math.max(0, i.col - +!!s),
|
|
1143
1143
|
row: Math.max(0, i.row)
|
|
1144
1144
|
});
|
|
1145
1145
|
else if (!c) {
|
|
1146
1146
|
if (i && (i?.col === -1 || i?.row === -1 || s)) {
|
|
1147
1147
|
let t = i.col, n = i.row, r = !1, a = !1;
|
|
1148
|
-
(i.col === -1 || s) && (t = I.length - (L ? 3 : 2), r = !0), i.row === -1 && (n = e.length - 1, a = !0), l &&
|
|
1148
|
+
(i.col === -1 || s) && (t = I.length - (L ? 3 : 2), r = !0), i.row === -1 && (n = e.length - 1, a = !0), l && K && (t = K.col, a = !0), (u || d) && K && (n = K.row, r = !0), q({
|
|
1149
1149
|
col: t,
|
|
1150
1150
|
row: n,
|
|
1151
1151
|
doNotScrollX: r,
|
|
1152
1152
|
doNotScrollY: a
|
|
1153
1153
|
});
|
|
1154
|
-
} else
|
|
1154
|
+
} else q(null);
|
|
1155
1155
|
r && t.preventDefault();
|
|
1156
1156
|
}
|
|
1157
1157
|
}, [
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1158
|
+
$e,
|
|
1159
|
+
et.length,
|
|
1160
|
+
ut,
|
|
1161
|
+
H,
|
|
1162
|
+
W,
|
|
1163
1163
|
I,
|
|
1164
|
-
|
|
1165
|
-
Y,
|
|
1166
|
-
L,
|
|
1167
|
-
je,
|
|
1168
|
-
tt,
|
|
1169
|
-
K,
|
|
1164
|
+
Z,
|
|
1170
1165
|
J,
|
|
1166
|
+
L,
|
|
1167
|
+
Fe,
|
|
1168
|
+
ot,
|
|
1169
|
+
G,
|
|
1171
1170
|
q,
|
|
1171
|
+
K,
|
|
1172
1172
|
e.length
|
|
1173
1173
|
])), j("mouseup", t(() => {
|
|
1174
|
-
if (
|
|
1175
|
-
if (
|
|
1176
|
-
let t = [], n =
|
|
1174
|
+
if (it !== null) {
|
|
1175
|
+
if (nt > 0 && W) {
|
|
1176
|
+
let t = [], n = J?.min || W, r = J?.max || W;
|
|
1177
1177
|
for (let i = n.row; i <= r.row; ++i) {
|
|
1178
1178
|
t.push([]);
|
|
1179
1179
|
for (let a = n.col; a <= r.col; ++a) {
|
|
@@ -1192,7 +1192,7 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1192
1192
|
let a = [...e];
|
|
1193
1193
|
for (let e = 0; e < t[0].length; e++) {
|
|
1194
1194
|
let i = I[n.col + e + 1]?.pasteValue;
|
|
1195
|
-
if (i) for (let o = r.row + 1; o <= r.row +
|
|
1195
|
+
if (i) for (let o = r.row + 1; o <= r.row + nt; o++) Z({
|
|
1196
1196
|
col: e + n.col,
|
|
1197
1197
|
row: o
|
|
1198
1198
|
}) || (a[o] = i({
|
|
@@ -1204,107 +1204,107 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1204
1204
|
p(a, [{
|
|
1205
1205
|
type: "UPDATE",
|
|
1206
1206
|
fromRowIndex: r.row + 1,
|
|
1207
|
-
toRowIndex: r.row + 1 +
|
|
1207
|
+
toRowIndex: r.row + 1 + nt
|
|
1208
1208
|
}]);
|
|
1209
|
-
}),
|
|
1210
|
-
col: Math.min(
|
|
1211
|
-
row: Math.min(
|
|
1209
|
+
}), rt(0), G({
|
|
1210
|
+
col: Math.min(W?.col ?? Infinity, J?.min.col ?? Infinity),
|
|
1211
|
+
row: Math.min(W?.row ?? Infinity, J?.min.row ?? Infinity),
|
|
1212
1212
|
doNotScrollX: !0,
|
|
1213
1213
|
doNotScrollY: !0
|
|
1214
|
-
}),
|
|
1215
|
-
col: Math.max(
|
|
1216
|
-
row: Math.max(
|
|
1214
|
+
}), q({
|
|
1215
|
+
col: Math.max(W?.col ?? 0, J?.max.col ?? 0),
|
|
1216
|
+
row: Math.max(W?.row ?? 0, J?.max.row ?? 0) + nt
|
|
1217
1217
|
});
|
|
1218
1218
|
}
|
|
1219
|
-
|
|
1219
|
+
at(null);
|
|
1220
1220
|
}
|
|
1221
|
-
|
|
1221
|
+
ot({
|
|
1222
1222
|
columns: !1,
|
|
1223
1223
|
rows: !1,
|
|
1224
1224
|
active: !1
|
|
1225
1225
|
});
|
|
1226
1226
|
}, [
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1227
|
+
it,
|
|
1228
|
+
ot,
|
|
1229
|
+
nt,
|
|
1230
|
+
W,
|
|
1231
|
+
J?.min,
|
|
1232
|
+
J?.max,
|
|
1233
1233
|
e,
|
|
1234
1234
|
p,
|
|
1235
|
-
|
|
1236
|
-
|
|
1235
|
+
G,
|
|
1236
|
+
q,
|
|
1237
1237
|
I,
|
|
1238
|
-
|
|
1238
|
+
Z
|
|
1239
1239
|
])), j("mousemove", t((t) => {
|
|
1240
|
-
if (
|
|
1241
|
-
let e =
|
|
1242
|
-
e && (
|
|
1240
|
+
if (it !== null) {
|
|
1241
|
+
let e = ut(t);
|
|
1242
|
+
e && (rt(Math.max(0, e.row - it)), $({
|
|
1243
1243
|
col: e.col,
|
|
1244
|
-
row: Math.max(e.row,
|
|
1244
|
+
row: Math.max(e.row, it)
|
|
1245
1245
|
}));
|
|
1246
1246
|
}
|
|
1247
|
-
if (
|
|
1248
|
-
let n =
|
|
1249
|
-
|
|
1250
|
-
col:
|
|
1251
|
-
row:
|
|
1252
|
-
doNotScrollX: !
|
|
1253
|
-
doNotScrollY: !
|
|
1254
|
-
}),
|
|
1247
|
+
if (Y.active) {
|
|
1248
|
+
let n = ut(t), r = I.length - (L ? 3 : 2);
|
|
1249
|
+
q(n && {
|
|
1250
|
+
col: Y.columns ? Math.max(0, Math.min(r, n.col)) : r,
|
|
1251
|
+
row: Y.rows ? Math.max(0, n.row) : e.length - 1,
|
|
1252
|
+
doNotScrollX: !Y.columns,
|
|
1253
|
+
doNotScrollY: !Y.rows
|
|
1254
|
+
}), U(!1);
|
|
1255
1255
|
}
|
|
1256
1256
|
}, [
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1257
|
+
$,
|
|
1258
|
+
Y.active,
|
|
1259
|
+
Y.columns,
|
|
1260
|
+
Y.rows,
|
|
1261
|
+
ut,
|
|
1262
1262
|
I.length,
|
|
1263
1263
|
L,
|
|
1264
|
-
|
|
1264
|
+
q,
|
|
1265
1265
|
e.length,
|
|
1266
|
-
|
|
1266
|
+
it
|
|
1267
1267
|
])), j("keydown", t((t) => {
|
|
1268
|
-
if (
|
|
1269
|
-
if (t.key === "Tab" && !t.shiftKey &&
|
|
1270
|
-
if (
|
|
1271
|
-
if (
|
|
1272
|
-
t.preventDefault(),
|
|
1268
|
+
if (W && !t.isComposing) {
|
|
1269
|
+
if (t.key === "Tab" && !t.shiftKey && W.col === I.length - (L ? 3 : 2) && !I[W.col + 1].disableKeys) {
|
|
1270
|
+
if (W.row === e.length - 1) {
|
|
1271
|
+
if (ze.current) {
|
|
1272
|
+
t.preventDefault(), G(null), q(null), U(!1);
|
|
1273
1273
|
let e = ge();
|
|
1274
|
-
e[(e.indexOf(
|
|
1274
|
+
e[(e.indexOf(ze.current) + 1) % e.length].focus();
|
|
1275
1275
|
return;
|
|
1276
1276
|
}
|
|
1277
1277
|
} else {
|
|
1278
|
-
|
|
1278
|
+
G((e) => ({
|
|
1279
1279
|
col: 0,
|
|
1280
1280
|
row: (e?.row ?? 0) + 1
|
|
1281
|
-
})),
|
|
1281
|
+
})), q(null), U(!1), t.preventDefault();
|
|
1282
1282
|
return;
|
|
1283
1283
|
}
|
|
1284
1284
|
}
|
|
1285
|
-
if (t.key === "Tab" && t.shiftKey &&
|
|
1286
|
-
if (
|
|
1287
|
-
if (
|
|
1288
|
-
t.preventDefault(),
|
|
1285
|
+
if (t.key === "Tab" && t.shiftKey && W.col === 0 && !I[W.col + 1].disableKeys) {
|
|
1286
|
+
if (W.row === 0) {
|
|
1287
|
+
if (Re.current) {
|
|
1288
|
+
t.preventDefault(), G(null), q(null), U(!1);
|
|
1289
1289
|
let e = ge();
|
|
1290
|
-
e[(e.indexOf(
|
|
1290
|
+
e[(e.indexOf(Re.current) - 1 + e.length) % e.length].focus();
|
|
1291
1291
|
return;
|
|
1292
1292
|
}
|
|
1293
1293
|
} else {
|
|
1294
|
-
|
|
1294
|
+
G((e) => ({
|
|
1295
1295
|
col: I.length - (L ? 3 : 2),
|
|
1296
1296
|
row: (e?.row ?? 1) - 1
|
|
1297
|
-
})),
|
|
1297
|
+
})), q(null), U(!1), t.preventDefault();
|
|
1298
1298
|
return;
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
if (t.key?.startsWith("Arrow") || t.key === "Tab") {
|
|
1302
|
-
if (
|
|
1302
|
+
if (H && I[W.col + 1].disableKeys || H && ["ArrowLeft", "ArrowRight"].includes(t.key)) return;
|
|
1303
1303
|
let n = ([t, n], r) => r && {
|
|
1304
1304
|
col: Math.max(0, Math.min(I.length - (L ? 3 : 2), r.col + t)),
|
|
1305
1305
|
row: Math.max(0, Math.min(e.length - 1, r.row + n))
|
|
1306
1306
|
};
|
|
1307
|
-
if (t.key === "Tab" && t.shiftKey)
|
|
1307
|
+
if (t.key === "Tab" && t.shiftKey) G((e) => n([-1, 0], e)), q(null);
|
|
1308
1308
|
else {
|
|
1309
1309
|
let r = {
|
|
1310
1310
|
ArrowDown: [0, 1],
|
|
@@ -1313,15 +1313,22 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1313
1313
|
ArrowRight: [1, 0],
|
|
1314
1314
|
Tab: [1, 0]
|
|
1315
1315
|
}[t.key];
|
|
1316
|
-
(t.ctrlKey || t.metaKey) && (r[0] *= I.length, r[1] *= e.length), t.shiftKey ?
|
|
1316
|
+
(t.ctrlKey || t.metaKey) && (r[0] *= I.length, r[1] *= e.length), t.shiftKey ? q((e) => n(r, e || W)) : (G((e) => n(r, e)), q(null));
|
|
1317
1317
|
}
|
|
1318
|
-
|
|
1319
|
-
} else
|
|
1318
|
+
U(!1), t.preventDefault();
|
|
1319
|
+
} else if (t.key === "Escape") !H && !K && G(null), q(null), U(!1);
|
|
1320
|
+
else if ((t.key === "Enter" || t.key === "F2") && !t.ctrlKey && !t.metaKey && !t.altKey && !t.shiftKey) q(null), H ? I[W.col + 1].disableKeys || (ht(), t.preventDefault()) : Z(W) || (Pe.current = W, U(!0), $(W), t.preventDefault());
|
|
1321
|
+
else if (t.key === "Enter" && !t.ctrlKey && !t.metaKey && !t.altKey && t.shiftKey && !H) Q(J?.max.row || W.row);
|
|
1322
|
+
else if (t.key === "d" && (t.ctrlKey || t.metaKey) && !t.altKey && !t.shiftKey) dt(J?.min.row || W.row, J?.max.row), t.preventDefault();
|
|
1323
|
+
else if (ve(t) || ye(t)) {
|
|
1324
|
+
let e = ve(t) ? we : Me;
|
|
1325
|
+
!H && e && (e(), t.preventDefault());
|
|
1326
|
+
} else (de(t.key) || /Key[A-Z]$/.exec(t.code)) && !t.ctrlKey && !t.metaKey && !t.altKey ? !H && !Z(W) && (Pe.current = W, q(null), U(!0), $(W)) : ["Backspace", "Delete"].includes(t.key) ? H || (mt(), t.preventDefault()) : t.key === "a" && (t.ctrlKey || t.metaKey) && (H || (G({
|
|
1320
1327
|
col: 0,
|
|
1321
1328
|
row: 0,
|
|
1322
1329
|
doNotScrollY: !0,
|
|
1323
1330
|
doNotScrollX: !0
|
|
1324
|
-
}),
|
|
1331
|
+
}), q({
|
|
1325
1332
|
col: I.length - (L ? 3 : 2),
|
|
1326
1333
|
row: e.length - 1,
|
|
1327
1334
|
doNotScrollY: !0,
|
|
@@ -1329,40 +1336,50 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1329
1336
|
}), t.preventDefault()));
|
|
1330
1337
|
}
|
|
1331
1338
|
}, [
|
|
1332
|
-
|
|
1339
|
+
W,
|
|
1333
1340
|
I,
|
|
1334
1341
|
e.length,
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
$,
|
|
1342
|
+
mt,
|
|
1343
|
+
dt,
|
|
1344
|
+
H,
|
|
1339
1345
|
Q,
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1346
|
+
Z,
|
|
1347
|
+
$,
|
|
1348
|
+
J?.max.row,
|
|
1349
|
+
J?.min.row,
|
|
1344
1350
|
K,
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1351
|
+
G,
|
|
1352
|
+
q,
|
|
1353
|
+
ht,
|
|
1354
|
+
L,
|
|
1355
|
+
we,
|
|
1356
|
+
Me
|
|
1357
|
+
]));
|
|
1358
|
+
let yt = o(null);
|
|
1359
|
+
j("focusin", t((e) => {
|
|
1360
|
+
W && e !== yt.current && (G(null), q(null), U(!1));
|
|
1361
|
+
}, [
|
|
1362
|
+
W,
|
|
1363
|
+
G,
|
|
1364
|
+
q
|
|
1348
1365
|
])), j("contextmenu", t((e) => {
|
|
1349
|
-
let t =
|
|
1366
|
+
let t = Le.current?.contains(e.target) || !1, n = t ? ut(e, !0, !0) : null, r = n && W && W.col === n.col && W.row === n.row && H;
|
|
1350
1367
|
t && !r && e.preventDefault();
|
|
1351
1368
|
}, [
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1369
|
+
ut,
|
|
1370
|
+
W,
|
|
1371
|
+
H
|
|
1355
1372
|
])), n(() => {
|
|
1356
1373
|
let e = [];
|
|
1357
|
-
|
|
1374
|
+
W?.row !== void 0 && e.push({
|
|
1358
1375
|
type: "COPY",
|
|
1359
1376
|
action: () => {
|
|
1360
|
-
|
|
1377
|
+
gt(), V(null);
|
|
1361
1378
|
}
|
|
1362
1379
|
}, {
|
|
1363
1380
|
type: "CUT",
|
|
1364
1381
|
action: () => {
|
|
1365
|
-
|
|
1382
|
+
_t(), V(null);
|
|
1366
1383
|
}
|
|
1367
1384
|
}, {
|
|
1368
1385
|
type: "PASTE",
|
|
@@ -1372,203 +1389,206 @@ var Ce = ({ value: e, rowHeight: t }) => {
|
|
|
1372
1389
|
let e = await navigator.clipboard.read();
|
|
1373
1390
|
for (let t of e) {
|
|
1374
1391
|
let e = [[""]];
|
|
1375
|
-
t.types.includes("text/html") ? e = se(await (await t.getType("text/html")).text()) : t.types.includes("text/plain") ? e = ce(await (await t.getType("text/plain")).text()) : t.types.includes("text") && (e = se(await (await t.getType("text")).text())), await
|
|
1392
|
+
t.types.includes("text/html") ? e = se(await (await t.getType("text/html")).text()) : t.types.includes("text/plain") ? e = ce(await (await t.getType("text/plain")).text()) : t.types.includes("text") && (e = se(await (await t.getType("text")).text())), await vt(e);
|
|
1376
1393
|
}
|
|
1377
1394
|
} else if (navigator.clipboard.readText !== void 0) {
|
|
1378
1395
|
let e = await navigator.clipboard.readText();
|
|
1379
|
-
await
|
|
1396
|
+
await vt(ce(e));
|
|
1380
1397
|
} else alert("This action is unavailable in your browser, but you can still use Ctrl+V for paste");
|
|
1381
|
-
|
|
1398
|
+
V(null);
|
|
1382
1399
|
})();
|
|
1383
1400
|
}
|
|
1384
|
-
}),
|
|
1401
|
+
}), J?.max.row === void 0 ? W?.row !== void 0 && e.push({
|
|
1385
1402
|
type: "INSERT_ROW_BELLOW",
|
|
1386
1403
|
action: () => {
|
|
1387
|
-
|
|
1404
|
+
V(null), Q(W.row);
|
|
1388
1405
|
}
|
|
1389
1406
|
}) : e.push({
|
|
1390
1407
|
type: "INSERT_ROW_BELLOW",
|
|
1391
1408
|
action: () => {
|
|
1392
|
-
|
|
1409
|
+
V(null), Q(J.max.row);
|
|
1393
1410
|
}
|
|
1394
|
-
}),
|
|
1411
|
+
}), J?.min.row !== void 0 && J.min.row !== J.max.row ? e.push({
|
|
1395
1412
|
type: "DUPLICATE_ROWS",
|
|
1396
|
-
fromRow:
|
|
1397
|
-
toRow:
|
|
1413
|
+
fromRow: J.min.row + 1,
|
|
1414
|
+
toRow: J.max.row + 1,
|
|
1398
1415
|
action: () => {
|
|
1399
|
-
|
|
1416
|
+
V(null), dt(J.min.row, J.max.row);
|
|
1400
1417
|
}
|
|
1401
|
-
}) :
|
|
1418
|
+
}) : W?.row !== void 0 && e.push({
|
|
1402
1419
|
type: "DUPLICATE_ROW",
|
|
1403
1420
|
action: () => {
|
|
1404
|
-
|
|
1421
|
+
V(null), dt(W.row);
|
|
1405
1422
|
}
|
|
1406
|
-
}),
|
|
1423
|
+
}), J?.min.row !== void 0 && J.min.row !== J.max.row ? e.push({
|
|
1407
1424
|
type: "DELETE_ROWS",
|
|
1408
|
-
fromRow:
|
|
1409
|
-
toRow:
|
|
1425
|
+
fromRow: J.min.row + 1,
|
|
1426
|
+
toRow: J.max.row + 1,
|
|
1410
1427
|
action: () => {
|
|
1411
|
-
|
|
1428
|
+
V(null), pt(J.min.row, J.max.row);
|
|
1412
1429
|
}
|
|
1413
|
-
}) :
|
|
1430
|
+
}) : W?.row !== void 0 && e.push({
|
|
1414
1431
|
type: "DELETE_ROW",
|
|
1415
1432
|
action: () => {
|
|
1416
|
-
|
|
1433
|
+
V(null), pt(W.row);
|
|
1417
1434
|
}
|
|
1418
|
-
}),
|
|
1435
|
+
}), tt(e), e.length || V(null);
|
|
1419
1436
|
}, [
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
lt,
|
|
1423
|
-
ot,
|
|
1424
|
-
$,
|
|
1437
|
+
J,
|
|
1438
|
+
W,
|
|
1425
1439
|
pt,
|
|
1426
|
-
|
|
1427
|
-
|
|
1440
|
+
dt,
|
|
1441
|
+
Q,
|
|
1442
|
+
_t,
|
|
1443
|
+
gt,
|
|
1444
|
+
vt
|
|
1428
1445
|
]);
|
|
1429
|
-
let
|
|
1430
|
-
|
|
1431
|
-
let
|
|
1432
|
-
r(
|
|
1433
|
-
activeCell: pe(
|
|
1434
|
-
selection: he(
|
|
1435
|
-
min:
|
|
1436
|
-
max:
|
|
1446
|
+
let bt = o(et);
|
|
1447
|
+
bt.current = et;
|
|
1448
|
+
let xt = t(() => bt.current, []);
|
|
1449
|
+
r(Ne, () => ({
|
|
1450
|
+
activeCell: pe(W, I),
|
|
1451
|
+
selection: he(J ?? (W ? {
|
|
1452
|
+
min: W,
|
|
1453
|
+
max: W
|
|
1437
1454
|
} : null), I),
|
|
1438
1455
|
setSelection: (t) => {
|
|
1439
1456
|
let n = me(t, I.length - (L ? 2 : 1), e.length, I);
|
|
1440
|
-
|
|
1457
|
+
G(n?.min || null), U(!1), ot({
|
|
1441
1458
|
columns: !1,
|
|
1442
1459
|
active: !1,
|
|
1443
1460
|
rows: !1
|
|
1444
|
-
}),
|
|
1461
|
+
}), q(n?.max || null);
|
|
1445
1462
|
},
|
|
1446
1463
|
setActiveCell: (t) => {
|
|
1447
1464
|
let n = fe(t, I.length - (L ? 2 : 1), e.length, I);
|
|
1448
|
-
|
|
1465
|
+
G(n), U(!1), ot({
|
|
1449
1466
|
columns: !1,
|
|
1450
1467
|
active: !1,
|
|
1451
1468
|
rows: !1
|
|
1452
|
-
}),
|
|
1469
|
+
}), q(null);
|
|
1453
1470
|
}
|
|
1454
1471
|
}));
|
|
1455
|
-
let
|
|
1472
|
+
let St = o({
|
|
1456
1473
|
onFocus: P,
|
|
1457
1474
|
onBlur: F,
|
|
1458
1475
|
onActiveCellChange: ae,
|
|
1459
1476
|
onSelectionChange: oe
|
|
1460
1477
|
});
|
|
1461
|
-
return
|
|
1462
|
-
|
|
1463
|
-
}, [
|
|
1464
|
-
|
|
1478
|
+
return St.current.onFocus = P, St.current.onBlur = F, St.current.onActiveCellChange = ae, St.current.onSelectionChange = oe, n(() => {
|
|
1479
|
+
Pe.current && (H ? St.current.onFocus({ cell: pe(Pe.current, I) }) : St.current.onBlur({ cell: pe(Pe.current, I) }));
|
|
1480
|
+
}, [H, I]), n(() => {
|
|
1481
|
+
St.current.onActiveCellChange({ cell: pe(W, I) });
|
|
1465
1482
|
}, [
|
|
1466
|
-
|
|
1467
|
-
|
|
1483
|
+
W?.col,
|
|
1484
|
+
W?.row,
|
|
1468
1485
|
I
|
|
1469
1486
|
]), n(() => {
|
|
1470
|
-
|
|
1471
|
-
min:
|
|
1472
|
-
max:
|
|
1487
|
+
St.current.onSelectionChange({ selection: he(J ?? (W ? {
|
|
1488
|
+
min: W,
|
|
1489
|
+
max: W
|
|
1473
1490
|
} : null), I) });
|
|
1474
1491
|
}, [
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1492
|
+
J?.min.col ?? W?.col,
|
|
1493
|
+
J?.min.row ?? W?.row,
|
|
1494
|
+
J?.max.col ?? W?.col,
|
|
1495
|
+
J?.max.row ?? W?.row,
|
|
1496
|
+
W?.col,
|
|
1497
|
+
W?.row,
|
|
1481
1498
|
I
|
|
1482
1499
|
]), /* @__PURE__ */ d("div", {
|
|
1483
1500
|
className: i,
|
|
1484
1501
|
style: l,
|
|
1502
|
+
onFocus: (e) => {
|
|
1503
|
+
yt.current = e.nativeEvent;
|
|
1504
|
+
},
|
|
1485
1505
|
children: [
|
|
1486
1506
|
/* @__PURE__ */ u("div", {
|
|
1487
|
-
ref:
|
|
1507
|
+
ref: Re,
|
|
1488
1508
|
tabIndex: h.length && e.length ? 0 : void 0,
|
|
1489
1509
|
onFocus: (e) => {
|
|
1490
|
-
e.target.blur(),
|
|
1510
|
+
e.target.blur(), G({
|
|
1491
1511
|
col: 0,
|
|
1492
1512
|
row: 0
|
|
1493
1513
|
});
|
|
1494
1514
|
}
|
|
1495
1515
|
}),
|
|
1496
|
-
/* @__PURE__ */ u(
|
|
1516
|
+
/* @__PURE__ */ u(Se, {
|
|
1497
1517
|
columns: I,
|
|
1498
1518
|
outerRef: R,
|
|
1499
|
-
columnWidths:
|
|
1519
|
+
columnWidths: z,
|
|
1500
1520
|
hasStickyRightColumn: L,
|
|
1501
|
-
pinFirstColumn:
|
|
1502
|
-
displayHeight:
|
|
1521
|
+
pinFirstColumn: Ce,
|
|
1522
|
+
displayHeight: Ge,
|
|
1503
1523
|
data: e,
|
|
1504
|
-
fullWidth:
|
|
1524
|
+
fullWidth: Ye,
|
|
1505
1525
|
headerRowHeight: _,
|
|
1506
|
-
activeCell:
|
|
1507
|
-
innerRef:
|
|
1526
|
+
activeCell: W,
|
|
1527
|
+
innerRef: Le,
|
|
1508
1528
|
rowHeight: g,
|
|
1509
|
-
getRowSize:
|
|
1529
|
+
getRowSize: He,
|
|
1510
1530
|
rowKey: b,
|
|
1511
|
-
selection:
|
|
1531
|
+
selection: J,
|
|
1512
1532
|
rowClassName: _e,
|
|
1513
|
-
editing:
|
|
1514
|
-
getContextMenuItems:
|
|
1515
|
-
setRowData:
|
|
1516
|
-
deleteRows:
|
|
1517
|
-
insertRowAfter:
|
|
1518
|
-
duplicateRows:
|
|
1519
|
-
stopEditing:
|
|
1520
|
-
cellClassName:
|
|
1521
|
-
onScroll:
|
|
1522
|
-
children: /* @__PURE__ */ u(
|
|
1523
|
-
columnRights:
|
|
1524
|
-
columnWidths:
|
|
1525
|
-
activeCell:
|
|
1526
|
-
selection:
|
|
1533
|
+
editing: H,
|
|
1534
|
+
getContextMenuItems: xt,
|
|
1535
|
+
setRowData: ft,
|
|
1536
|
+
deleteRows: pt,
|
|
1537
|
+
insertRowAfter: Q,
|
|
1538
|
+
duplicateRows: dt,
|
|
1539
|
+
stopEditing: ht,
|
|
1540
|
+
cellClassName: be,
|
|
1541
|
+
onScroll: xe,
|
|
1542
|
+
children: /* @__PURE__ */ u(Te, {
|
|
1543
|
+
columnRights: B,
|
|
1544
|
+
columnWidths: z,
|
|
1545
|
+
activeCell: W,
|
|
1546
|
+
selection: J,
|
|
1527
1547
|
headerRowHeight: _,
|
|
1528
|
-
rowHeight:
|
|
1548
|
+
rowHeight: He,
|
|
1529
1549
|
hasStickyRightColumn: L,
|
|
1530
1550
|
dataLength: e.length,
|
|
1531
|
-
viewHeight:
|
|
1532
|
-
viewWidth:
|
|
1533
|
-
contentWidth:
|
|
1534
|
-
edges:
|
|
1535
|
-
editing:
|
|
1536
|
-
isCellDisabled:
|
|
1537
|
-
expandSelection:
|
|
1538
|
-
stickyLeftColumns:
|
|
1539
|
-
getStickyLeftOffset:
|
|
1551
|
+
viewHeight: qe,
|
|
1552
|
+
viewWidth: Ke,
|
|
1553
|
+
contentWidth: Ye ? void 0 : Xe,
|
|
1554
|
+
edges: Je,
|
|
1555
|
+
editing: H,
|
|
1556
|
+
isCellDisabled: Z,
|
|
1557
|
+
expandSelection: st,
|
|
1558
|
+
stickyLeftColumns: Ze,
|
|
1559
|
+
getStickyLeftOffset: Qe
|
|
1540
1560
|
})
|
|
1541
1561
|
}),
|
|
1542
1562
|
/* @__PURE__ */ u("div", {
|
|
1543
|
-
ref:
|
|
1563
|
+
ref: ze,
|
|
1544
1564
|
tabIndex: h.length && e.length ? 0 : void 0,
|
|
1545
1565
|
onFocus: (t) => {
|
|
1546
|
-
t.target.blur(),
|
|
1566
|
+
t.target.blur(), G({
|
|
1547
1567
|
col: I.length - (L ? 3 : 2),
|
|
1548
1568
|
row: e.length - 1
|
|
1549
1569
|
});
|
|
1550
1570
|
}
|
|
1551
1571
|
}),
|
|
1552
|
-
!T && S && /* @__PURE__ */ u(S, { addRows: (t) =>
|
|
1553
|
-
|
|
1554
|
-
clientX:
|
|
1555
|
-
clientY:
|
|
1556
|
-
cursorIndex:
|
|
1557
|
-
items:
|
|
1558
|
-
close: () =>
|
|
1572
|
+
!T && S && /* @__PURE__ */ u(S, { addRows: (t) => Q(e.length - 1, t) }),
|
|
1573
|
+
$e && et.length > 0 && /* @__PURE__ */ u(ee, {
|
|
1574
|
+
clientX: $e.x,
|
|
1575
|
+
clientY: $e.y,
|
|
1576
|
+
cursorIndex: $e.cursorIndex,
|
|
1577
|
+
items: et,
|
|
1578
|
+
close: () => V(null)
|
|
1559
1579
|
})
|
|
1560
1580
|
]
|
|
1561
1581
|
});
|
|
1562
1582
|
}));
|
|
1563
|
-
|
|
1583
|
+
Me.displayName = "DataSheetGrid";
|
|
1564
1584
|
// src/hooks/useConstant.ts
|
|
1565
|
-
function
|
|
1585
|
+
function Ne(e) {
|
|
1566
1586
|
let [t] = s(e);
|
|
1567
1587
|
return t;
|
|
1568
1588
|
}
|
|
1569
1589
|
// src/components/StaticDataSheetGrid.tsx
|
|
1570
|
-
var
|
|
1571
|
-
let _ =
|
|
1590
|
+
var Pe = e.forwardRef(({ columns: e, gutterColumn: t, stickyRightColumn: n, addRowsComponent: r, createRow: i, duplicateRow: a, style: o, rowKey: s, onFocus: c, onBlur: l, onActiveCellChange: d, onSelectionChange: f, rowClassName: p, rowHeight: m, ...h }, g) => {
|
|
1591
|
+
let _ = Ne(() => ({
|
|
1572
1592
|
columns: e,
|
|
1573
1593
|
gutterColumn: t,
|
|
1574
1594
|
stickyRightColumn: n,
|
|
@@ -1584,51 +1604,51 @@ var je = e.forwardRef(({ columns: e, gutterColumn: t, stickyRightColumn: n, addR
|
|
|
1584
1604
|
rowClassName: p,
|
|
1585
1605
|
rowHeight: m
|
|
1586
1606
|
}));
|
|
1587
|
-
return /* @__PURE__ */ u(
|
|
1607
|
+
return /* @__PURE__ */ u(Me, {
|
|
1588
1608
|
..._,
|
|
1589
1609
|
...h,
|
|
1590
1610
|
rowHeight: typeof m == "number" ? m : _.rowHeight,
|
|
1591
1611
|
ref: g
|
|
1592
1612
|
});
|
|
1593
|
-
}),
|
|
1613
|
+
}), Fe = () => {
|
|
1594
1614
|
let e = o(!0), t = e.current;
|
|
1595
1615
|
return e.current = !1, t;
|
|
1596
|
-
},
|
|
1597
|
-
function
|
|
1616
|
+
}, I = ".dsg-cell-sticky-left, .dsg-cell-gutter", L = ".dsg-cell-sticky-right", Ie = 1;
|
|
1617
|
+
function Le(e, t) {
|
|
1598
1618
|
let { top: n, left: r } = e.getBoundingClientRect(), i = {
|
|
1599
1619
|
top: n,
|
|
1600
1620
|
left: r,
|
|
1601
1621
|
right: r + e.clientWidth,
|
|
1602
1622
|
bottom: n + e.clientHeight
|
|
1603
1623
|
}, a = e.querySelector(".dsg-row-header");
|
|
1604
|
-
return a && (i.top = Math.max(i.top, a.getBoundingClientRect().bottom), t?.matches(
|
|
1624
|
+
return a && (i.top = Math.max(i.top, a.getBoundingClientRect().bottom), t?.matches(I) || Array.from(a.querySelectorAll(I)).forEach((e) => {
|
|
1605
1625
|
i.left = Math.max(i.left, e.getBoundingClientRect().right);
|
|
1606
|
-
}), t?.matches(
|
|
1626
|
+
}), t?.matches(L) || Array.from(a.querySelectorAll(L)).forEach((e) => {
|
|
1607
1627
|
i.right = Math.min(i.right, e.getBoundingClientRect().left);
|
|
1608
1628
|
})), i;
|
|
1609
1629
|
}
|
|
1610
|
-
function
|
|
1611
|
-
return e.top >= t.top -
|
|
1630
|
+
function R(e, t) {
|
|
1631
|
+
return e.top >= t.top - Ie && e.top <= t.bottom + Ie && e.left >= t.left - Ie && e.left <= t.right + Ie;
|
|
1612
1632
|
}
|
|
1613
1633
|
// src/columns/textColumn.tsx
|
|
1614
|
-
var
|
|
1615
|
-
let _ = o(null), b =
|
|
1634
|
+
var Re = (e, t) => e !== null && e.top === t.top && e.left === t.left && e.width === t.width && e.height === t.height && e.maxWidth === t.maxWidth && e.maxHeight === t.maxHeight && e.anchorVisible === t.anchorVisible, ze = 480, Be = 300, Ve = (e, t, n, r, i) => Math.max(0, Math.min(Math.max(e, n), r - t - i)), He = e.memo(({ active: e, focus: t, rowData: r, setRowData: a, columnData: { placeholder: c, alignRight: f, formatInputOnFocus: p, formatBlurredInput: m, parseUserInput: h, continuousUpdates: g } }) => {
|
|
1635
|
+
let _ = o(null), b = Fe(), [x, S] = s(null), [C, w] = s(null);
|
|
1616
1636
|
i(() => {
|
|
1617
1637
|
if (!e || !x) {
|
|
1618
1638
|
w(null);
|
|
1619
1639
|
return;
|
|
1620
1640
|
}
|
|
1621
|
-
let t = getComputedStyle(document.documentElement), n = parseFloat(t.getPropertyValue("--dsg-cell-expanded-max-width")) ||
|
|
1622
|
-
let e = x.getBoundingClientRect(), t =
|
|
1641
|
+
let t = getComputedStyle(document.documentElement), n = parseFloat(t.getPropertyValue("--dsg-cell-expanded-max-width")) || ze, r = parseFloat(t.getPropertyValue("--dsg-cell-expanded-max-height")) || Be, i = x.closest(".dsg-container"), a = x.closest(".dsg-cell"), o, s = () => {
|
|
1642
|
+
let e = x.getBoundingClientRect(), t = Ve(e.width, e.left, n, window.innerWidth, 8), c = Ve(e.height, e.top, r, window.innerHeight, 8), l = {
|
|
1623
1643
|
top: e.top,
|
|
1624
1644
|
left: e.left,
|
|
1625
1645
|
width: e.width,
|
|
1626
1646
|
height: e.height,
|
|
1627
1647
|
maxWidth: t,
|
|
1628
1648
|
maxHeight: c,
|
|
1629
|
-
anchorVisible: !i ||
|
|
1649
|
+
anchorVisible: !i || R(e, Le(i, a))
|
|
1630
1650
|
};
|
|
1631
|
-
w((e) =>
|
|
1651
|
+
w((e) => Re(e, l) ? e : l), o = requestAnimationFrame(s);
|
|
1632
1652
|
};
|
|
1633
1653
|
return s(), () => cancelAnimationFrame(o);
|
|
1634
1654
|
}, [e, x]);
|
|
@@ -1712,11 +1732,11 @@ var Fe = (e, t) => e !== null && e.top === t.top && e.left === t.left && e.width
|
|
|
1712
1732
|
className: "dsg-input-anchor"
|
|
1713
1733
|
}), x && y(D ? te : A, D ? document.body : x)] });
|
|
1714
1734
|
});
|
|
1715
|
-
|
|
1716
|
-
var
|
|
1717
|
-
function
|
|
1735
|
+
He.displayName = "TextComponent";
|
|
1736
|
+
var Ue = We();
|
|
1737
|
+
function We({ placeholder: e, alignRight: t = !1, continuousUpdates: n = !0, deletedValue: r = null, parseUserInput: i = (e) => e.trim() || null, formatBlurredInput: a = (e) => String(e ?? ""), formatInputOnFocus: o = (e) => String(e ?? ""), formatForCopy: s = (e) => String(e ?? ""), parsePastedValue: c = (e) => e.trim() || null } = {}) {
|
|
1718
1738
|
return {
|
|
1719
|
-
component:
|
|
1739
|
+
component: He,
|
|
1720
1740
|
columnData: {
|
|
1721
1741
|
placeholder: e,
|
|
1722
1742
|
alignRight: t,
|
|
@@ -1732,7 +1752,7 @@ function Ve({ placeholder: e, alignRight: t = !1, continuousUpdates: n = !0, del
|
|
|
1732
1752
|
};
|
|
1733
1753
|
}
|
|
1734
1754
|
// src/columns/checkboxColumn.tsx
|
|
1735
|
-
var
|
|
1755
|
+
var Ge = /* @__PURE__ */ new Set([
|
|
1736
1756
|
"",
|
|
1737
1757
|
"false",
|
|
1738
1758
|
"no",
|
|
@@ -1746,7 +1766,7 @@ var He = /* @__PURE__ */ new Set([
|
|
|
1746
1766
|
"null",
|
|
1747
1767
|
"wrong",
|
|
1748
1768
|
"negative"
|
|
1749
|
-
]),
|
|
1769
|
+
]), Ke = e.memo(({ focus: e, rowData: t, setRowData: n, active: r, stopEditing: a, disabled: s }) => {
|
|
1750
1770
|
let c = o(null);
|
|
1751
1771
|
return i(() => {
|
|
1752
1772
|
e && (n(!t), a({ nextRow: !1 }));
|
|
@@ -1761,14 +1781,14 @@ var He = /* @__PURE__ */ new Set([
|
|
|
1761
1781
|
onChange: () => null
|
|
1762
1782
|
});
|
|
1763
1783
|
});
|
|
1764
|
-
|
|
1765
|
-
var
|
|
1766
|
-
component:
|
|
1784
|
+
Ke.displayName = "CheckboxComponent";
|
|
1785
|
+
var qe = {
|
|
1786
|
+
component: Ke,
|
|
1767
1787
|
deleteValue: () => !1,
|
|
1768
1788
|
copyValue: ({ rowData: e }) => e ? "YES" : "NO",
|
|
1769
|
-
pasteValue: ({ value: e }) => !
|
|
1789
|
+
pasteValue: ({ value: e }) => !Ge.has(e.toLowerCase()),
|
|
1770
1790
|
isCellEmpty: ({ rowData: e }) => !e
|
|
1771
|
-
},
|
|
1791
|
+
}, Je = We({
|
|
1772
1792
|
alignRight: !0,
|
|
1773
1793
|
formatBlurredInput: (e) => typeof e == "number" ? new Intl.NumberFormat().format(e) : "",
|
|
1774
1794
|
parseUserInput: (e) => {
|
|
@@ -1779,7 +1799,7 @@ var Ue = {
|
|
|
1779
1799
|
let t = parseFloat(e);
|
|
1780
1800
|
return isNaN(t) ? null : t;
|
|
1781
1801
|
}
|
|
1782
|
-
}),
|
|
1802
|
+
}), Ye = We({
|
|
1783
1803
|
alignRight: !0,
|
|
1784
1804
|
formatBlurredInput: (e) => typeof e == "number" ? new Intl.NumberFormat().format(e) : "",
|
|
1785
1805
|
parseUserInput: (e) => {
|
|
@@ -1790,10 +1810,10 @@ var Ue = {
|
|
|
1790
1810
|
let t = parseFloat(e);
|
|
1791
1811
|
return isNaN(t) ? null : Math.round(t);
|
|
1792
1812
|
}
|
|
1793
|
-
}),
|
|
1813
|
+
}), Xe = 0xe8d4a51000, z = 1e10, B = We({
|
|
1794
1814
|
alignRight: !0,
|
|
1795
1815
|
formatBlurredInput: (e) => typeof e == "number" ? new Intl.NumberFormat(void 0, { style: "percent" }).format(e) : "",
|
|
1796
|
-
formatInputOnFocus: (e) => typeof e == "number" && !isNaN(e) ? String(Math.round(e *
|
|
1816
|
+
formatInputOnFocus: (e) => typeof e == "number" && !isNaN(e) ? String(Math.round(e * Xe) / z) : "",
|
|
1797
1817
|
parseUserInput: (e) => {
|
|
1798
1818
|
let t = parseFloat(e);
|
|
1799
1819
|
return isNaN(t) ? null : t / 100;
|
|
@@ -1802,7 +1822,7 @@ var Ue = {
|
|
|
1802
1822
|
let t = parseFloat(e);
|
|
1803
1823
|
return isNaN(t) ? null : t;
|
|
1804
1824
|
}
|
|
1805
|
-
}),
|
|
1825
|
+
}), Ze = e.memo(({ focus: e, active: t, rowData: n, setRowData: r }) => {
|
|
1806
1826
|
let a = o(null);
|
|
1807
1827
|
return i(() => {
|
|
1808
1828
|
e ? a.current?.select() : a.current?.blur();
|
|
@@ -1823,9 +1843,9 @@ var Ue = {
|
|
|
1823
1843
|
}
|
|
1824
1844
|
});
|
|
1825
1845
|
});
|
|
1826
|
-
|
|
1827
|
-
var
|
|
1828
|
-
component:
|
|
1846
|
+
Ze.displayName = "DateComponent";
|
|
1847
|
+
var Qe = {
|
|
1848
|
+
component: Ze,
|
|
1829
1849
|
deleteValue: () => null,
|
|
1830
1850
|
copyValue: ({ rowData: e }) => e ? e.toISOString().substr(0, 10) : null,
|
|
1831
1851
|
pasteValue: ({ value: e }) => {
|
|
@@ -1834,7 +1854,7 @@ var Je = {
|
|
|
1834
1854
|
},
|
|
1835
1855
|
minWidth: 170,
|
|
1836
1856
|
isCellEmpty: ({ rowData: e }) => !e
|
|
1837
|
-
},
|
|
1857
|
+
}, $e = e.memo(({ focus: e, active: t, rowData: n, setRowData: r }) => {
|
|
1838
1858
|
let a = o(null);
|
|
1839
1859
|
return i(() => {
|
|
1840
1860
|
e ? a.current?.select() : a.current?.blur();
|
|
@@ -1855,9 +1875,9 @@ var Je = {
|
|
|
1855
1875
|
}
|
|
1856
1876
|
});
|
|
1857
1877
|
});
|
|
1858
|
-
|
|
1859
|
-
var
|
|
1860
|
-
component:
|
|
1878
|
+
$e.displayName = "IsoDateComponent";
|
|
1879
|
+
var V = {
|
|
1880
|
+
component: $e,
|
|
1861
1881
|
deleteValue: () => null,
|
|
1862
1882
|
copyValue: ({ rowData: e }) => e,
|
|
1863
1883
|
pasteValue: ({ value: e }) => {
|
|
@@ -1866,7 +1886,7 @@ var Ye = {
|
|
|
1866
1886
|
},
|
|
1867
1887
|
minWidth: 170,
|
|
1868
1888
|
isCellEmpty: ({ rowData: e }) => !e
|
|
1869
|
-
},
|
|
1889
|
+
}, et = ({ columnData: { key: e, original: n }, rowData: r, setRowData: i, ...a }) => {
|
|
1870
1890
|
let s = o(r);
|
|
1871
1891
|
s.current = r;
|
|
1872
1892
|
let c = t((t) => {
|
|
@@ -1883,14 +1903,14 @@ var Ye = {
|
|
|
1883
1903
|
rowData: r[e],
|
|
1884
1904
|
...a
|
|
1885
1905
|
});
|
|
1886
|
-
},
|
|
1906
|
+
}, tt = (e, t) => ({
|
|
1887
1907
|
id: e,
|
|
1888
1908
|
...t,
|
|
1889
1909
|
columnData: {
|
|
1890
1910
|
key: e,
|
|
1891
1911
|
original: t
|
|
1892
1912
|
},
|
|
1893
|
-
component:
|
|
1913
|
+
component: et,
|
|
1894
1914
|
copyValue: ({ rowData: n, rowIndex: r }) => t.copyValue?.({
|
|
1895
1915
|
rowData: n[e],
|
|
1896
1916
|
rowIndex: r
|
|
@@ -1923,7 +1943,7 @@ var Ye = {
|
|
|
1923
1943
|
rowData: n[e],
|
|
1924
1944
|
rowIndex: r
|
|
1925
1945
|
}) ?? !1
|
|
1926
|
-
}),
|
|
1927
|
-
export {
|
|
1946
|
+
}), H = Me, U = Pe;
|
|
1947
|
+
export { U as DataSheetGrid, H as DynamicDataSheetGrid, qe as checkboxColumn, N as createAddRowsComponent, F as createContextMenuComponent, We as createTextColumn, Qe as dateColumn, Je as floatColumn, Ye as intColumn, V as isoDateColumn, tt as keyColumn, B as percentColumn, P as renderContextMenuItem, Ue as textColumn };
|
|
1928
1948
|
|
|
1929
1949
|
//# sourceMappingURL=index.js.map
|