fix: binding not working in nested array script arg (#5585)

This commit is contained in:
Diego Imbert
2025-04-08 11:14:06 +02:00
committed by GitHub
parent 3b3523048b
commit a4406ffb16
+23 -20
View File
@@ -133,7 +133,7 @@
} else {
const label = oneOf[0]['title']
oneOfSelected = label
value = { ...(typeof value === 'object' ? value ?? {} : {}), label }
value = { ...(typeof value === 'object' ? (value ?? {}) : {}), label }
}
}
}
@@ -264,12 +264,12 @@
value == undefined || value == null
? ''
: isObjectCat(inputCat)
? JSON.stringify(value, null, 2)
: isRawStringEditor(inputCat)
? typeof value == 'string'
? value
: JSON.stringify(value, null, 2)
: undefined
? JSON.stringify(value, null, 2)
: isRawStringEditor(inputCat)
? typeof value == 'string'
? value
: JSON.stringify(value, null, 2)
: undefined
if (newRawValue != rawValue) {
rawValue = newRawValue
@@ -415,12 +415,12 @@
diffStatus?.diff == 'added'
? 'bg-green-300 dark:bg-green-800'
: diffStatus?.diff === 'removed'
? 'bg-red-300 dark:bg-red-800'
: diffStatus?.diff === 'same'
? 'bg-surface'
: diffStatus?.diff === 'modified' || typeof diffStatus?.diff === 'object'
? 'border-2 border-green-500 bg-surface'
: ''
? 'bg-red-300 dark:bg-red-800'
: diffStatus?.diff === 'same'
? 'bg-surface'
: diffStatus?.diff === 'modified' || typeof diffStatus?.diff === 'object'
? 'border-2 border-green-500 bg-surface'
: ''
)}
data-schema-picker
>
@@ -563,7 +563,7 @@
{#if i < itemsLimit}
<div class="flex max-w-md mt-1 w-full items-center">
{#if itemsType?.type == 'number'}
<input type="number" bind:value={v} id="arg-input-number-array" />
<input type="number" bind:value={value[i]} id="arg-input-number-array" />
{:else if itemsType?.type == 'string' && itemsType?.contentEncoding == 'base64'}
<input
type="file"
@@ -575,7 +575,10 @@
{#await import('$lib/components/JsonEditor.svelte')}
<Loader2 class="animate-spin" />
{:then Module}
<Module.default code={JSON.stringify(v, null, 2)} bind:value={v} />
<Module.default
code={JSON.stringify(v, null, 2)}
bind:value={value[i]}
/>
{/await}
{:else if Array.isArray(itemsType?.enum)}
<ArgEnum
@@ -591,14 +594,14 @@
{valid}
{disabled}
{autofocus}
bind:value={v}
bind:value={value[i]}
enum_={itemsType?.enum ?? []}
enumLabels={extra['enumLabels']}
/>
{:else if itemsType?.type == 'resource' && itemsType?.resourceType && resourceTypes?.includes(itemsType.resourceType)}
<ObjectResourceInput
value={v ? `$res:${v}` : undefined}
bind:path={v}
bind:path={value[i]}
format={'resource-' + itemsType?.resourceType}
defaultValue={undefined}
/>
@@ -615,7 +618,7 @@
dispatch('blur')
}}
code={JSON.stringify(v, null, 2)}
bind:value={v}
bind:value={value[i]}
/>
{/await}
{:else if itemsType?.type === 'object' && itemsType?.properties}
@@ -625,11 +628,11 @@
{disablePortal}
{disabled}
schema={getSchemaFromProperties(itemsType?.properties)}
bind:args={v}
bind:args={value[i]}
/>
</div>
{:else}
<input type="text" bind:value={v} id="arg-input-array" />
<input type="text" bind:value={value[i]} id="arg-input-array" />
{/if}
<button
transition:fade|local={{ duration: 100 }}