2019-09-27 18:03:31 +02:00
|
|
|
<script>
|
|
|
|
|
|
|
|
export let columns=[];
|
|
|
|
export let data="";
|
|
|
|
export let tableClass="";
|
|
|
|
export let theadClass="";
|
|
|
|
export let tbodyClass="";
|
|
|
|
export let trClass="";
|
|
|
|
export let thClass="";
|
|
|
|
export let onRowClick;
|
|
|
|
|
|
|
|
export let _bb;
|
|
|
|
|
|
|
|
const rowClickHandler = (row) => () => {
|
2019-10-07 07:03:41 +02:00
|
|
|
_bb.call(onRowClick, row);
|
2019-09-27 18:03:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-18 18:32:03 +02:00
|
|
|
const cellValue = (colIndex, row) => {
|
|
|
|
const val = _bb.getStateOrValue(
|
2019-10-19 08:24:20 +02:00
|
|
|
_bb.props.columns[colIndex].value
|
2019-10-18 18:32:03 +02:00
|
|
|
, row)
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-27 18:03:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<table class={tableClass}>
|
|
|
|
<thead class={theadClass}>
|
|
|
|
<tr class={trClass}>
|
|
|
|
{#each columns as col}
|
|
|
|
<th class={thClass}>{col.title}</th>
|
|
|
|
{/each}
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class={tbodyClass}>
|
2019-10-18 18:32:03 +02:00
|
|
|
{#if data}
|
2019-09-27 18:03:31 +02:00
|
|
|
{#each data as row}
|
|
|
|
<tr class={trClass}
|
|
|
|
on:click={rowClickHandler(row)} >
|
2019-10-18 18:32:03 +02:00
|
|
|
{#each columns as col, index}
|
|
|
|
<th class={thClass}>{cellValue(index, row)}</th>
|
2019-09-27 18:03:31 +02:00
|
|
|
{/each}
|
|
|
|
</tr>
|
|
|
|
{/each}
|
2019-10-18 18:32:03 +02:00
|
|
|
{/if}
|
2019-09-27 18:03:31 +02:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.table-default {
|
|
|
|
width: 100%;
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
color: #212529;
|
|
|
|
border-collapse: collapse;
|
|
|
|
}
|
|
|
|
|
|
|
|
.table-default .thead-default .th-default {
|
|
|
|
vertical-align: bottom;
|
|
|
|
border-bottom: 2px solid #dee2e6;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.table-default .th-default {
|
|
|
|
padding: .75rem;
|
|
|
|
vertical-align: top;
|
|
|
|
border-top: 1px solid #dee2e6;
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
.th-default {
|
|
|
|
text-align: inherit;
|
|
|
|
}
|
|
|
|
|
|
|
|
.table-default .tbody-default .tr-default:hover {
|
|
|
|
color: #212529;
|
|
|
|
background-color: rgba(0,0,0,.075);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|