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

27 lines
557 B
Svelte

<script>
import { getContext, onMount } from "svelte"
import { isEmpty } from "lodash/fp"
const { API, styleable, DataProvider } = getContext("sdk")
const component = getContext("component")
const data = getContext("data")
export let datasource = []
let rows = []
onMount(async () => {
if (!isEmpty(datasource)) {
rows = await API.fetchDatasource(datasource, $data)
}
})
</script>
<div use:styleable={$component.styles}>
{#each rows as row}
<DataProvider {row}>
<slot />
</DataProvider>
{/each}
</div>