@etsoo/materialui 1.5.76 → 1.5.78

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.
@@ -247,9 +247,12 @@ function DataGridEx(props) {
247
247
  const sharedWidth = leftWidth > 0 ? leftWidth / widthCalculator.unset : 0;
248
248
  return (column.minWidth || minWidth) + sharedWidth;
249
249
  }, [columns, width]);
250
- const onUpdateRowsHandler = react_2.default.useCallback((rows, state) => {
250
+ const onUpdateRowsHandler = react_2.default.useCallback((rows, state, reset) => {
251
251
  GridUtils_1.GridUtils.getUpdateRowsHandler(cacheKey)?.(rows, state);
252
- onUpdateRows?.(rows, state);
252
+ onUpdateRows?.(rows, state, reset);
253
+ if (cacheKey && reset) {
254
+ sessionStorage.removeItem((0, useGridCacheInitLoad_1.gridCacheKeyGenerator)(cacheKey));
255
+ }
253
256
  }, [onUpdateRows, cacheKey]);
254
257
  // Table
255
258
  const table = react_2.default.useMemo(() => {
@@ -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
@@ -25,9 +26,7 @@ function MobileListItemRenderer({ data }, renderer, cellSX) {
25
26
  // Elements
26
27
  const [title, subheader, actions, children, cardActions] = renderer(data);
27
28
  return ((0, jsx_runtime_1.jsxs)(Card_1.default, { sx: {
28
- height: `calc(100% - 8px)`,
29
- marginTop: "8px",
30
- overflow: "auto",
29
+ ...ScrollerListEx_1.ScrollerListExItemDefaultStyles,
31
30
  ...cellSX
32
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: {
33
32
  vertical: "bottom",
@@ -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,18 @@ 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
+ /**
56
+ * default rowHeight is 150px when 16px margin top/bottom
57
+ */
58
+ marginTop: "8px",
59
+ marginBottom: "8px",
60
+ overflow: "auto"
61
+ };
49
62
  /**
50
63
  * Extended ScrollerList
51
64
  * @param props Props
@@ -73,12 +86,15 @@ function ScrollerListEx(props) {
73
86
  return selected;
74
87
  };
75
88
  // 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;
89
+ 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 = 150, selectedColor = "#edf4fb", ...rest } = props;
77
90
  // Init handler
78
91
  const initHandler = (0, useListCacheInitLoad_1.useListCacheInitLoad)(cacheKey, cacheMinutes);
79
- const onUpdateRowsHandler = react_2.default.useCallback((rows, state) => {
92
+ const onUpdateRowsHandler = react_2.default.useCallback((rows, state, reset) => {
80
93
  GridUtils_1.GridUtils.getUpdateRowsHandler(cacheKey)?.(rows, state);
81
- onUpdateRows?.(rows, state);
94
+ onUpdateRows?.(rows, state, reset);
95
+ if (cacheKey && reset) {
96
+ sessionStorage.removeItem((0, useListCacheInitLoad_1.listCacheKeyGenerator)(cacheKey));
97
+ }
82
98
  }, [onUpdateRows, cacheKey]);
83
99
  // Layout
84
100
  return ((0, jsx_runtime_1.jsx)(react_1.ScrollerList, { className: shared_1.Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, onRowsRendered: cacheKey
@@ -240,9 +240,12 @@ export function DataGridEx(props) {
240
240
  const sharedWidth = leftWidth > 0 ? leftWidth / widthCalculator.unset : 0;
241
241
  return (column.minWidth || minWidth) + sharedWidth;
242
242
  }, [columns, width]);
243
- const onUpdateRowsHandler = React.useCallback((rows, state) => {
243
+ const onUpdateRowsHandler = React.useCallback((rows, state, reset) => {
244
244
  GridUtils.getUpdateRowsHandler(cacheKey)?.(rows, state);
245
- onUpdateRows?.(rows, state);
245
+ onUpdateRows?.(rows, state, reset);
246
+ if (cacheKey && reset) {
247
+ sessionStorage.removeItem(gridCacheKeyGenerator(cacheKey));
248
+ }
246
249
  }, [onUpdateRows, cacheKey]);
247
250
  // Table
248
251
  const table = React.useMemo(() => {
@@ -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
@@ -19,9 +20,7 @@ export function MobileListItemRenderer({ data }, renderer, cellSX) {
19
20
  // Elements
20
21
  const [title, subheader, actions, children, cardActions] = renderer(data);
21
22
  return (_jsxs(Card, { sx: {
22
- height: `calc(100% - 8px)`,
23
- marginTop: "8px",
24
- overflow: "auto",
23
+ ...ScrollerListExItemDefaultStyles,
25
24
  ...cellSX
26
25
  }, children: [_jsx(CardHeader, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? (_jsx(MoreFab, { iconButton: true, size: "small", anchorOrigin: {
27
26
  vertical: "bottom",
@@ -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
  */
@@ -40,6 +40,18 @@ 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
+ /**
49
+ * default rowHeight is 150px when 16px margin top/bottom
50
+ */
51
+ marginTop: "8px",
52
+ marginBottom: "8px",
53
+ overflow: "auto"
54
+ };
43
55
  /**
44
56
  * Extended ScrollerList
45
57
  * @param props Props
@@ -67,12 +79,15 @@ export function ScrollerListEx(props) {
67
79
  return selected;
68
80
  };
69
81
  // 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;
82
+ 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 = 150, selectedColor = "#edf4fb", ...rest } = props;
71
83
  // Init handler
72
84
  const initHandler = useListCacheInitLoad(cacheKey, cacheMinutes);
73
- const onUpdateRowsHandler = React.useCallback((rows, state) => {
85
+ const onUpdateRowsHandler = React.useCallback((rows, state, reset) => {
74
86
  GridUtils.getUpdateRowsHandler(cacheKey)?.(rows, state);
75
- onUpdateRows?.(rows, state);
87
+ onUpdateRows?.(rows, state, reset);
88
+ if (cacheKey && reset) {
89
+ sessionStorage.removeItem(listCacheKeyGenerator(cacheKey));
90
+ }
76
91
  }, [onUpdateRows, cacheKey]);
77
92
  // Layout
78
93
  return (_jsx(ScrollerList, { className: Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, onRowsRendered: cacheKey
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.76",
3
+ "version": "1.5.78",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -42,7 +42,7 @@
42
42
  "@emotion/styled": "^11.14.1",
43
43
  "@etsoo/appscript": "^1.6.45",
44
44
  "@etsoo/notificationbase": "^1.1.64",
45
- "@etsoo/react": "^1.8.59",
45
+ "@etsoo/react": "^1.8.60",
46
46
  "@etsoo/shared": "^1.2.76",
47
47
  "@mui/icons-material": "^7.3.4",
48
48
  "@mui/material": "^7.3.4",
@@ -81,7 +81,7 @@
81
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
- "jsdom": "^27.0.0",
84
+ "jsdom": "^27.0.1",
85
85
  "typescript": "^5.9.3",
86
86
  "vitest": "^3.2.4"
87
87
  }
@@ -560,9 +560,13 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
560
560
  );
561
561
 
562
562
  const onUpdateRowsHandler = React.useCallback(
563
- (rows: T[], state: GridLoaderStates<T>) => {
563
+ (rows: T[], state: GridLoaderStates<T>, reset: boolean) => {
564
564
  GridUtils.getUpdateRowsHandler<T>(cacheKey)?.(rows, state);
565
- onUpdateRows?.(rows, state);
565
+ onUpdateRows?.(rows, state, reset);
566
+
567
+ if (cacheKey && reset) {
568
+ sessionStorage.removeItem(gridCacheKeyGenerator(cacheKey));
569
+ }
566
570
  },
567
571
  [onUpdateRows, cacheKey]
568
572
  );
@@ -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
  /**
@@ -38,9 +41,7 @@ export function MobileListItemRenderer<T>(
38
41
  return (
39
42
  <Card
40
43
  sx={{
41
- height: `calc(100% - 8px)`,
42
- marginTop: "8px",
43
- overflow: "auto",
44
+ ...ScrollerListExItemDefaultStyles,
44
45
  ...cellSX
45
46
  }}
46
47
  >
@@ -79,6 +79,21 @@ export type ScrollerListExItemRendererProps<T> = {
79
79
  selected: boolean;
80
80
  };
81
81
 
82
+ /**
83
+ * Default styles for item renderer
84
+ */
85
+ export const ScrollerListExItemDefaultStyles: React.CSSProperties = {
86
+ height: `calc(100% - 16px)`,
87
+
88
+ /**
89
+ * default rowHeight is 150px when 16px margin top/bottom
90
+ */
91
+ marginTop: "8px",
92
+ marginBottom: "8px",
93
+
94
+ overflow: "auto"
95
+ };
96
+
82
97
  /**
83
98
  * Extended ScrollerList Props
84
99
  */
@@ -173,7 +188,7 @@ export function ScrollerListEx<T extends object>(
173
188
  cacheMinutes = 15,
174
189
  idField = "id" as DataTypes.Keys<T>,
175
190
  itemRenderer = ({ data }) => (
176
- <Box component="pre" sx={{ height: "100%", overflow: "auto" }}>
191
+ <Box component="pre" sx={ScrollerListExItemDefaultStyles}>
177
192
  {JSON.stringify(data)}
178
193
  </Box>
179
194
  ),
@@ -181,7 +196,7 @@ export function ScrollerListEx<T extends object>(
181
196
  onDoubleClick,
182
197
  onUpdateRows,
183
198
  onSelectChange,
184
- rowHeight = 116,
199
+ rowHeight = 150,
185
200
  selectedColor = "#edf4fb",
186
201
  ...rest
187
202
  } = props;
@@ -190,9 +205,13 @@ export function ScrollerListEx<T extends object>(
190
205
  const initHandler = useListCacheInitLoad<T>(cacheKey, cacheMinutes);
191
206
 
192
207
  const onUpdateRowsHandler = React.useCallback(
193
- (rows: T[], state: GridLoaderStates<T>) => {
208
+ (rows: T[], state: GridLoaderStates<T>, reset: boolean) => {
194
209
  GridUtils.getUpdateRowsHandler<T>(cacheKey)?.(rows, state);
195
- onUpdateRows?.(rows, state);
210
+ onUpdateRows?.(rows, state, reset);
211
+
212
+ if (cacheKey && reset) {
213
+ sessionStorage.removeItem(listCacheKeyGenerator(cacheKey));
214
+ }
196
215
  },
197
216
  [onUpdateRows, cacheKey]
198
217
  );