@etsoo/materialui 1.4.44 → 1.4.46
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/GridUtils.d.ts +3 -2
- package/lib/GridUtils.js +3 -2
- package/lib/ListMoreDisplay.d.ts +3 -4
- package/lib/ResponsibleContainer.d.ts +10 -11
- package/lib/ResponsibleContainer.js +19 -25
- package/lib/pages/DataGridPage.d.ts +1 -2
- package/lib/pages/DataGridPage.js +1 -1
- package/lib/pages/DataGridPageProps.d.ts +1 -2
- package/lib/pages/FixedListPage.d.ts +1 -2
- package/lib/pages/FixedListPage.js +1 -1
- package/lib/pages/ListPage.d.ts +2 -3
- package/lib/pages/ListPage.js +1 -1
- package/lib/pages/ResponsivePage.d.ts +2 -3
- package/lib/pages/SearchPageProps.d.ts +5 -6
- package/lib/pages/TablePage.d.ts +2 -2
- package/lib/pages/TablePage.js +1 -1
- package/package.json +11 -11
- package/src/GridUtils.ts +8 -8
- package/src/ListMoreDisplay.tsx +6 -9
- package/src/ResponsibleContainer.tsx +38 -43
- package/src/pages/DataGridPage.tsx +3 -7
- package/src/pages/DataGridPageProps.ts +1 -5
- package/src/pages/FixedListPage.tsx +4 -8
- package/src/pages/ListPage.tsx +5 -11
- package/src/pages/ResponsivePage.tsx +3 -10
- package/src/pages/SearchPageProps.ts +10 -9
- package/src/pages/TablePage.tsx +4 -6
package/lib/GridUtils.d.ts
CHANGED
|
@@ -10,9 +10,10 @@ export declare namespace GridUtils {
|
|
|
10
10
|
* @param props Props
|
|
11
11
|
* @param template Field template
|
|
12
12
|
* @param cacheKey Cache key
|
|
13
|
+
* @param keepSource Keep source or not
|
|
13
14
|
* @returns Request data
|
|
14
15
|
*/
|
|
15
|
-
function createLoader
|
|
16
|
+
function createLoader(props: GridLoadDataProps, template?: object, cacheKey?: string, keepSource?: boolean): {
|
|
16
17
|
queryPaging: import("@etsoo/appscript").QueryPagingData;
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
@@ -27,7 +28,7 @@ export declare namespace GridUtils {
|
|
|
27
28
|
* @param cacheKey Cache key
|
|
28
29
|
* @returns Result
|
|
29
30
|
*/
|
|
30
|
-
function getSearchData
|
|
31
|
+
function getSearchData(cacheKey?: string): any;
|
|
31
32
|
/**
|
|
32
33
|
* Get update rows handler
|
|
33
34
|
* @param cacheKey Cache key
|
package/lib/GridUtils.js
CHANGED
|
@@ -9,11 +9,12 @@ export var GridUtils;
|
|
|
9
9
|
* @param props Props
|
|
10
10
|
* @param template Field template
|
|
11
11
|
* @param cacheKey Cache key
|
|
12
|
+
* @param keepSource Keep source or not
|
|
12
13
|
* @returns Request data
|
|
13
14
|
*/
|
|
14
|
-
function createLoader(props, template, cacheKey) {
|
|
15
|
+
function createLoader(props, template, cacheKey, keepSource) {
|
|
15
16
|
const { data, ...rest } = props;
|
|
16
|
-
const formData = GridDataGetData(data, template);
|
|
17
|
+
const formData = GridDataGetData(data, template, keepSource);
|
|
17
18
|
if (cacheKey)
|
|
18
19
|
sessionStorage.setItem(`${cacheKey}-searchbar`, JSON.stringify(formData));
|
|
19
20
|
return { ...formData, ...rest };
|
package/lib/ListMoreDisplay.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import { CardProps } from "@mui/material";
|
|
3
2
|
import React from "react";
|
|
4
3
|
import { GridData, GridLoader } from "@etsoo/react";
|
|
5
4
|
/**
|
|
6
5
|
* ListMoreDisplay props
|
|
7
6
|
*/
|
|
8
|
-
export interface ListMoreDisplayProps<T extends object
|
|
7
|
+
export interface ListMoreDisplayProps<T extends object> extends Omit<CardProps, "children">, GridLoader<T> {
|
|
9
8
|
/**
|
|
10
9
|
* Batch size to load
|
|
11
10
|
*/
|
|
@@ -17,7 +16,7 @@ export interface ListMoreDisplayProps<T extends object, F extends DataTypes.Basi
|
|
|
17
16
|
/**
|
|
18
17
|
* Search field template
|
|
19
18
|
*/
|
|
20
|
-
fieldTemplate
|
|
19
|
+
readonly fieldTemplate: object;
|
|
21
20
|
/**
|
|
22
21
|
* Header renderer
|
|
23
22
|
*/
|
|
@@ -36,4 +35,4 @@ export interface ListMoreDisplayProps<T extends object, F extends DataTypes.Basi
|
|
|
36
35
|
* @param props Props
|
|
37
36
|
* @returns Component
|
|
38
37
|
*/
|
|
39
|
-
export declare function ListMoreDisplay<T extends object
|
|
38
|
+
export declare function ListMoreDisplay<T extends object>(props: ListMoreDisplayProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import { SxProps, Theme } from "@mui/material";
|
|
3
2
|
import React from "react";
|
|
4
3
|
import { ListChildComponentProps } from "react-window";
|
|
5
|
-
import { GridColumn, GridJsonData, GridMethodRef } from "@etsoo/react";
|
|
4
|
+
import { GridColumn, GridJsonData, GridMethodRef, GridTemplateType } from "@etsoo/react";
|
|
6
5
|
import { DataGridExProps } from "./DataGridEx";
|
|
7
6
|
import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from "./ScrollerListEx";
|
|
8
7
|
/**
|
|
9
8
|
* ResponsibleContainer props
|
|
10
9
|
*/
|
|
11
|
-
export type ResponsibleContainerProps<T extends object
|
|
10
|
+
export type ResponsibleContainerProps<T extends object> = Omit<DataGridExProps<T>, "height" | "itemKey" | "loadData" | "mRef" | "onScroll" | "onItemsRendered" | "onInitLoad" | "onUpdateRows"> & {
|
|
12
11
|
/**
|
|
13
12
|
* Height will be deducted
|
|
14
13
|
* @param height Current calcuated height
|
|
@@ -30,18 +29,14 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
30
29
|
* Container box SX (dataGrid determines the case)
|
|
31
30
|
*/
|
|
32
31
|
containerBoxSx?: (paddings: number | Record<string, string | number>, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
|
|
33
|
-
/**
|
|
34
|
-
* Min width to show Datagrid
|
|
35
|
-
*/
|
|
36
|
-
dataGridMinWidth?: number;
|
|
37
32
|
/**
|
|
38
33
|
* Search fields
|
|
39
34
|
*/
|
|
40
|
-
fields?: React.ReactElement[] | ((data:
|
|
35
|
+
fields?: React.ReactElement[] | ((data: GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>) => React.ReactElement[]);
|
|
41
36
|
/**
|
|
42
37
|
* Search field template
|
|
43
38
|
*/
|
|
44
|
-
fieldTemplate
|
|
39
|
+
fieldTemplate: object;
|
|
45
40
|
/**
|
|
46
41
|
* Grid height
|
|
47
42
|
*/
|
|
@@ -61,7 +56,7 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
61
56
|
/**
|
|
62
57
|
* Load data callback
|
|
63
58
|
*/
|
|
64
|
-
loadData: (data: GridJsonData &
|
|
59
|
+
loadData: (data: GridJsonData & GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
|
|
65
60
|
/**
|
|
66
61
|
* Methods
|
|
67
62
|
*/
|
|
@@ -90,10 +85,14 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
90
85
|
* SearchBar height
|
|
91
86
|
*/
|
|
92
87
|
searchBarHeight?: number;
|
|
88
|
+
/**
|
|
89
|
+
* SearchBar bottom padding
|
|
90
|
+
*/
|
|
91
|
+
searchBarBottom?: number;
|
|
93
92
|
};
|
|
94
93
|
/**
|
|
95
94
|
* Responsible container
|
|
96
95
|
* @param props Props
|
|
97
96
|
* @returns Layout
|
|
98
97
|
*/
|
|
99
|
-
export declare function ResponsibleContainer<T extends object
|
|
98
|
+
export declare function ResponsibleContainer<T extends object>(props: ResponsibleContainerProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Stack } from "@mui/material";
|
|
2
|
+
import { Box, Stack, useMediaQuery } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { ReactUtils, useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
5
|
-
import { DataGridEx
|
|
5
|
+
import { DataGridEx } from "./DataGridEx";
|
|
6
6
|
import { MUGlobal } from "./MUGlobal";
|
|
7
7
|
import { PullToRefreshUI } from "./PullToRefreshUI";
|
|
8
8
|
import { ScrollerListEx } from "./ScrollerListEx";
|
|
@@ -24,7 +24,7 @@ function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
|
|
|
24
24
|
*/
|
|
25
25
|
export function ResponsibleContainer(props) {
|
|
26
26
|
// Destruct
|
|
27
|
-
const { adjustHeight, adjustFabHeight, cacheKey, cacheMinutes = 15, columns, containerBoxSx = defaultContainerBoxSx,
|
|
27
|
+
const { adjustHeight, adjustFabHeight, cacheKey, cacheMinutes = 15, columns, containerBoxSx = defaultContainerBoxSx, elementReady, fields, fieldTemplate, height, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, searchBarHeight = 45.6, searchBarBottom = 8, ...rest } = props;
|
|
28
28
|
// Labels
|
|
29
29
|
const labels = Labels.CommonPage;
|
|
30
30
|
// Refs
|
|
@@ -35,6 +35,8 @@ export function ResponsibleContainer(props) {
|
|
|
35
35
|
return;
|
|
36
36
|
state.ref = ref;
|
|
37
37
|
});
|
|
38
|
+
// Screen size detection
|
|
39
|
+
const showDataGrid = useMediaQuery("(min-width:600px)");
|
|
38
40
|
// Update mounted state
|
|
39
41
|
React.useEffect(() => {
|
|
40
42
|
return () => {
|
|
@@ -46,7 +48,7 @@ export function ResponsibleContainer(props) {
|
|
|
46
48
|
// Load data
|
|
47
49
|
const localLoadData = (props, lastItem) => {
|
|
48
50
|
state.mounted = true;
|
|
49
|
-
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey), lastItem);
|
|
51
|
+
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
50
52
|
};
|
|
51
53
|
// Search data
|
|
52
54
|
const searchData = GridUtils.getSearchData(cacheKey);
|
|
@@ -114,14 +116,10 @@ export function ResponsibleContainer(props) {
|
|
|
114
116
|
// Rect
|
|
115
117
|
const rect = dimensions[0][2];
|
|
116
118
|
// Create list
|
|
117
|
-
const
|
|
119
|
+
const list = (() => {
|
|
118
120
|
// No layout
|
|
119
121
|
if (rect == null)
|
|
120
122
|
return [null, undefined];
|
|
121
|
-
// Width
|
|
122
|
-
const width = rect.width;
|
|
123
|
-
// Show DataGrid or List dependng on width
|
|
124
|
-
const showDataGrid = width >= dataGridMinWidth;
|
|
125
123
|
// Height
|
|
126
124
|
let heightLocal;
|
|
127
125
|
if (height != null) {
|
|
@@ -134,7 +132,7 @@ export function ResponsibleContainer(props) {
|
|
|
134
132
|
const style = window.getComputedStyle(dimensions[0][1]);
|
|
135
133
|
const boxMargin = parseFloat(style.marginBottom);
|
|
136
134
|
if (!isNaN(boxMargin))
|
|
137
|
-
heightLocal -=
|
|
135
|
+
heightLocal -= boxMargin;
|
|
138
136
|
if (adjustHeight != null)
|
|
139
137
|
heightLocal -=
|
|
140
138
|
typeof adjustHeight === "number"
|
|
@@ -146,13 +144,10 @@ export function ResponsibleContainer(props) {
|
|
|
146
144
|
if (showDataGrid) {
|
|
147
145
|
// Delete
|
|
148
146
|
delete rest.itemRenderer;
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}, onScroll: onGridScroll, columns: columns, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, ...rest }) }),
|
|
154
|
-
true
|
|
155
|
-
];
|
|
147
|
+
return (_jsx(Box, { className: "DataGridBox", children: _jsx(DataGridEx, { autoLoad: !hasFields, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), outerRef: (element) => {
|
|
148
|
+
if (element != null && elementReady)
|
|
149
|
+
elementReady(element, true);
|
|
150
|
+
}, onScroll: onGridScroll, columns: columns, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, ...rest }) }));
|
|
156
151
|
}
|
|
157
152
|
// Delete
|
|
158
153
|
delete rest.checkable;
|
|
@@ -163,13 +158,10 @@ export function ResponsibleContainer(props) {
|
|
|
163
158
|
delete rest.hideFooter;
|
|
164
159
|
delete rest.hoverColor;
|
|
165
160
|
delete rest.selectable;
|
|
166
|
-
return
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}, onScroll: onListScroll, ...rest }) }),
|
|
171
|
-
false
|
|
172
|
-
];
|
|
161
|
+
return (_jsx(Box, { className: "ListBox", sx: { height: heightLocal }, children: _jsx(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, mRef: mRefs, onClick: (event, data) => quickAction && ReactUtils.isSafeClick(event) && quickAction(data), oRef: (element) => {
|
|
162
|
+
if (element != null && elementReady)
|
|
163
|
+
elementReady(element, false);
|
|
164
|
+
}, onScroll: onListScroll, ...rest }) }));
|
|
173
165
|
})();
|
|
174
166
|
const searchBar = React.useMemo(() => {
|
|
175
167
|
if (!hasFields ||
|
|
@@ -189,7 +181,9 @@ export function ResponsibleContainer(props) {
|
|
|
189
181
|
// Layout
|
|
190
182
|
return (_jsxs(Box, { sx: containerBoxSx == null
|
|
191
183
|
? undefined
|
|
192
|
-
: containerBoxSx(paddings, hasFields, showDataGrid), children: [_jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], className: "SearchBox", sx: {
|
|
184
|
+
: containerBoxSx(paddings, hasFields, showDataGrid), children: [_jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], className: "SearchBox", sx: {
|
|
185
|
+
height: hasFields ? searchBarHeight : 0
|
|
186
|
+
}, marginBottom: hasFields ? `${searchBarBottom}px!important` : undefined, children: searchBar }), list] }), pullToRefresh && pullContainer && (_jsx(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => state.ref?.reset(), shouldPullToRefresh: () => {
|
|
193
187
|
const container = document.querySelector(pullContainer);
|
|
194
188
|
return !container?.scrollTop;
|
|
195
189
|
} }))] }));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import type { DataGridPageProps } from "./DataGridPageProps";
|
|
3
2
|
/**
|
|
4
3
|
* DataGrid page
|
|
5
4
|
* @param props Props
|
|
6
5
|
* @returns Component
|
|
7
6
|
*/
|
|
8
|
-
export declare function DataGridPage<T extends object
|
|
7
|
+
export declare function DataGridPage<T extends object>(props: DataGridPageProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -34,7 +34,7 @@ export function DataGridPage(props) {
|
|
|
34
34
|
setStates({ data });
|
|
35
35
|
};
|
|
36
36
|
const localLoadData = (props, lastItem) => {
|
|
37
|
-
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey), lastItem);
|
|
37
|
+
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
38
38
|
};
|
|
39
39
|
// Search data
|
|
40
40
|
const searchData = GridUtils.getSearchData(cacheKey);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import type { DataGridExProps } from "../DataGridEx";
|
|
3
2
|
import type { SearchPageProps } from "./SearchPageProps";
|
|
4
3
|
/**
|
|
5
4
|
* DataGrid page props
|
|
6
5
|
*/
|
|
7
|
-
export type DataGridPageProps<T extends object
|
|
6
|
+
export type DataGridPageProps<T extends object> = SearchPageProps<T> & Omit<DataGridExProps<T>, "loadData"> & {
|
|
8
7
|
/**
|
|
9
8
|
* Height will be deducted
|
|
10
9
|
* @param height Current calcuated height
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import type { ListPageProps } from "./ListPage";
|
|
3
2
|
/**
|
|
4
3
|
* Fixed height list page
|
|
5
4
|
* @param props Props
|
|
6
5
|
* @returns Component
|
|
7
6
|
*/
|
|
8
|
-
export declare function FixedListPage<T extends object
|
|
7
|
+
export declare function FixedListPage<T extends object>(props: ListPageProps<T> & {
|
|
9
8
|
/**
|
|
10
9
|
* Height will be deducted
|
|
11
10
|
* @param height Current calcuated height
|
|
@@ -40,7 +40,7 @@ export function FixedListPage(props) {
|
|
|
40
40
|
reset();
|
|
41
41
|
};
|
|
42
42
|
const localLoadData = (props, lastItem) => {
|
|
43
|
-
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey), lastItem);
|
|
43
|
+
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
44
44
|
};
|
|
45
45
|
// Search data
|
|
46
46
|
const searchData = GridUtils.getSearchData(cacheKey);
|
package/lib/pages/ListPage.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import { ScrollerListExProps } from "../ScrollerListEx";
|
|
3
2
|
import type { SearchPageProps } from "./SearchPageProps";
|
|
4
3
|
/**
|
|
5
4
|
* List page props
|
|
6
5
|
*/
|
|
7
|
-
export type ListPageProps<T extends object
|
|
6
|
+
export type ListPageProps<T extends object> = SearchPageProps<T> & Omit<ScrollerListExProps<T>, "loadData">;
|
|
8
7
|
/**
|
|
9
8
|
* List page
|
|
10
9
|
* @param props Props
|
|
11
10
|
* @returns Component
|
|
12
11
|
*/
|
|
13
|
-
export declare function ListPage<T extends object
|
|
12
|
+
export declare function ListPage<T extends object>(props: ListPageProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/lib/pages/ListPage.js
CHANGED
|
@@ -38,7 +38,7 @@ export function ListPage(props) {
|
|
|
38
38
|
reset();
|
|
39
39
|
};
|
|
40
40
|
const localLoadData = (props, lastItem) => {
|
|
41
|
-
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey), lastItem);
|
|
41
|
+
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
42
42
|
};
|
|
43
43
|
// Search data
|
|
44
44
|
const searchData = GridUtils.getSearchData(cacheKey);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import type { DataGridPageProps } from "./DataGridPageProps";
|
|
4
3
|
import type { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from "../ScrollerListEx";
|
|
@@ -8,7 +7,7 @@ import type { OperationMessageHandlerAll } from "../messages/OperationMessageHan
|
|
|
8
7
|
/**
|
|
9
8
|
* Response page props
|
|
10
9
|
*/
|
|
11
|
-
export type ResponsePageProps<T extends object
|
|
10
|
+
export type ResponsePageProps<T extends object> = DataGridPageProps<T> & {
|
|
12
11
|
/**
|
|
13
12
|
*
|
|
14
13
|
* @param height Current height
|
|
@@ -54,4 +53,4 @@ export type ResponsePageProps<T extends object, F extends DataTypes.BasicTemplat
|
|
|
54
53
|
* @param props Props
|
|
55
54
|
* @returns Component
|
|
56
55
|
*/
|
|
57
|
-
export declare function ResponsivePage<T extends object
|
|
56
|
+
export declare function ResponsivePage<T extends object>(props: ResponsePageProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { GridJsonData, GridLoader } from "@etsoo/react";
|
|
2
|
-
import type { DataTypes } from "@etsoo/shared";
|
|
1
|
+
import type { GridJsonData, GridLoader, GridTemplateType } from "@etsoo/react";
|
|
3
2
|
import type { CommonPageProps } from "./CommonPage";
|
|
4
3
|
/**
|
|
5
4
|
* Search page props
|
|
6
5
|
*/
|
|
7
|
-
export type SearchPageProps<T extends object
|
|
6
|
+
export type SearchPageProps<T extends object> = Omit<GridLoader<T>, "loadData"> & {
|
|
8
7
|
/**
|
|
9
8
|
* Cache key
|
|
10
9
|
*/
|
|
@@ -16,15 +15,15 @@ export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate>
|
|
|
16
15
|
/**
|
|
17
16
|
* Search fields
|
|
18
17
|
*/
|
|
19
|
-
fields: React.ReactElement[] | ((data:
|
|
18
|
+
fields: React.ReactElement[] | ((data: GridTemplateType<SearchPageProps<T>["fieldTemplate"]>) => React.ReactElement[]);
|
|
20
19
|
/**
|
|
21
20
|
* Search field template
|
|
22
21
|
*/
|
|
23
|
-
fieldTemplate
|
|
22
|
+
readonly fieldTemplate: object;
|
|
24
23
|
/**
|
|
25
24
|
* Load data callback
|
|
26
25
|
*/
|
|
27
|
-
loadData: (data: GridJsonData &
|
|
26
|
+
loadData: (data: GridJsonData & GridTemplateType<SearchPageProps<T>["fieldTemplate"]>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
|
|
28
27
|
/**
|
|
29
28
|
* Page props
|
|
30
29
|
*/
|
package/lib/pages/TablePage.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import type { SearchPageProps } from "./SearchPageProps";
|
|
|
4
4
|
/**
|
|
5
5
|
* Table page props
|
|
6
6
|
*/
|
|
7
|
-
export type TablePageProps<T extends object,
|
|
7
|
+
export type TablePageProps<T extends object, D extends DataTypes.Keys<T>> = SearchPageProps<T> & Omit<TableExProps<T, D>, "loadData">;
|
|
8
8
|
/**
|
|
9
9
|
* Table page
|
|
10
10
|
* @param props Props
|
|
11
11
|
* @returns Component
|
|
12
12
|
*/
|
|
13
|
-
export declare function TablePage<T extends object,
|
|
13
|
+
export declare function TablePage<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TablePageProps<T, D>): import("react/jsx-runtime").JSX.Element;
|
package/lib/pages/TablePage.js
CHANGED
|
@@ -37,7 +37,7 @@ export function TablePage(props) {
|
|
|
37
37
|
reset();
|
|
38
38
|
};
|
|
39
39
|
const localLoadData = (props, lastItem) => {
|
|
40
|
-
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey), lastItem);
|
|
40
|
+
return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
|
|
41
41
|
};
|
|
42
42
|
// Search data
|
|
43
43
|
const searchData = GridUtils.getSearchData(cacheKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.46",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/ETSOO/ReactMU#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dnd-kit/core": "^6.
|
|
34
|
-
"@dnd-kit/sortable": "^
|
|
33
|
+
"@dnd-kit/core": "^6.3.1",
|
|
34
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
35
35
|
"@emotion/css": "^11.13.5",
|
|
36
36
|
"@emotion/react": "^11.13.5",
|
|
37
37
|
"@emotion/styled": "^11.13.5",
|
|
38
38
|
"@etsoo/appscript": "^1.5.78",
|
|
39
39
|
"@etsoo/notificationbase": "^1.1.54",
|
|
40
|
-
"@etsoo/react": "^1.8.
|
|
40
|
+
"@etsoo/react": "^1.8.10",
|
|
41
41
|
"@etsoo/shared": "^1.2.55",
|
|
42
|
-
"@mui/icons-material": "^6.1.
|
|
43
|
-
"@mui/material": "^6.1.
|
|
44
|
-
"@mui/x-data-grid": "^7.23.
|
|
42
|
+
"@mui/icons-material": "^6.1.10",
|
|
43
|
+
"@mui/material": "^6.1.10",
|
|
44
|
+
"@mui/x-data-grid": "^7.23.1",
|
|
45
45
|
"chart.js": "^4.4.7",
|
|
46
46
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
47
47
|
"eventemitter3": "^5.0.1",
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
"react-imask": "7.6.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
58
|
+
"@babel/cli": "^7.26.4",
|
|
59
59
|
"@babel/core": "^7.26.0",
|
|
60
60
|
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
61
61
|
"@babel/preset-env": "^7.26.0",
|
|
62
|
-
"@babel/preset-react": "^7.
|
|
62
|
+
"@babel/preset-react": "^7.26.3",
|
|
63
63
|
"@babel/preset-typescript": "^7.26.0",
|
|
64
64
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
65
|
-
"@testing-library/react": "^16.0
|
|
65
|
+
"@testing-library/react": "^16.1.0",
|
|
66
66
|
"@types/pica": "^9.0.4",
|
|
67
67
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
68
|
-
"@types/react": "^18.3.
|
|
68
|
+
"@types/react": "^18.3.13",
|
|
69
69
|
"@types/react-avatar-editor": "^13.0.3",
|
|
70
70
|
"@types/react-dom": "^18.3.1",
|
|
71
71
|
"@types/react-input-mask": "^3.0.6",
|
package/src/GridUtils.ts
CHANGED
|
@@ -15,15 +15,17 @@ export namespace GridUtils {
|
|
|
15
15
|
* @param props Props
|
|
16
16
|
* @param template Field template
|
|
17
17
|
* @param cacheKey Cache key
|
|
18
|
+
* @param keepSource Keep source or not
|
|
18
19
|
* @returns Request data
|
|
19
20
|
*/
|
|
20
|
-
export function createLoader
|
|
21
|
+
export function createLoader(
|
|
21
22
|
props: GridLoadDataProps,
|
|
22
|
-
template?:
|
|
23
|
-
cacheKey?: string
|
|
23
|
+
template?: object,
|
|
24
|
+
cacheKey?: string,
|
|
25
|
+
keepSource?: boolean
|
|
24
26
|
) {
|
|
25
27
|
const { data, ...rest } = props;
|
|
26
|
-
const formData = GridDataGetData(data, template);
|
|
28
|
+
const formData = GridDataGetData(data, template, keepSource);
|
|
27
29
|
|
|
28
30
|
if (cacheKey)
|
|
29
31
|
sessionStorage.setItem(`${cacheKey}-searchbar`, JSON.stringify(formData));
|
|
@@ -55,13 +57,11 @@ export namespace GridUtils {
|
|
|
55
57
|
* @param cacheKey Cache key
|
|
56
58
|
* @returns Result
|
|
57
59
|
*/
|
|
58
|
-
export function getSearchData
|
|
59
|
-
cacheKey?: string
|
|
60
|
-
) {
|
|
60
|
+
export function getSearchData(cacheKey?: string) {
|
|
61
61
|
if (cacheKey) {
|
|
62
62
|
const data = sessionStorage.getItem(`${cacheKey}-searchbar`);
|
|
63
63
|
if (data) {
|
|
64
|
-
return JSON.parse(data)
|
|
64
|
+
return JSON.parse(data);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/ListMoreDisplay.tsx
CHANGED
|
@@ -21,10 +21,8 @@ import { globalApp } from "./app/ReactApp";
|
|
|
21
21
|
/**
|
|
22
22
|
* ListMoreDisplay props
|
|
23
23
|
*/
|
|
24
|
-
export interface ListMoreDisplayProps<
|
|
25
|
-
|
|
26
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
27
|
-
> extends Omit<CardProps, "children">,
|
|
24
|
+
export interface ListMoreDisplayProps<T extends object>
|
|
25
|
+
extends Omit<CardProps, "children">,
|
|
28
26
|
GridLoader<T> {
|
|
29
27
|
/**
|
|
30
28
|
* Batch size to load
|
|
@@ -39,7 +37,7 @@ export interface ListMoreDisplayProps<
|
|
|
39
37
|
/**
|
|
40
38
|
* Search field template
|
|
41
39
|
*/
|
|
42
|
-
fieldTemplate
|
|
40
|
+
readonly fieldTemplate: object;
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* Header renderer
|
|
@@ -67,10 +65,9 @@ type states<T> = {
|
|
|
67
65
|
* @param props Props
|
|
68
66
|
* @returns Component
|
|
69
67
|
*/
|
|
70
|
-
export function ListMoreDisplay<
|
|
71
|
-
T
|
|
72
|
-
|
|
73
|
-
>(props: ListMoreDisplayProps<T, F>) {
|
|
68
|
+
export function ListMoreDisplay<T extends object>(
|
|
69
|
+
props: ListMoreDisplayProps<T>
|
|
70
|
+
) {
|
|
74
71
|
// Destruct
|
|
75
72
|
const {
|
|
76
73
|
batchSize = 6,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Box, Stack, SxProps, Theme } from "@mui/material";
|
|
1
|
+
import { Box, Stack, SxProps, Theme, useMediaQuery } from "@mui/material";
|
|
3
2
|
import React from "react";
|
|
4
3
|
import {
|
|
5
4
|
GridOnScrollProps,
|
|
@@ -13,16 +12,13 @@ import {
|
|
|
13
12
|
GridLoadDataProps,
|
|
14
13
|
GridLoaderStates,
|
|
15
14
|
GridMethodRef,
|
|
15
|
+
GridTemplateType,
|
|
16
16
|
ReactUtils,
|
|
17
17
|
ScrollerListRef,
|
|
18
18
|
useCombinedRefs,
|
|
19
19
|
useDimensions
|
|
20
20
|
} from "@etsoo/react";
|
|
21
|
-
import {
|
|
22
|
-
DataGridEx,
|
|
23
|
-
DataGridExCalColumns,
|
|
24
|
-
DataGridExProps
|
|
25
|
-
} from "./DataGridEx";
|
|
21
|
+
import { DataGridEx, DataGridExProps } from "./DataGridEx";
|
|
26
22
|
import { MUGlobal } from "./MUGlobal";
|
|
27
23
|
import { PullToRefreshUI } from "./PullToRefreshUI";
|
|
28
24
|
import {
|
|
@@ -37,10 +33,7 @@ import { GridUtils } from "./GridUtils";
|
|
|
37
33
|
/**
|
|
38
34
|
* ResponsibleContainer props
|
|
39
35
|
*/
|
|
40
|
-
export type ResponsibleContainerProps<
|
|
41
|
-
T extends object,
|
|
42
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
43
|
-
> = Omit<
|
|
36
|
+
export type ResponsibleContainerProps<T extends object> = Omit<
|
|
44
37
|
DataGridExProps<T>,
|
|
45
38
|
| "height"
|
|
46
39
|
| "itemKey"
|
|
@@ -80,22 +73,19 @@ export type ResponsibleContainerProps<
|
|
|
80
73
|
dataGrid?: boolean
|
|
81
74
|
) => SxProps<Theme>;
|
|
82
75
|
|
|
83
|
-
/**
|
|
84
|
-
* Min width to show Datagrid
|
|
85
|
-
*/
|
|
86
|
-
dataGridMinWidth?: number;
|
|
87
|
-
|
|
88
76
|
/**
|
|
89
77
|
* Search fields
|
|
90
78
|
*/
|
|
91
79
|
fields?:
|
|
92
80
|
| React.ReactElement[]
|
|
93
|
-
| ((
|
|
81
|
+
| ((
|
|
82
|
+
data: GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>
|
|
83
|
+
) => React.ReactElement[]);
|
|
94
84
|
|
|
95
85
|
/**
|
|
96
86
|
* Search field template
|
|
97
87
|
*/
|
|
98
|
-
fieldTemplate
|
|
88
|
+
fieldTemplate: object;
|
|
99
89
|
|
|
100
90
|
/**
|
|
101
91
|
* Grid height
|
|
@@ -123,7 +113,8 @@ export type ResponsibleContainerProps<
|
|
|
123
113
|
* Load data callback
|
|
124
114
|
*/
|
|
125
115
|
loadData: (
|
|
126
|
-
data: GridJsonData &
|
|
116
|
+
data: GridJsonData &
|
|
117
|
+
GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>,
|
|
127
118
|
lastItem?: T
|
|
128
119
|
) => PromiseLike<T[] | null | undefined>;
|
|
129
120
|
|
|
@@ -161,6 +152,11 @@ export type ResponsibleContainerProps<
|
|
|
161
152
|
* SearchBar height
|
|
162
153
|
*/
|
|
163
154
|
searchBarHeight?: number;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* SearchBar bottom padding
|
|
158
|
+
*/
|
|
159
|
+
searchBarBottom?: number;
|
|
164
160
|
};
|
|
165
161
|
|
|
166
162
|
interface LocalRefs<T> {
|
|
@@ -189,10 +185,9 @@ function defaultContainerBoxSx(
|
|
|
189
185
|
* @param props Props
|
|
190
186
|
* @returns Layout
|
|
191
187
|
*/
|
|
192
|
-
export function ResponsibleContainer<
|
|
193
|
-
T
|
|
194
|
-
|
|
195
|
-
>(props: ResponsibleContainerProps<T, F>) {
|
|
188
|
+
export function ResponsibleContainer<T extends object>(
|
|
189
|
+
props: ResponsibleContainerProps<T>
|
|
190
|
+
) {
|
|
196
191
|
// Destruct
|
|
197
192
|
const {
|
|
198
193
|
adjustHeight,
|
|
@@ -201,7 +196,6 @@ export function ResponsibleContainer<
|
|
|
201
196
|
cacheMinutes = 15,
|
|
202
197
|
columns,
|
|
203
198
|
containerBoxSx = defaultContainerBoxSx,
|
|
204
|
-
dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total),
|
|
205
199
|
elementReady,
|
|
206
200
|
fields,
|
|
207
201
|
fieldTemplate,
|
|
@@ -213,6 +207,7 @@ export function ResponsibleContainer<
|
|
|
213
207
|
quickAction,
|
|
214
208
|
sizeReadyMiliseconds = 0,
|
|
215
209
|
searchBarHeight = 45.6,
|
|
210
|
+
searchBarBottom = 8,
|
|
216
211
|
...rest
|
|
217
212
|
} = props;
|
|
218
213
|
|
|
@@ -228,6 +223,9 @@ export function ResponsibleContainer<
|
|
|
228
223
|
state.ref = ref;
|
|
229
224
|
});
|
|
230
225
|
|
|
226
|
+
// Screen size detection
|
|
227
|
+
const showDataGrid = useMediaQuery("(min-width:600px)");
|
|
228
|
+
|
|
231
229
|
// Update mounted state
|
|
232
230
|
React.useEffect(() => {
|
|
233
231
|
return () => {
|
|
@@ -242,13 +240,13 @@ export function ResponsibleContainer<
|
|
|
242
240
|
const localLoadData = (props: GridLoadDataProps, lastItem?: T) => {
|
|
243
241
|
state.mounted = true;
|
|
244
242
|
return loadData(
|
|
245
|
-
GridUtils.createLoader
|
|
243
|
+
GridUtils.createLoader(props, fieldTemplate, cacheKey, false),
|
|
246
244
|
lastItem
|
|
247
245
|
);
|
|
248
246
|
};
|
|
249
247
|
|
|
250
248
|
// Search data
|
|
251
|
-
const searchData = GridUtils.getSearchData
|
|
249
|
+
const searchData = GridUtils.getSearchData(cacheKey);
|
|
252
250
|
|
|
253
251
|
// On submit callback
|
|
254
252
|
const onSubmit = (data: FormData, _reset: boolean) => {
|
|
@@ -339,16 +337,10 @@ export function ResponsibleContainer<
|
|
|
339
337
|
const rect = dimensions[0][2];
|
|
340
338
|
|
|
341
339
|
// Create list
|
|
342
|
-
const
|
|
340
|
+
const list = (() => {
|
|
343
341
|
// No layout
|
|
344
342
|
if (rect == null) return [null, undefined];
|
|
345
343
|
|
|
346
|
-
// Width
|
|
347
|
-
const width = rect.width;
|
|
348
|
-
|
|
349
|
-
// Show DataGrid or List dependng on width
|
|
350
|
-
const showDataGrid = width >= dataGridMinWidth;
|
|
351
|
-
|
|
352
344
|
// Height
|
|
353
345
|
let heightLocal: number;
|
|
354
346
|
if (height != null) {
|
|
@@ -360,7 +352,7 @@ export function ResponsibleContainer<
|
|
|
360
352
|
|
|
361
353
|
const style = window.getComputedStyle(dimensions[0][1]!);
|
|
362
354
|
const boxMargin = parseFloat(style.marginBottom);
|
|
363
|
-
if (!isNaN(boxMargin)) heightLocal -=
|
|
355
|
+
if (!isNaN(boxMargin)) heightLocal -= boxMargin;
|
|
364
356
|
|
|
365
357
|
if (adjustHeight != null)
|
|
366
358
|
heightLocal -=
|
|
@@ -376,7 +368,7 @@ export function ResponsibleContainer<
|
|
|
376
368
|
// Delete
|
|
377
369
|
delete rest.itemRenderer;
|
|
378
370
|
|
|
379
|
-
return
|
|
371
|
+
return (
|
|
380
372
|
<Box className="DataGridBox">
|
|
381
373
|
<DataGridEx<T>
|
|
382
374
|
autoLoad={!hasFields}
|
|
@@ -394,9 +386,8 @@ export function ResponsibleContainer<
|
|
|
394
386
|
onInitLoad={onInitLoad}
|
|
395
387
|
{...rest}
|
|
396
388
|
/>
|
|
397
|
-
</Box
|
|
398
|
-
|
|
399
|
-
];
|
|
389
|
+
</Box>
|
|
390
|
+
);
|
|
400
391
|
}
|
|
401
392
|
|
|
402
393
|
// Delete
|
|
@@ -409,7 +400,7 @@ export function ResponsibleContainer<
|
|
|
409
400
|
delete rest.hoverColor;
|
|
410
401
|
delete rest.selectable;
|
|
411
402
|
|
|
412
|
-
return
|
|
403
|
+
return (
|
|
413
404
|
<Box className="ListBox" sx={{ height: heightLocal }}>
|
|
414
405
|
<ScrollerListEx<T>
|
|
415
406
|
autoLoad={!hasFields}
|
|
@@ -427,9 +418,8 @@ export function ResponsibleContainer<
|
|
|
427
418
|
onScroll={onListScroll}
|
|
428
419
|
{...rest}
|
|
429
420
|
/>
|
|
430
|
-
</Box
|
|
431
|
-
|
|
432
|
-
];
|
|
421
|
+
</Box>
|
|
422
|
+
);
|
|
433
423
|
})();
|
|
434
424
|
|
|
435
425
|
const searchBar = React.useMemo(() => {
|
|
@@ -473,7 +463,12 @@ export function ResponsibleContainer<
|
|
|
473
463
|
<Box
|
|
474
464
|
ref={dimensions[0][0]}
|
|
475
465
|
className="SearchBox"
|
|
476
|
-
sx={{
|
|
466
|
+
sx={{
|
|
467
|
+
height: hasFields ? searchBarHeight : 0
|
|
468
|
+
}}
|
|
469
|
+
marginBottom={
|
|
470
|
+
hasFields ? `${searchBarBottom}px!important` : undefined
|
|
471
|
+
}
|
|
477
472
|
>
|
|
478
473
|
{searchBar}
|
|
479
474
|
</Box>
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useCombinedRefs,
|
|
8
8
|
useDimensions
|
|
9
9
|
} from "@etsoo/react";
|
|
10
|
-
import { DataTypes } from "@etsoo/shared";
|
|
11
10
|
import { Box, Stack } from "@mui/material";
|
|
12
11
|
import React from "react";
|
|
13
12
|
import { DataGridEx } from "../DataGridEx";
|
|
@@ -29,10 +28,7 @@ interface LocalStates<T> {
|
|
|
29
28
|
* @param props Props
|
|
30
29
|
* @returns Component
|
|
31
30
|
*/
|
|
32
|
-
export function DataGridPage<
|
|
33
|
-
T extends object,
|
|
34
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
35
|
-
>(props: DataGridPageProps<T, F>) {
|
|
31
|
+
export function DataGridPage<T extends object>(props: DataGridPageProps<T>) {
|
|
36
32
|
// Destruct
|
|
37
33
|
const {
|
|
38
34
|
adjustHeight,
|
|
@@ -78,13 +74,13 @@ export function DataGridPage<
|
|
|
78
74
|
|
|
79
75
|
const localLoadData = (props: GridLoadDataProps, lastItem?: T) => {
|
|
80
76
|
return loadData(
|
|
81
|
-
GridUtils.createLoader
|
|
77
|
+
GridUtils.createLoader(props, fieldTemplate, cacheKey, false),
|
|
82
78
|
lastItem
|
|
83
79
|
);
|
|
84
80
|
};
|
|
85
81
|
|
|
86
82
|
// Search data
|
|
87
|
-
const searchData = GridUtils.getSearchData
|
|
83
|
+
const searchData = GridUtils.getSearchData(cacheKey);
|
|
88
84
|
|
|
89
85
|
const onInitLoad = (
|
|
90
86
|
ref: VariableSizeGrid<T>
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import type { DataGridExProps } from "../DataGridEx";
|
|
3
2
|
import type { SearchPageProps } from "./SearchPageProps";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* DataGrid page props
|
|
7
6
|
*/
|
|
8
|
-
export type DataGridPageProps<
|
|
9
|
-
T extends object,
|
|
10
|
-
F extends DataTypes.BasicTemplate
|
|
11
|
-
> = SearchPageProps<T, F> &
|
|
7
|
+
export type DataGridPageProps<T extends object> = SearchPageProps<T> &
|
|
12
8
|
Omit<DataGridExProps<T>, "loadData"> & {
|
|
13
9
|
/**
|
|
14
10
|
* Height will be deducted
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useCombinedRefs,
|
|
8
8
|
useDimensions
|
|
9
9
|
} from "@etsoo/react";
|
|
10
|
-
import { DataTypes } from "@etsoo/shared";
|
|
11
10
|
import { Box, Stack } from "@mui/material";
|
|
12
11
|
import React from "react";
|
|
13
12
|
import { MUGlobal } from "../MUGlobal";
|
|
@@ -22,11 +21,8 @@ import type { ListPageProps } from "./ListPage";
|
|
|
22
21
|
* @param props Props
|
|
23
22
|
* @returns Component
|
|
24
23
|
*/
|
|
25
|
-
export function FixedListPage<
|
|
26
|
-
T
|
|
27
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
28
|
-
>(
|
|
29
|
-
props: ListPageProps<T, F> & {
|
|
24
|
+
export function FixedListPage<T extends object>(
|
|
25
|
+
props: ListPageProps<T> & {
|
|
30
26
|
/**
|
|
31
27
|
* Height will be deducted
|
|
32
28
|
* @param height Current calcuated height
|
|
@@ -90,13 +86,13 @@ export function FixedListPage<
|
|
|
90
86
|
|
|
91
87
|
const localLoadData = (props: GridLoadDataProps, lastItem?: T) => {
|
|
92
88
|
return loadData(
|
|
93
|
-
GridUtils.createLoader
|
|
89
|
+
GridUtils.createLoader(props, fieldTemplate, cacheKey, false),
|
|
94
90
|
lastItem
|
|
95
91
|
);
|
|
96
92
|
};
|
|
97
93
|
|
|
98
94
|
// Search data
|
|
99
|
-
const searchData = GridUtils.getSearchData
|
|
95
|
+
const searchData = GridUtils.getSearchData(cacheKey);
|
|
100
96
|
|
|
101
97
|
const onInitLoad = (
|
|
102
98
|
ref: ScrollerListRef
|
package/src/pages/ListPage.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
ScrollerListRef,
|
|
7
7
|
useCombinedRefs
|
|
8
8
|
} from "@etsoo/react";
|
|
9
|
-
import { DataTypes } from "@etsoo/shared";
|
|
10
9
|
import { Box, Stack } from "@mui/material";
|
|
11
10
|
import React from "react";
|
|
12
11
|
import { MUGlobal } from "../MUGlobal";
|
|
@@ -19,20 +18,15 @@ import type { SearchPageProps } from "./SearchPageProps";
|
|
|
19
18
|
/**
|
|
20
19
|
* List page props
|
|
21
20
|
*/
|
|
22
|
-
export type ListPageProps<
|
|
23
|
-
T
|
|
24
|
-
F extends DataTypes.BasicTemplate
|
|
25
|
-
> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T>, "loadData">;
|
|
21
|
+
export type ListPageProps<T extends object> = SearchPageProps<T> &
|
|
22
|
+
Omit<ScrollerListExProps<T>, "loadData">;
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* List page
|
|
29
26
|
* @param props Props
|
|
30
27
|
* @returns Component
|
|
31
28
|
*/
|
|
32
|
-
export function ListPage<
|
|
33
|
-
T extends object,
|
|
34
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
35
|
-
>(props: ListPageProps<T, F>) {
|
|
29
|
+
export function ListPage<T extends object>(props: ListPageProps<T>) {
|
|
36
30
|
// Destruct
|
|
37
31
|
const {
|
|
38
32
|
fields,
|
|
@@ -78,13 +72,13 @@ export function ListPage<
|
|
|
78
72
|
|
|
79
73
|
const localLoadData = (props: GridLoadDataProps, lastItem?: T) => {
|
|
80
74
|
return loadData(
|
|
81
|
-
GridUtils.createLoader
|
|
75
|
+
GridUtils.createLoader(props, fieldTemplate, cacheKey, false),
|
|
82
76
|
lastItem
|
|
83
77
|
);
|
|
84
78
|
};
|
|
85
79
|
|
|
86
80
|
// Search data
|
|
87
|
-
const searchData = GridUtils.getSearchData
|
|
81
|
+
const searchData = GridUtils.getSearchData(cacheKey);
|
|
88
82
|
|
|
89
83
|
const onInitLoad = (
|
|
90
84
|
ref: ScrollerListRef
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from "@etsoo/shared";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { MUGlobal } from "../MUGlobal";
|
|
4
3
|
import { ResponsibleContainer } from "../ResponsibleContainer";
|
|
@@ -16,10 +15,7 @@ import type { OperationMessageHandlerAll } from "../messages/OperationMessageHan
|
|
|
16
15
|
/**
|
|
17
16
|
* Response page props
|
|
18
17
|
*/
|
|
19
|
-
export type ResponsePageProps<
|
|
20
|
-
T extends object,
|
|
21
|
-
F extends DataTypes.BasicTemplate
|
|
22
|
-
> = DataGridPageProps<T, F> & {
|
|
18
|
+
export type ResponsePageProps<T extends object> = DataGridPageProps<T> & {
|
|
23
19
|
/**
|
|
24
20
|
*
|
|
25
21
|
* @param height Current height
|
|
@@ -76,10 +72,7 @@ export type ResponsePageProps<
|
|
|
76
72
|
* @param props Props
|
|
77
73
|
* @returns Component
|
|
78
74
|
*/
|
|
79
|
-
export function ResponsivePage<
|
|
80
|
-
T extends object,
|
|
81
|
-
F extends DataTypes.BasicTemplate = {}
|
|
82
|
-
>(props: ResponsePageProps<T, F>) {
|
|
75
|
+
export function ResponsivePage<T extends object>(props: ResponsePageProps<T>) {
|
|
83
76
|
// Destruct
|
|
84
77
|
const { pageProps = {}, operationMessageHandler, ...rest } = props;
|
|
85
78
|
|
|
@@ -101,7 +94,7 @@ export function ResponsivePage<
|
|
|
101
94
|
{operationMessageHandler && (
|
|
102
95
|
<OperationMessageContainer handler={operationMessageHandler} />
|
|
103
96
|
)}
|
|
104
|
-
<ResponsibleContainer<T
|
|
97
|
+
<ResponsibleContainer<T>
|
|
105
98
|
paddings={paddings}
|
|
106
99
|
containerBoxSx={(paddings, hasField, _dataGrid) => {
|
|
107
100
|
// Half
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { GridJsonData, GridLoader } from "@etsoo/react";
|
|
2
|
-
import type { DataTypes } from "@etsoo/shared";
|
|
1
|
+
import type { GridJsonData, GridLoader, GridTemplateType } from "@etsoo/react";
|
|
3
2
|
import type { CommonPageProps } from "./CommonPage";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Search page props
|
|
7
6
|
*/
|
|
8
|
-
export type SearchPageProps<
|
|
9
|
-
T
|
|
10
|
-
|
|
11
|
-
>
|
|
7
|
+
export type SearchPageProps<T extends object> = Omit<
|
|
8
|
+
GridLoader<T>,
|
|
9
|
+
"loadData"
|
|
10
|
+
> & {
|
|
12
11
|
/**
|
|
13
12
|
* Cache key
|
|
14
13
|
*/
|
|
@@ -24,18 +23,20 @@ export type SearchPageProps<
|
|
|
24
23
|
*/
|
|
25
24
|
fields:
|
|
26
25
|
| React.ReactElement[]
|
|
27
|
-
| ((
|
|
26
|
+
| ((
|
|
27
|
+
data: GridTemplateType<SearchPageProps<T>["fieldTemplate"]>
|
|
28
|
+
) => React.ReactElement[]);
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Search field template
|
|
31
32
|
*/
|
|
32
|
-
fieldTemplate
|
|
33
|
+
readonly fieldTemplate: object;
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Load data callback
|
|
36
37
|
*/
|
|
37
38
|
loadData: (
|
|
38
|
-
data: GridJsonData &
|
|
39
|
+
data: GridJsonData & GridTemplateType<SearchPageProps<T>["fieldTemplate"]>,
|
|
39
40
|
lastItem?: T
|
|
40
41
|
) => PromiseLike<T[] | null | undefined>;
|
|
41
42
|
|
package/src/pages/TablePage.tsx
CHANGED
|
@@ -23,9 +23,8 @@ import type { SearchPageProps } from "./SearchPageProps";
|
|
|
23
23
|
*/
|
|
24
24
|
export type TablePageProps<
|
|
25
25
|
T extends object,
|
|
26
|
-
F extends DataTypes.BasicTemplate,
|
|
27
26
|
D extends DataTypes.Keys<T>
|
|
28
|
-
> = SearchPageProps<T
|
|
27
|
+
> = SearchPageProps<T> & Omit<TableExProps<T, D>, "loadData">;
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* Table page
|
|
@@ -34,9 +33,8 @@ export type TablePageProps<
|
|
|
34
33
|
*/
|
|
35
34
|
export function TablePage<
|
|
36
35
|
T extends object,
|
|
37
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
38
36
|
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
39
|
-
>(props: TablePageProps<T,
|
|
37
|
+
>(props: TablePageProps<T, D>) {
|
|
40
38
|
// Destruct
|
|
41
39
|
const {
|
|
42
40
|
columns,
|
|
@@ -85,13 +83,13 @@ export function TablePage<
|
|
|
85
83
|
|
|
86
84
|
const localLoadData = (props: GridLoadDataProps, lastItem?: T) => {
|
|
87
85
|
return loadData(
|
|
88
|
-
GridUtils.createLoader
|
|
86
|
+
GridUtils.createLoader(props, fieldTemplate, cacheKey, false),
|
|
89
87
|
lastItem
|
|
90
88
|
);
|
|
91
89
|
};
|
|
92
90
|
|
|
93
91
|
// Search data
|
|
94
|
-
const searchData = GridUtils.getSearchData
|
|
92
|
+
const searchData = GridUtils.getSearchData(cacheKey);
|
|
95
93
|
|
|
96
94
|
// Total width
|
|
97
95
|
const totalWidth = React.useMemo(
|