UNPKG

4.06 kBTypeScriptView Raw
1import { SearchBoxDebounce, SearchBoxDebounceOptions } from '../tree/search-box-debounce';
2import { BaseWidget, Message } from '../widgets/widget';
3import { Emitter, Event } from '../../common/event';
4import { KeyCode, Key } from '../keyboard/keys';
5/**
6 * Initializer properties for the search box widget.
7 */
8export interface SearchBoxProps extends SearchBoxDebounceOptions {
9 /**
10 * If `true`, the `Previous`, `Next`, and `Close` buttons will be visible. Otherwise, `false`. Defaults to `false`.
11 */
12 readonly showButtons?: boolean;
13 /**
14 * If `true`, `Filter` and `Close` buttons will be visible, and clicking the `Filter` button will triggers filter on the search term. Defaults to `false`.
15 */
16 readonly showFilter?: boolean;
17}
18export declare namespace SearchBoxProps {
19 /**
20 * The default search box widget option.
21 */
22 const DEFAULT: SearchBoxProps;
23}
24/**
25 * The search box widget.
26 */
27export declare class SearchBox extends BaseWidget {
28 protected readonly props: SearchBoxProps;
29 protected readonly debounce: SearchBoxDebounce;
30 protected static SPECIAL_KEYS: Key[];
31 protected static MAX_CONTENT_LENGTH: number;
32 protected readonly nextEmitter: Emitter<void>;
33 protected readonly previousEmitter: Emitter<void>;
34 protected readonly closeEmitter: Emitter<void>;
35 protected readonly textChangeEmitter: Emitter<string | undefined>;
36 protected readonly filterToggleEmitter: Emitter<boolean>;
37 protected readonly input: HTMLSpanElement;
38 protected readonly filter: HTMLElement | undefined;
39 protected _isFiltering: boolean;
40 constructor(props: SearchBoxProps, debounce: SearchBoxDebounce);
41 get onPrevious(): Event<void>;
42 get onNext(): Event<void>;
43 get onClose(): Event<void>;
44 get onTextChange(): Event<string | undefined>;
45 get onFilterToggled(): Event<boolean>;
46 get isFiltering(): boolean;
47 get keyCodePredicate(): KeyCode.Predicate;
48 protected firePrevious(): void;
49 protected fireNext(): void;
50 protected fireClose(): void;
51 protected fireTextChange(input: string | undefined): void;
52 protected fireFilterToggle(): void;
53 protected doFireFilterToggle(toggleTo?: boolean): void;
54 handle(event: KeyboardEvent): void;
55 protected handleArrowUp(): void;
56 protected handleArrowDown(): void;
57 onBeforeHide(): void;
58 protected handleKey(keyCode: KeyCode): void;
59 protected getTrimmedContent(data: string): string;
60 protected canHandle(keyCode: KeyCode | undefined): boolean;
61 protected isCtrlBackspace(keyCode: KeyCode): boolean;
62 updateHighlightInfo(info: SearchBox.HighlightInfo): void;
63 protected createContent(): {
64 container: HTMLElement;
65 input: HTMLSpanElement;
66 filter: HTMLElement | undefined;
67 previous: HTMLElement | undefined;
68 next: HTMLElement | undefined;
69 close: HTMLElement | undefined;
70 };
71 protected onAfterAttach(msg: Message): void;
72}
73export declare namespace SearchBox {
74 /**
75 * CSS classes for the search box widget.
76 */
77 namespace Styles {
78 const SEARCH_BOX = "theia-search-box";
79 const SEARCH_INPUT = "theia-search-input";
80 const SEARCH_BUTTONS_WRAPPER = "theia-search-buttons-wrapper";
81 const BUTTON = "theia-search-button";
82 const FILTER: string[];
83 const FILTER_ON = "filter-active";
84 const BUTTON_PREVIOUS = "theia-search-button-previous";
85 const BUTTON_NEXT = "theia-search-button-next";
86 const BUTTON_CLOSE = "theia-search-button-close";
87 const NON_SELECTABLE = "theia-non-selectable";
88 const NO_MATCH = "no-match";
89 }
90 interface HighlightInfo {
91 filterText: string | undefined;
92 matched: number;
93 total: number;
94 }
95}
96/**
97 * Search box factory.
98 */
99export declare const SearchBoxFactory: unique symbol;
100export interface SearchBoxFactory {
101 /**
102 * Creates a new search box with the given initializer properties.
103 */
104 (props: SearchBoxProps): SearchBox;
105}
106//# sourceMappingURL=search-box.d.ts.map
\No newline at end of file