UNPKG

dockview

Version:

Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support

100 lines 4.57 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ContentContainer = void 0; var lifecycle_1 = require("../../lifecycle"); var events_1 = require("../../events"); var dom_1 = require("../../dom"); var ContentContainer = /** @class */ (function (_super) { __extends(ContentContainer, _super); function ContentContainer() { var _this = _super.call(this) || this; _this.disposable = new lifecycle_1.MutableDisposable(); _this._onDidFocus = new events_1.Emitter(); _this.onDidFocus = _this._onDidFocus.event; _this._onDidBlur = new events_1.Emitter(); _this.onDidBlur = _this._onDidBlur.event; _this._element = document.createElement('div'); _this._element.className = 'content-container'; _this._element.tabIndex = -1; return _this; // for hosted containers // 1) register a drop target on the host // 2) register window dragStart events to disable pointer events // 3) register dragEnd events // 4) register mouseMove events (if no buttons are present we take this as a dragEnd event) } Object.defineProperty(ContentContainer.prototype, "element", { get: function () { return this._element; }, enumerable: false, configurable: true }); ContentContainer.prototype.show = function () { this.element.style.display = ''; }; ContentContainer.prototype.hide = function () { this.element.style.display = 'none'; }; ContentContainer.prototype.openPanel = function (panel) { var _this = this; var _a; if (this.panel === panel) { return; } if (this.panel) { if ((_a = this.panel.view) === null || _a === void 0 ? void 0 : _a.content) { this._element.removeChild(this.panel.view.content.element); } this.panel = undefined; } this.panel = panel; var disposable = new lifecycle_1.CompositeDisposable(); if (this.panel.view) { var _onDidFocus = this.panel.view.content.onDidFocus; var _onDidBlur = this.panel.view.content.onDidBlur; var _b = (0, dom_1.trackFocus)(this._element), onDidFocus = _b.onDidFocus, onDidBlur = _b.onDidBlur; disposable.addDisposables(onDidFocus(function () { return _this._onDidFocus.fire(); }), onDidBlur(function () { return _this._onDidBlur.fire(); })); if (_onDidFocus) { disposable.addDisposables(_onDidFocus(function () { return _this._onDidFocus.fire(); })); } if (_onDidBlur) { disposable.addDisposables(_onDidBlur(function () { return _this._onDidBlur.fire(); })); } this._element.appendChild(this.panel.view.content.element); } this.disposable.value = disposable; }; ContentContainer.prototype.layout = function (width, height) { // noop }; ContentContainer.prototype.closePanel = function () { var _a, _b, _c; if ((_c = (_b = (_a = this.panel) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.element) { this._element.removeChild(this.panel.view.content.element); this.panel = undefined; } }; ContentContainer.prototype.dispose = function () { this.disposable.dispose(); _super.prototype.dispose.call(this); }; return ContentContainer; }(lifecycle_1.CompositeDisposable)); exports.ContentContainer = ContentContainer; //# sourceMappingURL=content.js.map