@etsoo/materialui 1.5.74 → 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.
@@ -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];
@@ -1,17 +1,19 @@
1
1
  import { ListItemReact } from "@etsoo/react";
2
2
  import React from "react";
3
3
  import { ScrollerListExItemRendererProps } from "./ScrollerListEx";
4
+ import { SxProps, Theme } from "@mui/material/styles";
4
5
  /**
5
6
  * Default mobile list item renderer
6
7
  * @param param0 List renderer props
7
8
  * @param margin Margin
8
9
  * @param renderer Renderer for card content
10
+ * @param cellSX Cell sx
9
11
  * @returns Component
10
12
  */
11
- export declare function MobileListItemRenderer<T>({ data, margins }: ScrollerListExItemRendererProps<T>, renderer: (data: T) => [
13
+ export declare function MobileListItemRenderer<T>({ data }: ScrollerListExItemRendererProps<T>, renderer: (data: T) => [
12
14
  string,
13
15
  string | undefined,
14
16
  React.ReactNode | (ListItemReact | boolean)[],
15
17
  React.ReactNode,
16
18
  React.ReactNode?
17
- ]): import("react/jsx-runtime").JSX.Element;
19
+ ], cellSX?: SxProps<Theme>): import("react/jsx-runtime").JSX.Element;
@@ -15,16 +15,20 @@ const CardContent_1 = __importDefault(require("@mui/material/CardContent"));
15
15
  * @param param0 List renderer props
16
16
  * @param margin Margin
17
17
  * @param renderer Renderer for card content
18
+ * @param cellSX Cell sx
18
19
  * @returns Component
19
20
  */
20
- function MobileListItemRenderer({ data, margins }, renderer) {
21
+ function MobileListItemRenderer({ data }, renderer, cellSX) {
21
22
  // Loading
22
23
  if (data == null)
23
24
  return (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {});
24
25
  // Elements
25
26
  const [title, subheader, actions, children, cardActions] = renderer(data);
26
27
  return ((0, jsx_runtime_1.jsxs)(Card_1.default, { sx: {
27
- ...margins
28
+ height: `calc(100% - 8px)`,
29
+ marginTop: "8px",
30
+ overflow: "auto",
31
+ ...cellSX
28
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: {
29
33
  vertical: "bottom",
30
34
  horizontal: "right"
@@ -34,8 +38,5 @@ function MobileListItemRenderer({ data, margins }, renderer) {
34
38
  }, actions: actions })) : (actions), title: title, subheader: subheader, slotProps: {
35
39
  title: { variant: "body2" },
36
40
  subheader: { variant: "caption" }
37
- } }), (0, jsx_runtime_1.jsx)(CardContent_1.default, { sx: {
38
- paddingTop: 0,
39
- paddingBottom: cardActions == null ? Reflect.get(margins, "marginBottom") ?? 0 : 0
40
- }, children: children }), cardActions] }));
41
+ } }), (0, jsx_runtime_1.jsx)(CardContent_1.default, { children: children }), cardActions] }));
41
42
  }
@@ -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 ||
@@ -17,10 +17,6 @@ export type ScrollerListExItemRendererProps<T> = {
17
17
  * Style
18
18
  */
19
19
  style: React.CSSProperties;
20
- /**
21
- * Default margins
22
- */
23
- margins: object;
24
20
  /**
25
21
  * Item selected
26
22
  */
@@ -42,10 +38,6 @@ export type ScrollerListExProps<T extends object> = Omit<ScrollerListProps<T>, "
42
38
  * Cache minutes
43
39
  */
44
40
  cacheMinutes?: number;
45
- /**
46
- * Cell margins, default to half of MUGlobal.pagePaddings
47
- */
48
- cellMargins?: object;
49
41
  /**
50
42
  * Item renderer
51
43
  */
@@ -9,7 +9,6 @@ const css_1 = require("@emotion/css");
9
9
  const react_1 = require("@etsoo/react");
10
10
  const shared_1 = require("@etsoo/shared");
11
11
  const react_2 = __importDefault(require("react"));
12
- const MUGlobal_1 = require("./MUGlobal");
13
12
  const GridUtils_1 = require("./GridUtils");
14
13
  const useListCacheInitLoad_1 = require("./uses/useListCacheInitLoad");
15
14
  const Box_1 = __importDefault(require("@mui/material/Box"));
@@ -47,16 +46,6 @@ const createGridStyle = (alternatingColors, selectedColor) => {
47
46
  }
48
47
  });
49
48
  };
50
- // Default margins
51
- const defaultMargins = () => {
52
- const half = MUGlobal_1.MUGlobal.half(MUGlobal_1.MUGlobal.pagePaddings);
53
- return {
54
- marginLeft: 0,
55
- marginRight: 0,
56
- marginTop: half,
57
- marginBottom: half
58
- };
59
- };
60
49
  /**
61
50
  * Extended ScrollerList
62
51
  * @param props Props
@@ -84,9 +73,7 @@ function ScrollerListEx(props) {
84
73
  return selected;
85
74
  };
86
75
  // Destruct
87
- const { alternatingColors = [undefined, undefined], className, cacheKey, cacheMinutes = 15, cellMargins = defaultMargins(), idField = "id", itemRenderer = ({ data, margins }) => ((0, jsx_runtime_1.jsx)(Box_1.default, { component: "pre", sx: {
88
- ...margins
89
- }, children: JSON.stringify(data) })), onClick, onDoubleClick, onUpdateRows, onSelectChange, rowHeight = 116, selectedColor = "#edf4fb", ...rest } = props;
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;
90
77
  // Init handler
91
78
  const initHandler = (0, useListCacheInitLoad_1.useListCacheInitLoad)(cacheKey, cacheMinutes);
92
79
  const onUpdateRowsHandler = react_2.default.useCallback((rows, state) => {
@@ -95,7 +82,7 @@ function ScrollerListEx(props) {
95
82
  }, [onUpdateRows, cacheKey]);
96
83
  // Layout
97
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
98
- ? (visibleRows) => sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(visibleRows))
85
+ ? (visibleRows) => sessionStorage.setItem((0, useListCacheInitLoad_1.listCacheKeyGenerator)(cacheKey), JSON.stringify(visibleRows))
99
86
  : undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, rowComponent: (cellProps) => {
100
87
  const { index, style, items } = cellProps;
101
88
  const data = items[index];
@@ -106,8 +93,7 @@ function ScrollerListEx(props) {
106
93
  index,
107
94
  data,
108
95
  style,
109
- selected,
110
- margins: cellMargins
96
+ selected
111
97
  });
112
98
  return ((0, jsx_runtime_1.jsx)("div", { className: rowClass, style: style, onMouseDown: (event) => onMouseDown(event.currentTarget, data), onClick: (event) => onClick && onClick(event, data), onDoubleClick: (event) => onDoubleClick && onDoubleClick(event, data), children: child }));
113
99
  }, rowHeight: rowHeight, ...rest }));
@@ -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];
@@ -1,17 +1,19 @@
1
1
  import { ListItemReact } from "@etsoo/react";
2
2
  import React from "react";
3
3
  import { ScrollerListExItemRendererProps } from "./ScrollerListEx";
4
+ import { SxProps, Theme } from "@mui/material/styles";
4
5
  /**
5
6
  * Default mobile list item renderer
6
7
  * @param param0 List renderer props
7
8
  * @param margin Margin
8
9
  * @param renderer Renderer for card content
10
+ * @param cellSX Cell sx
9
11
  * @returns Component
10
12
  */
11
- export declare function MobileListItemRenderer<T>({ data, margins }: ScrollerListExItemRendererProps<T>, renderer: (data: T) => [
13
+ export declare function MobileListItemRenderer<T>({ data }: ScrollerListExItemRendererProps<T>, renderer: (data: T) => [
12
14
  string,
13
15
  string | undefined,
14
16
  React.ReactNode | (ListItemReact | boolean)[],
15
17
  React.ReactNode,
16
18
  React.ReactNode?
17
- ]): import("react/jsx-runtime").JSX.Element;
19
+ ], cellSX?: SxProps<Theme>): import("react/jsx-runtime").JSX.Element;
@@ -9,16 +9,20 @@ import CardContent from "@mui/material/CardContent";
9
9
  * @param param0 List renderer props
10
10
  * @param margin Margin
11
11
  * @param renderer Renderer for card content
12
+ * @param cellSX Cell sx
12
13
  * @returns Component
13
14
  */
14
- export function MobileListItemRenderer({ data, margins }, renderer) {
15
+ export function MobileListItemRenderer({ data }, renderer, cellSX) {
15
16
  // Loading
16
17
  if (data == null)
17
18
  return _jsx(LinearProgress, {});
18
19
  // Elements
19
20
  const [title, subheader, actions, children, cardActions] = renderer(data);
20
21
  return (_jsxs(Card, { sx: {
21
- ...margins
22
+ height: `calc(100% - 8px)`,
23
+ marginTop: "8px",
24
+ overflow: "auto",
25
+ ...cellSX
22
26
  }, children: [_jsx(CardHeader, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? (_jsx(MoreFab, { iconButton: true, size: "small", anchorOrigin: {
23
27
  vertical: "bottom",
24
28
  horizontal: "right"
@@ -28,8 +32,5 @@ export function MobileListItemRenderer({ data, margins }, renderer) {
28
32
  }, actions: actions })) : (actions), title: title, subheader: subheader, slotProps: {
29
33
  title: { variant: "body2" },
30
34
  subheader: { variant: "caption" }
31
- } }), _jsx(CardContent, { sx: {
32
- paddingTop: 0,
33
- paddingBottom: cardActions == null ? Reflect.get(margins, "marginBottom") ?? 0 : 0
34
- }, children: children }), cardActions] }));
35
+ } }), _jsx(CardContent, { children: children }), cardActions] }));
35
36
  }
@@ -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 ||
@@ -17,10 +17,6 @@ export type ScrollerListExItemRendererProps<T> = {
17
17
  * Style
18
18
  */
19
19
  style: React.CSSProperties;
20
- /**
21
- * Default margins
22
- */
23
- margins: object;
24
20
  /**
25
21
  * Item selected
26
22
  */
@@ -42,10 +38,6 @@ export type ScrollerListExProps<T extends object> = Omit<ScrollerListProps<T>, "
42
38
  * Cache minutes
43
39
  */
44
40
  cacheMinutes?: number;
45
- /**
46
- * Cell margins, default to half of MUGlobal.pagePaddings
47
- */
48
- cellMargins?: object;
49
41
  /**
50
42
  * Item renderer
51
43
  */
@@ -3,9 +3,8 @@ import { css } from "@emotion/css";
3
3
  import { ScrollerList } from "@etsoo/react";
4
4
  import { Utils } from "@etsoo/shared";
5
5
  import React from "react";
6
- import { MUGlobal } from "./MUGlobal";
7
6
  import { GridUtils } from "./GridUtils";
8
- import { useListCacheInitLoad } from "./uses/useListCacheInitLoad";
7
+ import { listCacheKeyGenerator, useListCacheInitLoad } from "./uses/useListCacheInitLoad";
9
8
  import Box from "@mui/material/Box";
10
9
  // Scroll bar size
11
10
  const scrollbarSize = 16;
@@ -41,16 +40,6 @@ const createGridStyle = (alternatingColors, selectedColor) => {
41
40
  }
42
41
  });
43
42
  };
44
- // Default margins
45
- const defaultMargins = () => {
46
- const half = MUGlobal.half(MUGlobal.pagePaddings);
47
- return {
48
- marginLeft: 0,
49
- marginRight: 0,
50
- marginTop: half,
51
- marginBottom: half
52
- };
53
- };
54
43
  /**
55
44
  * Extended ScrollerList
56
45
  * @param props Props
@@ -78,9 +67,7 @@ export function ScrollerListEx(props) {
78
67
  return selected;
79
68
  };
80
69
  // Destruct
81
- const { alternatingColors = [undefined, undefined], className, cacheKey, cacheMinutes = 15, cellMargins = defaultMargins(), idField = "id", itemRenderer = ({ data, margins }) => (_jsx(Box, { component: "pre", sx: {
82
- ...margins
83
- }, children: JSON.stringify(data) })), onClick, onDoubleClick, onUpdateRows, onSelectChange, rowHeight = 116, selectedColor = "#edf4fb", ...rest } = props;
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;
84
71
  // Init handler
85
72
  const initHandler = useListCacheInitLoad(cacheKey, cacheMinutes);
86
73
  const onUpdateRowsHandler = React.useCallback((rows, state) => {
@@ -89,7 +76,7 @@ export function ScrollerListEx(props) {
89
76
  }, [onUpdateRows, cacheKey]);
90
77
  // Layout
91
78
  return (_jsx(ScrollerList, { className: Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, onRowsRendered: cacheKey
92
- ? (visibleRows) => sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(visibleRows))
79
+ ? (visibleRows) => sessionStorage.setItem(listCacheKeyGenerator(cacheKey), JSON.stringify(visibleRows))
93
80
  : undefined, onInitLoad: initHandler, onUpdateRows: onUpdateRowsHandler, rowComponent: (cellProps) => {
94
81
  const { index, style, items } = cellProps;
95
82
  const data = items[index];
@@ -100,8 +87,7 @@ export function ScrollerListEx(props) {
100
87
  index,
101
88
  data,
102
89
  style,
103
- selected,
104
- margins: cellMargins
90
+ selected
105
91
  });
106
92
  return (_jsx("div", { className: rowClass, style: style, onMouseDown: (event) => onMouseDown(event.currentTarget, data), onClick: (event) => onClick && onClick(event, data), onDoubleClick: (event) => onDoubleClick && onDoubleClick(event, data), children: child }));
107
93
  }, rowHeight: rowHeight, ...rest }));
@@ -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.74",
3
+ "version": "1.5.76",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -46,10 +46,10 @@
46
46
  "@etsoo/shared": "^1.2.76",
47
47
  "@mui/icons-material": "^7.3.4",
48
48
  "@mui/material": "^7.3.4",
49
- "@mui/x-data-grid": "^8.14.0",
50
- "chart.js": "^4.5.0",
49
+ "@mui/x-data-grid": "^8.14.1",
50
+ "chart.js": "^4.5.1",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
- "dompurify": "^3.2.7",
52
+ "dompurify": "^3.3.0",
53
53
  "eventemitter3": "^5.0.1",
54
54
  "pica": "^9.0.1",
55
55
  "pulltorefreshjs": "^0.1.22",
@@ -78,7 +78,7 @@
78
78
  "@types/pulltorefreshjs": "^0.1.7",
79
79
  "@types/react": "^19.2.2",
80
80
  "@types/react-avatar-editor": "^13.0.4",
81
- "@types/react-dom": "^19.2.1",
81
+ "@types/react-dom": "^19.2.2",
82
82
  "@types/react-input-mask": "^3.0.6",
83
83
  "@vitejs/plugin-react": "^5.0.4",
84
84
  "jsdom": "^27.0.0",
@@ -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
@@ -6,16 +6,18 @@ import Card from "@mui/material/Card";
6
6
  import CardHeader from "@mui/material/CardHeader";
7
7
  import CardContent from "@mui/material/CardContent";
8
8
  import { ScrollerListExItemRendererProps } from "./ScrollerListEx";
9
+ import { SxProps, Theme } from "@mui/material/styles";
9
10
 
10
11
  /**
11
12
  * Default mobile list item renderer
12
13
  * @param param0 List renderer props
13
14
  * @param margin Margin
14
15
  * @param renderer Renderer for card content
16
+ * @param cellSX Cell sx
15
17
  * @returns Component
16
18
  */
17
19
  export function MobileListItemRenderer<T>(
18
- { data, margins }: ScrollerListExItemRendererProps<T>,
20
+ { data }: ScrollerListExItemRendererProps<T>,
19
21
  renderer: (
20
22
  data: T
21
23
  ) => [
@@ -24,7 +26,8 @@ export function MobileListItemRenderer<T>(
24
26
  React.ReactNode | (ListItemReact | boolean)[],
25
27
  React.ReactNode,
26
28
  React.ReactNode?
27
- ]
29
+ ],
30
+ cellSX?: SxProps<Theme>
28
31
  ) {
29
32
  // Loading
30
33
  if (data == null) return <LinearProgress />;
@@ -35,7 +38,10 @@ export function MobileListItemRenderer<T>(
35
38
  return (
36
39
  <Card
37
40
  sx={{
38
- ...margins
41
+ height: `calc(100% - 8px)`,
42
+ marginTop: "8px",
43
+ overflow: "auto",
44
+ ...cellSX
39
45
  }}
40
46
  >
41
47
  <CardHeader
@@ -66,15 +72,7 @@ export function MobileListItemRenderer<T>(
66
72
  subheader: { variant: "caption" }
67
73
  }}
68
74
  />
69
- <CardContent
70
- sx={{
71
- paddingTop: 0,
72
- paddingBottom:
73
- cardActions == null ? Reflect.get(margins, "marginBottom") ?? 0 : 0
74
- }}
75
- >
76
- {children}
77
- </CardContent>
75
+ <CardContent>{children}</CardContent>
78
76
  {cardActions}
79
77
  </Card>
80
78
  );
@@ -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}
@@ -6,9 +6,12 @@ import {
6
6
  } from "@etsoo/react";
7
7
  import { DataTypes, Utils } from "@etsoo/shared";
8
8
  import React from "react";
9
- import { MouseEventWithDataHandler, MUGlobal } from "./MUGlobal";
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";
13
16
 
14
17
  // Scroll bar size
@@ -51,18 +54,6 @@ const createGridStyle = (
51
54
  });
52
55
  };
53
56
 
54
- // Default margins
55
- const defaultMargins = () => {
56
- const half = MUGlobal.half(MUGlobal.pagePaddings);
57
-
58
- return {
59
- marginLeft: 0,
60
- marginRight: 0,
61
- marginTop: half,
62
- marginBottom: half
63
- };
64
- };
65
-
66
57
  /**
67
58
  * Extended ScrollerList inner item renderer props
68
59
  */
@@ -82,11 +73,6 @@ export type ScrollerListExItemRendererProps<T> = {
82
73
  */
83
74
  style: React.CSSProperties;
84
75
 
85
- /**
86
- * Default margins
87
- */
88
- margins: object;
89
-
90
76
  /**
91
77
  * Item selected
92
78
  */
@@ -116,11 +102,6 @@ export type ScrollerListExProps<T extends object> = Omit<
116
102
  */
117
103
  cacheMinutes?: number;
118
104
 
119
- /**
120
- * Cell margins, default to half of MUGlobal.pagePaddings
121
- */
122
- cellMargins?: object;
123
-
124
105
  /**
125
106
  * Item renderer
126
107
  */
@@ -190,15 +171,9 @@ export function ScrollerListEx<T extends object>(
190
171
  className,
191
172
  cacheKey,
192
173
  cacheMinutes = 15,
193
- cellMargins = defaultMargins(),
194
174
  idField = "id" as DataTypes.Keys<T>,
195
- itemRenderer = ({ data, margins }) => (
196
- <Box
197
- component="pre"
198
- sx={{
199
- ...margins
200
- }}
201
- >
175
+ itemRenderer = ({ data }) => (
176
+ <Box component="pre" sx={{ height: "100%", overflow: "auto" }}>
202
177
  {JSON.stringify(data)}
203
178
  </Box>
204
179
  ),
@@ -235,7 +210,7 @@ export function ScrollerListEx<T extends object>(
235
210
  cacheKey
236
211
  ? (visibleRows) =>
237
212
  sessionStorage.setItem(
238
- `${cacheKey}-scroll`,
213
+ listCacheKeyGenerator(cacheKey),
239
214
  JSON.stringify(visibleRows)
240
215
  )
241
216
  : undefined
@@ -255,8 +230,7 @@ export function ScrollerListEx<T extends object>(
255
230
  index,
256
231
  data,
257
232
  style,
258
- selected,
259
- margins: cellMargins
233
+ selected
260
234
  });
261
235
 
262
236
  return (
@@ -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(