@etsoo/materialui 1.4.29 → 1.4.30

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): void | false;
11
+ (canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob, type: string): Promise<void | false | undefined>;
12
12
  }
13
13
  /**
14
14
  * User avatar editor props
@@ -134,20 +134,21 @@ export function UserAvatarEditor(props) {
134
134
  to.height = heightCalculated;
135
135
  // Large photo, resize it
136
136
  // https://github.com/nodeca/pica
137
- picaInstance
138
- .resize(data, to, {
137
+ const canvas = await picaInstance.resize(data, to, {
139
138
  unsharpAmount: 160,
140
139
  unsharpRadius: 0.6,
141
140
  unsharpThreshold: 1
142
- })
143
- .then((result) => {
144
- if (onDone(result, toBlob, type.current) === false) {
145
- resetUI();
146
- }
147
141
  });
142
+ const result = await onDone(canvas, toBlob, type.current);
143
+ if (result === false) {
144
+ resetUI();
145
+ }
148
146
  }
149
- else if (onDone(data, toBlob, type.current) === false) {
150
- resetUI();
147
+ else {
148
+ const result = await onDone(data, toBlob, type.current);
149
+ if (result === false) {
150
+ resetUI();
151
+ }
151
152
  }
152
153
  };
153
154
  // Load the component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.29",
3
+ "version": "1.4.30",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -36,9 +36,11 @@ export interface UserAvatarEditorToBlob {
36
36
  * User avatar editor on done handler
37
37
  */
38
38
  export interface UserAvatarEditorOnDoneHandler {
39
- (canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob, type: string):
40
- | void
41
- | false;
39
+ (
40
+ canvas: HTMLCanvasElement,
41
+ toBlob: UserAvatarEditorToBlob,
42
+ type: string
43
+ ): Promise<void | false | undefined>;
42
44
  }
43
45
 
44
46
  /**
@@ -269,19 +271,21 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
269
271
 
270
272
  // Large photo, resize it
271
273
  // https://github.com/nodeca/pica
272
- picaInstance
273
- .resize(data, to, {
274
- unsharpAmount: 160,
275
- unsharpRadius: 0.6,
276
- unsharpThreshold: 1
277
- })
278
- .then((result) => {
279
- if (onDone(result, toBlob, type.current) === false) {
280
- resetUI();
281
- }
282
- });
283
- } else if (onDone(data, toBlob, type.current) === false) {
284
- resetUI();
274
+ const canvas = await picaInstance.resize(data, to, {
275
+ unsharpAmount: 160,
276
+ unsharpRadius: 0.6,
277
+ unsharpThreshold: 1
278
+ });
279
+
280
+ const result = await onDone(canvas, toBlob, type.current);
281
+ if (result === false) {
282
+ resetUI();
283
+ }
284
+ } else {
285
+ const result = await onDone(data, toBlob, type.current);
286
+ if (result === false) {
287
+ resetUI();
288
+ }
285
289
  }
286
290
  };
287
291