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

26 lines
540 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"
const { API, styleable, DataProvider } = getContext("sdk")
const component = getContext("component")
2020-06-03 00:26:06 +02:00
export let datasource = []
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)) {
2020-11-24 12:28:31 +01:00
rows = await API.fetchDatasource(datasource, $component.dataContext)
2020-06-03 00:26:06 +02:00
}
})
</script>
<div use:styleable={$component.styles}>
2020-11-18 12:24:01 +01:00
{#each rows as row}
<DataProvider {row}>
<slot />
</DataProvider>
{/each}
</div>