@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
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  GridLoadDataProps,
3
- GridLoaderStates,
4
- ListOnScrollProps,
5
3
  ScrollerListForwardRef,
6
- ScrollerListRef,
7
4
  useCombinedRefs,
8
5
  useDimensions,
9
6
  useSearchParamsWithCache
@@ -62,8 +59,6 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
62
59
  if (first) reset();
63
60
  });
64
61
 
65
- const initLoadedRef = React.useRef<boolean>();
66
-
67
62
  const reset = () => {
68
63
  if (states.data == null || states.ref == null) return;
69
64
  states.ref.reset({ data: states.data });
@@ -89,41 +84,6 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
89
84
  // Search data
90
85
  const searchData = useSearchParamsWithCache(cacheKey);
91
86
 
92
- const onInitLoad = (
93
- ref: ScrollerListRef
94
- ): [T[], Partial<GridLoaderStates<T>>?] | null | undefined => {
95
- // Avoid repeatedly load from cache
96
- if (initLoadedRef.current || !cacheKey) return undefined;
97
-
98
- // Cache data
99
- const cacheData = GridUtils.getCacheData<T>(cacheKey, cacheMinutes);
100
- if (cacheData) {
101
- const { rows, state } = cacheData;
102
-
103
- GridUtils.mergeSearchData(state, searchData);
104
-
105
- // Scroll position
106
- const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
107
- if (scrollData) {
108
- const { scrollOffset } = JSON.parse(scrollData) as ListOnScrollProps;
109
- globalThis.setTimeout(() => ref.scrollTo(scrollOffset), 0);
110
- }
111
-
112
- // Update flag value
113
- initLoadedRef.current = true;
114
-
115
- // Return cached rows and state
116
- return [rows, state];
117
- }
118
-
119
- return undefined;
120
- };
121
-
122
- const onListScroll = (props: ListOnScrollProps) => {
123
- if (!cacheKey || !initLoadedRef.current) return;
124
- sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
125
- };
126
-
127
87
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
128
88
 
129
89
  // Layout
@@ -148,9 +108,6 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
148
108
  <ScrollerListEx<T>
149
109
  autoLoad={false}
150
110
  loadData={localLoadData}
151
- onUpdateRows={GridUtils.getUpdateRowsHandler<T>(cacheKey)}
152
- onInitLoad={onInitLoad}
153
- onScroll={onListScroll}
154
111
  mRef={refs}
155
112
  {...rest}
156
113
  />
@@ -5,10 +5,9 @@ import { CommonPage } from "./CommonPage";
5
5
  import { OperationMessageContainer } from "../messages/OperationMessageContainer";
6
6
  import type { DataGridPageProps } from "./DataGridPageProps";
7
7
  import type {
8
- ScrollerListExInnerItemRendererProps,
9
- ScrollerListExItemSize
8
+ ScrollerListExItemSize,
9
+ ScrollerListExProps
10
10
  } from "../ScrollerListEx";
11
- import { ListChildComponentProps } from "react-window";
12
11
  import { GridMethodRef } from "@etsoo/react";
13
12
  import type { OperationMessageHandlerAll } from "../messages/OperationMessageHandler";
14
13
 
@@ -29,17 +28,10 @@ export type ResponsePageProps<T extends object, F> = DataGridPageProps<T, F> & {
29
28
  */
30
29
  dataGridMinWidth?: number;
31
30
 
32
- /**
33
- * Inner item renderer
34
- */
35
- innerItemRenderer: (
36
- props: ScrollerListExInnerItemRendererProps<T>
37
- ) => React.ReactNode;
38
-
39
31
  /**
40
32
  * Item renderer
41
33
  */
42
- itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
34
+ itemRenderer?: ScrollerListExProps<T>["itemRenderer"];
43
35
 
44
36
  /**
45
37
  * Item size, a function indicates its a variable size list
@@ -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
+ }