@luizleon/sf.prefeiturasp.vuecomponents 0.0.17 → 0.0.19
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 +2882 -2214
- package/dist/lib.es.js.map +1 -1
- package/dist/lib.umd.js +37 -37
- package/dist/lib.umd.js.map +1 -1
- package/dist/services/dialogService.d.ts +8 -2
- package/package.json +4 -2
- package/src/components/internal/HeaderAvatar.vue +1 -1
- package/src/services/dialogService.ts +34 -6
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
interface ConfirmOptions {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
text: string;
|
|
3
|
+
title?: string;
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luizleon/sf.prefeiturasp.vuecomponents",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Pacote de componentes Vue para projetos em SF.",
|
|
5
5
|
"main": "dist/lib.umd.js",
|
|
6
6
|
"module": "dist/lib.es.js",
|
|
@@ -15,14 +15,16 @@
|
|
|
15
15
|
"vue-currency-input": "3.0.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@types/dompurify": "3.0.5",
|
|
18
19
|
"@vitejs/plugin-vue": "4.4.1",
|
|
19
20
|
"base64-js": "1.5.1",
|
|
21
|
+
"dompurify": "3.0.6",
|
|
20
22
|
"js-sha256": "0.10.1",
|
|
21
23
|
"jwt-decode": "4.0.0",
|
|
22
24
|
"rimraf": "3.0.2",
|
|
23
25
|
"sass": "1.69.5",
|
|
24
26
|
"typescript": "5.2.2",
|
|
25
|
-
"vite": "4.5.
|
|
27
|
+
"vite": "4.5.1",
|
|
26
28
|
"vite-plugin-dts": "1.6.4",
|
|
27
29
|
"vite-plugin-vue-type-imports": "0.2.3",
|
|
28
30
|
"vue-tsc": "1.8.22"
|
|
@@ -8,7 +8,7 @@ const letters = Letters();
|
|
|
8
8
|
|
|
9
9
|
async function Logout() {
|
|
10
10
|
const confirm = await dialogService.ConfirmAsync({
|
|
11
|
-
|
|
11
|
+
text: `${AuthService.User.username} - ${AuthService.User.name}.<br /><br />Você deseja sair da conta?`,
|
|
12
12
|
confirmLabel: "sair",
|
|
13
13
|
});
|
|
14
14
|
if (!confirm) return;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import Swal from "sweetalert2";
|
|
2
|
+
import DOMPurify from "dompurify";
|
|
3
3
|
|
|
4
4
|
interface ConfirmOptions {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
text: string;
|
|
6
|
+
title?: string;
|
|
7
7
|
confirmLabel?: string;
|
|
8
8
|
rejectLabel?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
interface AlertOptions {
|
|
12
|
+
text: string | string[];
|
|
13
|
+
title?: string;
|
|
14
|
+
icon?: "info" | "error" | "success" | "warning" | "question";
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
class DialogService {
|
|
12
18
|
get IsVisible(): boolean {
|
|
13
19
|
return Swal.isVisible();
|
|
14
20
|
}
|
|
21
|
+
|
|
15
22
|
async ConfirmAsync(options: ConfirmOptions): Promise<boolean> {
|
|
16
23
|
return new Promise((r) => {
|
|
17
24
|
Swal.fire({
|
|
@@ -19,8 +26,8 @@ class DialogService {
|
|
|
19
26
|
allowEscapeKey: false,
|
|
20
27
|
allowOutsideClick: false,
|
|
21
28
|
icon: "question",
|
|
22
|
-
title: options.
|
|
23
|
-
html: options.
|
|
29
|
+
title: options.title,
|
|
30
|
+
html: DOMPurify.sanitize(options.text),
|
|
24
31
|
confirmButtonText: options.confirmLabel ?? "confirmar",
|
|
25
32
|
cancelButtonText: options.rejectLabel ?? "cancelar",
|
|
26
33
|
}).then((x: any) => {
|
|
@@ -28,6 +35,27 @@ class DialogService {
|
|
|
28
35
|
});
|
|
29
36
|
});
|
|
30
37
|
}
|
|
38
|
+
|
|
39
|
+
async AlertAsync(options: AlertOptions): Promise<boolean> {
|
|
40
|
+
const icon = options.icon ?? "info";
|
|
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
|
+
html = options.text;
|
|
48
|
+
}
|
|
49
|
+
return new Promise((r) => {
|
|
50
|
+
Swal.fire({
|
|
51
|
+
allowEscapeKey: false,
|
|
52
|
+
allowOutsideClick: false,
|
|
53
|
+
icon,
|
|
54
|
+
title: options.title,
|
|
55
|
+
html: DOMPurify.sanitize(html),
|
|
56
|
+
}).then(() => r(true));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
31
59
|
}
|
|
32
60
|
|
|
33
61
|
const service = new DialogService();
|