@etsoo/materialui 1.4.4 → 1.4.6
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/AddresSelector.d.ts +3 -2
- package/lib/AddresSelector.js +3 -3
- package/lib/HiSelector.d.ts +3 -3
- package/lib/HiSelector.js +2 -2
- package/lib/HiSelectorTL.d.ts +3 -3
- package/lib/HiSelectorTL.js +2 -2
- package/lib/ResponsiveStyleValue.d.ts +7 -0
- package/lib/ResponsiveStyleValue.js +1 -0
- package/lib/app/CommonApp.d.ts +2 -7
- package/lib/app/CommonApp.js +13 -70
- package/lib/app/ReactApp.d.ts +1 -2
- package/lib/app/ReactApp.js +2 -3
- package/lib/app/ServiceApp.d.ts +5 -7
- package/lib/app/ServiceApp.js +12 -9
- package/lib/custom/CustomFieldUtils.d.ts +8 -2
- package/lib/custom/CustomFieldUtils.js +5 -5
- package/lib/custom/CustomFieldViewer.d.ts +2 -2
- package/lib/custom/CustomFieldViewer.js +3 -3
- package/lib/custom/CustomFieldWindow.d.ts +2 -2
- package/lib/custom/CustomFieldWindow.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/pages/EditPage.js +2 -2
- package/lib/pages/ViewPage.d.ts +3 -3
- package/lib/pages/ViewPage.js +7 -6
- package/package.json +8 -8
- package/src/AddresSelector.tsx +13 -13
- package/src/HiSelector.tsx +13 -13
- package/src/HiSelectorTL.tsx +14 -13
- package/src/ResponsiveStyleValue.ts +11 -0
- package/src/app/CommonApp.ts +16 -99
- package/src/app/ReactApp.ts +2 -8
- package/src/app/ServiceApp.ts +14 -14
- package/src/custom/CustomFieldUtils.tsx +10 -11
- package/src/custom/CustomFieldViewer.tsx +7 -8
- package/src/custom/CustomFieldWindow.tsx +4 -4
- package/src/index.ts +1 -0
- package/src/pages/EditPage.tsx +10 -5
- package/src/pages/ViewPage.tsx +26 -25
package/lib/AddresSelector.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AddressApi, AddressCity, AddressDistrict, AddressRegionDb, AddressState } from "@etsoo/appscript";
|
|
2
|
+
import { GridSize } from "@mui/material";
|
|
2
3
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
+
import { ResponsiveStyleValue } from "./ResponsiveStyleValue";
|
|
4
5
|
/**
|
|
5
6
|
* Address field
|
|
6
7
|
*/
|
|
@@ -23,7 +24,7 @@ export type AddressSelectorProps = {
|
|
|
23
24
|
/**
|
|
24
25
|
* Break points
|
|
25
26
|
*/
|
|
26
|
-
breakPoints?:
|
|
27
|
+
breakPoints?: ResponsiveStyleValue<GridSize>;
|
|
27
28
|
/**
|
|
28
29
|
* City
|
|
29
30
|
*/
|
package/lib/AddresSelector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { FormLabel,
|
|
2
|
+
import { FormLabel, Grid2 } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { globalApp } from "./app/ReactApp";
|
|
5
5
|
import { ComboBox } from "./ComboBox";
|
|
@@ -123,12 +123,12 @@ export function AddressSelector(props) {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
// Layout
|
|
126
|
-
return (_jsxs(React.Fragment, { children: [label && (_jsx(
|
|
126
|
+
return (_jsxs(React.Fragment, { children: [label && (_jsx(Grid2, { size: { xs: 12 }, children: _jsx(FormLabel, { required: required, sx: { fontSize: (theme) => theme.typography.caption }, children: label }) })), !hideRegion && (_jsx(Grid2, { size: breakPoints, children: _jsx(Tiplist, { label: regionLabel, name: AddressField.Region, search: search, fullWidth: true, idValue: regionState, loadData: (keyword, id, items) => api.getRegions({
|
|
127
127
|
keyword,
|
|
128
128
|
id,
|
|
129
129
|
items,
|
|
130
130
|
favoredIds: favoredIds == null
|
|
131
131
|
? undefined
|
|
132
132
|
: favoredIds(AddressField.Region)
|
|
133
|
-
}), inputRequired: required, inputError: error, inputHelperText: helperText, onChange: (_event, value) => handleChange([AddressField.Region, value]) }) })), _jsx(
|
|
133
|
+
}), inputRequired: required, inputError: error, inputHelperText: helperText, onChange: (_event, value) => handleChange([AddressField.Region, value]) }) })), _jsx(Grid2, { size: breakPoints, children: _jsx(ComboBox, { name: AddressField.State, label: stateLabel, search: search, fullWidth: true, idValue: stateState, options: states, inputRequired: required, inputError: hideRegion ? error : undefined, inputHelperText: hideRegion ? helperText : undefined, onChange: (_event, value) => handleChange([AddressField.State, value]) }) }), _jsx(Grid2, { size: breakPoints, children: _jsx(ComboBox, { name: AddressField.City, label: cityLabel, search: search, fullWidth: true, idValue: cityState, options: cities, onChange: (_event, value) => handleChange([AddressField.City, value]) }) }), _jsx(Grid2, { size: breakPoints, children: _jsx(ComboBox, { name: AddressField.District, label: districtLabel, search: search, fullWidth: true, idValue: districtState, options: districts, onChange: (_event, value) => handleChange([AddressField.District, value]) }) })] }));
|
|
134
134
|
}
|
package/lib/HiSelector.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataTypes, IdDefaultType, LabelDefaultType } from "@etsoo/shared";
|
|
2
|
-
import { SelectChangeEvent } from "@mui/material";
|
|
2
|
+
import { GridSize, SelectChangeEvent } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ResponsiveStyleValue } from "./ResponsiveStyleValue";
|
|
5
5
|
/**
|
|
6
6
|
* Hierarchy selector props
|
|
7
7
|
*/
|
|
@@ -9,7 +9,7 @@ export type HiSelectorProps<T extends object, D extends DataTypes.Keys<T> = IdDe
|
|
|
9
9
|
/**
|
|
10
10
|
* Break points
|
|
11
11
|
*/
|
|
12
|
-
breakPoints?:
|
|
12
|
+
breakPoints?: ResponsiveStyleValue<GridSize>;
|
|
13
13
|
/**
|
|
14
14
|
* Id field
|
|
15
15
|
*/
|
package/lib/HiSelector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { FormLabel,
|
|
2
|
+
import { FormLabel, Grid2 } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { SelectEx } from "./SelectEx";
|
|
5
5
|
/**
|
|
@@ -39,5 +39,5 @@ export function HiSelector(props) {
|
|
|
39
39
|
React.useEffect(() => {
|
|
40
40
|
updateValue(currentValue);
|
|
41
41
|
}, [currentValue]);
|
|
42
|
-
return (_jsxs(React.Fragment, { children: [label && (_jsx(
|
|
42
|
+
return (_jsxs(React.Fragment, { children: [label && (_jsx(Grid2, { size: { xs: 12 }, children: _jsx(FormLabel, { required: required, sx: { fontSize: (theme) => theme.typography.caption }, children: label }) })), _jsx("input", { type: "hidden", name: name, value: `${currentValue ?? ""}` }), _jsx(Grid2, { size: breakPoints, children: _jsx(SelectEx, { idField: idField, label: labels[0], labelField: labelField, name: "tab1", search: search, fullWidth: true, loadData: () => loadData(), value: values[0], onChange: (event) => doChange(event, 0), onItemChange: doItemChange, required: required, error: error, helperText: helperText, variant: variant }) }), localValues[0] != null && (_jsx(Grid2, { size: breakPoints, children: _jsx(SelectEx, { idField: idField, label: labels[1], labelField: labelField, name: "tab2", search: search, fullWidth: true, loadData: () => loadData(localValues[0]), value: values[1], onChange: (event) => doChange(event, 1), onItemChange: doItemChange, variant: variant }, `${localValues[0]}`) })), localValues[1] != null && (_jsx(Grid2, { size: breakPoints, children: _jsx(SelectEx, { idField: idField, label: labels[2], labelField: labelField, name: "tab3", search: search, fullWidth: true, loadData: () => loadData(localValues[1]), value: values[2], onChange: (event) => doChange(event, 2), onItemChange: doItemChange, variant: variant }, `${localValues[1]}`) })), localValues[2] != null && (_jsx(Grid2, { size: breakPoints, children: _jsx(SelectEx, { idField: idField, label: labels[3], labelField: labelField, name: "tab4", search: search, fullWidth: true, loadData: () => loadData(localValues[2]), value: values[3], onChange: (event) => doChange(event, 3), onItemChange: doItemChange, variant: variant }, `${localValues[2]}`) }))] }));
|
|
43
43
|
}
|
package/lib/HiSelectorTL.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
2
|
-
import { AutocompleteChangeReason } from "@mui/material";
|
|
2
|
+
import { AutocompleteChangeReason, GridSize } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ResponsiveStyleValue } from "./ResponsiveStyleValue";
|
|
5
5
|
/**
|
|
6
6
|
* Hierarchy tiplist selector props
|
|
7
7
|
*/
|
|
@@ -9,7 +9,7 @@ export type HiSelectorTLProps<T extends object, D extends DataTypes.Keys<T> = Id
|
|
|
9
9
|
/**
|
|
10
10
|
* Break points
|
|
11
11
|
*/
|
|
12
|
-
breakPoints?:
|
|
12
|
+
breakPoints?: ResponsiveStyleValue<GridSize>;
|
|
13
13
|
/**
|
|
14
14
|
* Id field
|
|
15
15
|
*/
|
package/lib/HiSelectorTL.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { FormLabel,
|
|
2
|
+
import { FormLabel, Grid2 } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { Tiplist } from "./Tiplist";
|
|
5
5
|
/**
|
|
@@ -33,5 +33,5 @@ export function HiSelectorTL(props) {
|
|
|
33
33
|
React.useEffect(() => {
|
|
34
34
|
updateValue(currentValue);
|
|
35
35
|
}, [currentValue]);
|
|
36
|
-
return (_jsxs(React.Fragment, { children: [label && (_jsx(
|
|
36
|
+
return (_jsxs(React.Fragment, { children: [label && (_jsx(Grid2, { size: { xs: 12 }, children: _jsx(FormLabel, { required: required, sx: { fontSize: (theme) => theme.typography.caption }, children: label }) })), _jsx("input", { type: "hidden", name: name, value: `${currentValue ?? ""}` }), _jsx(Grid2, { size: breakPoints, children: _jsx(Tiplist, { idField: idField, label: labels[0], name: "tab1", search: search, fullWidth: true, idValue: values[0], loadData: (keyword, id, items) => loadData(keyword, id, items), inputRequired: required, inputError: error, inputHelperText: helperText, onChange: (event, value, reason) => doChange(0, event, value, reason) }) }), localValues[0] != null && (_jsx(Grid2, { size: breakPoints, children: _jsx(Tiplist, { label: labels[1], idField: idField, name: "tab2", search: search, fullWidth: true, loadData: (keyword, id, items) => loadData(keyword, id, items, localValues[0]), idValue: values[1], onChange: (event, value, reason) => doChange(1, event, value, reason) }, `${localValues[0]}`) })), localValues[1] != null && (_jsx(Grid2, { size: breakPoints, children: _jsx(Tiplist, { label: labels[2], idField: idField, name: "tab3", search: search, fullWidth: true, loadData: (keyword, id, items) => loadData(keyword, id, items, localValues[1]), idValue: values[2], onChange: (event, value, reason) => doChange(2, event, value, reason) }, `${localValues[1]}`) })), localValues[2] != null && (_jsx(Grid2, { size: breakPoints, children: _jsx(Tiplist, { label: labels[3], idField: idField, name: "tab4", search: search, fullWidth: true, loadData: (keyword, id, items) => loadData(keyword, id, items, localValues[2]), idValue: values[3], onChange: (event, value, reason) => doChange(3, event, value, reason) }, `${localValues[2]}`) }))] }));
|
|
37
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAppSettings, IUser
|
|
1
|
+
import { AppLoginParams, IAppSettings, IUser } from "@etsoo/appscript";
|
|
2
2
|
import { IPageData } from "@etsoo/react";
|
|
3
3
|
import { ReactApp } from "./ReactApp";
|
|
4
4
|
/**
|
|
@@ -15,15 +15,10 @@ export declare abstract class CommonApp<U extends IUser = IUser, P extends IPage
|
|
|
15
15
|
* @returns Fields
|
|
16
16
|
*/
|
|
17
17
|
protected initCallEncryptedUpdateFields(): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Refresh token
|
|
20
|
-
* @param props Props
|
|
21
|
-
*/
|
|
22
|
-
refreshToken(props?: RefreshTokenProps): Promise<boolean>;
|
|
23
18
|
/**
|
|
24
19
|
* Try login
|
|
25
20
|
* @param showLoading Show loading bar or not
|
|
26
21
|
* @returns Result
|
|
27
22
|
*/
|
|
28
|
-
tryLogin(
|
|
23
|
+
tryLogin(params?: AppLoginParams): Promise<void>;
|
|
29
24
|
}
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -20,82 +20,25 @@ export class CommonApp extends ReactApp {
|
|
|
20
20
|
fields.push(CoreConstants.FieldUserIdSaved);
|
|
21
21
|
return fields;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Refresh token
|
|
25
|
-
* @param props Props
|
|
26
|
-
*/
|
|
27
|
-
async refreshToken(props) {
|
|
28
|
-
// Destruct
|
|
29
|
-
const { callback, showLoading = false } = props ?? {};
|
|
30
|
-
// Token
|
|
31
|
-
const token = this.getCacheToken();
|
|
32
|
-
if (token == null || token === "") {
|
|
33
|
-
if (callback)
|
|
34
|
-
callback(false);
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
// Reqest data
|
|
38
|
-
const rq = {
|
|
39
|
-
deviceId: this.deviceId
|
|
40
|
-
};
|
|
41
|
-
// Payload
|
|
42
|
-
const payload = {
|
|
43
|
-
// No loading bar needed to avoid screen flicks
|
|
44
|
-
showLoading,
|
|
45
|
-
config: { headers: { [CoreConstants.TokenHeaderRefresh]: token } },
|
|
46
|
-
onError: (error) => {
|
|
47
|
-
if (callback)
|
|
48
|
-
callback(error);
|
|
49
|
-
// Prevent further processing
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// Success callback
|
|
54
|
-
const success = (result, failCallback) => {
|
|
55
|
-
// Token
|
|
56
|
-
const refreshToken = this.getResponseToken(payload.response);
|
|
57
|
-
if (refreshToken == null || result.data == null) {
|
|
58
|
-
if (failCallback)
|
|
59
|
-
failCallback(this.get("noData"));
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
// Keep
|
|
63
|
-
const keep = this.storage.getData(CoreConstants.FieldLoginKeep, false);
|
|
64
|
-
// User login
|
|
65
|
-
this.userLogin(result.data, refreshToken, keep);
|
|
66
|
-
// Callback
|
|
67
|
-
if (failCallback)
|
|
68
|
-
failCallback(true);
|
|
69
|
-
return true;
|
|
70
|
-
};
|
|
71
|
-
// Call API
|
|
72
|
-
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
73
|
-
if (result == null)
|
|
74
|
-
return false;
|
|
75
|
-
if (!result.ok) {
|
|
76
|
-
// Remove the wrong token
|
|
77
|
-
this.clearCacheToken();
|
|
78
|
-
// Callback
|
|
79
|
-
if (callback)
|
|
80
|
-
callback(result);
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return success(result, callback);
|
|
84
|
-
}
|
|
85
23
|
/**
|
|
86
24
|
* Try login
|
|
87
25
|
* @param showLoading Show loading bar or not
|
|
88
26
|
* @returns Result
|
|
89
27
|
*/
|
|
90
|
-
async tryLogin(
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
28
|
+
async tryLogin(params) {
|
|
29
|
+
// Check status
|
|
30
|
+
if (this.isTryingLogin)
|
|
31
|
+
return;
|
|
32
|
+
this.isTryingLogin = true;
|
|
95
33
|
// Refresh token
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
34
|
+
await this.refreshToken({
|
|
35
|
+
showLoading: params?.showLoading
|
|
36
|
+
}, (result) => {
|
|
37
|
+
if (result) {
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.toLoginPage(params);
|
|
41
|
+
}
|
|
99
42
|
});
|
|
100
43
|
}
|
|
101
44
|
}
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -211,10 +211,9 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
|
|
|
211
211
|
* User login extended
|
|
212
212
|
* @param user New user
|
|
213
213
|
* @param refreshToken Refresh token
|
|
214
|
-
* @param keep Keep in local storage or not
|
|
215
214
|
* @param dispatch User state dispatch
|
|
216
215
|
*/
|
|
217
|
-
userLogin(user: D, refreshToken: string,
|
|
216
|
+
userLogin(user: D, refreshToken: string, dispatch?: boolean): void;
|
|
218
217
|
/**
|
|
219
218
|
* User logout
|
|
220
219
|
* @param clearToken Clear refresh token or not
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -257,12 +257,11 @@ export class ReactApp extends CoreApp {
|
|
|
257
257
|
* User login extended
|
|
258
258
|
* @param user New user
|
|
259
259
|
* @param refreshToken Refresh token
|
|
260
|
-
* @param keep Keep in local storage or not
|
|
261
260
|
* @param dispatch User state dispatch
|
|
262
261
|
*/
|
|
263
|
-
userLogin(user, refreshToken,
|
|
262
|
+
userLogin(user, refreshToken, dispatch) {
|
|
264
263
|
// Super call, set token
|
|
265
|
-
super.userLogin(user, refreshToken
|
|
264
|
+
super.userLogin(user, refreshToken);
|
|
266
265
|
// Dispatch action
|
|
267
266
|
if (this.userStateDispatch != null && dispatch !== false)
|
|
268
267
|
this.userStateDispatch({
|
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiRefreshTokenDto, ExternalEndpoint, IApi } from "@etsoo/appscript";
|
|
1
|
+
import { ApiRefreshTokenDto, AppLoginParams, ExternalEndpoint, IApi } from "@etsoo/appscript";
|
|
2
2
|
import { IServiceApp } from "./IServiceApp";
|
|
3
3
|
import { IServiceAppSettings } from "./IServiceAppSettings";
|
|
4
4
|
import { IServicePageData } from "./IServicePage";
|
|
@@ -36,18 +36,16 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
36
36
|
loadCore(): void;
|
|
37
37
|
/**
|
|
38
38
|
* Go to the login page
|
|
39
|
-
* @
|
|
40
|
-
* @param removeUrl Remove current URL for reuse
|
|
39
|
+
* @params Login parameters
|
|
41
40
|
*/
|
|
42
|
-
toLoginPage(
|
|
41
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
43
42
|
/**
|
|
44
43
|
* User login extended
|
|
45
44
|
* @param user New user
|
|
46
45
|
* @param refreshToken Refresh token
|
|
47
|
-
* @param keep Keep in local storage or not
|
|
48
46
|
* @param dispatch User state dispatch
|
|
49
47
|
*/
|
|
50
|
-
userLogin(user: U, refreshToken: string,
|
|
48
|
+
userLogin(user: U, refreshToken: string, dispatch?: boolean): void;
|
|
51
49
|
/**
|
|
52
50
|
*
|
|
53
51
|
* @param user Current user
|
|
@@ -55,5 +53,5 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
55
53
|
* @param keep Keep in local storage or not
|
|
56
54
|
* @param dispatch User state dispatch
|
|
57
55
|
*/
|
|
58
|
-
userLoginEx(user: U & ServiceUserToken, core?: ApiRefreshTokenDto,
|
|
56
|
+
userLoginEx(user: U & ServiceUserToken, core?: ApiRefreshTokenDto, dispatch?: boolean): void;
|
|
59
57
|
}
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthApi, BridgeUtils } from "@etsoo/appscript";
|
|
2
2
|
import { ReactApp } from "./ReactApp";
|
|
3
3
|
const coreName = "core";
|
|
4
|
+
const coreTokenKey = "core-refresh-token";
|
|
4
5
|
/**
|
|
5
6
|
* Core Service App
|
|
6
7
|
* Service login to core system, get the refesh token and access token
|
|
@@ -37,10 +38,11 @@ export class ServiceApp extends ReactApp {
|
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Go to the login page
|
|
40
|
-
* @
|
|
41
|
-
* @param removeUrl Remove current URL for reuse
|
|
41
|
+
* @params Login parameters
|
|
42
42
|
*/
|
|
43
|
-
toLoginPage(
|
|
43
|
+
toLoginPage(params) {
|
|
44
|
+
// Destruct
|
|
45
|
+
const { removeUrl, showLoading, ...rest } = params ?? {};
|
|
44
46
|
// Cache current URL
|
|
45
47
|
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
46
48
|
// Get the redirect URL
|
|
@@ -53,7 +55,7 @@ export class ServiceApp extends ReactApp {
|
|
|
53
55
|
if (!url)
|
|
54
56
|
return;
|
|
55
57
|
// Add try login flag
|
|
56
|
-
url = url.
|
|
58
|
+
url = url.addUrlParams(rest);
|
|
57
59
|
// Is it embeded?
|
|
58
60
|
if (this.embedded) {
|
|
59
61
|
globalThis.parent.postMessage(["login", url], this.coreOrigin);
|
|
@@ -74,10 +76,9 @@ export class ServiceApp extends ReactApp {
|
|
|
74
76
|
* User login extended
|
|
75
77
|
* @param user New user
|
|
76
78
|
* @param refreshToken Refresh token
|
|
77
|
-
* @param keep Keep in local storage or not
|
|
78
79
|
* @param dispatch User state dispatch
|
|
79
80
|
*/
|
|
80
|
-
userLogin(user, refreshToken,
|
|
81
|
+
userLogin(user, refreshToken, dispatch) {
|
|
81
82
|
if (user.clientDeviceId && user.passphrase) {
|
|
82
83
|
// Save the passphrase
|
|
83
84
|
// Interpolated string expressions are different between TypeScript and C# for the null value
|
|
@@ -88,7 +89,7 @@ export class ServiceApp extends ReactApp {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
// Super call, set token
|
|
91
|
-
super.userLogin(user, refreshToken,
|
|
92
|
+
super.userLogin(user, refreshToken, dispatch);
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
*
|
|
@@ -97,10 +98,10 @@ export class ServiceApp extends ReactApp {
|
|
|
97
98
|
* @param keep Keep in local storage or not
|
|
98
99
|
* @param dispatch User state dispatch
|
|
99
100
|
*/
|
|
100
|
-
userLoginEx(user, core,
|
|
101
|
+
userLoginEx(user, core, dispatch) {
|
|
101
102
|
// User login
|
|
102
103
|
const { refreshToken } = user;
|
|
103
|
-
this.userLogin(user, refreshToken,
|
|
104
|
+
this.userLogin(user, refreshToken, dispatch);
|
|
104
105
|
// Core system login
|
|
105
106
|
core ?? (core = {
|
|
106
107
|
refreshToken,
|
|
@@ -108,6 +109,8 @@ export class ServiceApp extends ReactApp {
|
|
|
108
109
|
tokenType: user.tokenScheme ?? "Bearer",
|
|
109
110
|
expiresIn: user.seconds
|
|
110
111
|
});
|
|
112
|
+
// Cache the core system refresh token
|
|
113
|
+
this.storage.setData(coreTokenKey, core.refreshToken);
|
|
111
114
|
this.exchangeTokenAll(core, coreName);
|
|
112
115
|
}
|
|
113
116
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomFieldData, CustomFieldSpace } from "@etsoo/appscript";
|
|
2
2
|
import { CustomFieldReactCollection, ICustomFieldReact } from "@etsoo/react";
|
|
3
3
|
import { IdType, ListType2 } from "@etsoo/shared";
|
|
4
|
-
import {
|
|
4
|
+
import { GridSize } from "@mui/material";
|
|
5
5
|
import { TypographyProps } from "@mui/material/Typography";
|
|
6
6
|
/**
|
|
7
7
|
* Custom field utilities
|
|
@@ -34,7 +34,13 @@ export declare namespace CustomFieldUtils {
|
|
|
34
34
|
* @param space Space
|
|
35
35
|
* @returns Result
|
|
36
36
|
*/
|
|
37
|
-
function transformSpace(space?: CustomFieldSpace):
|
|
37
|
+
function transformSpace(space?: CustomFieldSpace): {
|
|
38
|
+
xs?: GridSize | null | undefined;
|
|
39
|
+
sm?: GridSize | null | undefined;
|
|
40
|
+
md?: GridSize | null | undefined;
|
|
41
|
+
lg?: GridSize | null | undefined;
|
|
42
|
+
xl?: GridSize | null | undefined;
|
|
43
|
+
};
|
|
38
44
|
/**
|
|
39
45
|
* Update ref options
|
|
40
46
|
* @param fields Fields
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Grid2, Typography } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { FieldCheckbox } from "./FieldCheckbox";
|
|
5
5
|
import { FieldAmountLabel } from "./FieldAmountLabel";
|
|
@@ -63,7 +63,7 @@ export var CustomFieldUtils;
|
|
|
63
63
|
fieldCalback(field);
|
|
64
64
|
const creator = CustomFieldUtils.customFieldCreators[field.type];
|
|
65
65
|
if (creator == null) {
|
|
66
|
-
return (_jsx(
|
|
66
|
+
return (_jsx(Grid2, { size: transformSpace(field.space), ...field.gridItemProps, children: `Type ${field.type} is not supported currently` }, index));
|
|
67
67
|
}
|
|
68
68
|
const Creator = creator;
|
|
69
69
|
const mref = React.createRef();
|
|
@@ -77,7 +77,7 @@ export var CustomFieldUtils;
|
|
|
77
77
|
ui = `Duplicate custom field ${name}`;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
return (_jsx(
|
|
80
|
+
return (_jsx(Grid2, { size: transformSpace(field.space), ...field.gridItemProps, children: ui }, name ?? index));
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
CustomFieldUtils.create = create;
|
|
@@ -97,7 +97,7 @@ export var CustomFieldUtils;
|
|
|
97
97
|
* @returns Result
|
|
98
98
|
*/
|
|
99
99
|
function transformSpace(space) {
|
|
100
|
-
const
|
|
100
|
+
const size = space === "full"
|
|
101
101
|
? { xs: 12 }
|
|
102
102
|
: space === "quater"
|
|
103
103
|
? { sm: 12, md: 6, lg: 3 }
|
|
@@ -108,7 +108,7 @@ export var CustomFieldUtils;
|
|
|
108
108
|
: space === "half1"
|
|
109
109
|
? { xs: 12, sm: 6 }
|
|
110
110
|
: { sm: 12, md: 6 };
|
|
111
|
-
return
|
|
111
|
+
return size;
|
|
112
112
|
}
|
|
113
113
|
CustomFieldUtils.transformSpace = transformSpace;
|
|
114
114
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomFieldData } from "@etsoo/appscript";
|
|
2
|
-
import {
|
|
2
|
+
import { Grid2Props, TypographyProps } from "@mui/material";
|
|
3
3
|
/**
|
|
4
4
|
* Custom field viewer props
|
|
5
5
|
* 自定义字段查看器属性
|
|
@@ -14,7 +14,7 @@ export type CustomFieldViewerProps = {
|
|
|
14
14
|
* Grid props
|
|
15
15
|
* 网格属性
|
|
16
16
|
*/
|
|
17
|
-
gridProps?:
|
|
17
|
+
gridProps?: Grid2Props;
|
|
18
18
|
/**
|
|
19
19
|
* JSON data
|
|
20
20
|
* JSON 数据
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Grid2, Typography } from "@mui/material";
|
|
3
3
|
import { CustomFieldUtils } from "./CustomFieldUtils";
|
|
4
4
|
import { MUGlobal } from "../MUGlobal";
|
|
5
5
|
import { VBox } from "../FlexBox";
|
|
@@ -38,7 +38,7 @@ export function CustomFieldViewer(props) {
|
|
|
38
38
|
if (data == null || typeof data !== "object" || Array.isArray(data)) {
|
|
39
39
|
throw new Error("Invalid JSON data");
|
|
40
40
|
}
|
|
41
|
-
return (_jsx(
|
|
41
|
+
return (_jsx(Grid2, { container: true, justifyContent: "left", spacing: spacing, sx: {
|
|
42
42
|
".MuiTypography-subtitle2": {
|
|
43
43
|
fontWeight: "bold"
|
|
44
44
|
}
|
|
@@ -49,6 +49,6 @@ export function CustomFieldViewer(props) {
|
|
|
49
49
|
return;
|
|
50
50
|
// Field value
|
|
51
51
|
const value = Utils.getNestedValue(data, name);
|
|
52
|
-
return (_jsx(
|
|
52
|
+
return (_jsx(Grid2, { size: CustomFieldUtils.transformSpace(field.space), ...field.gridItemProps, children: _jsxs(VBox, { gap: verticalGap, children: [_jsx(Typography, { fontWeight: "bold", fontSize: "small", ...titleProps, children: field.label ?? name }), _jsx(Typography, { ...valueProps, children: valueLabelFormatter(value, field) })] }) }, name ?? index));
|
|
53
53
|
}) }));
|
|
54
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomFieldData } from "@etsoo/appscript";
|
|
2
|
-
import {
|
|
2
|
+
import { Grid2Props } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Custom field window props
|
|
@@ -24,7 +24,7 @@ export type CustomFieldWindowProps<D extends CustomFieldData> = {
|
|
|
24
24
|
* Grid props
|
|
25
25
|
* 网格属性
|
|
26
26
|
*/
|
|
27
|
-
gridProps?:
|
|
27
|
+
gridProps?: Grid2Props;
|
|
28
28
|
/**
|
|
29
29
|
* JSON data
|
|
30
30
|
* JSON 数据
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Utils } from "@etsoo/shared";
|
|
3
|
-
import {
|
|
3
|
+
import { Grid2, Stack } from "@mui/material";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { globalApp } from "../app/ReactApp";
|
|
6
6
|
import { MUGlobal } from "../MUGlobal";
|
|
@@ -73,7 +73,7 @@ export function CustomFieldWindow(props) {
|
|
|
73
73
|
}
|
|
74
74
|
}, {
|
|
75
75
|
fullScreen: app.smDown,
|
|
76
|
-
inputs: (_jsx(Stack, { marginTop: 1.5, children: _jsx(
|
|
76
|
+
inputs: (_jsx(Stack, { marginTop: 1.5, children: _jsx(Grid2, { container: true, justifyContent: "left", spacing: spacing, sx: {
|
|
77
77
|
".MuiTypography-subtitle2": {
|
|
78
78
|
fontWeight: "bold"
|
|
79
79
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export * from "./ProgressCount";
|
|
|
90
90
|
export * from "./PullToRefreshUI";
|
|
91
91
|
export * from "./QuickList";
|
|
92
92
|
export * from "./ResponsibleContainer";
|
|
93
|
+
export * from "./ResponsiveStyleValue";
|
|
93
94
|
export * from "./ScrollerListEx";
|
|
94
95
|
export * from "./ScrollTopFab";
|
|
95
96
|
export * from "./SearchBar";
|
package/lib/index.js
CHANGED
|
@@ -90,6 +90,7 @@ export * from "./ProgressCount";
|
|
|
90
90
|
export * from "./PullToRefreshUI";
|
|
91
91
|
export * from "./QuickList";
|
|
92
92
|
export * from "./ResponsibleContainer";
|
|
93
|
+
export * from "./ResponsiveStyleValue";
|
|
93
94
|
export * from "./ScrollerListEx";
|
|
94
95
|
export * from "./ScrollTopFab";
|
|
95
96
|
export * from "./SearchBar";
|
package/lib/pages/EditPage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button,
|
|
2
|
+
import { Button, Grid2 } from "@mui/material";
|
|
3
3
|
import { MUGlobal } from "../MUGlobal";
|
|
4
4
|
import { CommonPage } from "./CommonPage";
|
|
5
5
|
import SaveIcon from "@mui/icons-material/Save";
|
|
@@ -16,7 +16,7 @@ export function EditPage(props) {
|
|
|
16
16
|
const { children, isEditing, onDelete, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = globalThis, supportBack = true, submitDisabled = false, bottomPart, topPart, operationMessageHandler, ...rest } = props;
|
|
17
17
|
// Labels
|
|
18
18
|
const labels = Labels.CommonPage;
|
|
19
|
-
return (_jsxs(CommonPage, { paddings: paddings, scrollContainer: scrollContainer, ...rest, children: [operationMessageHandler && (_jsx(OperationMessageContainer, { handler: operationMessageHandler })), topPart, _jsxs("form", { onSubmit: onSubmit, children: [_jsx(
|
|
19
|
+
return (_jsxs(CommonPage, { paddings: paddings, scrollContainer: scrollContainer, ...rest, children: [operationMessageHandler && (_jsx(OperationMessageContainer, { handler: operationMessageHandler })), topPart, _jsxs("form", { onSubmit: onSubmit, children: [_jsx(Grid2, { container: true, justifyContent: "left", spacing: paddings, paddingTop: 1, children: children }), _jsxs(Grid2, { container: true, position: "sticky", display: "flex", gap: paddings, sx: {
|
|
20
20
|
top: "auto",
|
|
21
21
|
bottom: (theme) => MUGlobal.updateWithTheme(paddings, theme.spacing),
|
|
22
22
|
paddingTop: paddings
|
package/lib/pages/ViewPage.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { GridColumnRenderProps, GridDataType } from "@etsoo/react";
|
|
2
2
|
import { DataTypes } from "@etsoo/shared";
|
|
3
|
-
import {
|
|
3
|
+
import { Grid2Props } from "@mui/material";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { CommonPageProps } from "./CommonPage";
|
|
6
6
|
import type { OperationMessageHandlerAll } from "../messages/OperationMessageHandler";
|
|
7
7
|
/**
|
|
8
8
|
* View page grid item properties
|
|
9
9
|
*/
|
|
10
|
-
export type ViewPageGridItemProps =
|
|
10
|
+
export type ViewPageGridItemProps = Grid2Props & {
|
|
11
11
|
data: React.ReactNode;
|
|
12
12
|
label?: React.ReactNode;
|
|
13
13
|
singleRow?: ViewPageRowType;
|
|
@@ -25,7 +25,7 @@ export type ViewPageRowType = boolean | "default" | "small" | "medium" | object;
|
|
|
25
25
|
/**
|
|
26
26
|
* View page display field
|
|
27
27
|
*/
|
|
28
|
-
export interface ViewPageField<T extends object> extends
|
|
28
|
+
export interface ViewPageField<T extends object> extends Grid2Props {
|
|
29
29
|
/**
|
|
30
30
|
* Data field
|
|
31
31
|
*/
|