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