1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.BreadcrumbPopupContainer = exports.BreadcrumbID = exports.BreadcrumbPopupContainerFactory = void 0;
|
19 | const tslib_1 = require("tslib");
|
20 | const inversify_1 = require("../../../shared/inversify");
|
21 | const common_1 = require("../../common");
|
22 | const disposable_1 = require("../../common/disposable");
|
23 | const context_menu_renderer_1 = require("../context-menu-renderer");
|
24 | const react_renderer_1 = require("../widgets/react-renderer");
|
25 | const breadcrumbs_constants_1 = require("./breadcrumbs-constants");
|
26 | exports.BreadcrumbPopupContainerFactory = Symbol('BreadcrumbPopupContainerFactory');
|
27 | exports.BreadcrumbID = Symbol('BreadcrumbID');
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | let BreadcrumbPopupContainer = class BreadcrumbPopupContainer {
|
36 | constructor() {
|
37 | this.onDidDisposeEmitter = new common_1.Emitter();
|
38 | this.toDispose = new disposable_1.DisposableCollection(this.onDidDisposeEmitter);
|
39 | this.onFocusOut = (event) => {
|
40 | if (!(event.relatedTarget instanceof Element) || !this._container.contains(event.relatedTarget)) {
|
41 | this.dispose();
|
42 | }
|
43 | };
|
44 | this.escFunction = (event) => {
|
45 | if (event.key === 'Escape' || event.key === 'Esc') {
|
46 | this.dispose();
|
47 | }
|
48 | };
|
49 | }
|
50 | get onDidDispose() {
|
51 | return this.onDidDisposeEmitter.event;
|
52 | }
|
53 | get container() {
|
54 | return this._container;
|
55 | }
|
56 | get isOpen() {
|
57 | return this._isOpen;
|
58 | }
|
59 | init() {
|
60 | this._container = this.createPopupDiv(this.position);
|
61 | document.addEventListener('keyup', this.escFunction);
|
62 | this._container.focus();
|
63 | this._isOpen = true;
|
64 | }
|
65 | createPopupDiv(position) {
|
66 | const result = window.document.createElement('div');
|
67 | result.className = breadcrumbs_constants_1.Styles.BREADCRUMB_POPUP;
|
68 | result.style.left = `${position.x}px`;
|
69 | result.style.top = `${position.y}px`;
|
70 | result.tabIndex = 0;
|
71 | result.addEventListener('focusout', this.onFocusOut);
|
72 | this.parent.appendChild(result);
|
73 | return result;
|
74 | }
|
75 | dispose() {
|
76 | if (!this.toDispose.disposed) {
|
77 | this.onDidDisposeEmitter.fire();
|
78 | this.toDispose.dispose();
|
79 | this._container.remove();
|
80 | this._isOpen = false;
|
81 | document.removeEventListener('keyup', this.escFunction);
|
82 | }
|
83 | }
|
84 | };
|
85 | (0, tslib_1.__decorate)([
|
86 | (0, inversify_1.inject)(react_renderer_1.RendererHost),
|
87 | (0, tslib_1.__metadata)("design:type", Object)
|
88 | ], BreadcrumbPopupContainer.prototype, "parent", void 0);
|
89 | (0, tslib_1.__decorate)([
|
90 | (0, inversify_1.inject)(exports.BreadcrumbID),
|
91 | (0, tslib_1.__metadata)("design:type", String)
|
92 | ], BreadcrumbPopupContainer.prototype, "breadcrumbId", void 0);
|
93 | (0, tslib_1.__decorate)([
|
94 | (0, inversify_1.inject)(context_menu_renderer_1.Coordinate),
|
95 | (0, tslib_1.__metadata)("design:type", Object)
|
96 | ], BreadcrumbPopupContainer.prototype, "position", void 0);
|
97 | (0, tslib_1.__decorate)([
|
98 | (0, inversify_1.postConstruct)(),
|
99 | (0, tslib_1.__metadata)("design:type", Function),
|
100 | (0, tslib_1.__metadata)("design:paramtypes", []),
|
101 | (0, tslib_1.__metadata)("design:returntype", void 0)
|
102 | ], BreadcrumbPopupContainer.prototype, "init", null);
|
103 | BreadcrumbPopupContainer = (0, tslib_1.__decorate)([
|
104 | (0, inversify_1.injectable)()
|
105 | ], BreadcrumbPopupContainer);
|
106 | exports.BreadcrumbPopupContainer = BreadcrumbPopupContainer;
|
107 |
|
\ | No newline at end of file |