@symply.io/basic-components 1.6.11-alpha.5 → 1.6.11-alpha.6
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.
@@ -30,7 +30,7 @@ function TBody(props) {
|
|
30
30
|
var rows = props.rows, columns = props.columns, _a = props.noDataText, noDataText = _a === void 0 ? "No Data!" : _a, rest = __rest(props, ["rows", "columns", "noDataText"]);
|
31
31
|
var virtualRows = useTableVirtualizer().virtualRows;
|
32
32
|
return (_jsx(TableBody, { children: virtualRows.length > 0 ? (virtualRows.map(function (virtualRow) {
|
33
|
-
return (_jsx(TableBodyRow, __assign({ rowIndex: virtualRow.index, virtualRow: virtualRow, rows: rows, columns: columns }, rest), "DataTable_".concat(virtualRow.
|
33
|
+
return (_jsx(TableBodyRow, __assign({ rowIndex: virtualRow.index, virtualRow: virtualRow, rows: rows, columns: columns }, rest), "DataTable_".concat(virtualRow.index)));
|
34
34
|
})) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) }));
|
35
35
|
}
|
36
36
|
export default TBody;
|
@@ -47,6 +47,7 @@ function TableBodyRow(props) {
|
|
47
47
|
}, [row, columns, onCustomizeRowBgColor]), normal = _d.normal, hover = _d.hover;
|
48
48
|
return (_jsxs(TableRow, __assign({ sx: {
|
49
49
|
backgroundColor: normal,
|
50
|
+
width: "100%",
|
50
51
|
transform: "translateY(".concat(virtualRow.start - rowIndex * virtualRow.size, "px)"),
|
51
52
|
"&:hover": {
|
52
53
|
cursor: onRowClick ? "pointer" : "default",
|
@@ -11,7 +11,10 @@ var __assign = (this && this.__assign) || function () {
|
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
13
|
import { useRef, useState, useEffect, useContext, useCallback, createContext, } from "react";
|
14
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
14
|
+
import { useVirtualizer, elementScroll } from "@tanstack/react-virtual";
|
15
|
+
function easeInOutQuint(t) {
|
16
|
+
return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
17
|
+
}
|
15
18
|
var VirtualizerContext = createContext({
|
16
19
|
tableRef: { current: null },
|
17
20
|
virtualRows: [],
|
@@ -23,6 +26,29 @@ var VirtualizerContext = createContext({
|
|
23
26
|
export function VirtualizerContextProvider(props) {
|
24
27
|
var children = props.children, rows = props.rows, columns = props.columns, dense = props.dense;
|
25
28
|
var tableRef = useRef(null);
|
29
|
+
var scrollingRef = useRef();
|
30
|
+
var scrollToFn = useCallback(function (offset, canSmooth, instance) {
|
31
|
+
var _a;
|
32
|
+
var duration = 1000;
|
33
|
+
var start = ((_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) || 0;
|
34
|
+
var startTime = (scrollingRef.current = Date.now());
|
35
|
+
var run = function () {
|
36
|
+
if (scrollingRef.current !== startTime)
|
37
|
+
return;
|
38
|
+
var now = Date.now();
|
39
|
+
var elapsed = now - startTime;
|
40
|
+
var progress = easeInOutQuint(Math.min(elapsed / duration, 1));
|
41
|
+
var interpolated = start + (offset - start) * progress;
|
42
|
+
if (elapsed < duration) {
|
43
|
+
elementScroll(interpolated, canSmooth, instance);
|
44
|
+
requestAnimationFrame(run);
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
elementScroll(interpolated, canSmooth, instance);
|
48
|
+
}
|
49
|
+
};
|
50
|
+
requestAnimationFrame(run);
|
51
|
+
}, []);
|
26
52
|
var rowVirtualizer = useVirtualizer({
|
27
53
|
count: rows.length,
|
28
54
|
getScrollElement: function () { return tableRef.current; },
|
@@ -31,7 +57,8 @@ export function VirtualizerContextProvider(props) {
|
|
31
57
|
navigator.userAgent.indexOf("Firefox") === -1
|
32
58
|
? function (element) { return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height; }
|
33
59
|
: undefined,
|
34
|
-
overscan:
|
60
|
+
overscan: 12,
|
61
|
+
scrollToFn: scrollToFn,
|
35
62
|
});
|
36
63
|
var _a = useState(false), leftShadowVisible = _a[0], setLeftShadowVisible = _a[1];
|
37
64
|
var _b = useState(false), rightShadowVisible = _b[0], setRightShadowVisible = _b[1];
|