budibase/packages/materialdesign-components/src/Datatable/DatatableRow.svelte

32 lines
657 B
Svelte
Raw Normal View History

2020-02-17 18:01:57 +01:00
<script>
import { getContext } from "svelte";
import ClassBuilder from "../ClassBuilder.js"
export let onSelect = () => {};
export let isHeader = false;
2020-02-20 18:06:50 +01:00
export let _bb
let row = null;
let selected = false;
2020-02-17 18:01:57 +01:00
const cb = new ClassBuilder("data-table")
2020-02-17 18:01:57 +01:00
let elementName = isHeader ? "header-row" : "row";
let modifiers = {};
2020-02-17 18:01:57 +01:00
$: modifiers = { selected };
$: props = { modifiers };
$: rowClass = cb.build({ elementName, props });
2020-02-20 18:06:50 +01:00
$: row && _bb.attachChildren(row)
function rowSelected() {
selected = !selected;
onSelect();
}
2020-02-17 18:01:57 +01:00
</script>
<tr bind:this={row} class={rowClass} on:click={rowSelected}>
2020-02-17 18:01:57 +01:00
<slot />
</tr>