@etsoo/materialui 1.3.42 → 1.3.44
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__/NotifierMUTests.tsx +140 -140
- package/__tests__/ResponsePage.tsx +48 -0
- package/__tests__/SelectEx.tsx +2 -2
- package/__tests__/SwitchAnt.tsx +17 -17
- package/__tests__/tsconfig.json +17 -17
- package/lib/AddresSelector.js +1 -2
- package/lib/AuditDisplay.js +2 -3
- package/lib/BridgeCloseButton.js +1 -2
- package/lib/ComboBox.js +5 -5
- package/lib/ComboBoxMultiple.js +7 -8
- package/lib/ComboBoxPro.js +1 -2
- package/lib/CultureDataTable.js +2 -2
- package/lib/DataGridEx.d.ts +2 -3
- package/lib/DataGridEx.js +12 -14
- package/lib/DataGridRenderers.js +6 -6
- package/lib/DataSteps.js +1 -2
- package/lib/DataTable.js +1 -2
- package/lib/DialogButton.js +2 -3
- package/lib/DnDList.js +1 -1
- package/lib/EmailInput.js +1 -2
- package/lib/FileUploadButton.js +1 -1
- package/lib/GridDataFormat.js +5 -5
- package/lib/GridUtils.js +1 -2
- package/lib/HiSelector.js +1 -1
- package/lib/HiSelectorTL.js +1 -1
- package/lib/InputField.js +4 -5
- package/lib/InputTipField.js +1 -1
- package/lib/ItemList.js +2 -3
- package/lib/ListChooser.js +4 -5
- package/lib/LoadingButton.js +1 -2
- package/lib/MaskInput.js +2 -3
- package/lib/NotifierMU.js +14 -19
- package/lib/OptionBool.js +1 -2
- package/lib/OptionGroup.js +3 -4
- package/lib/OptionGroupFlag.js +1 -1
- package/lib/QuickList.js +2 -2
- package/lib/ResponsibleContainer.d.ts +3 -3
- package/lib/ResponsibleContainer.js +3 -3
- package/lib/ScrollerListEx.d.ts +6 -7
- package/lib/ScrollerListEx.js +30 -36
- package/lib/SearchField.js +3 -4
- package/lib/SelectBool.js +1 -2
- package/lib/SelectEx.js +6 -8
- package/lib/ShowDataComparison.js +3 -4
- package/lib/Switch.js +1 -2
- package/lib/SwitchAnt.js +6 -7
- package/lib/TableEx.js +5 -7
- package/lib/TagList.js +3 -5
- package/lib/TagListPro.js +3 -5
- package/lib/TextFieldEx.js +2 -2
- package/lib/Tiplist.js +6 -8
- package/lib/TiplistPro.js +9 -10
- package/lib/TooltipClick.js +2 -2
- package/lib/TwoFieldInput.js +1 -1
- package/lib/UserAvatar.js +1 -2
- package/lib/UserAvatarEditor.js +4 -6
- package/lib/app/CommonApp.js +1 -1
- package/lib/app/ReactApp.js +4 -6
- package/lib/app/ServiceApp.js +5 -7
- package/lib/pages/DataGridPage.d.ts +2 -2
- package/lib/pages/DataGridPage.js +2 -3
- package/lib/pages/DataGridPageProps.d.ts +2 -2
- package/lib/pages/FixedListPage.d.ts +2 -2
- package/lib/pages/FixedListPage.js +2 -3
- package/lib/pages/LeftDrawer.js +2 -3
- package/lib/pages/ListPage.d.ts +2 -2
- package/lib/pages/ListPage.js +2 -3
- package/lib/pages/ListPageProps.d.ts +1 -1
- package/lib/pages/ResponsivePage.d.ts +2 -2
- package/lib/pages/ResponsivePage.js +1 -2
- package/lib/pages/ResponsivePageProps.d.ts +2 -2
- package/lib/pages/TablePage.js +3 -5
- package/lib/pages/UserMenu.js +1 -2
- package/lib/pages/ViewPage.js +6 -7
- package/package.json +14 -12
- package/src/DataGridEx.tsx +6 -12
- package/src/ResponsibleContainer.tsx +7 -9
- package/src/ScrollerListEx.tsx +301 -311
- package/src/pages/DataGridPage.tsx +4 -5
- package/src/pages/DataGridPageProps.ts +3 -4
- package/src/pages/FixedListPage.tsx +4 -5
- package/src/pages/ListPage.tsx +4 -5
- package/src/pages/ListPageProps.ts +2 -3
- package/src/pages/ResponsivePage.tsx +4 -5
- package/src/pages/ResponsivePageProps.ts +3 -4
- package/tsconfig.json +3 -3
package/lib/TooltipClick.js
CHANGED
|
@@ -21,11 +21,11 @@ export function TooltipClick(props) {
|
|
|
21
21
|
setOpen(true);
|
|
22
22
|
if (newTitle)
|
|
23
23
|
setTitle(newTitle);
|
|
24
|
-
delayed
|
|
24
|
+
delayed?.call();
|
|
25
25
|
};
|
|
26
26
|
React.useEffect(() => {
|
|
27
27
|
return () => {
|
|
28
|
-
delayed
|
|
28
|
+
delayed?.clear();
|
|
29
29
|
};
|
|
30
30
|
}, []);
|
|
31
31
|
// Layout
|
package/lib/TwoFieldInput.js
CHANGED
|
@@ -11,7 +11,7 @@ import { InputField } from './InputField';
|
|
|
11
11
|
*/
|
|
12
12
|
export function TwoFieldInput(props) {
|
|
13
13
|
// Destruct
|
|
14
|
-
const { name, inputProps, type = inputProps
|
|
14
|
+
const { name, inputProps, type = inputProps?.inputMode, values, onValuesChange, onChange, onInput, ...rest } = props;
|
|
15
15
|
// Local values
|
|
16
16
|
const localValues = values == null
|
|
17
17
|
? [null, null]
|
package/lib/UserAvatar.js
CHANGED
|
@@ -10,8 +10,7 @@ import { globalApp } from "./app/ReactApp";
|
|
|
10
10
|
export function UserAvatar(props) {
|
|
11
11
|
// Destruct
|
|
12
12
|
const { src, title, formatTitle = (title) => {
|
|
13
|
-
|
|
14
|
-
return BusinessUtils.formatAvatarTitle(title, 3, (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get("me")) !== null && _a !== void 0 ? _a : "ME");
|
|
13
|
+
return BusinessUtils.formatAvatarTitle(title, 3, globalApp?.get("me") ?? "ME");
|
|
15
14
|
} } = props;
|
|
16
15
|
// Format
|
|
17
16
|
const fTitle = formatTitle(title);
|
package/lib/UserAvatarEditor.js
CHANGED
|
@@ -73,7 +73,6 @@ export function UserAvatarEditor(props) {
|
|
|
73
73
|
};
|
|
74
74
|
// Handle file upload
|
|
75
75
|
const handleFileUpload = (files) => {
|
|
76
|
-
var _a;
|
|
77
76
|
// Reset all settings
|
|
78
77
|
handleReset();
|
|
79
78
|
// Set new preview image
|
|
@@ -83,7 +82,7 @@ export function UserAvatarEditor(props) {
|
|
|
83
82
|
// Set ready state
|
|
84
83
|
setReady(false);
|
|
85
84
|
// Make the submit button visible
|
|
86
|
-
|
|
85
|
+
buttonRef.current?.scrollIntoView(false);
|
|
87
86
|
};
|
|
88
87
|
// Handle reset
|
|
89
88
|
const handleReset = () => {
|
|
@@ -99,11 +98,10 @@ export function UserAvatarEditor(props) {
|
|
|
99
98
|
};
|
|
100
99
|
// Handle done
|
|
101
100
|
const handleDone = async () => {
|
|
102
|
-
var _a, _b;
|
|
103
101
|
// Data
|
|
104
102
|
var data = scaledResult
|
|
105
|
-
?
|
|
106
|
-
:
|
|
103
|
+
? ref.current?.getImageScaledToCanvas()
|
|
104
|
+
: ref.current?.getImage();
|
|
107
105
|
if (data == null)
|
|
108
106
|
return;
|
|
109
107
|
// pica
|
|
@@ -141,7 +139,7 @@ export function UserAvatarEditor(props) {
|
|
|
141
139
|
React.createElement(FileUploadButton, { variant: "outlined", size: "medium", startIcon: React.createElement(ComputerIcon, null), fullWidth: true, onUploadFiles: handleFileUpload, inputProps: { multiple: false, accept: "image/png, image/jpeg" } }, labels.upload),
|
|
142
140
|
React.createElement(Stack, { direction: "row", spacing: 0.5 },
|
|
143
141
|
React.createElement(React.Suspense, { fallback: React.createElement(Skeleton, { variant: "rounded", width: width, height: height }) },
|
|
144
|
-
React.createElement(AE, { ref: ref, border: border, width: width, height: height, onLoadSuccess: handleLoad, image: previewImage
|
|
142
|
+
React.createElement(AE, { ref: ref, border: border, width: width, height: height, onLoadSuccess: handleLoad, image: previewImage ?? "", scale: editorState.scale, rotate: editorState.rotate })),
|
|
145
143
|
React.createElement(ButtonGroup, { size: "small", orientation: "vertical", disabled: !ready },
|
|
146
144
|
React.createElement(Button, { onClick: () => handleRotate(90), title: labels.rotateRight },
|
|
147
145
|
React.createElement(RotateRightIcon, null)),
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -37,7 +37,7 @@ export class CommonApp extends ReactApp {
|
|
|
37
37
|
*/
|
|
38
38
|
async refreshToken(props) {
|
|
39
39
|
// Destruct
|
|
40
|
-
const { callback, data, relogin = false, showLoading = false } = props
|
|
40
|
+
const { callback, data, relogin = false, showLoading = false } = props ?? {};
|
|
41
41
|
// Token
|
|
42
42
|
const token = this.getCacheToken();
|
|
43
43
|
if (token == null || token === "") {
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -38,7 +38,7 @@ export function ReactAppStateDetector(props) {
|
|
|
38
38
|
matchedFields = [];
|
|
39
39
|
targetFields.forEach((targetField) => {
|
|
40
40
|
if (changedFields.includes(targetField))
|
|
41
|
-
matchedFields
|
|
41
|
+
matchedFields?.push(targetField);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
// Callback
|
|
@@ -106,7 +106,6 @@ export class ReactApp extends CoreApp {
|
|
|
106
106
|
* @param culture New culture definition
|
|
107
107
|
*/
|
|
108
108
|
async changeCulture(culture) {
|
|
109
|
-
var _a, _b;
|
|
110
109
|
// Super call to update cultrue
|
|
111
110
|
const resources = await super.changeCulture(culture);
|
|
112
111
|
// Update component labels
|
|
@@ -124,7 +123,7 @@ export class ReactApp extends CoreApp {
|
|
|
124
123
|
});
|
|
125
124
|
// Document title
|
|
126
125
|
// Default is servier name's label or appName label
|
|
127
|
-
const title =
|
|
126
|
+
const title = this.get(this.name) ?? this.get("appName") ?? this.name;
|
|
128
127
|
const host = BridgeUtils.host;
|
|
129
128
|
if (host) {
|
|
130
129
|
// Notify host
|
|
@@ -164,7 +163,7 @@ export class ReactApp extends CoreApp {
|
|
|
164
163
|
* @returns Props
|
|
165
164
|
*/
|
|
166
165
|
getMoneyFormatProps(currency) {
|
|
167
|
-
return { culture: this.culture, currency: currency
|
|
166
|
+
return { culture: this.culture, currency: currency ?? this.currency };
|
|
168
167
|
}
|
|
169
168
|
/**
|
|
170
169
|
* Fresh countdown UI
|
|
@@ -241,8 +240,7 @@ export class ReactApp extends CoreApp {
|
|
|
241
240
|
* @param key Page title resource key
|
|
242
241
|
*/
|
|
243
242
|
setPageKey(key) {
|
|
244
|
-
|
|
245
|
-
this.setPageTitle((_a = this.get(key)) !== null && _a !== void 0 ? _a : "");
|
|
243
|
+
this.setPageTitle(this.get(key) ?? "");
|
|
246
244
|
}
|
|
247
245
|
/**
|
|
248
246
|
* Show input dialog
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -88,7 +88,7 @@ export class ServiceApp extends ReactApp {
|
|
|
88
88
|
*/
|
|
89
89
|
async refreshToken(props) {
|
|
90
90
|
// Destruct
|
|
91
|
-
const { appApi, callback, data, relogin = false, showLoading = false } = props
|
|
91
|
+
const { appApi, callback, data, relogin = false, showLoading = false } = props ?? {};
|
|
92
92
|
// Token
|
|
93
93
|
const token = this.getCacheToken();
|
|
94
94
|
if (token == null || token === "") {
|
|
@@ -116,7 +116,6 @@ export class ServiceApp extends ReactApp {
|
|
|
116
116
|
};
|
|
117
117
|
// Success callback
|
|
118
118
|
const success = async (result, failCallback) => {
|
|
119
|
-
var _a;
|
|
120
119
|
// Token
|
|
121
120
|
const refreshToken = this.getResponseToken(payload.response);
|
|
122
121
|
if (refreshToken == null || result.data == null) {
|
|
@@ -129,7 +128,7 @@ export class ServiceApp extends ReactApp {
|
|
|
129
128
|
// Use core system access token to service api to exchange service access token
|
|
130
129
|
const api = appApi ? appApi.api : this.serviceApi;
|
|
131
130
|
const serviceResult = await api.put("Auth/ExchangeToken", {
|
|
132
|
-
token: this.encryptEnhanced(userData.token, (
|
|
131
|
+
token: this.encryptEnhanced(userData.token, (appApi?.serviceId ?? this.settings.serviceId).toString())
|
|
133
132
|
}, {
|
|
134
133
|
showLoading,
|
|
135
134
|
onError: (error) => {
|
|
@@ -218,7 +217,7 @@ export class ServiceApp extends ReactApp {
|
|
|
218
217
|
* @returns Pure text
|
|
219
218
|
*/
|
|
220
219
|
serviceDecrypt(messageEncrypted, passphrase) {
|
|
221
|
-
return this.decrypt(messageEncrypted, passphrase
|
|
220
|
+
return this.decrypt(messageEncrypted, passphrase ?? this.servicePassphrase);
|
|
222
221
|
}
|
|
223
222
|
/**
|
|
224
223
|
* Service encrypt message
|
|
@@ -228,7 +227,7 @@ export class ServiceApp extends ReactApp {
|
|
|
228
227
|
* @returns Result
|
|
229
228
|
*/
|
|
230
229
|
serviceEncrypt(message, passphrase, iterations) {
|
|
231
|
-
return this.encrypt(message, passphrase
|
|
230
|
+
return this.encrypt(message, passphrase ?? this.servicePassphrase, iterations);
|
|
232
231
|
}
|
|
233
232
|
/**
|
|
234
233
|
* Try login
|
|
@@ -256,10 +255,9 @@ export class ServiceApp extends ReactApp {
|
|
|
256
255
|
* @param serviceUser Service user
|
|
257
256
|
*/
|
|
258
257
|
userLoginEx(user, refreshToken, serviceUser) {
|
|
259
|
-
var _a;
|
|
260
258
|
// Service user login
|
|
261
259
|
this.servicePassphrase =
|
|
262
|
-
|
|
260
|
+
this.decrypt(serviceUser.servicePassphrase, this.settings.serviceId.toString()) ?? "";
|
|
263
261
|
// Service user
|
|
264
262
|
this.serviceUser = serviceUser;
|
|
265
263
|
// Service API token
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { DataGridPageProps } from "./DataGridPageProps";
|
|
4
4
|
/**
|
|
@@ -6,4 +6,4 @@ import { DataGridPageProps } from "./DataGridPageProps";
|
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function DataGridPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
9
|
+
export declare function DataGridPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: DataGridPageProps<T, F>): React.JSX.Element;
|
|
@@ -12,10 +12,9 @@ import { GridUtils } from "../GridUtils";
|
|
|
12
12
|
* @returns Component
|
|
13
13
|
*/
|
|
14
14
|
export function DataGridPage(props) {
|
|
15
|
-
var _a;
|
|
16
15
|
// Destruct
|
|
17
16
|
const { adjustHeight, fields, fieldTemplate, height, loadData, mRef, sizeReadyMiliseconds = 100, pageProps = {}, cacheKey, cacheMinutes = 15, ...rest } = props;
|
|
18
|
-
|
|
17
|
+
pageProps.paddings ?? (pageProps.paddings = MUGlobal.pagePaddings);
|
|
19
18
|
// States
|
|
20
19
|
const [states, setStates] = React.useReducer((currentState, newState) => {
|
|
21
20
|
return { ...currentState, ...newState };
|
|
@@ -97,7 +96,7 @@ export function DataGridPage(props) {
|
|
|
97
96
|
return;
|
|
98
97
|
ref.reset({ data });
|
|
99
98
|
}, [ref, data]);
|
|
100
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
99
|
+
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
101
100
|
// Layout
|
|
102
101
|
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: states.element },
|
|
103
102
|
React.createElement(Stack, null,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import { DataGridExProps } from "../DataGridEx";
|
|
3
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
|
|
7
|
+
export type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplate> = SearchPageProps<T, F> & Omit<DataGridExProps<T>, "loadData" | "height"> & {
|
|
8
8
|
/**
|
|
9
9
|
* Height will be deducted
|
|
10
10
|
* @param height Current calcuated height
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ListPageProps } from "./ListPageProps";
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import { ListPageProps } from "./ListPageProps";
|
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function FixedListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
9
|
+
export declare function FixedListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListPageProps<T, F> & {
|
|
10
10
|
/**
|
|
11
11
|
* Height will be deducted
|
|
12
12
|
* @param height Current calcuated height
|
|
@@ -12,10 +12,9 @@ import { GridUtils } from "../GridUtils";
|
|
|
12
12
|
* @returns Component
|
|
13
13
|
*/
|
|
14
14
|
export function FixedListPage(props) {
|
|
15
|
-
var _a;
|
|
16
15
|
// Destruct
|
|
17
16
|
const { adjustHeight, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, cacheKey, cacheMinutes = 15, ...rest } = props;
|
|
18
|
-
|
|
17
|
+
pageProps.paddings ?? (pageProps.paddings = MUGlobal.pagePaddings);
|
|
19
18
|
// States
|
|
20
19
|
const [states] = React.useState({});
|
|
21
20
|
const initLoadedRef = React.useRef();
|
|
@@ -89,7 +88,7 @@ export function FixedListPage(props) {
|
|
|
89
88
|
}, ...rest })));
|
|
90
89
|
}
|
|
91
90
|
}, [rect]);
|
|
92
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
91
|
+
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
93
92
|
const { paddings, ...pageRest } = pageProps;
|
|
94
93
|
// Layout
|
|
95
94
|
return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer },
|
package/lib/pages/LeftDrawer.js
CHANGED
|
@@ -4,9 +4,8 @@ import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
|
4
4
|
import { DrawerHeader } from "./DrawerHeader";
|
|
5
5
|
import { globalApp } from "../app/ReactApp";
|
|
6
6
|
export function LeftDrawer(props) {
|
|
7
|
-
var _a;
|
|
8
7
|
// Destruct
|
|
9
|
-
const { mdUp, width, appName = globalApp
|
|
8
|
+
const { mdUp, width, appName = globalApp?.get("appName"), onMinimize, open = mdUp, children } = props;
|
|
10
9
|
// Menu open/close state
|
|
11
10
|
const [openLocal, setOpen] = React.useState();
|
|
12
11
|
const handleDrawerClose = () => {
|
|
@@ -29,7 +28,7 @@ export function LeftDrawer(props) {
|
|
|
29
28
|
keepMounted: true // Better open performance on mobile.
|
|
30
29
|
} },
|
|
31
30
|
React.createElement(DrawerHeader, null,
|
|
32
|
-
React.createElement("a", { href: "https://www.etsoo.com", title:
|
|
31
|
+
React.createElement("a", { href: "https://www.etsoo.com", title: globalApp?.get("etsoo") ?? "ETSOO", target: "_blank", rel: "noreferrer" },
|
|
33
32
|
React.createElement(Avatar, { src: process.env.PUBLIC_URL + "/logo192.png", variant: "square", sx: { marginLeft: -0.5, marginRight: 1.5, marginBottom: 1 } })),
|
|
34
33
|
React.createElement(Typography, { noWrap: true, component: "div", title: appName, sx: { flexGrow: 2 } }, appName),
|
|
35
34
|
React.createElement(IconButton, { size: "small", onClick: handleDrawerClose },
|
package/lib/pages/ListPage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ListPageProps } from "./ListPageProps";
|
|
4
4
|
/**
|
|
@@ -6,4 +6,4 @@ import { ListPageProps } from "./ListPageProps";
|
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function ListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
9
|
+
export declare function ListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListPageProps<T, F>): React.JSX.Element;
|
package/lib/pages/ListPage.js
CHANGED
|
@@ -12,10 +12,9 @@ import { GridUtils } from "../GridUtils";
|
|
|
12
12
|
* @returns Component
|
|
13
13
|
*/
|
|
14
14
|
export function ListPage(props) {
|
|
15
|
-
var _a;
|
|
16
15
|
// Destruct
|
|
17
16
|
const { fields, fieldTemplate, loadData, mRef, pageProps = {}, cacheKey, cacheMinutes = 15, ...rest } = props;
|
|
18
|
-
|
|
17
|
+
pageProps.paddings ?? (pageProps.paddings = MUGlobal.pagePaddings);
|
|
19
18
|
// States
|
|
20
19
|
const [states] = React.useState({});
|
|
21
20
|
const refs = useCombinedRefs(mRef, (ref) => {
|
|
@@ -69,7 +68,7 @@ export function ListPage(props) {
|
|
|
69
68
|
return;
|
|
70
69
|
sessionStorage.setItem(`${cacheKey}-scroll`, JSON.stringify(props));
|
|
71
70
|
};
|
|
72
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
71
|
+
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
73
72
|
// Layout
|
|
74
73
|
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: globalThis },
|
|
75
74
|
React.createElement(Stack, null,
|
|
@@ -4,4 +4,4 @@ import { SearchPageProps } from "./SearchPageProps";
|
|
|
4
4
|
/**
|
|
5
5
|
* List page props
|
|
6
6
|
*/
|
|
7
|
-
export type ListPageProps<T extends object, F extends DataTypes.BasicTemplate
|
|
7
|
+
export type ListPageProps<T extends object, F extends DataTypes.BasicTemplate> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T>, "loadData">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ResponsePageProps } from "./ResponsivePageProps";
|
|
4
4
|
/**
|
|
@@ -6,4 +6,4 @@ import { ResponsePageProps } from "./ResponsivePageProps";
|
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function ResponsivePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
9
|
+
export declare function ResponsivePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ResponsePageProps<T, F>): React.JSX.Element;
|
|
@@ -9,10 +9,9 @@ import { OperationMessageContainer } from "../messages/OperationMessageContainer
|
|
|
9
9
|
* @returns Component
|
|
10
10
|
*/
|
|
11
11
|
export function ResponsivePage(props) {
|
|
12
|
-
var _a;
|
|
13
12
|
// Destruct
|
|
14
13
|
const { pageProps = {}, operationMessageHandler, ...rest } = props;
|
|
15
|
-
|
|
14
|
+
pageProps.paddings ?? (pageProps.paddings = MUGlobal.pagePaddings);
|
|
16
15
|
const { paddings, fabColumnDirection, ...pageRest } = pageProps;
|
|
17
16
|
// State
|
|
18
17
|
const [scrollContainer, setScrollContainer] = React.useState();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GridMethodRef } from "@etsoo/react";
|
|
3
|
-
import { DataTypes
|
|
3
|
+
import { DataTypes } from "@etsoo/shared";
|
|
4
4
|
import { ListChildComponentProps } from "react-window";
|
|
5
5
|
import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from "../ScrollerListEx";
|
|
6
6
|
import { DataGridPageProps } from "./DataGridPageProps";
|
|
@@ -8,7 +8,7 @@ import { OperationMessageHandlerAll } from "../messages/OperationMessageHandler"
|
|
|
8
8
|
/**
|
|
9
9
|
* Response page props
|
|
10
10
|
*/
|
|
11
|
-
export type ResponsePageProps<T extends object, F extends DataTypes.BasicTemplate
|
|
11
|
+
export type ResponsePageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<DataGridPageProps<T, F>, "mRef" | "itemKey" | "onScroll" | "onItemsRendered"> & {
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
14
|
* @param height Current height
|
package/lib/pages/TablePage.js
CHANGED
|
@@ -12,10 +12,9 @@ import { GridUtils } from "../GridUtils";
|
|
|
12
12
|
* @returns Component
|
|
13
13
|
*/
|
|
14
14
|
export function TablePage(props) {
|
|
15
|
-
var _a;
|
|
16
15
|
// Destruct
|
|
17
16
|
const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, cacheKey, cacheMinutes = 15, ...rest } = props;
|
|
18
|
-
|
|
17
|
+
pageProps.paddings ?? (pageProps.paddings = MUGlobal.pagePaddings);
|
|
19
18
|
// States
|
|
20
19
|
const [states] = React.useState({});
|
|
21
20
|
const refs = useCombinedRefs(mRef, (ref) => {
|
|
@@ -43,8 +42,7 @@ export function TablePage(props) {
|
|
|
43
42
|
const searchData = GridUtils.getSearchData(cacheKey);
|
|
44
43
|
// Total width
|
|
45
44
|
const totalWidth = React.useMemo(() => columns.reduce((previousValue, { width, minWidth }) => {
|
|
46
|
-
|
|
47
|
-
return previousValue + ((_a = width !== null && width !== void 0 ? width : minWidth) !== null && _a !== void 0 ? _a : TableExMinWidth);
|
|
45
|
+
return previousValue + (width ?? minWidth ?? TableExMinWidth);
|
|
48
46
|
}, 0), [columns]);
|
|
49
47
|
// Watch container
|
|
50
48
|
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
|
|
@@ -59,7 +57,7 @@ export function TablePage(props) {
|
|
|
59
57
|
return (React.createElement(TableEx, { autoLoad: false, columns: columns, loadData: localLoadData, maxHeight: maxHeight, mRef: refs, ...rest }));
|
|
60
58
|
}
|
|
61
59
|
}, [rect]);
|
|
62
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
60
|
+
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
63
61
|
// Layout
|
|
64
62
|
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: globalThis },
|
|
65
63
|
React.createElement(Stack, null,
|
package/lib/pages/UserMenu.js
CHANGED
|
@@ -30,9 +30,8 @@ export function UserMenu(props) {
|
|
|
30
30
|
setAnchorEl(undefined);
|
|
31
31
|
};
|
|
32
32
|
const handleClick = async (event) => {
|
|
33
|
-
var _a;
|
|
34
33
|
handleMenuClose();
|
|
35
|
-
const item =
|
|
34
|
+
const item = event.target?.closest("li[href]");
|
|
36
35
|
if (item != null) {
|
|
37
36
|
const href = item.getAttribute("href");
|
|
38
37
|
if (href) {
|
package/lib/pages/ViewPage.js
CHANGED
|
@@ -21,10 +21,10 @@ export function ViewPageGridItem(props) {
|
|
|
21
21
|
// Default options
|
|
22
22
|
let options = {};
|
|
23
23
|
if (gridProps.xs == null && gridProps.md == null) {
|
|
24
|
-
options = getResp(singleRow
|
|
24
|
+
options = getResp(singleRow ?? "small");
|
|
25
25
|
}
|
|
26
26
|
else if (singleRow != null) {
|
|
27
|
-
options = getResp(singleRow
|
|
27
|
+
options = getResp(singleRow ?? "small");
|
|
28
28
|
}
|
|
29
29
|
// Layout
|
|
30
30
|
return (React.createElement(Grid, { item: true, ...gridProps, ...options },
|
|
@@ -60,13 +60,12 @@ function getResp(singleRow) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
function getItemField(field, data) {
|
|
63
|
-
var _a, _b, _c;
|
|
64
63
|
// Item data and label
|
|
65
64
|
let itemData, itemLabel, gridProps = {};
|
|
66
65
|
if (Array.isArray(field)) {
|
|
67
66
|
const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
|
|
68
67
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
69
|
-
itemLabel =
|
|
68
|
+
itemLabel = globalApp?.get(fieldData) ?? fieldData;
|
|
70
69
|
gridProps = { ...getResp(singleRow) };
|
|
71
70
|
}
|
|
72
71
|
else if (typeof field === "object") {
|
|
@@ -88,12 +87,12 @@ function getItemField(field, data) {
|
|
|
88
87
|
typeof fieldLabel === "function"
|
|
89
88
|
? fieldLabel(data)
|
|
90
89
|
: fieldLabel != null
|
|
91
|
-
?
|
|
90
|
+
? globalApp?.get(fieldLabel) ?? fieldLabel
|
|
92
91
|
: fieldLabel;
|
|
93
92
|
}
|
|
94
93
|
else {
|
|
95
94
|
itemData = formatItemData(data[field]);
|
|
96
|
-
itemLabel =
|
|
95
|
+
itemLabel = globalApp?.get(field) ?? field;
|
|
97
96
|
}
|
|
98
97
|
return [itemData, itemLabel, gridProps];
|
|
99
98
|
}
|
|
@@ -155,7 +154,7 @@ export function ViewPage(props) {
|
|
|
155
154
|
Utils.getResult(children, data, refresh),
|
|
156
155
|
pullToRefresh && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: refresh, shouldPullToRefresh: () => {
|
|
157
156
|
const container = document.querySelector(pullContainer);
|
|
158
|
-
return !
|
|
157
|
+
return !container?.scrollTop;
|
|
159
158
|
} })),
|
|
160
159
|
React.createElement(ScrollRestoration, null)))));
|
|
161
160
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.44",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"types": "lib/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"build": "tsc",
|
|
@@ -50,19 +51,13 @@
|
|
|
50
51
|
"@emotion/css": "^11.11.2",
|
|
51
52
|
"@emotion/react": "^11.11.4",
|
|
52
53
|
"@emotion/styled": "^11.11.0",
|
|
53
|
-
"@etsoo/appscript": "^1.4.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
56
|
-
"@etsoo/shared": "^1.2.
|
|
54
|
+
"@etsoo/appscript": "^1.4.79",
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.40",
|
|
56
|
+
"@etsoo/react": "^1.7.31",
|
|
57
|
+
"@etsoo/shared": "^1.2.31",
|
|
57
58
|
"@mui/icons-material": "^5.15.11",
|
|
58
59
|
"@mui/material": "^5.15.11",
|
|
59
|
-
"@mui/x-data-grid": "^6.19.
|
|
60
|
-
"@types/pica": "^9.0.4",
|
|
61
|
-
"@types/pulltorefreshjs": "^0.1.7",
|
|
62
|
-
"@types/react": "^18.2.60",
|
|
63
|
-
"@types/react-avatar-editor": "^13.0.2",
|
|
64
|
-
"@types/react-dom": "^18.2.19",
|
|
65
|
-
"@types/react-input-mask": "^3.0.5",
|
|
60
|
+
"@mui/x-data-grid": "^6.19.6",
|
|
66
61
|
"chart.js": "^4.4.2",
|
|
67
62
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
68
63
|
"eventemitter3": "^5.0.1",
|
|
@@ -86,6 +81,13 @@
|
|
|
86
81
|
"@testing-library/jest-dom": "^6.4.2",
|
|
87
82
|
"@testing-library/react": "^14.2.1",
|
|
88
83
|
"@types/jest": "^29.5.12",
|
|
84
|
+
"@types/pica": "^9.0.4",
|
|
85
|
+
"@types/pulltorefreshjs": "^0.1.7",
|
|
86
|
+
"@types/react": "^18.2.61",
|
|
87
|
+
"@types/react-avatar-editor": "^13.0.2",
|
|
88
|
+
"@types/react-dom": "^18.2.19",
|
|
89
|
+
"@types/react-input-mask": "^3.0.5",
|
|
90
|
+
"@types/react-window": "^1.8.8",
|
|
89
91
|
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
90
92
|
"@typescript-eslint/parser": "^7.1.0",
|
|
91
93
|
"jest": "^29.7.0",
|
package/src/DataGridEx.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ScrollerGridProps,
|
|
13
13
|
useCombinedRefs
|
|
14
14
|
} from "@etsoo/react";
|
|
15
|
-
import { DataTypes,
|
|
15
|
+
import { DataTypes, Utils } from "@etsoo/shared";
|
|
16
16
|
import {
|
|
17
17
|
Box,
|
|
18
18
|
BoxProps,
|
|
@@ -39,11 +39,8 @@ export type DataGridExFooterItemRendererProps<T extends object> = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Extended DataGrid with VariableSizeGrid props
|
|
41
41
|
*/
|
|
42
|
-
export type DataGridExProps<
|
|
43
|
-
T
|
|
44
|
-
D extends DataTypes.Keys<T>
|
|
45
|
-
> = Omit<
|
|
46
|
-
ScrollerGridProps<T, D>,
|
|
42
|
+
export type DataGridExProps<T extends object> = Omit<
|
|
43
|
+
ScrollerGridProps<T>,
|
|
47
44
|
"itemRenderer" | "columnCount" | "columnWidth" | "width"
|
|
48
45
|
> & {
|
|
49
46
|
/**
|
|
@@ -216,10 +213,7 @@ export function DataGridExCalColumns<T>(columns: GridColumn<T>[]) {
|
|
|
216
213
|
* @param props Props
|
|
217
214
|
* @returns Component
|
|
218
215
|
*/
|
|
219
|
-
export function DataGridEx<
|
|
220
|
-
T extends object,
|
|
221
|
-
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
222
|
-
>(props: DataGridExProps<T, D>) {
|
|
216
|
+
export function DataGridEx<T extends object>(props: DataGridExProps<T>) {
|
|
223
217
|
// Theme
|
|
224
218
|
const theme = useTheme();
|
|
225
219
|
|
|
@@ -367,7 +361,7 @@ export function DataGridEx<
|
|
|
367
361
|
footerItemRenderer = DataGridRenderers.defaultFooterItemRenderer,
|
|
368
362
|
hideFooter = false,
|
|
369
363
|
hoverColor = "#f6f9fb",
|
|
370
|
-
idField = "id" as
|
|
364
|
+
idField = "id" as DataTypes.Keys<T>,
|
|
371
365
|
mRef = React.createRef(),
|
|
372
366
|
onClick,
|
|
373
367
|
onDoubleClick,
|
|
@@ -636,7 +630,7 @@ export function DataGridEx<
|
|
|
636
630
|
: undefined;
|
|
637
631
|
|
|
638
632
|
return (
|
|
639
|
-
<ScrollerGrid<T
|
|
633
|
+
<ScrollerGrid<T>
|
|
640
634
|
className={Utils.mergeClasses(
|
|
641
635
|
"DataGridEx-Body",
|
|
642
636
|
"DataGridEx-CustomBar",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import { Box, Stack, SxProps, Theme } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import {
|
|
@@ -39,10 +39,9 @@ import { GridUtils } from "./GridUtils";
|
|
|
39
39
|
*/
|
|
40
40
|
export type ResponsibleContainerProps<
|
|
41
41
|
T extends object,
|
|
42
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
43
|
-
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
42
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
44
43
|
> = Omit<
|
|
45
|
-
DataGridExProps<T
|
|
44
|
+
DataGridExProps<T>,
|
|
46
45
|
| "height"
|
|
47
46
|
| "itemKey"
|
|
48
47
|
| "loadData"
|
|
@@ -190,9 +189,8 @@ function defaultContainerBoxSx(
|
|
|
190
189
|
*/
|
|
191
190
|
export function ResponsibleContainer<
|
|
192
191
|
T extends object,
|
|
193
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
194
|
-
|
|
195
|
-
>(props: ResponsibleContainerProps<T, F, D>) {
|
|
192
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
193
|
+
>(props: ResponsibleContainerProps<T, F>) {
|
|
196
194
|
// Destruct
|
|
197
195
|
const {
|
|
198
196
|
adjustHeight,
|
|
@@ -371,7 +369,7 @@ export function ResponsibleContainer<
|
|
|
371
369
|
|
|
372
370
|
return [
|
|
373
371
|
<Box className="DataGridBox">
|
|
374
|
-
<DataGridEx<T
|
|
372
|
+
<DataGridEx<T>
|
|
375
373
|
autoLoad={!hasFields}
|
|
376
374
|
height={heightLocal}
|
|
377
375
|
width={rect.width}
|
|
@@ -404,7 +402,7 @@ export function ResponsibleContainer<
|
|
|
404
402
|
|
|
405
403
|
return [
|
|
406
404
|
<Box className="ListBox" sx={{ height: heightLocal }}>
|
|
407
|
-
<ScrollerListEx<T
|
|
405
|
+
<ScrollerListEx<T>
|
|
408
406
|
autoLoad={!hasFields}
|
|
409
407
|
height={heightLocal}
|
|
410
408
|
loadData={localLoadData}
|