hbp-quickfire
Version:
A library of useful user-interface components built with React on top of React Bootstrap and MobX
43 lines (29 loc) • 11.6 kB
JavaScript
var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var _dec, _class;function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;} /*
* Copyright (c) Human Brain Project
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from "react";
import { inject, observer } from "mobx-react";import ControlLabel from "react-bootstrap/lib/ControlLabel";import OverlayTrigger from "react-bootstrap/lib/OverlayTrigger";import Tooltip from "react-bootstrap/lib/Tooltip";import Glyphicon from "react-bootstrap/lib/Glyphicon";
/**
* Label for all fields
* @class FieldLabel
* @memberof FormFields
*/var
FieldLabel = (_dec = inject("formStore"), _dec(_class = observer(_class = function (_React$Component) {_inherits(FieldLabel, _React$Component);function FieldLabel() {_classCallCheck(this, FieldLabel);return _possibleConstructorReturn(this, (FieldLabel.__proto__ || Object.getPrototypeOf(FieldLabel)).apply(this, arguments));}_createClass(FieldLabel, [{ key: "render", value: function render()
{var _props$field =
this.props.field,label = _props$field.label,labelTooltip = _props$field.labelTooltip,labelTooltipPlacement = _props$field.labelTooltipPlacement;
if (!label) {
return null;
} else if (labelTooltip) {
return (
React.createElement(ControlLabel, { className: "quickfire-label" },
label, "\xA0",
React.createElement(OverlayTrigger, { placement: labelTooltipPlacement, overlay: React.createElement(Tooltip, { id: this.props.formStore.getGeneratedKey(this.props.field, "label-tooltip") }, labelTooltip) },
React.createElement(Glyphicon, { glyph: "question-sign" }))));
} else {
return (
React.createElement(ControlLabel, { className: "quickfire-label" }, label));
}
} }]);return FieldLabel;}(React.Component)) || _class) || _class);export { FieldLabel as default };