@nexdom/uimed-vue 2.0.0-beta.4 → 2.0.0-beta.40

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.
@@ -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.4",
3
+ "version": "2.0.0-beta.40",
4
4
  "description": "A ui framework for NEXDOM applications.",
5
5
  "keywords": [
6
6
  "lib",
@@ -54,9 +54,8 @@
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
- "@nexdom/shared": "^2.1.1",
58
+ "@nexdom/shared": "^2.3.0",
60
59
  "@playwright/test": "^1.62.1",
61
60
  "@sonar/scan": "^5.0.0",
62
61
  "@stryker-mutator/core": "^10.0.0",
@@ -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": "4.1.10",
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",
@@ -76,10 +75,10 @@
76
75
  "sass-embedded": "^1.103.1",
77
76
  "stryker-vue-ignorer": "github:davidlandais/stryker-vue-ignorer",
78
77
  "typescript": "^6.0.3",
79
- "vite-plugin-vuetify": "^2.1.3",
80
- "vite-plus": "^0.2.9",
78
+ "vite-plus": "^1.0.0",
81
79
  "vitepress": "2.0.0-alpha.19",
82
80
  "vitepress-plugin-group-icons": "^1.7.6",
81
+ "vitest": "5.0.1",
83
82
  "vue": "^3.5.40",
84
83
  "vue-component-type-helpers": "^3.3.11",
85
84
  "vue-router": "^5.3.1",
@@ -87,12 +86,11 @@
87
86
  "vuetify": "^4.2.0"
88
87
  },
89
88
  "peerDependencies": {
90
- "@fontsource/roboto": "^5.3.0",
91
89
  "@mdi/font": "^7.4.47",
92
- "@nexdom/shared": "^2.1.1",
90
+ "@nexdom/shared": "^2.3.0",
93
91
  "resize-observer-polyfill": "^1.5.1",
94
- "vite-plugin-vuetify": "^2.1.3",
95
- "vite-plus": "^0.2.7",
92
+ "sass-embedded": "^1.103.1",
93
+ "vite-plus": "^1.0.0",
96
94
  "vue": "^3.5.40",
97
95
  "vue-component-type-helpers": "^3.3.11",
98
96
  "vue-router": "^5.3.1",
@@ -1,5 +0,0 @@
1
- //#region src/composables/colors/types.d.ts
2
- type ColorVariant = "primary" | "secondary" | FeedbackColorVariant;
3
- type FeedbackColorVariant = "positive" | "informative" | "caution" | "danger";
4
- //#endregion
5
- export { FeedbackColorVariant as n, ColorVariant as t };
@@ -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 };