Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
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);
    }
}
__decorate([
    mobx_1.observable
], SidebarItemState.prototype, "identifier", void 0);
__decorate([
    mobx_1.observable
], SidebarItemState.prototype, "isVisible", void 0);
__decorate([
    mobx_1.observable
], SidebarItemState.prototype, "contents", void 0);
__decorate([
    mobx_1.action
], SidebarItemState.prototype, "setIdentifier", null);
__decorate([
    mobx_1.action
], SidebarItemState.prototype, "setContents", null);
__decorate([
    mobx_1.action
], SidebarItemState.prototype, "setRender", null);
__decorate([
    mobx_1.action
], SidebarItemState.prototype, "setIsVisible", null);
__decorate([
    mobx_1.action.bound
], SidebarItemState.prototype, "handleHide", null);
__decorate([
    mobx_1.action.bound
], SidebarItemState.prototype, "handleShow", null);
__decorate([
    mobx_1.action.bound
], SidebarItemState.prototype, "handleToggle", null);
exports.SidebarItemState = SidebarItemState;
//# sourceMappingURL=State.js.map