blob: 26521e13172a37b5638cb0e2a68ca7b33f1dbd4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<script>
import { postToChannel } from '$lib/apiServer';
let { channel } = $props();
let form;
let value = $state('');
let pending = false;
let disabled = $derived(pending);
async function onSubmit(event) {
event.preventDefault();
pending = true;
await postToChannel(channel, value);
form.reset();
pending = false;
}
function onKeyDown(event) {
let modifier = event.shiftKey || event.altKey || event.ctrlKey || event.metaKey;
if (!modifier && event.key === 'Enter') {
onSubmit(event);
}
}
</script>
<form bind:this={form} onsubmit={onSubmit} class="flex flex-row flex-nowrap">
<textarea
onkeydown={onKeyDown}
bind:value
{disabled}
type="search"
class="flex-auto h-6 py-0 input rounded-r-none text-nowrap"
></textarea>
<button
color="primary variant-filled-secondary"
type="submit"
class="flex-none w-6 h-6 btn-icon variant-filled rounded-l-none">»</button
>
</form>
|