2020-06-03 00:26:06 +02:00
|
|
|
<script>
|
2021-01-21 11:42:14 +01:00
|
|
|
import { getContext } from "svelte"
|
2021-06-11 09:05:49 +02:00
|
|
|
import Placeholder from "./Placeholder.svelte"
|
2020-11-18 20:18:18 +01:00
|
|
|
|
2021-03-16 20:11:00 +01:00
|
|
|
export let dataProvider
|
2021-02-10 19:34:45 +01:00
|
|
|
export let noRowsMessage
|
2021-02-05 17:16:41 +01:00
|
|
|
|
2021-03-16 14:54:34 +01:00
|
|
|
const { API, styleable, builderStore, Provider } = getContext("sdk")
|
2020-11-24 12:02:10 +01:00
|
|
|
const component = getContext("component")
|
2021-03-16 14:54:34 +01:00
|
|
|
const context = getContext("context")
|
2020-06-03 00:26:06 +02:00
|
|
|
|
2021-03-16 20:11:00 +01:00
|
|
|
$: rows = dataProvider?.rows ?? []
|
|
|
|
$: loaded = dataProvider?.loaded ?? false
|
2020-06-03 00:26:06 +02:00
|
|
|
</script>
|
|
|
|
|
2021-03-16 14:54:34 +01:00
|
|
|
<div use:styleable={$component.styles}>
|
2021-06-11 09:05:49 +02:00
|
|
|
{#if $component.empty}
|
|
|
|
<Placeholder />
|
|
|
|
{:else if rows.length > 0}
|
|
|
|
{#each rows as row}
|
|
|
|
<Provider data={row}>
|
|
|
|
<slot />
|
|
|
|
</Provider>
|
|
|
|
{/each}
|
2021-03-16 14:54:34 +01:00
|
|
|
{:else if loaded && noRowsMessage}
|
2021-06-11 09:45:58 +02:00
|
|
|
<div class="noRows"><i class="ri-list-check-2" />{noRowsMessage}</div>
|
2021-03-16 14:54:34 +01:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-06-11 09:45:58 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.noRows {
|
|
|
|
color: var(--grey-6);
|
|
|
|
font-size: var(--font-size-s);
|
|
|
|
padding: var(--spacing-l);
|
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
|
|
|
}
|
|
|
|
.noRows i {
|
|
|
|
margin-bottom: var(--spacing-m);
|
|
|
|
font-size: 1.5rem;
|
|
|
|
color: var(--grey-5);
|
|
|
|
}
|
|
|
|
</style>
|