@tecsinapse/cortex-react 2.1.1-beta.2 → 2.1.1-beta.3
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.
|
@@ -35,36 +35,37 @@ class SnackbarSonner {
|
|
|
35
35
|
{ ...this._options, ...options }
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
-
promise(promise, config) {
|
|
38
|
+
async promise(promise, config) {
|
|
39
39
|
const { loading, success, error } = config;
|
|
40
40
|
const id = this.show(loading.type ?? "info", loading.message, {
|
|
41
41
|
...loading.options,
|
|
42
42
|
duration: loading.options?.duration ?? Infinity
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
await promise;
|
|
45
46
|
if (!success) {
|
|
46
47
|
sonner.toast.dismiss(id);
|
|
47
|
-
|
|
48
|
+
} else {
|
|
49
|
+
const msg = success?.message ?? "Opera\xE7\xE3o conclu\xEDda com sucesso.";
|
|
50
|
+
this.show(success?.type ?? "success", msg, {
|
|
51
|
+
...success?.options,
|
|
52
|
+
id,
|
|
53
|
+
duration: success?.options?.duration ?? this._options?.duration ?? 5e3
|
|
54
|
+
});
|
|
48
55
|
}
|
|
49
|
-
|
|
50
|
-
this.show(success.type ?? "success", msg, {
|
|
51
|
-
...success.options,
|
|
52
|
-
id,
|
|
53
|
-
duration: success.options?.duration ?? this._options?.duration ?? 5e3
|
|
54
|
-
});
|
|
55
|
-
}).catch((err) => {
|
|
56
|
+
} catch (err) {
|
|
56
57
|
if (!error) {
|
|
57
58
|
sonner.toast.dismiss(id);
|
|
58
|
-
|
|
59
|
+
} else {
|
|
60
|
+
const msg = error?.message ?? "Ocorreu um erro inesperado.";
|
|
61
|
+
this.show(error?.type ?? "error", msg, {
|
|
62
|
+
...error?.options,
|
|
63
|
+
id,
|
|
64
|
+
duration: error?.options?.duration ?? this._options?.duration ?? 5e3
|
|
65
|
+
});
|
|
59
66
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...error.options,
|
|
63
|
-
id,
|
|
64
|
-
duration: error.options?.duration ?? this._options?.duration ?? 5e3
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return promise();
|
|
67
|
+
}
|
|
68
|
+
return promise;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -33,36 +33,37 @@ class SnackbarSonner {
|
|
|
33
33
|
{ ...this._options, ...options }
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
promise(promise, config) {
|
|
36
|
+
async promise(promise, config) {
|
|
37
37
|
const { loading, success, error } = config;
|
|
38
38
|
const id = this.show(loading.type ?? "info", loading.message, {
|
|
39
39
|
...loading.options,
|
|
40
40
|
duration: loading.options?.duration ?? Infinity
|
|
41
41
|
});
|
|
42
|
-
|
|
42
|
+
try {
|
|
43
|
+
await promise;
|
|
43
44
|
if (!success) {
|
|
44
45
|
toast.dismiss(id);
|
|
45
|
-
|
|
46
|
+
} else {
|
|
47
|
+
const msg = success?.message ?? "Opera\xE7\xE3o conclu\xEDda com sucesso.";
|
|
48
|
+
this.show(success?.type ?? "success", msg, {
|
|
49
|
+
...success?.options,
|
|
50
|
+
id,
|
|
51
|
+
duration: success?.options?.duration ?? this._options?.duration ?? 5e3
|
|
52
|
+
});
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
this.show(success.type ?? "success", msg, {
|
|
49
|
-
...success.options,
|
|
50
|
-
id,
|
|
51
|
-
duration: success.options?.duration ?? this._options?.duration ?? 5e3
|
|
52
|
-
});
|
|
53
|
-
}).catch((err) => {
|
|
54
|
+
} catch (err) {
|
|
54
55
|
if (!error) {
|
|
55
56
|
toast.dismiss(id);
|
|
56
|
-
|
|
57
|
+
} else {
|
|
58
|
+
const msg = error?.message ?? "Ocorreu um erro inesperado.";
|
|
59
|
+
this.show(error?.type ?? "error", msg, {
|
|
60
|
+
...error?.options,
|
|
61
|
+
id,
|
|
62
|
+
duration: error?.options?.duration ?? this._options?.duration ?? 5e3
|
|
63
|
+
});
|
|
57
64
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
...error.options,
|
|
61
|
-
id,
|
|
62
|
-
duration: error.options?.duration ?? this._options?.duration ?? 5e3
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
return promise();
|
|
65
|
+
}
|
|
66
|
+
return promise;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -9,12 +9,12 @@ interface PromiseSnackConfig<T = unknown> {
|
|
|
9
9
|
options?: Omit<IExternalToast, 'className' | 'style'>;
|
|
10
10
|
};
|
|
11
11
|
success?: {
|
|
12
|
-
message?: string
|
|
12
|
+
message?: string;
|
|
13
13
|
type?: TypeSnack;
|
|
14
14
|
options?: Omit<IExternalToast, 'className' | 'style'>;
|
|
15
15
|
};
|
|
16
16
|
error?: {
|
|
17
|
-
message?: string
|
|
17
|
+
message?: string;
|
|
18
18
|
type?: TypeSnack;
|
|
19
19
|
options?: Omit<IExternalToast, 'className' | 'style'>;
|
|
20
20
|
};
|
|
@@ -24,6 +24,6 @@ export declare class SnackbarSonner implements ISnackbar<IExternalToast> {
|
|
|
24
24
|
constructor(options?: IExternalToast);
|
|
25
25
|
custom(Component: React.ReactElement, options?: ExternalToast): string | number;
|
|
26
26
|
show(type: TypeSnack, message: string, options?: Omit<IExternalToast, 'className' | 'style'>): string | number;
|
|
27
|
-
promise<T>(promise:
|
|
27
|
+
promise<T>(promise: Promise<T>, config: PromiseSnackConfig<T>): Promise<T>;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "2.1.1-beta.
|
|
3
|
+
"version": "2.1.1-beta.3",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-icons": ">=5.2.0",
|
|
49
49
|
"tailwindcss": "^4.1.16"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4eff3b2229ad43c2e1b92f39bfd97dadd52391eb"
|
|
52
52
|
}
|