From a9ef31f314607cf3befae03ce5463618a44a5197 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 14 Jun 2025 09:55:51 +0200 Subject: [PATCH] iterate --- .../apps/components/GroupWrapper.svelte | 11 +- .../components/buttons/AppFormButton.svelte | 4 +- .../components/buttons/AppSchemaForm.svelte | 17 +- .../display/AppDisplayComponentByJobId.svelte | 51 ++-- .../components/display/AppRecomputeAll.svelte | 4 +- .../apps/components/display/AppText.svelte | 97 ++++--- .../helpers/RunnableComponent.svelte | 6 +- .../components/layout/AppContainer.svelte | 38 ++- .../components/apps/editor/AppInputs.svelte | 8 +- .../apps/editor/SubGridEditor.svelte | 237 ++++++++++-------- .../editor/component/ComponentInner.svelte | 6 +- .../componentsPanel/CssHelperPanel.svelte | 6 +- .../editor/componentsPanel/CssSettings.svelte | 20 +- .../editor/componentsPanel/GroupList.svelte | 4 +- .../componentsPanel/QuickStyleMenu.svelte | 8 +- .../editor/componentsPanel/ThemeList.svelte | 14 +- .../editor/componentsPanel/ThemeRow.svelte | 33 +-- .../editor/contextPanel/DebugPanel.svelte | 67 ++--- .../editor/contextPanel/LazyModePanel.svelte | 20 +- .../contextPanel/components/Output.svelte | 30 ++- .../InlineScriptEditor.svelte | 3 +- .../InlineScriptHiddenRunnable.svelte | 12 +- .../settingsPanel/CSSMigrationModal.svelte | 24 +- .../settingsPanel/ComponentControl.svelte | 34 +-- .../ComponentInputTypeEditor.svelte | 2 +- .../settingsPanel/ContextVariables.svelte | 4 +- .../settingsPanel/DeleteComponent.svelte | 6 +- .../editor/settingsPanel/GridCondition.svelte | 76 +++--- .../apps/editor/settingsPanel/GridTab.svelte | 82 +++--- .../editor/settingsPanel/MenuItems.svelte | 3 +- .../settingsPanel/SelectedRunnable.svelte | 30 ++- .../editor/settingsPanel/StylePanel.svelte | 59 ++--- .../editor/settingsPanel/TableActions.svelte | 48 ++-- .../decisionTree/DecisionTreePreview.svelte | 16 +- .../inputEditor/EvalV2InputEditor.svelte | 4 +- .../inputEditor/RunnableInputEditor.svelte | 12 +- .../inputEditor/TabSelectInput.svelte | 8 +- .../script/shared/ScriptTriggers.svelte | 61 +++-- .../apps/svelte-grid/MoveResize.svelte | 127 ++++++---- .../RawAppInlineScriptPanelList.svelte | 15 +- .../tutorials/app/ConnectionTutorial.svelte | 14 +- .../wizards/TableActionsWizard.svelte | 34 ++- 42 files changed, 780 insertions(+), 575 deletions(-) diff --git a/frontend/src/lib/components/apps/components/GroupWrapper.svelte b/frontend/src/lib/components/apps/components/GroupWrapper.svelte index b41d20e654..e7e7555ca6 100644 --- a/frontend/src/lib/components/apps/components/GroupWrapper.svelte +++ b/frontend/src/lib/components/apps/components/GroupWrapper.svelte @@ -3,10 +3,15 @@ import type { Writable } from 'svelte/store' import type { GroupContext } from '../types' - export let context: Writable> - export let id: string + interface Props { + context: Writable> + id: string + children?: import('svelte').Snippet + } + + let { context, id, children }: Props = $props() setContext('GroupContext', { id, context }) - +{@render children?.()} diff --git a/frontend/src/lib/components/apps/components/buttons/AppFormButton.svelte b/frontend/src/lib/components/apps/components/buttons/AppFormButton.svelte index 4aa606da82..af4bf3da60 100644 --- a/frontend/src/lib/components/apps/components/buttons/AppFormButton.svelte +++ b/frontend/src/lib/components/apps/components/buttons/AppFormButton.svelte @@ -70,7 +70,7 @@ let errors: Record = {} - let css = $state(initCss($app?.css?.formbuttoncomponent, customCss)) + let css = $state(initCss(app?.css?.formbuttoncomponent, customCss)) let runnableWrapper: RunnableWrapper | undefined = $state() let loading = $state(false) let modal: AlwaysMountedModal | undefined = $state() @@ -93,7 +93,7 @@ {customCss} {key} bind:css={css[key]} - componentStyle={$app.css?.formbuttoncomponent} + componentStyle={app.css?.formbuttoncomponent} /> {/each} diff --git a/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte b/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte index 6caae874d9..f41e52dfd7 100644 --- a/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte +++ b/frontend/src/lib/components/apps/components/buttons/AppSchemaForm.svelte @@ -102,7 +102,7 @@ } } - let css = $state(initCss($app.css?.schemaformcomponent, customCss)) + let css = $state(initCss(app.css?.schemaformcomponent, customCss)) const resolvedConfig = $state( initConfig(components['schemaformcomponent'].initialData.configuration, configuration) @@ -125,7 +125,15 @@ return policy } $effect(() => { - args && untrack(() => handleArgsChange()) + if (!args) return + { + if (args && typeof args === 'object') { + for (const key in args) { + args[key] + } + } + } + untrack(() => handleArgsChange()) }) $effect(() => { outputs.valid.set(valid) @@ -152,7 +160,7 @@ {customCss} {key} bind:css={css[key]} - componentStyle={$app.css?.schemaformcomponent} + componentStyle={app.css?.schemaformcomponent} /> {/each} @@ -164,8 +172,7 @@ >
- !$connectingInput.opened && selectId(e as PointerEvent, id, selectedComponent, $app) + (e) => !$connectingInput.opened && selectId(e as PointerEvent, id, selectedComponent, app) )} > | undefined = undefined - export let configuration: RichConfigurations - export let render: boolean + interface Props { + id: string + initializing?: boolean | undefined + customCss?: ComponentCustomCSS<'jobiddisplaycomponent'> | undefined + configuration: RichConfigurations + render: boolean + } + + let { + id, + initializing = $bindable(false), + customCss = undefined, + configuration, + render + }: Props = $props() const { app, worldStore, workspace, appPath } = getContext('AppViewerContext') const requireHtmlApproval = getContext(IS_APP_PUBLIC_CONTEXT_KEY) - let resolvedConfig = initConfig( - components['jobiddisplaycomponent'].initialData.configuration, - configuration + let resolvedConfig = $state( + initConfig(components['jobiddisplaycomponent'].initialData.configuration, configuration) ) const outputs = initOutput($worldStore, id, { @@ -40,18 +49,20 @@ initializing = false - let css = initCss($app.css?.jobiddisplaycomponent, customCss) + let css = $state(initCss(app.css?.jobiddisplaycomponent, customCss)) - let testJobLoader: TestJobLoader | undefined = undefined - let testIsLoading: boolean = false - let testJob: Job | undefined = undefined + let testJobLoader: TestJobLoader | undefined = $state(undefined) + let testIsLoading: boolean = $state(false) + let testJob: Job | undefined = $state(undefined) - $: if (resolvedConfig.jobId) { - outputs.loading.set(true) - testJobLoader?.watchJob(resolvedConfig?.['jobId']) - } + $effect(() => { + if (resolvedConfig.jobId) { + outputs.loading.set(true) + testJobLoader?.watchJob(resolvedConfig?.['jobId']) + } + }) - let result: any = undefined + let result: any = $state(undefined) {#each Object.keys(components['jobiddisplaycomponent'].initialData.configuration) as key (key)} @@ -69,7 +80,7 @@ {customCss} {key} bind:css={css[key]} - componentStyle={$app.css?.jobiddisplaycomponent} + componentStyle={app.css?.jobiddisplaycomponent} /> {/each} @@ -101,13 +112,13 @@
diff --git a/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte b/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte index e356525cc9..5d4684c256 100644 --- a/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte +++ b/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte @@ -35,7 +35,7 @@ initializing = false - let css = initCss($app.css?.recomputeallcomponent, customCss) + let css = initCss(app.css?.recomputeallcomponent, customCss) $: resolvedConfig.defaultRefreshInterval && handleRefreshInterval() @@ -68,7 +68,7 @@ {customCss} {key} bind:css={css[key]} - componentStyle={$app.css?.recomputeallcomponent} + componentStyle={app.css?.recomputeallcomponent} /> {/each} diff --git a/frontend/src/lib/components/apps/components/display/AppText.svelte b/frontend/src/lib/components/apps/components/display/AppText.svelte index aa140273f7..89df498059 100644 --- a/frontend/src/lib/components/apps/components/display/AppText.svelte +++ b/frontend/src/lib/components/apps/components/display/AppText.svelte @@ -1,4 +1,7 @@ {#each Object.keys(components['textcomponent'].initialData.configuration) as key (key)} @@ -157,22 +178,22 @@ {customCss} {key} bind:css={css[key]} - componentStyle={$app.css?.textcomponent} + componentStyle={app.css?.textcomponent} /> {/each} - +
{ + ondblclick={() => { if (!editorMode) { editorMode = true document.getElementById(`text-${id}`)?.focus() } }} - on:keydown|stopPropagation + onkeydown={stopPropagation(bubble('keydown'))} > {#if $mode == 'dnd' && editorMode && (componentInput?.type == 'template' || componentInput?.type == 'templatev2')} @@ -187,20 +208,20 @@ horizontalAlignment === 'center' ? 'text-center' : horizontalAlignment === 'right' - ? 'text-right' - : 'text-left' + ? 'text-right' + : 'text-left' )} - on:pointerdown|stopPropagation + onpointerdown={stopPropagation(bubble('pointerdown'))} style={css?.text?.style} id={`text-${id}`} - on:pointerenter={() => { + onpointerenter={() => { const elem = document.getElementById(`text-${id}`) if (elem) { elem.focus() } }} {rows} - on:input={onInput} + oninput={onInput} value={editableValue} > @@ -215,7 +236,7 @@ {/if}
{:else} - +
- {#if $app.subgrids?.[`${id}-0`]} + {#if app.subgrids?.[`${id}-0`]} {/if}
-{:else if $app.subgrids?.[`${id}-0`]} +{:else if app.subgrids?.[`${id}-0`]} diff --git a/frontend/src/lib/components/apps/editor/AppInputs.svelte b/frontend/src/lib/components/apps/editor/AppInputs.svelte index ed9591903c..072cc91c30 100644 --- a/frontend/src/lib/components/apps/editor/AppInputs.svelte +++ b/frontend/src/lib/components/apps/editor/AppInputs.svelte @@ -9,7 +9,7 @@ const { app } = getContext('AppViewerContext') - let resourceOnly: boolean = true + let resourceOnly: boolean = $state(true) @@ -19,7 +19,7 @@
- {#each allItems($app.grid, $app.subgrids) as gridItem (gridItem.data.id)} + {#each allItems(app.grid, app.subgrids) as gridItem (gridItem.data.id)} {#if gridItem?.data?.type === 'tablecomponent'}
@@ -52,10 +52,10 @@ {/each}
-{#if $app?.hiddenInlineScripts?.length > 0} +{#if app?.hiddenInlineScripts?.length > 0}
Background runnable inputs
- {#each $app?.hiddenInlineScripts ?? [] as script, index (script.name)} + {#each app?.hiddenInlineScripts ?? [] as script, index (script.name)}
{script.name}
diff --git a/frontend/src/lib/components/apps/editor/SubGridEditor.svelte b/frontend/src/lib/components/apps/editor/SubGridEditor.svelte index 38b6f00dff..f0874863ca 100644 --- a/frontend/src/lib/components/apps/editor/SubGridEditor.svelte +++ b/frontend/src/lib/components/apps/editor/SubGridEditor.svelte @@ -1,4 +1,6 @@ -{#if everVisible || $app.eagerRendering} +{#if everVisible || app.eagerRendering}
-{:else if $app.lazyInitRequire == undefined} - {#each $app?.subgrids?.[subGridId] ?? [] as item} +{:else if app.lazyInitRequire == undefined} + {#each app?.subgrids?.[subGridId] ?? [] as item} {/each} {/if} diff --git a/frontend/src/lib/components/apps/editor/component/ComponentInner.svelte b/frontend/src/lib/components/apps/editor/component/ComponentInner.svelte index 2397447792..89c851f09e 100644 --- a/frontend/src/lib/components/apps/editor/component/ComponentInner.svelte +++ b/frontend/src/lib/components/apps/editor/component/ComponentInner.svelte @@ -94,7 +94,11 @@ }: Props = $props() - + { + console.log(`error in rendering component ${component.id}`, e) + }} +> {#if component.type === 'displaycomponent'} { - if ($app.css != undefined) { - if (type && e.detail && $app.css[type] == undefined) { - $app.css[type] = Object.fromEntries((ids ?? []).map(({ id }) => [id, {}])) + if (app.css != undefined) { + if (type && e.detail && app.css[type] == undefined) { + app.css[type] = Object.fromEntries((ids ?? []).map(({ id }) => [id, {}])) } } }} diff --git a/frontend/src/lib/components/apps/editor/componentsPanel/CssSettings.svelte b/frontend/src/lib/components/apps/editor/componentsPanel/CssSettings.svelte index bcab5c849f..4c1763302f 100644 --- a/frontend/src/lib/components/apps/editor/componentsPanel/CssSettings.svelte +++ b/frontend/src/lib/components/apps/editor/componentsPanel/CssSettings.svelte @@ -16,13 +16,13 @@ const { app } = getContext('AppViewerContext') - let cssEditor: SimpleEditor | undefined = undefined - let alertHeight: number | undefined = undefined - let themeViewer: any = undefined - let selectedTab: 'css' | 'theme' = 'css' + let cssEditor: SimpleEditor | undefined = $state(undefined) + let alertHeight: number | undefined = $state(undefined) + let themeViewer: any = $state(undefined) + let selectedTab: 'css' | 'theme' = $state('css') function insertSelector(selector: string) { - if ($app?.theme?.type === 'path') { + if (app?.theme?.type === 'path') { sendUserToast( 'You cannot edit the theme because it is a path theme. Fork the theme to edit it.', true @@ -70,25 +70,25 @@
{/if}
- {#if $app.theme?.type === 'inlined'} + {#if app.theme?.type === 'inlined'} {:else} - +
{/if} - {#if $app?.theme?.type !== 'path' || $app.theme.path !== row.path} + {#if app?.theme?.type !== 'path' || app.theme.path !== row.path} diff --git a/frontend/src/lib/components/apps/editor/contextPanel/DebugPanel.svelte b/frontend/src/lib/components/apps/editor/contextPanel/DebugPanel.svelte index d8cf6d6fa2..bbc57f5fc2 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/DebugPanel.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/DebugPanel.svelte @@ -12,34 +12,38 @@ const { app, initialized } = getContext('AppViewerContext') - $: unintitializedComponents = allItems($app.grid, $app.subgrids) - .map((x) => x.id) - .filter((x) => !$initialized.initializedComponents?.includes(x)) - .sort() + let unintitializedComponents = $derived( + allItems(app.grid, app.subgrids) + .map((x) => x.id) + .filter((x) => !$initialized.initializedComponents?.includes(x)) + .sort() + ) - $: subgridsErrors = Object.keys($app.subgrids ?? {}) - .map((x) => { - const parentId = x.split('-')[0] - const parent = findGridItem($app, parentId) - const subgrid = x.replace(`${parentId}-`, '') - if (subgrid == '-1') { - return { - subGridId: x, - error: 'Invalid subgrid index -1 ' + let subgridsErrors = $derived( + Object.keys(app.subgrids ?? {}) + .map((x) => { + const parentId = x.split('-')[0] + const parent = findGridItem(app, parentId) + const subgrid = x.replace(`${parentId}-`, '') + if (subgrid == '-1') { + return { + subGridId: x, + error: 'Invalid subgrid index -1 ' + } + } else if (parent === undefined) { + return { + subGridId: x, + error: 'Parent not found' + } + } else if (parent?.data?.numberOfSubgrids === undefined) { + return { + subGridId: x, + error: 'Parent is not a container' + } } - } else if (parent === undefined) { - return { - subGridId: x, - error: 'Parent not found' - } - } else if (parent?.data?.numberOfSubgrids === undefined) { - return { - subGridId: x, - error: 'Parent is not a container' - } - } - }) - .filter(Boolean) + }) + .filter(Boolean) + )
@@ -79,7 +83,7 @@ {#each unintitializedComponents as c} - {@const item = findGridItem($app, c)} + {@const item = findGridItem(app, c)} {#if !item}
Item {c} not found
{:else} @@ -107,8 +111,8 @@ }} size="xs2" on:click={() => { - let parent = findGridItemParentGrid($app, c) - deleteGridItem($app, item.data, parent) // $app = $app + let parent = findGridItemParentGrid(app, c) + deleteGridItem(app, item.data, parent) // $app = $app }} > Remove @@ -162,9 +166,8 @@ }} size="xs2" on:click={() => { - if ($app.subgrids && s) { - delete $app.subgrids[s.subGridId] - $app = { ...$app } + if (app.subgrids && s) { + delete app.subgrids[s.subGridId] } }} > diff --git a/frontend/src/lib/components/apps/editor/contextPanel/LazyModePanel.svelte b/frontend/src/lib/components/apps/editor/contextPanel/LazyModePanel.svelte index 534be983ac..be4e20b948 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/LazyModePanel.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/LazyModePanel.svelte @@ -9,10 +9,10 @@ import ToggleButton from '$lib/components/common/toggleButton-v2/ToggleButton.svelte' const { app } = getContext('AppViewerContext') - let code = $state(JSON.stringify($app.lazyInitRequire)) + let code = $state(JSON.stringify(app.lazyInitRequire)) let selectedRendering = $state( - $app.eagerRendering ? 'eager' : $app.lazyInitRequire ? 'lazy' : 'semi-lazy' + app.eagerRendering ? 'eager' : app.lazyInitRequire ? 'lazy' : 'semi-lazy' ) @@ -32,15 +32,15 @@ bind:selected={selectedRendering} on:selected={(e) => { if (e.detail == 'eager') { - $app.eagerRendering = true - $app.lazyInitRequire = undefined + app.eagerRendering = true + app.lazyInitRequire = undefined } else if (e.detail == 'semi-lazy') { - $app.eagerRendering = undefined - $app.lazyInitRequire = undefined + app.eagerRendering = undefined + app.lazyInitRequire = undefined } else { - $app.eagerRendering = undefined - $app.lazyInitRequire = [] - code = JSON.stringify($app.lazyInitRequire) + app.eagerRendering = undefined + app.lazyInitRequire = [] + code = JSON.stringify(app.lazyInitRequire) } }} > @@ -65,7 +65,7 @@ {:else if selectedRendering == 'lazy'}
- + {'e.g: ["a", "b"]'}, no need to put background runnables ids diff --git a/frontend/src/lib/components/apps/editor/contextPanel/components/Output.svelte b/frontend/src/lib/components/apps/editor/contextPanel/components/Output.svelte index c030207504..e585eafbe6 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/components/Output.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/components/Output.svelte @@ -7,18 +7,24 @@ const { connectingInput } = getContext('AppViewerContext') - export let id: string - export let first: boolean = false - export let label: string - export let renderRec: boolean + interface Props { + id: string + first?: boolean + label: string + renderRec: boolean + } + + let { id, first = false, label, renderRec }: Props = $props() - - { - $connectingInput = connectInput($connectingInput, id, detail) - }} - /> + + {#snippet children({ render })} + { + $connectingInput = connectInput($connectingInput, id, detail) + }} + /> + {/snippet} diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte index b374255ce0..7c808392af 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte @@ -30,8 +30,7 @@ stateId, worldStore, state: stateStore, - appPath, - app + appPath } = getContext('AppViewerContext') interface Props { diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptHiddenRunnable.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptHiddenRunnable.svelte index aca0f9c043..6faeb27af2 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptHiddenRunnable.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptHiddenRunnable.svelte @@ -6,9 +6,13 @@ import type { Runnable, StaticAppInput } from '../../inputType' import { createEventDispatcher, getContext } from 'svelte' - export let runnable: HiddenRunnable - export let id: string - export let transformer: boolean + interface Props { + runnable: HiddenRunnable + id: string + transformer: boolean + } + + let { runnable = $bindable(), id, transformer }: Props = $props() const { runnableComponents, app } = getContext('AppViewerContext') async function fork(nrunnable: Runnable) { @@ -69,7 +73,7 @@ /> {:else} onPick(e.detail)} on:delete showScriptPicker diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/CSSMigrationModal.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/CSSMigrationModal.svelte index 1955e636c2..1225bd2e2f 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/CSSMigrationModal.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/CSSMigrationModal.svelte @@ -71,7 +71,7 @@ } function appendMigrationsToCss(migrations: Map) { - const theme = $app.theme + const theme = app.theme if (theme?.type === 'path') { sendUserToast( @@ -111,7 +111,7 @@ theme.css = cssString - $app.theme = theme + app.theme = theme } } @@ -167,7 +167,7 @@
{/if} - {#if component?.type && $app.css} + {#if component?.type && app.css} {#each Object.keys(component.customCss ?? {}) as cssKey} {#if component.customCss?.[cssKey].style != undefined && component.customCss[cssKey].style !== ''}
@@ -215,15 +215,15 @@ {/each} {/if} - {#if hasStyles(component?.type ? $app.css?.[component?.type] : undefined)} + {#if hasStyles(component?.type ? app.css?.[component?.type] : undefined)}
Global: {component?.type ? ccomponents[component.type]?.name : ''}
{/if} - {#if component?.type && $app.css} - {#each Object.keys($app.css[component?.type] ?? {}) as cssKey} - {#if type && $app.css?.[type]?.[cssKey].style != undefined && $app.css[type]?.[cssKey].style !== ''} + {#if component?.type && app.css} + {#each Object.keys(app.css[component?.type] ?? {}) as cssKey} + {#if type && app.css?.[type]?.[cssKey].style != undefined && app.css[type]?.[cssKey].style !== ''}
@@ -236,9 +236,9 @@ color="dark" size="xs" on:click={() => { - if (type && $app.css?.[type]) { - setOrUpdateMigration(cssKey, $app.css[type][cssKey].style) - $app.css[type][cssKey].style = '' + if (type && app.css?.[type]) { + setOrUpdateMigration(cssKey, app.css[type][cssKey].style) + app.css[type][cssKey].style = '' } }} endIcon={{ icon: MoveRight }} @@ -247,14 +247,14 @@
- +
Preview
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentControl.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentControl.svelte index 501c3072be..9b9d1f3563 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentControl.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentControl.svelte @@ -7,29 +7,35 @@ import typescript from 'svelte-highlight/languages/typescript' import { Button } from '$lib/components/common' import HighlightTheme from '$lib/components/HighlightTheme.svelte' - export let type: keyof typeof components + interface Props { + type: keyof typeof components + } + + let { type }: Props = $props() const componentControls = getComponentControl(type) - let collapsed: boolean = true + let collapsed: boolean = $state(true) {#if componentControls?.length > 0} -
- -
+ {#snippet action()} +
+ +
+ {/snippet} {#if collapsed}
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte index 568c49f576..aed74d8e65 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte @@ -17,7 +17,7 @@ let { componentInput = $bindable(), disableStatic = false, evalV2editor }: Props = $props() - const { onchange, connectingInput, app } = getContext('AppViewerContext') + const { onchange, connectingInput } = getContext('AppViewerContext') const dispatch = createEventDispatcher() diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ContextVariables.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ContextVariables.svelte index 895f41fc0a..84b32d02fd 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ContextVariables.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ContextVariables.svelte @@ -47,7 +47,7 @@ function addGridItemContext(parentId: string) { if (!parentId) return - const gridItem = findGridItem($app, parentId) + const gridItem = findGridItem(app, parentId) addParentContextVariable(gridItem) } @@ -62,7 +62,7 @@ function findParentsContextVariables(id: string): void { if (!id) return - const allParents = dfs($app.grid, id, $app.subgrids ?? {}) + const allParents = dfs(app.grid, id, app.subgrids ?? {}) if (!allParents) return diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/DeleteComponent.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/DeleteComponent.svelte index 49ea54f231..17cd362c6f 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/DeleteComponent.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/DeleteComponent.svelte @@ -21,8 +21,8 @@ export function removeGridElement() { const id = $selectedComponent?.[0] - const componentSetting = findComponentSettings($app, id) - push(history, $app) + const componentSetting = findComponentSettings(app, id) + push(history, app) const onDeleteComponentControl = id ? $componentControl[id]?.onDelete : undefined if (onDeleteComponentControl) { @@ -44,7 +44,7 @@ $selectedComponent = undefined $focusedGrid = undefined if (componentSetting?.item && !noGrid) { - let ids = deleteGridItem($app, componentSetting?.item.data, componentSetting?.parent) + let ids = deleteGridItem(app, componentSetting?.item.data, componentSetting?.parent) for (const key of ids) { delete $runnableComponents[key] } diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/GridCondition.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/GridCondition.svelte index b7614d9586..e65e9168ee 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/GridCondition.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/GridCondition.svelte @@ -13,24 +13,32 @@ import { deleteGridItem } from '../appUtils' import type { AppComponent } from '../component' - export let conditions: RichConfiguration[] = [] - export let component: AppComponent + interface Props { + conditions?: RichConfiguration[] + component: AppComponent + } - let items = conditions.slice(0, -1).map((condition, index) => { - return { value: condition, id: generateRandomString(), originalIndex: index } + let { conditions = $bindable([]), component = $bindable() }: Props = $props() + + let items = $state( + conditions.slice(0, -1).map((condition, index) => { + return { value: condition, id: generateRandomString(), originalIndex: index } + }) + ) + + $effect.pre(() => { + conditions = items + .map((item) => item.value) + .concat([ + { + type: 'evalv2', + expr: 'true', + fieldType: 'boolean', + connections: [] + } + ]) }) - $: conditions = items - .map((item) => item.value) - .concat([ - { - type: 'evalv2', - expr: 'true', - fieldType: 'boolean', - connections: [] - } - ]) - const { app, runnableComponents, componentControl } = getContext('AppViewerContext') @@ -49,7 +57,7 @@ const newSubgrids = {} for (let i = 0; i < items.length; i++) { newSubgrids[`${component.id}-${i}`] = - $app!.subgrids![`${component.id}-${items[i].originalIndex}`] ?? [] + app!.subgrids![`${component.id}-${items[i].originalIndex}`] ?? [] } // update originalIndex @@ -57,8 +65,8 @@ item.originalIndex = i }) - $app!.subgrids = { - ...$app!.subgrids, + app!.subgrids = { + ...app!.subgrids, ...newSubgrids } // $app = $app @@ -71,8 +79,8 @@ function deleteSubgrid(index: number) { let subgrid = `${component.id}-${index}` - for (const item of $app!.subgrids![subgrid]) { - const components = deleteGridItem($app, item.data, subgrid) + for (const item of app!.subgrids![subgrid]) { + const components = deleteGridItem(app, item.data, subgrid) for (const key in components) { delete $runnableComponents[key] } @@ -80,7 +88,7 @@ $runnableComponents = $runnableComponents for (let i = index; i < items.length; i++) { - $app!.subgrids![`${component.id}-${i}`] = $app!.subgrids![`${component.id}-${i + 1}`] + app!.subgrids![`${component.id}-${i}`] = app!.subgrids![`${component.id}-${i + 1}`] } // Remove the corresponding item from the items array @@ -93,20 +101,20 @@ }) items = nitems - delete $app!.subgrids![`${component.id}-${items.length + 1}`] // $app = $app + delete app!.subgrids![`${component.id}-${items.length + 1}`] // $app = $app } function addCondition(): void { const numberOfConditions = conditions.length - if (!$app.subgrids) { - $app.subgrids = {} + if (!app.subgrids) { + app.subgrids = {} } - $app.subgrids[`${component.id}-${numberOfConditions}`] = - $app.subgrids[`${component.id}-${numberOfConditions - 1}`] + app.subgrids[`${component.id}-${numberOfConditions}`] = + app.subgrids[`${component.id}-${numberOfConditions - 1}`] - $app.subgrids[`${component.id}-${numberOfConditions - 1}`] = [] + app.subgrids[`${component.id}-${numberOfConditions - 1}`] = [] const newCondition: AppInputSpec<'boolean', boolean> = { type: 'evalv2', @@ -139,8 +147,8 @@ flipDurationMs: 200, dropTargetStyle: {} }} - on:consider={handleConsider} - on:finalize={handleFinalize} + onconsider={handleConsider} + onfinalize={handleFinalize} > {#each items as item, index (item.id)} {@const condition = item.value} @@ -166,14 +174,14 @@
- - -
deleteSubgrid(index)}> + + +
deleteSubgrid(index)}>
- - + +
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte index e41db98200..ead9ce5bf8 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte @@ -1,4 +1,7 @@ diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/StylePanel.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/StylePanel.svelte index 1e89ab908a..eb94da1399 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/StylePanel.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/StylePanel.svelte @@ -20,28 +20,29 @@ const { app, cssEditorOpen, selectedComponent } = getContext('AppViewerContext') - let component: AppComponent | undefined - $: { - const newComponent = findComponentSettings($app, $selectedComponent?.[0])?.item?.data + let component: AppComponent | undefined = $state() + $effect.pre(() => { + const newComponent = findComponentSettings(app, $selectedComponent?.[0])?.item?.data if (component != newComponent) { component = newComponent } - } + }) - let tab: 'local' | 'global' = 'local' - let overrideGlobalCSS: (() => void) | undefined = undefined - let overrideLocalCSS: (() => void) | undefined = undefined - $: type = component?.type - let migrationModal: CssMigrationModal | undefined = undefined + let tab: 'local' | 'global' = $state('local') + let overrideGlobalCSS: (() => void) | undefined = $state(undefined) + let overrideLocalCSS: (() => void) | undefined = $state(undefined) + let type = $derived(component?.type) + let migrationModal: CssMigrationModal | undefined = $state(undefined) - $: customCssByComponentType = - component?.type && $app.css - ? Object.entries($app.css[component.type] || {}).map(([id, v]) => ({ + let customCssByComponentType = $derived( + component?.type && app.css + ? Object.entries(app.css[component.type] || {}).map(([id, v]) => ({ id, forceStyle: v?.style != undefined, forceClass: v?.['class'] != undefined })) : undefined + ) function copyLocalToGlobal(name: string, value: ComponentCssProperty | undefined) { if (!value) { @@ -51,18 +52,16 @@ if (!type) return - if (hasStyleValue($app.css?.[type]?.[name])) { + if (hasStyleValue(app.css?.[type]?.[name])) { overrideGlobalCSS = () => { - $app.css![type]![name] = JSON.parse(JSON.stringify(value)) - app.set($app) + app.css![type]![name] = JSON.parse(JSON.stringify(value)) } } else { - if (!$app.css![type]) { + if (!app.css![type]) { initGlobalCss() } - $app.css![type]![name] = JSON.parse(JSON.stringify(value)) - app.set($app) + app.css![type]![name] = JSON.parse(JSON.stringify(value)) sendUserToast('Global CSS copied') } } @@ -75,11 +74,9 @@ if (hasStyleValue(value)) { overrideLocalCSS = () => { component!.customCss![id] = JSON.parse(JSON.stringify(value)) - app.set($app) } } else { component!.customCss![id] = JSON.parse(JSON.stringify(value)) - app.set($app) sendUserToast('Local CSS copied') } } @@ -88,21 +85,20 @@ function initGlobalCss() { // If the global css is not initialised, we initialise it. // Should only happen once per app - if (!$app.css) { - $app.css = {} + if (!app.css) { + app.css = {} } // If the global css for this component type is not initialised, we initialise it. // Should only happen once per component type if ( - $app.css && + app.css && component && - !$app.css[component.type]?.style && + !app.css[component.type]?.style && components[component.type] && - $app.css[component.type] === undefined + app.css[component.type] === undefined ) { - $app.css[component.type] = JSON.parse(JSON.stringify(components[component.type].customCss)) - app.set($app) + app.css[component.type] = JSON.parse(JSON.stringify(components[component.type].customCss)) } } @@ -196,13 +192,12 @@ wmClass={getSelector(name)} componentType={component.type} bind:value={component.customCss[name]} - on:change={() => app.set($app)} shouldDisplayRight={hasStyleValue(component.customCss[name])} on:right={() => { copyLocalToGlobal(name, component?.customCss?.[name]) tab = 'global' }} - overridding={hasStyleValue($app.css?.[component.type]?.[name]) && + overridding={hasStyleValue(app.css?.[component.type]?.[name]) && hasStyleValue(component.customCss[name])} />
@@ -214,16 +209,16 @@ {#if type} {#each customCssByComponentType ?? [] as { id, forceStyle, forceClass }}
- {#if $app.css && type && $app.css[type] && component?.customCss} + {#if app.css && type && app.css[type] && component?.customCss} { copyGlobalToLocal( id, - component?.type ? $app?.css?.[component?.type]?.[id] : undefined + component?.type ? app?.css?.[component?.type]?.[id] : undefined ) tab = 'local' }} diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte index 938d7cd0e3..0d2a4802e9 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte @@ -1,4 +1,7 @@ {#if hasNoTriggers} @@ -117,7 +134,7 @@ {#if isFrontend}
- + {/snippet}
@@ -68,7 +71,7 @@ {selectedRunnable === id ? 'border-blue-500 bg-blue-100 dark:bg-frost-900/50' : 'hover:bg-blue-50 dark:hover:bg-frost-900/50'}" - on:click={() => (selectedRunnable = id)} + onclick={() => (selectedRunnable = id)} > {runnable?.name} {id} diff --git a/frontend/src/lib/components/tutorials/app/ConnectionTutorial.svelte b/frontend/src/lib/components/tutorials/app/ConnectionTutorial.svelte index 2c4ec053f6..ab51b8c2b5 100644 --- a/frontend/src/lib/components/tutorials/app/ConnectionTutorial.svelte +++ b/frontend/src/lib/components/tutorials/app/ConnectionTutorial.svelte @@ -8,10 +8,14 @@ import { clickButtonBySelector } from '../utils' import { updateProgress } from '$lib/tutorialUtils' - export let name: string - export let index: number + interface Props { + name: string + index: number + } - let tutorial: Tutorial | undefined = undefined + let { name, index }: Props = $props() + + let tutorial: Tutorial | undefined = $state(undefined) const { app, selectedComponent, focusedGrid } = getContext('AppViewerContext') const { history } = getContext('AppEditorContext') @@ -21,10 +25,10 @@ } function addComponent(): void { - push(history, $app) + push(history, app) const id = insertNewGridItem( - $app, + app, appComponentFromType('textcomponent') as (id: string) => AppComponent, $focusedGrid ) diff --git a/frontend/src/lib/components/wizards/TableActionsWizard.svelte b/frontend/src/lib/components/wizards/TableActionsWizard.svelte index 7d1e7f6109..49f2a04f4f 100644 --- a/frontend/src/lib/components/wizards/TableActionsWizard.svelte +++ b/frontend/src/lib/components/wizards/TableActionsWizard.svelte @@ -12,11 +12,23 @@ CheckboxComponent, SelectComponent } from '../apps/editor/component' - export let actionsOrder: RichConfiguration | undefined = undefined - export let selectedId: string | undefined = undefined - export let components: - | (BaseAppComponent & (ButtonComponent | CheckboxComponent | SelectComponent))[] - | undefined + interface Props { + actionsOrder?: RichConfiguration | undefined + selectedId?: string | undefined + components: + | (BaseAppComponent & (ButtonComponent | CheckboxComponent | SelectComponent))[] + | undefined + trigger?: import('svelte').Snippet + } + + let { + actionsOrder = $bindable(undefined), + selectedId = undefined, + components, + trigger + }: Props = $props() + + const trigger_render = $derived(trigger) - - - - + {#snippet trigger()} + {@render trigger_render?.()} + {/snippet} + {#snippet content()}
{#if actionsOrder} @@ -93,5 +105,5 @@
-
+ {/snippet}