refacto(tables) : composant DataTable global + migration de toutes les tables
- Nouveau composant DataTable réutilisable avec tri par en-têtes, pagination, filtres colonnes - Nouveau composable useDataTable (sort/page/search/perPage/columnFilters + persistance URL) - Migration des 9 tables : constructeurs, comments, admin, pieces-catalog, component-catalog, product-catalog, documents, activity-log, ManagementView (catégories) - Filtres "Type de" server-side (ipartial) pour pièces, composants, produits Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
46
app/shared/types/dataTable.ts
Normal file
46
app/shared/types/dataTable.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
export type SortDirection = 'asc' | 'desc'
|
||||
|
||||
export interface DataTableColumn {
|
||||
/** Unique key — used as slot name prefix (`#cell-{key}`) and default data accessor (`row[key]`) */
|
||||
key: string
|
||||
/** Display label for the column header */
|
||||
label: string
|
||||
/** Whether clicking this column header triggers sorting. Default: false */
|
||||
sortable?: boolean
|
||||
/** Sort key sent to the API (may differ from `key`). Falls back to `key` if omitted. */
|
||||
sortKey?: string
|
||||
/** CSS class applied to both <th> and <td> */
|
||||
class?: string
|
||||
/** CSS class applied only to <th> */
|
||||
headerClass?: string
|
||||
/** Width hint (e.g. 'w-24', 'min-w-[10rem]') */
|
||||
width?: string
|
||||
/** Text alignment: 'left' (default), 'center', 'right' */
|
||||
align?: 'left' | 'center' | 'right'
|
||||
/** Hide on mobile (adds 'hidden sm:table-cell') */
|
||||
hiddenMobile?: boolean
|
||||
/** Whether this column has a filter input under the header */
|
||||
filterable?: boolean
|
||||
/** Placeholder for the filter input */
|
||||
filterPlaceholder?: string
|
||||
}
|
||||
|
||||
export type DataTableColumnFilters = Record<string, string>
|
||||
|
||||
export interface DataTableSort {
|
||||
field: string
|
||||
direction: SortDirection
|
||||
}
|
||||
|
||||
export interface DataTablePagination {
|
||||
currentPage: number
|
||||
totalPages: number
|
||||
/** Total items matching current filters */
|
||||
totalItems: number
|
||||
/** Items displayed on current page */
|
||||
pageItems: number
|
||||
/** Available per-page options. If omitted, per-page selector is hidden. */
|
||||
perPageOptions?: number[]
|
||||
/** Currently selected items per page */
|
||||
perPage?: number
|
||||
}
|
||||
Reference in New Issue
Block a user