2023-09-05 10:45:05 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
export let value: number[];
|
2023-09-30 05:05:35 +02:00
|
|
|
export let defaults: number[];
|
2023-09-05 10:45:05 +02:00
|
|
|
|
|
|
|
let stringValue: string;
|
2023-09-30 05:05:35 +02:00
|
|
|
$: stringValue = render(value);
|
|
|
|
|
|
|
|
function render(weights: number[]): string {
|
|
|
|
return weights.map((v) => v.toFixed(4)).join(", ");
|
|
|
|
}
|
2023-09-05 10:45:05 +02:00
|
|
|
|
|
|
|
function update(this: HTMLInputElement): void {
|
2023-09-16 08:09:26 +02:00
|
|
|
value = this.value
|
|
|
|
.replace(/ /g, "")
|
|
|
|
.split(",")
|
|
|
|
.filter((e) => e)
|
|
|
|
.map((v) => Number(v));
|
2023-09-05 10:45:05 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-09-30 05:05:35 +02:00
|
|
|
<textarea
|
|
|
|
value={stringValue}
|
|
|
|
on:blur={update}
|
|
|
|
class="w-100"
|
|
|
|
placeholder={render(defaults)}
|
|
|
|
/>
|