From e19c8f47d0b0d1ec346138916a7ae24fafd480ee Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 29 Jun 2025 09:29:28 +0000 Subject: [PATCH] app svelte 5 improvements --- .../components/display/AppChartJsV2.svelte | 2 +- .../components/display/AppDownload.svelte | 48 +++++++++------ .../components/display/AppRecomputeAll.svelte | 37 ++++++++---- .../display/charts/AppAgCharts.svelte | 7 ++- .../display/dbtable/DeleteRow.svelte | 12 ++-- .../display/dbtable/InsertRowRunnable.svelte | 12 ++-- .../apps/components/inputs/AppCheckbox.svelte | 60 ++++++++++++------- .../components/inputs/AppSelectStep.svelte | 47 +++++++++------ .../components/inputs/AppUserResource.svelte | 43 ++++++++----- .../apps/components/layout/AppDrawer.svelte | 4 +- .../editor/settingsPanel/EventHandlers.svelte | 21 +++++-- 11 files changed, 189 insertions(+), 104 deletions(-) diff --git a/frontend/src/lib/components/apps/components/display/AppChartJsV2.svelte b/frontend/src/lib/components/apps/components/display/AppChartJsV2.svelte index 5b2a375aa2..d4b35a97f2 100644 --- a/frontend/src/lib/components/apps/components/display/AppChartJsV2.svelte +++ b/frontend/src/lib/components/apps/components/display/AppChartJsV2.svelte @@ -164,7 +164,7 @@ {#if data && resolvedConfig.type} {#key resolvedConfig.type} {#key options} - + {/key} {/key} {/if} diff --git a/frontend/src/lib/components/apps/components/display/AppDownload.svelte b/frontend/src/lib/components/apps/components/display/AppDownload.svelte index 7f6f2b100f..38e2a555f5 100644 --- a/frontend/src/lib/components/apps/components/display/AppDownload.svelte +++ b/frontend/src/lib/components/apps/components/display/AppDownload.svelte @@ -1,5 +1,5 @@ diff --git a/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte b/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte index e356525cc9..0206de22c0 100644 --- a/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte +++ b/frontend/src/lib/components/apps/components/display/AppRecomputeAll.svelte @@ -1,5 +1,5 @@ {#each Object.keys(components['recomputeallcomponent'].initialData.configuration) as key (key)} diff --git a/frontend/src/lib/components/apps/components/display/charts/AppAgCharts.svelte b/frontend/src/lib/components/apps/components/display/charts/AppAgCharts.svelte index b312e9328d..5597ab3d37 100644 --- a/frontend/src/lib/components/apps/components/display/charts/AppAgCharts.svelte +++ b/frontend/src/lib/components/apps/components/display/charts/AppAgCharts.svelte @@ -158,7 +158,10 @@ if (!resolvedDatasetsValues) { return } - const type = resolvedDatasetsValues[index].type + const type = resolvedDatasetsValues?.[index]?.type + if (!type) { + return + } if (type === 'range-bar' || type === 'range-area') { return { type: type, @@ -361,7 +364,7 @@ bind:darkMode on:change={(e) => { tick().then(() => { - updateChart() + chartInstance && resolvedDatasetsValues && updateChart() }) }} /> diff --git a/frontend/src/lib/components/apps/components/display/dbtable/DeleteRow.svelte b/frontend/src/lib/components/apps/components/display/dbtable/DeleteRow.svelte index f2093b8506..da7b285f0d 100644 --- a/frontend/src/lib/components/apps/components/display/dbtable/DeleteRow.svelte +++ b/frontend/src/lib/components/apps/components/display/dbtable/DeleteRow.svelte @@ -9,7 +9,11 @@ import { sendUserToast } from '$lib/toast' import { getDeleteInput } from './queries/delete' - export let id: string + interface Props { + id: string + } + + let { id }: Props = $props() const { worldStore } = getContext('AppViewerContext') @@ -19,10 +23,10 @@ jobId: undefined }) - let runnableComponent: RunnableComponent - let loading = false + let runnableComponent: RunnableComponent | undefined = $state() + let loading = $state(false) - let input: AppInput | undefined = undefined + let input: AppInput | undefined = $state(undefined) const dispatch = createEventDispatcher() diff --git a/frontend/src/lib/components/apps/components/display/dbtable/InsertRowRunnable.svelte b/frontend/src/lib/components/apps/components/display/dbtable/InsertRowRunnable.svelte index 953206f121..aa71b27e86 100644 --- a/frontend/src/lib/components/apps/components/display/dbtable/InsertRowRunnable.svelte +++ b/frontend/src/lib/components/apps/components/display/dbtable/InsertRowRunnable.svelte @@ -9,7 +9,11 @@ import { sendUserToast } from '$lib/toast' import { getInsertInput } from './queries/insert' - export let id: string + interface Props { + id: string + } + + let { id }: Props = $props() const { worldStore } = getContext('AppViewerContext') @@ -19,9 +23,9 @@ jobId: undefined }) - let runnableComponent: RunnableComponent - let loading = false - let input: AppInput | undefined = undefined + let runnableComponent: RunnableComponent | undefined = $state() + let loading = $state(false) + let input: AppInput | undefined = $state(undefined) const dispatch = createEventDispatcher() diff --git a/frontend/src/lib/components/apps/components/inputs/AppCheckbox.svelte b/frontend/src/lib/components/apps/components/inputs/AppCheckbox.svelte index 91a94db8ce..261eb67b65 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppCheckbox.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppCheckbox.svelte @@ -1,6 +1,6 @@ {#each Object.keys(components['checkboxcomponent'].initialData.configuration) as key (key)} diff --git a/frontend/src/lib/components/apps/components/inputs/AppSelectStep.svelte b/frontend/src/lib/components/apps/components/inputs/AppSelectStep.svelte index b6fb3a6e3c..75210022f0 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppSelectStep.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppSelectStep.svelte @@ -1,5 +1,5 @@ {#each Object.keys(components['selectstepcomponent'].initialData.configuration) as key (key)} @@ -112,7 +125,7 @@ class={twMerge(css?.container?.class, 'wm-select-step')} style={css?.container?.style} > -
+
getLabel(item))} hasValidations={false} diff --git a/frontend/src/lib/components/apps/components/inputs/AppUserResource.svelte b/frontend/src/lib/components/apps/components/inputs/AppUserResource.svelte index 93a54b7f4f..73d4060f0b 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppUserResource.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppUserResource.svelte @@ -17,17 +17,26 @@ import { twMerge } from 'tailwind-merge' import LightweightResourcePicker from '$lib/components/LightweightResourcePicker.svelte' - export let id: string - export let configuration: RichConfigurations - export let verticalAlignment: 'top' | 'center' | 'bottom' | undefined = undefined - export let customCss: ComponentCustomCSS<'userresourcecomponent'> | undefined = undefined - export let render: boolean + interface Props { + id: string + configuration: RichConfigurations + verticalAlignment?: 'top' | 'center' | 'bottom' | undefined + customCss?: ComponentCustomCSS<'userresourcecomponent'> | undefined + render: boolean + } + + let { + id, + configuration, + verticalAlignment = undefined, + customCss = undefined, + render + }: Props = $props() const { app, worldStore, componentControl } = getContext('AppViewerContext') - let resolvedConfig = initConfig( - components['userresourcecomponent'].initialData.configuration, - configuration + let resolvedConfig = $state( + initConfig(components['userresourcecomponent'].initialData.configuration, configuration) ) const iterContext = getContext('ListWrapperContext') @@ -37,16 +46,18 @@ result: undefined as string | undefined }) - let css = initCss($app.css?.['userresourcecomponent'], customCss) + let css = $state(initCss($app.css?.['userresourcecomponent'], customCss)) - $: classInput = twMerge( - 'windmillapp w-full px-2', - css?.input?.class ?? '', - 'wm-input', - 'wm-user-resource-select' + let classInput = $derived( + twMerge( + 'windmillapp w-full px-2', + css?.input?.class ?? '', + 'wm-input', + 'wm-user-resource-select' + ) ) - let value: string | undefined = outputs.result.peak()?.replace('$res:', '') + let value: string | undefined = $state(outputs.result.peak()?.replace('$res:', '')) value && assignValue(outputs.result.peak()) @@ -76,7 +87,7 @@ } } - let resourcePicker: LightweightResourcePicker | undefined = undefined + let resourcePicker: LightweightResourcePicker | undefined = $state(undefined) {#each Object.keys(components['userresourcecomponent'].initialData.configuration) as key (key)} diff --git a/frontend/src/lib/components/apps/components/layout/AppDrawer.svelte b/frontend/src/lib/components/apps/components/layout/AppDrawer.svelte index 679bb928c8..6116e93c26 100644 --- a/frontend/src/lib/components/apps/components/layout/AppDrawer.svelte +++ b/frontend/src/lib/components/apps/components/layout/AppDrawer.svelte @@ -1,6 +1,4 @@