@spteck/react-controls-v2 2.3.8 → 2.3.91
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/components/DataGridV2/useDataGridV2Styles.d.ts +1 -1
- package/dist/index.cjs +10 -26
- package/dist/index.js +95 -94
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9634,27 +9634,27 @@ var Zu = function(e, t, n) {
|
|
|
9634
9634
|
children: [/* @__PURE__ */ R(_t, { children: /* @__PURE__ */ R(yt, { children: ({ renderHeaderCell: e }) => /* @__PURE__ */ R(vt, { children: e() }) }) }), /* @__PURE__ */ R(k, {})]
|
|
9635
9635
|
})
|
|
9636
9636
|
});
|
|
9637
|
-
}, _d =
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9637
|
+
}, _d = In({ scrollbar: {
|
|
9638
|
+
scrollbarWidth: "thin",
|
|
9639
|
+
scrollbarColor: `${V.colorBrandBackground} ${V.colorNeutralBackground4}`,
|
|
9640
|
+
"&::-webkit-scrollbar": {
|
|
9641
|
+
width: "5px",
|
|
9642
|
+
height: "5px"
|
|
9643
|
+
},
|
|
9644
|
+
"&::-webkit-scrollbar-track": {
|
|
9645
|
+
background: V.colorNeutralBackground4,
|
|
9646
|
+
borderRadius: V.borderRadiusMedium
|
|
9647
|
+
},
|
|
9648
|
+
"&::-webkit-scrollbar-thumb": {
|
|
9649
|
+
background: V.colorBrandBackground,
|
|
9650
|
+
borderRadius: V.borderRadiusMedium
|
|
9651
|
+
},
|
|
9652
|
+
"&::-webkit-scrollbar-thumb:hover": { background: V.colorBrandBackgroundHover }
|
|
9653
|
+
} });
|
|
9654
9654
|
//#endregion
|
|
9655
9655
|
//#region src/components/DataGridV2/DataGridV2.tsx
|
|
9656
9656
|
function vd(e, t) {
|
|
9657
|
-
let { columns:
|
|
9657
|
+
let n = _d().scrollbar, { columns: r, items: i, enableSorting: a = !1, enableResizing: o = !1, selectionMode: s = "none", onSelectionChange: c, defaultSelectedItems: l = [], defaultSortState: u, onSortChange: d, columnSizingOptions: f, resizableColumnsOptions: p, noItemsMessage: m, isLoadingData: h, isLoadingDataMessage: g, dataGridBodyClassName: _, dataGridBodyStyles: v, refreshData: y, enableInfiniteScroll: b, onLoadMore: x, infiniteScrollPageSize: S, hasNextPage: C, isLoadingMore: w, autoShowLastPage: T = !0, virtualizedHeight: E = 600, virtualizedItemSize: D = 44, startIndex: O, onRowClick: k } = e, A = M.useMemo(() => r.map((e) => Fn({
|
|
9658
9658
|
columnId: e.column,
|
|
9659
9659
|
renderHeaderCell: () => /* @__PURE__ */ R(rt, { children: e.header }),
|
|
9660
9660
|
renderCell: (t) => /* @__PURE__ */ R(Sn, {
|
|
@@ -9664,138 +9664,139 @@ function vd(e, t) {
|
|
|
9664
9664
|
children: e.onRender ? e.onRender(t) : String(t[e.column] ?? "")
|
|
9665
9665
|
}),
|
|
9666
9666
|
compare: e.order
|
|
9667
|
-
})), [
|
|
9667
|
+
})), [r]), j = M.useCallback((e) => i.findIndex((t) => t === e), [i]), [ee, te] = M.useState(new Set(l.map((e) => j(e)))), [ne, re] = M.useState(0);
|
|
9668
9668
|
M.useEffect(() => {
|
|
9669
|
-
|
|
9669
|
+
l.length && te(new Set(l.map((e) => j(e))));
|
|
9670
9670
|
}, [
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9671
|
+
l,
|
|
9672
|
+
i,
|
|
9673
|
+
j
|
|
9674
9674
|
]), M.useEffect(() => {
|
|
9675
|
-
|
|
9676
|
-
}, [
|
|
9677
|
-
let
|
|
9675
|
+
y && te(/* @__PURE__ */ new Set());
|
|
9676
|
+
}, [y]);
|
|
9677
|
+
let ie = (e, t) => {
|
|
9678
9678
|
let n = /* @__PURE__ */ new Set();
|
|
9679
9679
|
t.selectedItems.forEach((e) => {
|
|
9680
9680
|
let t = Number(e);
|
|
9681
9681
|
isNaN(t) || n.add(t);
|
|
9682
|
-
}),
|
|
9683
|
-
},
|
|
9684
|
-
|
|
9685
|
-
}, [
|
|
9682
|
+
}), te(n), c && c(Array.from(n).map((e) => i[e]));
|
|
9683
|
+
}, ae = (e, t) => {
|
|
9684
|
+
d && d(t);
|
|
9685
|
+
}, [oe, se] = M.useState(null), ce = M.useMemo(() => new Map(i.map((e, t) => [e, t])), [i]);
|
|
9686
9686
|
M.useEffect(() => {
|
|
9687
|
-
|
|
9687
|
+
s === "row" && oe != null && oe >= i.length && se(null);
|
|
9688
9688
|
}, [
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9689
|
+
i,
|
|
9690
|
+
oe,
|
|
9691
|
+
s
|
|
9692
9692
|
]), M.useEffect(() => {
|
|
9693
|
-
|
|
9694
|
-
}, [
|
|
9695
|
-
let
|
|
9693
|
+
y && s === "row" && se(null);
|
|
9694
|
+
}, [y, s]);
|
|
9695
|
+
let le = M.useRef(null), ue = M.useRef(i.length), de = M.useRef(!1), fe = M.useRef(!1), pe = M.useRef(!1);
|
|
9696
9696
|
M.useImperativeHandle(t, () => ({
|
|
9697
9697
|
scrollToIndex: (e, t = "auto") => {
|
|
9698
|
-
let n =
|
|
9698
|
+
let n = le.current;
|
|
9699
9699
|
n && "scrollToItem" in n && n.scrollToItem(Math.max(0, e), t);
|
|
9700
9700
|
},
|
|
9701
9701
|
resetGrid: () => {
|
|
9702
|
-
|
|
9702
|
+
re((e) => e + 1), ue.current = 0, de.current = !1, fe.current = !1, pe.current = !1, me.current = -1, te(/* @__PURE__ */ new Set()), se(null);
|
|
9703
9703
|
},
|
|
9704
|
-
getSelectedRow: () =>
|
|
9705
|
-
item:
|
|
9706
|
-
index:
|
|
9704
|
+
getSelectedRow: () => oe !== null && oe < i.length ? {
|
|
9705
|
+
item: i[oe],
|
|
9706
|
+
index: oe
|
|
9707
9707
|
} : null,
|
|
9708
9708
|
setSelectedRow: (e) => {
|
|
9709
|
-
let t =
|
|
9710
|
-
t !== -1 && (
|
|
9709
|
+
let t = i.findIndex((t) => t === e);
|
|
9710
|
+
t !== -1 && (se(t), c?.([e]));
|
|
9711
9711
|
}
|
|
9712
9712
|
})), M.useEffect(() => {
|
|
9713
|
-
if (!
|
|
9714
|
-
let e =
|
|
9715
|
-
"scrollToItem" in e && e.scrollToItem(Math.min(
|
|
9716
|
-
}
|
|
9717
|
-
}, [
|
|
9718
|
-
let e =
|
|
9719
|
-
if (
|
|
9720
|
-
let
|
|
9721
|
-
|
|
9722
|
-
}, [
|
|
9723
|
-
let
|
|
9724
|
-
if (!
|
|
9725
|
-
if (!
|
|
9726
|
-
|
|
9713
|
+
if (!de.current && typeof O == "number" && le.current) {
|
|
9714
|
+
let e = le.current;
|
|
9715
|
+
"scrollToItem" in e && e.scrollToItem(Math.min(O, Math.max(i.length - 1, 0)), "start"), de.current = !0;
|
|
9716
|
+
}
|
|
9717
|
+
}, [O, i.length]), M.useEffect(() => {
|
|
9718
|
+
let e = ue.current, t = i.length, n = t > e;
|
|
9719
|
+
if (ue.current = t, !T || !n || e === 0) return;
|
|
9720
|
+
let r = le.current;
|
|
9721
|
+
r && "scrollToItem" in r && r.scrollToItem(Math.max(t - 1, 0), "end");
|
|
9722
|
+
}, [i.length, T]);
|
|
9723
|
+
let me = M.useRef(-1), he = M.useCallback(({ visibleStopIndex: e }) => {
|
|
9724
|
+
if (!b || !x || w || pe.current) return;
|
|
9725
|
+
if (!fe.current) {
|
|
9726
|
+
fe.current = !0;
|
|
9727
9727
|
return;
|
|
9728
9728
|
}
|
|
9729
|
-
let t =
|
|
9730
|
-
if (
|
|
9729
|
+
let t = S ?? 20;
|
|
9730
|
+
if (i.length < t) return;
|
|
9731
9731
|
let n = Math.max(5, Math.ceil(t / 5));
|
|
9732
|
-
e >=
|
|
9732
|
+
e >= i.length - n && C && me.current !== i.length && (me.current = i.length, pe.current = !0, x());
|
|
9733
9733
|
}, [
|
|
9734
|
-
y,
|
|
9735
9734
|
b,
|
|
9736
|
-
|
|
9735
|
+
x,
|
|
9737
9736
|
C,
|
|
9738
|
-
|
|
9739
|
-
|
|
9737
|
+
w,
|
|
9738
|
+
i.length,
|
|
9739
|
+
S
|
|
9740
9740
|
]);
|
|
9741
9741
|
return M.useEffect(() => {
|
|
9742
|
-
|
|
9743
|
-
}, [
|
|
9742
|
+
pe.current && i.length > me.current && (pe.current = !1);
|
|
9743
|
+
}, [i.length]), /* @__PURE__ */ z("div", {
|
|
9744
9744
|
style: M.useMemo(() => ({
|
|
9745
9745
|
overflowX: "auto",
|
|
9746
9746
|
overflowY: "hidden",
|
|
9747
9747
|
position: "relative"
|
|
9748
9748
|
}), []),
|
|
9749
|
-
className:
|
|
9750
|
-
children: [
|
|
9749
|
+
className: n,
|
|
9750
|
+
children: [h && /* @__PURE__ */ R(Y, {
|
|
9751
9751
|
alignItems: "center",
|
|
9752
9752
|
justifyContent: "center",
|
|
9753
|
-
height: `${
|
|
9754
|
-
children: M.isValidElement(
|
|
9753
|
+
height: `${E}px`,
|
|
9754
|
+
children: M.isValidElement(g) ? g : /* @__PURE__ */ z(vn, {
|
|
9755
9755
|
size: "extra-tiny",
|
|
9756
9756
|
children: [
|
|
9757
9757
|
" ",
|
|
9758
|
-
|
|
9758
|
+
g ?? "Loading data...",
|
|
9759
9759
|
" "
|
|
9760
9760
|
]
|
|
9761
9761
|
})
|
|
9762
|
-
}), !
|
|
9763
|
-
items:
|
|
9764
|
-
columns:
|
|
9765
|
-
sortable:
|
|
9766
|
-
onSortChange:
|
|
9767
|
-
selectionMode:
|
|
9768
|
-
selectedItems:
|
|
9769
|
-
onSelectionChange:
|
|
9770
|
-
defaultSortState:
|
|
9771
|
-
resizableColumns:
|
|
9772
|
-
columnSizingOptions:
|
|
9773
|
-
resizableColumnsOptions:
|
|
9762
|
+
}), !h && i.length ? /* @__PURE__ */ z(gi, {
|
|
9763
|
+
items: i,
|
|
9764
|
+
columns: A,
|
|
9765
|
+
sortable: a,
|
|
9766
|
+
onSortChange: a ? ae : void 0,
|
|
9767
|
+
selectionMode: s === "none" || s === "row" ? void 0 : s === "multiple" ? "multiselect" : s === "single" ? "single" : void 0,
|
|
9768
|
+
selectedItems: ee,
|
|
9769
|
+
onSelectionChange: ie,
|
|
9770
|
+
defaultSortState: u,
|
|
9771
|
+
resizableColumns: o,
|
|
9772
|
+
columnSizingOptions: f,
|
|
9773
|
+
resizableColumnsOptions: p,
|
|
9774
9774
|
focusMode: "cell",
|
|
9775
|
-
className:
|
|
9776
|
-
style:
|
|
9775
|
+
className: Ln(_, n),
|
|
9776
|
+
style: v,
|
|
9777
9777
|
children: [/* @__PURE__ */ R(yi, { children: /* @__PURE__ */ R(xi, { children: ({ renderHeaderCell: e }) => /* @__PURE__ */ R(bi, { children: e() }) }) }), /* @__PURE__ */ R(_i, {
|
|
9778
|
-
itemSize:
|
|
9779
|
-
height:
|
|
9778
|
+
itemSize: D,
|
|
9779
|
+
height: E,
|
|
9780
9780
|
width: "100%",
|
|
9781
|
-
listProps: { onItemsRendered:
|
|
9781
|
+
listProps: { onItemsRendered: he },
|
|
9782
|
+
className: n,
|
|
9782
9783
|
children: (e, t) => (() => {
|
|
9783
|
-
let n = e.item,
|
|
9784
|
-
|
|
9784
|
+
let n = e.item, r = ce.get(n) ?? i.indexOf(n), a = s === "row", o = a && oe === r, l = (e) => {
|
|
9785
|
+
se(r), c?.([n]), k?.(n, r);
|
|
9785
9786
|
};
|
|
9786
9787
|
return /* @__PURE__ */ R(xi, {
|
|
9787
9788
|
style: {
|
|
9788
9789
|
...t,
|
|
9789
9790
|
cursor: a ? "pointer" : void 0,
|
|
9790
|
-
background:
|
|
9791
|
+
background: o ? V.colorSubtleBackgroundSelected : void 0
|
|
9791
9792
|
},
|
|
9792
9793
|
onClick: l,
|
|
9793
|
-
"aria-selected":
|
|
9794
|
+
"aria-selected": o || void 0,
|
|
9794
9795
|
children: ({ renderCell: e }) => /* @__PURE__ */ R(vi, { children: e(n) })
|
|
9795
9796
|
});
|
|
9796
9797
|
})()
|
|
9797
9798
|
})]
|
|
9798
|
-
},
|
|
9799
|
+
}, ne) : !h && !i.length ? /* @__PURE__ */ R("div", { children: m }) : null]
|
|
9799
9800
|
});
|
|
9800
9801
|
}
|
|
9801
9802
|
var yd = M.forwardRef(vd);
|