UNPKG

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