platform/packages/ui/src/components/SearchEdit.svelte
Alexander Platov 67b7c9df24
New themes (#3049)
Signed-off-by: Alexander Platov <sas_lord@mail.ru>
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
Co-authored-by: Denis Bykhov <bykhov.denis@gmail.com>
2023-04-24 00:37:24 +07:00

37 lines
755 B
Svelte

<script lang="ts">
import { createEventDispatcher } from 'svelte'
import EditWithIcon from './EditWithIcon.svelte'
import IconSearch from './icons/Search.svelte'
import plugin from '../plugin'
export let value: string = ''
$: _search = value
const dispatch = createEventDispatcher()
</script>
<EditWithIcon
icon={IconSearch}
width={'12rem'}
placeholder={plugin.string.Search}
bind:value={_search}
on:change={() => {
if (_search === '') {
value = ''
dispatch('change', '')
}
}}
on:input={() => {
if (_search === '') {
value = ''
dispatch('change', '')
}
}}
on:keydown={(evt) => {
if (evt.key === 'Enter') {
value = _search
dispatch('change', _search)
}
}}
/>