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"
|
2021-06-24 12:44:33 +02:00
|
|
|
import Container from "./Container.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-06-24 12:44:33 +02:00
|
|
|
export let direction
|
|
|
|
export let hAlign
|
|
|
|
export let vAlign
|
2021-06-24 13:15:04 +02:00
|
|
|
export let gap
|
2021-02-05 17:16:41 +01:00
|
|
|
|
2021-06-24 12:44:33 +02:00
|
|
|
const { Provider } = getContext("sdk")
|
2020-11-24 12:02:10 +01:00
|
|
|
const component = getContext("component")
|
2020-06-03 00:26:06 +02:00
|
|
|
|
2021-03-16 20:11:00 +01:00
|
|
|
$: rows = dataProvider?.rows ?? []
|
2021-06-11 12:37:05 +02:00
|
|
|
$: loaded = dataProvider?.loaded ?? true
|
2020-06-03 00:26:06 +02:00
|
|
|
</script>
|
|
|
|
|
2021-06-24 13:15:04 +02:00
|
|
|
<Container {direction} {hAlign} {vAlign} {gap} wrap>
|
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}
|
2021-06-24 12:44:33 +02:00
|
|
|
</Container>
|
2021-06-11 09:45:58 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.noRows {
|
2021-07-05 15:02:49 +02:00
|
|
|
color: var(--spectrum-global-color-gray-600);
|
2021-06-11 09:45:58 +02:00
|
|
|
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;
|
2021-07-05 15:02:49 +02:00
|
|
|
color: var(--spectrum-global-color-gray-600);
|
2021-06-11 09:45:58 +02:00
|
|
|
}
|
|
|
|
</style>
|