UNPKG

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