Shivam Mishra
2024-10-02 13:06:30 +05:30
committed by GitHub
parent e0bf2bd9d4
commit 42f6621afb
661 changed files with 15939 additions and 31194 deletions

View File

@@ -38,15 +38,19 @@ const props = defineProps({
},
});
const emit = defineEmits(['onSearch']);
const emit = defineEmits(['onSearch', 'select']);
const searchTerm = ref('');
const onSearch = debounce(value => {
searchTerm.value = value;
const debouncedEmit = debounce(value => {
emit('onSearch', value);
}, 300);
const onSearch = value => {
searchTerm.value = value;
debouncedEmit();
};
const filteredListItems = computed(() => {
if (!searchTerm.value) return props.listItems;
return picoSearch(props.listItems, searchTerm.value, ['name']);
@@ -84,7 +88,7 @@ const shouldShowEmptyState = computed(() => {
:input-placeholder="inputPlaceholder"
:show-clear-filter="showClearFilter"
@input="onSearch"
@click="$emit('removeFilter')"
@remove="$emit('removeFilter')"
/>
</slot>
<slot name="listItem">
@@ -103,7 +107,7 @@ const shouldShowEmptyState = computed(() => {
:button-text="item.name"
:icon="item.icon"
:icon-color="item.iconColor"
@click="$emit('click', item)"
@click.stop.prevent="emit('select', item)"
/>
</slot>
</div>