Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -1,14 +1,13 @@
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; };
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; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import debounce from 'lodash/debounce';
import EventListener from 'react-event-listener';
import withStyles from '../styles/withStyles';
const rowsHeight = 24;
const ROWS_HEIGHT = 19;
export const styles = {
root: {
@@ -50,7 +49,7 @@ class Textarea extends React.Component {
return _temp = super(...args), this.state = {
height: null
}, this.handleResize = debounce(event => {
}, this.shadow = null, this.singlelineShadow = null, this.input = null, this.value = null, this.handleResize = debounce(event => {
this.syncHeightWithShadow(event);
}, 166), this.handleRefInput = node => {
this.input = node;
@@ -81,7 +80,7 @@ class Textarea extends React.Component {
// so that it can check whether they are dirty
this.value = this.props.value || this.props.defaultValue || '';
this.setState({
height: Number(this.props.rows) * rowsHeight
height: Number(this.props.rows) * ROWS_HEIGHT
});
}
@@ -171,15 +170,54 @@ class Textarea extends React.Component {
className: classnames(classes.textarea, className),
defaultValue: defaultValue,
value: value,
onChange: this.handleChange
}, other, {
onChange: this.handleChange,
ref: this.handleRefInput
}))
}, other))
);
}
}
Textarea.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* @ignore
*/
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* @ignore
*/
disabled: PropTypes.bool,
/**
* @ignore
*/
onChange: PropTypes.func,
/**
* Number of rows to display when multiline option is set to true.
*/
rows: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* Maximum number of rows to display when multiline option is set to true.
*/
rowsMax: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* Use that property to pass a ref callback to the native textarea element.
*/
textareaRef: PropTypes.func,
/**
* @ignore
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
} : {};
Textarea.defaultProps = {
rows: 1
};
export default withStyles(styles, { name: 'MuiTextarea' })(Textarea);