1
0
Fork 0
mirror of synced 2024-06-13 16:05:06 +12:00
budibase/packages/client/src/components/BlockComponent.svelte

36 lines
828 B
Svelte
Raw Normal View History

<script>
import { getContext } from "svelte"
import { generate } from "shortid"
import Component from "components/Component.svelte"
export let type
export let props
export let styles
export let context
// ID is only exposed as a prop so that it can be bound to from parent
// block components
export let id
const block = getContext("block")
const rand = generate()
// Create a fake component instance so that we can use the core Component
// to render this part of the block, taking advantage of binding enrichment
$: id = `${block.id}-${context ?? rand}`
2021-11-03 01:58:38 +13:00
$: instance = {
_component: `@budibase/standard-components/${type}`,
_id: id,
_styles: {
normal: {
...styles,
},
2021-11-03 01:58:38 +13:00
},
...props,
}
</script>
2021-11-13 04:19:25 +13:00
<Component {instance} isBlock>
<slot />
</Component>