@etsoo/materialui 1.2.30 → 1.2.32
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/ComboBoxPro.js +5 -2
- package/lib/PullToRefreshUI.d.ts +2 -2
- package/lib/PullToRefreshUI.js +8 -4
- package/lib/UserAvatarEditor.d.ts +1 -1
- package/lib/UserAvatarEditor.js +18 -15
- package/lib/app/CommonApp.d.ts +3 -3
- package/lib/app/CommonApp.js +10 -10
- package/lib/app/IServiceApp.d.ts +5 -5
- package/lib/app/ReactApp.js +14 -13
- package/lib/app/ServiceApp.d.ts +2 -2
- package/lib/app/ServiceApp.js +2 -4
- package/package.json +7 -7
- package/src/ComboBoxPro.tsx +5 -2
- package/src/PullToRefreshUI.tsx +17 -10
- package/src/UserAvatarEditor.tsx +251 -251
- package/src/app/CommonApp.ts +189 -201
- package/src/app/IServiceApp.ts +37 -37
- package/src/app/ReactApp.ts +14 -14
- package/src/app/ServiceApp.ts +5 -6
package/lib/ComboBoxPro.js
CHANGED
|
@@ -47,8 +47,11 @@ export function ComboBoxPro(props) {
|
|
|
47
47
|
}, onClose: () => {
|
|
48
48
|
setOpen(false);
|
|
49
49
|
}, options: localOptions, loading: loading, openOnFocus: openOnFocus, renderInput: (params) => (React.createElement(InputField, { ...inputProps, ...params, label: label, name: name, onBlur: (event) => {
|
|
50
|
-
if (
|
|
51
|
-
|
|
50
|
+
if (onChange) {
|
|
51
|
+
const value = event.target.value;
|
|
52
|
+
if (!localValue && localValue != value)
|
|
53
|
+
onChange(event, value, "blur", undefined);
|
|
54
|
+
}
|
|
52
55
|
} })), getOptionLabel: (item) => typeof item === "object"
|
|
53
56
|
? "label" in item
|
|
54
57
|
? item.label
|
package/lib/PullToRefreshUI.d.ts
CHANGED
package/lib/PullToRefreshUI.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import PullToRefresh from 'pulltorefreshjs';
|
|
1
|
+
import React from "react";
|
|
3
2
|
/**
|
|
4
3
|
* PullToRefresh UI
|
|
5
4
|
* Use hammerjs or touchemulator to simulate browser as mobile device
|
|
@@ -9,9 +8,14 @@ import PullToRefresh from 'pulltorefreshjs';
|
|
|
9
8
|
export function PullToRefreshUI(props) {
|
|
10
9
|
// Ready
|
|
11
10
|
React.useEffect(() => {
|
|
12
|
-
|
|
11
|
+
let pr;
|
|
12
|
+
import("pulltorefreshjs").then((PullToRefresh) => {
|
|
13
|
+
PullToRefresh.init(props);
|
|
14
|
+
pr = PullToRefresh;
|
|
15
|
+
});
|
|
13
16
|
return () => {
|
|
14
|
-
|
|
17
|
+
if (pr)
|
|
18
|
+
pr.destroyAll();
|
|
15
19
|
};
|
|
16
20
|
}, [props]);
|
|
17
21
|
return React.createElement(React.Fragment, null);
|
package/lib/UserAvatarEditor.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { Button, ButtonGroup, Slider, Stack } from
|
|
2
|
-
import React from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import pica from 'pica';
|
|
10
|
-
import { Labels } from './app/Labels';
|
|
1
|
+
import { Button, ButtonGroup, Skeleton, Slider, Stack } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
|
4
|
+
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
|
5
|
+
import ClearAllIcon from "@mui/icons-material/ClearAll";
|
|
6
|
+
import ComputerIcon from "@mui/icons-material/Computer";
|
|
7
|
+
import DoneIcon from "@mui/icons-material/Done";
|
|
8
|
+
import { Labels } from "./app/Labels";
|
|
11
9
|
const defaultState = {
|
|
12
10
|
scale: 1,
|
|
13
11
|
rotate: 0
|
|
@@ -29,6 +27,7 @@ export function UserAvatarEditor(props) {
|
|
|
29
27
|
const labels = Labels.UserAvatarEditor;
|
|
30
28
|
// Ref
|
|
31
29
|
const ref = React.createRef();
|
|
30
|
+
const [AE, setAE] = React.useState();
|
|
32
31
|
// Button ref
|
|
33
32
|
const buttonRef = React.createRef();
|
|
34
33
|
// Preview image state
|
|
@@ -39,7 +38,7 @@ export function UserAvatarEditor(props) {
|
|
|
39
38
|
const [editorState, setEditorState] = React.useState(defaultState);
|
|
40
39
|
// Handle zoom
|
|
41
40
|
const handleZoom = (_event, value, _activeThumb) => {
|
|
42
|
-
const scale = typeof value ===
|
|
41
|
+
const scale = typeof value === "number" ? value : value[0];
|
|
43
42
|
const newState = { ...editorState, scale };
|
|
44
43
|
setEditorState(newState);
|
|
45
44
|
};
|
|
@@ -75,7 +74,7 @@ export function UserAvatarEditor(props) {
|
|
|
75
74
|
setEditorState(newState);
|
|
76
75
|
};
|
|
77
76
|
// Handle done
|
|
78
|
-
const handleDone = () => {
|
|
77
|
+
const handleDone = async () => {
|
|
79
78
|
var _a, _b;
|
|
80
79
|
// Data
|
|
81
80
|
var data = scaledResult
|
|
@@ -84,17 +83,18 @@ export function UserAvatarEditor(props) {
|
|
|
84
83
|
if (data == null)
|
|
85
84
|
return;
|
|
86
85
|
// pica
|
|
86
|
+
const pica = (await import("pica")).default;
|
|
87
87
|
const picaInstance = pica();
|
|
88
88
|
// toBlob helper
|
|
89
89
|
// Convenience method, similar to canvas.toBlob(), but with promise interface & polyfill for old browsers.
|
|
90
|
-
const toBlob = (canvas, mimeType =
|
|
90
|
+
const toBlob = (canvas, mimeType = "image/jpeg", quality = 1) => {
|
|
91
91
|
return picaInstance.toBlob(canvas, mimeType, quality);
|
|
92
92
|
};
|
|
93
93
|
if (data.width > maxWidthCalculated) {
|
|
94
94
|
// Target height
|
|
95
95
|
const heightCalculated = (height * maxWidthCalculated) / width;
|
|
96
96
|
// Target
|
|
97
|
-
const to = document.createElement(
|
|
97
|
+
const to = document.createElement("canvas");
|
|
98
98
|
to.width = maxWidthCalculated;
|
|
99
99
|
to.height = heightCalculated;
|
|
100
100
|
// Large photo, resize it
|
|
@@ -111,12 +111,15 @@ export function UserAvatarEditor(props) {
|
|
|
111
111
|
onDone(data, toBlob);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
import("react-avatar-editor").then((result) => setAE(result.default));
|
|
116
|
+
}, []);
|
|
114
117
|
return (React.createElement(Stack, { direction: "column", spacing: 0.5, width: containerWidth },
|
|
115
118
|
React.createElement(Button, { variant: "outlined", size: "medium", component: "label", startIcon: React.createElement(ComputerIcon, null), fullWidth: true },
|
|
116
119
|
labels.upload,
|
|
117
120
|
React.createElement("input", { id: "fileInput", type: "file", accept: "image/png, image/jpeg", multiple: false, hidden: true, onChange: handleFileChange })),
|
|
118
121
|
React.createElement(Stack, { direction: "row", spacing: 0.5 },
|
|
119
|
-
React.createElement(
|
|
122
|
+
AE == null ? (React.createElement(Skeleton, { variant: "rounded", width: width, height: height })) : (React.createElement(AE, { ref: ref, border: border, width: width, height: height, onLoadSuccess: handleLoad, image: previewImage !== null && previewImage !== void 0 ? previewImage : "", scale: editorState.scale, rotate: editorState.rotate })),
|
|
120
123
|
React.createElement(ButtonGroup, { size: "small", orientation: "vertical", disabled: !ready },
|
|
121
124
|
React.createElement(Button, { onClick: () => handleRotate(90), title: labels.rotateRight },
|
|
122
125
|
React.createElement(RotateRightIcon, null)),
|
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAppSettings, IUser, RefreshTokenProps, RefreshTokenRQ } from
|
|
2
|
-
import { IPageData } from
|
|
3
|
-
import { ReactApp } from
|
|
1
|
+
import { IAppSettings, IUser, RefreshTokenProps, RefreshTokenRQ } from "@etsoo/appscript";
|
|
2
|
+
import { IPageData } from "@etsoo/react";
|
|
3
|
+
import { ReactApp } from "./ReactApp";
|
|
4
4
|
/**
|
|
5
5
|
* Common independent application
|
|
6
6
|
* 通用独立程序
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CoreConstants } from
|
|
2
|
-
import { ReactApp } from
|
|
1
|
+
import { CoreConstants } from "@etsoo/react";
|
|
2
|
+
import { ReactApp } from "./ReactApp";
|
|
3
3
|
/**
|
|
4
4
|
* Common independent application
|
|
5
5
|
* 通用独立程序
|
|
@@ -40,7 +40,7 @@ export class CommonApp extends ReactApp {
|
|
|
40
40
|
const { callback, data, relogin = false, showLoading = false } = props !== null && props !== void 0 ? props : {};
|
|
41
41
|
// Token
|
|
42
42
|
const token = this.getCacheToken();
|
|
43
|
-
if (token == null || token ===
|
|
43
|
+
if (token == null || token === "") {
|
|
44
44
|
if (callback)
|
|
45
45
|
callback(false);
|
|
46
46
|
return false;
|
|
@@ -69,7 +69,7 @@ export class CommonApp extends ReactApp {
|
|
|
69
69
|
const refreshToken = this.getResponseToken(payload.response);
|
|
70
70
|
if (refreshToken == null || result.data == null) {
|
|
71
71
|
if (failCallback)
|
|
72
|
-
failCallback(this.get(
|
|
72
|
+
failCallback(this.get("noData"));
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
// Keep
|
|
@@ -82,23 +82,23 @@ export class CommonApp extends ReactApp {
|
|
|
82
82
|
return true;
|
|
83
83
|
};
|
|
84
84
|
// Call API
|
|
85
|
-
const result = await this.api.put(
|
|
85
|
+
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
86
86
|
if (result == null)
|
|
87
87
|
return false;
|
|
88
88
|
if (!result.ok) {
|
|
89
|
-
if (result.type ===
|
|
89
|
+
if (result.type === "TokenExpired" && relogin) {
|
|
90
90
|
// Try login
|
|
91
91
|
// Dialog to receive password
|
|
92
|
-
var labels = this.getLabels(
|
|
92
|
+
var labels = this.getLabels("reloginTip", "login");
|
|
93
93
|
this.notifier.prompt(labels.reloginTip, async (pwd) => {
|
|
94
94
|
if (pwd == null) {
|
|
95
95
|
this.toLoginPage();
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
// Set password for the action
|
|
99
|
-
rq.pwd = this.encrypt(this.hash(pwd));
|
|
99
|
+
rq.pwd = await this.encrypt(await this.hash(pwd));
|
|
100
100
|
// Submit again
|
|
101
|
-
const result = await this.api.put(
|
|
101
|
+
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
102
102
|
if (result == null)
|
|
103
103
|
return;
|
|
104
104
|
if (result.ok) {
|
|
@@ -117,7 +117,7 @@ export class CommonApp extends ReactApp {
|
|
|
117
117
|
// Popup message
|
|
118
118
|
this.alertResult(result);
|
|
119
119
|
return false;
|
|
120
|
-
}, labels.login, { type:
|
|
120
|
+
}, labels.login, { type: "password" });
|
|
121
121
|
// Fake truth to avoid reloading
|
|
122
122
|
return true;
|
|
123
123
|
}
|
package/lib/app/IServiceApp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IApi } from
|
|
2
|
-
import { IServiceUser } from
|
|
3
|
-
import { ReactAppType } from
|
|
1
|
+
import { IApi } from "@etsoo/appscript";
|
|
2
|
+
import { IServiceUser } from "./IServiceUser";
|
|
3
|
+
import { ReactAppType } from "./ReactApp";
|
|
4
4
|
/**
|
|
5
5
|
* Service application interface
|
|
6
6
|
*/
|
|
@@ -23,7 +23,7 @@ export interface IServiceApp extends ReactAppType {
|
|
|
23
23
|
* @param passphrase Secret passphrase
|
|
24
24
|
* @returns Pure text
|
|
25
25
|
*/
|
|
26
|
-
serviceDecrypt(messageEncrypted: string, passphrase?: string): string | undefined
|
|
26
|
+
serviceDecrypt(messageEncrypted: string, passphrase?: string): Promise<string | undefined>;
|
|
27
27
|
/**
|
|
28
28
|
* Service encrypt message
|
|
29
29
|
* @param message Message
|
|
@@ -31,5 +31,5 @@ export interface IServiceApp extends ReactAppType {
|
|
|
31
31
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
32
32
|
* @returns Result
|
|
33
33
|
*/
|
|
34
|
-
serviceEncrypt(message: string, passphrase?: string, iterations?: number): string | undefined
|
|
34
|
+
serviceEncrypt(message: string, passphrase?: string, iterations?: number): Promise<string | undefined>;
|
|
35
35
|
}
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -108,19 +108,20 @@ export class ReactApp extends CoreApp {
|
|
|
108
108
|
changeCulture(culture) {
|
|
109
109
|
var _a, _b;
|
|
110
110
|
// Super call to update cultrue
|
|
111
|
-
super.changeCulture(culture)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
super.changeCulture(culture, (resources) => {
|
|
112
|
+
// Update component labels
|
|
113
|
+
Labels.setLabels(resources, {
|
|
114
|
+
notificationMU: {
|
|
115
|
+
alertTitle: "warning",
|
|
116
|
+
alertOK: "ok",
|
|
117
|
+
confirmTitle: "confirm",
|
|
118
|
+
confirmYes: "ok",
|
|
119
|
+
confirmNo: "cancel",
|
|
120
|
+
promptTitle: "prompt",
|
|
121
|
+
promptCancel: "cancel",
|
|
122
|
+
promptOK: "ok"
|
|
123
|
+
}
|
|
124
|
+
});
|
|
124
125
|
});
|
|
125
126
|
// Document title
|
|
126
127
|
// Default is servier name's label or appName label
|
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
52
52
|
* @param passphrase Secret passphrase
|
|
53
53
|
* @returns Pure text
|
|
54
54
|
*/
|
|
55
|
-
serviceDecrypt(messageEncrypted: string, passphrase?: string): string | undefined
|
|
55
|
+
serviceDecrypt(messageEncrypted: string, passphrase?: string): Promise<string | undefined>;
|
|
56
56
|
/**
|
|
57
57
|
* Service encrypt message
|
|
58
58
|
* @param message Message
|
|
@@ -60,7 +60,7 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
60
60
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
61
61
|
* @returns Result
|
|
62
62
|
*/
|
|
63
|
-
serviceEncrypt(message: string, passphrase?: string, iterations?: number): string
|
|
63
|
+
serviceEncrypt(message: string, passphrase?: string, iterations?: number): Promise<string>;
|
|
64
64
|
/**
|
|
65
65
|
* Try login
|
|
66
66
|
* @param data Additional data
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -154,7 +154,7 @@ export class ServiceApp extends ReactApp {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
// Set password for the action
|
|
157
|
-
rq.pwd = this.encrypt(this.hash(pwd));
|
|
157
|
+
rq.pwd = await this.encrypt(await this.hash(pwd));
|
|
158
158
|
// Submit again
|
|
159
159
|
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
160
160
|
if (result == null)
|
|
@@ -230,10 +230,8 @@ export class ServiceApp extends ReactApp {
|
|
|
230
230
|
* @param serviceUser Service user
|
|
231
231
|
*/
|
|
232
232
|
userLoginEx(user, refreshToken, serviceUser) {
|
|
233
|
-
var _a;
|
|
234
233
|
// Service user login
|
|
235
|
-
this.servicePassphrase =
|
|
236
|
-
(_a = this.decrypt(serviceUser.servicePassphrase, this.settings.serviceId.toString())) !== null && _a !== void 0 ? _a : "";
|
|
234
|
+
this.decrypt(serviceUser.servicePassphrase, this.settings.serviceId.toString()).then((result) => (this.servicePassphrase = result !== null && result !== void 0 ? result : ""));
|
|
237
235
|
// Service user
|
|
238
236
|
this.serviceUser = serviceUser;
|
|
239
237
|
// Service API token
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.32",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@emotion/css": "^11.11.0",
|
|
51
51
|
"@emotion/react": "^11.11.0",
|
|
52
52
|
"@emotion/styled": "^11.11.0",
|
|
53
|
-
"@etsoo/appscript": "^1.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/react": "^1.6.
|
|
56
|
-
"@etsoo/shared": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.4.2",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.25",
|
|
55
|
+
"@etsoo/react": "^1.6.77",
|
|
56
|
+
"@etsoo/shared": "^1.2.5",
|
|
57
57
|
"@mui/icons-material": "^5.11.16",
|
|
58
58
|
"@mui/material": "^5.12.3",
|
|
59
59
|
"@mui/x-data-grid": "^6.3.1",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@testing-library/jest-dom": "^5.16.5",
|
|
86
86
|
"@testing-library/react": "^14.0.0",
|
|
87
87
|
"@types/jest": "^29.5.1",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
89
|
-
"@typescript-eslint/parser": "^5.59.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
89
|
+
"@typescript-eslint/parser": "^5.59.5",
|
|
90
90
|
"jest": "^29.5.0",
|
|
91
91
|
"jest-environment-jsdom": "^29.5.0",
|
|
92
92
|
"typescript": "^5.0.4"
|
package/src/ComboBoxPro.tsx
CHANGED
|
@@ -121,8 +121,11 @@ export function ComboBoxPro<D extends ListType2 = ListType2>(
|
|
|
121
121
|
label={label}
|
|
122
122
|
name={name}
|
|
123
123
|
onBlur={(event) => {
|
|
124
|
-
if (
|
|
125
|
-
|
|
124
|
+
if (onChange) {
|
|
125
|
+
const value = event.target.value;
|
|
126
|
+
if (!localValue && localValue != value)
|
|
127
|
+
onChange(event, value, "blur", undefined);
|
|
128
|
+
}
|
|
126
129
|
}}
|
|
127
130
|
/>
|
|
128
131
|
)}
|
package/src/PullToRefreshUI.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Options } from "pulltorefreshjs";
|
|
3
|
+
import type PullToRefresh from "pulltorefreshjs";
|
|
4
|
+
|
|
5
|
+
type p = typeof PullToRefresh;
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* PullToRefresh UI
|
|
@@ -8,14 +11,18 @@ import PullToRefresh, { Options } from 'pulltorefreshjs';
|
|
|
8
11
|
* @returns Component
|
|
9
12
|
*/
|
|
10
13
|
export function PullToRefreshUI(props: Options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
// Ready
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
let pr: p | null;
|
|
17
|
+
import("pulltorefreshjs").then((PullToRefresh) => {
|
|
18
|
+
PullToRefresh.init(props);
|
|
19
|
+
pr = PullToRefresh;
|
|
20
|
+
});
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
return () => {
|
|
23
|
+
if (pr) pr.destroyAll();
|
|
24
|
+
};
|
|
25
|
+
}, [props]);
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
return <React.Fragment />;
|
|
21
28
|
}
|