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

27 lines
553 B
Svelte
Raw Normal View History

2020-02-17 18:01:57 +01:00
<script>
import { getContext } from "svelte";
2020-02-17 18:01:57 +01:00
export let onSelect = () => {};
export let isHeader = false;
let row = null;
let selected = false;
2020-02-17 18:01:57 +01:00
const cb = getContext("BBMD:data-table:cb");
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 });
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>