@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.
- package/__tests__/ReactAppTests.tsx +12 -7
- package/__tests__/SelectEx.tsx +1 -1
- package/__tests__/tsconfig.json +1 -1
- package/lib/cjs/ButtonPopupCheckbox.js +1 -1
- package/lib/cjs/ButtonPopupRadio.js +1 -1
- package/lib/cjs/DataGridEx.d.ts +8 -1
- package/lib/cjs/DataGridEx.js +71 -56
- package/lib/cjs/DataGridRenderers.d.ts +1 -1
- package/lib/cjs/DataGridRenderers.js +1 -1
- package/lib/cjs/DnDList.js +1 -1
- package/lib/cjs/MUUtils.d.ts +0 -9
- package/lib/cjs/MUUtils.js +0 -26
- package/lib/cjs/MobileListItemRenderer.d.ts +2 -2
- package/lib/cjs/ResponsibleContainer.d.ts +2 -7
- package/lib/cjs/ResponsibleContainer.js +8 -57
- package/lib/cjs/ScrollerListEx.d.ts +24 -9
- package/lib/cjs/ScrollerListEx.js +36 -39
- package/lib/cjs/SelectEx.js +2 -2
- package/lib/cjs/TableEx.d.ts +7 -0
- package/lib/cjs/TableEx.js +6 -12
- package/lib/cjs/app/ReactApp.d.ts +1 -3
- package/lib/cjs/custom/FieldDateInput.js +1 -1
- package/lib/cjs/custom/FieldInput.js +1 -1
- package/lib/cjs/custom/FieldJson.js +1 -1
- package/lib/cjs/custom/FieldNumberInput.js +1 -1
- package/lib/cjs/custom/FieldTexarea.js +1 -1
- package/lib/cjs/html/HtmlDiv.d.ts +24 -7
- package/lib/cjs/html/HtmlDiv.js +5 -1
- package/lib/cjs/pages/DataGridPage.js +3 -32
- package/lib/cjs/pages/FixedListPage.js +5 -34
- package/lib/cjs/pages/ListPage.js +1 -29
- package/lib/cjs/pages/ResponsivePage.d.ts +2 -7
- package/lib/cjs/uses/useGridCacheInitLoad.d.ts +2 -0
- package/lib/cjs/uses/useGridCacheInitLoad.js +41 -0
- package/lib/cjs/uses/useListCacheInitLoad.d.ts +2 -0
- package/lib/cjs/uses/useListCacheInitLoad.js +38 -0
- package/lib/mjs/ButtonPopupCheckbox.js +1 -1
- package/lib/mjs/ButtonPopupRadio.js +1 -1
- package/lib/mjs/DataGridEx.d.ts +8 -1
- package/lib/mjs/DataGridEx.js +71 -56
- package/lib/mjs/DataGridRenderers.d.ts +1 -1
- package/lib/mjs/DataGridRenderers.js +1 -1
- package/lib/mjs/DnDList.js +1 -1
- package/lib/mjs/MUUtils.d.ts +0 -9
- package/lib/mjs/MUUtils.js +0 -26
- package/lib/mjs/MobileListItemRenderer.d.ts +2 -2
- package/lib/mjs/ResponsibleContainer.d.ts +2 -7
- package/lib/mjs/ResponsibleContainer.js +8 -57
- package/lib/mjs/ScrollerListEx.d.ts +24 -9
- package/lib/mjs/ScrollerListEx.js +36 -39
- package/lib/mjs/SelectEx.js +2 -2
- package/lib/mjs/TableEx.d.ts +7 -0
- package/lib/mjs/TableEx.js +6 -12
- package/lib/mjs/app/ReactApp.d.ts +1 -3
- package/lib/mjs/custom/FieldDateInput.js +1 -1
- package/lib/mjs/custom/FieldInput.js +1 -1
- package/lib/mjs/custom/FieldJson.js +1 -1
- package/lib/mjs/custom/FieldNumberInput.js +1 -1
- package/lib/mjs/custom/FieldTexarea.js +1 -1
- package/lib/mjs/html/HtmlDiv.d.ts +24 -7
- package/lib/mjs/html/HtmlDiv.js +2 -1
- package/lib/mjs/pages/DataGridPage.js +3 -32
- package/lib/mjs/pages/FixedListPage.js +5 -34
- package/lib/mjs/pages/ListPage.js +1 -29
- package/lib/mjs/pages/ResponsivePage.d.ts +2 -7
- package/lib/mjs/uses/useGridCacheInitLoad.d.ts +2 -0
- package/lib/mjs/uses/useGridCacheInitLoad.js +35 -0
- package/lib/mjs/uses/useListCacheInitLoad.d.ts +2 -0
- package/lib/mjs/uses/useListCacheInitLoad.js +32 -0
- package/package.json +18 -19
- package/setupTests.ts +2 -0
- package/src/ButtonPopupCheckbox.tsx +1 -1
- package/src/ButtonPopupRadio.tsx +1 -1
- package/src/DataGridEx.tsx +151 -108
- package/src/DataGridRenderers.tsx +2 -1
- package/src/DnDList.tsx +1 -1
- package/src/MUUtils.ts +0 -33
- package/src/MobileListItemRenderer.tsx +2 -2
- package/src/ResponsibleContainer.tsx +21 -94
- package/src/ScrollerListEx.tsx +110 -122
- package/src/SelectEx.tsx +2 -2
- package/src/TableEx.tsx +20 -12
- package/src/custom/CustomFieldUtils.tsx +1 -1
- package/src/custom/FieldDateInput.tsx +1 -1
- package/src/custom/FieldInput.tsx +1 -1
- package/src/custom/FieldJson.tsx +1 -1
- package/src/custom/FieldNumberInput.tsx +1 -1
- package/src/custom/FieldTexarea.tsx +1 -1
- package/src/html/HtmlDiv.tsx +13 -9
- package/src/pages/DataGridPage.tsx +3 -49
- package/src/pages/FixedListPage.tsx +5 -49
- package/src/pages/ListPage.tsx +0 -43
- package/src/pages/ResponsivePage.tsx +3 -11
- package/src/uses/useGridCacheInitLoad.ts +55 -0
- package/src/uses/useListCacheInitLoad.ts +51 -0
|
@@ -9,7 +9,7 @@ import Typography from "@mui/material/Typography";
|
|
|
9
9
|
*/
|
|
10
10
|
export const FieldInput = ({ field, mref, onChange, defaultValue }) => {
|
|
11
11
|
// Ref
|
|
12
|
-
const inputRef = React.useRef();
|
|
12
|
+
const inputRef = React.useRef(null);
|
|
13
13
|
const getValue = () => inputRef.current?.value;
|
|
14
14
|
React.useImperativeHandle(mref, () => ({
|
|
15
15
|
getValue,
|
|
@@ -20,7 +20,7 @@ function parseJson(value) {
|
|
|
20
20
|
*/
|
|
21
21
|
export const FieldJson = ({ field, mref, onChange, defaultValue }) => {
|
|
22
22
|
// Ref
|
|
23
|
-
const inputRef = React.useRef();
|
|
23
|
+
const inputRef = React.useRef(null);
|
|
24
24
|
const getValue = () => parseJson(inputRef.current?.value);
|
|
25
25
|
const setValue = (value) => {
|
|
26
26
|
if (inputRef.current) {
|
|
@@ -10,7 +10,7 @@ import Typography from "@mui/material/Typography";
|
|
|
10
10
|
*/
|
|
11
11
|
export const FieldNumberInput = ({ field, mref, onChange, defaultValue }) => {
|
|
12
12
|
// Ref
|
|
13
|
-
const inputRef = React.useRef();
|
|
13
|
+
const inputRef = React.useRef(null);
|
|
14
14
|
const getValue = () => {
|
|
15
15
|
const value = inputRef.current?.valueAsNumber;
|
|
16
16
|
return NumberUtils.parse(value);
|
|
@@ -9,7 +9,7 @@ import Typography from "@mui/material/Typography";
|
|
|
9
9
|
*/
|
|
10
10
|
export const FieldTexarea = ({ field, mref, onChange, defaultValue }) => {
|
|
11
11
|
// Ref
|
|
12
|
-
const inputRef = React.useRef();
|
|
12
|
+
const inputRef = React.useRef(null);
|
|
13
13
|
const getValue = () => inputRef.current?.value;
|
|
14
14
|
const setValue = (value) => {
|
|
15
15
|
if (inputRef.current)
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
|
+
declare class HtmlDivElement extends HTMLElement {
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
private wrapper;
|
|
5
|
+
private observer;
|
|
6
|
+
private _displayStyle?;
|
|
7
|
+
/**
|
|
8
|
+
* Display style
|
|
9
|
+
*/
|
|
10
|
+
get displayStyle(): string | undefined;
|
|
11
|
+
set displayStyle(style: string | undefined);
|
|
12
|
+
constructor();
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
disconnectedCallback(): void;
|
|
15
|
+
attributeChangedCallback(name: string, _oldValue: any, newValue: any): void;
|
|
16
|
+
setContent(): void;
|
|
17
|
+
}
|
|
18
|
+
declare module "react" {
|
|
19
|
+
namespace JSX {
|
|
20
|
+
interface IntrinsicElements {
|
|
21
|
+
"html-div": React.DetailedHTMLProps<React.HTMLAttributes<HtmlDivElement>, HtmlDivElement>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
2
25
|
/**
|
|
3
26
|
* Custom HTML element properties
|
|
4
27
|
* 自定义 HTML 元素属性
|
|
@@ -10,13 +33,6 @@ export type HtmlDivProps = HTMLAttributes<HTMLElement> & {
|
|
|
10
33
|
*/
|
|
11
34
|
displayStyle?: string;
|
|
12
35
|
};
|
|
13
|
-
declare global {
|
|
14
|
-
namespace JSX {
|
|
15
|
-
interface IntrinsicElements {
|
|
16
|
-
"html-div": React.HTMLAttributes<HTMLElement>;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
36
|
/**
|
|
21
37
|
* Custom HTML element that sanitizes and displays HTML content
|
|
22
38
|
* 自定义 HTML 元素,用于清理和显示 HTML 内容
|
|
@@ -24,3 +40,4 @@ declare global {
|
|
|
24
40
|
* @returns Component
|
|
25
41
|
*/
|
|
26
42
|
export declare function HtmlDiv(props: HtmlDivProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export {};
|
package/lib/mjs/html/HtmlDiv.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Utils } from "@etsoo/shared";
|
|
3
|
+
import DOMPurify from "dompurify";
|
|
3
4
|
class HtmlDivElement extends HTMLElement {
|
|
4
5
|
static get observedAttributes() {
|
|
5
6
|
return ["displaystyle"];
|
|
@@ -83,7 +84,7 @@ class HtmlDivElement extends HTMLElement {
|
|
|
83
84
|
wrapper.innerHTML = this.textContent;
|
|
84
85
|
}
|
|
85
86
|
else {
|
|
86
|
-
wrapper.innerHTML = html;
|
|
87
|
+
wrapper.innerHTML = DOMPurify.sanitize(html);
|
|
87
88
|
}
|
|
88
89
|
this.textContent = null; // Clear the textContent to avoid duplication
|
|
89
90
|
}
|
|
@@ -27,9 +27,10 @@ export function DataGridPage(props) {
|
|
|
27
27
|
if (ref == null)
|
|
28
28
|
return;
|
|
29
29
|
states.ref = ref;
|
|
30
|
+
if (ref.element)
|
|
31
|
+
setStates({ element: ref.element });
|
|
30
32
|
//setStates({ ref });
|
|
31
33
|
});
|
|
32
|
-
const initLoadedRef = React.useRef();
|
|
33
34
|
// On submit callback
|
|
34
35
|
const onSubmit = (data, _reset) => {
|
|
35
36
|
setStates({ data });
|
|
@@ -39,33 +40,6 @@ export function DataGridPage(props) {
|
|
|
39
40
|
};
|
|
40
41
|
// Search data
|
|
41
42
|
const searchData = useSearchParamsWithCache(cacheKey);
|
|
42
|
-
const onInitLoad = (ref) => {
|
|
43
|
-
// Avoid repeatedly load from cache
|
|
44
|
-
if (initLoadedRef.current || !cacheKey)
|
|
45
|
-
return undefined;
|
|
46
|
-
// Cache data
|
|
47
|
-
const cacheData = GridUtils.getCacheData(cacheKey, cacheMinutes);
|
|
48
|
-
if (cacheData) {
|
|
49
|
-
const { rows, state } = cacheData;
|
|
50
|
-
GridUtils.mergeSearchData(state, searchData);
|
|
51
|
-
// Scroll position
|
|
52
|
-
const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
|
|
53
|
-
if (scrollData) {
|
|
54
|
-
const { scrollLeft, scrollTop } = JSON.parse(scrollData);
|
|
55
|
-
globalThis.setTimeout(() => ref.scrollTo({ scrollLeft, scrollTop }), 0);
|
|
56
|
-
}
|
|
57
|
-
// Update flag value
|
|
58
|
-
initLoadedRef.current = true;
|
|
59
|
-
// Return cached rows and state
|
|
60
|
-
return [rows, state];
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
};
|
|
64
|
-
const onGridScroll = (props) => {
|
|
65
|
-
if (!cacheKey || !initLoadedRef.current)
|
|
66
|
-
return;
|
|
67
|
-
sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
|
|
68
|
-
};
|
|
69
43
|
// Watch container
|
|
70
44
|
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
71
45
|
const rect = dimensions[0][2];
|
|
@@ -90,10 +64,7 @@ export function DataGridPage(props) {
|
|
|
90
64
|
const gridHeight = states.height;
|
|
91
65
|
if (gridHeight == null)
|
|
92
66
|
return;
|
|
93
|
-
return (_jsx(DataGridEx, { autoLoad: false, height: gridHeight, loadData: localLoadData, mRef: refs,
|
|
94
|
-
if (element != null)
|
|
95
|
-
setStates({ element });
|
|
96
|
-
}, ...rest }));
|
|
67
|
+
return (_jsx(DataGridEx, { autoLoad: false, height: gridHeight, loadData: localLoadData, mRef: refs, ...rest }));
|
|
97
68
|
}, [states.height]);
|
|
98
69
|
const { ref, data } = states;
|
|
99
70
|
React.useEffect(() => {
|
|
@@ -19,7 +19,6 @@ export function FixedListPage(props) {
|
|
|
19
19
|
pageProps.paddings ??= MUGlobal.pagePaddings;
|
|
20
20
|
// States
|
|
21
21
|
const [states] = React.useState({});
|
|
22
|
-
const initLoadedRef = React.useRef();
|
|
23
22
|
// Scroll container
|
|
24
23
|
const [scrollContainer, updateScrollContainer] = React.useState();
|
|
25
24
|
const refs = useCombinedRefs(mRef, (ref) => {
|
|
@@ -27,6 +26,8 @@ export function FixedListPage(props) {
|
|
|
27
26
|
return;
|
|
28
27
|
const first = states.ref == null;
|
|
29
28
|
states.ref = ref;
|
|
29
|
+
if (ref.element)
|
|
30
|
+
updateScrollContainer(ref.element);
|
|
30
31
|
if (first)
|
|
31
32
|
reset();
|
|
32
33
|
});
|
|
@@ -43,35 +44,6 @@ export function FixedListPage(props) {
|
|
|
43
44
|
const localLoadData = (props, lastItem) => {
|
|
44
45
|
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
45
46
|
};
|
|
46
|
-
// Search data
|
|
47
|
-
const searchData = useSearchParamsWithCache(cacheKey);
|
|
48
|
-
const onInitLoad = (ref) => {
|
|
49
|
-
// Avoid repeatedly load from cache
|
|
50
|
-
if (initLoadedRef.current || !cacheKey)
|
|
51
|
-
return undefined;
|
|
52
|
-
// Cache data
|
|
53
|
-
const cacheData = GridUtils.getCacheData(cacheKey, cacheMinutes);
|
|
54
|
-
if (cacheData) {
|
|
55
|
-
const { rows, state } = cacheData;
|
|
56
|
-
GridUtils.mergeSearchData(state, searchData);
|
|
57
|
-
// Scroll position
|
|
58
|
-
const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
|
|
59
|
-
if (scrollData) {
|
|
60
|
-
const { scrollOffset } = JSON.parse(scrollData);
|
|
61
|
-
globalThis.setTimeout(() => ref.scrollTo(scrollOffset), 0);
|
|
62
|
-
}
|
|
63
|
-
// Update flag value
|
|
64
|
-
initLoadedRef.current = true;
|
|
65
|
-
// Return cached rows and state
|
|
66
|
-
return [rows, state];
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
69
|
-
};
|
|
70
|
-
const onListScroll = (props) => {
|
|
71
|
-
if (!cacheKey || !initLoadedRef.current)
|
|
72
|
-
return;
|
|
73
|
-
sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
|
|
74
|
-
};
|
|
75
47
|
// Watch container
|
|
76
48
|
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
77
49
|
const rect = dimensions[0][2];
|
|
@@ -86,12 +58,11 @@ export function FixedListPage(props) {
|
|
|
86
58
|
: adjustHeight(height, rect);
|
|
87
59
|
return (_jsx(Box, { id: "list-container", sx: {
|
|
88
60
|
height: height + "px"
|
|
89
|
-
}, children: _jsx(ScrollerListEx, { autoLoad: false, height: height, loadData: localLoadData, mRef: refs,
|
|
90
|
-
if (element != null)
|
|
91
|
-
updateScrollContainer(element);
|
|
92
|
-
}, ...rest }) }));
|
|
61
|
+
}, children: _jsx(ScrollerListEx, { autoLoad: false, height: height, loadData: localLoadData, mRef: refs, ...rest }) }));
|
|
93
62
|
}
|
|
94
63
|
}, [rect]);
|
|
64
|
+
// Search data
|
|
65
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
95
66
|
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
96
67
|
const { paddings, ...pageRest } = pageProps;
|
|
97
68
|
// Layout
|
|
@@ -27,7 +27,6 @@ export function ListPage(props) {
|
|
|
27
27
|
if (first)
|
|
28
28
|
reset();
|
|
29
29
|
});
|
|
30
|
-
const initLoadedRef = React.useRef();
|
|
31
30
|
const reset = () => {
|
|
32
31
|
if (states.data == null || states.ref == null)
|
|
33
32
|
return;
|
|
@@ -46,36 +45,9 @@ export function ListPage(props) {
|
|
|
46
45
|
const rect = dimensions[0][2];
|
|
47
46
|
// Search data
|
|
48
47
|
const searchData = useSearchParamsWithCache(cacheKey);
|
|
49
|
-
const onInitLoad = (ref) => {
|
|
50
|
-
// Avoid repeatedly load from cache
|
|
51
|
-
if (initLoadedRef.current || !cacheKey)
|
|
52
|
-
return undefined;
|
|
53
|
-
// Cache data
|
|
54
|
-
const cacheData = GridUtils.getCacheData(cacheKey, cacheMinutes);
|
|
55
|
-
if (cacheData) {
|
|
56
|
-
const { rows, state } = cacheData;
|
|
57
|
-
GridUtils.mergeSearchData(state, searchData);
|
|
58
|
-
// Scroll position
|
|
59
|
-
const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
|
|
60
|
-
if (scrollData) {
|
|
61
|
-
const { scrollOffset } = JSON.parse(scrollData);
|
|
62
|
-
globalThis.setTimeout(() => ref.scrollTo(scrollOffset), 0);
|
|
63
|
-
}
|
|
64
|
-
// Update flag value
|
|
65
|
-
initLoadedRef.current = true;
|
|
66
|
-
// Return cached rows and state
|
|
67
|
-
return [rows, state];
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
};
|
|
71
|
-
const onListScroll = (props) => {
|
|
72
|
-
if (!cacheKey || !initLoadedRef.current)
|
|
73
|
-
return;
|
|
74
|
-
sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
|
|
75
|
-
};
|
|
76
48
|
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
77
49
|
// Layout
|
|
78
50
|
return (_jsx(CommonPage, { ...pageProps, scrollContainer: globalThis, children: _jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], sx: {
|
|
79
51
|
paddingBottom: pageProps.paddings
|
|
80
|
-
}, children: rect && rect.width > 100 && (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), _jsx(ScrollerListEx, { autoLoad: false, loadData: localLoadData,
|
|
52
|
+
}, children: rect && rect.width > 100 && (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), _jsx(ScrollerListEx, { autoLoad: false, loadData: localLoadData, mRef: refs, ...rest })] }) }));
|
|
81
53
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DataGridPageProps } from "./DataGridPageProps";
|
|
3
|
-
import type {
|
|
4
|
-
import { ListChildComponentProps } from "react-window";
|
|
3
|
+
import type { ScrollerListExItemSize, ScrollerListExProps } from "../ScrollerListEx";
|
|
5
4
|
import { GridMethodRef } from "@etsoo/react";
|
|
6
5
|
import type { OperationMessageHandlerAll } from "../messages/OperationMessageHandler";
|
|
7
6
|
/**
|
|
@@ -19,14 +18,10 @@ export type ResponsePageProps<T extends object, F> = DataGridPageProps<T, F> & {
|
|
|
19
18
|
* Min width to show Datagrid
|
|
20
19
|
*/
|
|
21
20
|
dataGridMinWidth?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Inner item renderer
|
|
24
|
-
*/
|
|
25
|
-
innerItemRenderer: (props: ScrollerListExInnerItemRendererProps<T>) => React.ReactNode;
|
|
26
21
|
/**
|
|
27
22
|
* Item renderer
|
|
28
23
|
*/
|
|
29
|
-
itemRenderer?:
|
|
24
|
+
itemRenderer?: ScrollerListExProps<T>["itemRenderer"];
|
|
30
25
|
/**
|
|
31
26
|
* Item size, a function indicates its a variable size list
|
|
32
27
|
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useSearchParamsWithCache } from "@etsoo/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { GridUtils } from "../GridUtils";
|
|
4
|
+
import { ExtendUtils } from "@etsoo/shared";
|
|
5
|
+
export function useGridCacheInitLoad(cacheKey, cacheMinutes) {
|
|
6
|
+
// Reference
|
|
7
|
+
const ref = React.useRef(null);
|
|
8
|
+
// Search data
|
|
9
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
10
|
+
// Avoid repeatedly load from cache
|
|
11
|
+
if (ref.current || !cacheKey)
|
|
12
|
+
return undefined;
|
|
13
|
+
// Cache data
|
|
14
|
+
const cacheData = GridUtils.getCacheData(cacheKey, cacheMinutes);
|
|
15
|
+
if (cacheData) {
|
|
16
|
+
const { rows, state } = cacheData;
|
|
17
|
+
GridUtils.mergeSearchData(state, searchData);
|
|
18
|
+
// Update flag value
|
|
19
|
+
ref.current = true;
|
|
20
|
+
return (ref) => {
|
|
21
|
+
// Scroll position
|
|
22
|
+
const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
|
|
23
|
+
if (scrollData) {
|
|
24
|
+
const data = JSON.parse(scrollData);
|
|
25
|
+
ExtendUtils.waitFor(() => ref.scrollToCell({
|
|
26
|
+
rowIndex: data.rowStartIndex,
|
|
27
|
+
columnIndex: data.columnStartIndex
|
|
28
|
+
}), 100);
|
|
29
|
+
}
|
|
30
|
+
// Return cached rows and state
|
|
31
|
+
return [rows, state];
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useSearchParamsWithCache } from "@etsoo/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { GridUtils } from "../GridUtils";
|
|
4
|
+
import { ExtendUtils } from "@etsoo/shared";
|
|
5
|
+
export function useListCacheInitLoad(cacheKey, cacheMinutes) {
|
|
6
|
+
// Reference
|
|
7
|
+
const ref = React.useRef(null);
|
|
8
|
+
// Search data
|
|
9
|
+
const searchData = useSearchParamsWithCache(cacheKey);
|
|
10
|
+
// Avoid repeatedly load from cache
|
|
11
|
+
if (ref.current || !cacheKey)
|
|
12
|
+
return undefined;
|
|
13
|
+
// Cache data
|
|
14
|
+
const cacheData = GridUtils.getCacheData(cacheKey, cacheMinutes);
|
|
15
|
+
if (cacheData) {
|
|
16
|
+
const { rows, state } = cacheData;
|
|
17
|
+
GridUtils.mergeSearchData(state, searchData);
|
|
18
|
+
// Update flag value
|
|
19
|
+
ref.current = true;
|
|
20
|
+
return (ref) => {
|
|
21
|
+
// Scroll position
|
|
22
|
+
const scrollData = sessionStorage.getItem(`${cacheKey}-scroll`);
|
|
23
|
+
if (scrollData) {
|
|
24
|
+
const data = JSON.parse(scrollData);
|
|
25
|
+
ExtendUtils.waitFor(() => ref.scrollToRow({ index: data.startIndex }), 100);
|
|
26
|
+
}
|
|
27
|
+
// Return cached rows and state
|
|
28
|
+
return [rows, state];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.72",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -40,23 +40,23 @@
|
|
|
40
40
|
"@dnd-kit/sortable": "^10.0.0",
|
|
41
41
|
"@emotion/react": "^11.14.0",
|
|
42
42
|
"@emotion/styled": "^11.14.1",
|
|
43
|
-
"@etsoo/appscript": "^1.6.
|
|
44
|
-
"@etsoo/notificationbase": "^1.1.
|
|
45
|
-
"@etsoo/react": "^1.8.
|
|
46
|
-
"@etsoo/shared": "^1.2.
|
|
47
|
-
"@mui/icons-material": "^7.3.
|
|
48
|
-
"@mui/material": "^7.3.
|
|
49
|
-
"@mui/x-data-grid": "^8.
|
|
43
|
+
"@etsoo/appscript": "^1.6.45",
|
|
44
|
+
"@etsoo/notificationbase": "^1.1.64",
|
|
45
|
+
"@etsoo/react": "^1.8.58",
|
|
46
|
+
"@etsoo/shared": "^1.2.76",
|
|
47
|
+
"@mui/icons-material": "^7.3.4",
|
|
48
|
+
"@mui/material": "^7.3.4",
|
|
49
|
+
"@mui/x-data-grid": "^8.13.1",
|
|
50
50
|
"chart.js": "^4.5.0",
|
|
51
51
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
52
|
-
"dompurify": "^3.2.
|
|
52
|
+
"dompurify": "^3.2.7",
|
|
53
53
|
"eventemitter3": "^5.0.1",
|
|
54
54
|
"pica": "^9.0.1",
|
|
55
55
|
"pulltorefreshjs": "^0.1.22",
|
|
56
|
-
"react": "^
|
|
56
|
+
"react": "^19.2.0",
|
|
57
57
|
"react-avatar-editor": "^13.0.2",
|
|
58
58
|
"react-chartjs-2": "^5.3.0",
|
|
59
|
-
"react-dom": "^
|
|
59
|
+
"react-dom": "^19.2.0",
|
|
60
60
|
"react-draggable": "^4.5.0",
|
|
61
61
|
"react-imask": "7.6.1"
|
|
62
62
|
},
|
|
@@ -67,23 +67,22 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@babel/cli": "^7.28.3",
|
|
70
|
-
"@babel/core": "^7.28.
|
|
70
|
+
"@babel/core": "^7.28.4",
|
|
71
71
|
"@babel/plugin-transform-runtime": "^7.28.3",
|
|
72
72
|
"@babel/preset-env": "^7.28.3",
|
|
73
73
|
"@babel/preset-react": "^7.27.1",
|
|
74
74
|
"@babel/preset-typescript": "^7.27.1",
|
|
75
|
-
"@babel/runtime-corejs3": "^7.28.
|
|
75
|
+
"@babel/runtime-corejs3": "^7.28.4",
|
|
76
76
|
"@testing-library/react": "^16.3.0",
|
|
77
77
|
"@types/pica": "^9.0.5",
|
|
78
78
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
79
|
-
"@types/react": "^
|
|
79
|
+
"@types/react": "^19.2.2",
|
|
80
80
|
"@types/react-avatar-editor": "^13.0.4",
|
|
81
|
-
"@types/react-dom": "^
|
|
81
|
+
"@types/react-dom": "^19.2.1",
|
|
82
82
|
"@types/react-input-mask": "^3.0.6",
|
|
83
|
-
"@
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"typescript": "^5.9.2",
|
|
83
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
84
|
+
"jsdom": "^27.0.0",
|
|
85
|
+
"typescript": "^5.9.3",
|
|
87
86
|
"vitest": "^3.2.4"
|
|
88
87
|
}
|
|
89
88
|
}
|
package/setupTests.ts
CHANGED
|
@@ -323,7 +323,7 @@ export function ButtonPopupCheckbox<D extends DnDItemType>(
|
|
|
323
323
|
}, [value]);
|
|
324
324
|
|
|
325
325
|
// Selected ids
|
|
326
|
-
const tempSelectedIds = React.useRef<D["id"][]>();
|
|
326
|
+
const tempSelectedIds = React.useRef<D["id"][]>(null);
|
|
327
327
|
|
|
328
328
|
// Click handler
|
|
329
329
|
const clickHandler = () => {
|
package/src/ButtonPopupRadio.tsx
CHANGED
|
@@ -287,7 +287,7 @@ export function ButtonPopupRadio<D extends DnDItemType>(
|
|
|
287
287
|
}, [value]);
|
|
288
288
|
|
|
289
289
|
// Selected id
|
|
290
|
-
const tempSelectedId = React.useRef<D["id"]>();
|
|
290
|
+
const tempSelectedId = React.useRef<D["id"]>(null);
|
|
291
291
|
|
|
292
292
|
// Click handler
|
|
293
293
|
const clickHandler = () => {
|