mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 00:05:27 +00:00
* Monaco transparent bg
* started improving input transform form
* always show static/f selector
* fix connecting btn changing size
* pretty Fill Inputs button
* ResizeTransitionWrapper
* Prettier TemplateEditor
* prevent double onpointerdown when clicking button to close
* text hint
* force focus border for TemplateEditor
* styling in js mode
* update select style
* fix jittery fake monaco placeholder
* select nits
* aiproviderpicker + nits
* smaller ${...} badge
* no-default-style
* select dropdown slide
* nit
* Refresh button in flow picker quick
* jsonEditor pretty
* ai provider toggle button more
* change resource edit button pos
* ResourcePicker Add and Refresh btn
* fix scrollbar
* Fix FileInput and S3 Arg Input
* fix textarea styling
* nicer refresh button in Test This Step
* fix togglebutton border in darkmode
* rounded nit
* Fix multiselect styling
* Prevent crash when selecting dyn-multiselect
* missing $derived and $state => reactivity issue when switching between DynSelect and DynMultiselect
* forgot $effect.pre
* fix nested objects
* nits
* prettier json toggle and array inputs
* array input nits
* nit
* fix json toggle appearing in fileinputs
* nit
* started updating PropertyEditor
* (stash) fix select dropdown animation teleporting from bottom to top
* nit
* nit
* resize transition in schemaform
* nit
* nit typo
* nit enableFlyTransition
* shadow nit
* small consistency changes
* user setting nit
* resize transition in module preview form
* more space
* nit readability on hover
* DateTimeInput new style
* nit fix
* remove yPadding in template and simple editor
* nits
* Revert "remove yPadding in template and simple editor"
This reverts commit 8f27c8d0b8.
* nit
* Fix proppicker border
* fix inconsistent spacing btw arginput and input transform form field headers
* consistent add item button
* nit
* s3 settings nits
* RunsFilter fix
* gray ${...} badge
* border fix darkmode
* nit
* nit app editor consistency
* fix step input gen style
* nit fix
* nits
* toggle border
* nit toggle button
* nit font-medium
* nit font-medium
* nit font-medium
* nit font-medium
* nit
---------
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
83 lines
1.9 KiB
Svelte
83 lines
1.9 KiB
Svelte
<script lang="ts">
|
|
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
|
|
import { createEventDispatcher } from 'svelte'
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
export let updateOnBlur = true
|
|
export let placeholder =
|
|
'Write a JSON payload. The input schema will be inferred.<br/><br/>Example:<br/><br/>{<br/> "foo": "12"<br/>}'
|
|
export let selected: boolean = false
|
|
|
|
let pendingJson = ''
|
|
let simpleEditor: SimpleEditor | undefined = undefined
|
|
let focusTrap: HTMLElement | undefined
|
|
|
|
function updatePayloadFromJson(jsonInput: string) {
|
|
if (jsonInput === undefined || jsonInput === null || jsonInput.trim() === '') {
|
|
dispatch('select', undefined)
|
|
return
|
|
}
|
|
try {
|
|
const parsed = JSON.parse(jsonInput)
|
|
dispatch('select', parsed)
|
|
} catch (error) {
|
|
dispatch('select', undefined)
|
|
}
|
|
}
|
|
|
|
export function setCode(code: string) {
|
|
simpleEditor?.setCode(code)
|
|
}
|
|
|
|
export function resetSelected(dispatchEvent?: boolean) {
|
|
if (dispatchEvent) {
|
|
dispatch('select', undefined)
|
|
}
|
|
}
|
|
|
|
function handleKeydown(event: KeyboardEvent) {
|
|
if (event.key === 'Escape' && selected) {
|
|
focusTrap?.focus()
|
|
resetSelected(true)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<svelte:window on:keydown={handleKeydown} />
|
|
|
|
<!-- Add a hidden button that can receive focus -->
|
|
<button bind:this={focusTrap} class="sr-only" tabindex="-1" aria-hidden="true">Focus trap</button>
|
|
|
|
<div class="h-full py-3 rounded-md border">
|
|
<SimpleEditor
|
|
bind:this={simpleEditor}
|
|
on:focus={() => {
|
|
if (updateOnBlur) {
|
|
dispatch('focus')
|
|
updatePayloadFromJson(pendingJson)
|
|
}
|
|
}}
|
|
on:blur={async () => {
|
|
if (updateOnBlur) {
|
|
dispatch('blur')
|
|
}
|
|
}}
|
|
on:change={(e) => {
|
|
if (e.detail?.code !== undefined) {
|
|
updatePayloadFromJson(e.detail.code)
|
|
}
|
|
}}
|
|
bind:code={pendingJson}
|
|
lang="json"
|
|
class="h-full json-inputs-editor"
|
|
{placeholder}
|
|
/>
|
|
</div>
|
|
|
|
<style>
|
|
:global(.json-inputs-editor .monaco-editor .suggest-widget) {
|
|
z-index: 200000 !important;
|
|
}
|
|
</style>
|