@etsoo/materialui 1.1.57 → 1.1.58
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/lib/ResponsibleContainer.d.ts +1 -0
- package/lib/pages/DataGridPage.d.ts +2 -2
- package/lib/pages/DataGridPage.js +9 -10
- package/lib/pages/DataGridPageProps.d.ts +6 -5
- package/lib/pages/FixedListPage.d.ts +4 -3
- package/lib/pages/FixedListPage.js +10 -11
- package/package.json +1 -1
- package/src/ResponsibleContainer.tsx +1 -0
- package/src/pages/DataGridPage.tsx +122 -124
- package/src/pages/DataGridPageProps.ts +18 -17
- package/src/pages/FixedListPage.tsx +124 -129
|
@@ -12,6 +12,7 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
12
12
|
/**
|
|
13
13
|
* Height will be deducted
|
|
14
14
|
* @param height Current calcuated height
|
|
15
|
+
* @param rect Current rect data
|
|
15
16
|
*/
|
|
16
17
|
adjustHeight?: (height: number, rect: DOMRect) => number;
|
|
17
18
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes, IdDefaultType } from
|
|
3
|
-
import { DataGridPageProps } from
|
|
2
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
3
|
+
import { DataGridPageProps } from "./DataGridPageProps";
|
|
4
4
|
/**
|
|
5
5
|
* DataGrid page
|
|
6
6
|
* @param props Props
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GridDataGet, useCombinedRefs, useDimensions } from
|
|
2
|
-
import { Box, Stack } from
|
|
3
|
-
import React from
|
|
4
|
-
import { DataGridEx } from
|
|
5
|
-
import { MUGlobal } from
|
|
6
|
-
import { SearchBar } from
|
|
7
|
-
import { CommonPage } from
|
|
1
|
+
import { GridDataGet, useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
2
|
+
import { Box, Stack } from "@mui/material";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { DataGridEx } from "../DataGridEx";
|
|
5
|
+
import { MUGlobal } from "../MUGlobal";
|
|
6
|
+
import { SearchBar } from "../SearchBar";
|
|
7
|
+
import { CommonPage } from "./CommonPage";
|
|
8
8
|
/**
|
|
9
9
|
* DataGrid page
|
|
10
10
|
* @param props Props
|
|
@@ -46,9 +46,8 @@ export function DataGridPage(props) {
|
|
|
46
46
|
const paddingBottom = parseFloat(style.paddingBottom);
|
|
47
47
|
if (!isNaN(paddingBottom))
|
|
48
48
|
gridHeight -= paddingBottom;
|
|
49
|
-
if (adjustHeight != null)
|
|
50
|
-
gridHeight -= adjustHeight(gridHeight);
|
|
51
|
-
}
|
|
49
|
+
if (adjustHeight != null)
|
|
50
|
+
gridHeight -= adjustHeight(gridHeight, rect);
|
|
52
51
|
if (gridHeight !== states.height)
|
|
53
52
|
setStates({ height: gridHeight });
|
|
54
53
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { DataTypes, IdDefaultType } from
|
|
2
|
-
import { DataGridExProps } from
|
|
3
|
-
import { SearchPageProps } from
|
|
1
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
2
|
+
import { DataGridExProps } from "../DataGridEx";
|
|
3
|
+
import { SearchPageProps } from "./SearchPageProps";
|
|
4
4
|
/**
|
|
5
5
|
* DataGrid page props
|
|
6
6
|
*/
|
|
7
|
-
export type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = SearchPageProps<T, F> & Omit<DataGridExProps<T, D>,
|
|
7
|
+
export type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = SearchPageProps<T, F> & Omit<DataGridExProps<T, D>, "loadData" | "height"> & {
|
|
8
8
|
/**
|
|
9
9
|
* Height will be deducted
|
|
10
10
|
* @param height Current calcuated height
|
|
11
|
+
* @param rect Current rect data
|
|
11
12
|
*/
|
|
12
|
-
adjustHeight?: (height: number) => number;
|
|
13
|
+
adjustHeight?: (height: number, rect: DOMRect) => number;
|
|
13
14
|
/**
|
|
14
15
|
* Grid height
|
|
15
16
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes, IdDefaultType } from
|
|
3
|
-
import { ListPageProps } from
|
|
2
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
3
|
+
import { ListPageProps } from "./ListPageProps";
|
|
4
4
|
/**
|
|
5
5
|
* Fixed height list page
|
|
6
6
|
* @param props Props
|
|
@@ -10,6 +10,7 @@ export declare function FixedListPage<T extends object, F extends DataTypes.Basi
|
|
|
10
10
|
/**
|
|
11
11
|
* Height will be deducted
|
|
12
12
|
* @param height Current calcuated height
|
|
13
|
+
* @param rect Current rect data
|
|
13
14
|
*/
|
|
14
|
-
adjustHeight?: (height: number) => number;
|
|
15
|
+
adjustHeight?: (height: number, rect: DOMRect) => number;
|
|
15
16
|
}): JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GridDataGet, useCombinedRefs, useDimensions } from
|
|
2
|
-
import { Box, Stack } from
|
|
3
|
-
import React from
|
|
4
|
-
import { MUGlobal } from
|
|
5
|
-
import { ScrollerListEx } from
|
|
6
|
-
import { SearchBar } from
|
|
7
|
-
import { CommonPage } from
|
|
1
|
+
import { GridDataGet, useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
2
|
+
import { Box, Stack } from "@mui/material";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { MUGlobal } from "../MUGlobal";
|
|
5
|
+
import { ScrollerListEx } from "../ScrollerListEx";
|
|
6
|
+
import { SearchBar } from "../SearchBar";
|
|
7
|
+
import { CommonPage } from "./CommonPage";
|
|
8
8
|
/**
|
|
9
9
|
* Fixed height list page
|
|
10
10
|
* @param props Props
|
|
@@ -48,11 +48,10 @@ export function FixedListPage(props) {
|
|
|
48
48
|
if (rect != null && rect.height > 50) {
|
|
49
49
|
let height = document.documentElement.clientHeight -
|
|
50
50
|
Math.round(rect.top + rect.height + 1);
|
|
51
|
-
if (adjustHeight != null)
|
|
52
|
-
height -= adjustHeight(height);
|
|
53
|
-
}
|
|
51
|
+
if (adjustHeight != null)
|
|
52
|
+
height -= adjustHeight(height, rect);
|
|
54
53
|
return (React.createElement(Box, { id: "list-container", sx: {
|
|
55
|
-
height: height +
|
|
54
|
+
height: height + "px"
|
|
56
55
|
} },
|
|
57
56
|
React.createElement(ScrollerListEx, { autoLoad: false, height: height, loadData: localLoadData, mRef: refs, oRef: (element) => {
|
|
58
57
|
if (element != null)
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import { DataTypes, IdDefaultType } from
|
|
9
|
-
import { Box, Stack } from
|
|
10
|
-
import React from
|
|
11
|
-
import { DataGridEx } from
|
|
12
|
-
import { MUGlobal } from
|
|
13
|
-
import { SearchBar } from
|
|
14
|
-
import { CommonPage } from
|
|
15
|
-
import { DataGridPageProps } from
|
|
2
|
+
GridDataGet,
|
|
3
|
+
GridLoadDataProps,
|
|
4
|
+
ScrollerGridForwardRef,
|
|
5
|
+
useCombinedRefs,
|
|
6
|
+
useDimensions
|
|
7
|
+
} from "@etsoo/react";
|
|
8
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
9
|
+
import { Box, Stack } from "@mui/material";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { DataGridEx } from "../DataGridEx";
|
|
12
|
+
import { MUGlobal } from "../MUGlobal";
|
|
13
|
+
import { SearchBar } from "../SearchBar";
|
|
14
|
+
import { CommonPage } from "./CommonPage";
|
|
15
|
+
import { DataGridPageProps } from "./DataGridPageProps";
|
|
16
16
|
|
|
17
17
|
interface LocalStates<T> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
data?: FormData;
|
|
19
|
+
element?: HTMLElement;
|
|
20
|
+
height?: number;
|
|
21
|
+
ref?: ScrollerGridForwardRef<T>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -27,114 +27,112 @@ interface LocalStates<T> {
|
|
|
27
27
|
* @returns Component
|
|
28
28
|
*/
|
|
29
29
|
export function DataGridPage<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
T extends object,
|
|
31
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
32
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
33
33
|
>(props: DataGridPageProps<T, F, D>) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
34
|
+
// Destruct
|
|
35
|
+
const {
|
|
36
|
+
adjustHeight,
|
|
37
|
+
fields,
|
|
38
|
+
fieldTemplate,
|
|
39
|
+
height,
|
|
40
|
+
loadData,
|
|
41
|
+
mRef,
|
|
42
|
+
sizeReadyMiliseconds = 100,
|
|
43
|
+
pageProps = {},
|
|
44
|
+
...rest
|
|
45
|
+
} = props;
|
|
46
|
+
|
|
47
|
+
pageProps.paddings ??= MUGlobal.pagePaddings;
|
|
48
|
+
|
|
49
|
+
// States
|
|
50
|
+
const [states, setStates] = React.useReducer(
|
|
51
|
+
(currentState: LocalStates<T>, newState: Partial<LocalStates<T>>) => {
|
|
52
|
+
return { ...currentState, ...newState };
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
height
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const refs = useCombinedRefs<ScrollerGridForwardRef<T>>(
|
|
60
|
+
mRef,
|
|
61
|
+
(ref: ScrollerGridForwardRef<T> | null | undefined) => {
|
|
62
|
+
if (ref == null) return;
|
|
63
|
+
states.ref = ref;
|
|
64
|
+
//setStates({ ref });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// On submit callback
|
|
69
|
+
const onSubmit = (data: FormData, _reset: boolean) => {
|
|
70
|
+
setStates({ data });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const localLoadData = (props: GridLoadDataProps) => {
|
|
74
|
+
const data = GridDataGet(props, fieldTemplate);
|
|
75
|
+
return loadData(data);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Watch container
|
|
79
|
+
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
80
|
+
const rect = dimensions[0][2];
|
|
81
|
+
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
if (rect != null && rect.height > 50 && height == null) {
|
|
84
|
+
let gridHeight =
|
|
85
|
+
document.documentElement.clientHeight -
|
|
86
|
+
Math.round(rect.top + rect.height + 1);
|
|
87
|
+
|
|
88
|
+
const style = window.getComputedStyle(dimensions[0][1]!);
|
|
89
|
+
const paddingBottom = parseFloat(style.paddingBottom);
|
|
90
|
+
if (!isNaN(paddingBottom)) gridHeight -= paddingBottom;
|
|
91
|
+
|
|
92
|
+
if (adjustHeight != null) gridHeight -= adjustHeight(gridHeight, rect);
|
|
93
|
+
|
|
94
|
+
if (gridHeight !== states.height) setStates({ height: gridHeight });
|
|
95
|
+
}
|
|
96
|
+
}, [rect]);
|
|
97
|
+
|
|
98
|
+
const list = React.useMemo(() => {
|
|
99
|
+
const gridHeight = states.height;
|
|
100
|
+
if (gridHeight == null) return;
|
|
67
101
|
|
|
68
|
-
// On submit callback
|
|
69
|
-
const onSubmit = (data: FormData, _reset: boolean) => {
|
|
70
|
-
setStates({ data });
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const localLoadData = (props: GridLoadDataProps) => {
|
|
74
|
-
const data = GridDataGet(props, fieldTemplate);
|
|
75
|
-
return loadData(data);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// Watch container
|
|
79
|
-
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
80
|
-
const rect = dimensions[0][2];
|
|
81
|
-
|
|
82
|
-
React.useEffect(() => {
|
|
83
|
-
if (rect != null && rect.height > 50 && height == null) {
|
|
84
|
-
let gridHeight =
|
|
85
|
-
document.documentElement.clientHeight -
|
|
86
|
-
Math.round(rect.top + rect.height + 1);
|
|
87
|
-
|
|
88
|
-
const style = window.getComputedStyle(dimensions[0][1]!);
|
|
89
|
-
const paddingBottom = parseFloat(style.paddingBottom);
|
|
90
|
-
if (!isNaN(paddingBottom)) gridHeight -= paddingBottom;
|
|
91
|
-
|
|
92
|
-
if (adjustHeight != null) {
|
|
93
|
-
gridHeight -= adjustHeight(gridHeight);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (gridHeight !== states.height) setStates({ height: gridHeight });
|
|
97
|
-
}
|
|
98
|
-
}, [rect]);
|
|
99
|
-
|
|
100
|
-
const list = React.useMemo(() => {
|
|
101
|
-
const gridHeight = states.height;
|
|
102
|
-
if (gridHeight == null) return;
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<DataGridEx<T, D>
|
|
106
|
-
autoLoad={false}
|
|
107
|
-
height={gridHeight}
|
|
108
|
-
loadData={localLoadData}
|
|
109
|
-
mRef={refs}
|
|
110
|
-
outerRef={(element?: HTMLDivElement) => {
|
|
111
|
-
if (element != null) setStates({ element });
|
|
112
|
-
}}
|
|
113
|
-
{...rest}
|
|
114
|
-
/>
|
|
115
|
-
);
|
|
116
|
-
}, [states.height]);
|
|
117
|
-
|
|
118
|
-
const { ref, data } = states;
|
|
119
|
-
React.useEffect(() => {
|
|
120
|
-
if (ref == null || data == null) return;
|
|
121
|
-
ref.reset({ data });
|
|
122
|
-
}, [ref, data]);
|
|
123
|
-
|
|
124
|
-
// Layout
|
|
125
102
|
return (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{list}
|
|
137
|
-
</Stack>
|
|
138
|
-
</CommonPage>
|
|
103
|
+
<DataGridEx<T, D>
|
|
104
|
+
autoLoad={false}
|
|
105
|
+
height={gridHeight}
|
|
106
|
+
loadData={localLoadData}
|
|
107
|
+
mRef={refs}
|
|
108
|
+
outerRef={(element?: HTMLDivElement) => {
|
|
109
|
+
if (element != null) setStates({ element });
|
|
110
|
+
}}
|
|
111
|
+
{...rest}
|
|
112
|
+
/>
|
|
139
113
|
);
|
|
114
|
+
}, [states.height]);
|
|
115
|
+
|
|
116
|
+
const { ref, data } = states;
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
if (ref == null || data == null) return;
|
|
119
|
+
ref.reset({ data });
|
|
120
|
+
}, [ref, data]);
|
|
121
|
+
|
|
122
|
+
// Layout
|
|
123
|
+
return (
|
|
124
|
+
<CommonPage {...pageProps} scrollContainer={states.element}>
|
|
125
|
+
<Stack>
|
|
126
|
+
<Box
|
|
127
|
+
ref={dimensions[0][0]}
|
|
128
|
+
sx={{
|
|
129
|
+
paddingBottom: pageProps.paddings
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<SearchBar fields={fields} onSubmit={onSubmit} />
|
|
133
|
+
</Box>
|
|
134
|
+
{list}
|
|
135
|
+
</Stack>
|
|
136
|
+
</CommonPage>
|
|
137
|
+
);
|
|
140
138
|
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { DataTypes, IdDefaultType } from
|
|
2
|
-
import { DataGridExProps } from
|
|
3
|
-
import { SearchPageProps } from
|
|
1
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
2
|
+
import { DataGridExProps } from "../DataGridEx";
|
|
3
|
+
import { SearchPageProps } from "./SearchPageProps";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* DataGrid page props
|
|
7
7
|
*/
|
|
8
8
|
export type DataGridPageProps<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
T extends object,
|
|
10
|
+
F extends DataTypes.BasicTemplate,
|
|
11
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
12
12
|
> = SearchPageProps<T, F> &
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
Omit<DataGridExProps<T, D>, "loadData" | "height"> & {
|
|
14
|
+
/**
|
|
15
|
+
* Height will be deducted
|
|
16
|
+
* @param height Current calcuated height
|
|
17
|
+
* @param rect Current rect data
|
|
18
|
+
*/
|
|
19
|
+
adjustHeight?: (height: number, rect: DOMRect) => number;
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Grid height
|
|
23
|
+
*/
|
|
24
|
+
height?: number;
|
|
25
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import { DataTypes, IdDefaultType } from
|
|
9
|
-
import { Box, Stack } from
|
|
10
|
-
import React from
|
|
11
|
-
import { MUGlobal } from
|
|
12
|
-
import { ScrollerListEx } from
|
|
13
|
-
import { SearchBar } from
|
|
14
|
-
import { CommonPage } from
|
|
15
|
-
import { ListPageProps } from
|
|
2
|
+
GridDataGet,
|
|
3
|
+
GridLoadDataProps,
|
|
4
|
+
ScrollerListForwardRef,
|
|
5
|
+
useCombinedRefs,
|
|
6
|
+
useDimensions
|
|
7
|
+
} from "@etsoo/react";
|
|
8
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
9
|
+
import { Box, Stack } from "@mui/material";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { MUGlobal } from "../MUGlobal";
|
|
12
|
+
import { ScrollerListEx } from "../ScrollerListEx";
|
|
13
|
+
import { SearchBar } from "../SearchBar";
|
|
14
|
+
import { CommonPage } from "./CommonPage";
|
|
15
|
+
import { ListPageProps } from "./ListPageProps";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Fixed height list page
|
|
@@ -20,122 +20,117 @@ import { ListPageProps } from './ListPageProps';
|
|
|
20
20
|
* @returns Component
|
|
21
21
|
*/
|
|
22
22
|
export function FixedListPage<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
T extends object,
|
|
24
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
25
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
26
26
|
>(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
props: ListPageProps<T, F, D> & {
|
|
28
|
+
/**
|
|
29
|
+
* Height will be deducted
|
|
30
|
+
* @param height Current calcuated height
|
|
31
|
+
* @param rect Current rect data
|
|
32
|
+
*/
|
|
33
|
+
adjustHeight?: (height: number, rect: DOMRect) => number;
|
|
34
|
+
}
|
|
34
35
|
) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
height: height + 'px'
|
|
107
|
-
}}
|
|
108
|
-
>
|
|
109
|
-
<ScrollerListEx<T, D>
|
|
110
|
-
autoLoad={false}
|
|
111
|
-
height={height}
|
|
112
|
-
loadData={localLoadData}
|
|
113
|
-
mRef={refs}
|
|
114
|
-
oRef={(element) => {
|
|
115
|
-
if (element != null) updateScrollContainer(element);
|
|
116
|
-
}}
|
|
117
|
-
{...rest}
|
|
118
|
-
/>
|
|
119
|
-
</Box>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}, [rect]);
|
|
123
|
-
|
|
124
|
-
const { paddings, ...pageRest } = pageProps;
|
|
125
|
-
|
|
126
|
-
// Layout
|
|
127
|
-
return (
|
|
128
|
-
<CommonPage
|
|
129
|
-
{...pageRest}
|
|
130
|
-
paddings={{}}
|
|
131
|
-
scrollContainer={scrollContainer}
|
|
36
|
+
// Destruct
|
|
37
|
+
const {
|
|
38
|
+
adjustHeight,
|
|
39
|
+
fields,
|
|
40
|
+
fieldTemplate,
|
|
41
|
+
loadData,
|
|
42
|
+
mRef,
|
|
43
|
+
sizeReadyMiliseconds = 0,
|
|
44
|
+
pageProps = {},
|
|
45
|
+
...rest
|
|
46
|
+
} = props;
|
|
47
|
+
|
|
48
|
+
pageProps.paddings ??= MUGlobal.pagePaddings;
|
|
49
|
+
|
|
50
|
+
// States
|
|
51
|
+
const [states] = React.useState<{
|
|
52
|
+
data?: FormData;
|
|
53
|
+
ref?: ScrollerListForwardRef<T>;
|
|
54
|
+
}>({});
|
|
55
|
+
|
|
56
|
+
// Scroll container
|
|
57
|
+
const [scrollContainer, updateScrollContainer] = React.useState<
|
|
58
|
+
HTMLElement | undefined
|
|
59
|
+
>();
|
|
60
|
+
|
|
61
|
+
const refs = useCombinedRefs(
|
|
62
|
+
mRef,
|
|
63
|
+
(ref: ScrollerListForwardRef<T> | null | undefined) => {
|
|
64
|
+
if (ref == null) return;
|
|
65
|
+
|
|
66
|
+
const first = states.ref == null;
|
|
67
|
+
|
|
68
|
+
states.ref = ref;
|
|
69
|
+
|
|
70
|
+
if (first) reset();
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const reset = () => {
|
|
75
|
+
if (states.data == null || states.ref == null) return;
|
|
76
|
+
states.ref.reset({ data: states.data });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// On submit callback
|
|
80
|
+
const onSubmit = (data: FormData, _reset: boolean) => {
|
|
81
|
+
states.data = data;
|
|
82
|
+
reset();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const localLoadData = (props: GridLoadDataProps) => {
|
|
86
|
+
const data = GridDataGet(props, fieldTemplate);
|
|
87
|
+
return loadData(data);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Watch container
|
|
91
|
+
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
92
|
+
const rect = dimensions[0][2];
|
|
93
|
+
const list = React.useMemo(() => {
|
|
94
|
+
if (rect != null && rect.height > 50) {
|
|
95
|
+
let height =
|
|
96
|
+
document.documentElement.clientHeight -
|
|
97
|
+
Math.round(rect.top + rect.height + 1);
|
|
98
|
+
|
|
99
|
+
if (adjustHeight != null) height -= adjustHeight(height, rect);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Box
|
|
103
|
+
id="list-container"
|
|
104
|
+
sx={{
|
|
105
|
+
height: height + "px"
|
|
106
|
+
}}
|
|
132
107
|
>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
108
|
+
<ScrollerListEx<T, D>
|
|
109
|
+
autoLoad={false}
|
|
110
|
+
height={height}
|
|
111
|
+
loadData={localLoadData}
|
|
112
|
+
mRef={refs}
|
|
113
|
+
oRef={(element) => {
|
|
114
|
+
if (element != null) updateScrollContainer(element);
|
|
115
|
+
}}
|
|
116
|
+
{...rest}
|
|
117
|
+
/>
|
|
118
|
+
</Box>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}, [rect]);
|
|
122
|
+
|
|
123
|
+
const { paddings, ...pageRest } = pageProps;
|
|
124
|
+
|
|
125
|
+
// Layout
|
|
126
|
+
return (
|
|
127
|
+
<CommonPage {...pageRest} paddings={{}} scrollContainer={scrollContainer}>
|
|
128
|
+
<Stack>
|
|
129
|
+
<Box ref={dimensions[0][0]} sx={{ padding: paddings }}>
|
|
130
|
+
<SearchBar fields={fields} onSubmit={onSubmit} />
|
|
131
|
+
</Box>
|
|
132
|
+
{list}
|
|
133
|
+
</Stack>
|
|
134
|
+
</CommonPage>
|
|
135
|
+
);
|
|
141
136
|
}
|