|
|
|
@ -1,18 +1,71 @@ |
|
|
|
<script> |
|
|
|
import { getContext } from "svelte" |
|
|
|
import Manifest from "manifest.json" |
|
|
|
import { builderStore } from "stores" |
|
|
|
|
|
|
|
const { builderStore } = getContext("sdk") |
|
|
|
const { componentStore } = getContext("sdk") |
|
|
|
const component = getContext("component") |
|
|
|
|
|
|
|
export let text |
|
|
|
|
|
|
|
$: componentInstance = componentStore.actions.getComponentById($component.id) |
|
|
|
|
|
|
|
const getComponentKey = compId => { |
|
|
|
if (!compId) { |
|
|
|
return |
|
|
|
} |
|
|
|
const prefix = "@budibase/standard-components/" |
|
|
|
let componentKey = compId.replace(prefix, "") |
|
|
|
return componentKey |
|
|
|
} |
|
|
|
|
|
|
|
//Corify this somewhere |
|
|
|
const emptyFields = (definition, options) => { |
|
|
|
if (!options) { |
|
|
|
return [] |
|
|
|
} |
|
|
|
return definition?.settings |
|
|
|
? definition.settings.filter(setting => { |
|
|
|
return ( |
|
|
|
setting.required && |
|
|
|
(!options[setting.key] || options[setting.key] == "") |
|
|
|
) |
|
|
|
}) |
|
|
|
: [] |
|
|
|
} |
|
|
|
const definition = Manifest[getComponentKey($component.type)] |
|
|
|
$: focus_setting = emptyFields(definition, componentInstance)[0] |
|
|
|
</script> |
|
|
|
|
|
|
|
{#if $builderStore.inBuilder} |
|
|
|
<div class="placeholder_wrap"> |
|
|
|
{#if !$$slots.content} |
|
|
|
{#if componentInstance && focus_setting} |
|
|
|
<div> |
|
|
|
<span> |
|
|
|
Add the <mark>{focus_setting?.label}</mark> setting to start using your |
|
|
|
component |
|
|
|
</span> |
|
|
|
<span |
|
|
|
class="showMe spectrum-Link" |
|
|
|
on:click={() => { |
|
|
|
builderStore.actions.setFocus([ |
|
|
|
{ |
|
|
|
location: "component_settings", |
|
|
|
key: focus_setting.key, |
|
|
|
target: $component.id, |
|
|
|
}, |
|
|
|
]) |
|
|
|
}} |
|
|
|
> |
|
|
|
Show me |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
{:else} |
|
|
|
{text || $component.name || "Placeholder"} |
|
|
|
<!-- {#if definition.hasChildren} |
|
|
|
<span>: Add a component or two!</span> |
|
|
|
{/if} --> |
|
|
|
{/if} |
|
|
|
<slot name="content" /> |
|
|
|
</div> |
|
|
|
{/if} |
|
|
|
|
|
|
|
|