@symply.io/basic-components 1.6.11-alpha.1 → 1.6.11-alpha.3
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/DataTable/TableBody.js
CHANGED
@@ -27,6 +27,8 @@ import TableCell from "@mui/material/TableCell";
|
|
27
27
|
import TableBodyRow from "./TableBodyRow";
|
28
28
|
function TBody(props) {
|
29
29
|
var rows = props.rows, columns = props.columns, virtualRows = props.virtualRows, _a = props.noDataText, noDataText = _a === void 0 ? "No Data!" : _a, rest = __rest(props, ["rows", "columns", "virtualRows", "noDataText"]);
|
30
|
-
return (_jsx(TableBody, { children: virtualRows.length > 0 ? (virtualRows.map(function (
|
30
|
+
return (_jsx(TableBody, { children: virtualRows.length > 0 ? (virtualRows.map(function (virtualRow) {
|
31
|
+
return (_jsx(TableBodyRow, __assign({ rowIndex: virtualRow.index, virtualRow: virtualRow, rows: rows, columns: columns }, rest), "DataTable_".concat(virtualRow.key || virtualRow.index)));
|
32
|
+
})) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) }));
|
31
33
|
}
|
32
34
|
export default TBody;
|
@@ -16,10 +16,11 @@ 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
|
function TableBodyRow(props) {
|
19
|
-
var
|
19
|
+
var rows = props.rows, columns = props.columns, rowIndex = props.rowIndex, virtualRow = props.virtualRow, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
|
20
20
|
var _a = useState(), rowEl = _a[0], setRowEl = _a[1];
|
21
21
|
var theme = useTheme();
|
22
22
|
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
23
|
+
var row = useMemo(function () { return rows[virtualRow.index]; }, [rows, virtualRow]);
|
23
24
|
var _b = useMemo(function () {
|
24
25
|
if (isUpMd) {
|
25
26
|
var left = columns.filter(function (c) { return c.fixable === "left"; });
|
@@ -44,6 +45,7 @@ function TableBodyRow(props) {
|
|
44
45
|
}, [row, columns, onCustomizeRowBgColor]), normal = _c.normal, hover = _c.hover;
|
45
46
|
return (_jsxs(TableRow, __assign({ sx: {
|
46
47
|
backgroundColor: normal,
|
48
|
+
transform: "translateY(".concat(virtualRow.start - rowIndex * virtualRow.size, "px)"),
|
47
49
|
"&:hover": {
|
48
50
|
cursor: onRowClick ? "pointer" : "default",
|
49
51
|
backgroundColor: onRowClick ? hover : normal,
|
package/DataTable/index.js
CHANGED
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
11
11
|
};
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
13
|
import { useState, useCallback, useRef, useEffect } from "react";
|
14
|
+
import Grid from "@mui/material/Grid";
|
14
15
|
import Table from "@mui/material/Table";
|
15
16
|
import TableContainer from "@mui/material/TableContainer";
|
16
17
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
@@ -27,7 +28,7 @@ function DataTable(props) {
|
|
27
28
|
var rowVirtualizer = useVirtualizer({
|
28
29
|
count: rows.length,
|
29
30
|
getScrollElement: function () { return tableRef.current; },
|
30
|
-
estimateSize: function () { return (dense ? 48 :
|
31
|
+
estimateSize: function () { return (dense ? 48 : 72); },
|
31
32
|
measureElement: typeof window !== "undefined" &&
|
32
33
|
navigator.userAgent.indexOf("Firefox") === -1
|
33
34
|
? function (element) { return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height; }
|
@@ -67,7 +68,7 @@ function DataTable(props) {
|
|
67
68
|
borderRadius: "4px",
|
68
69
|
borderCollapse: "unset !important",
|
69
70
|
transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
70
|
-
} }, { 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, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, virtualRows: virtualRows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), (footers === null || footers === void 0 ? void 0 : footers.length) > 0 ? (_jsx(TableFooter, { footers: footers, footerBgColor: footerBgColor, footerTextColor: footerTextColor, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
|
71
|
+
} }, { children: _jsx(Grid, __assign({ sx: { height: "".concat(rowVirtualizer.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, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, virtualRows: virtualRows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), (footers === null || footers === void 0 ? void 0 : footers.length) > 0 ? (_jsx(TableFooter, { footers: footers, footerBgColor: footerBgColor, footerTextColor: footerTextColor, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })) })));
|
71
72
|
}
|
72
73
|
export default DataTable;
|
73
74
|
export * from "./types";
|
package/DataTable/types.d.ts
CHANGED
@@ -74,8 +74,8 @@ export declare type TableBodyProps<RowProps extends KvProps, ExtendedProps exten
|
|
74
74
|
}) => CustomRowBgColor;
|
75
75
|
};
|
76
76
|
export declare type TableBodyRowProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableBodyProps<RowProps, ExtendedProps>, "noDataText" | "virtualRows"> & {
|
77
|
-
row: RowProps;
|
78
77
|
rowIndex: number;
|
78
|
+
virtualRow: VirtualItem;
|
79
79
|
};
|
80
80
|
export declare type TableFooterProps<RowProps extends KvProps, ExtendedProps extends KvProps> = {
|
81
81
|
footers?: Array<TableFooterCellProps<RowProps, ExtendedProps>>;
|
@@ -85,7 +85,7 @@ export declare type TableFooterProps<RowProps extends KvProps, ExtendedProps ext
|
|
85
85
|
leftShadowVisible?: boolean;
|
86
86
|
rightShadowVisible?: boolean;
|
87
87
|
};
|
88
|
-
export declare type DataTableProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableHeaderProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & Omit<TableBodyProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible"> & Omit<TableFooterProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & {
|
88
|
+
export declare type DataTableProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableHeaderProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & Omit<TableBodyProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "virtualRows"> & Omit<TableFooterProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & {
|
89
89
|
dense?: boolean;
|
90
90
|
primaryColor?: CSSProperties["color"];
|
91
91
|
secondaryColor?: CSSProperties["color"];
|