mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-25 00:53:48 +00:00
[WIP] initialize search bar
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
const emits = defineEmits<{
|
||||
search: [search: string];
|
||||
}>();
|
||||
|
||||
let searchTimer = 0;
|
||||
let searchString: string;
|
||||
|
||||
const onInput = function (event: InputEvent) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
const value = target.value;
|
||||
searchString = value;
|
||||
|
||||
if (0 === searchTimer) {
|
||||
window.clearTimeout(searchTimer);
|
||||
searchTimer = 0;
|
||||
}
|
||||
|
||||
searchTimer = window.setTimeout(() => {
|
||||
if (value === searchString) {
|
||||
emits("search", value);
|
||||
}
|
||||
}, 500);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input type="search" @input="onInput" />
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
Reference in New Issue
Block a user