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

28 lines
573 B
Svelte
Raw Normal View History

2020-06-03 00:26:06 +02:00
<script>
import { getContext, onMount } from "svelte"
import { isEmpty } from "lodash/fp"
import DataProvider from "./DataProvider.svelte"
const { API, styleable } = getContext("app")
const dataContext = getContext("data")
2020-06-03 00:26:06 +02:00
export let datasource = []
2020-11-18 12:24:01 +01:00
export let styles
2020-06-03 00:26:06 +02:00
2020-11-18 12:24:01 +01:00
let rows = []
2020-06-03 00:26:06 +02:00
onMount(async () => {
if (!isEmpty(datasource)) {
rows = await API.fetchDatasource(datasource, $dataContext)
2020-06-03 00:26:06 +02:00
}
})
</script>
2020-11-18 12:24:01 +01:00
<div use:styleable={styles}>
{#each rows as row}
<DataProvider {row}>
<slot />
</DataProvider>
{/each}
</div>