dockview-solid
Version:
Zero dependency layout manager supporting tabs, grids and splitviews
46 lines (45 loc) • 1.97 kB
JavaScript
import { DockviewCompositeDisposable, DockviewMutableDisposable } from 'dockview-core';
import { SolidPart } from '../solid';
/**
* SolidJS implementation of IHeaderActionsRenderer: mounts Solid components into group header actions.
*/
export class SolidHeaderActionsRendererPart {
constructor(component, _group) {
this.component = component;
this._group = _group;
this.mutableDisposable = new DockviewMutableDisposable();
this.element = document.createElement('div');
this.element.className = 'dv-solid-part';
this.element.style.height = '100%';
this.element.style.width = '100%';
}
init(parameters) {
this.mutableDisposable.value = new DockviewCompositeDisposable(this._group.model.onDidAddPanel(() => this.updatePanels()), this._group.model.onDidRemovePanel(() => this.updatePanels()), this._group.model.onDidActivePanelChange(() => this.updateActivePanel()), parameters.api.onDidActiveChange(() => this.updateGroupActive()));
this.part = new SolidPart(this.element, this.component, {
api: parameters.api,
containerApi: parameters.containerApi,
panels: this._group.model.panels,
activePanel: this._group.model.activePanel,
isGroupActive: this._group.api.isActive,
group: this._group,
});
}
update(event) {
var _a;
(_a = this.part) === null || _a === void 0 ? void 0 : _a.update(event.params);
}
dispose() {
var _a;
this.mutableDisposable.dispose();
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
}
updatePanels() {
this.update({ params: { panels: this._group.model.panels } });
}
updateActivePanel() {
this.update({ params: { activePanel: this._group.model.activePanel } });
}
updateGroupActive() {
this.update({ params: { isGroupActive: this._group.api.isActive } });
}
}