mirror of
				https://github.com/CorentinTh/it-tools.git
				synced 2025-11-03 21:43:21 +00: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:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							6498c9b0fa
						
					
				
				
					commit
					dfa1ba8554
				
			@@ -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 };
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user