UNPKG

1.73 kBTypeScriptView Raw
1import { ReactWidget } from './vdom';
2import React from 'react';
3/**
4 * The class name added to the filebrowser crumbs node.
5 */
6export interface IFilterBoxProps {
7 /**
8 * Whether to use case-sensitive search
9 */
10 caseSensitive?: boolean;
11 /**
12 * Whether the search box is disabled or not.
13 */
14 disabled?: boolean;
15 /**
16 * Whether to force a refresh.
17 */
18 forceRefresh?: boolean;
19 /**
20 * An optional initial search value.
21 */
22 initialQuery?: string;
23 /**
24 * Pass a ref to the input element
25 */
26 inputRef?: React.RefObject<HTMLInputElement>;
27 /**
28 * Optional placeholder for the search box.
29 */
30 placeholder?: string;
31 /**
32 * A function to callback when filter is updated.
33 */
34 updateFilter: (filterFn: (item: string) => Partial<IScore> | null, query?: string) => void;
35 /**
36 * Whether to use the fuzzy filter.
37 */
38 useFuzzyFilter: boolean;
39}
40/**
41 * A text match score with associated content item.
42 */
43export interface IScore {
44 /**
45 * The numerical score for the text match.
46 */
47 score: number;
48 /**
49 * The indices of the text matches.
50 */
51 indices: number[] | null;
52}
53/**
54 * Perform a fuzzy search on a single item.
55 */
56export declare function fuzzySearch(source: string, query: string): IScore | null;
57export declare const updateFilterFunction: (value: string, useFuzzyFilter: boolean, caseSensitive?: boolean) => (item: string) => Partial<IScore> | null;
58export declare const FilterBox: (props: IFilterBoxProps) => JSX.Element;
59/**
60 * A widget which hosts a input textbox to filter on file names.
61 */
62export declare const FilenameSearcher: (props: IFilterBoxProps) => ReactWidget;