Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-textarea-autosize

Package Overview
Dependencies
Maintainers
2
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-textarea-autosize - npm Package Compare versions

Comparing version 2.5.4 to 3.0.0

186

lib/TextareaAutosize.js

@@ -0,31 +1,32 @@

/**
* <TextareaAutosize />
*/
'use strict';
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
Object.defineProperty(exports, '__esModule', {
value: true
});
var _objectWithoutProperties = function (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; };
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 _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _inherits = function (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) subClass.__proto__ = superClass; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
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; }
Object.defineProperty(exports, '__esModule', {
value: true
});
/**
* <TextareaAutosize />
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _React = require('react');
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) : subClass.__proto__ = superClass; }
var _React2 = _interopRequireWildcard(_React);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _calculateNodeHeight = require('./calculateNodeHeight');
var _calculateNodeHeight2 = _interopRequireWildcard(_calculateNodeHeight);
var _calculateNodeHeight2 = _interopRequireDefault(_calculateNodeHeight);

@@ -35,2 +36,57 @@ var emptyFunction = function emptyFunction() {};

var TextareaAutosize = (function (_React$Component) {
_inherits(TextareaAutosize, _React$Component);
_createClass(TextareaAutosize, null, [{
key: 'propTypes',
value: {
/**
* Current textarea value.
*/
value: _react2['default'].PropTypes.string,
/**
* Callback on value change.
*/
onChange: _react2['default'].PropTypes.func,
/**
* Callback on height changes.
*/
onHeightChange: _react2['default'].PropTypes.func,
/**
* Try to cache DOM measurements performed by component so that we don't
* touch DOM when it's not needed.
*
* This optimization doesn't work if we dynamically style <textarea />
* component.
*/
useCacheForDOMMeasurements: _react2['default'].PropTypes.bool,
/**
* Minimal numbder of rows to show.
*/
rows: _react2['default'].PropTypes.number,
/**
* Alias for `rows`.
*/
minRows: _react2['default'].PropTypes.number,
/**
* Maximum number of rows to show.
*/
maxRows: _react2['default'].PropTypes.number
},
enumerable: true
}, {
key: 'defaultProps',
value: {
onChange: emptyFunction,
onHeightChange: emptyFunction,
useCacheForDOMMeasurements: false
},
enumerable: true
}]);
function TextareaAutosize(props) {

@@ -45,8 +101,9 @@ _classCallCheck(this, TextareaAutosize);

};
this._onNextFrameActionId = null;
this._rootDOMNode = null;
this._onChange = this._onChange.bind(this);
this._resizeComponent = this._resizeComponent.bind(this);
this._onRootDOMNode = this._onRootDOMNode.bind(this);
}
_inherits(TextareaAutosize, _React$Component);
_createClass(TextareaAutosize, [{

@@ -72,3 +129,6 @@ key: 'render',

}
return _React2['default'].createElement('textarea', _extends({}, props, { onChange: this._onChange }));
return _react2['default'].createElement('textarea', _extends({}, props, {
onChange: this._onChange,
ref: this._onRootDOMNode
}));
}

@@ -85,4 +145,4 @@ }, {

// Re-render with the new content then recalculate the height as required.
this.clearNextFrame();
this.onNextFrameActionId = onNextFrame(this._resizeComponent);
this._clearNextFrame();
this._onNextFrameActionId = onNextFrame(this._resizeComponent);
}

@@ -100,15 +160,20 @@ }, {

value: function componentWillUnmount() {
//remove any scheduled events to prevent manipulating the node after it's
//been unmounted
this.clearNextFrame();
// Remove any scheduled events to prevent manipulating the node after it's
// been unmounted.
this._clearNextFrame();
window.removeEventListener('resize', this._resizeComponent);
}
}, {
key: 'clearNextFrame',
value: function clearNextFrame() {
if (this.onNextFrameActionId) {
clearNextFrameAction(this.onNextFrameActionId);
key: '_clearNextFrame',
value: function _clearNextFrame() {
if (this._onNextFrameActionId) {
clearNextFrameAction(this._onNextFrameActionId);
}
}
}, {
key: '_onRootDOMNode',
value: function _onRootDOMNode(node) {
this._rootDOMNode = node;
}
}, {
key: '_onChange',

@@ -132,6 +197,4 @@ value: function _onChange(e) {

this.setState(_calculateNodeHeight2['default'](_React2['default'].findDOMNode(this), useCacheForDOMMeasurements, this.props.rows || this.props.minRows, this.props.maxRows));
this.setState((0, _calculateNodeHeight2['default'])(this._rootDOMNode, useCacheForDOMMeasurements, this.props.rows || this.props.minRows, this.props.maxRows));
}
}, {
key: 'value',

@@ -141,5 +204,2 @@ /**

*/
get: function () {
return _React2['default'].findDOMNode(this).value;
}
}, {

@@ -152,59 +212,13 @@ key: 'focus',

value: function focus() {
_React2['default'].findDOMNode(this).focus();
this._rootDOMNode.focus();
}
}], [{
key: 'propTypes',
value: {
/**
* Current textarea value.
*/
value: _React2['default'].PropTypes.string,
/**
* Callback on value change.
*/
onChange: _React2['default'].PropTypes.func,
/**
* Callback on height changes.
*/
onHeightChange: _React2['default'].PropTypes.func,
/**
* Try to cache DOM measurements performed by component so that we don't
* touch DOM when it's not needed.
*
* This optimization doesn't work if we dynamically style <textarea />
* component.
*/
useCacheForDOMMeasurements: _React2['default'].PropTypes.bool,
/**
* Minimal numbder of rows to show.
*/
rows: _React2['default'].PropTypes.number,
/**
* Alias for `rows`.
*/
minRows: _React2['default'].PropTypes.number,
/**
* Maximum number of rows to show.
*/
maxRows: _React2['default'].PropTypes.number
},
enumerable: true
}, {
key: 'defaultProps',
value: {
onChange: emptyFunction,
onHeightChange: emptyFunction,
useCacheForDOMMeasurements: false
},
enumerable: true
key: 'value',
get: function get() {
return this._rootDOMNode.value;
}
}]);
return TextareaAutosize;
})(_React2['default'].Component);
})(_react2['default'].Component);

@@ -211,0 +225,0 @@ exports['default'] = TextareaAutosize;

{
"name": "react-textarea-autosize",
"description": "textarea component for React which grows with content",
"version": "2.5.4",
"version": "3.0.0",
"author": {

@@ -21,3 +21,3 @@ "name": "Andrey Popp",

"peerDependencies": {
"react": ">= 0.13.0 || ^0.14.0-alpha"
"react": "^0.14.0"
},

@@ -29,2 +29,3 @@ "repository": {

"devDependencies": {
"react": "^0.14.0",
"babel": "^5.1.0",

@@ -31,0 +32,0 @@ "babel-eslint": "^3.0.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc