diff --git a/frontend/src/lib/components/SchemaEditor.svelte b/frontend/src/lib/components/SchemaEditor.svelte index e16de7d4a5..2a3cf1543c 100644 --- a/frontend/src/lib/components/SchemaEditor.svelte +++ b/frontend/src/lib/components/SchemaEditor.svelte @@ -18,6 +18,7 @@ const dispatch = createEventDispatcher() + export let lightMode: boolean = false export let schema: Schema = emptySchema() if (!schema) { schema = emptySchema() @@ -162,7 +163,7 @@ + ↑ + {/if} {#if i < Object.keys(schema.properties).length - 1} + class="text-lg mr-2 {isAnimated ? 'invisible' : ''}" + >↓ + {/if} diff --git a/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte b/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte new file mode 100644 index 0000000000..c46b7a49ab --- /dev/null +++ b/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte @@ -0,0 +1,54 @@ + + + + {#if result && Object.keys(result.properties).length > 0} +
+ !$connectingInput.opened && selectId(e, id, selectedComponent, $app)} + > + +
+ {:else} +

Empty form

+ {/if} +
diff --git a/frontend/src/lib/components/apps/editor/component/Component.svelte b/frontend/src/lib/components/apps/editor/component/Component.svelte index e2f5812340..68120e19f5 100644 --- a/frontend/src/lib/components/apps/editor/component/Component.svelte +++ b/frontend/src/lib/components/apps/editor/component/Component.svelte @@ -39,6 +39,7 @@ AppPdf } from '../../components' import AppMultiSelect from '../../components/inputs/AppMultiSelect.svelte' + import AppSchemaForm from '../../components/buttons/AppSchemaForm.svelte' export let component: AppComponent export let selected: boolean @@ -460,6 +461,13 @@ customCss={component.customCss} {render} /> + {:else if component.type === 'schemaformcomponent'} + {/if} diff --git a/frontend/src/lib/components/apps/editor/component/components.ts b/frontend/src/lib/components/apps/editor/component/components.ts index fb84fd72c8..5902c133da 100644 --- a/frontend/src/lib/components/apps/editor/component/components.ts +++ b/frontend/src/lib/components/apps/editor/component/components.ts @@ -105,6 +105,7 @@ export type HorizontalSplitPanesComponent = BaseComponent<'horizontalsplitpanesc panes: number[] } export type PdfComponent = BaseComponent<'pdfcomponent'> +export type Schemaformcomponent = BaseComponent<'schemaformcomponent'> export type TypedComponent = | DisplayComponent @@ -146,6 +147,7 @@ export type TypedComponent = | VerticalSplitPanesComponent | HorizontalSplitPanesComponent | PdfComponent + | Schemaformcomponent export type AppComponent = BaseAppComponent & TypedComponent @@ -1656,6 +1658,27 @@ Hello \${ctx.username} } } } + }, + schemaformcomponent: { + name: 'Schema Form', + icon: FileText, + dims: '3:8-8:12' as AppComponentDimensions, + customCss: { + container: { class: '', style: '' } + }, + initialData: { + componentInput: { + type: 'static', + fieldType: 'schema', + value: { + $schema: 'https://json-schema.org/draft/2020-12/schema', + properties: {}, + required: [], + type: 'object' + } + }, + configuration: {} + } } } as const diff --git a/frontend/src/lib/components/apps/editor/component/sets.ts b/frontend/src/lib/components/apps/editor/component/sets.ts index 91f33f2c4a..04c086acd6 100644 --- a/frontend/src/lib/components/apps/editor/component/sets.ts +++ b/frontend/src/lib/components/apps/editor/component/sets.ts @@ -34,7 +34,8 @@ const inputs: ComponentSet = { 'checkboxcomponent', 'selectcomponent', 'resourceselectcomponent', - 'multiselectcomponent' + 'multiselectcomponent', + 'schemaformcomponent' ] } as const diff --git a/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts b/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts index 089b3f2561..58324aa365 100644 --- a/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts +++ b/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts @@ -550,6 +550,10 @@ export const quickStyleProperties: Record< pdfcomponent: { container: containerDefaultProps }, + schemaformcomponent: { + container: containerDefaultProps, + button: buttonDefaultProps + }, formcomponent: { container: containerDefaultProps, button: buttonDefaultProps diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/StaticInputEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/StaticInputEditor.svelte index bdb0f2cadc..3887e7a1ca 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/StaticInputEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/StaticInputEditor.svelte @@ -11,6 +11,7 @@ import { DollarSign } from 'lucide-svelte' import Popover from '$lib/components/Popover.svelte' import Toggle from '$lib/components/Toggle.svelte' + import SchemaEditor from '$lib/components/SchemaEditor.svelte' export let componentInput: StaticInput | undefined export let fieldType: InputType | undefined = undefined @@ -110,6 +111,10 @@ {/if} {:else if fieldType === 'array'} + {:else if fieldType === 'schema'} +
+ +
{:else}
{:else} {/if} diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/script/shared/ScriptTriggers.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/script/shared/ScriptTriggers.svelte index d733b7492e..e8dbc7bbc2 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/script/shared/ScriptTriggers.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/script/shared/ScriptTriggers.svelte @@ -13,7 +13,6 @@ export let isFrontend: boolean = false export let dependencies: string[] = [] export let shoudlDisplayChangeEvents: boolean = false - export let isTriggerable: boolean = false $: changeEvents = isFrontend ? inlineScript?.refreshOn @@ -57,7 +56,7 @@ } -{#if isFrontend && !isTriggerable} +{#if isFrontend && shoudlDisplayChangeEvents}