input.svelte (870B)
1 <script lang="ts"> 2 import type { ILibInput } from "$lib/types/components"; 3 4 let { val = $bindable(``), basis }: { val?: string; basis: ILibInput } = 5 $props(); 6 </script> 7 8 <input 9 bind:value={val} 10 type={basis.type || "text"} 11 inputmode={basis.type === "numeric" ? "numeric" : undefined} 12 pattern={basis.pattern || basis.type === "numeric" ? "[0-9]*" : undefined} 13 disabled={basis.disabled} 14 class={basis.classes} 15 placeholder={basis.placeholder || ``} 16 onkeydown={async (ev) => { 17 if (basis?.callback_keydown) 18 await basis?.callback_keydown({ 19 key: ev.key, 20 is_submit: ev.key === `Enter`, 21 el: ev.currentTarget, 22 }); 23 }} 24 oninput={async (ev) => { 25 if (basis?.callback_input) 26 await basis?.callback_input(ev.currentTarget); 27 }} 28 />