UNPKG

9.36 kBTypeScriptView Raw
1import { Event } from './event';
2import { KeySequence } from './keys';
3import { CancellationToken } from './cancellation';
4export declare const quickPickServicePath = "/services/quickPick";
5export declare const QuickPickService: unique symbol;
6export interface QuickPickService {
7 show<T extends QuickPickItem>(items: Array<T | QuickPickSeparator>, options?: QuickPickOptions<T>): Promise<T | undefined>;
8 setItems<T extends QuickPickItem>(items: Array<T>): void;
9 hide(): void;
10 readonly onDidHide: Event<void>;
11 readonly onDidAccept: Event<void>;
12 readonly onDidChangeValue: Event<{
13 quickPick: QuickPick<QuickPickItem>;
14 filter: string;
15 }>;
16 readonly onDidChangeActive: Event<{
17 quickPick: QuickPick<QuickPickItem>;
18 activeItems: Array<QuickPickItem>;
19 }>;
20 readonly onDidChangeSelection: Event<{
21 quickPick: QuickPick<QuickPickItem>;
22 selectedItems: Array<QuickPickItem>;
23 }>;
24 readonly onDidTriggerButton: Event<QuickInputButtonHandle>;
25}
26export interface Match {
27 start: number;
28 end: number;
29}
30export interface QuickPickItemHighlights {
31 label?: Match[];
32 description?: Match[];
33 detail?: Match[];
34}
35export interface QuickPickItem {
36 type?: 'item';
37 id?: string;
38 label: string;
39 meta?: string;
40 ariaLabel?: string;
41 description?: string;
42 detail?: string;
43 keySequence?: KeySequence;
44 iconClasses?: string[];
45 alwaysShow?: boolean;
46 highlights?: QuickPickItemHighlights;
47 buttons?: QuickInputButton[];
48 execute?: () => void;
49}
50export interface QuickPickSeparator {
51 type: 'separator';
52 label?: string;
53}
54export type QuickPickItemOrSeparator = QuickPickItem | QuickPickSeparator;
55export type QuickPickInput<T = QuickPickItem> = T | QuickPickSeparator;
56export declare namespace QuickPickItem {
57 function is(item: QuickPickSeparator | QuickPickItem): item is QuickPickItem;
58}
59export interface QuickPickSeparator {
60 type: 'separator';
61 label?: string;
62}
63export declare namespace QuickPickSeparator {
64 function is(item: QuickPickItemOrSeparator): item is QuickPickSeparator;
65}
66export type QuickPicks = (QuickPickSeparator | QuickPickItem)[];
67export interface QuickPickValue<V> extends QuickPickItem {
68 value: V;
69}
70export interface QuickInputButton {
71 iconClass?: string;
72 tooltip?: string;
73 /**
74 * Whether the button should be visible even when the user is not hovering.
75 */
76 alwaysVisible?: boolean;
77}
78export interface QuickInputButtonHandle extends QuickInputButton {
79 handle: number;
80}
81export declare enum QuickInputHideReason {
82 /**
83 * Focus was moved away from the input, but the user may not have explicitly closed it.
84 */
85 Blur = 1,
86 /**
87 * An explicit close gesture, like striking the Escape key
88 */
89 Gesture = 2,
90 /**
91 * Any other reason
92 */
93 Other = 3
94}
95export interface QuickInput {
96 readonly onDidHide: Event<{
97 reason: QuickInputHideReason;
98 }>;
99 readonly onDispose: Event<void>;
100 title: string | undefined;
101 description: string | undefined;
102 step: number | undefined;
103 totalSteps: number | undefined;
104 enabled: boolean;
105 contextKey: string | undefined;
106 busy: boolean;
107 ignoreFocusOut: boolean;
108 show(): void;
109 hide(): void;
110 dispose(): void;
111}
112export interface InputBox extends QuickInput {
113 value: string | undefined;
114 valueSelection: Readonly<[number, number]> | undefined;
115 placeholder: string | undefined;
116 password: boolean;
117 readonly onDidChangeValue: Event<string>;
118 readonly onDidAccept: Event<void>;
119 buttons: ReadonlyArray<QuickInputButton>;
120 readonly onDidTriggerButton: Event<QuickInputButton>;
121 prompt: string | undefined;
122 validationMessage: string | undefined;
123}
124export interface QuickPick<T extends QuickPickItemOrSeparator> extends QuickInput {
125 value: string;
126 placeholder: string | undefined;
127 items: ReadonlyArray<T | QuickPickSeparator>;
128 activeItems: ReadonlyArray<T>;
129 selectedItems: ReadonlyArray<T>;
130 canSelectMany: boolean;
131 matchOnDescription: boolean;
132 matchOnDetail: boolean;
133 keepScrollPosition: boolean;
134 buttons: ReadonlyArray<QuickInputButton>;
135 readonly onDidAccept: Event<{
136 inBackground: boolean;
137 } | undefined>;
138 readonly onDidChangeValue: Event<string>;
139 readonly onDidTriggerButton: Event<QuickInputButton>;
140 readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<QuickPickItem>>;
141 readonly onDidChangeActive: Event<T[]>;
142 readonly onDidChangeSelection: Event<T[]>;
143}
144export interface PickOptions<T extends QuickPickItem> {
145 title?: string;
146 placeHolder?: string;
147 matchOnDescription?: boolean;
148 matchOnDetail?: boolean;
149 matchOnLabel?: boolean;
150 autoFocusOnList?: boolean;
151 ignoreFocusLost?: boolean;
152 canPickMany?: boolean;
153 contextKey?: string;
154 activeItem?: Promise<T> | T;
155 onDidFocus?: (entry: T) => void;
156}
157export interface InputOptions {
158 title?: string;
159 value?: string;
160 valueSelection?: [number, number];
161 prompt?: string;
162 placeHolder?: string;
163 password?: boolean;
164 ignoreFocusLost?: boolean;
165 validateInput?(input: string): Promise<string | {
166 content: string;
167 severity: number;
168 } | null | undefined> | undefined;
169}
170export interface QuickPickItemButtonEvent<T extends QuickPickItemOrSeparator> {
171 button: QuickInputButton;
172 item: T;
173}
174export interface QuickPickItemButtonContext<T extends QuickPickItemOrSeparator> extends QuickPickItemButtonEvent<T> {
175 removeItem(): void;
176}
177export interface QuickPickOptions<T extends QuickPickItemOrSeparator> {
178 busy?: boolean;
179 enabled?: boolean;
180 title?: string;
181 description?: string;
182 value?: string;
183 filterValue?: (value: string) => string;
184 ariaLabel?: string;
185 buttons?: Array<QuickInputButton>;
186 placeholder?: string;
187 canAcceptInBackground?: boolean;
188 customButton?: boolean;
189 customLabel?: string;
190 customHover?: string;
191 canSelectMany?: boolean;
192 matchOnDescription?: boolean;
193 matchOnDetail?: boolean;
194 matchOnLabel?: boolean;
195 sortByLabel?: boolean;
196 keepScrollPosition?: boolean;
197 autoFocusOnList?: boolean;
198 ignoreFocusOut?: boolean;
199 valueSelection?: Readonly<[number, number]>;
200 validationMessage?: string;
201 hideInput?: boolean;
202 hideCheckAll?: boolean;
203 runIfSingle?: boolean;
204 contextKey?: string;
205 activeItem?: T;
206 step?: number;
207 totalSteps?: number;
208 onDidAccept?: () => void;
209 onDidChangeActive?: (quickPick: QuickPick<T>, activeItems: Array<T>) => void;
210 onDidChangeSelection?: (quickPick: QuickPick<T>, selectedItems: Array<T>) => void;
211 onDidChangeValue?: (quickPick: QuickPick<T>, filter: string) => void;
212 onDidCustom?: () => void;
213 onDidHide?: () => void;
214 onDidTriggerButton?: (button: QuickInputButton) => void;
215 onDidTriggerItemButton?: (ItemButtonEvent: QuickPickItemButtonContext<T>) => void;
216}
217export declare const quickInputServicePath = "/services/quickInput";
218export declare const QuickInputService: unique symbol;
219export interface QuickInputService {
220 readonly backButton: QuickInputButton;
221 readonly onShow: Event<void>;
222 readonly onHide: Event<void>;
223 open(filter: string): void;
224 createInputBox(): InputBox;
225 input(options?: InputOptions, token?: CancellationToken): Promise<string | undefined>;
226 pick<T extends QuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: PickOptions<T> & {
227 canPickMany: true;
228 }, token?: CancellationToken): Promise<T[] | undefined>;
229 pick<T extends QuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: PickOptions<T> & {
230 canPickMany: false;
231 }, token?: CancellationToken): Promise<T | undefined>;
232 pick<T extends QuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<PickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined>;
233 showQuickPick<T extends QuickPickItem>(items: Array<T | QuickPickSeparator>, options?: QuickPickOptions<T>): Promise<T | undefined>;
234 hide(): void;
235 /**
236 * Provides raw access to the quick pick controller.
237 */
238 createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
239}
240/**
241 * Filter the list of quick pick items based on the provided filter.
242 * Items are filtered based on if:
243 * - their `label` satisfies the filter using `fuzzy`.
244 * - their `description` satisfies the filter using `fuzzy`.
245 * - their `detail` satisfies the filter using `fuzzy`.
246 * Filtered items are also updated to display proper highlights based on how they were filtered.
247 * @param items the list of quick pick items.
248 * @param filter the filter to search for.
249 * @returns the list of quick pick items that satisfy the filter.
250 */
251export declare function filterItems(items: QuickPickItemOrSeparator[], filter: string): QuickPickItemOrSeparator[];
252/**
253 * Find match highlights when testing a word against a pattern.
254 * @param word the word to test.
255 * @param pattern the word to match against.
256 * @returns the list of highlights if present.
257 */
258export declare function findMatches(word: string, pattern: string): Array<{
259 start: number;
260 end: number;
261}> | undefined;
262//# sourceMappingURL=quick-pick-service.d.ts.map
\No newline at end of file