UNPKG

catreact

Version:

Catavolt Core React Components

32 lines (31 loc) 1 kB
"use strict"; /** * Created by rburson on 1/11/16. */ Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var catreact_core_1 = require("./catreact-core"); /* *************************************************** * Exposes the scope of the enclosing tag via the handler function *************************************************** */ exports.CvScope = React.createClass({ mixins: [catreact_core_1.CvBaseMixin], getDefaultProps: function () { return { handler: null, get: null }; }, render: function () { if (this.scopeCtx().scopeObj) { var scopeObj = this.scopeCtx().scopeObj; if (this.props.get) { var value = scopeObj[this.props.get]; return value ? React.createElement("span", null, value) : null; } else if (this.props.handler) { return this.props.handler(scopeObj); } } return null; }, });