@etsoo/materialui 1.4.31 → 1.4.33

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.
@@ -8,7 +8,7 @@ export interface UserAvatarEditorToBlob {
8
8
  * User avatar editor on done handler
9
9
  */
10
10
  export interface UserAvatarEditorOnDoneHandler {
11
- (canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob, type: string): Promise<void | false | undefined>;
11
+ (canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob, type: string): Promise<void | true | undefined>;
12
12
  }
13
13
  /**
14
14
  * User avatar editor props
@@ -76,8 +76,8 @@ export function UserAvatarEditor(props) {
76
76
  };
77
77
  // Handle image load
78
78
  const handleLoad = (imageInfo) => {
79
- // Ignore small images
80
- if (imageInfo.height < 10 || imageInfo.width < 10)
79
+ // Ignore too small images
80
+ if (imageInfo.resource.width < 10 || imageInfo.resource.height < 10)
81
81
  return;
82
82
  if (noHeight) {
83
83
  setHeight((imageInfo.height * width) / imageInfo.width);
@@ -102,6 +102,7 @@ export function UserAvatarEditor(props) {
102
102
  setEditorState({ ...defaultState });
103
103
  };
104
104
  const resetUI = () => {
105
+ setReady(false);
105
106
  setPreviewImage(undefined);
106
107
  handleReset();
107
108
  };
@@ -144,13 +145,13 @@ export function UserAvatarEditor(props) {
144
145
  unsharpThreshold: 1
145
146
  });
146
147
  const result = await onDone(canvas, toBlob, type.current);
147
- if (result === false) {
148
+ if (result) {
148
149
  resetUI();
149
150
  }
150
151
  }
151
152
  else {
152
153
  const result = await onDone(data, toBlob, type.current);
153
- if (result === false) {
154
+ if (result) {
154
155
  resetUI();
155
156
  }
156
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.31",
3
+ "version": "1.4.33",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -35,7 +35,7 @@
35
35
  "@emotion/css": "^11.13.5",
36
36
  "@emotion/react": "^11.13.5",
37
37
  "@emotion/styled": "^11.13.5",
38
- "@etsoo/appscript": "^1.5.71",
38
+ "@etsoo/appscript": "^1.5.72",
39
39
  "@etsoo/notificationbase": "^1.1.54",
40
40
  "@etsoo/react": "^1.8.3",
41
41
  "@etsoo/shared": "^1.2.55",
@@ -40,7 +40,7 @@ export interface UserAvatarEditorOnDoneHandler {
40
40
  canvas: HTMLCanvasElement,
41
41
  toBlob: UserAvatarEditorToBlob,
42
42
  type: string
43
- ): Promise<void | false | undefined>;
43
+ ): Promise<void | true | undefined>;
44
44
  }
45
45
 
46
46
  /**
@@ -198,8 +198,8 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
198
198
 
199
199
  // Handle image load
200
200
  const handleLoad = (imageInfo: ImageState) => {
201
- // Ignore small images
202
- if (imageInfo.height < 10 || imageInfo.width < 10) return;
201
+ // Ignore too small images
202
+ if (imageInfo.resource.width < 10 || imageInfo.resource.height < 10) return;
203
203
 
204
204
  if (noHeight) {
205
205
  setHeight((imageInfo.height * width) / imageInfo.width);
@@ -230,6 +230,7 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
230
230
  };
231
231
 
232
232
  const resetUI = () => {
233
+ setReady(false);
233
234
  setPreviewImage(undefined);
234
235
  handleReset();
235
236
  };
@@ -283,12 +284,12 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
283
284
  });
284
285
 
285
286
  const result = await onDone(canvas, toBlob, type.current);
286
- if (result === false) {
287
+ if (result) {
287
288
  resetUI();
288
289
  }
289
290
  } else {
290
291
  const result = await onDone(data, toBlob, type.current);
291
- if (result === false) {
292
+ if (result) {
292
293
  resetUI();
293
294
  }
294
295
  }