2021-11-02 09:45:27 +01:00
|
|
|
<script>
|
|
|
|
import { getContext } from "svelte"
|
|
|
|
import { generate } from "shortid"
|
|
|
|
import Component from "components/Component.svelte"
|
|
|
|
|
|
|
|
export let type
|
|
|
|
export let props
|
|
|
|
export let styles
|
2021-11-08 15:35:58 +01:00
|
|
|
export let context
|
2021-11-02 09:58:50 +01:00
|
|
|
|
|
|
|
// ID is only exposed as a prop so that it can be bound to from parent
|
|
|
|
// block components
|
2021-11-02 09:45:27 +01:00
|
|
|
export let id
|
|
|
|
|
|
|
|
const block = getContext("block")
|
|
|
|
const rand = generate()
|
|
|
|
|
2021-11-02 09:58:50 +01:00
|
|
|
// 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
|
2021-11-08 15:35:58 +01:00
|
|
|
$: id = `${block.id}-${context ?? rand}`
|
2021-11-02 13:58:38 +01:00
|
|
|
$: instance = {
|
|
|
|
_component: `@budibase/standard-components/${type}`,
|
|
|
|
_id: id,
|
|
|
|
_styles: {
|
|
|
|
normal: {
|
|
|
|
...styles,
|
2021-11-02 09:45:27 +01:00
|
|
|
},
|
2021-11-02 13:58:38 +01:00
|
|
|
},
|
|
|
|
...props,
|
2021-11-02 09:45:27 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-11-12 16:19:25 +01:00
|
|
|
<Component {instance} isBlock>
|
2021-11-02 09:45:27 +01:00
|
|
|
<slot />
|
|
|
|
</Component>
|