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

27 lines
571 B
Svelte

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