feat: ajout du composant datatable (#28)
All checks were successful
Release / release (push) Successful in 1m5s
All checks were successful
Release / release (push) Successful in 1m5s
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [x] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [x] CHANGELOG modifié Co-authored-by: kevin <kevin@yuno.malio.fr> Co-authored-by: Kevin Boudet <kevin@yuno.malio.fr> Reviewed-on: #28 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #28.
This commit is contained in:
@@ -394,3 +394,59 @@ Panneau latéral (drawer) qui s'ouvre depuis la droite avec backdrop semi-transp
|
||||
<p>Drawer plus large</p>
|
||||
</MalioDrawer>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## MalioDataTable
|
||||
|
||||
Tableau de données presentational avec pagination, filtres par slots et lignes cliquables.
|
||||
|
||||
| Prop | Type | Défaut | Description |
|
||||
|------|------|--------|-------------|
|
||||
| `id` | `string` | auto | Identifiant HTML |
|
||||
| `columns` | `{ key: string, label: string }[]` | **requis** | Définition des colonnes |
|
||||
| `items` | `Record<string, unknown>[]` | **requis** | Données à afficher |
|
||||
| `totalItems` | `number` | **requis** | Total pour la pagination |
|
||||
| `page` | `number` | `1` | Page courante (v-model) |
|
||||
| `perPage` | `number` | `10` | Lignes par page (v-model) |
|
||||
| `perPageOptions` | `number[]` | `[10, 25, 50]` | Options du sélecteur de lignes |
|
||||
| `rowClickable` | `boolean` | `true` | Lignes cliquables (cursor pointer + hover) |
|
||||
| `tableClass` | `string` | `''` | Classes CSS sur `<table>` (twMerge) |
|
||||
| `emptyMessage` | `string` | `'Aucune donnée'` | Message si items vide |
|
||||
|
||||
**Events :** `update:page(value: number)`, `update:per-page(value: number)`, `row-click(item: Record<string, unknown>)`
|
||||
**Slots :** `#header-{key}` (filtre dans le `<th>`, placeholder = label), `#cell-{key}` (contenu du `<td>`), `#empty` (état vide)
|
||||
|
||||
```vue
|
||||
<!-- Avec filtres et pagination -->
|
||||
<MalioDataTable
|
||||
:columns="[{ key: 'nom', label: 'Nom' }, { key: 'ville', label: 'Ville' }]"
|
||||
:items="data"
|
||||
:total-items="total"
|
||||
v-model:page="page"
|
||||
v-model:per-page="perPage"
|
||||
@row-click="router.push(`/contact/${$event.id}`)"
|
||||
>
|
||||
<template #header-nom>
|
||||
<input v-model="filtreNom" placeholder="Nom" class="w-full border-0 border-b border-black bg-transparent px-0 py-1 text-sm outline-none">
|
||||
</template>
|
||||
<template #header-ville>
|
||||
<select v-model="filtreVille" class="w-full appearance-none border-0 border-b border-black bg-transparent px-0 py-1 text-sm outline-none">
|
||||
<option value="">Ville</option>
|
||||
<option v-for="v in villes" :key="v" :value="v">{{ v }}</option>
|
||||
</select>
|
||||
</template>
|
||||
<template #cell-nom="{ item }">
|
||||
<strong>{{ item.nom }}</strong>
|
||||
</template>
|
||||
</MalioDataTable>
|
||||
|
||||
<!-- Simple sans filtres -->
|
||||
<MalioDataTable
|
||||
:columns="columns"
|
||||
:items="data"
|
||||
:total-items="total"
|
||||
v-model:page="page"
|
||||
v-model:per-page="perPage"
|
||||
/>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user