UNPKG

4.03 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2021 Arm 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// *****************************************************************************
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};
26var __param = (this && this.__param) || function (paramIndex, decorator) {
27 return function (target, key) { decorator(target, key, paramIndex); }
28};
29Object.defineProperty(exports, "__esModule", { value: true });
30exports.TooltipServiceImpl = exports.TooltipService = void 0;
31const inversify_1 = require("inversify");
32const React = require("react");
33const react_tooltip_1 = require("react-tooltip");
34const react_renderer_1 = require("./widgets/react-renderer");
35const core_preferences_1 = require("./core-preferences");
36const uuid_1 = require("uuid");
37exports.TooltipService = Symbol('TooltipService');
38const DELAY_PREFERENCE = 'workbench.hover.delay';
39let TooltipServiceImpl = class TooltipServiceImpl extends react_renderer_1.ReactRenderer {
40 constructor(host) {
41 super(host);
42 this.rendered = false;
43 this.tooltipId = (0, uuid_1.v4)();
44 }
45 init() {
46 this.toDispose.push(this.corePreferences.onPreferenceChanged(preference => {
47 if (preference.preferenceName === DELAY_PREFERENCE) {
48 this.update(true);
49 }
50 }));
51 }
52 attachTo(host) {
53 host.appendChild(this.host);
54 }
55 update(fullRender = false) {
56 if (fullRender || !this.rendered) {
57 this.render();
58 this.rendered = true;
59 }
60 react_tooltip_1.default.rebuild();
61 }
62 doRender() {
63 const hoverDelay = this.corePreferences.get(DELAY_PREFERENCE);
64 return React.createElement(react_tooltip_1.default, { id: this.tooltipId, className: 'theia-tooltip', html: true, delayShow: hoverDelay });
65 }
66 dispose() {
67 this.toDispose.dispose();
68 super.dispose();
69 }
70};
71__decorate([
72 (0, inversify_1.inject)(core_preferences_1.CorePreferences),
73 __metadata("design:type", Object)
74], TooltipServiceImpl.prototype, "corePreferences", void 0);
75__decorate([
76 (0, inversify_1.postConstruct)(),
77 __metadata("design:type", Function),
78 __metadata("design:paramtypes", []),
79 __metadata("design:returntype", void 0)
80], TooltipServiceImpl.prototype, "init", null);
81TooltipServiceImpl = __decorate([
82 (0, inversify_1.injectable)(),
83 __param(0, (0, inversify_1.inject)(react_renderer_1.RendererHost)),
84 __param(0, (0, inversify_1.optional)()),
85 __metadata("design:paramtypes", [Object])
86], TooltipServiceImpl);
87exports.TooltipServiceImpl = TooltipServiceImpl;
88//# sourceMappingURL=tooltip-service.js.map
\No newline at end of file