UNPKG

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