Refactored Svelte components
This commit is contained in:
29
src/components/InputSearch.svelte
Normal file
29
src/components/InputSearch.svelte
Normal file
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { debounce } from "obsidian"
|
||||
import { createEventDispatcher, onMount, tick } from "svelte"
|
||||
|
||||
export let value = ''
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let elInput: HTMLInputElement
|
||||
|
||||
onMount(async () => {
|
||||
await tick()
|
||||
elInput.focus()
|
||||
elInput.select()
|
||||
})
|
||||
|
||||
const debouncedOnInput = debounce(() => {
|
||||
dispatch("input", value)
|
||||
}, 100)
|
||||
</script>
|
||||
|
||||
<input
|
||||
bind:value
|
||||
bind:this={elInput}
|
||||
on:input={debouncedOnInput}
|
||||
type="text"
|
||||
class="prompt-input"
|
||||
placeholder="Type to search through your notes"
|
||||
spellcheck="false"
|
||||
/>
|
||||
Reference in New Issue
Block a user