macro parameters

This commit is contained in:
Jan Prochazka
2021-03-14 20:44:19 +01:00
parent 49337a4112
commit 0af207d330
12 changed files with 307 additions and 16 deletions

View File

@@ -0,0 +1,27 @@
<script lang="ts">
import _ from 'lodash';
import FormCheckboxField from './FormCheckboxField.svelte';
import FormSelectField from './FormSelectField.svelte';
import FormTextField from './FormTextField.svelte';
export let arg;
export let namePrefix;
$: name = `${namePrefix}${arg.name}`;
</script>
{#if arg.type == 'text'}
<FormTextField label={arg.label} {name} />
{:else if arg.type == 'checkbox'}
<FormCheckboxField label={arg.label} {name} defaultValue={arg.default} />
{:else if arg.type == 'select'}
<FormSelectField
label={arg.label}
isNative
{name}
options={arg.options.map(opt =>
_.isString(opt) ? { label: opt, value: opt } : { label: opt.name, value: opt.value }
)}
/>
{/if}