@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
72 lines • 2.97 kB
JavaScript
import { __decorate, __param } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
// *****************************************************************************
// 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
// *****************************************************************************
import { injectable, inject, optional, postConstruct } from 'inversify';
import ReactTooltipModule from 'react-tooltip';
import { ReactRenderer, RendererHost } from './widgets/react-renderer.js';
import { generateUuid } from '../common/uuid.js';
import { CorePreferences } from '../common/core-preferences.js';
// The types of `react-tooltip` declare an ES module default export, but its CommonJS entry point assigns the component to
// `module.exports`, which is what a default import from an ES module provides at runtime.
const ReactTooltip = ReactTooltipModule;
export const TooltipService = Symbol('TooltipService');
const DELAY_PREFERENCE = 'workbench.hover.delay';
let TooltipServiceImpl = class TooltipServiceImpl extends ReactRenderer {
constructor(host) {
super(host);
this.rendered = false;
this.tooltipId = 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;
}
ReactTooltip.rebuild();
}
doRender() {
const hoverDelay = this.corePreferences.get(DELAY_PREFERENCE);
return _jsx(ReactTooltip, { id: this.tooltipId, className: 'theia-tooltip', html: true, delayShow: hoverDelay });
}
dispose() {
this.toDispose.dispose();
super.dispose();
}
};
__decorate([
inject(CorePreferences)
], TooltipServiceImpl.prototype, "corePreferences", void 0);
__decorate([
postConstruct()
], TooltipServiceImpl.prototype, "init", null);
TooltipServiceImpl = __decorate([
injectable(),
__param(0, inject(RendererHost)),
__param(0, optional())
], TooltipServiceImpl);
export { TooltipServiceImpl };
//# sourceMappingURL=tooltip-service.js.map