@etsoo/materialui 1.2.35 → 1.2.37

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.
@@ -10,6 +10,7 @@ const defaultState = {
10
10
  scale: 1,
11
11
  rotate: 0
12
12
  };
13
+ const AE = React.lazy(() => import("react-avatar-editor"));
13
14
  /**
14
15
  * User avatar editor
15
16
  * https://github.com/mosch/react-avatar-editor
@@ -27,7 +28,6 @@ export function UserAvatarEditor(props) {
27
28
  const labels = Labels.UserAvatarEditor;
28
29
  // Ref
29
30
  const ref = React.createRef();
30
- const [AE, setAE] = React.useState();
31
31
  // Button ref
32
32
  const buttonRef = React.createRef();
33
33
  // Preview image state
@@ -111,15 +111,13 @@ 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
- }, []);
117
114
  return (React.createElement(Stack, { direction: "column", spacing: 0.5, width: containerWidth },
118
115
  React.createElement(Button, { variant: "outlined", size: "medium", component: "label", startIcon: React.createElement(ComputerIcon, null), fullWidth: true },
119
116
  labels.upload,
120
117
  React.createElement("input", { id: "fileInput", type: "file", accept: "image/png, image/jpeg", multiple: false, hidden: true, onChange: handleFileChange })),
121
118
  React.createElement(Stack, { direction: "row", spacing: 0.5 },
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 })),
119
+ React.createElement(React.Suspense, { fallback: React.createElement(Skeleton, { variant: "rounded", width: width, height: height }) },
120
+ 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 })),
123
121
  React.createElement(ButtonGroup, { size: "small", orientation: "vertical", disabled: !ready },
124
122
  React.createElement(Button, { onClick: () => handleRotate(90), title: labels.rotateRight },
125
123
  React.createElement(RotateRightIcon, null)),
@@ -96,7 +96,7 @@ export class CommonApp extends ReactApp {
96
96
  return;
97
97
  }
98
98
  // Set password for the action
99
- rq.pwd = await this.encrypt(await this.hash(pwd));
99
+ rq.pwd = this.encrypt(this.hash(pwd));
100
100
  // Submit again
101
101
  const result = await this.api.put("Auth/RefreshToken", rq, payload);
102
102
  if (result == null)
@@ -145,10 +145,11 @@ export class ReactApp extends CoreApp {
145
145
  // Same?
146
146
  if (culture.name === this.culture)
147
147
  return;
148
- // Dispatch action
149
- dispatch(culture);
150
148
  // Super call
151
- this.changeCulture(culture);
149
+ this.changeCulture(culture).then(() => {
150
+ // Dispatch action
151
+ dispatch(culture);
152
+ });
152
153
  }
153
154
  /**
154
155
  * Get date format props
@@ -110,7 +110,7 @@ export class ServiceApp extends ReactApp {
110
110
  const userData = result.data;
111
111
  // Use core system access token to service api to exchange service access token
112
112
  const serviceResult = await this.serviceApi.put("Auth/ExchangeToken", {
113
- token: await this.encryptEnhanced(userData.token, this.settings.serviceId.toString())
113
+ token: this.encryptEnhanced(userData.token, this.settings.serviceId.toString())
114
114
  }, {
115
115
  showLoading,
116
116
  onError: (error) => {
@@ -154,7 +154,7 @@ export class ServiceApp extends ReactApp {
154
154
  return;
155
155
  }
156
156
  // Set password for the action
157
- rq.pwd = await this.encrypt(await this.hash(pwd));
157
+ rq.pwd = this.encrypt(this.hash(pwd));
158
158
  // Submit again
159
159
  const result = await this.api.put("Auth/RefreshToken", rq, payload);
160
160
  if (result == null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.35",
3
+ "version": "1.2.37",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,9 +50,9 @@
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.4.6",
53
+ "@etsoo/appscript": "^1.4.7",
54
54
  "@etsoo/notificationbase": "^1.1.25",
55
- "@etsoo/react": "^1.6.79",
55
+ "@etsoo/react": "^1.6.80",
56
56
  "@etsoo/shared": "^1.2.5",
57
57
  "@mui/icons-material": "^5.11.16",
58
58
  "@mui/material": "^5.12.3",
@@ -76,6 +76,8 @@ const defaultState: EditorState = {
76
76
  rotate: 0
77
77
  };
78
78
 
79
+ const AE = React.lazy(() => import("react-avatar-editor"));
80
+
79
81
  /**
80
82
  * User avatar editor
81
83
  * https://github.com/mosch/react-avatar-editor
@@ -107,8 +109,6 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
107
109
  // Ref
108
110
  const ref = React.createRef<AvatarEditor>();
109
111
 
110
- const [AE, setAE] = React.useState<typeof AvatarEditor>();
111
-
112
112
  // Button ref
113
113
  const buttonRef = React.createRef<HTMLButtonElement>();
114
114
 
@@ -214,10 +214,6 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
214
214
  }
215
215
  };
216
216
 
217
- React.useEffect(() => {
218
- import("react-avatar-editor").then((result) => setAE(result.default));
219
- }, []);
220
-
221
217
  return (
222
218
  <Stack direction="column" spacing={0.5} width={containerWidth}>
223
219
  <Button
@@ -238,9 +234,11 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
238
234
  />
239
235
  </Button>
240
236
  <Stack direction="row" spacing={0.5}>
241
- {AE == null ? (
242
- <Skeleton variant="rounded" width={width} height={height} />
243
- ) : (
237
+ <React.Suspense
238
+ fallback={
239
+ <Skeleton variant="rounded" width={width} height={height} />
240
+ }
241
+ >
244
242
  <AE
245
243
  ref={ref}
246
244
  border={border}
@@ -251,7 +249,7 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
251
249
  scale={editorState.scale}
252
250
  rotate={editorState.rotate}
253
251
  />
254
- )}
252
+ </React.Suspense>
255
253
  <ButtonGroup size="small" orientation="vertical" disabled={!ready}>
256
254
  <Button onClick={() => handleRotate(90)} title={labels.rotateRight}>
257
255
  <RotateRightIcon />
@@ -144,7 +144,7 @@ export abstract class CommonApp<
144
144
  }
145
145
 
146
146
  // Set password for the action
147
- rq.pwd = await this.encrypt(await this.hash(pwd));
147
+ rq.pwd = this.encrypt(this.hash(pwd));
148
148
 
149
149
  // Submit again
150
150
  const result = await this.api.put<LoginResult>(
@@ -355,11 +355,11 @@ export class ReactApp<
355
355
  // Same?
356
356
  if (culture.name === this.culture) return;
357
357
 
358
- // Dispatch action
359
- dispatch(culture);
360
-
361
358
  // Super call
362
- this.changeCulture(culture);
359
+ this.changeCulture(culture).then(() => {
360
+ // Dispatch action
361
+ dispatch(culture);
362
+ });
363
363
  }
364
364
 
365
365
  /**
@@ -167,7 +167,7 @@ export class ServiceApp<
167
167
  const serviceResult = await this.serviceApi.put<ServiceLoginResult<U>>(
168
168
  "Auth/ExchangeToken",
169
169
  {
170
- token: await this.encryptEnhanced(
170
+ token: this.encryptEnhanced(
171
171
  userData.token,
172
172
  this.settings.serviceId.toString()
173
173
  )
@@ -226,7 +226,7 @@ export class ServiceApp<
226
226
  }
227
227
 
228
228
  // Set password for the action
229
- rq.pwd = await this.encrypt(await this.hash(pwd));
229
+ rq.pwd = this.encrypt(this.hash(pwd));
230
230
 
231
231
  // Submit again
232
232
  const result = await this.api.put<LoginResult>(