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