UNPKG

3.55 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2018 TypeFox and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.QuickPickServiceImpl = void 0;
19const tslib_1 = require("tslib");
20const inversify_1 = require("inversify");
21const event_1 = require("../../common/event");
22const quick_input_service_1 = require("./quick-input-service");
23let QuickPickServiceImpl = class QuickPickServiceImpl {
24 constructor() {
25 this.onDidHideEmitter = new event_1.Emitter();
26 this.onDidHide = this.onDidHideEmitter.event;
27 this.onDidChangeValueEmitter = new event_1.Emitter();
28 this.onDidChangeValue = this.onDidChangeValueEmitter.event;
29 this.onDidAcceptEmitter = new event_1.Emitter();
30 this.onDidAccept = this.onDidAcceptEmitter.event;
31 this.onDidChangeActiveEmitter = new event_1.Emitter();
32 this.onDidChangeActive = this.onDidChangeActiveEmitter.event;
33 this.onDidChangeSelectionEmitter = new event_1.Emitter();
34 this.onDidChangeSelection = this.onDidChangeSelectionEmitter.event;
35 this.onDidTriggerButtonEmitter = new event_1.Emitter();
36 this.onDidTriggerButton = this.onDidTriggerButtonEmitter.event;
37 // eslint-disable-next-line @typescript-eslint/no-explicit-any
38 this.items = [];
39 }
40 async show(items, options) {
41 var _a;
42 this.items = items;
43 const opts = Object.assign({}, options, {
44 onDidAccept: () => this.onDidAcceptEmitter.fire(),
45 onDidChangeActive: (quickPick, activeItems) => this.onDidChangeActiveEmitter.fire({ quickPick, activeItems }),
46 onDidChangeSelection: (quickPick, selectedItems) => this.onDidChangeSelectionEmitter.fire({ quickPick, selectedItems }),
47 onDidChangeValue: (quickPick, filter) => this.onDidChangeValueEmitter.fire({ quickPick, filter }),
48 onDidHide: () => this.onDidHideEmitter.fire(),
49 onDidTriggerButton: (btn) => this.onDidTriggerButtonEmitter.fire(btn),
50 });
51 return (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(this.items, opts);
52 }
53 hide() {
54 var _a;
55 (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.hide();
56 }
57 setItems(items) {
58 this.items = items;
59 }
60};
61(0, tslib_1.__decorate)([
62 (0, inversify_1.inject)(quick_input_service_1.QuickInputService),
63 (0, inversify_1.optional)(),
64 (0, tslib_1.__metadata)("design:type", Object)
65], QuickPickServiceImpl.prototype, "quickInputService", void 0);
66QuickPickServiceImpl = (0, tslib_1.__decorate)([
67 (0, inversify_1.injectable)()
68], QuickPickServiceImpl);
69exports.QuickPickServiceImpl = QuickPickServiceImpl;
70//# sourceMappingURL=quick-pick-service-impl.js.map
\No newline at end of file