improve form config

This commit is contained in:
Ruben Fiszel
2023-05-10 09:24:00 +02:00
parent f6b938f446
commit 4c3151dfdc
4 changed files with 39 additions and 8 deletions
@@ -1,6 +1,7 @@
<script lang="ts">
import { twMerge } from 'tailwind-merge'
import Required from './Required.svelte'
import { addWhitespaceBeforeCapitals, capitalize } from '$lib/utils'
export let label: string
export let format: string = ''
@@ -13,7 +14,7 @@
<div class="inline-flex flex-row items-center truncated">
<span class={twMerge('font-semibold', labelClass)}>
{label}
{addWhitespaceBeforeCapitals(label.replace(/_/g, ' ')).split(' ').map(capitalize).join(' ')}
</span>
<Required {required} class="!ml-0" />
@@ -61,7 +61,7 @@
{/each}
<RunnableWrapper {outputs} {render} autoRefresh {componentInput} {id} bind:initializing bind:result>
{#if result && Object.keys(result.properties).length > 0}
{#if result && Object.keys(result?.properties ?? {}).length > 0}
<div
class={twMerge('m-2', css?.container?.class)}
style={css?.container?.style}
@@ -1757,10 +1757,14 @@ Hello \${ctx.username}
type: 'static',
fieldType: 'schema',
value: {
$schema: 'https://json-schema.org/draft/2020-12/schema',
properties: {},
required: [],
type: 'object'
properties: {
first_name: {
type: 'string',
description: 'your name',
default: 'default'
}
},
required: []
}
},
configuration: {
@@ -1768,13 +1772,13 @@ Hello \${ctx.username}
fieldType: 'boolean',
type: 'static',
value: false,
staticOnly: true
onlyStatic: true
},
largeGap: {
fieldType: 'boolean',
type: 'static',
value: false,
staticOnly: true
onlyStatic: true
}
}
}
@@ -474,5 +474,31 @@ export async function main(db: Resource<"postgresql">) {
}`,
python3: `def main():
return "Smile"`
},
schemaformcomponent: {
deno: `export async function main() {
return {
properties: {
first_name: {
type: 'string',
description: 'your name',
default: 'default'
}
},
required: []
}
}`,
python3: `def main():
return {
"properties": {
"first_name": {
"type": "string",
"description": "your name",
"default": "default"
}
},
"required": []
}
`
}
} as const