@nexdom/uimed-vue 2.0.0-beta.2 → 2.0.0-beta.20
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/AGENTS.md +113 -12
- package/README.md +2 -2
- package/dist/components.d.ts +696 -77
- package/dist/components.js +1493 -311
- package/dist/composables.d.ts +130 -4
- package/dist/composables.js +55 -3
- package/dist/index.d.ts +3 -15
- package/dist/index.js +25 -13
- package/dist/locale-CM4o8cD_.js +12 -0
- package/dist/plugins.d.ts +5 -6
- package/dist/plugins.js +3 -3
- package/dist/styles/fonts/UnimedSlab-Regular.woff2 +0 -0
- package/dist/styles/fonts/fonts.css +4 -0
- package/dist/types-HPMP8IrV.d.ts +49 -0
- package/dist/unit-test.d.ts +2 -3
- package/dist/unit-test.js +3 -1
- package/dist/use-dialog-Ck2_ZW7T.js +124 -0
- package/package.json +7 -6
- package/dist/types-BPXXtbmW.d.ts +0 -5
- package/dist/use-toast-CACuYhK_.js +0 -53
package/dist/composables.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as FeedbackColorVariant, n as ButtonVariant, r as ColorVariant } from "./types-HPMP8IrV.js";
|
|
2
2
|
//#region src/composables/dialogs/types.d.ts
|
|
3
3
|
interface ToastOptions {
|
|
4
4
|
/**
|
|
@@ -6,12 +6,84 @@ interface ToastOptions {
|
|
|
6
6
|
*/
|
|
7
7
|
message: string;
|
|
8
8
|
/**
|
|
9
|
-
* Applies a color to the
|
|
9
|
+
* Applies a color to the toast.
|
|
10
10
|
* One of `positive`, `informative`, `caution`, or `danger`.
|
|
11
11
|
* @default "informative"
|
|
12
12
|
*/
|
|
13
13
|
color?: FeedbackColorVariant;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* A button displayed at the bottom of a dialog opened by `useDialog`'s `dialog`.
|
|
17
|
+
*/
|
|
18
|
+
interface DialogAction<T extends string = string> {
|
|
19
|
+
/**
|
|
20
|
+
* Text displayed on the button.
|
|
21
|
+
*/
|
|
22
|
+
text: string;
|
|
23
|
+
/**
|
|
24
|
+
* Value the dialog resolves with when the button is clicked.
|
|
25
|
+
*/
|
|
26
|
+
value: T;
|
|
27
|
+
/**
|
|
28
|
+
* Applies a distinct style variation to the button.
|
|
29
|
+
* One of `primary`, `secondary`, or `ghost`.
|
|
30
|
+
* @default "ghost", or "primary" for the last action
|
|
31
|
+
*/
|
|
32
|
+
variant?: ButtonVariant;
|
|
33
|
+
/**
|
|
34
|
+
* Applies a color to the button.
|
|
35
|
+
* One of `primary`, `secondary`, `positive`, `informative`, `caution`, or `danger`.
|
|
36
|
+
* @default "primary"
|
|
37
|
+
*/
|
|
38
|
+
color?: ColorVariant;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Options of a dialog opened by `useDialog`'s `dialog`.
|
|
42
|
+
*/
|
|
43
|
+
interface DialogOptions<T extends string = string> {
|
|
44
|
+
/**
|
|
45
|
+
* Plain text displayed as the dialog's title. HTML isn't interpreted.
|
|
46
|
+
*/
|
|
47
|
+
title?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Plain text displayed as the dialog's message. HTML isn't interpreted.
|
|
50
|
+
*/
|
|
51
|
+
message: string;
|
|
52
|
+
/**
|
|
53
|
+
* Buttons displayed at the bottom of the dialog, right-aligned, in the given order.
|
|
54
|
+
* @default [{ text: "Fechar" }], which resolves `undefined`
|
|
55
|
+
*/
|
|
56
|
+
actions?: DialogAction<T>[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Options of a dialog opened by `useConfirm`'s `confirm`.
|
|
60
|
+
*/
|
|
61
|
+
interface ConfirmOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Plain text displayed as the dialog's title. HTML isn't interpreted.
|
|
64
|
+
*/
|
|
65
|
+
title?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Plain text displayed as the dialog's message. HTML isn't interpreted.
|
|
68
|
+
*/
|
|
69
|
+
message: string;
|
|
70
|
+
/**
|
|
71
|
+
* Text displayed on the confirm button.
|
|
72
|
+
* @default "Confirmar"
|
|
73
|
+
*/
|
|
74
|
+
confirmText?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Text displayed on the cancel button.
|
|
77
|
+
* @default "Cancelar"
|
|
78
|
+
*/
|
|
79
|
+
cancelText?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Applies a color to the confirm button.
|
|
82
|
+
* One of `primary`, `secondary`, `positive`, `informative`, `caution`, or `danger`.
|
|
83
|
+
* @default "primary"
|
|
84
|
+
*/
|
|
85
|
+
color?: ColorVariant;
|
|
86
|
+
}
|
|
15
87
|
//#endregion
|
|
16
88
|
//#region src/composables/dialogs/use-toast.d.ts
|
|
17
89
|
/**
|
|
@@ -37,7 +109,7 @@ declare function useToast(): {
|
|
|
37
109
|
*/
|
|
38
110
|
declare function toast(options: ToastOptions): void;
|
|
39
111
|
//#endregion
|
|
40
|
-
//#region src/composables/dialogs/use-run-or-toast
|
|
112
|
+
//#region src/composables/dialogs/use-run-or-toast.d.ts
|
|
41
113
|
/**
|
|
42
114
|
* Generate `run` method and a computed property `isRunning`.
|
|
43
115
|
* Calling `run` will reactively update `isRunning`.
|
|
@@ -64,4 +136,58 @@ declare function useRunOrToast(): {
|
|
|
64
136
|
isRunning: import("vue").ComputedRef<boolean>;
|
|
65
137
|
};
|
|
66
138
|
//#endregion
|
|
67
|
-
|
|
139
|
+
//#region src/composables/dialogs/use-dialog.d.ts
|
|
140
|
+
/**
|
|
141
|
+
* Composable which returns a function to display dialogs.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const { dialog } = useDialog();
|
|
146
|
+
*
|
|
147
|
+
* const answer = await dialog({
|
|
148
|
+
* title: "Sessão expirando",
|
|
149
|
+
* message: "Deseja continuar conectado?",
|
|
150
|
+
* actions: [
|
|
151
|
+
* { text: "Sair", value: "leave" },
|
|
152
|
+
* { text: "Continuar", value: "stay" },
|
|
153
|
+
* ],
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function useDialog(): {
|
|
158
|
+
dialog: typeof dialog;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Displays a dialog. Dialogs are displayed one at a time, in the order they were requested.
|
|
162
|
+
* @param {DialogOptions} options - Options for the dialog.
|
|
163
|
+
* @returns the `value` of the clicked action, or `undefined` when the dialog is closed by the
|
|
164
|
+
* default action, the `Esc` key, a click outside it or the browser's back button.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* await dialog({ title: "Aviso", message: "Seu cadastro foi enviado para análise." });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
declare function dialog<T extends string = never>(options: DialogOptions<T>): Promise<T | undefined>;
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/composables/dialogs/use-confirm.d.ts
|
|
174
|
+
/**
|
|
175
|
+
* Composable which returns a function to run actions only after the user confirms them in a
|
|
176
|
+
* dialog, and a computed property `isRunning`.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const { confirm, isRunning } = useConfirm();
|
|
181
|
+
*
|
|
182
|
+
* const removed = await confirm(
|
|
183
|
+
* { title: "Excluir paciente", message: "Esta ação não pode ser desfeita.", confirmText: "Excluir", color: "danger" },
|
|
184
|
+
* () => api.deletePatient(id),
|
|
185
|
+
* );
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useConfirm(): {
|
|
189
|
+
confirm: <F extends (...args: Parameters<F>) => PromiseLike<Awaited<ReturnType<F>>>>(options: ConfirmOptions, action: F, ...params: Parameters<F>) => Promise<Awaited<ReturnType<F>> | false>;
|
|
190
|
+
isRunning: import("vue").ComputedRef<boolean>;
|
|
191
|
+
};
|
|
192
|
+
//#endregion
|
|
193
|
+
export { useConfirm, useDialog, useRunOrToast, useToast };
|
package/dist/composables.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as useDialog, o as useToast, t as openDialog } from "./use-dialog-Ck2_ZW7T.js";
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
|
-
//#region src/composables/dialogs/use-run-or-toast
|
|
3
|
+
//#region src/composables/dialogs/use-run-or-toast.ts
|
|
4
4
|
const { toast } = useToast();
|
|
5
5
|
/**
|
|
6
6
|
* Generate `run` method and a computed property `isRunning`.
|
|
@@ -62,4 +62,56 @@ function useRunOrToast() {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
//#endregion
|
|
65
|
-
|
|
65
|
+
//#region src/composables/dialogs/use-confirm.ts
|
|
66
|
+
/**
|
|
67
|
+
* Composable which returns a function to run actions only after the user confirms them in a
|
|
68
|
+
* dialog, and a computed property `isRunning`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const { confirm, isRunning } = useConfirm();
|
|
73
|
+
*
|
|
74
|
+
* const removed = await confirm(
|
|
75
|
+
* { title: "Excluir paciente", message: "Esta ação não pode ser desfeita.", confirmText: "Excluir", color: "danger" },
|
|
76
|
+
* () => api.deletePatient(id),
|
|
77
|
+
* );
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
function useConfirm() {
|
|
81
|
+
const { run, isRunning } = useRunOrToast();
|
|
82
|
+
/**
|
|
83
|
+
* Displays a confirmation dialog and, if the user confirms, runs the given function while the
|
|
84
|
+
* dialog shows the confirm button loading. If the function throws an error, the dialog closes
|
|
85
|
+
* and a toast shows the error message.
|
|
86
|
+
* @returns the function returned value, or `false` if the user cancels or the function fails
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const { confirm } = useConfirm();
|
|
91
|
+
*
|
|
92
|
+
* // Call like this:
|
|
93
|
+
* const result1 = await confirm({ message: "Salvar alterações?" }, () => save(form));
|
|
94
|
+
*
|
|
95
|
+
* // Or this:
|
|
96
|
+
* const result2 = await confirm({ message: "Salvar alterações?" }, save, form);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
function confirm(options, action, ...params) {
|
|
100
|
+
return openDialog({
|
|
101
|
+
title: options.title,
|
|
102
|
+
message: options.message,
|
|
103
|
+
role: "alertdialog",
|
|
104
|
+
actions: [{ text: options.cancelText ?? "Cancelar" }, {
|
|
105
|
+
text: options.confirmText ?? "Confirmar",
|
|
106
|
+
value: "confirm",
|
|
107
|
+
color: options.color
|
|
108
|
+
}]
|
|
109
|
+
}, (value) => value === "confirm" ? run(action, ...params) : false);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
confirm,
|
|
113
|
+
isRunning
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { useConfirm, useDialog, useRunOrToast, useToast };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import "@fontsource/roboto/100.css";
|
|
2
|
-
import "@fontsource/roboto/300.css";
|
|
3
|
-
import "@fontsource/roboto/400.css";
|
|
4
|
-
import "@fontsource/roboto/500.css";
|
|
5
|
-
import "@fontsource/roboto/700.css";
|
|
6
|
-
import "@fontsource/roboto/900.css";
|
|
7
|
-
import "@fontsource/roboto/100-italic.css";
|
|
8
|
-
import "@fontsource/roboto/300-italic.css";
|
|
9
|
-
import "@fontsource/roboto/400-italic.css";
|
|
10
|
-
import "@fontsource/roboto/500-italic.css";
|
|
11
|
-
import "@fontsource/roboto/700-italic.css";
|
|
12
|
-
import "@fontsource/roboto/900-italic.css";
|
|
13
1
|
import "@mdi/font/css/materialdesignicons.css";
|
|
14
2
|
import "vuetify/styles";
|
|
3
|
+
import "./styles/fonts/fonts.css";
|
|
15
4
|
import { Plugin } from "vue";
|
|
16
5
|
//#region src/index.d.ts
|
|
17
6
|
/**
|
|
18
7
|
* Create an UIMed-Vue instance to be installed after [createApp](https://vuejs.org/guide/essentials/application.html#the-application-instance).
|
|
19
8
|
* @returns an instance to be used with [app.use](https://vuejs.org/guide/essentials/application.html#the-application-instance)
|
|
20
9
|
*/
|
|
21
|
-
declare function createUimed(): Plugin;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { createUimed };
|
|
10
|
+
export declare function createUimed(): Plugin;
|
|
11
|
+
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "@fontsource/roboto/300.css";
|
|
3
|
-
import "@fontsource/roboto/400.css";
|
|
4
|
-
import "@fontsource/roboto/500.css";
|
|
5
|
-
import "@fontsource/roboto/700.css";
|
|
6
|
-
import "@fontsource/roboto/900.css";
|
|
7
|
-
import "@fontsource/roboto/100-italic.css";
|
|
8
|
-
import "@fontsource/roboto/300-italic.css";
|
|
9
|
-
import "@fontsource/roboto/400-italic.css";
|
|
10
|
-
import "@fontsource/roboto/500-italic.css";
|
|
11
|
-
import "@fontsource/roboto/700-italic.css";
|
|
12
|
-
import "@fontsource/roboto/900-italic.css";
|
|
1
|
+
import { t as localeOptions } from "./locale-CM4o8cD_.js";
|
|
13
2
|
import "@mdi/font/css/materialdesignicons.css";
|
|
14
3
|
import "vuetify/styles";
|
|
4
|
+
import "./styles/fonts/fonts.css";
|
|
15
5
|
import { createVuetify } from "vuetify";
|
|
16
6
|
import "vue";
|
|
17
7
|
//#region src/index.ts
|
|
@@ -20,7 +10,29 @@ import "vue";
|
|
|
20
10
|
* @returns an instance to be used with [app.use](https://vuejs.org/guide/essentials/application.html#the-application-instance)
|
|
21
11
|
*/
|
|
22
12
|
function createUimed() {
|
|
23
|
-
return createVuetify({
|
|
13
|
+
return createVuetify({
|
|
14
|
+
locale: localeOptions,
|
|
15
|
+
theme: {
|
|
16
|
+
defaultTheme: "light",
|
|
17
|
+
themes: { light: {
|
|
18
|
+
dark: false,
|
|
19
|
+
colors: {
|
|
20
|
+
background: "#EAEDF0",
|
|
21
|
+
surface: "#FCFCFD",
|
|
22
|
+
primary: "#00995D",
|
|
23
|
+
secondary: "#FCFCFD",
|
|
24
|
+
success: "#A9EFC5",
|
|
25
|
+
warning: "#FFE596",
|
|
26
|
+
error: "#D92D20",
|
|
27
|
+
info: "#9ACBE5"
|
|
28
|
+
},
|
|
29
|
+
variables: {
|
|
30
|
+
"border-color": "#D0D5DD",
|
|
31
|
+
"font-body": "\"Unimed Slab\", sans-serif"
|
|
32
|
+
}
|
|
33
|
+
} }
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
}
|
|
25
37
|
//#endregion
|
|
26
38
|
export { createUimed };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pt } from "vuetify/locale";
|
|
2
|
+
//#region src/consts/locale.ts
|
|
3
|
+
/**
|
|
4
|
+
* Language of the texts the components generate on their own, such as
|
|
5
|
+
* screen reader announcements and pagination labels. Fixed in pt-BR.
|
|
6
|
+
*/
|
|
7
|
+
const localeOptions = {
|
|
8
|
+
locale: "pt-BR",
|
|
9
|
+
messages: { "pt-BR": pt }
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { localeOptions as t };
|
package/dist/plugins.d.ts
CHANGED
|
@@ -2,12 +2,11 @@ import vitePluginVuetify from "vite-plugin-vuetify";
|
|
|
2
2
|
import { UserConfig } from "vite-plus";
|
|
3
3
|
//#region src/plugins.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Vite plugin for
|
|
5
|
+
* Vite plugin for UIMed.
|
|
6
6
|
*/
|
|
7
|
-
declare function vitePluginUimed(): ReturnType<typeof vitePluginVuetify>;
|
|
7
|
+
export declare function vitePluginUimed(): ReturnType<typeof vitePluginVuetify>;
|
|
8
8
|
/**
|
|
9
|
-
* Vitest Server plugin for
|
|
9
|
+
* Vitest Server plugin for UIMed.
|
|
10
10
|
*/
|
|
11
|
-
declare function vitestServerPluginUimed(): NonNullable<NonNullable<UserConfig["test"]>["server"]>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { vitePluginUimed, vitestServerPluginUimed };
|
|
11
|
+
export declare function vitestServerPluginUimed(): NonNullable<NonNullable<UserConfig["test"]>["server"]>;
|
|
12
|
+
//#endregion
|
package/dist/plugins.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import vitePluginVuetify from "vite-plugin-vuetify";
|
|
2
2
|
//#region src/plugins.ts
|
|
3
3
|
/**
|
|
4
|
-
* Vite plugin for
|
|
4
|
+
* Vite plugin for UIMed.
|
|
5
5
|
*/
|
|
6
6
|
function vitePluginUimed() {
|
|
7
7
|
return vitePluginVuetify({ autoImport: false });
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Vitest Server plugin for
|
|
10
|
+
* Vitest Server plugin for UIMed.
|
|
11
11
|
*/
|
|
12
12
|
function vitestServerPluginUimed() {
|
|
13
|
-
return { deps: { inline: ["vuetify"] } };
|
|
13
|
+
return { deps: { inline: ["vuetify", "@nexdom/uimed-vue"] } };
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
export { vitePluginUimed, vitestServerPluginUimed };
|
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/composables/colors/types.d.ts
|
|
2
|
+
type ColorVariant = "primary" | "secondary" | FeedbackColorVariant;
|
|
3
|
+
type FeedbackColorVariant = "positive" | "informative" | "caution" | "danger";
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/components/button/types.d.ts
|
|
6
|
+
type ButtonVariant = "primary" | "secondary" | "ghost";
|
|
7
|
+
/**
|
|
8
|
+
* Props exposed by the {@link Button} component.
|
|
9
|
+
*/
|
|
10
|
+
type ButtonProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Applies a distinct style variation to the button.
|
|
13
|
+
* One of `primary`, `secondary`, or `ghost`.
|
|
14
|
+
* @default "primary"
|
|
15
|
+
*/
|
|
16
|
+
variant?: ButtonVariant;
|
|
17
|
+
/**
|
|
18
|
+
* Applies a distinct behavior to the button.
|
|
19
|
+
* One of `button` or `submit`.
|
|
20
|
+
* @default "button"
|
|
21
|
+
*/
|
|
22
|
+
type?: "submit" | "button";
|
|
23
|
+
/**
|
|
24
|
+
* Applies a color to the button.
|
|
25
|
+
* One of `primary`, `secondary`, `positive`, `informative`, `caution`, or `danger`.
|
|
26
|
+
* @default "primary"
|
|
27
|
+
*/
|
|
28
|
+
color?: ColorVariant;
|
|
29
|
+
/**
|
|
30
|
+
* Removes the ability to click or target the button.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Displays a loading indicator on the button, disabling interaction.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Associated [form](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/form) id.
|
|
41
|
+
*/
|
|
42
|
+
form?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Component id to use on automated tests.
|
|
45
|
+
*/
|
|
46
|
+
dataTestid?: string;
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { FeedbackColorVariant as i, ButtonVariant as n, ColorVariant as r, ButtonProps as t };
|
package/dist/unit-test.d.ts
CHANGED
|
@@ -3,6 +3,5 @@ import { createVuetify } from "vuetify";
|
|
|
3
3
|
/**
|
|
4
4
|
* Vue Test Utils plugin for Uimed.
|
|
5
5
|
*/
|
|
6
|
-
declare function vueTestUtilsPluginUimed(): ReturnType<typeof createVuetify>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { vueTestUtilsPluginUimed };
|
|
6
|
+
export declare function vueTestUtilsPluginUimed(): ReturnType<typeof createVuetify>;
|
|
7
|
+
//#endregion
|
package/dist/unit-test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as localeOptions } from "./locale-CM4o8cD_.js";
|
|
1
2
|
import { createVuetify } from "vuetify";
|
|
2
3
|
import * as components from "vuetify/components";
|
|
3
4
|
import * as directives from "vuetify/directives";
|
|
@@ -10,7 +11,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
10
11
|
//#region src/unit-test.ts
|
|
11
12
|
const vuetify = createVuetify({
|
|
12
13
|
components,
|
|
13
|
-
directives
|
|
14
|
+
directives,
|
|
15
|
+
locale: localeOptions
|
|
14
16
|
});
|
|
15
17
|
/**
|
|
16
18
|
* Vue Test Utils plugin for Uimed.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { computed, ref, toValue } from "vue";
|
|
2
|
+
const colorToVuetifyColor = {
|
|
3
|
+
primary: "primary",
|
|
4
|
+
secondary: "secondary",
|
|
5
|
+
positive: "success",
|
|
6
|
+
informative: "info",
|
|
7
|
+
caution: "warning",
|
|
8
|
+
danger: "error"
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/composables/colors/use-vuetify-color.ts
|
|
12
|
+
function useVuetifyColor(color) {
|
|
13
|
+
return computed(() => {
|
|
14
|
+
const colorValue = toValue(color);
|
|
15
|
+
return colorValue ? colorToVuetifyColor[colorValue] : colorToVuetifyColor.primary;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/composables/dialogs/use-toast.ts
|
|
20
|
+
const messages = ref([]);
|
|
21
|
+
/**
|
|
22
|
+
* Composable which returns a function to display toast messages.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const { toast } = useToast();
|
|
27
|
+
* toast({ message: "Hello, World!" });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function useToast() {
|
|
31
|
+
return { toast };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Displays a toast message.
|
|
35
|
+
* @param {ToastOptions} options - Options for the toast message.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* toast({ message: "Hello, World!" });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function toast(options) {
|
|
43
|
+
const text = options.message;
|
|
44
|
+
const color = useVuetifyColor(options.color ?? "informative");
|
|
45
|
+
const toastMessage = {
|
|
46
|
+
text,
|
|
47
|
+
color: color.value,
|
|
48
|
+
prependIcon: `$${color.value}`
|
|
49
|
+
};
|
|
50
|
+
messages.value.push(toastMessage);
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/composables/dialogs/use-dialog.ts
|
|
54
|
+
/**
|
|
55
|
+
* Dialogs waiting to be displayed, shared by `useDialog` and `useConfirm`. The first one is the
|
|
56
|
+
* dialog on display (or about to be).
|
|
57
|
+
*/
|
|
58
|
+
const requests = ref([]);
|
|
59
|
+
/**
|
|
60
|
+
* Mounted `Dialog` components, in mounting order. Only the first one displays dialogs, so pages
|
|
61
|
+
* with more than one `UMain` don't display duplicates.
|
|
62
|
+
*/
|
|
63
|
+
const owners = ref([]);
|
|
64
|
+
/**
|
|
65
|
+
* Queues a dialog and resolves with what `onSelect` returns for the clicked action's value
|
|
66
|
+
* (`undefined` when the dialog is dismissed).
|
|
67
|
+
*/
|
|
68
|
+
function openDialog(options, onSelect) {
|
|
69
|
+
const { actions, ...content } = options;
|
|
70
|
+
const lastIndex = actions.length - 1;
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
requests.value.push({
|
|
73
|
+
...content,
|
|
74
|
+
actions: actions.map((action, index) => ({
|
|
75
|
+
...action,
|
|
76
|
+
variant: action.variant ?? (index === lastIndex ? "primary" : "ghost")
|
|
77
|
+
})),
|
|
78
|
+
async select(value) {
|
|
79
|
+
resolve(await onSelect(value));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Composable which returns a function to display dialogs.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const { dialog } = useDialog();
|
|
90
|
+
*
|
|
91
|
+
* const answer = await dialog({
|
|
92
|
+
* title: "Sessão expirando",
|
|
93
|
+
* message: "Deseja continuar conectado?",
|
|
94
|
+
* actions: [
|
|
95
|
+
* { text: "Sair", value: "leave" },
|
|
96
|
+
* { text: "Continuar", value: "stay" },
|
|
97
|
+
* ],
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
function useDialog() {
|
|
102
|
+
return { dialog };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Displays a dialog. Dialogs are displayed one at a time, in the order they were requested.
|
|
106
|
+
* @param {DialogOptions} options - Options for the dialog.
|
|
107
|
+
* @returns the `value` of the clicked action, or `undefined` when the dialog is closed by the
|
|
108
|
+
* default action, the `Esc` key, a click outside it or the browser's back button.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* await dialog({ title: "Aviso", message: "Seu cadastro foi enviado para análise." });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
function dialog(options) {
|
|
116
|
+
return openDialog({
|
|
117
|
+
title: options.title,
|
|
118
|
+
message: options.message,
|
|
119
|
+
role: "dialog",
|
|
120
|
+
actions: options.actions ?? [{ text: "Fechar" }]
|
|
121
|
+
}, (value) => value);
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { messages as a, useDialog as i, owners as n, useToast as o, requests as r, useVuetifyColor as s, openDialog as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexdom/uimed-vue",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.20",
|
|
4
4
|
"description": "A ui framework for NEXDOM applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lib",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@commitlint/cli": "^21.2.1",
|
|
56
56
|
"@commitlint/config-conventional": "^21.2.0",
|
|
57
|
-
"@fontsource/roboto": "^5.3.0",
|
|
58
57
|
"@mdi/font": "^7.4.47",
|
|
59
58
|
"@nexdom/shared": "^2.1.1",
|
|
60
59
|
"@playwright/test": "^1.62.1",
|
|
@@ -64,7 +63,7 @@
|
|
|
64
63
|
"@types/node": "^26.1.2",
|
|
65
64
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
66
65
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
67
|
-
"@vitest/coverage-v8": "
|
|
66
|
+
"@vitest/coverage-v8": "5.0.1",
|
|
68
67
|
"@vue/test-utils": "^2.4.11",
|
|
69
68
|
"bumpp": "^12.1.1",
|
|
70
69
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
@@ -77,22 +76,24 @@
|
|
|
77
76
|
"stryker-vue-ignorer": "github:davidlandais/stryker-vue-ignorer",
|
|
78
77
|
"typescript": "^6.0.3",
|
|
79
78
|
"vite-plugin-vuetify": "^2.1.3",
|
|
80
|
-
"vite-plus": "^0.
|
|
79
|
+
"vite-plus": "^1.0.0",
|
|
81
80
|
"vitepress": "2.0.0-alpha.19",
|
|
82
81
|
"vitepress-plugin-group-icons": "^1.7.6",
|
|
82
|
+
"vitest": "5.0.1",
|
|
83
83
|
"vue": "^3.5.40",
|
|
84
|
+
"vue-component-type-helpers": "^3.3.11",
|
|
84
85
|
"vue-router": "^5.3.1",
|
|
85
86
|
"vue-tsc": "^3.3.9",
|
|
86
87
|
"vuetify": "^4.2.0"
|
|
87
88
|
},
|
|
88
89
|
"peerDependencies": {
|
|
89
|
-
"@fontsource/roboto": "^5.3.0",
|
|
90
90
|
"@mdi/font": "^7.4.47",
|
|
91
91
|
"@nexdom/shared": "^2.1.1",
|
|
92
92
|
"resize-observer-polyfill": "^1.5.1",
|
|
93
93
|
"vite-plugin-vuetify": "^2.1.3",
|
|
94
|
-
"vite-plus": "^0.
|
|
94
|
+
"vite-plus": "^1.0.0",
|
|
95
95
|
"vue": "^3.5.40",
|
|
96
|
+
"vue-component-type-helpers": "^3.3.11",
|
|
96
97
|
"vue-router": "^5.3.1",
|
|
97
98
|
"vuetify": "^4.2.0"
|
|
98
99
|
},
|
package/dist/types-BPXXtbmW.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { computed, ref, toValue } from "vue";
|
|
2
|
-
const colorToVuetifyColor = {
|
|
3
|
-
primary: "primary",
|
|
4
|
-
secondary: "secondary",
|
|
5
|
-
positive: "success",
|
|
6
|
-
informative: "info",
|
|
7
|
-
caution: "warning",
|
|
8
|
-
danger: "error"
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/composables/colors/use-vuetify-color.ts
|
|
12
|
-
function useVuetifyColor(color) {
|
|
13
|
-
return computed(() => {
|
|
14
|
-
const colorValue = toValue(color);
|
|
15
|
-
return colorValue ? colorToVuetifyColor[colorValue] : colorToVuetifyColor.primary;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/composables/dialogs/use-toast.ts
|
|
20
|
-
const messages = ref([]);
|
|
21
|
-
/**
|
|
22
|
-
* Composable which returns a function to display toast messages.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const { toast } = useToast();
|
|
27
|
-
* toast({ message: "Hello, World!" });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
function useToast() {
|
|
31
|
-
return { toast };
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Displays a toast message.
|
|
35
|
-
* @param {ToastOptions} options - Options for the toast message.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* toast({ message: "Hello, World!" });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
function toast(options) {
|
|
43
|
-
const text = options.message;
|
|
44
|
-
const color = useVuetifyColor(options.color ?? "informative");
|
|
45
|
-
const toastMessage = {
|
|
46
|
-
text,
|
|
47
|
-
color: color.value,
|
|
48
|
-
prependIcon: `$${color.value}`
|
|
49
|
-
};
|
|
50
|
-
messages.value.push(toastMessage);
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
export { useToast as n, useVuetifyColor as r, messages as t };
|