@etsoo/materialui 1.5.75 → 1.5.76
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/lib/cjs/DataGridEx.js +2 -2
- package/lib/cjs/MobileListItemRenderer.js +6 -1
- package/lib/cjs/ResponsibleContainer.js +2 -2
- package/lib/cjs/ScrollerListEx.js +1 -1
- package/lib/cjs/uses/useGridCacheInitLoad.d.ts +1 -0
- package/lib/cjs/uses/useGridCacheInitLoad.js +5 -1
- package/lib/cjs/uses/useListCacheInitLoad.d.ts +1 -0
- package/lib/cjs/uses/useListCacheInitLoad.js +5 -1
- package/lib/mjs/DataGridEx.js +3 -3
- package/lib/mjs/MobileListItemRenderer.js +6 -1
- package/lib/mjs/ResponsibleContainer.js +2 -2
- package/lib/mjs/ScrollerListEx.js +2 -2
- package/lib/mjs/uses/useGridCacheInitLoad.d.ts +1 -0
- package/lib/mjs/uses/useGridCacheInitLoad.js +4 -1
- package/lib/mjs/uses/useListCacheInitLoad.d.ts +1 -0
- package/lib/mjs/uses/useListCacheInitLoad.js +4 -1
- package/package.json +1 -1
- package/src/DataGridEx.tsx +105 -99
- package/src/MobileListItemRenderer.tsx +8 -1
- package/src/ResponsibleContainer.tsx +4 -0
- package/src/ScrollerListEx.tsx +5 -2
- package/src/uses/useGridCacheInitLoad.ts +7 -1
- package/src/uses/useListCacheInitLoad.ts +7 -1
package/lib/cjs/DataGridEx.js
CHANGED
|
@@ -54,7 +54,7 @@ const doRowItems = (parent, rowIndex, callback) => {
|
|
|
54
54
|
if (parent == null || rowIndex == null)
|
|
55
55
|
return;
|
|
56
56
|
parent
|
|
57
|
-
?.querySelectorAll(`div[
|
|
57
|
+
?.querySelectorAll(`div[role="row"][aria-rowindex="${rowIndex}"]`)
|
|
58
58
|
.forEach((rowItem) => {
|
|
59
59
|
callback(rowItem);
|
|
60
60
|
});
|
|
@@ -254,7 +254,7 @@ function DataGridEx(props) {
|
|
|
254
254
|
// Table
|
|
255
255
|
const table = react_2.default.useMemo(() => {
|
|
256
256
|
return ((0, jsx_runtime_1.jsx)(react_1.ScrollerGrid, { className: shared_1.Utils.mergeClasses("DataGridEx-Body", "DataGridEx-CustomBar", className, createGridStyle(alternatingColors, selectedColor, hoverColor)), onCellsRendered: cacheKey
|
|
257
|
-
? (visibleCells) => sessionStorage.setItem(
|
|
257
|
+
? (visibleCells) => sessionStorage.setItem((0, useGridCacheInitLoad_1.gridCacheKeyGenerator)(cacheKey), JSON.stringify(visibleCells))
|
|
258
258
|
: undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, cellComponent: ({ rowIndex, columnIndex, style, rows, states }) => {
|
|
259
259
|
// Column
|
|
260
260
|
const { align, cellRenderer = DataGridRenderers_1.DataGridRenderers.defaultCellRenderer, cellBoxStyle, field, type, valueFormatter, renderProps } = columns[columnIndex];
|
|
@@ -24,7 +24,12 @@ function MobileListItemRenderer({ data }, renderer, cellSX) {
|
|
|
24
24
|
return (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {});
|
|
25
25
|
// Elements
|
|
26
26
|
const [title, subheader, actions, children, cardActions] = renderer(data);
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(Card_1.default, { sx: {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.default, { sx: {
|
|
28
|
+
height: `calc(100% - 8px)`,
|
|
29
|
+
marginTop: "8px",
|
|
30
|
+
overflow: "auto",
|
|
31
|
+
...cellSX
|
|
32
|
+
}, children: [(0, jsx_runtime_1.jsx)(CardHeader_1.default, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? ((0, jsx_runtime_1.jsx)(MoreFab_1.MoreFab, { iconButton: true, size: "small", anchorOrigin: {
|
|
28
33
|
vertical: "bottom",
|
|
29
34
|
horizontal: "right"
|
|
30
35
|
}, transformOrigin: {
|
|
@@ -126,11 +126,11 @@ function ResponsibleContainer(props) {
|
|
|
126
126
|
if (showDataGrid) {
|
|
127
127
|
// Remove useless props
|
|
128
128
|
const { itemRenderer, ...gridProps } = rest;
|
|
129
|
-
return ((0, jsx_runtime_1.jsx)(Box_1.default, { className: "DataGridBox", children: (0, jsx_runtime_1.jsx)(DataGridEx_1.DataGridEx, { autoLoad: !hasFields, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), columns: columns, rowHeight: getRowHeight(true), ...gridProps }) }));
|
|
129
|
+
return ((0, jsx_runtime_1.jsx)(Box_1.default, { className: "DataGridBox", children: (0, jsx_runtime_1.jsx)(DataGridEx_1.DataGridEx, { autoLoad: !hasFields, cacheKey: cacheKey, cacheMinutes: cacheMinutes, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), columns: columns, rowHeight: getRowHeight(true), ...gridProps }) }));
|
|
130
130
|
}
|
|
131
131
|
// Remove useless props
|
|
132
132
|
const { checkable, borderRowsCount, bottomHeight, footerItemRenderer, headerHeight, hideFooter, hoverColor, selectable, onCellsRendered, ...listProps } = rest;
|
|
133
|
-
return ((0, jsx_runtime_1.jsx)(Box_1.default, { className: "ListBox", sx: { height: heightLocal }, children: (0, jsx_runtime_1.jsx)(ScrollerListEx_1.ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction && react_2.ReactUtils.isSafeClick(event) && quickAction(data), rowHeight: getRowHeight(false), ...listProps }) }));
|
|
133
|
+
return ((0, jsx_runtime_1.jsx)(Box_1.default, { className: "ListBox", sx: { height: heightLocal }, children: (0, jsx_runtime_1.jsx)(ScrollerListEx_1.ScrollerListEx, { autoLoad: !hasFields, cacheKey: cacheKey, cacheMinutes: cacheMinutes, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction && react_2.ReactUtils.isSafeClick(event) && quickAction(data), rowHeight: getRowHeight(false), ...listProps }) }));
|
|
134
134
|
})();
|
|
135
135
|
const searchBar = react_1.default.useMemo(() => {
|
|
136
136
|
if (!hasFields ||
|
|
@@ -82,7 +82,7 @@ function ScrollerListEx(props) {
|
|
|
82
82
|
}, [onUpdateRows, cacheKey]);
|
|
83
83
|
// Layout
|
|
84
84
|
return ((0, jsx_runtime_1.jsx)(react_1.ScrollerList, { className: shared_1.Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, onRowsRendered: cacheKey
|
|
85
|
-
? (visibleRows) => sessionStorage.setItem(
|
|
85
|
+
? (visibleRows) => sessionStorage.setItem((0, useListCacheInitLoad_1.listCacheKeyGenerator)(cacheKey), JSON.stringify(visibleRows))
|
|
86
86
|
: undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, rowComponent: (cellProps) => {
|
|
87
87
|
const { index, style, items } = cellProps;
|
|
88
88
|
const data = items[index];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ScrollerGridProps } from "@etsoo/react";
|
|
2
|
+
export declare function gridCacheKeyGenerator(cacheKey: string): string;
|
|
2
3
|
export declare function useGridCacheInitLoad<T extends object>(cacheKey: string | undefined, cacheMinutes: number): ScrollerGridProps<T>["onInitLoad"];
|
|
@@ -3,11 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.gridCacheKeyGenerator = gridCacheKeyGenerator;
|
|
6
7
|
exports.useGridCacheInitLoad = useGridCacheInitLoad;
|
|
7
8
|
const react_1 = require("@etsoo/react");
|
|
8
9
|
const react_2 = __importDefault(require("react"));
|
|
9
10
|
const GridUtils_1 = require("../GridUtils");
|
|
10
11
|
const shared_1 = require("@etsoo/shared");
|
|
12
|
+
function gridCacheKeyGenerator(cacheKey) {
|
|
13
|
+
return `${cacheKey}-grid-scroll`;
|
|
14
|
+
}
|
|
11
15
|
function useGridCacheInitLoad(cacheKey, cacheMinutes) {
|
|
12
16
|
// Reference
|
|
13
17
|
const ref = react_2.default.useRef(null);
|
|
@@ -25,7 +29,7 @@ function useGridCacheInitLoad(cacheKey, cacheMinutes) {
|
|
|
25
29
|
ref.current = true;
|
|
26
30
|
return (ref) => {
|
|
27
31
|
// Scroll position
|
|
28
|
-
const scrollData = sessionStorage.getItem(
|
|
32
|
+
const scrollData = sessionStorage.getItem(gridCacheKeyGenerator(cacheKey));
|
|
29
33
|
if (scrollData) {
|
|
30
34
|
const data = JSON.parse(scrollData);
|
|
31
35
|
shared_1.ExtendUtils.waitFor(() => ref.scrollToCell({
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ScrollerListProps } from "@etsoo/react";
|
|
2
|
+
export declare function listCacheKeyGenerator(cacheKey: string): string;
|
|
2
3
|
export declare function useListCacheInitLoad<T extends object>(cacheKey: string | undefined, cacheMinutes: number): ScrollerListProps<T>["onInitLoad"];
|
|
@@ -3,11 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listCacheKeyGenerator = listCacheKeyGenerator;
|
|
6
7
|
exports.useListCacheInitLoad = useListCacheInitLoad;
|
|
7
8
|
const react_1 = require("@etsoo/react");
|
|
8
9
|
const react_2 = __importDefault(require("react"));
|
|
9
10
|
const GridUtils_1 = require("../GridUtils");
|
|
10
11
|
const shared_1 = require("@etsoo/shared");
|
|
12
|
+
function listCacheKeyGenerator(cacheKey) {
|
|
13
|
+
return `${cacheKey}-list-scroll`;
|
|
14
|
+
}
|
|
11
15
|
function useListCacheInitLoad(cacheKey, cacheMinutes) {
|
|
12
16
|
// Reference
|
|
13
17
|
const ref = react_2.default.useRef(null);
|
|
@@ -25,7 +29,7 @@ function useListCacheInitLoad(cacheKey, cacheMinutes) {
|
|
|
25
29
|
ref.current = true;
|
|
26
30
|
return (ref) => {
|
|
27
31
|
// Scroll position
|
|
28
|
-
const scrollData = sessionStorage.getItem(
|
|
32
|
+
const scrollData = sessionStorage.getItem(listCacheKeyGenerator(cacheKey));
|
|
29
33
|
if (scrollData) {
|
|
30
34
|
const data = JSON.parse(scrollData);
|
|
31
35
|
shared_1.ExtendUtils.waitFor(() => ref.scrollToRow({ index: data.startIndex }), 100);
|
package/lib/mjs/DataGridEx.js
CHANGED
|
@@ -10,7 +10,7 @@ import TableSortLabel from "@mui/material/TableSortLabel";
|
|
|
10
10
|
import Checkbox from "@mui/material/Checkbox";
|
|
11
11
|
import Paper from "@mui/material/Paper";
|
|
12
12
|
import { GridUtils } from "./GridUtils";
|
|
13
|
-
import { useGridCacheInitLoad } from "./uses/useGridCacheInitLoad";
|
|
13
|
+
import { gridCacheKeyGenerator, useGridCacheInitLoad } from "./uses/useGridCacheInitLoad";
|
|
14
14
|
// Borders
|
|
15
15
|
const boldBorder = "2px solid rgba(224, 224, 224, 1)";
|
|
16
16
|
const thinBorder = "1px solid rgba(224, 224, 224, 1)";
|
|
@@ -47,7 +47,7 @@ const doRowItems = (parent, rowIndex, callback) => {
|
|
|
47
47
|
if (parent == null || rowIndex == null)
|
|
48
48
|
return;
|
|
49
49
|
parent
|
|
50
|
-
?.querySelectorAll(`div[
|
|
50
|
+
?.querySelectorAll(`div[role="row"][aria-rowindex="${rowIndex}"]`)
|
|
51
51
|
.forEach((rowItem) => {
|
|
52
52
|
callback(rowItem);
|
|
53
53
|
});
|
|
@@ -247,7 +247,7 @@ export function DataGridEx(props) {
|
|
|
247
247
|
// Table
|
|
248
248
|
const table = React.useMemo(() => {
|
|
249
249
|
return (_jsx(ScrollerGrid, { className: Utils.mergeClasses("DataGridEx-Body", "DataGridEx-CustomBar", className, createGridStyle(alternatingColors, selectedColor, hoverColor)), onCellsRendered: cacheKey
|
|
250
|
-
? (visibleCells) => sessionStorage.setItem(
|
|
250
|
+
? (visibleCells) => sessionStorage.setItem(gridCacheKeyGenerator(cacheKey), JSON.stringify(visibleCells))
|
|
251
251
|
: undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, cellComponent: ({ rowIndex, columnIndex, style, rows, states }) => {
|
|
252
252
|
// Column
|
|
253
253
|
const { align, cellRenderer = DataGridRenderers.defaultCellRenderer, cellBoxStyle, field, type, valueFormatter, renderProps } = columns[columnIndex];
|
|
@@ -18,7 +18,12 @@ export function MobileListItemRenderer({ data }, renderer, cellSX) {
|
|
|
18
18
|
return _jsx(LinearProgress, {});
|
|
19
19
|
// Elements
|
|
20
20
|
const [title, subheader, actions, children, cardActions] = renderer(data);
|
|
21
|
-
return (_jsxs(Card, { sx: {
|
|
21
|
+
return (_jsxs(Card, { sx: {
|
|
22
|
+
height: `calc(100% - 8px)`,
|
|
23
|
+
marginTop: "8px",
|
|
24
|
+
overflow: "auto",
|
|
25
|
+
...cellSX
|
|
26
|
+
}, children: [_jsx(CardHeader, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? (_jsx(MoreFab, { iconButton: true, size: "small", anchorOrigin: {
|
|
22
27
|
vertical: "bottom",
|
|
23
28
|
horizontal: "right"
|
|
24
29
|
}, transformOrigin: {
|
|
@@ -120,11 +120,11 @@ export function ResponsibleContainer(props) {
|
|
|
120
120
|
if (showDataGrid) {
|
|
121
121
|
// Remove useless props
|
|
122
122
|
const { itemRenderer, ...gridProps } = rest;
|
|
123
|
-
return (_jsx(Box, { className: "DataGridBox", children: _jsx(DataGridEx, { autoLoad: !hasFields, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), columns: columns, rowHeight: getRowHeight(true), ...gridProps }) }));
|
|
123
|
+
return (_jsx(Box, { className: "DataGridBox", children: _jsx(DataGridEx, { autoLoad: !hasFields, cacheKey: cacheKey, cacheMinutes: cacheMinutes, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), columns: columns, rowHeight: getRowHeight(true), ...gridProps }) }));
|
|
124
124
|
}
|
|
125
125
|
// Remove useless props
|
|
126
126
|
const { checkable, borderRowsCount, bottomHeight, footerItemRenderer, headerHeight, hideFooter, hoverColor, selectable, onCellsRendered, ...listProps } = rest;
|
|
127
|
-
return (_jsx(Box, { className: "ListBox", sx: { height: heightLocal }, children: _jsx(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction && ReactUtils.isSafeClick(event) && quickAction(data), rowHeight: getRowHeight(false), ...listProps }) }));
|
|
127
|
+
return (_jsx(Box, { className: "ListBox", sx: { height: heightLocal }, children: _jsx(ScrollerListEx, { autoLoad: !hasFields, cacheKey: cacheKey, cacheMinutes: cacheMinutes, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction && ReactUtils.isSafeClick(event) && quickAction(data), rowHeight: getRowHeight(false), ...listProps }) }));
|
|
128
128
|
})();
|
|
129
129
|
const searchBar = React.useMemo(() => {
|
|
130
130
|
if (!hasFields ||
|
|
@@ -4,7 +4,7 @@ import { ScrollerList } from "@etsoo/react";
|
|
|
4
4
|
import { Utils } from "@etsoo/shared";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { GridUtils } from "./GridUtils";
|
|
7
|
-
import { useListCacheInitLoad } from "./uses/useListCacheInitLoad";
|
|
7
|
+
import { listCacheKeyGenerator, useListCacheInitLoad } from "./uses/useListCacheInitLoad";
|
|
8
8
|
import Box from "@mui/material/Box";
|
|
9
9
|
// Scroll bar size
|
|
10
10
|
const scrollbarSize = 16;
|
|
@@ -76,7 +76,7 @@ export function ScrollerListEx(props) {
|
|
|
76
76
|
}, [onUpdateRows, cacheKey]);
|
|
77
77
|
// Layout
|
|
78
78
|
return (_jsx(ScrollerList, { className: Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, onRowsRendered: cacheKey
|
|
79
|
-
? (visibleRows) => sessionStorage.setItem(
|
|
79
|
+
? (visibleRows) => sessionStorage.setItem(listCacheKeyGenerator(cacheKey), JSON.stringify(visibleRows))
|
|
80
80
|
: undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, rowComponent: (cellProps) => {
|
|
81
81
|
const { index, style, items } = cellProps;
|
|
82
82
|
const data = items[index];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ScrollerGridProps } from "@etsoo/react";
|
|
2
|
+
export declare function gridCacheKeyGenerator(cacheKey: string): string;
|
|
2
3
|
export declare function useGridCacheInitLoad<T extends object>(cacheKey: string | undefined, cacheMinutes: number): ScrollerGridProps<T>["onInitLoad"];
|
|
@@ -2,6 +2,9 @@ import { useSearchParamsWithCache } from "@etsoo/react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { GridUtils } from "../GridUtils";
|
|
4
4
|
import { ExtendUtils } from "@etsoo/shared";
|
|
5
|
+
export function gridCacheKeyGenerator(cacheKey) {
|
|
6
|
+
return `${cacheKey}-grid-scroll`;
|
|
7
|
+
}
|
|
5
8
|
export function useGridCacheInitLoad(cacheKey, cacheMinutes) {
|
|
6
9
|
// Reference
|
|
7
10
|
const ref = React.useRef(null);
|
|
@@ -19,7 +22,7 @@ export function useGridCacheInitLoad(cacheKey, cacheMinutes) {
|
|
|
19
22
|
ref.current = true;
|
|
20
23
|
return (ref) => {
|
|
21
24
|
// Scroll position
|
|
22
|
-
const scrollData = sessionStorage.getItem(
|
|
25
|
+
const scrollData = sessionStorage.getItem(gridCacheKeyGenerator(cacheKey));
|
|
23
26
|
if (scrollData) {
|
|
24
27
|
const data = JSON.parse(scrollData);
|
|
25
28
|
ExtendUtils.waitFor(() => ref.scrollToCell({
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ScrollerListProps } from "@etsoo/react";
|
|
2
|
+
export declare function listCacheKeyGenerator(cacheKey: string): string;
|
|
2
3
|
export declare function useListCacheInitLoad<T extends object>(cacheKey: string | undefined, cacheMinutes: number): ScrollerListProps<T>["onInitLoad"];
|
|
@@ -2,6 +2,9 @@ import { useSearchParamsWithCache } from "@etsoo/react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { GridUtils } from "../GridUtils";
|
|
4
4
|
import { ExtendUtils } from "@etsoo/shared";
|
|
5
|
+
export function listCacheKeyGenerator(cacheKey) {
|
|
6
|
+
return `${cacheKey}-list-scroll`;
|
|
7
|
+
}
|
|
5
8
|
export function useListCacheInitLoad(cacheKey, cacheMinutes) {
|
|
6
9
|
// Reference
|
|
7
10
|
const ref = React.useRef(null);
|
|
@@ -19,7 +22,7 @@ export function useListCacheInitLoad(cacheKey, cacheMinutes) {
|
|
|
19
22
|
ref.current = true;
|
|
20
23
|
return (ref) => {
|
|
21
24
|
// Scroll position
|
|
22
|
-
const scrollData = sessionStorage.getItem(
|
|
25
|
+
const scrollData = sessionStorage.getItem(listCacheKeyGenerator(cacheKey));
|
|
23
26
|
if (scrollData) {
|
|
24
27
|
const data = JSON.parse(scrollData);
|
|
25
28
|
ExtendUtils.waitFor(() => ref.scrollToRow({ index: data.startIndex }), 100);
|
package/package.json
CHANGED
package/src/DataGridEx.tsx
CHANGED
|
@@ -24,7 +24,10 @@ import TableSortLabel from "@mui/material/TableSortLabel";
|
|
|
24
24
|
import Checkbox from "@mui/material/Checkbox";
|
|
25
25
|
import Paper from "@mui/material/Paper";
|
|
26
26
|
import { GridUtils } from "./GridUtils";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
gridCacheKeyGenerator,
|
|
29
|
+
useGridCacheInitLoad
|
|
30
|
+
} from "./uses/useGridCacheInitLoad";
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* Footer item renderer props
|
|
@@ -53,102 +56,103 @@ export type DataGridExProps<
|
|
|
53
56
|
| "onInitLoad"
|
|
54
57
|
| "rowHeight"
|
|
55
58
|
| "width"
|
|
56
|
-
> &
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
59
|
+
> &
|
|
60
|
+
Partial<Pick<ScrollerGridProps<T, P>, "rowHeight">> & {
|
|
61
|
+
/**
|
|
62
|
+
* Alternating colors for odd/even rows
|
|
63
|
+
*/
|
|
64
|
+
alternatingColors?: [string?, string?];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Cache key
|
|
68
|
+
*/
|
|
69
|
+
cacheKey?: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Cache minutes
|
|
73
|
+
*/
|
|
74
|
+
cacheMinutes?: number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Checkable to choose multiple items
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
checkable?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Rows count to have the bottom border
|
|
84
|
+
*/
|
|
85
|
+
borderRowsCount?: number;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Bottom height
|
|
89
|
+
*/
|
|
90
|
+
bottomHeight?: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Columns
|
|
94
|
+
*/
|
|
95
|
+
columns: GridColumn<T>[];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Footer item renderer
|
|
99
|
+
*/
|
|
100
|
+
footerItemRenderer?: (
|
|
101
|
+
rows: T[],
|
|
102
|
+
props: DataGridExFooterItemRendererProps<T>
|
|
103
|
+
) => React.ReactNode;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Header height
|
|
107
|
+
* @default 56
|
|
108
|
+
*/
|
|
109
|
+
headerHeight?: number;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Hide the footer
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
hideFooter?: boolean;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Hover color
|
|
119
|
+
*/
|
|
120
|
+
hoverColor?: string;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Double click handler
|
|
124
|
+
*/
|
|
125
|
+
onDoubleClick?: MouseEventWithDataHandler<T>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Click handler
|
|
129
|
+
*/
|
|
130
|
+
onClick?: MouseEventWithDataHandler<T>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Data change handler
|
|
134
|
+
* @param rows Rows
|
|
135
|
+
* @param rowIndex Row index
|
|
136
|
+
* @param columnIndex Column index
|
|
137
|
+
*/
|
|
138
|
+
onDataChange?: (rows: T[], rowIndex: number, columnIndex: number) => void;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Selectable to support hover over and out effect and row clickable
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
selectable?: boolean;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Selected color
|
|
148
|
+
*/
|
|
149
|
+
selectedColor?: string;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Width
|
|
153
|
+
*/
|
|
154
|
+
width?: number;
|
|
155
|
+
};
|
|
152
156
|
|
|
153
157
|
// Borders
|
|
154
158
|
const boldBorder = "2px solid rgba(224, 224, 224, 1)";
|
|
@@ -201,7 +205,9 @@ const doRowItems = (
|
|
|
201
205
|
if (parent == null || rowIndex == null) return;
|
|
202
206
|
|
|
203
207
|
parent
|
|
204
|
-
?.querySelectorAll<HTMLDivElement>(
|
|
208
|
+
?.querySelectorAll<HTMLDivElement>(
|
|
209
|
+
`div[role="row"][aria-rowindex="${rowIndex}"]`
|
|
210
|
+
)
|
|
205
211
|
.forEach((rowItem) => {
|
|
206
212
|
callback(rowItem);
|
|
207
213
|
});
|
|
@@ -575,7 +581,7 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
|
|
|
575
581
|
cacheKey
|
|
576
582
|
? (visibleCells) =>
|
|
577
583
|
sessionStorage.setItem(
|
|
578
|
-
|
|
584
|
+
gridCacheKeyGenerator(cacheKey),
|
|
579
585
|
JSON.stringify(visibleCells)
|
|
580
586
|
)
|
|
581
587
|
: undefined
|
|
@@ -36,7 +36,14 @@ export function MobileListItemRenderer<T>(
|
|
|
36
36
|
const [title, subheader, actions, children, cardActions] = renderer(data);
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
|
-
<Card
|
|
39
|
+
<Card
|
|
40
|
+
sx={{
|
|
41
|
+
height: `calc(100% - 8px)`,
|
|
42
|
+
marginTop: "8px",
|
|
43
|
+
overflow: "auto",
|
|
44
|
+
...cellSX
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
40
47
|
<CardHeader
|
|
41
48
|
sx={{ paddingBottom: 0.5 }}
|
|
42
49
|
action={
|
|
@@ -324,6 +324,8 @@ export function ResponsibleContainer<T extends object, F>(
|
|
|
324
324
|
<Box className="DataGridBox">
|
|
325
325
|
<DataGridEx<T>
|
|
326
326
|
autoLoad={!hasFields}
|
|
327
|
+
cacheKey={cacheKey}
|
|
328
|
+
cacheMinutes={cacheMinutes}
|
|
327
329
|
height={heightLocal}
|
|
328
330
|
width={rect.width}
|
|
329
331
|
loadData={localLoadData}
|
|
@@ -355,6 +357,8 @@ export function ResponsibleContainer<T extends object, F>(
|
|
|
355
357
|
<Box className="ListBox" sx={{ height: heightLocal }}>
|
|
356
358
|
<ScrollerListEx<T>
|
|
357
359
|
autoLoad={!hasFields}
|
|
360
|
+
cacheKey={cacheKey}
|
|
361
|
+
cacheMinutes={cacheMinutes}
|
|
358
362
|
height={heightLocal}
|
|
359
363
|
loadData={localLoadData}
|
|
360
364
|
mRef={mRefs}
|
package/src/ScrollerListEx.tsx
CHANGED
|
@@ -8,7 +8,10 @@ import { DataTypes, Utils } from "@etsoo/shared";
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
import { MouseEventWithDataHandler } from "./MUGlobal";
|
|
10
10
|
import { GridUtils } from "./GridUtils";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
listCacheKeyGenerator,
|
|
13
|
+
useListCacheInitLoad
|
|
14
|
+
} from "./uses/useListCacheInitLoad";
|
|
12
15
|
import Box from "@mui/material/Box";
|
|
13
16
|
|
|
14
17
|
// Scroll bar size
|
|
@@ -207,7 +210,7 @@ export function ScrollerListEx<T extends object>(
|
|
|
207
210
|
cacheKey
|
|
208
211
|
? (visibleRows) =>
|
|
209
212
|
sessionStorage.setItem(
|
|
210
|
-
|
|
213
|
+
listCacheKeyGenerator(cacheKey),
|
|
211
214
|
JSON.stringify(visibleRows)
|
|
212
215
|
)
|
|
213
216
|
: undefined
|
|
@@ -8,6 +8,10 @@ import React from "react";
|
|
|
8
8
|
import { GridUtils } from "../GridUtils";
|
|
9
9
|
import { ExtendUtils } from "@etsoo/shared";
|
|
10
10
|
|
|
11
|
+
export function gridCacheKeyGenerator(cacheKey: string) {
|
|
12
|
+
return `${cacheKey}-grid-scroll`;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
export function useGridCacheInitLoad<T extends object>(
|
|
12
16
|
cacheKey: string | undefined,
|
|
13
17
|
cacheMinutes: number
|
|
@@ -33,7 +37,9 @@ export function useGridCacheInitLoad<T extends object>(
|
|
|
33
37
|
|
|
34
38
|
return (ref: GridImperativeAPI) => {
|
|
35
39
|
// Scroll position
|
|
36
|
-
const scrollData = sessionStorage.getItem(
|
|
40
|
+
const scrollData = sessionStorage.getItem(
|
|
41
|
+
gridCacheKeyGenerator(cacheKey)
|
|
42
|
+
);
|
|
37
43
|
if (scrollData) {
|
|
38
44
|
const data = JSON.parse(scrollData) as OnCellsRenderedData;
|
|
39
45
|
ExtendUtils.waitFor(
|
|
@@ -8,6 +8,10 @@ import React from "react";
|
|
|
8
8
|
import { GridUtils } from "../GridUtils";
|
|
9
9
|
import { ExtendUtils } from "@etsoo/shared";
|
|
10
10
|
|
|
11
|
+
export function listCacheKeyGenerator(cacheKey: string) {
|
|
12
|
+
return `${cacheKey}-list-scroll`;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
export function useListCacheInitLoad<T extends object>(
|
|
12
16
|
cacheKey: string | undefined,
|
|
13
17
|
cacheMinutes: number
|
|
@@ -33,7 +37,9 @@ export function useListCacheInitLoad<T extends object>(
|
|
|
33
37
|
|
|
34
38
|
return (ref: ListImperativeAPI) => {
|
|
35
39
|
// Scroll position
|
|
36
|
-
const scrollData = sessionStorage.getItem(
|
|
40
|
+
const scrollData = sessionStorage.getItem(
|
|
41
|
+
listCacheKeyGenerator(cacheKey)
|
|
42
|
+
);
|
|
37
43
|
if (scrollData) {
|
|
38
44
|
const data = JSON.parse(scrollData) as OnRowsRenderedData;
|
|
39
45
|
ExtendUtils.waitFor(
|