Repository URL to install this package:
|
Version:
4.0.29 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const mobx_1 = require("xmobx/mobx");
const renderProps_1 = require("./renderProps");
const EMPTY = '@@EMPTY';
class SidebarItemState {
constructor() {
this.store = mobx_1.observable.map();
this.identifier = ''; // @todo default not visible?
this.isVisible = true; // @alias children
this.contents = EMPTY;
}
static init() {
return new SidebarItemState();
}
render(props) {
console.debug('[SidebarItem] render');
if (this.store.has('render')) {
console.info('[SidebarItem] render with a specified render');
const renderedValue = this.store.get('render')(props);
return renderedValue;
} else if (this.contents !== EMPTY) {
console.info('[SidebarItem] returning contents');
return this.contents;
} else {
return renderProps_1.renderStyledSidebar(props);
}
}
/**
* these setters are @chainable
*/
setIdentifier(identifier) {
this.identifier = identifier;
return this;
}
setContents(contents) {
this.contents = contents;
return this;
}
setRender(renderProp) {
this.store.set('render', renderProp);
return this;
}
setIsVisible(isVisible) {
console.log('[Sidebar] Item.State setIsVisible ', this.identifier, this.isVisible);
this.isVisible = isVisible;
return this;
}
handleHide() {
this.setIsVisible(false);
}
handleShow() {
this.setIsVisible(true);
}
handleToggle() {
this.setIsVisible(!this.isVisible);
}
}
tslib_1.__decorate([mobx_1.observable], SidebarItemState.prototype, "identifier", void 0);
tslib_1.__decorate([mobx_1.observable], SidebarItemState.prototype, "isVisible", void 0);
tslib_1.__decorate([mobx_1.observable], SidebarItemState.prototype, "contents", void 0);
tslib_1.__decorate([mobx_1.action], SidebarItemState.prototype, "setIdentifier", null);
tslib_1.__decorate([mobx_1.action], SidebarItemState.prototype, "setContents", null);
tslib_1.__decorate([mobx_1.action], SidebarItemState.prototype, "setRender", null);
tslib_1.__decorate([mobx_1.action], SidebarItemState.prototype, "setIsVisible", null);
tslib_1.__decorate([mobx_1.action.bound], SidebarItemState.prototype, "handleHide", null);
tslib_1.__decorate([mobx_1.action.bound], SidebarItemState.prototype, "handleShow", null);
tslib_1.__decorate([mobx_1.action.bound], SidebarItemState.prototype, "handleToggle", null);
exports.SidebarItemState = SidebarItemState; //# sourceMappingURL=SidebarItemState.js.map