2020-06-03 00:26:06 +02:00
|
|
|
<script>
|
2021-01-21 11:42:14 +01:00
|
|
|
import { getContext } from "svelte"
|
2020-11-18 20:18:18 +01:00
|
|
|
|
2021-03-16 14:54:34 +01:00
|
|
|
export let dataProviderId
|
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 14:54:34 +01:00
|
|
|
$: data = context[dataProviderId]?.rows ?? []
|
|
|
|
$: loaded = context[dataProviderId]?.loaded ?? false
|
2020-06-03 00:26:06 +02:00
|
|
|
</script>
|
|
|
|
|
2021-03-16 14:54:34 +01:00
|
|
|
<div use:styleable={$component.styles}>
|
|
|
|
{#if data.length > 0}
|
|
|
|
{#if $component.children === 0 && $builderStore.inBuilder}
|
|
|
|
<p><i class="ri-image-line" />Add some components to display.</p>
|
|
|
|
{:else}
|
|
|
|
{#each data as row}
|
|
|
|
<Provider data={row}>
|
|
|
|
<slot />
|
|
|
|
</Provider>
|
|
|
|
{/each}
|
2021-01-26 10:48:41 +01:00
|
|
|
{/if}
|
2021-03-16 14:54:34 +01:00
|
|
|
{:else if loaded && noRowsMessage}
|
|
|
|
<p><i class="ri-list-check-2" />{noRowsMessage}</p>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2021-01-19 15:11:21 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
p {
|
2021-02-10 19:34:45 +01:00
|
|
|
margin: 0 var(--spacing-m);
|
|
|
|
background-color: var(--grey-2);
|
|
|
|
color: var(--grey-6);
|
|
|
|
font-size: var(--font-size-s);
|
|
|
|
padding: var(--spacing-l);
|
|
|
|
border-radius: var(--border-radius-s);
|
2021-01-19 15:11:21 +01:00
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
2021-02-10 19:34:45 +01:00
|
|
|
}
|
|
|
|
p i {
|
|
|
|
margin-bottom: var(--spacing-m);
|
|
|
|
font-size: 1.5rem;
|
|
|
|
color: var(--grey-5);
|
2021-01-19 15:11:21 +01:00
|
|
|
}
|
2021-01-22 11:49:03 +01:00
|
|
|
</style>
|