mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 00:15:05 +01:00
feat(Table): add style to table and column meta (#4513)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -45,12 +45,19 @@ declare module '@tanstack/table-core' {
|
||||
th?: string | ((cell: Header<TData, TValue>) => string)
|
||||
td?: string | ((cell: Cell<TData, TValue>) => string)
|
||||
}
|
||||
style?: {
|
||||
th?: string | Record<string, string> | ((cell: Header<TData, TValue>) => string | Record<string, string>)
|
||||
td?: string | Record<string, string> | ((cell: Cell<TData, TValue>) => string | Record<string, string>)
|
||||
}
|
||||
}
|
||||
|
||||
interface TableMeta<TData> {
|
||||
class?: {
|
||||
tr?: string | ((row: Row<TData>) => string)
|
||||
}
|
||||
style?: {
|
||||
tr?: string | Record<string, string> | ((row: Row<TData>) => string | Record<string, string>)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -432,6 +439,7 @@ defineExpose({
|
||||
typeof tableApi.options.meta?.class?.tr === 'function' ? tableApi.options.meta.class.tr(row) : tableApi.options.meta?.class?.tr
|
||||
]
|
||||
})"
|
||||
:style="typeof tableApi.options.meta?.style?.tr === 'function' ? tableApi.options.meta?.style?.tr(row) : tableApi.options.meta?.style?.tr"
|
||||
@click="onRowSelect($event, row)"
|
||||
@pointerenter="onRowHover($event, row)"
|
||||
@pointerleave="onRowHover($event, null)"
|
||||
@@ -448,6 +456,7 @@ defineExpose({
|
||||
],
|
||||
pinned: !!cell.column.getIsPinned()
|
||||
})"
|
||||
:style="typeof cell.column.columnDef.meta?.style?.td === 'function' ? cell.column.columnDef.meta.style.td(cell) : cell.column.columnDef.meta?.style?.td"
|
||||
>
|
||||
<slot :name="`${cell.column.id}-cell`" v-bind="cell.getContext()">
|
||||
<FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
|
||||
@@ -495,6 +504,7 @@ defineExpose({
|
||||
],
|
||||
pinned: !!header.column.getIsPinned()
|
||||
})"
|
||||
:style="typeof header.column.columnDef.meta?.style?.th === 'function' ? header.column.columnDef.meta.style.th(header) : header.column.columnDef.meta?.style?.th"
|
||||
>
|
||||
<slot :name="`${header.id}-footer`" v-bind="header.getContext()">
|
||||
<FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.footer" :props="header.getContext()" />
|
||||
|
||||
Reference in New Issue
Block a user