@luizleon/sf.prefeiturasp.vuecomponents 0.0.16 → 0.0.18
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.
- package/dist/lib.es.js +2417 -2243
- package/dist/lib.es.js.map +1 -1
- package/dist/lib.umd.js +36 -37
- package/dist/lib.umd.js.map +1 -1
- package/dist/services/dialogService.d.ts +6 -0
- package/package.json +1 -1
- package/src/components/button/Button.vue +1 -1
- package/src/services/dialogService.ts +31 -2
|
@@ -4,9 +4,15 @@ interface ConfirmOptions {
|
|
|
4
4
|
confirmLabel?: string;
|
|
5
5
|
rejectLabel?: string;
|
|
6
6
|
}
|
|
7
|
+
interface AlertOptions {
|
|
8
|
+
text: string | string[];
|
|
9
|
+
title?: string;
|
|
10
|
+
icon?: "info" | "error" | "success" | "warning" | "question";
|
|
11
|
+
}
|
|
7
12
|
declare class DialogService {
|
|
8
13
|
get IsVisible(): boolean;
|
|
9
14
|
ConfirmAsync(options: ConfirmOptions): Promise<boolean>;
|
|
15
|
+
AlertAsync(options: AlertOptions): Promise<boolean>;
|
|
10
16
|
}
|
|
11
17
|
export declare const UseDialogService: () => DialogService;
|
|
12
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import Swal from "sweetalert2/dist/sweetalert2.js";
|
|
1
|
+
import Swal from "sweetalert2";
|
|
3
2
|
|
|
4
3
|
interface ConfirmOptions {
|
|
5
4
|
message: string;
|
|
@@ -8,10 +7,17 @@ interface ConfirmOptions {
|
|
|
8
7
|
rejectLabel?: string;
|
|
9
8
|
}
|
|
10
9
|
|
|
10
|
+
interface AlertOptions {
|
|
11
|
+
text: string | string[];
|
|
12
|
+
title?: string;
|
|
13
|
+
icon?: "info" | "error" | "success" | "warning" | "question";
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
class DialogService {
|
|
12
17
|
get IsVisible(): boolean {
|
|
13
18
|
return Swal.isVisible();
|
|
14
19
|
}
|
|
20
|
+
|
|
15
21
|
async ConfirmAsync(options: ConfirmOptions): Promise<boolean> {
|
|
16
22
|
return new Promise((r) => {
|
|
17
23
|
Swal.fire({
|
|
@@ -28,6 +34,29 @@ class DialogService {
|
|
|
28
34
|
});
|
|
29
35
|
});
|
|
30
36
|
}
|
|
37
|
+
|
|
38
|
+
async AlertAsync(options: AlertOptions): Promise<boolean> {
|
|
39
|
+
const icon = options.icon ?? "info";
|
|
40
|
+
let text: string;
|
|
41
|
+
let html: string;
|
|
42
|
+
if (Array.isArray(options.text)) {
|
|
43
|
+
html = `<div style="max-height: 50vh; overflow: auto">
|
|
44
|
+
${options.text.join("<br />")}
|
|
45
|
+
</div>`;
|
|
46
|
+
} else {
|
|
47
|
+
text = options.text;
|
|
48
|
+
}
|
|
49
|
+
return new Promise((r) => {
|
|
50
|
+
Swal.fire({
|
|
51
|
+
allowEscapeKey: false,
|
|
52
|
+
allowOutsideClick: false,
|
|
53
|
+
icon,
|
|
54
|
+
title: options.title,
|
|
55
|
+
text: text,
|
|
56
|
+
html,
|
|
57
|
+
}).then(() => r(true));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
31
60
|
}
|
|
32
61
|
|
|
33
62
|
const service = new DialogService();
|