Default header rendering.
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
export type TableProps<T> = {
|
export type TableProps<T> = {
|
||||||
columns: Column<T>[];
|
columns: Column<T>[];
|
||||||
data: T[];
|
data: T[];
|
||||||
header: Snippet<[Column<T>]>;
|
header?: Snippet<[Column<T>]>;
|
||||||
cell: Snippet<[Cell<T>]>;
|
cell: Snippet<[Cell<T>]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,7 +89,11 @@
|
|||||||
(c.wrap ? ' wrap-break-words' : ' truncate') +
|
(c.wrap ? ' wrap-break-words' : ' truncate') +
|
||||||
(s.target === 'cell' ? ' contain-[inline-size]' : '')}
|
(s.target === 'cell' ? ' contain-[inline-size]' : '')}
|
||||||
>
|
>
|
||||||
{@render header(c)}
|
{#if header}
|
||||||
|
{@render header(c)}
|
||||||
|
{:else}
|
||||||
|
{c.label}
|
||||||
|
{/if}
|
||||||
</th>
|
</th>
|
||||||
{/each}
|
{/each}
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -44,9 +44,6 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Table {columns} {data}>
|
<Table {columns} {data}>
|
||||||
{#snippet header(col)}
|
|
||||||
{col.label}
|
|
||||||
{/snippet}
|
|
||||||
{#snippet cell(ctx)}
|
{#snippet cell(ctx)}
|
||||||
{#if ctx.key === 'name'}
|
{#if ctx.key === 'name'}
|
||||||
{ctx.value}
|
{ctx.value}
|
||||||
|
|||||||
Reference in New Issue
Block a user