@nexdom/uimed-vue 2.0.0-beta.2 → 2.0.0-beta.21
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 +116 -14
- 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 +22 -13
- package/dist/locale-CM4o8cD_.js +12 -0
- package/dist/plugins.d.ts +18 -8
- package/dist/plugins.js +56 -5
- package/dist/styles/fonts/UnimedSlab-Regular.woff2 +0 -0
- package/dist/styles/fonts/fonts.css +4 -0
- package/dist/styles/settings.scss +6 -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 +8 -8
- 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,26 @@ 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: { "border-color": "#D0D5DD" }
|
|
30
|
+
} }
|
|
31
|
+
}
|
|
32
|
+
});
|
|
24
33
|
}
|
|
25
34
|
//#endregion
|
|
26
35
|
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
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UserConfig } from "vite-plus";
|
|
1
|
+
import { Plugin, UserConfig } from "vite-plus";
|
|
3
2
|
//#region src/plugins.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* Vite plugin
|
|
4
|
+
* Vite plugin that compiles the components' styles with the library's font and Sass settings.
|
|
5
|
+
* Required: without it, the components lose the Unimed Slab font. Needs `sass-embedded`, a peer
|
|
6
|
+
* dependency.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // vite.config.ts
|
|
11
|
+
* import { vitePluginUimed } from "@nexdom/uimed-vue/plugins";
|
|
12
|
+
*
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* plugins: [vue(), vitePluginUimed()],
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
6
17
|
*/
|
|
7
|
-
declare function vitePluginUimed():
|
|
18
|
+
export declare function vitePluginUimed(): Plugin[];
|
|
8
19
|
/**
|
|
9
|
-
* Vitest Server plugin for
|
|
20
|
+
* Vitest Server plugin for UIMed.
|
|
10
21
|
*/
|
|
11
|
-
declare function vitestServerPluginUimed(): NonNullable<NonNullable<UserConfig["test"]>["server"]>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { vitePluginUimed, vitestServerPluginUimed };
|
|
22
|
+
export declare function vitestServerPluginUimed(): NonNullable<NonNullable<UserConfig["test"]>["server"]>;
|
|
23
|
+
//#endregion
|
package/dist/plugins.js
CHANGED
|
@@ -1,16 +1,67 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
2
3
|
//#region src/plugins.ts
|
|
4
|
+
/** Matches the ids of CSS files, with or without a query */
|
|
5
|
+
const stylesheet = /\.css(?:\?|$)/;
|
|
6
|
+
/** Path of Vuetify's stylesheets folder, inside the `node_modules` folder where it's installed */
|
|
7
|
+
const vuetifyStylesheets = "/node_modules/vuetify/lib/";
|
|
3
8
|
/**
|
|
4
|
-
*
|
|
9
|
+
* Matches the queries that import a stylesheet's file as is (`?raw`) or its URL (`?url`), which
|
|
10
|
+
* Vite doesn't compile. The URL still serves the compiled stylesheet, which Vite loads separately
|
|
11
|
+
*/
|
|
12
|
+
const uncompiledStylesheetQuery = /[?&](?:raw|url)\b/;
|
|
13
|
+
/**
|
|
14
|
+
* Vite plugin that compiles the components' styles with the library's font and Sass settings.
|
|
15
|
+
* Required: without it, the components lose the Unimed Slab font. Needs `sass-embedded`, a peer
|
|
16
|
+
* dependency.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // vite.config.ts
|
|
21
|
+
* import { vitePluginUimed } from "@nexdom/uimed-vue/plugins";
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig({
|
|
24
|
+
* plugins: [vue(), vitePluginUimed()],
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
5
27
|
*/
|
|
6
28
|
function vitePluginUimed() {
|
|
7
|
-
|
|
29
|
+
const settings = new URL("./styles/settings.scss", import.meta.url);
|
|
30
|
+
let compiler;
|
|
31
|
+
return [{
|
|
32
|
+
name: "uimed:vuetify-styles",
|
|
33
|
+
enforce: "pre",
|
|
34
|
+
load: {
|
|
35
|
+
filter: { id: {
|
|
36
|
+
include: stylesheet,
|
|
37
|
+
exclude: uncompiledStylesheetQuery
|
|
38
|
+
} },
|
|
39
|
+
async handler(id) {
|
|
40
|
+
const file = id.split("?")[0].replaceAll("\\", "/");
|
|
41
|
+
const folder = file.lastIndexOf(vuetifyStylesheets);
|
|
42
|
+
if (folder === -1) return null;
|
|
43
|
+
const nodeModules = `${file.slice(0, folder)}/node_modules`;
|
|
44
|
+
const source = [".sass", ".scss"].map((extension) => `${file.slice(0, -4)}${extension}`).find((path) => existsSync(path));
|
|
45
|
+
if (!source) return null;
|
|
46
|
+
compiler ??= import("sass-embedded").then((sass) => sass.initAsyncCompiler());
|
|
47
|
+
const sass = await compiler;
|
|
48
|
+
const entry = `@use "${settings.href}";\n@use "${pathToFileURL(source).href}";`;
|
|
49
|
+
const { css } = await sass.compileStringAsync(entry, { loadPaths: [nodeModules] });
|
|
50
|
+
return css;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
async closeBundle() {
|
|
54
|
+
const current = compiler;
|
|
55
|
+
compiler = void 0;
|
|
56
|
+
await (await current)?.dispose();
|
|
57
|
+
}
|
|
58
|
+
}];
|
|
8
59
|
}
|
|
9
60
|
/**
|
|
10
|
-
* Vitest Server plugin for
|
|
61
|
+
* Vitest Server plugin for UIMed.
|
|
11
62
|
*/
|
|
12
63
|
function vitestServerPluginUimed() {
|
|
13
|
-
return { deps: { inline: ["vuetify"] } };
|
|
64
|
+
return { deps: { inline: ["vuetify", "@nexdom/uimed-vue"] } };
|
|
14
65
|
}
|
|
15
66
|
//#endregion
|
|
16
67
|
export { vitePluginUimed, vitestServerPluginUimed };
|
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
@use "vuetify/settings" with (
|
|
2
|
+
$body-font-family: var(--v-font-body, "Unimed Slab", sans-serif),
|
|
3
|
+
// Unimed Slab's ascent and descent take 1.26em, more than the subtitles' default 1rem line
|
|
4
|
+
// height, which clipped its descenders and accented capitals
|
|
5
|
+
$list-item-subtitle-line-height: normal
|
|
6
|
+
);
|
|
@@ -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 };
|