UNPKG

4.22 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 WITH Classpath-exception-2.0
16// *****************************************************************************
17var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21 return c > 3 && r && Object.defineProperty(target, key, r), r;
22};
23var __metadata = (this && this.__metadata) || function (k, v) {
24 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25};
26Object.defineProperty(exports, "__esModule", { value: true });
27exports.QuickPickServiceImpl = void 0;
28const inversify_1 = require("inversify");
29const event_1 = require("../../common/event");
30const quick_input_service_1 = require("./quick-input-service");
31let QuickPickServiceImpl = class QuickPickServiceImpl {
32 constructor() {
33 this.onDidHideEmitter = new event_1.Emitter();
34 this.onDidHide = this.onDidHideEmitter.event;
35 this.onDidChangeValueEmitter = new event_1.Emitter();
36 this.onDidChangeValue = this.onDidChangeValueEmitter.event;
37 this.onDidAcceptEmitter = new event_1.Emitter();
38 this.onDidAccept = this.onDidAcceptEmitter.event;
39 this.onDidChangeActiveEmitter = new event_1.Emitter();
40 this.onDidChangeActive = this.onDidChangeActiveEmitter.event;
41 this.onDidChangeSelectionEmitter = new event_1.Emitter();
42 this.onDidChangeSelection = this.onDidChangeSelectionEmitter.event;
43 this.onDidTriggerButtonEmitter = new event_1.Emitter();
44 this.onDidTriggerButton = this.onDidTriggerButtonEmitter.event;
45 // eslint-disable-next-line @typescript-eslint/no-explicit-any
46 this.items = [];
47 }
48 async show(items, options) {
49 var _a;
50 this.items = items;
51 const opts = Object.assign({}, options, {
52 onDidAccept: () => this.onDidAcceptEmitter.fire(),
53 onDidChangeActive: (quickPick, activeItems) => this.onDidChangeActiveEmitter.fire({ quickPick, activeItems }),
54 onDidChangeSelection: (quickPick, selectedItems) => this.onDidChangeSelectionEmitter.fire({ quickPick, selectedItems }),
55 onDidChangeValue: (quickPick, filter) => this.onDidChangeValueEmitter.fire({ quickPick, filter }),
56 onDidHide: () => this.onDidHideEmitter.fire(),
57 onDidTriggerButton: (btn) => this.onDidTriggerButtonEmitter.fire(btn),
58 });
59 return (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(this.items, opts);
60 }
61 hide() {
62 var _a;
63 (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.hide();
64 }
65 setItems(items) {
66 this.items = items;
67 }
68};
69__decorate([
70 (0, inversify_1.inject)(quick_input_service_1.QuickInputService),
71 (0, inversify_1.optional)(),
72 __metadata("design:type", Object)
73], QuickPickServiceImpl.prototype, "quickInputService", void 0);
74QuickPickServiceImpl = __decorate([
75 (0, inversify_1.injectable)()
76], QuickPickServiceImpl);
77exports.QuickPickServiceImpl = QuickPickServiceImpl;
78//# sourceMappingURL=quick-pick-service-impl.js.map
\No newline at end of file