@etsoo/materialui 1.4.11 → 1.4.13

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.
@@ -65,10 +65,7 @@ export function OptionGroup(props) {
65
65
  changedValues.push(typeValue);
66
66
  }
67
67
  else {
68
- const index = changedValues.findIndex((v) => v === typeValue);
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);
@@ -1,4 +1,4 @@
1
- import { AppTryLoginParams, IAppSettings, IUser } from "@etsoo/appscript";
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
  }
@@ -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
  }
@@ -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
@@ -197,6 +197,50 @@ 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
+ // Ignore the result warning
227
+ return true;
228
+ }
229
+ });
230
+ return true;
231
+ }
232
+ /**
233
+ * Check if the action result should be ignored during try login
234
+ * @param result Action result
235
+ * @returns Result
236
+ */
237
+ tryLoginIgnoreResult(result) {
238
+ // Ignore no token warning
239
+ if (result.type === "noData" && result.field === "token")
240
+ return true;
241
+ else
242
+ return false;
243
+ }
200
244
  /**
201
245
  * Set page data
202
246
  * @param data Page data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
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.52",
54
- "@etsoo/notificationbase": "^1.1.50",
55
- "@etsoo/react": "^1.7.85",
56
- "@etsoo/shared": "^1.2.49",
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",
@@ -218,9 +218,7 @@ export function OptionGroup<
218
218
  if (changedValues.includes(typeValue)) return;
219
219
  changedValues.push(typeValue);
220
220
  } else {
221
- const index = changedValues.findIndex((v) => v === typeValue);
222
- if (index === -1) return;
223
- changedValues.splice(index, 1);
221
+ changedValues.remove(typeValue);
224
222
  }
225
223
 
226
224
  if (onValueChange) onValueChange(changedValues);
@@ -1,4 +1,4 @@
1
- import { AppTryLoginParams, IAppSettings, IUser } from "@etsoo/appscript";
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
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ AppTryLoginParams,
2
3
  BridgeUtils,
3
4
  CoreApp,
4
5
  FormatResultCustomCallback,
@@ -418,6 +419,58 @@ 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
+ // Ignore the result warning
455
+ return true;
456
+ }
457
+ }
458
+ );
459
+
460
+ return true;
461
+ }
462
+
463
+ /**
464
+ * Check if the action result should be ignored during try login
465
+ * @param result Action result
466
+ * @returns Result
467
+ */
468
+ protected tryLoginIgnoreResult(result: IActionResult) {
469
+ // Ignore no token warning
470
+ if (result.type === "noData" && result.field === "token") return true;
471
+ else return false;
472
+ }
473
+
421
474
  /**
422
475
  * Set page data
423
476
  * @param data Page data