diff options
author | Francesco <firefelix@gmail.com> | 2015-06-19 13:22:27 +0200 |
---|---|---|
committer | Francesco <firefelix@gmail.com> | 2015-06-19 13:28:34 +0200 |
commit | d4867b2d0bc99f50781c8d577b054d034b567623 (patch) | |
tree | 03fb7a0ec9832ec62f8b3a47d423d96db7b9c8bd /lib/TextareaAutosize.js | |
parent | e627fbb0b9c2eb3ba2e3bacfdb1c9f1c8d49421b (diff) | |
download | react-autosize-textarea-d4867b2d0bc99f50781c8d577b054d034b567623.zip react-autosize-textarea-d4867b2d0bc99f50781c8d577b054d034b567623.tar.gz react-autosize-textarea-d4867b2d0bc99f50781c8d577b054d034b567623.tar.bz2 |
updated to new web-lib-seed release
Diffstat (limited to 'lib/TextareaAutosize.js')
-rw-r--r-- | lib/TextareaAutosize.js | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/TextareaAutosize.js b/lib/TextareaAutosize.js deleted file mode 100644 index 822dcbc..0000000 --- a/lib/TextareaAutosize.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -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; }; - -var React = require('react'), - autosize = require('autosize'), - UPDATE = 'autosize:update', - DESTROY = 'autosize:destroy', - RESIZED = 'autosize:resized'; - -var TextareaAutosize = React.createClass({ - displayName: 'TextareaAutosize', - - propTypes: { - onResize: React.PropTypes.func - }, - - getDefaultProps: function getDefaultProps() { - return { - rows: 1 - }; - }, - - componentDidMount: function componentDidMount() { - autosize(this.refs.textarea.getDOMNode()); - if (this.props.onResize) { - this.refs.textarea.getDOMNode().addEventListener(RESIZED, this.props.onResize); - } - }, - - componentWillUnmount: function componentWillUnmount() { - if (this.props.onResize) { - this.refs.textarea.getDOMNode().removeEventListener(RESIZED); - } - this.dispatchEvent(DESTROY); - }, - - dispatchEvent: function dispatchEvent(EVENT_TYPE) { - var _this = this; - - var event = document.createEvent('Event'); - event.initEvent(EVENT_TYPE, true, false); - setTimeout(function () { - return _this.refs.textarea.getDOMNode().dispatchEvent(event); - }); - }, - - getValue: function getValue(props) { - if (props) { - return props.valueLink ? props.valueLink.value : props.value; - } - }, - - render: function render() { - return React.createElement( - 'textarea', - _extends({}, this.props, { ref: 'textarea' }), - this.props.children - ); - }, - - componentWillReceiveProps: function componentWillReceiveProps(nextProps) { - if (this.getValue(nextProps) !== this.getValue(this.props)) { - this.dispatchEvent(UPDATE); - } - } - -}); - -module.exports = TextareaAutosize;
\ No newline at end of file |