1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __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 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | var __param = (this && this.__param) || function (paramIndex, decorator) {
|
27 | return function (target, key) { decorator(target, key, paramIndex); }
|
28 | };
|
29 | Object.defineProperty(exports, "__esModule", { value: true });
|
30 | exports.TooltipServiceImpl = exports.TooltipService = void 0;
|
31 | const inversify_1 = require("inversify");
|
32 | const React = require("react");
|
33 | const react_tooltip_1 = require("react-tooltip");
|
34 | const react_renderer_1 = require("./widgets/react-renderer");
|
35 | const core_preferences_1 = require("./core-preferences");
|
36 | const uuid_1 = require("uuid");
|
37 | exports.TooltipService = Symbol('TooltipService');
|
38 | const DELAY_PREFERENCE = 'workbench.hover.delay';
|
39 | let 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);
|
81 | TooltipServiceImpl = __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);
|
87 | exports.TooltipServiceImpl = TooltipServiceImpl;
|
88 |
|
\ | No newline at end of file |