2021-05-22 12:32:32 +03:00
|
|
|
<script>
|
2021-07-26 02:31:00 +03:00
|
|
|
import { afterUpdate } from 'svelte';
|
2021-05-22 12:32:32 +03:00
|
|
|
export let label;
|
|
|
|
|
export let placeholder;
|
|
|
|
|
export let value;
|
2021-05-29 22:24:14 +03:00
|
|
|
export let onKeyDown;
|
2021-07-26 02:31:00 +03:00
|
|
|
export let className = '';
|
|
|
|
|
export let inputClassName = '';
|
|
|
|
|
export let type = 'text';
|
|
|
|
|
export let autoFocus = false;
|
|
|
|
|
|
|
|
|
|
let ref = null;
|
|
|
|
|
|
|
|
|
|
function typeAction(node) {
|
|
|
|
|
node.type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
afterUpdate(() => {
|
|
|
|
|
if (autoFocus) {
|
|
|
|
|
ref.focus();
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-22 12:32:32 +03:00
|
|
|
</script>
|
|
|
|
|
|
2021-07-03 19:29:41 +00:00
|
|
|
<label class="block {className}">
|
2021-07-26 02:31:00 +03:00
|
|
|
{#if label}<label class="m-0">{label}</label>{/if}
|
2021-05-22 12:32:32 +03:00
|
|
|
<input
|
2021-07-26 02:31:00 +03:00
|
|
|
use:typeAction
|
|
|
|
|
class="form-input {inputClassName} p-2 mt-1 block w-full bg-white border border-gray-300"
|
2021-05-29 22:24:14 +03:00
|
|
|
on:keydown={onKeyDown}
|
2021-05-22 12:32:32 +03:00
|
|
|
{placeholder}
|
2021-05-30 14:17:08 +03:00
|
|
|
bind:value
|
2021-07-26 02:31:00 +03:00
|
|
|
bind:this={ref}
|
2021-05-30 14:17:08 +03:00
|
|
|
/>
|
2021-05-22 12:32:32 +03:00
|
|
|
</label>
|