@groupteknology/vuno 0.3.0 → 0.6.0

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 (41) hide show
  1. package/README.md +174 -2
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/app/components/Cell/CellBadge.d.vue.ts +5 -0
  4. package/dist/runtime/app/components/Cell/CellBadge.vue +24 -0
  5. package/dist/runtime/app/components/Cell/CellBadge.vue.d.ts +5 -0
  6. package/dist/runtime/app/components/Cell/CellBoolean.d.vue.ts +5 -0
  7. package/dist/runtime/app/components/Cell/CellBoolean.vue +21 -0
  8. package/dist/runtime/app/components/Cell/CellBoolean.vue.d.ts +5 -0
  9. package/dist/runtime/app/components/Cell/CellCurrency.d.vue.ts +5 -0
  10. package/dist/runtime/app/components/Cell/CellCurrency.vue +14 -0
  11. package/dist/runtime/app/components/Cell/CellCurrency.vue.d.ts +5 -0
  12. package/dist/runtime/app/components/Cell/CellDate.d.vue.ts +5 -0
  13. package/dist/runtime/app/components/Cell/CellDate.vue +19 -0
  14. package/dist/runtime/app/components/Cell/CellDate.vue.d.ts +5 -0
  15. package/dist/runtime/app/components/Cell/CellImage.d.vue.ts +5 -0
  16. package/dist/runtime/app/components/Cell/CellImage.vue +22 -0
  17. package/dist/runtime/app/components/Cell/CellImage.vue.d.ts +5 -0
  18. package/dist/runtime/app/components/Cell/CellNumber.d.vue.ts +5 -0
  19. package/dist/runtime/app/components/Cell/CellNumber.vue +15 -0
  20. package/dist/runtime/app/components/Cell/CellNumber.vue.d.ts +5 -0
  21. package/dist/runtime/app/components/Cell/CellText.d.vue.ts +5 -0
  22. package/dist/runtime/app/components/Cell/CellText.vue +13 -0
  23. package/dist/runtime/app/components/Cell/CellText.vue.d.ts +5 -0
  24. package/dist/runtime/app/components/Field/FieldSwitch.d.vue.ts +5 -0
  25. package/dist/runtime/app/components/Field/FieldSwitch.vue +27 -0
  26. package/dist/runtime/app/components/Field/FieldSwitch.vue.d.ts +5 -0
  27. package/dist/runtime/app/components/Form/FormField.vue +18 -16
  28. package/dist/runtime/app/components/Form/FormModal.d.vue.ts +6 -0
  29. package/dist/runtime/app/components/Form/FormModal.vue +47 -46
  30. package/dist/runtime/app/components/Form/FormModal.vue.d.ts +6 -0
  31. package/dist/runtime/app/components/Table/Table.vue +273 -264
  32. package/dist/runtime/app/components/Table/TableCell.vue +24 -73
  33. package/dist/runtime/app/composables/useVunoCrud.js +9 -1
  34. package/dist/runtime/app/theme/index.js +18 -1
  35. package/dist/runtime/app/types/crud.d.ts +17 -1
  36. package/dist/runtime/app/types/field.d.ts +8 -1
  37. package/dist/runtime/app/types/table.d.ts +80 -13
  38. package/dist/runtime/app/types/theme.d.ts +6 -0
  39. package/dist/runtime/app/utils/column.d.ts +9 -0
  40. package/dist/runtime/app/utils/column.js +5 -0
  41. package/package.json +1 -1
package/README.md CHANGED
@@ -62,7 +62,7 @@ const definition = {
62
62
 
63
63
  ### Tipos de campo
64
64
 
65
- `text` · `email` · `password` · `textarea` · `number` · `select` · `radio` · `checkbox` · `color` · `slug` · `file` · `array`
65
+ `text` · `email` · `password` · `textarea` · `number` · `select` · `radio` · `checkbox` · `switch` · `color` · `slug` · `file` · `array`
66
66
 
67
67
  `source` del campo `slug` es el **nombre** del campo del que deriva, no su valor.
68
68
 
@@ -89,18 +89,114 @@ Con `layout: 'tabs'`, cada pestaña muestra un contador de los campos con error
89
89
 
90
90
  ### En un modal
91
91
 
92
+ El slot `footer` recibe `formId`, necesario para enviar desde un botón propio: el pie vive fuera del `<form>`, así que la asociación se hace con el atributo nativo.
93
+
94
+ ```vue
95
+ <VFormModal v-model:open="open" v-model:state="state" :definition="definition" :title="title">
96
+ <template #footer="{ close, formId, loading }">
97
+ <UButton label="Cancelar" variant="ghost" @click="close" />
98
+ <UButton :form="formId" :label="editando ? 'Guardar cambios' : 'Crear'" :loading="loading" type="submit" />
99
+ </template>
100
+ </VFormModal>
101
+ ```
102
+
92
103
  `VFormModal` añade el diálogo, los botones y el ancho adecuado. Los botones van en el pie del modal —fijo mientras el cuerpo hace scroll— asociados al formulario por `id`.
93
104
 
94
105
  ```vue
95
106
  <VFormModal v-model:open="open" v-model:state="state" :definition="definition" :schema="schema" title="Nuevo producto" close-on-submit @submit="guardar" />
96
107
  ```
97
108
 
109
+ ### Un componente por formulario
110
+
111
+ Un formulario largo no vive en la página. Se declara en su propio componente, que contiene **la definición, el esquema y los textos**, y nada más.
112
+
113
+ Es la práctica recomendada y no es una cuestión de orden: el mismo formulario acaba abriéndose desde más de un sitio —la lista, la ficha, un atajo— y en el momento en que lleva dentro el guardado, ya no se puede reutilizar sin arrastrar consecuencias que no son suyas.
114
+
115
+ La regla que lo resume: **el componente decide cómo es el formulario; quien lo usa decide qué pasa al enviarlo.**
116
+
117
+ ```vue
118
+ <!-- app/components/Product/ProductForm.vue -->
119
+ <script setup lang="ts">
120
+ import type { VunoFormDefinition } from '@groupteknology/vuno'
121
+ import * as z from 'zod'
122
+
123
+ const props = defineProps<{
124
+ /** La fila en edición. Sin ella, el formulario es de alta. */
125
+ product?: null | Product
126
+ loading?: boolean
127
+ }>()
128
+
129
+ const emit = defineEmits<{ submit: [] }>()
130
+
131
+ const open = defineModel<boolean>('open', { default: false })
132
+ const state = defineModel<ProductFormState>('state', { required: true })
133
+
134
+ // Lo propio del formulario: su forma, sus reglas y sus textos.
135
+ const schema = z.object({ sku: z.string().min(1, 'El SKU es requerido') })
136
+
137
+ const title = computed(() => (props.product ? `Editar ${props.product.sku}` : 'Nuevo producto'))
138
+
139
+ const definition = {
140
+ layout: 'tabs',
141
+ sections: [/* ... */],
142
+ } satisfies VunoFormDefinition
143
+ </script>
144
+
145
+ <template>
146
+ <VFormModal
147
+ v-model:open="open"
148
+ v-model:state="state"
149
+ :definition="definition"
150
+ :loading="props.loading"
151
+ :schema="schema"
152
+ :title="title"
153
+ @submit="emit('submit')"
154
+ />
155
+ </template>
156
+ ```
157
+
158
+ Y la página queda sin saber nada de los campos:
159
+
160
+ ```vue
161
+ <ProductForm
162
+ v-model:open="formOpen"
163
+ v-model:state="state"
164
+ :loading="isSaving"
165
+ :product="editing"
166
+ @submit="submit"
167
+ />
168
+ ```
169
+
170
+ #### Qué expone
171
+
172
+ | | |
173
+ |---|---|
174
+ | `v-model:state` | El estado del formulario. Obligatorio: lo posee quien lo usa, no el formulario. |
175
+ | `v-model:open` | Solo si es modal. |
176
+ | `:loading` | Si se está guardando, para bloquear el botón. |
177
+ | La fila en edición | Un prop —`product`, `brand`, lo que sea— que vale `null` en el alta. De él salen el título y la etiqueta del botón. |
178
+ | `@submit` | Significa «el usuario confirmó», nada más. Sin datos: ya están en `state`. |
179
+
180
+ No es casualidad que encaje: son exactamente `state`, `formOpen`, `isSaving`, `editing` y `submit` de `useVunoCrud`.
181
+
182
+ #### Qué se queda fuera
183
+
184
+ La petición, la mutación, invalidar la caché, los avisos y cerrar el modal al terminar. Todo eso es consecuencia del envío, y la consecuencia cambia según desde dónde se abra el formulario.
185
+
186
+ Si el componente hace el `$fetch` dentro, el síntoma llega pronto: en cuanto haga falta abrirlo desde otra pantalla con otro destino, hay que copiarlo o llenarlo de condicionales.
187
+
188
+ El estado tampoco se queda dentro. Si el formulario declara su propio `ref` en vez de recibir `v-model:state`, quien lo usa no ve lo que el usuario escribió y el guardado envía el estado inicial: falla en silencio y lejos de la causa.
189
+
98
190
  ## Una pantalla de mantenimiento entera
99
191
 
100
192
  `useVunoCrud` resuelve el ciclo completo: listar, dar de alta o editar en un modal, borrar con confirmación, invalidar la caché y avisar. Está construido sobre [TanStack Query](https://tanstack.com/query).
101
193
 
102
194
  ```vue
103
195
  <script setup lang="ts">
196
+ // En SSR, `$fetch` no reenvía la cookie de la petición y una ruta con sesión
197
+ // responde 401 durante el render. `useRequestFetch()` sí la lleva.
198
+ const request = useRequestFetch()
199
+
104
200
  const query = useVunoTableQuery({ sort: 'sku', url: true })
105
201
 
106
202
  const { items, total, failure, isPending, isSaving, isDeleting,
@@ -109,7 +205,7 @@ const { items, total, failure, isPending, isSaving, isDeleting,
109
205
  key: 'products',
110
206
  query,
111
207
  emptyForm: () => ({ name: '', sku: '' }),
112
- list: (q) => $fetch('/api/products', { query: q }),
208
+ list: (q) => request('/api/products', { query: q }),
113
209
  create: (form) => $fetch('/api/products', { body: form, method: 'POST' }),
114
210
  update: (id, form) => $fetch(`/api/products/${id}`, { body: form, method: 'PATCH' }),
115
211
  remove: (row) => $fetch(`/api/products/${row.id}`, { method: 'DELETE' }),
@@ -117,6 +213,8 @@ const { items, total, failure, isPending, isSaving, isDeleting,
117
213
  </script>
118
214
  ```
119
215
 
216
+ Solo `list` necesita `useRequestFetch()`: es la única que corre en servidor. El alta, la edición y el borrado salen siempre del navegador, donde `$fetch` lleva la cookie por su cuenta.
217
+
120
218
  La consulta forma parte de la clave de caché, así que cada página, filtro y orden se guarda por separado. Usa `placeholderData: keepPreviousData`, que mantiene en pantalla los datos anteriores mientras llega la nueva página: sin eso, cada cambio de filtro deja `data` en `undefined` un instante y la tabla parpadea enseñando su estado vacío. Los textos de los avisos salen de `vuno.messages` y se pueden afinar por pantalla con la opción `messages`.
121
219
 
122
220
  ### Claves que dependen de estado reactivo
@@ -180,6 +278,8 @@ export default defineNuxtPlugin((nuxtApp) => {
180
278
  })
181
279
  ```
182
280
 
281
+ **Si tu API tiene sesión, `list` tiene que usar `useRequestFetch()`.** Un `$fetch` pelado no reenvía la cookie de la petición entrante, así que durante el render en servidor la llamada sale sin autenticar y la ruta responde 401. Es el tropiezo más probable al estrenar esto, porque en cliente el mismo código funciona.
282
+
183
283
  Con la clave incompleta no se espera nada: la consulta está suspendida y esperarla colgaría el render entero, porque una consulta deshabilitada nunca se asienta.
184
284
 
185
285
  `server: false` desactiva la espera para lo que no se ve en la primera pintada —una lista dentro de un modal, una pestaña oculta—, donde solo retrasaría el HTML.
@@ -222,6 +322,78 @@ const { data, status } = await useFetch('/api/products', {
222
322
 
223
323
  Con `url: true` los filtros, la página, la búsqueda y el orden viajan en la query string: el enlace es compartible y recargar conserva la vista.
224
324
 
325
+ ### Tipos de columna
326
+
327
+ `text` · `number` · `currency` · `date` · `badge` · `boolean` · `image` · `actions` · `custom`
328
+
329
+ Cada uno declara sus propios props en una unión discriminada por `type`, igual que los campos. `key` es la ruta del valor en la fila y admite anidado: `key: 'proveedor.nombre'`.
330
+
331
+ ```ts
332
+ const definition = {
333
+ searchable: false, // el endpoint no busca: no se pinta la barra
334
+ paginated: false, // ni pagina: el pie dice cuántos hay y nada más
335
+ columns: [
336
+ { key: 'sku', label: 'SKU', type: 'text', sortable: true },
337
+ { key: 'price', label: 'Precio', type: 'currency', currency: 'EUR', align: 'end' },
338
+ { key: 'createdAt', label: 'Alta', type: 'date' },
339
+ ],
340
+ } satisfies VunoTableDefinition<Product>
341
+ ```
342
+
343
+ #### Traducir un valor a una etiqueta
344
+
345
+ La columna `badge` tiene `map`, que convierte el valor crudo que llega del servidor en la etiqueta y el color que ve el usuario. Es lo que evita enseñar `user` o `published` en pantalla:
346
+
347
+ ```ts
348
+ {
349
+ key: 'role',
350
+ label: 'Rol',
351
+ type: 'badge',
352
+ map: {
353
+ user: { color: 'neutral', label: 'Usuario' },
354
+ admin: { color: 'primary', label: 'Administrador' },
355
+ },
356
+ }
357
+ ```
358
+
359
+ Un valor sin entrada en el `map` se pinta tal cual, con el `color` de la columna o `neutral`. Es deliberado: si el servidor empieza a mandar un estado nuevo, verás el valor crudo en pantalla en lugar de una celda vacía que esconde que hay algo sin contemplar.
360
+
361
+ #### Calcular el valor desde la fila
362
+
363
+ Cuando lo que se muestra no está en una sola clave, o hay que derivarlo, toda columna acepta `value`:
364
+
365
+ ```ts
366
+ { key: 'role', label: 'Rol', type: 'text', value: (row) => traducirRol(row.role) }
367
+ { key: 'total', label: 'Total', type: 'currency', value: (row) => row.precio * row.unidades }
368
+ { key: 'autor', label: 'Autor', type: 'text', value: (row) => `${row.nombre} ${row.apellido}` }
369
+ ```
370
+
371
+ Recibe la fila entera y está tipada: con `VunoTableDefinition<Product>`, `row` es un `Product`.
372
+
373
+ **Sustituye de dónde sale el valor, no cómo se pinta.** Lo que devuelve sigue pasando por el formato de su tipo de columna, así que se combina con todo lo demás: en una columna `currency` se formatea como moneda, en una `date` como fecha, y en un `badge` pasa por su `map`.
374
+
375
+ ```ts
376
+ // Deriva el valor, y el `map` lo traduce después.
377
+ { key: 'estado', type: 'badge', value: (row) => (row.stock > 0 ? 'disponible' : 'agotado'), map: { agotado: { color: 'error', label: 'Agotado' }, disponible: { color: 'success', label: 'Disponible' } } }
378
+ ```
379
+
380
+ `key` sigue haciendo falta: nombra la columna para el orden y para el slot `cell-<key>`.
381
+
382
+ Y un aviso al ordenar: `sortable` ordena **en servidor por `key`**, y el servidor no conoce esta función. Si el valor mostrado no se deriva de `key` de forma monótona —un nombre completo compuesto de dos campos, por ejemplo— el orden no coincidirá con lo que se ve. Para eso, ordena por la clave que de verdad manda o deja la columna sin `sortable`.
383
+
384
+ `map` es solo de `badge`. Para traducir en otro tipo de columna, o para componer algo que no es una etiqueta, está `type: 'custom'` con su slot:
385
+
386
+ ```vue
387
+ <VTable :definition="definition" :data="rows">
388
+ <template #cell-stock="{ row, value }">
389
+ <span class="tabular-nums">{{ value }} uds.</span>
390
+ <UBadge v-if="row.stock === 0" color="error" label="Agotado" />
391
+ </template>
392
+ </VTable>
393
+ ```
394
+
395
+ El slot se llama `cell-<key>` y recibe `value` —el valor de esa columna, ya resuelto por su `key`— y `row` entera, directa y sin envolver.
396
+
225
397
  ### Una tabla vacía no es una que falló
226
398
 
227
399
  Son dos estados distintos y se pintan distinto. Sin separarlos, una consulta que falla se normaliza a lista vacía (`data ?? []`) y la tabla dice «No hay resultados»: afirma que no hay nada cuando lo cierto es que no se pudo saber.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuno",
3
3
  "configKey": "vuno",
4
- "version": "0.3.0",
4
+ "version": "0.6.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "unknown"
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'badge'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,24 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ const props = defineProps({
4
+ column: { type: Object, required: true },
5
+ row: { type: Object, required: true },
6
+ value: { type: null, required: true }
7
+ });
8
+ const text = computed(() => props.value === null || props.value === void 0 ? "" : String(props.value));
9
+ const badge = computed(() => {
10
+ const entry = props.column.map?.[text.value];
11
+ return {
12
+ color: entry?.color ?? props.column.color ?? "neutral",
13
+ label: entry?.label ?? text.value
14
+ };
15
+ });
16
+ </script>
17
+
18
+ <template>
19
+ <UBadge
20
+ :color="badge.color"
21
+ :label="badge.label"
22
+ variant="subtle"
23
+ />
24
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'badge'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'boolean'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,21 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useVunoIcons } from "#vuno/composables/useVunoTheme";
4
+ const props = defineProps({
5
+ column: { type: Object, required: true },
6
+ row: { type: Object, required: true },
7
+ value: { type: null, required: true }
8
+ });
9
+ const icons = useVunoIcons();
10
+ const labelled = computed(() => Boolean(props.column.trueLabel || props.column.falseLabel));
11
+ </script>
12
+
13
+ <template>
14
+ <span v-if="labelled">{{ props.value ? props.column.trueLabel ?? "" : props.column.falseLabel ?? "" }}</span>
15
+
16
+ <UIcon
17
+ v-else
18
+ :class="props.value ? 'text-success' : 'text-muted'"
19
+ :name="props.value ? icons.booleanTrue : icons.booleanFalse"
20
+ />
21
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'boolean'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'currency'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,14 @@
1
+ <script setup>
2
+ import { useLocale } from "@nuxt/ui/composables";
3
+ import { formatCurrency } from "#vuno/utils/format";
4
+ const props = defineProps({
5
+ column: { type: Object, required: true },
6
+ row: { type: Object, required: true },
7
+ value: { type: null, required: true }
8
+ });
9
+ const locale = useLocale();
10
+ </script>
11
+
12
+ <template>
13
+ <span class="tabular-nums">{{ formatCurrency(props.value, locale.code.value, props.column.currency, props.column.decimals) }}</span>
14
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'currency'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'date'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,19 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useLocale } from "@nuxt/ui/composables";
4
+ import { formatDate } from "#vuno/utils/format";
5
+ const props = defineProps({
6
+ column: { type: Object, required: true },
7
+ row: { type: Object, required: true },
8
+ value: { type: null, required: true }
9
+ });
10
+ const locale = useLocale();
11
+ const options = computed(() => ({
12
+ dateStyle: props.column.dateStyle ?? "medium",
13
+ ...props.column.timeStyle ? { timeStyle: props.column.timeStyle } : {}
14
+ }));
15
+ </script>
16
+
17
+ <template>
18
+ <span class="tabular-nums">{{ formatDate(props.value, locale.code.value, options) }}</span>
19
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'date'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'image'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,22 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { getPath } from "#vuno/utils/path";
4
+ const props = defineProps({
5
+ column: { type: Object, required: true },
6
+ row: { type: Object, required: true },
7
+ value: { type: null, required: true }
8
+ });
9
+ const src = computed(() => props.value === null || props.value === void 0 ? "" : String(props.value));
10
+ const alt = computed(() => {
11
+ if (props.column.altKey) return String(getPath(props.row, props.column.altKey) ?? "");
12
+ return props.column.alt ?? "";
13
+ });
14
+ </script>
15
+
16
+ <template>
17
+ <UAvatar
18
+ :alt="alt"
19
+ :size="props.column.size ?? 'md'"
20
+ :src="src"
21
+ />
22
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'image'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'number'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,15 @@
1
+ <script setup>
2
+ import { useLocale } from "@nuxt/ui/composables";
3
+ import { formatNumber } from "#vuno/utils/format";
4
+ const props = defineProps({
5
+ column: { type: Object, required: true },
6
+ row: { type: Object, required: true },
7
+ value: { type: null, required: true }
8
+ });
9
+ const locale = useLocale();
10
+ </script>
11
+
12
+ <template>
13
+ <!-- `tabular-nums` alinea las cifras en columna; sin ello los dígitos bailan. -->
14
+ <span class="tabular-nums">{{ formatNumber(props.value, locale.code.value, props.column.decimals) }}</span>
15
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'number'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'text'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,13 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ const props = defineProps({
4
+ column: { type: Object, required: true },
5
+ row: { type: Object, required: true },
6
+ value: { type: null, required: true }
7
+ });
8
+ const text = computed(() => props.value === null || props.value === void 0 ? "" : String(props.value));
9
+ </script>
10
+
11
+ <template>
12
+ <span :class="props.column.truncate ? 'block max-w-[32ch] truncate' : void 0">{{ text }}</span>
13
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoTableCellProps } from '#vuno/types/table';
2
+ type __VLS_Props = VunoTableCellProps<'text'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { VunoFieldSwitch } from '#vuno/types/field';
2
+ type __VLS_Props = Omit<VunoFieldSwitch, 'class' | 'columns'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,27 @@
1
+ <script setup>
2
+ import { useVunoField } from "#vuno/composables/useVunoField";
3
+ import { useVunoTheme } from "#vuno/composables/useVunoTheme";
4
+ const props = defineProps({
5
+ name: { type: String, required: true },
6
+ description: { type: String, required: false },
7
+ disabled: { type: Boolean, required: false },
8
+ help: { type: String, required: false },
9
+ hint: { type: String, required: false },
10
+ label: { type: String, required: false },
11
+ required: { type: Boolean, required: false },
12
+ size: { type: String, required: false },
13
+ ui: { type: Object, required: false }
14
+ });
15
+ const { value } = useVunoField(() => props.name);
16
+ const ui = useVunoTheme("fieldSwitch", () => props.ui);
17
+ </script>
18
+
19
+ <template>
20
+ <USwitch
21
+ v-model="value"
22
+ :disabled="props.disabled"
23
+ :name="props.name"
24
+ :size="props.size"
25
+ :ui="ui"
26
+ />
27
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { VunoFieldSwitch } from '#vuno/types/field';
2
+ type __VLS_Props = Omit<VunoFieldSwitch, 'class' | 'columns'>;
3
+ 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>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -12,6 +12,7 @@ import FieldPassword from "#vuno/components/Field/FieldPassword.vue";
12
12
  import FieldRadio from "#vuno/components/Field/FieldRadio.vue";
13
13
  import FieldSelect from "#vuno/components/Field/FieldSelect.vue";
14
14
  import FieldSlug from "#vuno/components/Field/FieldSlug.vue";
15
+ import FieldSwitch from "#vuno/components/Field/FieldSwitch.vue";
15
16
  import FieldText from "#vuno/components/Field/FieldText.vue";
16
17
  import FieldTextarea from "#vuno/components/Field/FieldTextarea.vue";
17
18
  const props = defineProps({
@@ -28,6 +29,7 @@ const components = {
28
29
  radio: FieldRadio,
29
30
  select: FieldSelect,
30
31
  slug: FieldSlug,
32
+ switch: FieldSwitch,
31
33
  text: FieldText,
32
34
  textarea: FieldTextarea
33
35
  };
@@ -42,20 +44,20 @@ const fieldProps = computed(() => {
42
44
  </script>
43
45
 
44
46
  <template>
45
- <UFormField
46
- :class="props.field.class"
47
- :description="props.field.description"
48
- :help="props.field.help"
49
- :hint="props.field.hint"
50
- :label="props.field.label"
51
- :name="props.field.name"
52
- :required="props.field.required"
53
- :size="size"
54
- :ui="ui"
55
- >
56
- <component
57
- :is="component"
58
- v-bind="fieldProps"
59
- />
60
- </UFormField>
47
+ <UFormField
48
+ :class="props.field.class"
49
+ :description="props.field.description"
50
+ :help="props.field.help"
51
+ :hint="props.field.hint"
52
+ :label="props.field.label"
53
+ :name="props.field.name"
54
+ :required="props.field.required"
55
+ :size="size"
56
+ :ui="ui"
57
+ >
58
+ <component
59
+ :is="component"
60
+ v-bind="fieldProps"
61
+ />
62
+ </UFormField>
61
63
  </template>
@@ -32,8 +32,14 @@ declare const __VLS_export: <TState extends VunoFormState>(__VLS_props: NonNulla
32
32
  expose: (exposed: {}) => void;
33
33
  attrs: any;
34
34
  slots: {
35
+ /**
36
+ * `formId` es imprescindible, no un extra: el pie del modal vive fuera
37
+ * del `<form>`, así que un botón propio solo puede enviarlo con
38
+ * `:form="formId"`. Sin exponerlo, cualquier pie a medida queda mudo.
39
+ */
35
40
  footer?: (props: {
36
41
  dirty: boolean;
42
+ formId: string;
37
43
  loading: boolean;
38
44
  close: () => void;
39
45
  reset: () => void;