{"dependencies":[{"name":"babel-runtime/helpers/extends","loc":{"line":7,"column":24}},{"name":"babel-runtime/helpers/objectWithoutProperties","loc":{"line":11,"column":40}},{"name":"babel-runtime/core-js/object/get-prototype-of","loc":{"line":15,"column":30}},{"name":"babel-runtime/helpers/classCallCheck","loc":{"line":19,"column":31}},{"name":"babel-runtime/helpers/createClass","loc":{"line":23,"column":28}},{"name":"babel-runtime/helpers/possibleConstructorReturn","loc":{"line":27,"column":42}},{"name":"babel-runtime/helpers/inherits","loc":{"line":31,"column":25}},{"name":"simple-assign","loc":{"line":35,"column":28}},{"name":"react","loc":{"line":39,"column":21}},{"name":"prop-types","loc":{"line":43,"column":25}},{"name":"react-event-listener","loc":{"line":47,"column":34}}],"generated":{"js":"'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _extends2 = require('babel-runtime/helpers/extends');\n\nvar _extends3 = _interopRequireDefault(_extends2);\n\nvar _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');\n\nvar _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _simpleAssign = require('simple-assign');\n\nvar _simpleAssign2 = _interopRequireDefault(_simpleAssign);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _reactEventListener = require('react-event-listener');\n\nvar _reactEventListener2 = _interopRequireDefault(_reactEventListener);\n\nfunction _interopRequireDefault(obj) {\n  return obj && obj.__esModule ? obj : { default: obj };\n}\n\nvar rowsHeight = 24;\n\nfunction getStyles(props, context, state) {\n  return {\n    root: {\n      position: 'relative' // because the shadow has position: 'absolute'\n    },\n    textarea: {\n      height: state.height,\n      width: '100%',\n      resize: 'none',\n      font: 'inherit',\n      padding: 0,\n      cursor: 'inherit'\n    },\n    shadow: {\n      resize: 'none',\n      // Overflow also needed to here to remove the extra row\n      // added to textareas in Firefox.\n      overflow: 'hidden',\n      // Visibility needed to hide the extra text area on ipads\n      visibility: 'hidden',\n      position: 'absolute',\n      height: 'auto'\n    }\n  };\n}\n\nvar EnhancedTextarea = function (_Component) {\n  (0, _inherits3.default)(EnhancedTextarea, _Component);\n\n  function EnhancedTextarea() {\n    var _ref;\n\n    var _temp, _this, _ret;\n\n    (0, _classCallCheck3.default)(this, EnhancedTextarea);\n\n    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n\n    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = EnhancedTextarea.__proto__ || (0, _getPrototypeOf2.default)(EnhancedTextarea)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n      height: null\n    }, _this.handleResize = function (event) {\n      _this.syncHeightWithShadow(_this.props.value, event);\n    }, _this.handleChange = function (event) {\n      if (!_this.props.hasOwnProperty('value')) {\n        _this.syncHeightWithShadow(event.target.value);\n      }\n\n      if (_this.props.hasOwnProperty('valueLink')) {\n        _this.props.valueLink.requestChange(event.target.value);\n      }\n\n      if (_this.props.onChange) {\n        _this.props.onChange(event);\n      }\n    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);\n  }\n\n  (0, _createClass3.default)(EnhancedTextarea, [{\n    key: 'componentWillMount',\n    value: function componentWillMount() {\n      this.setState({\n        height: this.props.rows * rowsHeight\n      });\n    }\n  }, {\n    key: 'componentDidMount',\n    value: function componentDidMount() {\n      this.syncHeightWithShadow(this.props.value);\n    }\n  }, {\n    key: 'componentWillReceiveProps',\n    value: function componentWillReceiveProps(nextProps) {\n      if (nextProps.value !== this.props.value || nextProps.rowsMax !== this.props.rowsMax) {\n        this.syncHeightWithShadow(nextProps.value, null, nextProps);\n      }\n    }\n  }, {\n    key: 'getInputNode',\n    value: function getInputNode() {\n      return this.refs.input;\n    }\n  }, {\n    key: 'setValue',\n    value: function setValue(value) {\n      this.getInputNode().value = value;\n      this.syncHeightWithShadow(value);\n    }\n  }, {\n    key: 'syncHeightWithShadow',\n    value: function syncHeightWithShadow(newValue, event, props) {\n      var shadow = this.refs.shadow;\n      var displayText = this.props.hintText && (newValue === '' || newValue === undefined || newValue === null) ? this.props.hintText : newValue;\n\n      if (displayText !== undefined) {\n        shadow.value = displayText;\n      }\n\n      var newHeight = shadow.scrollHeight;\n\n      // Guarding for jsdom, where scrollHeight isn't present.\n      // See https://github.com/tmpvar/jsdom/issues/1013\n      if (newHeight === undefined) return;\n\n      props = props || this.props;\n\n      if (props.rowsMax >= props.rows) {\n        newHeight = Math.min(props.rowsMax * rowsHeight, newHeight);\n      }\n\n      newHeight = Math.max(newHeight, rowsHeight);\n\n      if (this.state.height !== newHeight) {\n        var input = this.refs.input;\n        var cursorPosition = input.selectionStart;\n        this.setState({\n          height: newHeight\n        }, function () {\n          input.setSelectionRange(cursorPosition, cursorPosition);\n        });\n\n        if (props.onHeightChange) {\n          props.onHeightChange(event, newHeight);\n        }\n      }\n    }\n  }, {\n    key: 'render',\n    value: function render() {\n      var _props = this.props,\n          onChange = _props.onChange,\n          onHeightChange = _props.onHeightChange,\n          rows = _props.rows,\n          rowsMax = _props.rowsMax,\n          shadowStyle = _props.shadowStyle,\n          style = _props.style,\n          hintText = _props.hintText,\n          textareaStyle = _props.textareaStyle,\n          valueLink = _props.valueLink,\n          other = (0, _objectWithoutProperties3.default)(_props, ['onChange', 'onHeightChange', 'rows', 'rowsMax', 'shadowStyle', 'style', 'hintText', 'textareaStyle', 'valueLink']);\n      var prepareStyles = this.context.muiTheme.prepareStyles;\n\n      var styles = getStyles(this.props, this.context, this.state);\n      var rootStyles = (0, _simpleAssign2.default)(styles.root, style);\n      var textareaStyles = (0, _simpleAssign2.default)(styles.textarea, textareaStyle);\n      var shadowStyles = (0, _simpleAssign2.default)({}, textareaStyles, styles.shadow, shadowStyle);\n      var props = {};\n\n      if (this.props.hasOwnProperty('valueLink')) {\n        other.value = valueLink.value;\n        props.valueLink = valueLink;\n      }\n\n      return _react2.default.createElement('div', { style: prepareStyles(rootStyles) }, _react2.default.createElement(_reactEventListener2.default, { target: 'window', onResize: this.handleResize }), _react2.default.createElement('textarea', (0, _extends3.default)({\n        ref: 'shadow',\n        style: prepareStyles(shadowStyles),\n        tabIndex: '-1',\n        rows: this.props.rows,\n        defaultValue: this.props.defaultValue,\n        readOnly: true,\n        value: this.props.value\n      }, props)), _react2.default.createElement('textarea', (0, _extends3.default)({}, other, {\n        ref: 'input',\n        rows: this.props.rows,\n        style: prepareStyles(textareaStyles),\n        onChange: this.handleChange\n      })));\n    }\n  }]);\n  return EnhancedTextarea;\n}(_react.Component);\n\nEnhancedTextarea.defaultProps = {\n  rows: 1\n};\nEnhancedTextarea.contextTypes = {\n  muiTheme: _propTypes2.default.object.isRequired\n};\nEnhancedTextarea.propTypes = \"development\" !== \"production\" ? {\n  defaultValue: _propTypes2.default.any,\n  disabled: _propTypes2.default.bool,\n  hintText: _propTypes2.default.node,\n  onChange: _propTypes2.default.func,\n  onHeightChange: _propTypes2.default.func,\n  rows: _propTypes2.default.number,\n  rowsMax: _propTypes2.default.number,\n  shadowStyle: _propTypes2.default.object,\n  /**\n   * Override the inline-styles of the root element.\n   */\n  style: _propTypes2.default.object,\n  textareaStyle: _propTypes2.default.object,\n  value: _propTypes2.default.string,\n  valueLink: _propTypes2.default.object\n} : {};\nexports.default = EnhancedTextarea;"},"hash":"b73432e247e5a5f6d66a2303bc3b6966"}