UNPKG

3.31 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// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.TooltipServiceImpl = exports.TooltipService = void 0;
19const tslib_1 = require("tslib");
20const inversify_1 = require("inversify");
21const React = require("react");
22const react_tooltip_1 = require("react-tooltip");
23const react_renderer_1 = require("./widgets/react-renderer");
24const core_preferences_1 = require("./core-preferences");
25const uuid_1 = require("../common/uuid");
26exports.TooltipService = Symbol('TooltipService');
27const DELAY_PREFERENCE = 'workbench.hover.delay';
28let TooltipServiceImpl = class TooltipServiceImpl extends react_renderer_1.ReactRenderer {
29 constructor(host) {
30 super(host);
31 this.rendered = false;
32 this.tooltipId = (0, uuid_1.generateUuid)();
33 }
34 init() {
35 this.toDispose.push(this.corePreferences.onPreferenceChanged(preference => {
36 if (preference.preferenceName === DELAY_PREFERENCE) {
37 this.update(true);
38 }
39 }));
40 }
41 attachTo(host) {
42 host.appendChild(this.host);
43 }
44 update(fullRender = false) {
45 if (fullRender || !this.rendered) {
46 this.render();
47 this.rendered = true;
48 }
49 react_tooltip_1.default.rebuild();
50 }
51 doRender() {
52 const hoverDelay = this.corePreferences.get(DELAY_PREFERENCE);
53 return React.createElement(react_tooltip_1.default, { id: this.tooltipId, className: 'theia-tooltip', html: true, delayShow: hoverDelay });
54 }
55 dispose() {
56 this.toDispose.dispose();
57 super.dispose();
58 }
59};
60(0, tslib_1.__decorate)([
61 (0, inversify_1.inject)(core_preferences_1.CorePreferences),
62 (0, tslib_1.__metadata)("design:type", Object)
63], TooltipServiceImpl.prototype, "corePreferences", void 0);
64(0, tslib_1.__decorate)([
65 (0, inversify_1.postConstruct)(),
66 (0, tslib_1.__metadata)("design:type", Function),
67 (0, tslib_1.__metadata)("design:paramtypes", []),
68 (0, tslib_1.__metadata)("design:returntype", void 0)
69], TooltipServiceImpl.prototype, "init", null);
70TooltipServiceImpl = (0, tslib_1.__decorate)([
71 (0, inversify_1.injectable)(),
72 (0, tslib_1.__param)(0, (0, inversify_1.inject)(react_renderer_1.RendererHost)),
73 (0, tslib_1.__param)(0, (0, inversify_1.optional)()),
74 (0, tslib_1.__metadata)("design:paramtypes", [Object])
75], TooltipServiceImpl);
76exports.TooltipServiceImpl = TooltipServiceImpl;
77//# sourceMappingURL=tooltip-service.js.map
\No newline at end of file