UNPKG

catreact

Version:

Catavolt Core React Components

48 lines (47 loc) 1.65 kB
"use strict"; /** * Created by rburson on 3/17/16. */ var React = require('react'); var catreact_core_1 = require('./catreact-core'); var catavolt_sdk_1 = require('catavolt-sdk'); /* *************************************************** * A component analogous to Catavolt AppWinDef *************************************************** */ exports.CvWorkbenchMenu = React.createClass({ mixins: [catreact_core_1.CvBaseMixin], appWinDef: function () { return this.props.appWinDef || this.firstInScope(catavolt_sdk_1.AppWinDef); }, getChildContext: function () { var ctx = this.getDefaultChildContext(); ctx.cvContext.scopeCtx.scopeObj = this.appWinDef(); return ctx; }, getDefaultProps: function () { return { appWindDef: null, menuItemRenderer: null, wrapperElemName: 'span', wrapperElemProps: {} }; }, render: function () { var _this = this; var appWinDef = this.appWinDef(); if (appWinDef) { if (this.props.menuItemRenderer) { return React.createElement(this.props.wrapperElemName, this.props.wrapperElemProps, appWinDef.workbenches.map(function (workbench) { return _this.props.menuItemRenderer(workbench); })); } else if (this.props.renderer) { return this.props.renderer(this.getChildContext().cvContext); } else if (React.Children.count(this.props.children) > 0) { return this.props.children; } else { return null; } } else { return null; } }, });