frontend: properly bind marks values
This commit is contained in:
parent
f36d5aac0c
commit
a0925f9ba5
3 changed files with 17 additions and 9 deletions
|
@ -4,19 +4,19 @@
|
|||
|
||||
let { value = $bindable([]), label = "" } = $props();
|
||||
let items: string[] = $state([]);
|
||||
|
||||
$effect(() => {value = items});
|
||||
</script>
|
||||
|
||||
<div class="marks-container input rounded">
|
||||
<p>{label}</p>
|
||||
|
||||
{#each items as item}
|
||||
<Mark text={item}/>
|
||||
{#each items as item, index}
|
||||
<Mark bind:text={items[index]}/>
|
||||
{/each}
|
||||
<AddButton handler={() => {
|
||||
items.push("");
|
||||
value = items;
|
||||
items.push(null);
|
||||
}} />
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<script lang="ts">
|
||||
let { text } = $props();
|
||||
|
||||
let { text = $bindable() } = $props();
|
||||
|
||||
let compl_data = $state([]);
|
||||
|
||||
const placeholder = "Текст";
|
||||
|
||||
function autocomplete() {
|
||||
if (text !== "") {
|
||||
|
@ -18,14 +21,19 @@
|
|||
compl_data = [];
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (text == "") text = null;
|
||||
})
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<input type="text"
|
||||
class="dyn-input rounded"
|
||||
style="width: {text.length}ch;margin:0;"
|
||||
style="width: {(text ?? placeholder).length}ch;margin:0;"
|
||||
bind:value={text}
|
||||
oninput={autocomplete}>
|
||||
oninput={autocomplete}
|
||||
{placeholder}>
|
||||
{#if compl_data}
|
||||
<div class="popup rounded" tabindex="0" role="button" onmousedown={(e) => {e.preventDefault();}}>
|
||||
{#each compl_data as item}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
genres: [],
|
||||
tags: [],
|
||||
badges: []
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue