1
0
Fork 0
mirror of synced 2024-09-02 02:31:11 +12:00
budibase/packages/standard-components/src/List.svelte
2020-11-25 18:43:58 +00:00

26 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>