@nexdom/uimed-vue 1.1.0-beta.4 → 1.2.0-beta.1
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/components.d.ts +2 -2
- package/dist/components.js +61 -40
- package/dist/composables.d.ts +67 -0
- package/dist/composables.js +65 -0
- package/dist/types-BPXXtbmW.d.ts +5 -0
- package/dist/use-toast-CACuYhK_.js +53 -0
- package/package.json +5 -4
package/dist/components.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as ColorVariant } from "./types-BPXXtbmW.js";
|
|
1
2
|
//#region src/components/root/types.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Props exposed by the {@link Root} component.
|
|
@@ -34,7 +35,6 @@ type __VLS_WithSlots$5<T, S> = T & {
|
|
|
34
35
|
//#endregion
|
|
35
36
|
//#region src/components/btn/types.d.ts
|
|
36
37
|
type BtnVariant = "primary" | "secondary" | "ghost";
|
|
37
|
-
type BtnColor = "primary" | "secondary" | "positive" | "informative" | "caution" | "danger";
|
|
38
38
|
/**
|
|
39
39
|
* Props exposed by the {@link Btn} component.
|
|
40
40
|
*/
|
|
@@ -56,7 +56,7 @@ type BtnProps = {
|
|
|
56
56
|
* One of `primary`, `secondary`, `positive`, `informative`, `caution`, or `danger`.
|
|
57
57
|
* @default "primary"
|
|
58
58
|
*/
|
|
59
|
-
color?:
|
|
59
|
+
color?: ColorVariant;
|
|
60
60
|
/**
|
|
61
61
|
* Removes the ability to click or target the button.
|
|
62
62
|
* @default false
|
package/dist/components.js
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { r as useVuetifyColor, t as messages } from "./use-toast-CACuYhK_.js";
|
|
2
|
+
import { computed, createBlock, createPropsRestProxy, createVNode, defineComponent, isRef, mergeModels, mergeProps, openBlock, renderSlot, toValue, unref, useModel, withCtx, withModifiers } from "vue";
|
|
3
|
+
import { VApp, VBtn, VCol, VContainer, VForm, VIconBtn, VMain, VRow, VSnackbarQueue, VTextField } from "vuetify/components";
|
|
3
4
|
import { isEmail, isEmpty, isPhone, isUrl } from "@nexdom/shared/utils";
|
|
4
5
|
//#endregion
|
|
6
|
+
//#region src/components/grid/container/container.vue
|
|
7
|
+
var container_default = /* @__PURE__ */ defineComponent({
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
__name: "container",
|
|
10
|
+
props: { dataTestid: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: false
|
|
13
|
+
} },
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
return (_ctx, _cache) => {
|
|
17
|
+
return openBlock(), createBlock(unref(VContainer), {
|
|
18
|
+
"data-testid": props.dataTestid,
|
|
19
|
+
fluid: ""
|
|
20
|
+
}, {
|
|
21
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
22
|
+
_: 3
|
|
23
|
+
}, 8, ["data-testid"]);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/components/dialogs/toast.vue
|
|
29
|
+
var toast_default = /* @__PURE__ */ defineComponent({
|
|
30
|
+
inheritAttrs: false,
|
|
31
|
+
__name: "toast",
|
|
32
|
+
setup(__props) {
|
|
33
|
+
return (_ctx, _cache) => {
|
|
34
|
+
return openBlock(), createBlock(unref(VSnackbarQueue), {
|
|
35
|
+
modelValue: unref(messages),
|
|
36
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(messages) ? messages.value = $event : null),
|
|
37
|
+
"display-strategy": "overflow",
|
|
38
|
+
location: "top end",
|
|
39
|
+
"total-visible": "3",
|
|
40
|
+
collapsed: "",
|
|
41
|
+
closable: "",
|
|
42
|
+
timer: ""
|
|
43
|
+
}, {
|
|
44
|
+
actions: withCtx(({ props }) => [createVNode(unref(VIconBtn), mergeProps(props, {
|
|
45
|
+
"aria-label": "Fechar",
|
|
46
|
+
icon: "$close",
|
|
47
|
+
size: "small",
|
|
48
|
+
variant: "text"
|
|
49
|
+
}), null, 16)]),
|
|
50
|
+
_: 1
|
|
51
|
+
}, 8, ["modelValue"]);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
5
56
|
//#region src/components/root/root.vue
|
|
6
57
|
var root_default = /* @__PURE__ */ defineComponent({
|
|
7
58
|
inheritAttrs: false,
|
|
@@ -14,7 +65,13 @@ var root_default = /* @__PURE__ */ defineComponent({
|
|
|
14
65
|
const props = __props;
|
|
15
66
|
return (_ctx, _cache) => {
|
|
16
67
|
return openBlock(), createBlock(unref(VApp), { "data-testid": props.dataTestid }, {
|
|
17
|
-
default: withCtx(() => [
|
|
68
|
+
default: withCtx(() => [createVNode(unref(VMain), null, {
|
|
69
|
+
default: withCtx(() => [createVNode(container_default, null, {
|
|
70
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default"), createVNode(toast_default)]),
|
|
71
|
+
_: 3
|
|
72
|
+
})]),
|
|
73
|
+
_: 3
|
|
74
|
+
})]),
|
|
18
75
|
_: 3
|
|
19
76
|
}, 8, ["data-testid"]);
|
|
20
77
|
};
|
|
@@ -27,26 +84,12 @@ const btnVariantToVuetifyVariant = {
|
|
|
27
84
|
secondary: "flat",
|
|
28
85
|
ghost: "outlined"
|
|
29
86
|
};
|
|
30
|
-
const btnColorToVuetifyColor = {
|
|
31
|
-
primary: "primary",
|
|
32
|
-
secondary: "secondary",
|
|
33
|
-
positive: "success",
|
|
34
|
-
informative: "info",
|
|
35
|
-
caution: "warning",
|
|
36
|
-
danger: "error"
|
|
37
|
-
};
|
|
38
87
|
function useBtnVariant(variant) {
|
|
39
88
|
return computed(() => {
|
|
40
89
|
const variantValue = toValue(variant);
|
|
41
90
|
return variantValue ? btnVariantToVuetifyVariant[variantValue] : btnVariantToVuetifyVariant.primary;
|
|
42
91
|
});
|
|
43
92
|
}
|
|
44
|
-
function useBtnColor(color) {
|
|
45
|
-
return computed(() => {
|
|
46
|
-
const colorValue = toValue(color);
|
|
47
|
-
return colorValue ? btnColorToVuetifyColor[colorValue] : btnColorToVuetifyColor.primary;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
93
|
function useBtnType(type) {
|
|
51
94
|
return computed(() => {
|
|
52
95
|
return toValue(type) ?? "button";
|
|
@@ -95,7 +138,7 @@ var btn_default = /* @__PURE__ */ defineComponent({
|
|
|
95
138
|
const props = __props;
|
|
96
139
|
const emit = __emit;
|
|
97
140
|
const variant = useBtnVariant(() => props.variant);
|
|
98
|
-
const color =
|
|
141
|
+
const color = useVuetifyColor(() => props.color);
|
|
99
142
|
const type = useBtnType(() => props.type);
|
|
100
143
|
const form = useBtnForm(() => props.form);
|
|
101
144
|
function onClick(event) {
|
|
@@ -291,28 +334,6 @@ var text_field_default = /* @__PURE__ */ defineComponent({
|
|
|
291
334
|
}
|
|
292
335
|
});
|
|
293
336
|
//#endregion
|
|
294
|
-
//#region src/components/grid/container/container.vue
|
|
295
|
-
var container_default = /* @__PURE__ */ defineComponent({
|
|
296
|
-
inheritAttrs: false,
|
|
297
|
-
__name: "container",
|
|
298
|
-
props: { dataTestid: {
|
|
299
|
-
type: String,
|
|
300
|
-
required: false
|
|
301
|
-
} },
|
|
302
|
-
setup(__props) {
|
|
303
|
-
const props = __props;
|
|
304
|
-
return (_ctx, _cache) => {
|
|
305
|
-
return openBlock(), createBlock(unref(VContainer), {
|
|
306
|
-
"data-testid": props.dataTestid,
|
|
307
|
-
fluid: ""
|
|
308
|
-
}, {
|
|
309
|
-
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
310
|
-
_: 3
|
|
311
|
-
}, 8, ["data-testid"]);
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
//#endregion
|
|
316
337
|
//#region src/components/grid/row/row.vue
|
|
317
338
|
var row_default = /* @__PURE__ */ defineComponent({
|
|
318
339
|
inheritAttrs: false,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { n as FeedbackColorVariant } from "./types-BPXXtbmW.js";
|
|
2
|
+
//#region src/composables/dialogs/types.d.ts
|
|
3
|
+
interface ToastOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Text to be presented in the toast.
|
|
6
|
+
*/
|
|
7
|
+
message: string;
|
|
8
|
+
/**
|
|
9
|
+
* Applies a color to the button.
|
|
10
|
+
* One of `positive`, `informative`, `caution`, or `danger`.
|
|
11
|
+
* @default "informative"
|
|
12
|
+
*/
|
|
13
|
+
color?: FeedbackColorVariant;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/composables/dialogs/use-toast.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Composable which returns a function to display toast messages.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const { toast } = useToast();
|
|
23
|
+
* toast({ message: "Hello, World!" });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function useToast(): {
|
|
27
|
+
toast: typeof toast;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Displays a toast message.
|
|
31
|
+
* @param {ToastOptions} options - Options for the toast message.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* toast({ message: "Hello, World!" });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function toast(options: ToastOptions): void;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/composables/dialogs/use-run-or-toast..d.ts
|
|
41
|
+
/**
|
|
42
|
+
* Generate `run` method and a computed property `isRunning`.
|
|
43
|
+
* Calling `run` will reactively update `isRunning`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const { run, isRunning } = useRunOrToast();
|
|
48
|
+
*
|
|
49
|
+
* // Logs: false
|
|
50
|
+
* console.log(isRunning.value);
|
|
51
|
+
*
|
|
52
|
+
* const promise = run(() => someFunction(param1, param2));
|
|
53
|
+
*
|
|
54
|
+
* // Logs: true
|
|
55
|
+
* console.log(isRunning.value);
|
|
56
|
+
*
|
|
57
|
+
* await promise;
|
|
58
|
+
* // Logs: false
|
|
59
|
+
* console.log(isRunning.value);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function useRunOrToast(): {
|
|
63
|
+
run: <T extends (...args: Parameters<T>) => PromiseLike<Awaited<ReturnType<T>>>>(toRun: T, ...params: Parameters<T>) => Promise<Awaited<ReturnType<T>> | false>;
|
|
64
|
+
isRunning: import("vue").ComputedRef<boolean>;
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
export { useRunOrToast, useToast };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { n as useToast } from "./use-toast-CACuYhK_.js";
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
//#region src/composables/dialogs/use-run-or-toast..ts
|
|
4
|
+
const { toast } = useToast();
|
|
5
|
+
/**
|
|
6
|
+
* Generate `run` method and a computed property `isRunning`.
|
|
7
|
+
* Calling `run` will reactively update `isRunning`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const { run, isRunning } = useRunOrToast();
|
|
12
|
+
*
|
|
13
|
+
* // Logs: false
|
|
14
|
+
* console.log(isRunning.value);
|
|
15
|
+
*
|
|
16
|
+
* const promise = run(() => someFunction(param1, param2));
|
|
17
|
+
*
|
|
18
|
+
* // Logs: true
|
|
19
|
+
* console.log(isRunning.value);
|
|
20
|
+
*
|
|
21
|
+
* await promise;
|
|
22
|
+
* // Logs: false
|
|
23
|
+
* console.log(isRunning.value);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function useRunOrToast() {
|
|
27
|
+
const running = ref(false);
|
|
28
|
+
const isRunning = computed(() => running.value);
|
|
29
|
+
/**
|
|
30
|
+
* Receives a function and its parameters, runs it, and if it throws an error, shows a toast with the error message.
|
|
31
|
+
* @returns the function returned value or `false` on error
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const { run, isRunning } = useRunOrToast();
|
|
36
|
+
*
|
|
37
|
+
* // Call like this:
|
|
38
|
+
* const someFunctionResult1 = await run(() => someFunction(param1, param2));
|
|
39
|
+
*
|
|
40
|
+
* // Or this:
|
|
41
|
+
* const someFunctionResult2 = await run(someFunction, param1, param2);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
async function run(toRun, ...params) {
|
|
45
|
+
try {
|
|
46
|
+
running.value = true;
|
|
47
|
+
return await toRun(...params);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (error instanceof Error) toast({
|
|
50
|
+
message: error.message,
|
|
51
|
+
color: "danger"
|
|
52
|
+
});
|
|
53
|
+
else console.error(error);
|
|
54
|
+
return false;
|
|
55
|
+
} finally {
|
|
56
|
+
running.value = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
run,
|
|
61
|
+
isRunning
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { useRunOrToast, useToast };
|
|
@@ -0,0 +1,53 @@
|
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexdom/uimed-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta.1",
|
|
4
4
|
"description": "A ui framework for NEXDOM applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lib",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": "./dist/index.js",
|
|
29
29
|
"./components": "./dist/components.js",
|
|
30
|
+
"./composables": "./dist/composables.js",
|
|
30
31
|
"./plugins": "./dist/plugins.js",
|
|
31
32
|
"./unit-test": "./dist/unit-test.js",
|
|
32
33
|
"./package.json": "./package.json"
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
68
69
|
"dependency-cruiser": "^18.1.1",
|
|
69
70
|
"jsdom": "^30.0.1",
|
|
70
|
-
"oxc-minify": "^0.
|
|
71
|
+
"oxc-minify": "^0.147.0",
|
|
71
72
|
"postcss": "^8.5.25",
|
|
72
73
|
"resize-observer-polyfill": "^1.5.1",
|
|
73
74
|
"sass-embedded": "^1.103.1",
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
"vitepress-plugin-group-icons": "^1.7.6",
|
|
80
81
|
"vue": "^3.5.40",
|
|
81
82
|
"vue-tsc": "^3.3.9",
|
|
82
|
-
"vuetify": "^4.
|
|
83
|
+
"vuetify": "^4.2.0"
|
|
83
84
|
},
|
|
84
85
|
"peerDependencies": {
|
|
85
86
|
"@fontsource/roboto": "^5.3.0",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"vite-plugin-vuetify": "^2.1.3",
|
|
90
91
|
"vite-plus": "^0.2.7",
|
|
91
92
|
"vue": "^3.5.40",
|
|
92
|
-
"vuetify": "^4.
|
|
93
|
+
"vuetify": "^4.2.0"
|
|
93
94
|
},
|
|
94
95
|
"commitlint": {
|
|
95
96
|
"extends": [
|