@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
77 lines • 3.29 kB
JavaScript
// *****************************************************************************
// Copyright (C) 2021 Arm and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
Object.defineProperty(exports, "__esModule", { value: true });
exports.TooltipServiceImpl = exports.TooltipService = void 0;
const tslib_1 = require("tslib");
const inversify_1 = require("inversify");
const React = require("react");
const react_tooltip_1 = require("react-tooltip");
const react_renderer_1 = require("./widgets/react-renderer");
const core_preferences_1 = require("./core-preferences");
const uuid_1 = require("../common/uuid");
exports.TooltipService = Symbol('TooltipService');
const DELAY_PREFERENCE = 'workbench.hover.delay';
let TooltipServiceImpl = class TooltipServiceImpl extends react_renderer_1.ReactRenderer {
constructor(host) {
super(host);
this.rendered = false;
this.tooltipId = (0, uuid_1.generateUuid)();
}
init() {
this.toDispose.push(this.corePreferences.onPreferenceChanged(preference => {
if (preference.preferenceName === DELAY_PREFERENCE) {
this.update(true);
}
}));
}
attachTo(host) {
host.appendChild(this.host);
}
update(fullRender = false) {
if (fullRender || !this.rendered) {
this.render();
this.rendered = true;
}
react_tooltip_1.default.rebuild();
}
doRender() {
const hoverDelay = this.corePreferences.get(DELAY_PREFERENCE);
return React.createElement(react_tooltip_1.default, { id: this.tooltipId, className: 'theia-tooltip', html: true, delayShow: hoverDelay });
}
dispose() {
this.toDispose.dispose();
super.dispose();
}
};
exports.TooltipServiceImpl = TooltipServiceImpl;
tslib_1.__decorate([
(0, inversify_1.inject)(core_preferences_1.CorePreferences),
tslib_1.__metadata("design:type", Object)
], TooltipServiceImpl.prototype, "corePreferences", void 0);
tslib_1.__decorate([
(0, inversify_1.postConstruct)(),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", []),
tslib_1.__metadata("design:returntype", void 0)
], TooltipServiceImpl.prototype, "init", null);
exports.TooltipServiceImpl = TooltipServiceImpl = tslib_1.__decorate([
(0, inversify_1.injectable)(),
tslib_1.__param(0, (0, inversify_1.inject)(react_renderer_1.RendererHost)),
tslib_1.__param(0, (0, inversify_1.optional)()),
tslib_1.__metadata("design:paramtypes", [Object])
], TooltipServiceImpl);
//# sourceMappingURL=tooltip-service.js.map
;