@nexdom/uimed-vue 2.0.0-beta.5 → 2.0.0-beta.50

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.
@@ -0,0 +1,69 @@
1
+ import { RouteLocationRaw } from "vue-router";
2
+ //#region src/composables/colors/types.d.ts
3
+ type ColorVariant = "primary" | "secondary" | FeedbackColorVariant;
4
+ type FeedbackColorVariant = "positive" | "informative" | "caution" | "danger";
5
+ //#endregion
6
+ //#region src/components/button/types.d.ts
7
+ type ButtonVariant = "primary" | "secondary" | "ghost";
8
+ /**
9
+ * Props exposed by the {@link Button} component.
10
+ */
11
+ type ButtonProps = {
12
+ /**
13
+ * Applies a distinct style variation to the button.
14
+ * One of `primary`, `secondary`, or `ghost`.
15
+ * @default "primary"
16
+ */
17
+ variant?: ButtonVariant;
18
+ /**
19
+ * Applies a distinct behavior to the button.
20
+ * One of `button` or `submit`. Ignored when `route` is set.
21
+ * @default "button"
22
+ */
23
+ type?: "submit" | "button";
24
+ /**
25
+ * Applies a color to the button.
26
+ * One of `primary`, `secondary`, `positive`, `informative`, `caution`, or `danger`.
27
+ * @default "primary"
28
+ */
29
+ color?: ColorVariant;
30
+ /**
31
+ * Removes the ability to click or target the button.
32
+ * @default false
33
+ */
34
+ disabled?: boolean;
35
+ /**
36
+ * Displays a loading indicator on the button and disables it while active, as `disabled` does:
37
+ * it can't be clicked or focused, `click` isn't emitted and its form isn't submitted, including
38
+ * by pressing `Enter` in one of the form's fields when it's the form's first submit button. It
39
+ * looks disabled, with the indicator, and loses focus if focused when loading starts, as any
40
+ * disabled button does. The button keeps its text as accessible name and is marked as busy, and
41
+ * assistive technologies ignore the indicator.
42
+ * @default false
43
+ */
44
+ loading?: boolean;
45
+ /**
46
+ * Stretches the button to the whole width of its parent, e.g. the only action of a form on a
47
+ * small screen.
48
+ * @default false
49
+ */
50
+ fullWidth?: boolean;
51
+ /**
52
+ * Associated [form](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/form) id.
53
+ * Ignored when `route` is set.
54
+ */
55
+ form?: string;
56
+ /**
57
+ * Where the button goes when clicked, rendering it as a link with the button's look. A route
58
+ * inside the app (`"/patients"`, `{ name: "patient", params: { id } }`) navigates through the
59
+ * app's router; a URL starting with `http` navigates through the browser, in the same tab. While
60
+ * `disabled` or `loading`, the button doesn't navigate and is rendered as a disabled button.
61
+ */
62
+ route?: RouteLocationRaw;
63
+ /**
64
+ * Component id to use on automated tests.
65
+ */
66
+ dataTestid?: string;
67
+ };
68
+ //#endregion
69
+ export { FeedbackColorVariant as i, ButtonVariant as n, ColorVariant as r, ButtonProps as t };
@@ -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,138 @@
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
+ /**
11
+ * The theme colors to use when a color is the text color, on the surface or background, instead
12
+ * of a fill. The fills are too light to reach WCAG AA's contrast as text, so each one has a darker
13
+ * shade, except `secondary`, which is almost white and gives way to the theme's text color.
14
+ */
15
+ const colorToVuetifyTextColor = {
16
+ primary: "primary-text",
17
+ secondary: "on-surface",
18
+ positive: "success-text",
19
+ informative: "info-text",
20
+ caution: "warning-text",
21
+ danger: "error-text"
22
+ };
23
+ //#endregion
24
+ //#region src/composables/colors/use-vuetify-color.ts
25
+ function useVuetifyColor(color) {
26
+ return computed(() => {
27
+ const colorValue = toValue(color);
28
+ return colorValue ? colorToVuetifyColor[colorValue] : colorToVuetifyColor.primary;
29
+ });
30
+ }
31
+ //#endregion
32
+ //#region src/composables/dialogs/use-toast.ts
33
+ const messages = ref([]);
34
+ /**
35
+ * Composable which returns a function to display toast messages.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const { toast } = useToast();
40
+ * toast({ message: "Hello, World!" });
41
+ * ```
42
+ */
43
+ function useToast() {
44
+ return { toast };
45
+ }
46
+ /**
47
+ * Displays a toast message.
48
+ * @param {ToastOptions} options - Options for the toast message.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * toast({ message: "Hello, World!" });
53
+ * ```
54
+ */
55
+ function toast(options) {
56
+ const text = options.message;
57
+ const color = useVuetifyColor(options.color ?? "informative");
58
+ const toastMessage = {
59
+ text,
60
+ color: color.value,
61
+ prependIcon: `$${color.value}`,
62
+ timerColor: `rgb(var(--v-theme-on-${color.value}))`
63
+ };
64
+ messages.value.push(toastMessage);
65
+ }
66
+ //#endregion
67
+ //#region src/composables/dialogs/use-dialog.ts
68
+ /**
69
+ * Dialogs waiting to be displayed, shared by `useDialog` and `useConfirm`. The first one is the
70
+ * dialog on display (or about to be).
71
+ */
72
+ const requests = ref([]);
73
+ /**
74
+ * Mounted `Dialog` components, in mounting order. Only the first one displays dialogs, so pages
75
+ * with more than one `UMain` don't display duplicates.
76
+ */
77
+ const owners = ref([]);
78
+ /**
79
+ * Queues a dialog and resolves with what `onSelect` returns for the clicked action's value
80
+ * (`undefined` when the dialog is dismissed).
81
+ */
82
+ function openDialog(options, onSelect) {
83
+ const { actions, ...content } = options;
84
+ const lastIndex = actions.length - 1;
85
+ return new Promise((resolve) => {
86
+ requests.value.push({
87
+ ...content,
88
+ actions: actions.map((action, index) => ({
89
+ ...action,
90
+ variant: action.variant ?? (index === lastIndex ? "primary" : "ghost")
91
+ })),
92
+ async select(value) {
93
+ resolve(await onSelect(value));
94
+ }
95
+ });
96
+ });
97
+ }
98
+ /**
99
+ * Composable which returns a function to display dialogs.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const { dialog } = useDialog();
104
+ *
105
+ * const answer = await dialog({
106
+ * title: "Sessão expirando",
107
+ * message: "Deseja continuar conectado?",
108
+ * actions: [
109
+ * { text: "Sair", value: "leave" },
110
+ * { text: "Continuar", value: "stay" },
111
+ * ],
112
+ * });
113
+ * ```
114
+ */
115
+ function useDialog() {
116
+ return { dialog };
117
+ }
118
+ /**
119
+ * Displays a dialog. Dialogs are displayed one at a time, in the order they were requested.
120
+ * @param {DialogOptions} options - Options for the dialog.
121
+ * @returns the `value` of the clicked action, or `undefined` when the dialog is closed by the
122
+ * default action, the `Esc` key, a click outside it or the browser's back button.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * await dialog({ title: "Aviso", message: "Seu cadastro foi enviado para análise." });
127
+ * ```
128
+ */
129
+ function dialog(options) {
130
+ return openDialog({
131
+ title: options.title,
132
+ message: options.message,
133
+ role: "dialog",
134
+ actions: options.actions ?? [{ text: "Fechar" }]
135
+ }, (value) => value);
136
+ }
137
+ //#endregion
138
+ export { messages as a, colorToVuetifyColor as c, useDialog as i, colorToVuetifyTextColor as l, 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.5",
3
+ "version": "2.0.0-beta.50",
4
4
  "description": "A ui framework for NEXDOM applications.",
5
5
  "keywords": [
6
6
  "lib",
@@ -52,11 +52,11 @@
52
52
  "postinstall": "playwright install --with-deps chromium"
53
53
  },
54
54
  "devDependencies": {
55
+ "@axe-core/playwright": "^4.13.0",
55
56
  "@commitlint/cli": "^21.2.1",
56
57
  "@commitlint/config-conventional": "^21.2.0",
57
- "@fontsource/roboto": "^5.3.0",
58
58
  "@mdi/font": "^7.4.47",
59
- "@nexdom/shared": "^2.1.1",
59
+ "@nexdom/shared": "^2.3.0",
60
60
  "@playwright/test": "^1.62.1",
61
61
  "@sonar/scan": "^5.0.0",
62
62
  "@stryker-mutator/core": "^10.0.0",
@@ -64,7 +64,7 @@
64
64
  "@types/node": "^26.1.2",
65
65
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
66
66
  "@vitejs/plugin-vue": "^6.0.8",
67
- "@vitest/coverage-v8": "4.1.10",
67
+ "@vitest/coverage-v8": "5.0.1",
68
68
  "@vue/test-utils": "^2.4.11",
69
69
  "bumpp": "^12.1.1",
70
70
  "conventional-changelog-conventionalcommits": "^9.3.1",
@@ -76,10 +76,10 @@
76
76
  "sass-embedded": "^1.103.1",
77
77
  "stryker-vue-ignorer": "github:davidlandais/stryker-vue-ignorer",
78
78
  "typescript": "^6.0.3",
79
- "vite-plugin-vuetify": "^2.1.3",
80
- "vite-plus": "^0.2.9",
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
84
  "vue-component-type-helpers": "^3.3.11",
85
85
  "vue-router": "^5.3.1",
@@ -87,12 +87,11 @@
87
87
  "vuetify": "^4.2.0"
88
88
  },
89
89
  "peerDependencies": {
90
- "@fontsource/roboto": "^5.3.0",
91
90
  "@mdi/font": "^7.4.47",
92
- "@nexdom/shared": "^2.1.1",
91
+ "@nexdom/shared": "^2.3.0",
93
92
  "resize-observer-polyfill": "^1.5.1",
94
- "vite-plugin-vuetify": "^2.1.3",
95
- "vite-plus": "^0.2.7",
93
+ "sass-embedded": "^1.103.1",
94
+ "vite-plus": "^1.0.0",
96
95
  "vue": "^3.5.40",
97
96
  "vue-component-type-helpers": "^3.3.11",
98
97
  "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 };