UNPKG

dockview

Version:

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

73 lines (72 loc) 2.21 kB
import { HostedContainer } from '../../../hostedContainer'; import { ReactPart } from '../../react'; export class ReactContentRenderer { constructor(id, component, reactPortalStore) { this.id = id; this.component = component; this.reactPortalStore = reactPortalStore; this._hostedContainer = new HostedContainer({ id, parent: document .getElementsByClassName('dockview') .item(0), }); this._element = document.createElement('div'); this._element.style.height = '100%'; this._element.style.width = '100%'; } get element() { return this._element; } get onDidBlur() { return this._hostedContainer.onDidBlur; } get onDidFocus() { return this._hostedContainer.onDidFocus; } focus() { // noop } init(parameters) { this.parameters = parameters; parameters.api.onDidVisibilityChange((event) => { if (event.isVisible) { this._hostedContainer.show(); this._hostedContainer.layout(this.element); } else { this._hostedContainer.hide(); } }); this.part = new ReactPart(this._hostedContainer.element, this.reactPortalStore, this.component, { params: parameters.params, api: parameters.api, containerApi: parameters.containerApi, }); } toJSON() { return { id: this.id, }; } update(params) { var _a; if (this.parameters) { this.parameters.params = params.params; } (_a = this.part) === null || _a === void 0 ? void 0 : _a.update(params.params); } updateParentGroup(group, isPanelVisible) { this._group = group; } layout(width, height) { this._hostedContainer.layout(this.element); } close() { return Promise.resolve(true); } dispose() { var _a; (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose(); } }