@etsoo/materialui 1.5.75 → 1.5.77

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.
@@ -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[data-row="${rowIndex}"]`)
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(`${cacheKey}-scroll`, JSON.stringify(visibleCells))
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];
@@ -10,6 +10,7 @@ const LinearProgress_1 = __importDefault(require("@mui/material/LinearProgress")
10
10
  const Card_1 = __importDefault(require("@mui/material/Card"));
11
11
  const CardHeader_1 = __importDefault(require("@mui/material/CardHeader"));
12
12
  const CardContent_1 = __importDefault(require("@mui/material/CardContent"));
13
+ const ScrollerListEx_1 = require("./ScrollerListEx");
13
14
  /**
14
15
  * Default mobile list item renderer
15
16
  * @param param0 List renderer props
@@ -24,7 +25,10 @@ function MobileListItemRenderer({ data }, renderer, cellSX) {
24
25
  return (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {});
25
26
  // Elements
26
27
  const [title, subheader, actions, children, cardActions] = renderer(data);
27
- return ((0, jsx_runtime_1.jsxs)(Card_1.default, { sx: { height: "100%", overflow: "auto", ...cellSX }, 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
+ return ((0, jsx_runtime_1.jsxs)(Card_1.default, { sx: {
29
+ ...ScrollerListEx_1.ScrollerListExItemDefaultStyles,
30
+ ...cellSX
31
+ }, 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
32
  vertical: "bottom",
29
33
  horizontal: "right"
30
34
  }, 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 ||
@@ -22,6 +22,10 @@ export type ScrollerListExItemRendererProps<T> = {
22
22
  */
23
23
  selected: boolean;
24
24
  };
25
+ /**
26
+ * Default styles for item renderer
27
+ */
28
+ export declare const ScrollerListExItemDefaultStyles: React.CSSProperties;
25
29
  /**
26
30
  * Extended ScrollerList Props
27
31
  */
@@ -3,6 +3,7 @@ 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.ScrollerListExItemDefaultStyles = void 0;
6
7
  exports.ScrollerListEx = ScrollerListEx;
7
8
  const jsx_runtime_1 = require("react/jsx-runtime");
8
9
  const css_1 = require("@emotion/css");
@@ -46,6 +47,15 @@ const createGridStyle = (alternatingColors, selectedColor) => {
46
47
  }
47
48
  });
48
49
  };
50
+ /**
51
+ * Default styles for item renderer
52
+ */
53
+ exports.ScrollerListExItemDefaultStyles = {
54
+ height: `calc(100% - 16px)`,
55
+ marginTop: "8px",
56
+ marginBottom: "8px",
57
+ overflow: "auto"
58
+ };
49
59
  /**
50
60
  * Extended ScrollerList
51
61
  * @param props Props
@@ -73,7 +83,7 @@ function ScrollerListEx(props) {
73
83
  return selected;
74
84
  };
75
85
  // Destruct
76
- const { alternatingColors = [undefined, undefined], className, cacheKey, cacheMinutes = 15, idField = "id", itemRenderer = ({ data }) => ((0, jsx_runtime_1.jsx)(Box_1.default, { component: "pre", sx: { height: "100%", overflow: "auto" }, children: JSON.stringify(data) })), onClick, onDoubleClick, onUpdateRows, onSelectChange, rowHeight = 116, selectedColor = "#edf4fb", ...rest } = props;
86
+ const { alternatingColors = [undefined, undefined], className, cacheKey, cacheMinutes = 15, idField = "id", itemRenderer = ({ data }) => ((0, jsx_runtime_1.jsx)(Box_1.default, { component: "pre", sx: exports.ScrollerListExItemDefaultStyles, children: JSON.stringify(data) })), onClick, onDoubleClick, onUpdateRows, onSelectChange, rowHeight = 142, selectedColor = "#edf4fb", ...rest } = props;
77
87
  // Init handler
78
88
  const initHandler = (0, useListCacheInitLoad_1.useListCacheInitLoad)(cacheKey, cacheMinutes);
79
89
  const onUpdateRowsHandler = react_2.default.useCallback((rows, state) => {
@@ -82,7 +92,7 @@ function ScrollerListEx(props) {
82
92
  }, [onUpdateRows, cacheKey]);
83
93
  // Layout
84
94
  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(`${cacheKey}-scroll`, JSON.stringify(visibleRows))
95
+ ? (visibleRows) => sessionStorage.setItem((0, useListCacheInitLoad_1.listCacheKeyGenerator)(cacheKey), JSON.stringify(visibleRows))
86
96
  : undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, rowComponent: (cellProps) => {
87
97
  const { index, style, items } = cellProps;
88
98
  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(`${cacheKey}-scroll`);
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(`${cacheKey}-scroll`);
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);
@@ -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[data-row="${rowIndex}"]`)
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(`${cacheKey}-scroll`, JSON.stringify(visibleCells))
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];
@@ -4,6 +4,7 @@ import LinearProgress from "@mui/material/LinearProgress";
4
4
  import Card from "@mui/material/Card";
5
5
  import CardHeader from "@mui/material/CardHeader";
6
6
  import CardContent from "@mui/material/CardContent";
7
+ import { ScrollerListExItemDefaultStyles } from "./ScrollerListEx";
7
8
  /**
8
9
  * Default mobile list item renderer
9
10
  * @param param0 List renderer props
@@ -18,7 +19,10 @@ export function MobileListItemRenderer({ data }, renderer, cellSX) {
18
19
  return _jsx(LinearProgress, {});
19
20
  // Elements
20
21
  const [title, subheader, actions, children, cardActions] = renderer(data);
21
- return (_jsxs(Card, { sx: { height: "100%", overflow: "auto", ...cellSX }, children: [_jsx(CardHeader, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? (_jsx(MoreFab, { iconButton: true, size: "small", anchorOrigin: {
22
+ return (_jsxs(Card, { sx: {
23
+ ...ScrollerListExItemDefaultStyles,
24
+ ...cellSX
25
+ }, children: [_jsx(CardHeader, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? (_jsx(MoreFab, { iconButton: true, size: "small", anchorOrigin: {
22
26
  vertical: "bottom",
23
27
  horizontal: "right"
24
28
  }, 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 ||
@@ -22,6 +22,10 @@ export type ScrollerListExItemRendererProps<T> = {
22
22
  */
23
23
  selected: boolean;
24
24
  };
25
+ /**
26
+ * Default styles for item renderer
27
+ */
28
+ export declare const ScrollerListExItemDefaultStyles: React.CSSProperties;
25
29
  /**
26
30
  * Extended ScrollerList Props
27
31
  */
@@ -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;
@@ -40,6 +40,15 @@ const createGridStyle = (alternatingColors, selectedColor) => {
40
40
  }
41
41
  });
42
42
  };
43
+ /**
44
+ * Default styles for item renderer
45
+ */
46
+ export const ScrollerListExItemDefaultStyles = {
47
+ height: `calc(100% - 16px)`,
48
+ marginTop: "8px",
49
+ marginBottom: "8px",
50
+ overflow: "auto"
51
+ };
43
52
  /**
44
53
  * Extended ScrollerList
45
54
  * @param props Props
@@ -67,7 +76,7 @@ export function ScrollerListEx(props) {
67
76
  return selected;
68
77
  };
69
78
  // Destruct
70
- const { alternatingColors = [undefined, undefined], className, cacheKey, cacheMinutes = 15, idField = "id", itemRenderer = ({ data }) => (_jsx(Box, { component: "pre", sx: { height: "100%", overflow: "auto" }, children: JSON.stringify(data) })), onClick, onDoubleClick, onUpdateRows, onSelectChange, rowHeight = 116, selectedColor = "#edf4fb", ...rest } = props;
79
+ const { alternatingColors = [undefined, undefined], className, cacheKey, cacheMinutes = 15, idField = "id", itemRenderer = ({ data }) => (_jsx(Box, { component: "pre", sx: ScrollerListExItemDefaultStyles, children: JSON.stringify(data) })), onClick, onDoubleClick, onUpdateRows, onSelectChange, rowHeight = 142, selectedColor = "#edf4fb", ...rest } = props;
71
80
  // Init handler
72
81
  const initHandler = useListCacheInitLoad(cacheKey, cacheMinutes);
73
82
  const onUpdateRowsHandler = React.useCallback((rows, state) => {
@@ -76,7 +85,7 @@ export function ScrollerListEx(props) {
76
85
  }, [onUpdateRows, cacheKey]);
77
86
  // Layout
78
87
  return (_jsx(ScrollerList, { className: Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, onRowsRendered: cacheKey
79
- ? (visibleRows) => sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(visibleRows))
88
+ ? (visibleRows) => sessionStorage.setItem(listCacheKeyGenerator(cacheKey), JSON.stringify(visibleRows))
80
89
  : undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, rowComponent: (cellProps) => {
81
90
  const { index, style, items } = cellProps;
82
91
  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(`${cacheKey}-scroll`);
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(`${cacheKey}-scroll`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.75",
3
+ "version": "1.5.77",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -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 { useGridCacheInitLoad } from "./uses/useGridCacheInitLoad";
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
- > & Partial<Pick<ScrollerGridProps<T, P>, "rowHeight">> & {
57
- /**
58
- * Alternating colors for odd/even rows
59
- */
60
- alternatingColors?: [string?, string?];
61
-
62
- /**
63
- * Cache key
64
- */
65
- cacheKey?: string;
66
-
67
- /**
68
- * Cache minutes
69
- */
70
- cacheMinutes?: number;
71
-
72
- /**
73
- * Checkable to choose multiple items
74
- * @default false
75
- */
76
- checkable?: boolean;
77
-
78
- /**
79
- * Rows count to have the bottom border
80
- */
81
- borderRowsCount?: number;
82
-
83
- /**
84
- * Bottom height
85
- */
86
- bottomHeight?: number;
87
-
88
- /**
89
- * Columns
90
- */
91
- columns: GridColumn<T>[];
92
-
93
- /**
94
- * Footer item renderer
95
- */
96
- footerItemRenderer?: (
97
- rows: T[],
98
- props: DataGridExFooterItemRendererProps<T>
99
- ) => React.ReactNode;
100
-
101
- /**
102
- * Header height
103
- * @default 56
104
- */
105
- headerHeight?: number;
106
-
107
- /**
108
- * Hide the footer
109
- * @default false
110
- */
111
- hideFooter?: boolean;
112
-
113
- /**
114
- * Hover color
115
- */
116
- hoverColor?: string;
117
-
118
- /**
119
- * Double click handler
120
- */
121
- onDoubleClick?: MouseEventWithDataHandler<T>;
122
-
123
- /**
124
- * Click handler
125
- */
126
- onClick?: MouseEventWithDataHandler<T>;
127
-
128
- /**
129
- * Data change handler
130
- * @param rows Rows
131
- * @param rowIndex Row index
132
- * @param columnIndex Column index
133
- */
134
- onDataChange?: (rows: T[], rowIndex: number, columnIndex: number) => void;
135
-
136
- /**
137
- * Selectable to support hover over and out effect and row clickable
138
- * @default true
139
- */
140
- selectable?: boolean;
141
-
142
- /**
143
- * Selected color
144
- */
145
- selectedColor?: string;
146
-
147
- /**
148
- * Width
149
- */
150
- width?: number;
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>(`div[data-row="${rowIndex}"]`)
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
- `${cacheKey}-scroll`,
584
+ gridCacheKeyGenerator(cacheKey),
579
585
  JSON.stringify(visibleCells)
580
586
  )
581
587
  : undefined
@@ -5,7 +5,10 @@ import LinearProgress from "@mui/material/LinearProgress";
5
5
  import Card from "@mui/material/Card";
6
6
  import CardHeader from "@mui/material/CardHeader";
7
7
  import CardContent from "@mui/material/CardContent";
8
- import { ScrollerListExItemRendererProps } from "./ScrollerListEx";
8
+ import {
9
+ ScrollerListExItemDefaultStyles,
10
+ ScrollerListExItemRendererProps
11
+ } from "./ScrollerListEx";
9
12
  import { SxProps, Theme } from "@mui/material/styles";
10
13
 
11
14
  /**
@@ -36,7 +39,12 @@ export function MobileListItemRenderer<T>(
36
39
  const [title, subheader, actions, children, cardActions] = renderer(data);
37
40
 
38
41
  return (
39
- <Card sx={{ height: "100%", overflow: "auto", ...cellSX }}>
42
+ <Card
43
+ sx={{
44
+ ...ScrollerListExItemDefaultStyles,
45
+ ...cellSX
46
+ }}
47
+ >
40
48
  <CardHeader
41
49
  sx={{ paddingBottom: 0.5 }}
42
50
  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}
@@ -8,8 +8,12 @@ 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 { useListCacheInitLoad } from "./uses/useListCacheInitLoad";
11
+ import {
12
+ listCacheKeyGenerator,
13
+ useListCacheInitLoad
14
+ } from "./uses/useListCacheInitLoad";
12
15
  import Box from "@mui/material/Box";
16
+ import { SxProps, Theme } from "@mui/material/styles";
13
17
 
14
18
  // Scroll bar size
15
19
  const scrollbarSize = 16;
@@ -76,6 +80,16 @@ export type ScrollerListExItemRendererProps<T> = {
76
80
  selected: boolean;
77
81
  };
78
82
 
83
+ /**
84
+ * Default styles for item renderer
85
+ */
86
+ export const ScrollerListExItemDefaultStyles: React.CSSProperties = {
87
+ height: `calc(100% - 16px)`,
88
+ marginTop: "8px",
89
+ marginBottom: "8px",
90
+ overflow: "auto"
91
+ };
92
+
79
93
  /**
80
94
  * Extended ScrollerList Props
81
95
  */
@@ -170,7 +184,7 @@ export function ScrollerListEx<T extends object>(
170
184
  cacheMinutes = 15,
171
185
  idField = "id" as DataTypes.Keys<T>,
172
186
  itemRenderer = ({ data }) => (
173
- <Box component="pre" sx={{ height: "100%", overflow: "auto" }}>
187
+ <Box component="pre" sx={ScrollerListExItemDefaultStyles}>
174
188
  {JSON.stringify(data)}
175
189
  </Box>
176
190
  ),
@@ -178,7 +192,7 @@ export function ScrollerListEx<T extends object>(
178
192
  onDoubleClick,
179
193
  onUpdateRows,
180
194
  onSelectChange,
181
- rowHeight = 116,
195
+ rowHeight = 142,
182
196
  selectedColor = "#edf4fb",
183
197
  ...rest
184
198
  } = props;
@@ -207,7 +221,7 @@ export function ScrollerListEx<T extends object>(
207
221
  cacheKey
208
222
  ? (visibleRows) =>
209
223
  sessionStorage.setItem(
210
- `${cacheKey}-scroll`,
224
+ listCacheKeyGenerator(cacheKey),
211
225
  JSON.stringify(visibleRows)
212
226
  )
213
227
  : 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(`${cacheKey}-scroll`);
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(`${cacheKey}-scroll`);
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(