@groupteknology/vuno 0.6.0 → 0.6.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.
Files changed (56) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +45 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +6 -0
  5. package/dist/runtime/app/assets/css/main.css +1 -1
  6. package/dist/runtime/app/components/App/App.d.vue.ts +33 -0
  7. package/dist/runtime/app/components/App/App.vue +127 -0
  8. package/dist/runtime/app/components/App/App.vue.d.ts +33 -0
  9. package/dist/runtime/app/components/App/AppContext.d.vue.ts +3 -0
  10. package/dist/runtime/app/components/App/AppContext.vue +7 -0
  11. package/dist/runtime/app/components/App/AppContext.vue.d.ts +3 -0
  12. package/dist/runtime/app/components/App/AppModal.d.vue.ts +38 -0
  13. package/dist/runtime/app/components/App/AppModal.vue +103 -0
  14. package/dist/runtime/app/components/App/AppModal.vue.d.ts +38 -0
  15. package/dist/runtime/app/components/App/AppOverlay.d.vue.ts +7 -0
  16. package/dist/runtime/app/components/App/AppOverlay.vue +33 -0
  17. package/dist/runtime/app/components/App/AppOverlay.vue.d.ts +7 -0
  18. package/dist/runtime/app/components/App/AppToast.d.vue.ts +11 -0
  19. package/dist/runtime/app/components/App/AppToast.vue +53 -0
  20. package/dist/runtime/app/components/App/AppToast.vue.d.ts +11 -0
  21. package/dist/runtime/app/components/App/AppToaster.d.vue.ts +11 -0
  22. package/dist/runtime/app/components/App/AppToaster.vue +49 -0
  23. package/dist/runtime/app/components/App/AppToaster.vue.d.ts +11 -0
  24. package/dist/runtime/app/components/Confirm/Confirm.vue +20 -13
  25. package/dist/runtime/app/components/Field/FieldArray.vue +68 -68
  26. package/dist/runtime/app/components/Field/FieldColor.vue +36 -36
  27. package/dist/runtime/app/components/Form/Form.vue +61 -49
  28. package/dist/runtime/app/components/Form/FormModal.vue +23 -15
  29. package/dist/runtime/app/components/Form/FormSection.vue +27 -27
  30. package/dist/runtime/app/components/Page/Page.vue +46 -46
  31. package/dist/runtime/app/components/State/EmptyState.vue +20 -20
  32. package/dist/runtime/app/components/State/FailureState.vue +21 -21
  33. package/dist/runtime/app/components/Table/Table.vue +18 -114
  34. package/dist/runtime/app/composables/useVunoConfirm.d.ts +15 -0
  35. package/dist/runtime/app/composables/useVunoConfirm.js +5 -0
  36. package/dist/runtime/app/composables/useVunoContext.d.ts +13 -0
  37. package/dist/runtime/app/composables/useVunoContext.js +9 -0
  38. package/dist/runtime/app/composables/useVunoModal.d.ts +21 -0
  39. package/dist/runtime/app/composables/useVunoModal.js +26 -0
  40. package/dist/runtime/app/composables/useVunoOverlay.d.ts +22 -0
  41. package/dist/runtime/app/composables/useVunoOverlay.js +10 -0
  42. package/dist/runtime/app/composables/useVunoTableQuery.js +3 -3
  43. package/dist/runtime/app/composables/useVunoTheme.js +2 -1
  44. package/dist/runtime/app/composables/useVunoToast.d.ts +28 -0
  45. package/dist/runtime/app/composables/useVunoToast.js +13 -0
  46. package/dist/runtime/app/internal/useVunoTable.d.ts +65 -0
  47. package/dist/runtime/app/internal/useVunoTable.js +161 -0
  48. package/dist/runtime/app/theme/index.js +64 -11
  49. package/dist/runtime/app/types/app.d.ts +83 -0
  50. package/dist/runtime/app/types/app.js +0 -0
  51. package/dist/runtime/app/types/confirm.d.ts +8 -0
  52. package/dist/runtime/app/types/index.d.ts +1 -0
  53. package/dist/runtime/app/types/theme.d.ts +6 -0
  54. package/dist/runtime/app/utils/pagination.d.ts +12 -0
  55. package/dist/runtime/app/utils/pagination.js +6 -0
  56. package/package.json +6 -3
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Diego Otayza
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Diego Otayza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -68,6 +68,14 @@ const definition = {
68
68
 
69
69
  Cada uno declara sus propios props mediante una unión discriminada por `type`, así que el editor te avisa si a un `slug` le falta el `source` o si le pasas un `placeholder` a un `file`.
70
70
 
71
+ ### Campos obligatorios
72
+
73
+ `required: true` hace tres cosas: pinta el asterisco en la etiqueta, pone el atributo `required` en el input —que es lo que anuncia el campo como obligatorio a un lector de pantalla y lo que permite estilar `:invalid`— y nada más. **Quien decide si el valor vale es el esquema.**
74
+
75
+ El `<form>` lleva `novalidate`, así que el navegador no valida por su cuenta. Sin eso convivirían dos validaciones y ganaría la del navegador: cortaría el envío antes de que el esquema llegase a ejecutarse, y el usuario vería un globo del navegador, en su idioma y fuera del tema, en lugar del mensaje que tú escribiste.
76
+
77
+ Conviene saberlo si vienes de Nuxt UI a secas: `UFormField` con `required` solo pinta el asterisco y no toca el input. Los campos de vuno sí lo propagan, a propósito y por accesibilidad, y por eso el `novalidate` es necesario y no una preferencia.
78
+
71
79
  ### Campos repetibles
72
80
 
73
81
  `type: 'array'` repite un grupo de campos y genera rutas anidadas (`variants.0.sku`) que coinciden con las que produce la validación, de modo que cada campo muestra su propio error. Admite anidamiento.
@@ -404,6 +412,10 @@ const failure = computed(() => isError.value
404
412
  : undefined)
405
413
  ```
406
414
 
415
+ Con `useVunoCrud` no hace falta escribirlo: el objeto lo construye él, y el título y la pista se declaran en `messages` con `listFailed` y `listFailedHint`.
416
+
417
+ Si vienes de componerlo a mano, cuenta con un efecto lateral: si tu proyecto tiene un test que sujeta esta invariante buscando el objeto en la pantalla, se pondrá **rojo** al mudar los textos, porque ahí ya no hay ningún `retry:` que encontrar. No es una regresión —la garantía sigue, solo que ahora la sostiene el tipo `VunoTableFailure`, cuyo `retry` es obligatorio y comprueba el typecheck— pero el test tiene que mirar otra cosa.
418
+
407
419
  El reintento va **dentro** del objeto para que no se pueda pintar un error sin ofrecer salida. Mientras hay fallo, la tabla no muestra filas ni paginación. El estado vacío se declara en la definición (`empty: { title, hint, icon }`) y tiene un slot `empty-actions` donde encaja el «crear el primero».
408
420
 
409
421
  Los dos estados existen además como componentes sueltos, para las pantallas que no son una tabla:
@@ -431,6 +443,39 @@ Tipos de columna: `text` · `number` · `currency` · `date` · `boolean` · `ba
431
443
 
432
444
  No se cierra solo cuando recibe `loading`: así se espera a que la acción termine contra la API y se cierra desde fuera.
433
445
 
446
+ ## Modales del proyecto
447
+
448
+ Un modal por componente, en `components/modal/`, abierto por su clave:
449
+
450
+ ```
451
+ app/components/modal/ModalProduct.vue -> open('product')
452
+ app/components/modal/ModalInvoice.vue -> open('invoice')
453
+ ```
454
+
455
+ ```ts
456
+ const modal = useVunoModal()
457
+
458
+ const guardado = await modal.open<boolean>('product', { sku: row.sku })
459
+ ```
460
+
461
+ No hay que registrarlo ni colocarlo en ninguna plantilla: el módulo marca esa carpeta como global, así que la clave **es** el nombre del componente y un modal que existe se puede abrir.
462
+
463
+ El componente recibe `open` y los props que le pases, y resuelve la promesa emitiendo `close` con su resultado:
464
+
465
+ ```vue
466
+ <script setup lang="ts">
467
+ const emit = defineEmits<{ close: [guardado: boolean] }>()
468
+ const open = defineModel<boolean>('open', { default: false })
469
+
470
+ function guardar() {
471
+ open.value = false
472
+ emit('close', true)
473
+ }
474
+ </script>
475
+ ```
476
+
477
+ Se pinta en `<VApp>` y no en la pantalla que lo abrió, así que navegar no lo desmonta a medias ni deja la promesa colgada. Cerrarlo con Escape o pulsando fuera resuelve sin valor.
478
+
434
479
  ## Composables
435
480
 
436
481
  | Composable | Para qué |
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuno",
3
3
  "configKey": "vuno",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -20,6 +20,12 @@ const module$1 = defineNuxtModule({
20
20
  pathPrefix: false,
21
21
  prefix: options.prefix
22
22
  });
23
+ nuxt.hook("components:extend", (components) => {
24
+ for (const component of components) {
25
+ const path = component.filePath.split("\\").join("/");
26
+ if (path.includes("/components/modal/")) component.global = true;
27
+ }
28
+ });
23
29
  addImportsDir(resolver.resolve("./runtime/app/composables"));
24
30
  nuxt.options.css.push(resolver.resolve("./runtime/app/assets/css/main.css"));
25
31
  }
@@ -1 +1 @@
1
- @import "tailwindcss";@import "@nuxt/ui";@source "../../**/*";
1
+ @import "tailwindcss";@import "@nuxt/ui";@source "../../**/*";:root{--vuno-modal-duration:180ms;--vuno-modal-ease:cubic-bezier(0.32,0.72,0,1);--vuno-backdrop:rgba(0,0,0,.5)}dialog{opacity:0;transform:scale(.97) translateY(.5rem);transition:opacity var(--vuno-modal-duration) var(--vuno-modal-ease),transform var(--vuno-modal-duration) var(--vuno-modal-ease),display var(--vuno-modal-duration) allow-discrete,overlay var(--vuno-modal-duration) allow-discrete}dialog[open]{opacity:1;transform:scale(1) translateY(0)}@starting-style{dialog[open]{opacity:0;transform:scale(.97) translateY(.5rem)}}dialog::backdrop{background-color:transparent;transition:background-color var(--vuno-modal-duration) var(--vuno-modal-ease),display var(--vuno-modal-duration) allow-discrete,overlay var(--vuno-modal-duration) allow-discrete}dialog[open]::backdrop{background-color:var(--vuno-backdrop)}@starting-style{dialog[open]::backdrop{background-color:transparent}}dialog.vuno-overlay-behind::backdrop,dialog.vuno-overlay-behind[open]::backdrop{background-color:transparent}@media (prefers-reduced-motion:reduce){dialog,dialog::backdrop{transition-duration:1ms}dialog{transform:none}}
@@ -0,0 +1,33 @@
1
+ import { type Component } from 'vue';
2
+ import type { VunoAlertRequest, VunoConfirmRequest, VunoNotifyRequest } from '#vuno/types/app';
3
+ /**
4
+ * Monta un componente y espera a que emita `close`.
5
+ *
6
+ * Cerrar con Escape o pulsando fuera cuenta como cerrar sin resultado: un
7
+ * `update:open` en falso resuelve igual, porque si no la promesa se quedaría
8
+ * esperando para siempre a un diálogo que ya no está en pantalla.
9
+ */
10
+ declare function open<TResult = unknown>(component: Component, props?: Record<string, unknown>): Promise<TResult | undefined>;
11
+ declare function closeAll(): void;
12
+ declare function dismiss(id: number): void;
13
+ declare function notify(request: VunoNotifyRequest): number;
14
+ declare var __VLS_1: {};
15
+ type __VLS_Slots = {} & {
16
+ default?: (props: typeof __VLS_1) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<{}, {
19
+ alert: (request: VunoAlertRequest) => Promise<void>;
20
+ closeAll: typeof closeAll;
21
+ confirm: (request: VunoConfirmRequest) => Promise<boolean>;
22
+ dismiss: typeof dismiss;
23
+ notify: typeof notify;
24
+ open: typeof open;
25
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };
@@ -0,0 +1,127 @@
1
+ <script setup>
2
+ import { onBeforeUnmount, provide, reactive, shallowReactive } from "vue";
3
+ import Confirm from "#vuno/components/Confirm/Confirm.vue";
4
+ import { vunoContextInjectionKey } from "#vuno/composables/useVunoContext";
5
+ import AppOverlay from "./AppOverlay.vue";
6
+ import AppToaster from "./AppToaster.vue";
7
+ const overlays = reactive([]);
8
+ const notifications = shallowReactive([]);
9
+ let nextId = 0;
10
+ const EXIT_MS = 220;
11
+ function removeOverlay(id) {
12
+ const index = overlays.findIndex((entry) => entry.id === id);
13
+ if (index !== -1) overlays.splice(index, 1);
14
+ }
15
+ function dismissOverlay(id) {
16
+ const entry = overlays.find((item) => item.id === id);
17
+ if (entry) entry.open = false;
18
+ setTimeout(() => removeOverlay(id), EXIT_MS);
19
+ }
20
+ function open(component, props = {}) {
21
+ return new Promise((resolve) => {
22
+ const id = nextId++;
23
+ let settled = false;
24
+ const settle = (value) => {
25
+ if (settled) return;
26
+ settled = true;
27
+ resolve(value);
28
+ dismissOverlay(id);
29
+ };
30
+ overlays.push({
31
+ id,
32
+ component,
33
+ listeners: {
34
+ close: (value) => settle(value),
35
+ /**
36
+ * Se aplaza una microtarea porque lo normal dentro del modal
37
+ * es cerrar y luego emitir el resultado:
38
+ *
39
+ * ```ts
40
+ * open.value = false
41
+ * emit('close', true)
42
+ * ```
43
+ *
44
+ * Resolver aquí en el acto se quedaría con el primero de los
45
+ * dos y devolvería `undefined` habiendo un resultado. Con el
46
+ * aplazamiento, un `close` síncrono llega antes y gana; si no
47
+ * llega ninguno —Escape, pulsar fuera—, resuelve sin valor.
48
+ */
49
+ "update:open": (value) => {
50
+ if (!value) queueMicrotask(() => settle(void 0));
51
+ }
52
+ },
53
+ open: true,
54
+ props: { ...props }
55
+ });
56
+ });
57
+ }
58
+ function askConfirm(request, dismissed) {
59
+ return new Promise((resolve) => {
60
+ const id = nextId++;
61
+ let settled = false;
62
+ const settle = (value) => {
63
+ if (settled) return;
64
+ settled = true;
65
+ resolve(value);
66
+ dismissOverlay(id);
67
+ };
68
+ overlays.push({
69
+ id,
70
+ component: Confirm,
71
+ listeners: {
72
+ cancel: () => settle(false),
73
+ confirm: () => settle(true),
74
+ // Escape o pulsar fuera: en una confirmación es que no, y en
75
+ // una alerta es que ya se enteró.
76
+ "update:open": (value) => {
77
+ if (!value) settle(dismissed);
78
+ }
79
+ },
80
+ open: true,
81
+ props: { ...request }
82
+ });
83
+ });
84
+ }
85
+ const confirm = (request) => askConfirm(request, false);
86
+ const alert = async (request) => {
87
+ await askConfirm({ ...request, alert: true }, true);
88
+ };
89
+ function closeAll() {
90
+ for (const entry of [...overlays]) (entry.listeners.cancel ?? entry.listeners.close)?.();
91
+ }
92
+ const timers = /* @__PURE__ */ new Map();
93
+ function dismiss(id) {
94
+ const timer = timers.get(id);
95
+ if (timer) {
96
+ clearTimeout(timer);
97
+ timers.delete(id);
98
+ }
99
+ const index = notifications.findIndex((entry) => entry.id === id);
100
+ if (index !== -1) notifications.splice(index, 1);
101
+ }
102
+ function notify(request) {
103
+ const id = nextId++;
104
+ const duration = request.duration ?? 5e3;
105
+ notifications.push({ ...request, id, color: request.color ?? "neutral", duration });
106
+ if (duration > 0) timers.set(id, setTimeout(() => dismiss(id), duration));
107
+ return id;
108
+ }
109
+ onBeforeUnmount(() => {
110
+ for (const timer of timers.values()) clearTimeout(timer);
111
+ timers.clear();
112
+ });
113
+ const context = { alert, closeAll, confirm, dismiss, notifications, notify, open, overlays };
114
+ provide(vunoContextInjectionKey, context);
115
+ defineExpose({ alert, closeAll, confirm, dismiss, notify, open });
116
+ </script>
117
+
118
+ <template>
119
+ <slot />
120
+
121
+ <AppOverlay :overlays="overlays" />
122
+
123
+ <AppToaster
124
+ :notifications="notifications"
125
+ @dismiss="dismiss"
126
+ />
127
+ </template>
@@ -0,0 +1,33 @@
1
+ import { type Component } from 'vue';
2
+ import type { VunoAlertRequest, VunoConfirmRequest, VunoNotifyRequest } from '#vuno/types/app';
3
+ /**
4
+ * Monta un componente y espera a que emita `close`.
5
+ *
6
+ * Cerrar con Escape o pulsando fuera cuenta como cerrar sin resultado: un
7
+ * `update:open` en falso resuelve igual, porque si no la promesa se quedaría
8
+ * esperando para siempre a un diálogo que ya no está en pantalla.
9
+ */
10
+ declare function open<TResult = unknown>(component: Component, props?: Record<string, unknown>): Promise<TResult | undefined>;
11
+ declare function closeAll(): void;
12
+ declare function dismiss(id: number): void;
13
+ declare function notify(request: VunoNotifyRequest): number;
14
+ declare var __VLS_1: {};
15
+ type __VLS_Slots = {} & {
16
+ default?: (props: typeof __VLS_1) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<{}, {
19
+ alert: (request: VunoAlertRequest) => Promise<void>;
20
+ closeAll: typeof closeAll;
21
+ confirm: (request: VunoConfirmRequest) => Promise<boolean>;
22
+ dismiss: typeof dismiss;
23
+ notify: typeof notify;
24
+ open: typeof open;
25
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,7 @@
1
+ <script setup lang="ts"></script>
2
+
3
+ <template>
4
+ <div>
5
+ <!-- -->
6
+ </div>
7
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import type { VunoFieldSlots } from '#vuno/types/field';
2
+ type __VLS_Props = {
3
+ description?: string;
4
+ /** Cerrar con Escape o pulsando el fondo. */
5
+ dismissible?: boolean;
6
+ title?: string;
7
+ ui?: VunoFieldSlots;
8
+ };
9
+ type __VLS_Slots = {
10
+ body?: () => unknown;
11
+ default?: () => unknown;
12
+ footer?: () => unknown;
13
+ header?: () => unknown;
14
+ };
15
+ type __VLS_ModelProps = {
16
+ 'open'?: boolean;
17
+ };
18
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
19
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
+ close: () => any;
21
+ "update:open": (value: boolean) => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
23
+ onClose?: (() => any) | undefined;
24
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
25
+ }>, {
26
+ description: string;
27
+ title: string;
28
+ ui: VunoFieldSlots;
29
+ dismissible: boolean;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,103 @@
1
+ <script setup>
2
+ import { onBeforeUnmount, useTemplateRef, watch } from "vue";
3
+ import { useVunoTheme } from "#vuno/composables/useVunoTheme";
4
+ const props = defineProps({
5
+ description: { type: String, required: false, default: void 0 },
6
+ dismissible: { type: Boolean, required: false, default: true },
7
+ title: { type: String, required: false, default: void 0 },
8
+ ui: { type: Object, required: false, default: void 0 }
9
+ });
10
+ const emit = defineEmits(["close"]);
11
+ const open = defineModel("open", { type: Boolean, ...{ default: false } });
12
+ defineSlots();
13
+ const ui = useVunoTheme("appModal", () => props.ui);
14
+ const dialog = useTemplateRef("dialog");
15
+ function lockScroll(locked) {
16
+ if (typeof document === "undefined") return;
17
+ document.body.style.overflow = locked ? "hidden" : "";
18
+ }
19
+ watch(
20
+ [open, dialog],
21
+ ([value, element]) => {
22
+ if (!element) return;
23
+ if (value && !element.open) {
24
+ element.showModal();
25
+ lockScroll(true);
26
+ return;
27
+ }
28
+ if (!value && element.open) {
29
+ element.close();
30
+ lockScroll(false);
31
+ }
32
+ },
33
+ { immediate: true }
34
+ );
35
+ onBeforeUnmount(() => lockScroll(false));
36
+ function requestClose() {
37
+ open.value = false;
38
+ lockScroll(false);
39
+ emit("close");
40
+ }
41
+ function onCancel(event) {
42
+ event.preventDefault();
43
+ if (props.dismissible) requestClose();
44
+ }
45
+ function onClick(event) {
46
+ if (!props.dismissible) return;
47
+ const element = dialog.value;
48
+ if (!element || event.target !== element) return;
49
+ const box = element.getBoundingClientRect();
50
+ const inside = event.clientX >= box.left && event.clientX <= box.right && event.clientY >= box.top && event.clientY <= box.bottom;
51
+ if (!inside) requestClose();
52
+ }
53
+ </script>
54
+
55
+ <template>
56
+ <dialog
57
+ ref="dialog"
58
+ :aria-describedby="props.description ? 'vuno-modal-description' : void 0"
59
+ :aria-labelledby="props.title ? 'vuno-modal-title' : void 0"
60
+ :class="ui.root"
61
+ @cancel="onCancel"
62
+ @click="onClick"
63
+ @close="open = false"
64
+ >
65
+ <div :class="ui.content">
66
+ <slot name="header">
67
+ <div
68
+ v-if="props.title || props.description"
69
+ :class="ui.header"
70
+ >
71
+ <h2
72
+ v-if="props.title"
73
+ id="vuno-modal-title"
74
+ :class="ui.title"
75
+ >
76
+ {{ props.title }}
77
+ </h2>
78
+
79
+ <p
80
+ v-if="props.description"
81
+ id="vuno-modal-description"
82
+ :class="ui.description"
83
+ >
84
+ {{ props.description }}
85
+ </p>
86
+ </div>
87
+ </slot>
88
+
89
+ <div :class="ui.body">
90
+ <slot name="body">
91
+ <slot />
92
+ </slot>
93
+ </div>
94
+
95
+ <div
96
+ v-if="$slots.footer"
97
+ :class="ui.footer"
98
+ >
99
+ <slot name="footer" />
100
+ </div>
101
+ </div>
102
+ </dialog>
103
+ </template>
@@ -0,0 +1,38 @@
1
+ import type { VunoFieldSlots } from '#vuno/types/field';
2
+ type __VLS_Props = {
3
+ description?: string;
4
+ /** Cerrar con Escape o pulsando el fondo. */
5
+ dismissible?: boolean;
6
+ title?: string;
7
+ ui?: VunoFieldSlots;
8
+ };
9
+ type __VLS_Slots = {
10
+ body?: () => unknown;
11
+ default?: () => unknown;
12
+ footer?: () => unknown;
13
+ header?: () => unknown;
14
+ };
15
+ type __VLS_ModelProps = {
16
+ 'open'?: boolean;
17
+ };
18
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
19
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
+ close: () => any;
21
+ "update:open": (value: boolean) => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
23
+ onClose?: (() => any) | undefined;
24
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
25
+ }>, {
26
+ description: string;
27
+ title: string;
28
+ ui: VunoFieldSlots;
29
+ dismissible: boolean;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,7 @@
1
+ import type { VunoOverlayEntry } from '#vuno/types/app';
2
+ type __VLS_Props = {
3
+ overlays: VunoOverlayEntry[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,33 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ overlays: { type: Array, required: true }
4
+ });
5
+ const isTopmost = (index) => index === props.overlays.length - 1;
6
+ </script>
7
+
8
+ <template>
9
+ <!--
10
+ Los overlays globales se pintan aquí y no donde se pidieron. Un diálogo
11
+ montado dentro de la pantalla que lo abre desaparece con ella —al navegar,
12
+ al cerrarse un modal que lo contenía— y su promesa se queda sin resolver.
13
+
14
+ No hay escalera de z-index, y no por olvido: se escribió una y resultó
15
+ inútil. Los diálogos de vuno son `<dialog>` nativos, que viven en la capa
16
+ superior del navegador y se apilan por orden de apertura, por encima de
17
+ cualquier z-index. Mientras todo sea nativo, el apilado ya es correcto;
18
+ en cuanto se mezcla con algo que no lo sea, ningún z-index lo arregla,
19
+ porque la capa superior siempre gana.
20
+
21
+ Tampoco lleva contenedor propio: cada diálogo se sale del flujo por su
22
+ cuenta, así que un elemento aquí solo añadiría un nodo vacío.
23
+ -->
24
+ <component
25
+ :is="entry.component"
26
+ v-for="(entry, index) in props.overlays"
27
+ :key="entry.id"
28
+ v-bind="entry.props"
29
+ :class="isTopmost(index) ? void 0 : 'vuno-overlay-behind'"
30
+ :open="entry.open"
31
+ v-on="entry.listeners"
32
+ />
33
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { VunoOverlayEntry } from '#vuno/types/app';
2
+ type __VLS_Props = {
3
+ overlays: VunoOverlayEntry[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { VunoNotification } from '#vuno/types/app';
2
+ type __VLS_Props = {
3
+ notification: VunoNotification;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ dismiss: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onDismiss?: (() => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,53 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useVunoIcons, useVunoMessages, useVunoTheme } from "#vuno/composables/useVunoTheme";
4
+ const props = defineProps({
5
+ notification: { type: Object, required: true }
6
+ });
7
+ const emit = defineEmits(["dismiss"]);
8
+ const icons = useVunoIcons();
9
+ const messages = useVunoMessages();
10
+ const ui = useVunoTheme("appToast");
11
+ const defaultIcons = {
12
+ error: icons.value.notifyError,
13
+ info: icons.value.notifyInfo,
14
+ neutral: icons.value.notifyInfo,
15
+ success: icons.value.notifySuccess,
16
+ warning: icons.value.notifyWarning
17
+ };
18
+ const icon = computed(() => props.notification.icon ?? defaultIcons[props.notification.color]);
19
+ const live = computed(() => props.notification.color === "error" ? "assertive" : "polite");
20
+ </script>
21
+
22
+ <template>
23
+ <div
24
+ :aria-live="live"
25
+ :class="ui.root"
26
+ role="status"
27
+ >
28
+ <UIcon
29
+ :class="[ui.icon, `text-${props.notification.color}`]"
30
+ :name="icon"
31
+ />
32
+
33
+ <div :class="ui.body">
34
+ <p :class="ui.title">{{ props.notification.title }}</p>
35
+
36
+ <p
37
+ v-if="props.notification.description"
38
+ :class="ui.description"
39
+ >
40
+ {{ props.notification.description }}
41
+ </p>
42
+ </div>
43
+
44
+ <UButton
45
+ :aria-label="messages.close"
46
+ color="neutral"
47
+ :icon="icons.close"
48
+ size="xs"
49
+ variant="ghost"
50
+ @click="emit('dismiss')"
51
+ />
52
+ </div>
53
+ </template>
@@ -0,0 +1,11 @@
1
+ import type { VunoNotification } from '#vuno/types/app';
2
+ type __VLS_Props = {
3
+ notification: VunoNotification;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ dismiss: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onDismiss?: (() => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;