From ee2a193958b87a7557eadfd7ea8231d109b9d41c Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Tue, 7 May 2024 18:04:12 +0200 Subject: [PATCH] feat(frontend): Improve app components (#3672) * fix(frontend): wip * fix(frontend): wip * fix(frontend): improve components * fix(frontend): improve components * fix(frontend): improve ranges * fix(frontend): fix build --- frontend/src/lib/assets/app.css | 1 + .../src/lib/components/DisplayResult.svelte | 19 ++-- .../apps/components/display/AppMap.svelte | 2 +- .../apps/components/display/AppPdf.svelte | 14 +-- .../components/inputs/AppDateInput.svelte | 2 +- .../components/inputs/AppMultiSelect.svelte | 106 +++++++++--------- .../components/inputs/AppNumberInput.svelte | 2 +- .../components/inputs/AppRangeInput.svelte | 81 +++++++------ .../apps/components/inputs/AppSelect.svelte | 1 + .../components/inputs/AppSliderInputs.svelte | 58 +++++----- .../components/inputs/AppTextInput.svelte | 1 + .../inputs/currency/AppCurrencyInput.svelte | 2 +- .../apps/editor/component/Component.svelte | 1 + .../apps/editor/component/components.ts | 14 ++- .../common/fileInput/FileInput.svelte | 2 +- .../common/fileUpload/FileUpload.svelte | 2 +- .../components/scriptEditor/LogPanel.svelte | 9 +- 17 files changed, 169 insertions(+), 148 deletions(-) diff --git a/frontend/src/lib/assets/app.css b/frontend/src/lib/assets/app.css index 8602ed3479..4a58b1c648 100644 --- a/frontend/src/lib/assets/app.css +++ b/frontend/src/lib/assets/app.css @@ -157,4 +157,5 @@ .app-editor-input { @apply rounded-component border border-gray-300 dark:border-gray-500 focus:border-gray-300 focus:dark:border-gray-500 focus:!ring-1 focus:!ring-blue-300; + @apply placeholder:text-gray-400 dark:placeholder:text-gray-600; } diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index d665f557b2..73c510bf42 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -11,7 +11,8 @@ PanelRightOpen, Table2, Braces, - Highlighter + Highlighter, + InfoIcon } from 'lucide-svelte' import Portal from 'svelte-portal' import ObjectViewer from './propertyPicker/ObjectViewer.svelte' @@ -26,7 +27,7 @@ import ToggleButtonGroup from './common/toggleButton-v2/ToggleButtonGroup.svelte' import ToggleButton from './common/toggleButton-v2/ToggleButton.svelte' import MapResult from './MapResult.svelte' - import Tooltip from '$lib/components/Tooltip.svelte' + import Popover from './Popover.svelte' export let result: any export let requireHtmlApproval = false @@ -304,13 +305,17 @@
{#if !disableExpand && !noControls} - - The result renderer in Windmill supports rich display rendering, allowing you to - customize the display format of your results. - + + The result renderer in Windmill supports rich display rendering, allowing you to + customize the display format of your results. + +
+ +
+ diff --git a/frontend/src/lib/components/apps/components/display/AppMap.svelte b/frontend/src/lib/components/apps/components/display/AppMap.svelte index 7aa941e7ff..cdf0560445 100644 --- a/frontend/src/lib/components/apps/components/display/AppMap.svelte +++ b/frontend/src/lib/components/apps/components/display/AppMap.svelte @@ -255,7 +255,7 @@ {/each} {#if render} -
+
{#if render} -
+
{#if source && zoom} {#if pages?.length}
diff --git a/frontend/src/lib/components/apps/components/inputs/AppDateInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppDateInput.svelte index a5445ad09c..2ffab7236d 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppDateInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppDateInput.svelte @@ -99,7 +99,7 @@ max={resolvedConfig.maxDate} placeholder="Type..." class={twMerge( - 'windmillapp w-full py-1.5 text-sm px-2 app-editor-input', + 'windmillapp w-full py-1.5 text-sm px-1 app-editor-input', css?.input?.class, 'wm-date-input' )} diff --git a/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte b/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte index 181a2dc731..b58f7d528d 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte @@ -20,6 +20,7 @@ export let configuration: RichConfigurations export let customCss: ComponentCustomCSS<'multiselectcomponent'> | undefined = undefined export let render: boolean + export let verticalAlignment: 'top' | 'center' | 'bottom' | undefined = undefined const [floatingRef, floatingContent] = createFloatingActions({ strategy: 'absolute', @@ -104,7 +105,6 @@ } let w = 0 - let h = 0 let open = false @@ -129,68 +129,74 @@ - +
{ + $selectedComponent = [id] + if (!e.shiftKey) { e.stopPropagation() } + selectedComponent.set([id]) }} use:floatingRef bind:clientWidth={w} - bind:clientHeight={h} > {#if !value || Array.isArray(value)} -
- { - if (event?.detail?.type === 'removeAll') { - outputs?.result.set([]) - } else { - outputs?.result.set([...(value ?? [])]) - } + { + if (event?.detail?.type === 'removeAll') { + outputs?.result.set([]) + } else { + outputs?.result.set([...(value ?? [])]) + } + }} + on:open={() => { + $selectedComponent = [id] + open = true + }} + on:close={() => { + open = false + }} + let:option + > + + +
{ + let newe = new MouseEvent('mouseup') + e.target?.['parentElement']?.dispatchEvent(newe) }} - on:open={() => { - $selectedComponent = [id] - open = true - }} - on:close={() => { - open = false - }} - let:option > - + {option} +
+
+ + + {:else} Value {value} is not an array {/if} diff --git a/frontend/src/lib/components/apps/components/inputs/AppNumberInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppNumberInput.svelte index 78f234dbd9..e4496c9849 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppNumberInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppNumberInput.svelte @@ -90,7 +90,7 @@ on:pointerdown|stopPropagation={() => ($selectedComponent = [id])} on:focus={() => ($selectedComponent = [id])} class={twMerge( - 'windmillapp w-full py-1.5 text-sm focus:ring-indigo-100 px-2', + 'windmillapp w-full py-1.5 px-2 text-sm app-editor-input', css?.input?.class ?? '', 'wm-number-input' )} diff --git a/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte index 0e1af0c103..fbea05a6d4 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte @@ -74,6 +74,10 @@ handles.forEach((handle) => (handle.style.cssText = css?.handles?.style ?? '')) } } + + const format = (v, i, p) => { + return `${v}` + } {#each Object.keys(components['rangecomponent'].initialData.configuration) as key (key)} @@ -99,13 +103,7 @@
-
- - {+(resolvedConfig.min ?? 0)} - +
-
- - {+(resolvedConfig.max ?? 1)} - -
-
- - {values[0]} - - - {values[1]} -
+ + diff --git a/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte b/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte index c16f0d5bd4..0a186dab86 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte @@ -221,6 +221,7 @@