budibase/packages/standard-components/src/Repeater.svelte

29 lines
705 B
Svelte
Raw Normal View History

2020-06-03 00:26:06 +02:00
<script>
import { getContext } from "svelte"
import Placeholder from "./Placeholder.svelte"
export let dataProvider
export let noRowsMessage
const { API, styleable, builderStore, Provider } = getContext("sdk")
const component = getContext("component")
const context = getContext("context")
2020-06-03 00:26:06 +02:00
$: rows = dataProvider?.rows ?? []
$: loaded = dataProvider?.loaded ?? false
2020-06-03 00:26:06 +02:00
</script>
<div use:styleable={$component.styles}>
{#if $component.empty}
<Placeholder />
{:else if rows.length > 0}
{#each rows as row}
<Provider data={row}>
<slot />
</Provider>
{/each}
{:else if loaded && noRowsMessage}
<Placeholder text={noRowsMessage} />
{/if}
</div>