resize param input on value change

This commit is contained in:
llama 2025-05-13 22:02:56 +08:00
parent 1c69333210
commit 130c8dee14
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3

View file

@ -3,11 +3,25 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { tick } from "svelte";
export let value: number[];
export let defaults: number[];
let stringValue: string;
$: stringValue = render(value);
let taRef: HTMLTextAreaElement;
function updateHeight() {
if (taRef) {
taRef.style.height = "auto";
taRef.style.height = `${taRef.scrollHeight}px`;
}
}
$: {
stringValue = render(value);
tick().then(updateHeight);
}
function render(params: number[]): string {
return params.map((v) => v.toFixed(4)).join(", ");
@ -23,6 +37,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script>
<textarea
bind:this={taRef}
value={stringValue}
on:blur={update}
class="w-100"