dockview
Version:
Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support
116 lines • 4.74 kB
JavaScript
;
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.BasePanelView = void 0;
var dom_1 = require("../dom");
var lifecycle_1 = require("../lifecycle");
var BasePanelView = /** @class */ (function (_super) {
__extends(BasePanelView, _super);
function BasePanelView(id, component, api) {
var _this = _super.call(this) || this;
_this.id = id;
_this.component = component;
_this.api = api;
_this._height = 0;
_this._width = 0;
_this._element = document.createElement('div');
_this._element.tabIndex = -1;
_this._element.style.outline = 'none';
_this._element.style.height = '100%';
_this._element.style.width = '100%';
_this._element.style.overflow = 'hidden';
var _a = (0, dom_1.trackFocus)(_this._element), onDidFocus = _a.onDidFocus, onDidBlur = _a.onDidBlur;
_this.addDisposables(_this.api, onDidFocus(function () {
_this.api._onDidChangeFocus.fire({ isFocused: true });
}), onDidBlur(function () {
_this.api._onDidChangeFocus.fire({ isFocused: false });
}));
return _this;
}
Object.defineProperty(BasePanelView.prototype, "element", {
get: function () {
return this._element;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BasePanelView.prototype, "width", {
get: function () {
return this._width;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BasePanelView.prototype, "height", {
get: function () {
return this._height;
},
enumerable: false,
configurable: true
});
BasePanelView.prototype.focus = function () {
this.api._onFocusEvent.fire();
};
BasePanelView.prototype.layout = function (width, height) {
this._width = width;
this._height = height;
this.api._onDidPanelDimensionChange.fire({ width: width, height: height });
if (this.part) {
if (this.params) {
this.part.update(this.params.params);
}
}
};
BasePanelView.prototype.init = function (parameters) {
this.params = parameters;
this.part = this.getComponent();
};
BasePanelView.prototype.update = function (event) {
var _a, _b;
this.params = __assign(__assign({}, this.params), { params: __assign(__assign({}, (_a = this.params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this.params.params });
};
BasePanelView.prototype.toJSON = function () {
var _a, _b;
var state = this.api.getState();
var params = (_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
return {
id: this.id,
component: this.component,
params: Object.keys(params).length > 0 ? params : undefined,
state: Object.keys(state).length === 0 ? undefined : state,
};
};
BasePanelView.prototype.dispose = function () {
_super.prototype.dispose.call(this);
this.api.dispose();
};
return BasePanelView;
}(lifecycle_1.CompositeDisposable));
exports.BasePanelView = BasePanelView;
//# sourceMappingURL=basePanelView.js.map