1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
8 |
|
9 | var _classnames = require('classnames');
|
10 |
|
11 | var _classnames2 = _interopRequireDefault(_classnames);
|
12 |
|
13 | var _react = require('react');
|
14 |
|
15 | var _react2 = _interopRequireDefault(_react);
|
16 |
|
17 | var _propTypes = require('prop-types');
|
18 |
|
19 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
20 |
|
21 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
22 |
|
23 | function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
|
24 |
|
25 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
26 |
|
27 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
28 |
|
29 | 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; }
|
30 |
|
31 | 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) : _defaults(subClass, superClass); }
|
32 |
|
33 | var propTypes = {
|
34 | validationState: _propTypes2["default"].oneOf(['success', 'warning', 'error'])
|
35 | };
|
36 | var defaultProps = {
|
37 | clsPrefix: 'u-form-group'
|
38 | };
|
39 |
|
40 | var FormGroup = function (_React$Component) {
|
41 | _inherits(FormGroup, _React$Component);
|
42 |
|
43 | function FormGroup(props) {
|
44 | _classCallCheck(this, FormGroup);
|
45 |
|
46 | return _possibleConstructorReturn(this, _React$Component.call(this, props));
|
47 | }
|
48 |
|
49 | FormGroup.prototype.render = function render() {
|
50 | var _props = this.props,
|
51 | validationState = _props.validationState,
|
52 | className = _props.className,
|
53 | children = _props.children,
|
54 | clsPrefix = _props.clsPrefix,
|
55 | others = _objectWithoutProperties(_props, ['validationState', 'className', 'children', 'clsPrefix']);
|
56 |
|
57 | var classes = {};
|
58 |
|
59 | if (validationState) {
|
60 | classes['has-' + validationState] = true;
|
61 | }
|
62 |
|
63 | var classNames = (0, _classnames2["default"])(clsPrefix, classes);
|
64 |
|
65 | return _react2["default"].createElement(
|
66 | 'div',
|
67 | _extends({}, others, {
|
68 | className: (0, _classnames2["default"])(className, classNames)
|
69 | }),
|
70 | children
|
71 | );
|
72 | };
|
73 |
|
74 | return FormGroup;
|
75 | }(_react2["default"].Component);
|
76 |
|
77 | FormGroup.propTypes = propTypes;
|
78 | FormGroup.defaultProps = defaultProps;
|
79 |
|
80 | exports["default"] = FormGroup;
|
81 | module.exports = exports['default']; |
\ | No newline at end of file |