mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 17:26:15 -04:00
feat(ui): added c-select in the ui lib (#550)
* feat(ui): added c-select in the ui lib * refactor(ui): switched n-select to c-select
This commit is contained in:
parent
6498c9b0fa
commit
dfa1ba8554
29 changed files with 666 additions and 199 deletions
|
@ -11,12 +11,19 @@ function useFuzzySearch<Data>({
|
|||
}: {
|
||||
search: MaybeRef<string>
|
||||
data: Data[]
|
||||
options?: Fuse.IFuseOptions<Data>
|
||||
options?: Fuse.IFuseOptions<Data> & { filterEmpty?: boolean }
|
||||
}) {
|
||||
const fuse = new Fuse(data, options);
|
||||
const filterEmpty = options.filterEmpty ?? true;
|
||||
|
||||
const searchResult = computed(() => {
|
||||
return fuse.search(get(search)).map(({ item }) => item);
|
||||
const searchResult = computed<Data[]>(() => {
|
||||
const query = get(search);
|
||||
|
||||
if (!filterEmpty && query === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
return fuse.search(query).map(({ item }) => item);
|
||||
});
|
||||
|
||||
return { searchResult };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue