@symply.io/basic-components 1.7.0-alpha.1 → 1.7.0-alpha.2
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/VirtualGrid/GridCore/{TableBody.d.ts → GridBody.d.ts} +2 -1
- package/VirtualGrid/GridCore/{TableBody.js → GridBody.js} +7 -11
- package/VirtualGrid/GridCore/GridBodyRow.d.ts +4 -0
- package/VirtualGrid/GridCore/{TableBodyRow.js → GridBodyRow.js} +35 -23
- package/VirtualGrid/GridCore/GridFooter.d.ts +4 -0
- package/VirtualGrid/GridCore/{TableFooter.js → GridFooter.js} +8 -13
- package/VirtualGrid/GridCore/GridHeader.d.ts +4 -0
- package/VirtualGrid/GridCore/{TableHeader.js → GridHeader.js} +9 -13
- package/VirtualGrid/GridCore/index.d.ts +2 -1
- package/VirtualGrid/GridCore/index.js +8 -6
- package/VirtualGrid/GridVirtualizerContext.js +11 -8
- package/VirtualGrid/index.js +2 -2
- package/VirtualGrid/types.d.ts +2 -0
- package/package.json +1 -1
- package/VirtualGrid/GridCore/TableBodyRow.d.ts +0 -3
- package/VirtualGrid/GridCore/TableFooter.d.ts +0 -5
- package/VirtualGrid/GridCore/TableHeader.d.ts +0 -5
@@ -1,3 +1,4 @@
|
|
1
1
|
import type { VirtualGridBodyProps } from "../types";
|
2
2
|
declare function VirtualGridBody<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridBodyProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
3
|
-
|
3
|
+
declare const _default: typeof VirtualGridBody;
|
4
|
+
export default _default;
|
@@ -21,21 +21,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
21
|
return t;
|
22
22
|
};
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
|
+
import { memo } from "react";
|
24
25
|
import TableRow from "@mui/material/TableRow";
|
25
26
|
import TableBody from "@mui/material/TableBody";
|
26
27
|
import TableCell from "@mui/material/TableCell";
|
27
|
-
import
|
28
|
+
import GridBodyRow from "./GridBodyRow";
|
28
29
|
import { useGridVirtualizer } from "../GridVirtualizerContext";
|
29
30
|
function VirtualGridBody(props) {
|
30
31
|
var rows = props.rows, columns = props.columns, _a = props.noDataText, noDataText = _a === void 0 ? "No Data!" : _a, rest = __rest(props, ["rows", "columns", "noDataText"]);
|
31
|
-
var
|
32
|
-
return (_jsx(TableBody,
|
33
|
-
|
34
|
-
|
35
|
-
position: "relative",
|
36
|
-
display: "grid",
|
37
|
-
} }, { children: virtualRows.length > 0 ? (virtualRows.map(function (virtualRow) {
|
38
|
-
return (_jsx(TableBodyRow, __assign({ rowIndex: virtualRow.index, virtualRow: virtualRow, rows: rows, columns: columns }, rest), "DataTable_".concat(virtualRow.index)));
|
39
|
-
})) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) })));
|
32
|
+
var virtualRows = useGridVirtualizer().virtualRows;
|
33
|
+
return (_jsx(TableBody, { children: virtualRows.length > 0 ? (virtualRows.map(function (virtualRow, index) {
|
34
|
+
return (_jsx(GridBodyRow, __assign({ rowIndex: index, virtualRow: virtualRow, rows: rows, columns: columns }, rest), "Virtual_Grid_Body_Row_".concat(virtualRow.key)));
|
35
|
+
})) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) }));
|
40
36
|
}
|
41
|
-
export default VirtualGridBody;
|
37
|
+
export default memo(VirtualGridBody);
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { VirtualGridBodyRowProps } from "../types";
|
2
|
+
declare function VirtualGridBodyRow<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridBodyRowProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
3
|
+
declare const _default: typeof VirtualGridBodyRow;
|
4
|
+
export default _default;
|
@@ -10,20 +10,20 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
-
import { cloneElement, useState, useMemo } from "react";
|
13
|
+
import { memo, cloneElement, useState, useMemo } from "react";
|
14
14
|
import TableRow from "@mui/material/TableRow";
|
15
15
|
import TableCell from "@mui/material/TableCell";
|
16
16
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
17
17
|
import useTheme from "@mui/material/styles/useTheme";
|
18
18
|
import { useGridVirtualizer } from "../GridVirtualizerContext";
|
19
|
-
function
|
19
|
+
function VirtualGridBodyRow(props) {
|
20
20
|
var rows = props.rows, columns = props.columns, rowIndex = props.rowIndex, virtualRow = props.virtualRow, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
|
21
|
-
|
21
|
+
console.log({ virtualRow: virtualRow });
|
22
22
|
var theme = useTheme();
|
23
23
|
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
24
|
-
var
|
24
|
+
var _a = useGridVirtualizer(), leftShadowVisible = _a.leftShadowVisible, rightShadowVisible = _a.rightShadowVisible, onMeasureElement = _a.onMeasureElement;
|
25
25
|
var row = useMemo(function () { return rows[virtualRow.index]; }, [rows, virtualRow]);
|
26
|
-
var
|
26
|
+
var _b = useMemo(function () {
|
27
27
|
if (isUpMd) {
|
28
28
|
var left = columns.filter(function (c) { return c.fixable === "left"; });
|
29
29
|
var right = columns.filter(function (c) { return c.fixable === "right"; });
|
@@ -33,8 +33,8 @@ function TableBodyRow(props) {
|
|
33
33
|
else {
|
34
34
|
return [[], columns, []];
|
35
35
|
}
|
36
|
-
}, [isUpMd, columns]), fixedLeftCols =
|
37
|
-
var
|
36
|
+
}, [isUpMd, columns]), fixedLeftCols = _b[0], dynamicCols = _b[1], fixedRightCols = _b[2];
|
37
|
+
var _c = useMemo(function () {
|
38
38
|
if (onCustomizeRowBgColor) {
|
39
39
|
var regex = /^#(\d|[a-f]|[A-F]){6}/i;
|
40
40
|
var _a = onCustomizeRowBgColor({ row: row, columns: columns }), normal_1 = _a.normal, hover_1 = _a.hover;
|
@@ -44,18 +44,18 @@ function TableBodyRow(props) {
|
|
44
44
|
};
|
45
45
|
}
|
46
46
|
return { normal: "#FEFEFE", hover: "#F2F1F3" };
|
47
|
-
}, [row, columns, onCustomizeRowBgColor]), normal =
|
47
|
+
}, [row, columns, onCustomizeRowBgColor]), normal = _c.normal, hover = _c.hover;
|
48
|
+
var _d = useState(), rowEl = _d[0], setRowEl = _d[1];
|
48
49
|
return (_jsxs(TableRow, __assign({ sx: {
|
49
50
|
backgroundColor: normal,
|
50
51
|
width: "100%",
|
51
|
-
|
52
|
-
|
53
|
-
transform: "translateY(".concat(virtualRow.start, "px)"),
|
52
|
+
height: "".concat(virtualRow.size, "px"),
|
53
|
+
transform: "translateY(".concat(virtualRow.start - rowIndex * virtualRow.size, "px)"),
|
54
54
|
"&:hover": {
|
55
55
|
cursor: onRowClick ? "pointer" : "default",
|
56
56
|
backgroundColor: onRowClick ? hover : normal,
|
57
57
|
},
|
58
|
-
}, "data-index": virtualRow.index,
|
58
|
+
}, "data-index": virtualRow.index, onMouseEnter: function (event) {
|
59
59
|
setRowEl(event.currentTarget);
|
60
60
|
}, onMouseLeave: function () {
|
61
61
|
setRowEl(undefined);
|
@@ -74,11 +74,10 @@ function TableBodyRow(props) {
|
|
74
74
|
.slice(0, index)
|
75
75
|
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
76
76
|
return (_jsx(TableCell, __assign({ align: align, sx: {
|
77
|
-
minWidth: width,
|
78
77
|
left: left,
|
79
|
-
position: "sticky",
|
80
|
-
display: "flex",
|
81
78
|
zIndex: 10,
|
79
|
+
position: "sticky",
|
80
|
+
width: width,
|
82
81
|
backgroundColor: onRowClick && rowEl ? hover : normal,
|
83
82
|
"&::after": index === fixedLeftCols.length - 1 && leftShadowVisible
|
84
83
|
? {
|
@@ -93,26 +92,34 @@ function TableBodyRow(props) {
|
|
93
92
|
boxShadow: "inset 10px 0 10px -8px rgba(0, 0, 0, 0.1)",
|
94
93
|
}
|
95
94
|
: undefined,
|
96
|
-
} }, { children: cloneElement(Cell, {
|
95
|
+
} }, { children: cloneElement(Cell, {
|
96
|
+
column: col,
|
97
|
+
rows: rows,
|
98
|
+
row: row,
|
99
|
+
rowIndex: virtualRow.index,
|
100
|
+
}) }), "Virtual_Grid_Body_Row_".concat(virtualRow.index, "_").concat(accessor)));
|
97
101
|
}), dynamicCols.map(function (col) {
|
98
102
|
var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
|
99
103
|
return (_jsx(TableCell, __assign({ align: align, sx: {
|
100
|
-
minWidth: width,
|
101
104
|
zIndex: 9,
|
102
|
-
|
105
|
+
width: width,
|
103
106
|
backgroundColor: onRowClick && rowEl ? hover : normal,
|
104
|
-
} }, { children: cloneElement(Cell, {
|
107
|
+
} }, { children: cloneElement(Cell, {
|
108
|
+
column: col,
|
109
|
+
rows: rows,
|
110
|
+
row: row,
|
111
|
+
rowIndex: virtualRow.index,
|
112
|
+
}) }), "Virtual_Grid_Body_Row_".concat(virtualRow.index, "_").concat(accessor)));
|
105
113
|
}), fixedRightCols.map(function (col, index) {
|
106
114
|
var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
|
107
115
|
var right = fixedRightCols
|
108
116
|
.slice(0, fixedRightCols.length - 1 - index)
|
109
117
|
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
110
118
|
return (_jsx(TableCell, __assign({ align: align, sx: {
|
111
|
-
minWidth: width,
|
112
119
|
right: right,
|
120
|
+
width: width,
|
113
121
|
position: "sticky",
|
114
122
|
zIndex: 10,
|
115
|
-
display: "flex",
|
116
123
|
backgroundColor: onRowClick && rowEl ? hover : normal,
|
117
124
|
"&::after": index === 0 && rightShadowVisible
|
118
125
|
? {
|
@@ -127,7 +134,12 @@ function TableBodyRow(props) {
|
|
127
134
|
boxShadow: "inset -10px 0 10px -8px rgba(0, 0, 0, 0.1)",
|
128
135
|
}
|
129
136
|
: undefined,
|
130
|
-
} }, { children: cloneElement(Cell, {
|
137
|
+
} }, { children: cloneElement(Cell, {
|
138
|
+
column: col,
|
139
|
+
rows: rows,
|
140
|
+
row: row,
|
141
|
+
rowIndex: virtualRow.index,
|
142
|
+
}) }), "Virtual_Grid_Body_Row_".concat(virtualRow.index, "_").concat(accessor)));
|
131
143
|
})] })));
|
132
144
|
}
|
133
|
-
export default
|
145
|
+
export default memo(VirtualGridBodyRow);
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { VirtualGridFooterProps } from "../types";
|
2
|
+
declare function VirtualGridFooter<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridFooterProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
3
|
+
declare const _default: typeof VirtualGridFooter;
|
4
|
+
export default _default;
|
@@ -17,7 +17,7 @@ import TableCell from "@mui/material/TableCell";
|
|
17
17
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
18
18
|
import useTheme from "@mui/material/styles/useTheme";
|
19
19
|
import { useGridVirtualizer } from "../GridVirtualizerContext";
|
20
|
-
function
|
20
|
+
function VirtualGridFooter(props) {
|
21
21
|
var _a = props.footers, footers = _a === void 0 ? [] : _a, footerBgColor = props.footerBgColor, footerTextColor = props.footerTextColor, noData = props.noData;
|
22
22
|
var theme = useTheme();
|
23
23
|
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
@@ -37,11 +37,9 @@ function TableFooter(props) {
|
|
37
37
|
position: "sticky",
|
38
38
|
bottom: "-1px",
|
39
39
|
zIndex: 20,
|
40
|
-
display: "grid",
|
41
40
|
} }, { children: _jsxs(TableRow, __assign({ sx: {
|
42
41
|
backgroundColor: "".concat(footerBgColor || "#eaf0f6", " !important"),
|
43
42
|
color: "".concat(footerTextColor || "inherit", " !important"),
|
44
|
-
display: "flex",
|
45
43
|
width: "100%",
|
46
44
|
} }, { children: [fixedLeftFooters.map(function (footer, index) {
|
47
45
|
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
@@ -54,8 +52,7 @@ function TableFooter(props) {
|
|
54
52
|
color: "".concat(footerTextColor || "inherit", " !important"),
|
55
53
|
zIndex: 10,
|
56
54
|
left: left,
|
57
|
-
|
58
|
-
display: "flex",
|
55
|
+
width: width,
|
59
56
|
userSelect: "none",
|
60
57
|
"&::after": index === fixedLeftFooters.length - 1 && leftShadowVisible
|
61
58
|
? {
|
@@ -70,17 +67,16 @@ function TableFooter(props) {
|
|
70
67
|
boxShadow: "inset 10px 0 10px -8px rgba(0, 0, 0, 0.1)",
|
71
68
|
}
|
72
69
|
: undefined,
|
73
|
-
} }, { children: cloneElement(Cell) }), accessor));
|
70
|
+
} }, { children: cloneElement(Cell) }), "Virtual_Grid_Footer_Col_".concat(accessor)));
|
74
71
|
}), dynamicFooters.map(function (footer) {
|
75
72
|
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
76
73
|
return (_jsx(TableCell, __assign({ align: align, sx: {
|
77
74
|
zIndex: 9,
|
78
|
-
|
79
|
-
display: "flex",
|
75
|
+
width: width,
|
80
76
|
userSelect: "none",
|
81
77
|
backgroundColor: "".concat(footerBgColor || "#eaf0f6", " !important"),
|
82
78
|
color: "".concat(footerTextColor || "inherit", " !important"),
|
83
|
-
} }, { children: cloneElement(Cell) }), accessor));
|
79
|
+
} }, { children: cloneElement(Cell) }), "Virtual_Grid_Footer_Col_".concat(accessor)));
|
84
80
|
}), fixedRightFooters.map(function (footer, index) {
|
85
81
|
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
86
82
|
var right = fixedRightFooters
|
@@ -89,9 +85,8 @@ function TableFooter(props) {
|
|
89
85
|
return (_jsx(TableCell, __assign({ align: align, sx: {
|
90
86
|
position: "sticky",
|
91
87
|
zIndex: 10,
|
92
|
-
minWidth: width,
|
93
88
|
right: right,
|
94
|
-
|
89
|
+
width: width,
|
95
90
|
backgroundColor: "".concat(footerBgColor || "#eaf0f6", " !important"),
|
96
91
|
color: "".concat(footerTextColor || "inherit", " !important"),
|
97
92
|
userSelect: "none",
|
@@ -108,7 +103,7 @@ function TableFooter(props) {
|
|
108
103
|
boxShadow: "inset -10px 0 10px -8px rgba(0, 0, 0, 0.1)",
|
109
104
|
}
|
110
105
|
: undefined,
|
111
|
-
} }, { children: cloneElement(Cell) }), accessor));
|
106
|
+
} }, { children: cloneElement(Cell) }), "Virtual_Grid_Footer_Col_".concat(accessor)));
|
112
107
|
})] })) })));
|
113
108
|
}
|
114
|
-
export default memo(
|
109
|
+
export default memo(VirtualGridFooter);
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { VirtualGridHeaderProps } from "../types";
|
2
|
+
declare function VirtualGridHeader<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridHeaderProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
3
|
+
declare const _default: typeof VirtualGridHeader;
|
4
|
+
export default _default;
|
@@ -17,7 +17,7 @@ import TableCell from "@mui/material/TableCell";
|
|
17
17
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
18
18
|
import useTheme from "@mui/material/styles/useTheme";
|
19
19
|
import { useGridVirtualizer } from "../GridVirtualizerContext";
|
20
|
-
function
|
20
|
+
function VirtualGridHeader(props) {
|
21
21
|
var headers = props.headers, headerBgColor = props.headerBgColor, headerTextColor = props.headerTextColor, noData = props.noData;
|
22
22
|
var theme = useTheme();
|
23
23
|
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
@@ -33,10 +33,9 @@ function TableHeader(props) {
|
|
33
33
|
return [[], headers, []];
|
34
34
|
}
|
35
35
|
}, [isUpMd, noData, headers]), fixedLeftHeaders = _b[0], dynamicHeaders = _b[1], fixedRightHeaders = _b[2];
|
36
|
-
return (_jsx(TableHead, __assign({ sx: { position: "sticky", top: 0, zIndex: 20
|
36
|
+
return (_jsx(TableHead, __assign({ sx: { position: "sticky", top: 0, zIndex: 20 } }, { children: _jsxs(TableRow, __assign({ sx: {
|
37
37
|
backgroundColor: "".concat(headerBgColor || "#eaf0f6", " !important"),
|
38
38
|
color: "".concat(headerTextColor || "inherit", " !important"),
|
39
|
-
display: "flex",
|
40
39
|
width: "100%",
|
41
40
|
} }, { children: [fixedLeftHeaders.map(function (header, index) {
|
42
41
|
var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
|
@@ -48,9 +47,8 @@ function TableHeader(props) {
|
|
48
47
|
backgroundColor: "".concat(headerBgColor || "#eaf0f6", " !important"),
|
49
48
|
color: "".concat(headerTextColor || "inherit", " !important"),
|
50
49
|
zIndex: 10,
|
51
|
-
minWidth: width,
|
52
50
|
left: left,
|
53
|
-
|
51
|
+
width: width,
|
54
52
|
userSelect: "none",
|
55
53
|
cursor: sortable ? "pointer" : "default",
|
56
54
|
"&::after": index === fixedLeftHeaders.length - 1 && leftShadowVisible
|
@@ -68,20 +66,19 @@ function TableHeader(props) {
|
|
68
66
|
: undefined,
|
69
67
|
}, onClick: function () {
|
70
68
|
onSort({ accessor: accessor });
|
71
|
-
} }, { children: cloneElement(Cell) }), accessor));
|
69
|
+
} }, { children: cloneElement(Cell) }), "Virtual_Grid_Header_Col_".concat(accessor)));
|
72
70
|
}), dynamicHeaders.map(function (header) {
|
73
71
|
var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
|
74
72
|
return (_jsx(TableCell, __assign({ title: title, align: align, sx: {
|
75
|
-
minWidth: width,
|
76
73
|
zIndex: 9,
|
74
|
+
width: width,
|
77
75
|
userSelect: "none",
|
78
|
-
display: "flex",
|
79
76
|
cursor: sortable ? "pointer" : "default",
|
80
77
|
backgroundColor: "".concat(headerBgColor || "#eaf0f6", " !important"),
|
81
78
|
color: "".concat(headerTextColor || "inherit", " !important"),
|
82
79
|
}, onClick: function () {
|
83
80
|
onSort({ accessor: accessor });
|
84
|
-
} }, { children: cloneElement(Cell) }), accessor));
|
81
|
+
} }, { children: cloneElement(Cell) }), "Virtual_Grid_Header_Col_".concat(accessor)));
|
85
82
|
}), fixedRightHeaders.map(function (header, index) {
|
86
83
|
var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
|
87
84
|
var right = fixedRightHeaders
|
@@ -92,9 +89,8 @@ function TableHeader(props) {
|
|
92
89
|
backgroundColor: "".concat(headerBgColor || "#eaf0f6", " !important"),
|
93
90
|
color: "".concat(headerTextColor || "inherit", " !important"),
|
94
91
|
zIndex: 10,
|
95
|
-
minWidth: width,
|
96
92
|
right: right,
|
97
|
-
|
93
|
+
width: width,
|
98
94
|
userSelect: "none",
|
99
95
|
cursor: sortable ? "pointer" : "default",
|
100
96
|
"&::after": index === 0 && rightShadowVisible
|
@@ -112,7 +108,7 @@ function TableHeader(props) {
|
|
112
108
|
: undefined,
|
113
109
|
}, onClick: function () {
|
114
110
|
onSort({ accessor: accessor });
|
115
|
-
} }, { children: cloneElement(Cell) }), accessor));
|
111
|
+
} }, { children: cloneElement(Cell) }), "Virtual_Grid_Header_Col_".concat(accessor)));
|
116
112
|
})] })) })));
|
117
113
|
}
|
118
|
-
export default memo(
|
114
|
+
export default memo(VirtualGridHeader);
|
@@ -1,3 +1,4 @@
|
|
1
1
|
import type { VirtualGridCoreProps } from "../types";
|
2
2
|
declare function VirtualGridCore<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridCoreProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
3
|
-
|
3
|
+
declare const _default: typeof VirtualGridCore;
|
4
|
+
export default _default;
|
@@ -10,15 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
import { memo } from "react";
|
14
|
+
import Grid from "@mui/material/Grid";
|
13
15
|
import Table from "@mui/material/Table";
|
14
16
|
import TableContainer from "@mui/material/TableContainer";
|
15
|
-
import TableBody from "./
|
16
|
-
import TableHeader from "./
|
17
|
-
import TableFooter from "./
|
17
|
+
import TableBody from "./GridBody";
|
18
|
+
import TableHeader from "./GridHeader";
|
19
|
+
import TableFooter from "./GridFooter";
|
18
20
|
import { useGridVirtualizer } from "../GridVirtualizerContext";
|
19
21
|
function VirtualGridCore(props) {
|
20
22
|
var dense = props.dense, _a = props.rows, rows = _a === void 0 ? [] : _a, _b = props.columns, columns = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, headerBgColor = props.headerBgColor, headerTextColor = props.headerTextColor, footerBgColor = props.footerBgColor, footerTextColor = props.footerTextColor, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
|
21
|
-
var _f = useGridVirtualizer(), tableRef = _f.tableRef, onProcessShadowVisible = _f.onProcessShadowVisible;
|
23
|
+
var _f = useGridVirtualizer(), tableRef = _f.tableRef, getTotalSize = _f.getTotalSize, onProcessShadowVisible = _f.onProcessShadowVisible;
|
22
24
|
return (_jsx(TableContainer, __assign({ ref: tableRef, onScroll: onProcessShadowVisible, sx: {
|
23
25
|
maxHeight: "inherit",
|
24
26
|
borderWidth: "thin",
|
@@ -27,6 +29,6 @@ function VirtualGridCore(props) {
|
|
27
29
|
borderRadius: "4px",
|
28
30
|
borderCollapse: "unset !important",
|
29
31
|
transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
30
|
-
} }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, headerBgColor: headerBgColor, headerTextColor: headerTextColor, noData: rows.length === 0 }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor }), (footers === null || footers === void 0 ? void 0 : footers.length) > 0 ? (_jsx(TableFooter, { footers: footers, footerBgColor: footerBgColor, footerTextColor: footerTextColor, noData: rows.length === 0 })) : (_jsx(_Fragment, {}))] })) })));
|
32
|
+
} }, { children: _jsx(Grid, __assign({ sx: { height: "".concat(getTotalSize(), "px") } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, headerBgColor: headerBgColor, headerTextColor: headerTextColor, noData: rows.length === 0 }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor }), (footers === null || footers === void 0 ? void 0 : footers.length) > 0 ? (_jsx(TableFooter, { footers: footers, footerBgColor: footerBgColor, footerTextColor: footerTextColor, noData: rows.length === 0 })) : (_jsx(_Fragment, {}))] })) })) })));
|
31
33
|
}
|
32
|
-
export default VirtualGridCore;
|
34
|
+
export default memo(VirtualGridCore);
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import { useRef, useState, useEffect, useContext, useCallback, createContext, } from "react";
|
13
|
+
import { useRef, useMemo, useState, useEffect, useContext, useCallback, createContext, } from "react";
|
14
14
|
import { useVirtualizer, elementScroll } from "@tanstack/react-virtual";
|
15
15
|
var PI = 3.1415965359;
|
16
16
|
function easeInOutQuint(t) {
|
@@ -28,7 +28,7 @@ var GridVirtualizerContext = createContext({
|
|
28
28
|
onProcessShadowVisible: function () { },
|
29
29
|
});
|
30
30
|
export function GridVirtualizerContextProvider(props) {
|
31
|
-
var children = props.children, rows = props.rows, columns = props.columns, dense = props.dense;
|
31
|
+
var children = props.children, rows = props.rows, columns = props.columns, dense = props.dense, estimateRowHeight = props.estimateRowHeight;
|
32
32
|
var tableRef = useRef(null);
|
33
33
|
var scrollingRef = useRef();
|
34
34
|
var scrollToFn = useCallback(function (offset, canSmooth, instance) {
|
@@ -53,15 +53,18 @@ export function GridVirtualizerContextProvider(props) {
|
|
53
53
|
};
|
54
54
|
requestAnimationFrame(run);
|
55
55
|
}, []);
|
56
|
+
var measureElementHeight = useMemo(function () {
|
57
|
+
return typeof window !== "undefined" &&
|
58
|
+
navigator.userAgent.indexOf("Firefox") === -1
|
59
|
+
? function (element) { return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height; }
|
60
|
+
: undefined;
|
61
|
+
}, []);
|
56
62
|
var rowVirtualizer = useVirtualizer({
|
57
63
|
count: rows.length,
|
58
64
|
getScrollElement: function () { return tableRef.current; },
|
59
|
-
estimateSize: function () { return (dense ? 48 : 72); },
|
60
|
-
measureElement:
|
61
|
-
|
62
|
-
? function (element) { return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height; }
|
63
|
-
: undefined,
|
64
|
-
overscan: Math.round(rows.length / PI),
|
65
|
+
estimateSize: function () { return estimateRowHeight || (dense ? 48 : 72); },
|
66
|
+
measureElement: measureElementHeight,
|
67
|
+
overscan: Math.round(rows.length / (2 * PI)),
|
65
68
|
scrollToFn: scrollToFn,
|
66
69
|
});
|
67
70
|
var _a = useState(false), leftShadowVisible = _a[0], setLeftShadowVisible = _a[1];
|
package/VirtualGrid/index.js
CHANGED
@@ -27,9 +27,9 @@ import useVirtualGrid from "./useVirtualGrid";
|
|
27
27
|
import VirtualGridCore from "./GridCore";
|
28
28
|
import { GridVirtualizerContextProvider } from "./GridVirtualizerContext";
|
29
29
|
function VirtualGrid(props) {
|
30
|
-
var primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rows = props.rows, columns = props.columns, dense = props.dense, rest = __rest(props, ["primaryColor", "secondaryColor", "rows", "columns", "dense"]);
|
30
|
+
var estimateRowHeight = props.estimateRowHeight, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rows = props.rows, columns = props.columns, dense = props.dense, rest = __rest(props, ["estimateRowHeight", "primaryColor", "secondaryColor", "rows", "columns", "dense"]);
|
31
31
|
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
32
|
-
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(GridVirtualizerContextProvider, __assign({ rows: rows, columns: columns, dense: dense }, { children: _jsx(VirtualGridCore, __assign({}, rest, { rows: rows, columns: columns, dense: dense })) })) })));
|
32
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(GridVirtualizerContextProvider, __assign({ rows: rows, columns: columns, dense: dense, estimateRowHeight: estimateRowHeight }, { children: _jsx(VirtualGridCore, __assign({}, rest, { rows: rows, columns: columns, dense: dense })) })) })));
|
33
33
|
}
|
34
34
|
export default VirtualGrid;
|
35
35
|
export * from "./types";
|
package/VirtualGrid/types.d.ts
CHANGED
@@ -83,6 +83,7 @@ export declare type VirtualGridCoreProps<RowProps extends Record<string, any>, E
|
|
83
83
|
secondaryColor?: CSSProperties["color"];
|
84
84
|
};
|
85
85
|
export declare type VirtualGridProps<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>> = VirtualGridCoreProps<RowProps, ExtendedProps> & {
|
86
|
+
estimateRowHeight?: number;
|
86
87
|
primaryColor?: CSSProperties["color"];
|
87
88
|
secondaryColor?: CSSProperties["color"];
|
88
89
|
};
|
@@ -90,6 +91,7 @@ export interface GridVirtualizerContextProviderProps<RowProps extends Record<str
|
|
90
91
|
dense?: boolean;
|
91
92
|
children: ReactNode;
|
92
93
|
rows: Array<RowProps>;
|
94
|
+
estimateRowHeight?: number;
|
93
95
|
columns: Array<VirtualGridBodyCellProps<RowProps, ExtendedProps>>;
|
94
96
|
}
|
95
97
|
export interface IGridVirtualizerContext {
|
package/package.json
CHANGED
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { VirtualGridBodyRowProps } from "../types";
|
2
|
-
declare function TableBodyRow<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridBodyRowProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
3
|
-
export default TableBodyRow;
|
@@ -1,5 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import type { VirtualGridFooterProps } from "../types";
|
3
|
-
declare function TableFooter<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridFooterProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
4
|
-
declare const _default: import("react").MemoExoticComponent<typeof TableFooter>;
|
5
|
-
export default _default;
|
@@ -1,5 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import type { VirtualGridHeaderProps } from "../types";
|
3
|
-
declare function TableHeader<RowProps extends Record<string, any>, ExtendedProps extends Record<string, any>>(props: VirtualGridHeaderProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
|
4
|
-
declare const _default: import("react").MemoExoticComponent<typeof TableHeader>;
|
5
|
-
export default _default;
|