@etsoo/materialui 1.2.36 → 1.2.38

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.
@@ -27,7 +27,6 @@ export function UserAvatarEditor(props) {
27
27
  const labels = Labels.UserAvatarEditor;
28
28
  // Ref
29
29
  const ref = React.createRef();
30
- const [AE, setAvatarEditor] = React.useState();
31
30
  // Button ref
32
31
  const buttonRef = React.createRef();
33
32
  // Preview image state
@@ -111,15 +110,15 @@ export function UserAvatarEditor(props) {
111
110
  onDone(data, toBlob);
112
111
  }
113
112
  };
114
- React.useEffect(() => {
115
- import("react-avatar-editor").then((result) => setAvatarEditor(result.default));
116
- }, []);
113
+ // Load the component
114
+ const AE = React.lazy(() => import("react-avatar-editor"));
117
115
  return (React.createElement(Stack, { direction: "column", spacing: 0.5, width: containerWidth },
118
116
  React.createElement(Button, { variant: "outlined", size: "medium", component: "label", startIcon: React.createElement(ComputerIcon, null), fullWidth: true },
119
117
  labels.upload,
120
118
  React.createElement("input", { id: "fileInput", type: "file", accept: "image/png, image/jpeg", multiple: false, hidden: true, onChange: handleFileChange })),
121
119
  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 })),
120
+ React.createElement(React.Suspense, { fallback: React.createElement(Skeleton, { variant: "rounded", width: width, height: height }) },
121
+ 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
122
  React.createElement(ButtonGroup, { size: "small", orientation: "vertical", disabled: !ready },
124
123
  React.createElement(Button, { onClick: () => handleRotate(90), title: labels.rotateRight },
125
124
  React.createElement(RotateRightIcon, 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.36",
3
+ "version": "1.2.38",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -107,8 +107,6 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
107
107
  // Ref
108
108
  const ref = React.createRef<AvatarEditor>();
109
109
 
110
- const [AE, setAvatarEditor] = React.useState<typeof AvatarEditor>();
111
-
112
110
  // Button ref
113
111
  const buttonRef = React.createRef<HTMLButtonElement>();
114
112
 
@@ -214,11 +212,8 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
214
212
  }
215
213
  };
216
214
 
217
- React.useEffect(() => {
218
- import("react-avatar-editor").then((result) =>
219
- setAvatarEditor(result.default)
220
- );
221
- }, []);
215
+ // Load the component
216
+ const AE = React.lazy(() => import("react-avatar-editor"));
222
217
 
223
218
  return (
224
219
  <Stack direction="column" spacing={0.5} width={containerWidth}>
@@ -240,9 +235,11 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
240
235
  />
241
236
  </Button>
242
237
  <Stack direction="row" spacing={0.5}>
243
- {AE == null ? (
244
- <Skeleton variant="rounded" width={width} height={height} />
245
- ) : (
238
+ <React.Suspense
239
+ fallback={
240
+ <Skeleton variant="rounded" width={width} height={height} />
241
+ }
242
+ >
246
243
  <AE
247
244
  ref={ref}
248
245
  border={border}
@@ -253,7 +250,7 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
253
250
  scale={editorState.scale}
254
251
  rotate={editorState.rotate}
255
252
  />
256
- )}
253
+ </React.Suspense>
257
254
  <ButtonGroup size="small" orientation="vertical" disabled={!ready}>
258
255
  <Button onClick={() => handleRotate(90)} title={labels.rotateRight}>
259
256
  <RotateRightIcon />
@@ -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
  /**