@etsoo/materialui 1.5.71 → 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 (58) hide show
  1. package/__tests__/ReactAppTests.tsx +12 -7
  2. package/__tests__/SelectEx.tsx +1 -1
  3. package/lib/cjs/DataGridEx.d.ts +8 -1
  4. package/lib/cjs/DataGridEx.js +71 -56
  5. package/lib/cjs/DataGridRenderers.d.ts +1 -1
  6. package/lib/cjs/DataGridRenderers.js +1 -1
  7. package/lib/cjs/MUUtils.d.ts +0 -9
  8. package/lib/cjs/MUUtils.js +0 -26
  9. package/lib/cjs/MobileListItemRenderer.d.ts +2 -2
  10. package/lib/cjs/ResponsibleContainer.d.ts +2 -7
  11. package/lib/cjs/ResponsibleContainer.js +8 -57
  12. package/lib/cjs/ScrollerListEx.d.ts +24 -9
  13. package/lib/cjs/ScrollerListEx.js +35 -38
  14. package/lib/cjs/TableEx.d.ts +7 -0
  15. package/lib/cjs/TableEx.js +6 -12
  16. package/lib/cjs/pages/DataGridPage.js +3 -32
  17. package/lib/cjs/pages/FixedListPage.js +5 -34
  18. package/lib/cjs/pages/ListPage.js +1 -29
  19. package/lib/cjs/pages/ResponsivePage.d.ts +2 -7
  20. package/lib/cjs/uses/useGridCacheInitLoad.d.ts +2 -0
  21. package/lib/cjs/uses/useGridCacheInitLoad.js +41 -0
  22. package/lib/cjs/uses/useListCacheInitLoad.d.ts +2 -0
  23. package/lib/cjs/uses/useListCacheInitLoad.js +38 -0
  24. package/lib/mjs/DataGridEx.d.ts +8 -1
  25. package/lib/mjs/DataGridEx.js +71 -56
  26. package/lib/mjs/DataGridRenderers.d.ts +1 -1
  27. package/lib/mjs/DataGridRenderers.js +1 -1
  28. package/lib/mjs/MUUtils.d.ts +0 -9
  29. package/lib/mjs/MUUtils.js +0 -26
  30. package/lib/mjs/MobileListItemRenderer.d.ts +2 -2
  31. package/lib/mjs/ResponsibleContainer.d.ts +2 -7
  32. package/lib/mjs/ResponsibleContainer.js +8 -57
  33. package/lib/mjs/ScrollerListEx.d.ts +24 -9
  34. package/lib/mjs/ScrollerListEx.js +35 -38
  35. package/lib/mjs/TableEx.d.ts +7 -0
  36. package/lib/mjs/TableEx.js +6 -12
  37. package/lib/mjs/pages/DataGridPage.js +3 -32
  38. package/lib/mjs/pages/FixedListPage.js +5 -34
  39. package/lib/mjs/pages/ListPage.js +1 -29
  40. package/lib/mjs/pages/ResponsivePage.d.ts +2 -7
  41. package/lib/mjs/uses/useGridCacheInitLoad.d.ts +2 -0
  42. package/lib/mjs/uses/useGridCacheInitLoad.js +35 -0
  43. package/lib/mjs/uses/useListCacheInitLoad.d.ts +2 -0
  44. package/lib/mjs/uses/useListCacheInitLoad.js +32 -0
  45. package/package.json +18 -19
  46. package/src/DataGridEx.tsx +151 -108
  47. package/src/DataGridRenderers.tsx +2 -1
  48. package/src/MUUtils.ts +0 -33
  49. package/src/MobileListItemRenderer.tsx +2 -2
  50. package/src/ResponsibleContainer.tsx +21 -94
  51. package/src/ScrollerListEx.tsx +109 -121
  52. package/src/TableEx.tsx +20 -12
  53. package/src/pages/DataGridPage.tsx +3 -49
  54. package/src/pages/FixedListPage.tsx +5 -49
  55. package/src/pages/ListPage.tsx +0 -43
  56. package/src/pages/ResponsivePage.tsx +3 -11
  57. package/src/uses/useGridCacheInitLoad.ts +55 -0
  58. package/src/uses/useListCacheInitLoad.ts +51 -0
@@ -0,0 +1,55 @@
1
+ import {
2
+ GridImperativeAPI,
3
+ OnCellsRenderedData,
4
+ ScrollerGridProps,
5
+ useSearchParamsWithCache
6
+ } from "@etsoo/react";
7
+ import React from "react";
8
+ import { GridUtils } from "../GridUtils";
9
+ import { ExtendUtils } from "@etsoo/shared";
10
+
11
+ export function useGridCacheInitLoad<T extends object>(
12
+ cacheKey: string | undefined,
13
+ cacheMinutes: number
14
+ ): ScrollerGridProps<T>["onInitLoad"] {
15
+ // Reference
16
+ const ref = React.useRef<boolean>(null);
17
+
18
+ // Search data
19
+ const searchData = useSearchParamsWithCache(cacheKey);
20
+
21
+ // Avoid repeatedly load from cache
22
+ if (ref.current || !cacheKey) return undefined;
23
+
24
+ // Cache data
25
+ const cacheData = GridUtils.getCacheData<T>(cacheKey, cacheMinutes);
26
+ if (cacheData) {
27
+ const { rows, state } = cacheData;
28
+
29
+ GridUtils.mergeSearchData(state, searchData);
30
+
31
+ // Update flag value
32
+ ref.current = true;
33
+
34
+ return (ref: GridImperativeAPI) => {
35
+ // Scroll position
36
+ const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
37
+ if (scrollData) {
38
+ const data = JSON.parse(scrollData) as OnCellsRenderedData;
39
+ ExtendUtils.waitFor(
40
+ () =>
41
+ ref.scrollToCell({
42
+ rowIndex: data.rowStartIndex,
43
+ columnIndex: data.columnStartIndex
44
+ }),
45
+ 100
46
+ );
47
+ }
48
+
49
+ // Return cached rows and state
50
+ return [rows, state];
51
+ };
52
+ }
53
+
54
+ return undefined;
55
+ }
@@ -0,0 +1,51 @@
1
+ import {
2
+ ListImperativeAPI,
3
+ OnRowsRenderedData,
4
+ ScrollerListProps,
5
+ useSearchParamsWithCache
6
+ } from "@etsoo/react";
7
+ import React from "react";
8
+ import { GridUtils } from "../GridUtils";
9
+ import { ExtendUtils } from "@etsoo/shared";
10
+
11
+ export function useListCacheInitLoad<T extends object>(
12
+ cacheKey: string | undefined,
13
+ cacheMinutes: number
14
+ ): ScrollerListProps<T>["onInitLoad"] {
15
+ // Reference
16
+ const ref = React.useRef<boolean>(null);
17
+
18
+ // Search data
19
+ const searchData = useSearchParamsWithCache(cacheKey);
20
+
21
+ // Avoid repeatedly load from cache
22
+ if (ref.current || !cacheKey) return undefined;
23
+
24
+ // Cache data
25
+ const cacheData = GridUtils.getCacheData<T>(cacheKey, cacheMinutes);
26
+ if (cacheData) {
27
+ const { rows, state } = cacheData;
28
+
29
+ GridUtils.mergeSearchData(state, searchData);
30
+
31
+ // Update flag value
32
+ ref.current = true;
33
+
34
+ return (ref: ListImperativeAPI) => {
35
+ // Scroll position
36
+ const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
37
+ if (scrollData) {
38
+ const data = JSON.parse(scrollData) as OnRowsRenderedData;
39
+ ExtendUtils.waitFor(
40
+ () => ref.scrollToRow({ index: data.startIndex }),
41
+ 100
42
+ );
43
+ }
44
+
45
+ // Return cached rows and state
46
+ return [rows, state];
47
+ };
48
+ }
49
+
50
+ return undefined;
51
+ }