Allow table to take children

This commit is contained in:
Andrew Kingston 2021-03-25 08:02:41 +00:00
parent 9dc337dfec
commit 7c79e52360
2 changed files with 21 additions and 2 deletions

View File

@ -1514,6 +1514,7 @@
"name": "Table", "name": "Table",
"icon": "ri-table-line", "icon": "ri-table-line",
"styleable": true, "styleable": true,
"hasChildren": true,
"settings": [ "settings": [
{ {
"type": "dataProvider", "type": "dataProvider",
@ -1579,6 +1580,10 @@
} }
] ]
} }
] ],
"dataContext": {
"type": "schema",
"dataProviderSetting": "dataProvider"
}
} }
} }

View File

@ -11,7 +11,7 @@
export let rowCount export let rowCount
const component = getContext("component") const component = getContext("component")
const { styleable } = getContext("sdk") const { styleable, Provider } = getContext("sdk")
let sortColumn let sortColumn
let sortOrder let sortOrder
@ -85,6 +85,11 @@
<table class="spectrum-Table"> <table class="spectrum-Table">
<thead class="spectrum-Table-head"> <thead class="spectrum-Table-head">
<tr> <tr>
{#if $component.children}
<th class="spectrum-Table-headCell">
<div class="spectrum-Table-headCell-content" />
</th>
{/if}
{#each fields as field} {#each fields as field}
<th <th
class="spectrum-Table-headCell is-sortable" class="spectrum-Table-headCell is-sortable"
@ -108,6 +113,15 @@
<tbody class="spectrum-Table-body"> <tbody class="spectrum-Table-body">
{#each sortedRows as row} {#each sortedRows as row}
<tr class="spectrum-Table-row"> <tr class="spectrum-Table-row">
{#if $component.children}
<td class="spectrum-Table-cell">
<div class="spectrum-Table-cell-content">
<Provider data={row}>
<slot />
</Provider>
</div>
</td>
{/if}
{#each fields as field} {#each fields as field}
<td class="spectrum-Table-cell"> <td class="spectrum-Table-cell">
<div class="spectrum-Table-cell-content"> <div class="spectrum-Table-cell-content">