import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import classNames from 'classnames'; import React from 'react'; import elementType from 'react-prop-types/lib/elementType'; import warning from 'warning'; import FormControlFeedback from './FormControlFeedback'; import FormControlStatic from './FormControlStatic'; import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils'; var propTypes = { componentClass: elementType, /** * Only relevant if `componentClass` is `'input'`. */ type: React.PropTypes.string, /** * Uses `controlId` from `` if not explicitly specified. */ id: React.PropTypes.string, /** * Attaches a ref to the `` element. Only functions can be used here. * * ```js * { this.input = ref; }} /> * ``` */ inputRef: React.PropTypes.func }; var defaultProps = { componentClass: 'input' }; var contextTypes = { $bs_formGroup: React.PropTypes.object }; var FormControl = function (_React$Component) { _inherits(FormControl, _React$Component); function FormControl() { _classCallCheck(this, FormControl); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } FormControl.prototype.render = function render() { var formGroup = this.context.$bs_formGroup; var controlId = formGroup && formGroup.controlId; var _props = this.props, Component = _props.componentClass, type = _props.type, _props$id = _props.id, id = _props$id === undefined ? controlId : _props$id, inputRef = _props.inputRef, className = _props.className, props = _objectWithoutProperties(_props, ['componentClass', 'type', 'id', 'inputRef', 'className']); var _splitBsProps = splitBsProps(props), bsProps = _splitBsProps[0], elementProps = _splitBsProps[1]; process.env.NODE_ENV !== 'production' ? warning(controlId == null || id === controlId, '`controlId` is ignored on `` when `id` is specified.') : void 0; // input[type="file"] should not have .form-control. var classes = void 0; if (type !== 'file') { classes = getClassSet(bsProps); } return React.createElement(Component, _extends({}, elementProps, { type: type, id: id, ref: inputRef, className: classNames(className, classes) })); }; return FormControl; }(React.Component); FormControl.propTypes = propTypes; FormControl.defaultProps = defaultProps; FormControl.contextTypes = contextTypes; FormControl.Feedback = FormControlFeedback; FormControl.Static = FormControlStatic; export default bsClass('form-control', FormControl);