<script>
    import { t } from '../../translations.svelte';

    let { items, selected = $bindable(null), drag_start = item => console.log({dragging:item}) } = $props();
</script>
<table>
    <thead>
        <tr>
            <th>{t('id')}</th>
            <th>{t('code')}</th>
            <th>{t('name')}</th>
        </tr>
    </thead>
    <tbody>
    {#each items as item}
    <tr onclick={ev => selected = item} ondragstart={e => drag_start(item)} draggable="true">
        <td>{item.id}</td>
        <td>{item.code}</td>
        <td>{item.name}</td>
    </tr>
    {/each}
    </tbody>
</table>
