feat(frontend): add support for dynamic default values + enums (#3109)
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
export let displayType: boolean = true
|
||||
export let largeGap: boolean = false
|
||||
export let isValid: boolean = true
|
||||
export let defaultValues: Record<string, any> = {}
|
||||
export let dynamicEnums: Record<string, any> = {}
|
||||
|
||||
let inputCheck: { [id: string]: boolean } = {}
|
||||
let errors: { [id: string]: string } = {}
|
||||
@@ -72,8 +74,8 @@
|
||||
type={schema.properties[argName].type}
|
||||
required={schema.required?.includes(argName) ?? false}
|
||||
pattern={schema.properties[argName].pattern}
|
||||
defaultValue={schema.properties[argName].default}
|
||||
enum_={schema.properties[argName].enum}
|
||||
defaultValue={defaultValues?.[argName] ?? schema.properties[argName].default}
|
||||
enum_={dynamicEnums?.[argName] ?? schema.properties[argName].enum}
|
||||
format={schema.properties[argName].format}
|
||||
contentEncoding={schema.properties[argName].contentEncoding}
|
||||
customErrorMessage={schema.properties[argName].customErrorMessage}
|
||||
|
||||
@@ -118,6 +118,8 @@
|
||||
!$connectingInput.opened && selectId(e, id, selectedComponent, $app)}
|
||||
>
|
||||
<LightweightSchemaForm
|
||||
defaultValues={resolvedConfig.defaultValues}
|
||||
dynamicEnums={resolvedConfig.dynamicEnums}
|
||||
schema={result}
|
||||
bind:isValid={valid}
|
||||
bind:args
|
||||
|
||||
@@ -2739,6 +2739,19 @@ This is a paragraph.
|
||||
}
|
||||
},
|
||||
configuration: {
|
||||
defaultValues: {
|
||||
type: 'static',
|
||||
fieldType: 'object',
|
||||
value: {},
|
||||
tooltip: 'This will allow you to dynamically set the default values of the form.'
|
||||
},
|
||||
dynamicEnums: {
|
||||
type: 'static',
|
||||
fieldType: 'object',
|
||||
value: {},
|
||||
tooltip: 'This will allow you to dynamically set the enum values of the form.'
|
||||
},
|
||||
|
||||
displayType: {
|
||||
fieldType: 'boolean',
|
||||
type: 'static',
|
||||
|
||||
Reference in New Issue
Block a user