feat(data-table): support generics (#1954)

Co-authored-by: K.Kiyokawa <koichi20110068@gmail.com>
Co-authored-by: brunnerh <brunnerh@users.noreply.github.com>
This commit is contained in:
Eric Liu 2024-11-11 21:10:45 -08:00 committed by GitHub
commit dd43224119
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 278 additions and 132 deletions

View file

@ -0,0 +1,30 @@
<script lang="ts">
import { DataTable } from "../types";
</script>
<DataTable
headers="{[
{ key: 'name', value: 'Name' },
{ key: 'protocol', value: 'Protocol', width: '400px', minWidth: '40%' },
{ key: 'port', value: 'Port' },
{ key: 'rule.name', value: 'Rule', sort: false },
]}"
rows="{[
{
id: 'a',
name: 'Load Balancer 3',
protocol: 'HTTP',
port: 3000,
'rule.name': 'Round robin',
},
]}"
>
<span slot="cell" let:cell let:row>
{cell.key === "rule.name"}
{#if cell.key === "name"}
{row.name} {row.id}
{:else}
{cell.value}
{/if}
</span>
</DataTable>