diff --git a/src/lib/components/Input/Input.svelte b/src/lib/components/Input/Input.svelte index 2764ed3..2270809 100644 --- a/src/lib/components/Input/Input.svelte +++ b/src/lib/components/Input/Input.svelte @@ -9,6 +9,7 @@ export let placeholder: string | null = null; export let required = false; export let disabled = false; + export let readonly = false; export let size: 'xs' | 'sm' | 'md' | 'lg' = 'md'; export let pickyWidth = true; @@ -85,6 +86,7 @@ {placeholder} {required} {disabled} + {readonly} bind:this={inputElement} autocomplete="off" on:input={(e) => { diff --git a/src/lib/components/Input/Search.svelte b/src/lib/components/Input/Search.svelte index 12d15c0..dae7ef7 100644 --- a/src/lib/components/Input/Search.svelte +++ b/src/lib/components/Input/Search.svelte @@ -1,7 +1,11 @@ @@ -47,13 +52,18 @@ value = searchSuggestion.value; searchSuggestions = []; e.target?.setCustomValidity(''); + dispatch('submit', { input: inputValue, value: value }); + } else if (inputValue === '' && emptyAllowed) { + dispatch('submit', { input: '', value: '' }); } }); }} on:invalid={(e) => { if (invalidMessage != null) e.target?.setCustomValidity(invalidMessage); }} - pattern={suggestionRequired ? `${value ? inputValue : 'a^'}` : null} + pattern={suggestionRequired + ? `${value ? inputValue : 'a^' + (emptyAllowed ? '|$^' : '')}` + : null} /> @@ -68,6 +78,7 @@ inputValue = searchSuggestion.name; value = searchSuggestion.value; searchSuggestions = []; + dispatch('submit', { input: inputValue, value: value }); }}>{searchSuggestion.name} @@ -76,6 +87,7 @@ {/if} + {#if inputValue && searchSuggestions.length !== 0}