@groupteknology/vuno 0.4.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.
- package/README.md +153 -0
- package/dist/module.json +1 -1
- package/dist/runtime/app/components/Cell/CellBadge.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellBadge.vue +24 -0
- package/dist/runtime/app/components/Cell/CellBadge.vue.d.ts +5 -0
- package/dist/runtime/app/components/Cell/CellBoolean.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellBoolean.vue +21 -0
- package/dist/runtime/app/components/Cell/CellBoolean.vue.d.ts +5 -0
- package/dist/runtime/app/components/Cell/CellCurrency.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellCurrency.vue +14 -0
- package/dist/runtime/app/components/Cell/CellCurrency.vue.d.ts +5 -0
- package/dist/runtime/app/components/Cell/CellDate.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellDate.vue +19 -0
- package/dist/runtime/app/components/Cell/CellDate.vue.d.ts +5 -0
- package/dist/runtime/app/components/Cell/CellImage.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellImage.vue +22 -0
- package/dist/runtime/app/components/Cell/CellImage.vue.d.ts +5 -0
- package/dist/runtime/app/components/Cell/CellNumber.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellNumber.vue +15 -0
- package/dist/runtime/app/components/Cell/CellNumber.vue.d.ts +5 -0
- package/dist/runtime/app/components/Cell/CellText.d.vue.ts +5 -0
- package/dist/runtime/app/components/Cell/CellText.vue +13 -0
- package/dist/runtime/app/components/Cell/CellText.vue.d.ts +5 -0
- package/dist/runtime/app/components/Table/Table.vue +273 -264
- package/dist/runtime/app/components/Table/TableCell.vue +24 -73
- package/dist/runtime/app/theme/index.js +15 -1
- package/dist/runtime/app/types/table.d.ts +80 -13
- package/dist/runtime/app/types/theme.d.ts +6 -0
- package/dist/runtime/app/utils/column.d.ts +9 -0
- package/dist/runtime/app/utils/column.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,87 @@ El slot `footer` recibe `formId`, necesario para enviar desde un botón propio:
|
|
|
106
106
|
<VFormModal v-model:open="open" v-model:state="state" :definition="definition" :schema="schema" title="Nuevo producto" close-on-submit @submit="guardar" />
|
|
107
107
|
```
|
|
108
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
|
+
|
|
109
190
|
## Una pantalla de mantenimiento entera
|
|
110
191
|
|
|
111
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).
|
|
@@ -241,6 +322,78 @@ const { data, status } = await useFetch('/api/products', {
|
|
|
241
322
|
|
|
242
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.
|
|
243
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
|
+
|
|
244
397
|
### Una tabla vacía no es una que falló
|
|
245
398
|
|
|
246
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
|
@@ -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;
|