@etsoo/materialui 1.4.10 → 1.4.12
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/OptionGroup.js +1 -4
- package/lib/app/CommonApp.d.ts +1 -7
- package/lib/app/CommonApp.js +0 -28
- package/lib/app/ReactApp.d.ts +13 -1
- package/lib/app/ReactApp.js +43 -0
- package/lib/app/ServiceApp.js +8 -4
- package/package.json +5 -5
- package/src/OptionGroup.tsx +1 -3
- package/src/app/CommonApp.ts +1 -39
- package/src/app/ReactApp.ts +52 -0
- package/src/app/ServiceApp.ts +10 -4
package/lib/OptionGroup.js
CHANGED
|
@@ -65,10 +65,7 @@ export function OptionGroup(props) {
|
|
|
65
65
|
changedValues.push(typeValue);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
|
|
69
|
-
if (index === -1)
|
|
70
|
-
return;
|
|
71
|
-
changedValues.splice(index, 1);
|
|
68
|
+
changedValues.remove(typeValue);
|
|
72
69
|
}
|
|
73
70
|
if (onValueChange)
|
|
74
71
|
onValueChange(changedValues);
|
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAppSettings, IUser } from "@etsoo/appscript";
|
|
2
2
|
import { IPageData } from "@etsoo/react";
|
|
3
3
|
import { ReactApp } from "./ReactApp";
|
|
4
4
|
/**
|
|
@@ -15,10 +15,4 @@ 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
|
-
* Try login
|
|
20
|
-
* @param showLoading Show loading bar or not
|
|
21
|
-
* @returns Result
|
|
22
|
-
*/
|
|
23
|
-
tryLogin(params?: AppTryLoginParams): Promise<boolean>;
|
|
24
18
|
}
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -20,32 +20,4 @@ export class CommonApp extends ReactApp {
|
|
|
20
20
|
fields.push(CoreConstants.FieldUserIdSaved);
|
|
21
21
|
return fields;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Try login
|
|
25
|
-
* @param showLoading Show loading bar or not
|
|
26
|
-
* @returns Result
|
|
27
|
-
*/
|
|
28
|
-
async tryLogin(params) {
|
|
29
|
-
// Check status
|
|
30
|
-
const result = await super.tryLogin(params);
|
|
31
|
-
if (!result) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
// Destruct
|
|
35
|
-
const { onFailure = () => {
|
|
36
|
-
this.toLoginPage(rest);
|
|
37
|
-
}, onSuccess, ...rest } = params ?? {};
|
|
38
|
-
// Refresh token
|
|
39
|
-
await this.refreshToken({
|
|
40
|
-
showLoading: params?.showLoading
|
|
41
|
-
}, (result) => {
|
|
42
|
-
if (result === true) {
|
|
43
|
-
onSuccess?.();
|
|
44
|
-
}
|
|
45
|
-
else if (result === false) {
|
|
46
|
-
onFailure();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
23
|
}
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreApp, FormatResultCustomCallback, IApp, IAppSettings, ICoreApp, IUser } from "@etsoo/appscript";
|
|
1
|
+
import { AppTryLoginParams, CoreApp, FormatResultCustomCallback, IApp, IAppSettings, ICoreApp, IUser } from "@etsoo/appscript";
|
|
2
2
|
import { INotifier, NotificationReturn } from "@etsoo/notificationbase";
|
|
3
3
|
import { DataTypes, IActionResult } from "@etsoo/shared";
|
|
4
4
|
import React from "react";
|
|
@@ -180,6 +180,18 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
|
|
|
180
180
|
* @param callback Callback
|
|
181
181
|
*/
|
|
182
182
|
freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
|
|
183
|
+
/**
|
|
184
|
+
* Try login
|
|
185
|
+
* @param showLoading Show loading bar or not
|
|
186
|
+
* @returns Result
|
|
187
|
+
*/
|
|
188
|
+
tryLogin(params?: AppTryLoginParams): Promise<boolean>;
|
|
189
|
+
/**
|
|
190
|
+
* Check if the action result should be ignored during try login
|
|
191
|
+
* @param result Action result
|
|
192
|
+
* @returns Result
|
|
193
|
+
*/
|
|
194
|
+
protected tryLoginIgnoreResult(result: IActionResult): boolean;
|
|
183
195
|
/**
|
|
184
196
|
* Set page data
|
|
185
197
|
* @param data Page data
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -197,6 +197,49 @@ export class ReactApp extends CoreApp {
|
|
|
197
197
|
inputs: progress
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Try login
|
|
202
|
+
* @param showLoading Show loading bar or not
|
|
203
|
+
* @returns Result
|
|
204
|
+
*/
|
|
205
|
+
async tryLogin(params) {
|
|
206
|
+
// Check status
|
|
207
|
+
const result = await super.tryLogin(params);
|
|
208
|
+
if (!result) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
// Destruct
|
|
212
|
+
const { onFailure = () => {
|
|
213
|
+
this.toLoginPage(rest);
|
|
214
|
+
}, onSuccess, ...rest } = params ?? {};
|
|
215
|
+
// Refresh token
|
|
216
|
+
await this.refreshToken({
|
|
217
|
+
showLoading: params?.showLoading
|
|
218
|
+
}, (result) => {
|
|
219
|
+
if (result === true) {
|
|
220
|
+
onSuccess?.();
|
|
221
|
+
}
|
|
222
|
+
else if (result === false) {
|
|
223
|
+
onFailure();
|
|
224
|
+
}
|
|
225
|
+
else if (result != null && this.tryLoginIgnoreResult(result)) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Check if the action result should be ignored during try login
|
|
233
|
+
* @param result Action result
|
|
234
|
+
* @returns Result
|
|
235
|
+
*/
|
|
236
|
+
tryLoginIgnoreResult(result) {
|
|
237
|
+
// Ignore no token warning
|
|
238
|
+
if (result.type === "noData" && result.field === "token")
|
|
239
|
+
return true;
|
|
240
|
+
else
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
200
243
|
/**
|
|
201
244
|
* Set page data
|
|
202
245
|
* @param data Page data
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -125,14 +125,18 @@ export class ServiceApp extends ReactApp {
|
|
|
125
125
|
* @param params Login parameters
|
|
126
126
|
*/
|
|
127
127
|
async tryLogin(params) {
|
|
128
|
-
//
|
|
128
|
+
// Destruct
|
|
129
129
|
params ?? (params = {});
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
let { onFailure, onSuccess, ...rest } = params;
|
|
131
|
+
if (onFailure == null) {
|
|
132
|
+
onFailure = params.onFailure = () => {
|
|
133
|
+
this.toLoginPage(rest);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
132
136
|
// Check core system token
|
|
133
137
|
const coreToken = this.storage.getData(coreTokenKey);
|
|
134
138
|
if (!coreToken) {
|
|
135
|
-
onFailure
|
|
139
|
+
onFailure();
|
|
136
140
|
return false;
|
|
137
141
|
}
|
|
138
142
|
params.onSuccess = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.12",
|
|
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.13.4",
|
|
51
51
|
"@emotion/react": "^11.13.3",
|
|
52
52
|
"@emotion/styled": "^11.13.0",
|
|
53
|
-
"@etsoo/appscript": "^1.5.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
56
|
-
"@etsoo/shared": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.5.53",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.52",
|
|
55
|
+
"@etsoo/react": "^1.7.87",
|
|
56
|
+
"@etsoo/shared": "^1.2.51",
|
|
57
57
|
"@mui/icons-material": "^6.1.4",
|
|
58
58
|
"@mui/material": "^6.1.4",
|
|
59
59
|
"@mui/x-data-grid": "^7.20.0",
|
package/src/OptionGroup.tsx
CHANGED
|
@@ -218,9 +218,7 @@ export function OptionGroup<
|
|
|
218
218
|
if (changedValues.includes(typeValue)) return;
|
|
219
219
|
changedValues.push(typeValue);
|
|
220
220
|
} else {
|
|
221
|
-
|
|
222
|
-
if (index === -1) return;
|
|
223
|
-
changedValues.splice(index, 1);
|
|
221
|
+
changedValues.remove(typeValue);
|
|
224
222
|
}
|
|
225
223
|
|
|
226
224
|
if (onValueChange) onValueChange(changedValues);
|
package/src/app/CommonApp.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAppSettings, IUser } from "@etsoo/appscript";
|
|
2
2
|
import { CoreConstants, IPageData } from "@etsoo/react";
|
|
3
3
|
import { ReactApp } from "./ReactApp";
|
|
4
4
|
|
|
@@ -27,42 +27,4 @@ export abstract class CommonApp<
|
|
|
27
27
|
fields.push(CoreConstants.FieldUserIdSaved);
|
|
28
28
|
return fields;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Try login
|
|
33
|
-
* @param showLoading Show loading bar or not
|
|
34
|
-
* @returns Result
|
|
35
|
-
*/
|
|
36
|
-
override async tryLogin(params?: AppTryLoginParams) {
|
|
37
|
-
// Check status
|
|
38
|
-
const result = await super.tryLogin(params);
|
|
39
|
-
if (!result) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Destruct
|
|
44
|
-
const {
|
|
45
|
-
onFailure = () => {
|
|
46
|
-
this.toLoginPage(rest);
|
|
47
|
-
},
|
|
48
|
-
onSuccess,
|
|
49
|
-
...rest
|
|
50
|
-
} = params ?? {};
|
|
51
|
-
|
|
52
|
-
// Refresh token
|
|
53
|
-
await this.refreshToken(
|
|
54
|
-
{
|
|
55
|
-
showLoading: params?.showLoading
|
|
56
|
-
},
|
|
57
|
-
(result) => {
|
|
58
|
-
if (result === true) {
|
|
59
|
-
onSuccess?.();
|
|
60
|
-
} else if (result === false) {
|
|
61
|
-
onFailure();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
30
|
}
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AppTryLoginParams,
|
|
2
3
|
BridgeUtils,
|
|
3
4
|
CoreApp,
|
|
4
5
|
FormatResultCustomCallback,
|
|
@@ -418,6 +419,57 @@ export class ReactApp<
|
|
|
418
419
|
);
|
|
419
420
|
}
|
|
420
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Try login
|
|
424
|
+
* @param showLoading Show loading bar or not
|
|
425
|
+
* @returns Result
|
|
426
|
+
*/
|
|
427
|
+
override async tryLogin(params?: AppTryLoginParams) {
|
|
428
|
+
// Check status
|
|
429
|
+
const result = await super.tryLogin(params);
|
|
430
|
+
if (!result) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Destruct
|
|
435
|
+
const {
|
|
436
|
+
onFailure = () => {
|
|
437
|
+
this.toLoginPage(rest);
|
|
438
|
+
},
|
|
439
|
+
onSuccess,
|
|
440
|
+
...rest
|
|
441
|
+
} = params ?? {};
|
|
442
|
+
|
|
443
|
+
// Refresh token
|
|
444
|
+
await this.refreshToken(
|
|
445
|
+
{
|
|
446
|
+
showLoading: params?.showLoading
|
|
447
|
+
},
|
|
448
|
+
(result) => {
|
|
449
|
+
if (result === true) {
|
|
450
|
+
onSuccess?.();
|
|
451
|
+
} else if (result === false) {
|
|
452
|
+
onFailure();
|
|
453
|
+
} else if (result != null && this.tryLoginIgnoreResult(result)) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Check if the action result should be ignored during try login
|
|
464
|
+
* @param result Action result
|
|
465
|
+
* @returns Result
|
|
466
|
+
*/
|
|
467
|
+
protected tryLoginIgnoreResult(result: IActionResult) {
|
|
468
|
+
// Ignore no token warning
|
|
469
|
+
if (result.type === "noData" && result.field === "token") return true;
|
|
470
|
+
else return false;
|
|
471
|
+
}
|
|
472
|
+
|
|
421
473
|
/**
|
|
422
474
|
* Set page data
|
|
423
475
|
* @param data Page data
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -180,15 +180,20 @@ export class ServiceApp<
|
|
|
180
180
|
* @param params Login parameters
|
|
181
181
|
*/
|
|
182
182
|
override async tryLogin(params?: AppTryLoginParams) {
|
|
183
|
-
//
|
|
183
|
+
// Destruct
|
|
184
184
|
params ??= {};
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
let { onFailure, onSuccess, ...rest } = params;
|
|
186
|
+
|
|
187
|
+
if (onFailure == null) {
|
|
188
|
+
onFailure = params.onFailure = () => {
|
|
189
|
+
this.toLoginPage(rest);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
187
192
|
|
|
188
193
|
// Check core system token
|
|
189
194
|
const coreToken = this.storage.getData<string>(coreTokenKey);
|
|
190
195
|
if (!coreToken) {
|
|
191
|
-
onFailure
|
|
196
|
+
onFailure();
|
|
192
197
|
return false;
|
|
193
198
|
}
|
|
194
199
|
|
|
@@ -205,6 +210,7 @@ export class ServiceApp<
|
|
|
205
210
|
onSuccess?.();
|
|
206
211
|
});
|
|
207
212
|
};
|
|
213
|
+
|
|
208
214
|
return await super.tryLogin(params);
|
|
209
215
|
}
|
|
210
216
|
}
|