dockview
Version:
Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support
76 lines (75 loc) • 2.53 kB
JavaScript
import { ReactPart } from '../react';
import { Emitter } from '../../events';
export class ReactPanelContentPart {
constructor(id, component, reactPortalStore) {
this.id = id;
this.component = component;
this.reactPortalStore = reactPortalStore;
// private hostedContainer: HostedContainer;
this._onDidFocus = new Emitter();
this.onDidFocus = this._onDidFocus.event;
this._onDidBlur = new Emitter();
this.onDidBlur = this._onDidBlur.event;
this._element = document.createElement('div');
this._element.style.height = '100%';
this._element.style.width = '100%';
// this.hostedContainer = new HostedContainer({
// id,
// });
// this.hostedContainer.onDidFocus(() => this._onDidFocus.fire());
// this.hostedContainer.onDidBlur(() => this._onDidBlur.fire());
this._actionsElement = document.createElement('div');
this._actionsElement.style.height = '100%';
this._actionsElement.style.width = '100%';
}
get element() {
return this._element;
}
get actions() {
return this._actionsElement;
}
focus() {
// TODO
}
init(parameters) {
const context = {
api: parameters.api,
containerApi: parameters.containerApi,
actionsPortalElement: this._actionsElement,
tabPortalElement: parameters.tab,
};
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
params: parameters.params,
api: parameters.api,
containerApi: parameters.containerApi,
}, context);
}
toJSON() {
return {
id: this.id,
};
}
update(event) {
var _a;
(_a = this.part) === null || _a === void 0 ? void 0 : _a.update(event.params);
}
updateParentGroup(group, isPanelVisible) {
this._group = group;
}
layout(width, height) {
// noop
// this.hostedContainer.layout(
// this.element
// // { width, height }
// );
}
close() {
return Promise.resolve(true);
}
dispose() {
var _a, _b;
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
// this.hostedContainer?.dispose();
(_b = this.actionsPart) === null || _b === void 0 ? void 0 : _b.dispose();
}
}