@etsoo/materialui 1.5.70 → 1.5.72

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.
Files changed (95) hide show
  1. package/__tests__/ReactAppTests.tsx +12 -7
  2. package/__tests__/SelectEx.tsx +1 -1
  3. package/__tests__/tsconfig.json +1 -1
  4. package/lib/cjs/ButtonPopupCheckbox.js +1 -1
  5. package/lib/cjs/ButtonPopupRadio.js +1 -1
  6. package/lib/cjs/DataGridEx.d.ts +8 -1
  7. package/lib/cjs/DataGridEx.js +71 -56
  8. package/lib/cjs/DataGridRenderers.d.ts +1 -1
  9. package/lib/cjs/DataGridRenderers.js +1 -1
  10. package/lib/cjs/DnDList.js +1 -1
  11. package/lib/cjs/MUUtils.d.ts +0 -9
  12. package/lib/cjs/MUUtils.js +0 -26
  13. package/lib/cjs/MobileListItemRenderer.d.ts +2 -2
  14. package/lib/cjs/ResponsibleContainer.d.ts +2 -7
  15. package/lib/cjs/ResponsibleContainer.js +8 -57
  16. package/lib/cjs/ScrollerListEx.d.ts +24 -9
  17. package/lib/cjs/ScrollerListEx.js +36 -39
  18. package/lib/cjs/SelectEx.js +2 -2
  19. package/lib/cjs/TableEx.d.ts +7 -0
  20. package/lib/cjs/TableEx.js +6 -12
  21. package/lib/cjs/app/ReactApp.d.ts +1 -3
  22. package/lib/cjs/custom/FieldDateInput.js +1 -1
  23. package/lib/cjs/custom/FieldInput.js +1 -1
  24. package/lib/cjs/custom/FieldJson.js +1 -1
  25. package/lib/cjs/custom/FieldNumberInput.js +1 -1
  26. package/lib/cjs/custom/FieldTexarea.js +1 -1
  27. package/lib/cjs/html/HtmlDiv.d.ts +24 -7
  28. package/lib/cjs/html/HtmlDiv.js +5 -1
  29. package/lib/cjs/pages/DataGridPage.js +3 -32
  30. package/lib/cjs/pages/FixedListPage.js +5 -34
  31. package/lib/cjs/pages/ListPage.js +1 -29
  32. package/lib/cjs/pages/ResponsivePage.d.ts +2 -7
  33. package/lib/cjs/uses/useGridCacheInitLoad.d.ts +2 -0
  34. package/lib/cjs/uses/useGridCacheInitLoad.js +41 -0
  35. package/lib/cjs/uses/useListCacheInitLoad.d.ts +2 -0
  36. package/lib/cjs/uses/useListCacheInitLoad.js +38 -0
  37. package/lib/mjs/ButtonPopupCheckbox.js +1 -1
  38. package/lib/mjs/ButtonPopupRadio.js +1 -1
  39. package/lib/mjs/DataGridEx.d.ts +8 -1
  40. package/lib/mjs/DataGridEx.js +71 -56
  41. package/lib/mjs/DataGridRenderers.d.ts +1 -1
  42. package/lib/mjs/DataGridRenderers.js +1 -1
  43. package/lib/mjs/DnDList.js +1 -1
  44. package/lib/mjs/MUUtils.d.ts +0 -9
  45. package/lib/mjs/MUUtils.js +0 -26
  46. package/lib/mjs/MobileListItemRenderer.d.ts +2 -2
  47. package/lib/mjs/ResponsibleContainer.d.ts +2 -7
  48. package/lib/mjs/ResponsibleContainer.js +8 -57
  49. package/lib/mjs/ScrollerListEx.d.ts +24 -9
  50. package/lib/mjs/ScrollerListEx.js +36 -39
  51. package/lib/mjs/SelectEx.js +2 -2
  52. package/lib/mjs/TableEx.d.ts +7 -0
  53. package/lib/mjs/TableEx.js +6 -12
  54. package/lib/mjs/app/ReactApp.d.ts +1 -3
  55. package/lib/mjs/custom/FieldDateInput.js +1 -1
  56. package/lib/mjs/custom/FieldInput.js +1 -1
  57. package/lib/mjs/custom/FieldJson.js +1 -1
  58. package/lib/mjs/custom/FieldNumberInput.js +1 -1
  59. package/lib/mjs/custom/FieldTexarea.js +1 -1
  60. package/lib/mjs/html/HtmlDiv.d.ts +24 -7
  61. package/lib/mjs/html/HtmlDiv.js +2 -1
  62. package/lib/mjs/pages/DataGridPage.js +3 -32
  63. package/lib/mjs/pages/FixedListPage.js +5 -34
  64. package/lib/mjs/pages/ListPage.js +1 -29
  65. package/lib/mjs/pages/ResponsivePage.d.ts +2 -7
  66. package/lib/mjs/uses/useGridCacheInitLoad.d.ts +2 -0
  67. package/lib/mjs/uses/useGridCacheInitLoad.js +35 -0
  68. package/lib/mjs/uses/useListCacheInitLoad.d.ts +2 -0
  69. package/lib/mjs/uses/useListCacheInitLoad.js +32 -0
  70. package/package.json +18 -19
  71. package/setupTests.ts +2 -0
  72. package/src/ButtonPopupCheckbox.tsx +1 -1
  73. package/src/ButtonPopupRadio.tsx +1 -1
  74. package/src/DataGridEx.tsx +151 -108
  75. package/src/DataGridRenderers.tsx +2 -1
  76. package/src/DnDList.tsx +1 -1
  77. package/src/MUUtils.ts +0 -33
  78. package/src/MobileListItemRenderer.tsx +2 -2
  79. package/src/ResponsibleContainer.tsx +21 -94
  80. package/src/ScrollerListEx.tsx +110 -122
  81. package/src/SelectEx.tsx +2 -2
  82. package/src/TableEx.tsx +20 -12
  83. package/src/custom/CustomFieldUtils.tsx +1 -1
  84. package/src/custom/FieldDateInput.tsx +1 -1
  85. package/src/custom/FieldInput.tsx +1 -1
  86. package/src/custom/FieldJson.tsx +1 -1
  87. package/src/custom/FieldNumberInput.tsx +1 -1
  88. package/src/custom/FieldTexarea.tsx +1 -1
  89. package/src/html/HtmlDiv.tsx +13 -9
  90. package/src/pages/DataGridPage.tsx +3 -49
  91. package/src/pages/FixedListPage.tsx +5 -49
  92. package/src/pages/ListPage.tsx +0 -43
  93. package/src/pages/ResponsivePage.tsx +3 -11
  94. package/src/uses/useGridCacheInitLoad.ts +55 -0
  95. package/src/uses/useListCacheInitLoad.ts +51 -0
@@ -11,7 +11,6 @@ import {
11
11
  GridLoaderStates,
12
12
  ScrollerGrid,
13
13
  ScrollerGridForwardRef,
14
- ScrollerGridItemRendererProps,
15
14
  ScrollerGridProps,
16
15
  useCombinedRefs
17
16
  } from "@etsoo/react";
@@ -24,6 +23,8 @@ import Box, { BoxProps } from "@mui/material/Box";
24
23
  import TableSortLabel from "@mui/material/TableSortLabel";
25
24
  import Checkbox from "@mui/material/Checkbox";
26
25
  import Paper from "@mui/material/Paper";
26
+ import { GridUtils } from "./GridUtils";
27
+ import { useGridCacheInitLoad } from "./uses/useGridCacheInitLoad";
27
28
 
28
29
  /**
29
30
  * Footer item renderer props
@@ -44,7 +45,13 @@ export type DataGridExProps<
44
45
  P extends GridJsonData = GridLoadDataProps
45
46
  > = Omit<
46
47
  ScrollerGridProps<T, P>,
47
- "itemRenderer" | "columnCount" | "columnWidth" | "width"
48
+ | "cellComponent"
49
+ | "columnCount"
50
+ | "columnWidth"
51
+ | "onClick"
52
+ | "onDoubleClick"
53
+ | "onInitLoad"
54
+ | "width"
48
55
  > & {
49
56
  /**
50
57
  * Alternating colors for odd/even rows
@@ -117,6 +124,14 @@ export type DataGridExProps<
117
124
  */
118
125
  onClick?: MouseEventWithDataHandler<T>;
119
126
 
127
+ /**
128
+ * Data change handler
129
+ * @param rows Rows
130
+ * @param rowIndex Row index
131
+ * @param columnIndex Column index
132
+ */
133
+ onDataChange?: (rows: T[], rowIndex: number, columnIndex: number) => void;
134
+
120
135
  /**
121
136
  * Selectable to support hover over and out effect and row clickable
122
137
  * @default true
@@ -355,6 +370,8 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
355
370
  alternatingColors = [theme.palette.grey[100], undefined],
356
371
  borderRowsCount,
357
372
  bottomHeight = 53,
373
+ cacheKey,
374
+ cacheMinutes = 15,
358
375
  checkable = false,
359
376
  className,
360
377
  columns,
@@ -369,7 +386,9 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
369
386
  idField = "id" as DataTypes.Keys<T>,
370
387
  mRef = React.createRef(),
371
388
  onClick,
389
+ onDataChange,
372
390
  onDoubleClick,
391
+ onUpdateRows,
373
392
  selectable = true,
374
393
  selectedColor = "#edf4fb",
375
394
  width,
@@ -433,6 +452,9 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
433
452
  }
434
453
  }
435
454
 
455
+ // Init handler
456
+ const initHandler = useGridCacheInitLoad<T>(cacheKey, cacheMinutes);
457
+
436
458
  const refs = React.useRef<{ ref?: ScrollerGridForwardRef<T> }>({});
437
459
 
438
460
  const mRefLocal = useCombinedRefs(mRef, (ref: ScrollerGridForwardRef<T>) => {
@@ -501,107 +523,6 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
501
523
  });
502
524
  };
503
525
 
504
- /**
505
- * Item renderer
506
- */
507
- const itemRenderer = ({
508
- columnIndex,
509
- rowIndex,
510
- style,
511
- data,
512
- selectedItems,
513
- setItems
514
- }: ScrollerGridItemRendererProps<T>) => {
515
- // Column
516
- const {
517
- align,
518
- cellRenderer = DataGridRenderers.defaultCellRenderer,
519
- cellBoxStyle,
520
- field,
521
- type,
522
- valueFormatter,
523
- renderProps
524
- } = columns[columnIndex];
525
-
526
- // Props
527
- const formatProps: GridCellFormatterProps<T> = {
528
- data,
529
- field,
530
- rowIndex,
531
- columnIndex
532
- };
533
-
534
- let rowClass = `DataGridEx-Cell${rowIndex % 2}`;
535
- if (
536
- borderRowsCount != null &&
537
- borderRowsCount > 0 &&
538
- (rowIndex + 1) % borderRowsCount === 0
539
- ) {
540
- rowClass += ` DataGridEx-Cell-Border`;
541
- }
542
-
543
- // Selected
544
- const selected =
545
- data != null &&
546
- (selectedRowIndex.current === rowIndex ||
547
- selectedItems.some(
548
- (selectedItem) =>
549
- selectedItem != null && selectedItem[idField] === data[idField]
550
- ));
551
-
552
- if (selected) {
553
- rowClass += ` DataGridEx-Selected`;
554
- }
555
-
556
- // Box style
557
- const boxStyle =
558
- data == null || cellBoxStyle == null
559
- ? undefined
560
- : typeof cellBoxStyle === "function"
561
- ? cellBoxStyle(data)
562
- : cellBoxStyle;
563
-
564
- const cellProps: BoxProps = {
565
- className: "DataGridEx-Cell",
566
- textAlign: GridAlignGet(align, type),
567
- sx: { ...boxStyle }
568
- };
569
-
570
- const child = cellRenderer({
571
- data,
572
- field,
573
- formattedValue: valueFormatter ? valueFormatter(formatProps) : undefined,
574
- selected,
575
- type,
576
- rowIndex,
577
- columnIndex,
578
- cellProps,
579
- renderProps:
580
- typeof renderProps === "function" ? renderProps(data) : renderProps,
581
- setItems
582
- });
583
-
584
- return (
585
- <div
586
- className={rowClass}
587
- style={style}
588
- data-row={rowIndex}
589
- data-column={columnIndex}
590
- onMouseDown={selectable && !checkable ? handleMouseDown : undefined}
591
- onMouseOver={selectable ? handleMouseOver : undefined}
592
- onMouseOut={selectable ? handleMouseOut : undefined}
593
- onClick={(event) => onClick && data != null && onClick(event, data)}
594
- onDoubleClick={(event) =>
595
- onDoubleClick && data != null && onDoubleClick(event, data)
596
- }
597
- >
598
- <Box {...cellProps} onMouseEnter={handleMouseEnter}>
599
- {child}
600
- </Box>
601
- </div>
602
- );
603
- };
604
-
605
526
  // Column width calculator
606
527
  const widthCalculator = React.useMemo(
607
528
  () => DataGridExCalColumns(columns),
@@ -630,6 +551,14 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
630
551
  [columns, width]
631
552
  );
632
553
 
554
+ const onUpdateRowsHandler = React.useCallback(
555
+ (rows: T[], state: GridLoaderStates<T>) => {
556
+ GridUtils.getUpdateRowsHandler<T>(cacheKey)?.(rows, state);
557
+ onUpdateRows?.(rows, state);
558
+ },
559
+ [onUpdateRows, cacheKey]
560
+ );
561
+
633
562
  // Table
634
563
  const table = React.useMemo(() => {
635
564
  return (
@@ -640,18 +569,132 @@ export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
640
569
  className,
641
570
  createGridStyle(alternatingColors, selectedColor, hoverColor)
642
571
  )}
572
+ onCellsRendered={
573
+ cacheKey
574
+ ? (visibleCells) =>
575
+ sessionStorage.setItem(
576
+ `${cacheKey}-scroll`,
577
+ JSON.stringify(visibleCells)
578
+ )
579
+ : undefined
580
+ }
581
+ onInitLoad={initHandler}
582
+ onUpdateRows={onUpdateRowsHandler}
583
+ cellComponent={({ rowIndex, columnIndex, style, rows, states }) => {
584
+ // Column
585
+ const {
586
+ align,
587
+ cellRenderer = DataGridRenderers.defaultCellRenderer,
588
+ cellBoxStyle,
589
+ field,
590
+ type,
591
+ valueFormatter,
592
+ renderProps
593
+ } = columns[columnIndex];
594
+
595
+ // Data
596
+ const data = rows[rowIndex];
597
+
598
+ // Props
599
+ const formatProps: GridCellFormatterProps<T> = {
600
+ data,
601
+ field,
602
+ rowIndex,
603
+ columnIndex
604
+ };
605
+
606
+ let rowClass = `DataGridEx-Cell${rowIndex % 2}`;
607
+ if (
608
+ borderRowsCount != null &&
609
+ borderRowsCount > 0 &&
610
+ (rowIndex + 1) % borderRowsCount === 0
611
+ ) {
612
+ rowClass += ` DataGridEx-Cell-Border`;
613
+ }
614
+
615
+ // Selected
616
+ const selected =
617
+ data != null &&
618
+ (selectedRowIndex.current === rowIndex ||
619
+ states.selectedItems.some(
620
+ (selectedItem) =>
621
+ selectedItem != null &&
622
+ selectedItem[idField] === data[idField]
623
+ ));
624
+
625
+ if (selected) {
626
+ rowClass += ` DataGridEx-Selected`;
627
+ }
628
+
629
+ // Box style
630
+ const boxStyle =
631
+ data == null || cellBoxStyle == null
632
+ ? undefined
633
+ : typeof cellBoxStyle === "function"
634
+ ? cellBoxStyle(data)
635
+ : cellBoxStyle;
636
+
637
+ const cellProps: BoxProps = {
638
+ className: "DataGridEx-Cell",
639
+ textAlign: GridAlignGet(align, type),
640
+ sx: { ...boxStyle }
641
+ };
642
+
643
+ const child = cellRenderer({
644
+ data,
645
+ field,
646
+ formattedValue: valueFormatter
647
+ ? valueFormatter(formatProps)
648
+ : undefined,
649
+ selected,
650
+ type,
651
+ rowIndex,
652
+ columnIndex,
653
+ cellProps,
654
+ renderProps:
655
+ typeof renderProps === "function"
656
+ ? renderProps(data)
657
+ : renderProps,
658
+ triggerChange: () => onDataChange?.(rows, rowIndex, columnIndex)
659
+ });
660
+
661
+ return (
662
+ <div
663
+ className={rowClass}
664
+ style={style}
665
+ data-row={rowIndex}
666
+ data-column={columnIndex}
667
+ onMouseDown={
668
+ selectable && !checkable ? handleMouseDown : undefined
669
+ }
670
+ onMouseOver={selectable ? handleMouseOver : undefined}
671
+ onMouseOut={selectable ? handleMouseOut : undefined}
672
+ onClick={(event) =>
673
+ onClick && data != null && onClick(event, data)
674
+ }
675
+ onDoubleClick={(event) =>
676
+ onDoubleClick && data != null && onDoubleClick(event, data)
677
+ }
678
+ >
679
+ <Box {...cellProps} onMouseEnter={handleMouseEnter}>
680
+ {child}
681
+ </Box>
682
+ </div>
683
+ );
684
+ }}
643
685
  columnCount={columns.length}
644
686
  columnWidth={columnWidth}
645
687
  defaultOrderBy={defaultOrderBy}
646
688
  height={
647
- height -
648
- headerHeight -
649
- (hideFooter ? 0 : bottomHeight + 1) -
650
- scrollbarSize
689
+ typeof height === "number"
690
+ ? height -
691
+ headerHeight -
692
+ (hideFooter ? 0 : bottomHeight + 1) -
693
+ scrollbarSize
694
+ : height
651
695
  }
652
696
  headerRenderer={headerRenderer}
653
697
  idField={idField}
654
- itemRenderer={itemRenderer}
655
698
  footerRenderer={hideFooter ? undefined : footerRenderer}
656
699
  width={Math.max(width ?? 0, widthCalculator.total)}
657
700
  mRef={mRefLocal}
@@ -23,7 +23,8 @@ export namespace DataGridRenderers {
23
23
  formattedValue,
24
24
  columnIndex,
25
25
  type,
26
- renderProps
26
+ renderProps,
27
+ triggerChange
27
28
  }: GridCellRendererProps<T>): React.ReactNode {
28
29
  // Is loading
29
30
  if (data == null) {
package/src/DnDList.tsx CHANGED
@@ -412,7 +412,7 @@ export function DnDList<
412
412
  );
413
413
  };
414
414
 
415
- const divRef = React.useRef<HTMLDivElement>();
415
+ const divRef = React.useRef<HTMLDivElement>(null);
416
416
 
417
417
  if (dnd == null) {
418
418
  return <Skeleton variant="rectangular" width="100%" height={height} />;
package/src/MUUtils.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { QueryRQ } from "@etsoo/appscript";
2
- import { IdType } from "@etsoo/shared";
3
1
  import { GridApiCommunity } from "@mui/x-data-grid/internals";
4
2
 
5
3
  /**
@@ -33,35 +31,4 @@ export namespace MUUtils {
33
31
  }
34
32
  return items;
35
33
  }
36
-
37
- /**
38
- * Setup paging keysets
39
- * @param data Paging data
40
- * @param lastItem Last item of the query
41
- * @param idField Id field
42
- */
43
- export function setupPagingKeysets<T, K extends IdType = number>(
44
- data: QueryRQ<K>,
45
- lastItem: T | undefined,
46
- idField: keyof T & string
47
- ) {
48
- // If the id field is not set for ordering, add it with descending
49
- if (typeof data.queryPaging === "object") {
50
- const orderBy = (data.queryPaging.orderBy ??= []);
51
- const idUpper = idField.toUpperCase();
52
- if (!orderBy.find((o) => o.field.toUpperCase() === idUpper)) {
53
- orderBy.push({ field: idField, desc: true, unique: true });
54
- }
55
-
56
- // Set the paging keysets
57
- if (lastItem) {
58
- const keysets = orderBy.map((o) => Reflect.get(lastItem, o.field));
59
- data.queryPaging.keysets = keysets;
60
- } else {
61
- data.queryPaging.keysets = undefined;
62
- }
63
- }
64
-
65
- return data;
66
- }
67
34
  }
@@ -1,11 +1,11 @@
1
1
  import { ListItemReact } from "@etsoo/react";
2
2
  import React from "react";
3
3
  import { MoreFab } from "./MoreFab";
4
- import { ScrollerListExInnerItemRendererProps } from "./ScrollerListEx";
5
4
  import LinearProgress from "@mui/material/LinearProgress";
6
5
  import Card from "@mui/material/Card";
7
6
  import CardHeader from "@mui/material/CardHeader";
8
7
  import CardContent from "@mui/material/CardContent";
8
+ import { ScrollerListExItemRendererProps } from "./ScrollerListEx";
9
9
 
10
10
  /**
11
11
  * Default mobile list item renderer
@@ -15,7 +15,7 @@ import CardContent from "@mui/material/CardContent";
15
15
  * @returns Component
16
16
  */
17
17
  export function MobileListItemRenderer<T>(
18
- { data, itemHeight, margins }: ScrollerListExInnerItemRendererProps<T>,
18
+ { data, itemHeight, margins }: ScrollerListExItemRendererProps<T>,
19
19
  renderer: (
20
20
  data: T
21
21
  ) => [
@@ -1,19 +1,11 @@
1
1
  import React from "react";
2
- import {
3
- GridOnScrollProps,
4
- ListChildComponentProps,
5
- ListOnScrollProps,
6
- VariableSizeGrid
7
- } from "react-window";
8
2
  import {
9
3
  GridColumn,
10
4
  GridJsonData,
11
5
  GridLoadDataProps,
12
- GridLoaderStates,
13
6
  GridMethodRef,
14
7
  GridTemplateType,
15
8
  ReactUtils,
16
- ScrollerListRef,
17
9
  useCombinedRefs,
18
10
  useDimensions,
19
11
  useSearchParamsWithCache
@@ -23,8 +15,8 @@ import { MUGlobal } from "./MUGlobal";
23
15
  import { PullToRefreshUI } from "./PullToRefreshUI";
24
16
  import {
25
17
  ScrollerListEx,
26
- ScrollerListExInnerItemRendererProps,
27
- ScrollerListExItemSize
18
+ ScrollerListExItemSize,
19
+ ScrollerListExProps
28
20
  } from "./ScrollerListEx";
29
21
  import { SearchBar } from "./SearchBar";
30
22
  import { Labels } from "./app/Labels";
@@ -94,17 +86,10 @@ export type ResponsibleContainerProps<T extends object, F> = Omit<
94
86
  */
95
87
  height?: number;
96
88
 
97
- /**
98
- * Inner item renderer
99
- */
100
- innerItemRenderer: (
101
- props: ScrollerListExInnerItemRendererProps<T>
102
- ) => React.ReactNode;
103
-
104
89
  /**
105
90
  * Item renderer
106
91
  */
107
- itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
92
+ itemRenderer?: ScrollerListExProps<T>["itemRenderer"];
108
93
 
109
94
  /**
110
95
  * Item size, a function indicates its a variable size list
@@ -228,6 +213,8 @@ export function ResponsibleContainer<T extends object, F>(
228
213
  const mRefs = useCombinedRefs(mRef, (ref: GridMethodRef<T>) => {
229
214
  if (ref == null) return;
230
215
  state.ref = ref;
216
+
217
+ if (ref.element && elementReady) elementReady(ref.element, true);
231
218
  });
232
219
 
233
220
  // Screen size detection
@@ -289,57 +276,6 @@ export function ResponsibleContainer<T extends object, F>(
289
276
  }
290
277
  );
291
278
 
292
- const onInitLoad = (
293
- ref: VariableSizeGrid<T> | ScrollerListRef
294
- ): [T[], Partial<GridLoaderStates<T>>?] | null | undefined => {
295
- // Avoid repeatedly load from cache
296
- if (refs.current.initLoaded || !cacheKey) return undefined;
297
-
298
- // Cache data
299
- const cacheData = GridUtils.getCacheData<T>(cacheKey, cacheMinutes);
300
- if (cacheData) {
301
- const { rows, state } = cacheData;
302
-
303
- GridUtils.mergeSearchData(state, searchData);
304
-
305
- // Scroll position
306
- const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
307
- if (scrollData) {
308
- if ("resetAfterColumnIndex" in ref) {
309
- const { scrollLeft, scrollTop } = JSON.parse(
310
- scrollData
311
- ) as GridOnScrollProps;
312
-
313
- globalThis.setTimeout(
314
- () => ref.scrollTo({ scrollLeft, scrollTop }),
315
- 0
316
- );
317
- } else {
318
- const { scrollOffset } = JSON.parse(scrollData) as ListOnScrollProps;
319
-
320
- globalThis.setTimeout(() => ref.scrollTo(scrollOffset), 0);
321
- }
322
- }
323
-
324
- // Update flag value
325
- refs.current.initLoaded = true;
326
-
327
- // Return cached rows and state
328
- return [rows, state];
329
- }
330
-
331
- return undefined;
332
- };
333
-
334
- const onListScroll = (props: ListOnScrollProps) => {
335
- if (!cacheKey || !refs.current.initLoaded) return;
336
- sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
337
- };
338
- const onGridScroll = (props: GridOnScrollProps) => {
339
- if (!cacheKey || !refs.current.initLoaded) return;
340
- sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
341
- };
342
-
343
279
  // Rect
344
280
  const rect = dimensions[0][2];
345
281
 
@@ -372,8 +308,8 @@ export function ResponsibleContainer<T extends object, F>(
372
308
  heightLocal = adjustFabHeight(heightLocal, showDataGrid);
373
309
 
374
310
  if (showDataGrid) {
375
- // Delete
376
- delete rest.itemRenderer;
311
+ // Remove useless props
312
+ const { itemRenderer, ...gridProps } = rest;
377
313
 
378
314
  return (
379
315
  <Box className="DataGridBox">
@@ -384,28 +320,25 @@ export function ResponsibleContainer<T extends object, F>(
384
320
  loadData={localLoadData}
385
321
  mRef={mRefs}
386
322
  onDoubleClick={(_, data) => quickAction && quickAction(data)}
387
- outerRef={(element?: HTMLDivElement) => {
388
- if (element != null && elementReady) elementReady(element, true);
389
- }}
390
- onScroll={onGridScroll}
391
323
  columns={columns}
392
- onUpdateRows={GridUtils.getUpdateRowsHandler<T>(cacheKey)}
393
- onInitLoad={onInitLoad}
394
- {...rest}
324
+ {...gridProps}
395
325
  />
396
326
  </Box>
397
327
  );
398
328
  }
399
329
 
400
- // Delete
401
- delete rest.checkable;
402
- delete rest.borderRowsCount;
403
- delete rest.bottomHeight;
404
- delete rest.footerItemRenderer;
405
- delete rest.headerHeight;
406
- delete rest.hideFooter;
407
- delete rest.hoverColor;
408
- delete rest.selectable;
330
+ // Remove useless props
331
+ const {
332
+ checkable,
333
+ borderRowsCount,
334
+ bottomHeight,
335
+ footerItemRenderer,
336
+ headerHeight,
337
+ hideFooter,
338
+ hoverColor,
339
+ selectable,
340
+ ...listProps
341
+ } = rest;
409
342
 
410
343
  return (
411
344
  <Box className="ListBox" sx={{ height: heightLocal }}>
@@ -413,17 +346,11 @@ export function ResponsibleContainer<T extends object, F>(
413
346
  autoLoad={!hasFields}
414
347
  height={heightLocal}
415
348
  loadData={localLoadData}
416
- onUpdateRows={GridUtils.getUpdateRowsHandler<T>(cacheKey)}
417
- onInitLoad={onInitLoad}
418
349
  mRef={mRefs}
419
350
  onClick={(event, data) =>
420
351
  quickAction && ReactUtils.isSafeClick(event) && quickAction(data)
421
352
  }
422
- oRef={(element) => {
423
- if (element != null && elementReady) elementReady(element, false);
424
- }}
425
- onScroll={onListScroll}
426
- {...rest}
353
+ {...listProps}
427
354
  />
428
355
  </Box>
429
356
  );