budibase/packages/standard-components/src/Test/TestApp.svelte

48 lines
856 B
Svelte
Raw Normal View History

2019-08-27 08:32:56 +02:00
<script>
2020-02-03 10:50:30 +01:00
import createApp from "./createApp"
import { form } from "./props"
2020-02-03 10:50:30 +01:00
let _bb
let currentComponent
let _appPromise
2020-02-25 16:21:23 +01:00
const autoAssignIds = (props, count = 0) => {
if (!props._id) {
props._id = `auto_id_${count}`
}
if (props._children) {
for (let child of props._children) {
count += 1
autoAssignIds(child, count)
}
}
}
$: {
if (currentComponent) {
const _appPromise = createApp()
const page = {
props: form,
}
autoAssignIds(page.props)
_appPromise.then(initialise => {
initialise(page, currentComponent, "")
})
}
2020-02-03 10:50:30 +01:00
}
2019-08-27 08:32:56 +02:00
</script>
{#await _appPromise}
2020-02-03 10:50:30 +01:00
loading
{:then _bb}
2020-02-03 10:50:30 +01:00
<div id="current_component" bind:this={currentComponent} />
{/await}
2019-08-27 08:32:56 +02:00
<style>
2020-02-03 10:50:30 +01:00
#current_component {
2019-08-27 08:32:56 +02:00
height: 100%;
width: 100%;
2020-02-03 10:50:30 +01:00
}
2019-08-27 08:32:56 +02:00
</style>