feat(Table): add body-top / body-bottom slots (#4354)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Estéban
2025-06-25 11:17:02 +02:00
committed by GitHub
parent 81569713e9
commit 595fc64515
4 changed files with 227 additions and 5 deletions

View File

@@ -173,10 +173,12 @@ type DynamicHeaderSlots<T, K = keyof T> = Record<string, (props: HeaderContext<T
type DynamicCellSlots<T, K = keyof T> = Record<string, (props: CellContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-cell`, (props: CellContext<T, unknown>) => any>
export type TableSlots<T extends TableData = TableData> = {
expanded: (props: { row: Row<T> }) => any
empty: (props?: {}) => any
loading: (props?: {}) => any
caption: (props?: {}) => any
'expanded': (props: { row: Row<T> }) => any
'empty': (props?: {}) => any
'loading': (props?: {}) => any
'caption': (props?: {}) => any
'body-top': (props?: {}) => any
'body-bottom': (props?: {}) => any
} & DynamicHeaderSlots<T> & DynamicCellSlots<T>
</script>
@@ -371,6 +373,8 @@ defineExpose({
</thead>
<tbody :class="ui.tbody({ class: [props.ui?.tbody] })">
<slot name="body-top" />
<template v-if="tableApi.getRowModel().rows?.length">
<template v-for="row in tableApi.getRowModel().rows" :key="row.id">
<tr
@@ -425,6 +429,8 @@ defineExpose({
</slot>
</td>
</tr>
<slot name="body-bottom" />
</tbody>
</table>
</Primitive>