UNPKG

dockview

Version:

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

187 lines 6.87 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 __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DefaultTab = exports.WrappedTab = void 0; var lifecycle_1 = require("../../../lifecycle"); var events_1 = require("../../../events"); var dom_1 = require("../../../dom"); var WrappedTab = /** @class */ (function () { function WrappedTab(renderer) { this.renderer = renderer; this._element = document.createElement('element'); this.show(); } Object.defineProperty(WrappedTab.prototype, "innerRenderer", { get: function () { return this.renderer; }, enumerable: false, configurable: true }); Object.defineProperty(WrappedTab.prototype, "element", { get: function () { return this._element; }, enumerable: false, configurable: true }); Object.defineProperty(WrappedTab.prototype, "id", { get: function () { return this.renderer.id; }, enumerable: false, configurable: true }); WrappedTab.prototype.show = function () { if (!this.renderer.element.parentElement) { this._element.appendChild(this.renderer.element); } }; WrappedTab.prototype.hide = function () { if (this.renderer.element.parentElement) { this.renderer.element.remove(); } }; WrappedTab.prototype.layout = function (width, height) { this.renderer.layout(width, height); }; WrappedTab.prototype.update = function (event) { this.renderer.update(event); }; WrappedTab.prototype.toJSON = function () { return this.renderer.toJSON(); }; WrappedTab.prototype.focus = function () { this.renderer.focus(); }; WrappedTab.prototype.init = function (parameters) { this.renderer.init(parameters); }; WrappedTab.prototype.updateParentGroup = function (group, isPanelVisible) { this.renderer.updateParentGroup(group, isPanelVisible); }; WrappedTab.prototype.dispose = function () { this.renderer.dispose(); }; return WrappedTab; }()); exports.WrappedTab = WrappedTab; var DefaultTab = /** @class */ (function (_super) { __extends(DefaultTab, _super); function DefaultTab() { var _this = _super.call(this) || this; _this._isPanelVisible = false; _this._isGroupActive = false; // _this.params = {}; // _this.isDirtyDisposable = new lifecycle_1.MutableDisposable(); _this.addDisposables(_this.isDirtyDisposable); _this._element = document.createElement('div'); _this._element.className = 'default-tab'; // _this._content = document.createElement('div'); _this._content.className = 'tab-content'; // _this._actionContainer = document.createElement('div'); _this._actionContainer.className = 'action-container'; // _this._list = document.createElement('ul'); _this._list.className = 'tab-list'; // _this.action = document.createElement('a'); _this.action.className = 'tab-action'; // _this._element.appendChild(_this._content); _this._element.appendChild(_this._actionContainer); _this._actionContainer.appendChild(_this._list); _this._list.appendChild(_this.action); // _this.addDisposables((0, events_1.addDisposableListener)(_this._actionContainer, 'mousedown', function (ev) { ev.preventDefault(); })); _this.render(); return _this; } Object.defineProperty(DefaultTab.prototype, "element", { get: function () { return this._element; }, enumerable: false, configurable: true }); Object.defineProperty(DefaultTab.prototype, "id", { get: function () { return '__DEFAULT_TAB__'; }, enumerable: false, configurable: true }); DefaultTab.prototype.update = function (event) { this.params = __assign(__assign({}, this.params), event.params); this.render(); }; DefaultTab.prototype.toJSON = function () { return { id: this.id }; }; DefaultTab.prototype.focus = function () { //noop }; DefaultTab.prototype.init = function (params) { var _this = this; this.params = params; this._content.textContent = params.title; this.isDirtyDisposable.value = this.params.api.onDidDirtyChange(function (event) { var isDirty = event; (0, dom_1.toggleClass)(_this.action, 'dirty', isDirty); }); if (!this.params.suppressClosable) { (0, events_1.addDisposableListener)(this.action, 'click', function (ev) { ev.preventDefault(); // _this.params.api.close(); }); } else { this.action.classList.add('disable-close'); } }; DefaultTab.prototype.updateParentGroup = function (group, isPanelVisible) { this._isPanelVisible = isPanelVisible; this._isGroupActive = group.isActive; this.render(); }; DefaultTab.prototype.layout = function (width, height) { // noop }; DefaultTab.prototype.render = function () { this._content.textContent = this.params.title; }; return DefaultTab; }(lifecycle_1.CompositeDisposable)); exports.DefaultTab = DefaultTab; //# sourceMappingURL=defaultTab.js.map