Socket
Socket
Sign inDemoInstall

react-textarea-autosize

Package Overview
Dependencies
Maintainers
4
Versions
98
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 4.3.1 to 4.3.2

15

dist/react-textarea-autosize.js

@@ -13,8 +13,13 @@ (function (global, factory) {

*/
var browser = typeof window !== 'undefined' && typeof document !== 'undefined';
var isIE = browser ? !!document.documentElement.currentStyle : false;
var boxSizingProp = function () {
if (!browser) {
return 'box-sizing';
}
var documentStyle = window.getComputedStyle(document.documentElement);
// TODO: remove prefixed - they are probably obsolete, were introduced in by df79cf502630744d40233b64cad01770e5584610 in 2014
return documentStyle.getPropertyValue('box-sizing') ? 'box-sizing' : documentStyle.getPropertyValue('-moz-box-sizing') ? '-moz-box-sizing' : documentStyle.getPropertyValue('-webkit-box-sizing') ? '-webkit-box-sizing' : 'box-sizing';
}();
var isIE = document.documentElement.currentStyle;
var documentStyle = window.getComputedStyle(document.documentElement);
// TODO: remove prefixed - they are probably obsolete, were introduced in by df79cf502630744d40233b64cad01770e5584610 in 2014
var boxSizingProp = documentStyle.getPropertyValue('box-sizing') ? 'box-sizing' : documentStyle.getPropertyValue('-moz-box-sizing') ? '-moz-box-sizing' : documentStyle.getPropertyValue('-webkit-box-sizing') ? '-webkit-box-sizing' : 'box-sizing';
var HIDDEN_TEXTAREA_STYLE = {

@@ -21,0 +26,0 @@ 'min-height': '0',

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.TextareaAutosize=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";function o(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;h?null===h.parentNode&&document.body.appendChild(h):(h=document.createElement("textarea"),document.body.appendChild(h));var r=n(e,t),a=r.paddingSize,s=r.borderSize,u=r.boxSizing,p=r.sizingStyle;Object.keys(p).map(function(e){h.style[e]=p[e]}),Object.keys(l).map(function(e){h.style.setProperty(e,l[e],"important")}),h.value=e.value||e.placeholder||"x";var d=-1/0,c=1/0,f=h.scrollHeight;if("border-box"===u?f+=s:"content-box"===u&&(f-=a),null!==o||null!==i){h.value="x";var g=h.scrollHeight-a;null!==o&&(d=g*o,"border-box"===u&&(d=d+a+s),f=Math.max(d,f)),null!==i&&(c=g*i,"border-box"===u&&(c=c+a+s),f=Math.min(c,f))}return{height:f,minHeight:d,maxHeight:c}}function n(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.getAttribute("id")||e.getAttribute("data-reactid")||e.getAttribute("name");if(t&&d[o])return d[o];var n=window.getComputedStyle(e),i=p.reduce(function(e,t){return e[t]=n.getPropertyValue(t),e},{}),r=i[u];a&&"border-box"===r&&(i.width=parseFloat(i.width)+parseFloat(n["border-right-width"])+parseFloat(n["border-left-width"])+parseFloat(n["padding-right"])+parseFloat(n["padding-left"])+"px");var s=parseFloat(i["padding-bottom"])+parseFloat(i["padding-top"]),l=parseFloat(i["border-bottom-width"])+parseFloat(i["border-top-width"]),h={sizingStyle:i,paddingSize:s,borderSize:l,boxSizing:r};return t&&o&&(d[o]=h),h}function i(e){return window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e,1)}function r(e){window.cancelAnimationFrame?window.cancelAnimationFrame(e):window.clearTimeout(e)}e="default"in e?e.default:e,t="default"in t?t.default:t;var a=document.documentElement.currentStyle,s=window.getComputedStyle(document.documentElement),u=s.getPropertyValue("box-sizing")?"box-sizing":s.getPropertyValue("-moz-box-sizing")?"-moz-box-sizing":s.getPropertyValue("-webkit-box-sizing")?"-webkit-box-sizing":"box-sizing",l={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},p=["letter-spacing","line-height","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-top","padding-right","padding-bottom","padding-left","border-top-width","border-right-width","border-bottom-width","border-left-width",u],d={},h=void 0,c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},g=function(){function e(e,t){for(var o=0;t.length>o;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),m=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},b=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},y=function(e,t){var o={};for(var n in e)0>t.indexOf(n)&&Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o},w=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},v=function(){},x=function(t){function n(e){f(this,n);var i=w(this,t.call(this,e));return i._onRootDOMNode=function(e){i._rootDOMNode=e,i.props.inputRef&&i.props.inputRef(e)},i._onChange=function(e){i._controlled||i._resizeComponent();var t=i.props,o=t.valueLink,n=t.onChange;o?o.requestChange(e.target.value):n(e)},i._resizeComponent=function(){if(i._rootDOMNode){var e=o(i._rootDOMNode,i.props.useCacheForDOMMeasurements,i.props.rows||i.props.minRows,i.props.maxRows),t=e.height,n=e.minHeight,r=e.maxHeight;i.state.height===t&&i.state.minHeight===n&&i.state.maxHeight===r||i.setState({height:t,minHeight:n,maxHeight:r})}},i.state={height:e.style&&e.style.height||0,minHeight:-1/0,maxHeight:1/0},i._controlled="string"==typeof e.value,i}return b(n,t),n.prototype.render=function(){var t=this.props,o=t.valueLink,n=y(t,["valueLink","minRows","maxRows","onHeightChange","useCacheForDOMMeasurements","inputRef"]);return"object"===(void 0===o?"undefined":c(o))&&(n.value=o.value),n.style=m({},n.style,{height:this.state.height}),this.state.height>Math.max(n.style.maxHeight||1/0,this.state.maxHeight)&&(n.style.overflow="hidden"),e.createElement("textarea",m({},n,{onChange:this._onChange,ref:this._onRootDOMNode}))},n.prototype.componentDidMount=function(){this._resizeComponent(),window.addEventListener("resize",this._resizeComponent)},n.prototype.componentWillReceiveProps=function(){this._clearNextFrame(),this._onNextFrameActionId=i(this._resizeComponent)},n.prototype.componentDidUpdate=function(e,t){this.state.height!==t.height&&this.props.onHeightChange(this.state.height)},n.prototype.componentWillUnmount=function(){this._clearNextFrame(),window.removeEventListener("resize",this._resizeComponent)},n.prototype._clearNextFrame=function(){this._onNextFrameActionId&&r(this._onNextFrameActionId)},n.prototype.focus=function(){this._rootDOMNode.focus()},n.prototype.blur=function(){this._rootDOMNode.blur()},g(n,[{key:"value",get:function(){return this._rootDOMNode.value},set:function(e){this._rootDOMNode.value=e}},{key:"selectionStart",get:function(){return this._rootDOMNode.selectionStart},set:function(e){this._rootDOMNode.selectionStart=e}},{key:"selectionEnd",get:function(){return this._rootDOMNode.selectionEnd},set:function(e){this._rootDOMNode.selectionEnd=e}}]),n}(e.Component);return x.propTypes={value:t.string,onChange:t.func,onHeightChange:t.func,useCacheForDOMMeasurements:t.bool,rows:t.number,minRows:t.number,maxRows:t.number,inputRef:t.func},x.defaultProps={onChange:v,onHeightChange:v,useCacheForDOMMeasurements:!1},x});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.TextareaAutosize=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";function o(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;h?null===h.parentNode&&document.body.appendChild(h):(h=document.createElement("textarea"),document.body.appendChild(h));var r=n(e,t),a=r.paddingSize,s=r.borderSize,u=r.boxSizing,l=r.sizingStyle;Object.keys(l).map(function(e){h.style[e]=l[e]}),Object.keys(p).map(function(e){h.style.setProperty(e,p[e],"important")}),h.value=e.value||e.placeholder||"x";var d=-1/0,c=1/0,f=h.scrollHeight;if("border-box"===u?f+=s:"content-box"===u&&(f-=a),null!==o||null!==i){h.value="x";var g=h.scrollHeight-a;null!==o&&(d=g*o,"border-box"===u&&(d=d+a+s),f=Math.max(d,f)),null!==i&&(c=g*i,"border-box"===u&&(c=c+a+s),f=Math.min(c,f))}return{height:f,minHeight:d,maxHeight:c}}function n(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.getAttribute("id")||e.getAttribute("data-reactid")||e.getAttribute("name");if(t&&d[o])return d[o];var n=window.getComputedStyle(e),i=l.reduce(function(e,t){return e[t]=n.getPropertyValue(t),e},{}),r=i[u];s&&"border-box"===r&&(i.width=parseFloat(i.width)+parseFloat(n["border-right-width"])+parseFloat(n["border-left-width"])+parseFloat(n["padding-right"])+parseFloat(n["padding-left"])+"px");var a=parseFloat(i["padding-bottom"])+parseFloat(i["padding-top"]),p=parseFloat(i["border-bottom-width"])+parseFloat(i["border-top-width"]),h={sizingStyle:i,paddingSize:a,borderSize:p,boxSizing:r};return t&&o&&(d[o]=h),h}function i(e){return window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e,1)}function r(e){window.cancelAnimationFrame?window.cancelAnimationFrame(e):window.clearTimeout(e)}e="default"in e?e.default:e,t="default"in t?t.default:t;var a="undefined"!=typeof window&&"undefined"!=typeof document,s=!!a&&!!document.documentElement.currentStyle,u=function(){if(!a)return"box-sizing";var e=window.getComputedStyle(document.documentElement);return e.getPropertyValue("box-sizing")?"box-sizing":e.getPropertyValue("-moz-box-sizing")?"-moz-box-sizing":e.getPropertyValue("-webkit-box-sizing")?"-webkit-box-sizing":"box-sizing"}(),p={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},l=["letter-spacing","line-height","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-top","padding-right","padding-bottom","padding-left","border-top-width","border-right-width","border-bottom-width","border-left-width",u],d={},h=void 0,c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},g=function(){function e(e,t){for(var o=0;t.length>o;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),m=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},b=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},y=function(e,t){var o={};for(var n in e)0>t.indexOf(n)&&Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o},w=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},v=function(){},x=function(t){function n(e){f(this,n);var i=w(this,t.call(this,e));return i._onRootDOMNode=function(e){i._rootDOMNode=e,i.props.inputRef&&i.props.inputRef(e)},i._onChange=function(e){i._controlled||i._resizeComponent();var t=i.props,o=t.valueLink,n=t.onChange;o?o.requestChange(e.target.value):n(e)},i._resizeComponent=function(){if(i._rootDOMNode){var e=o(i._rootDOMNode,i.props.useCacheForDOMMeasurements,i.props.rows||i.props.minRows,i.props.maxRows),t=e.height,n=e.minHeight,r=e.maxHeight;i.state.height===t&&i.state.minHeight===n&&i.state.maxHeight===r||i.setState({height:t,minHeight:n,maxHeight:r})}},i.state={height:e.style&&e.style.height||0,minHeight:-1/0,maxHeight:1/0},i._controlled="string"==typeof e.value,i}return b(n,t),n.prototype.render=function(){var t=this.props,o=t.valueLink,n=y(t,["valueLink","minRows","maxRows","onHeightChange","useCacheForDOMMeasurements","inputRef"]);return"object"===(void 0===o?"undefined":c(o))&&(n.value=o.value),n.style=m({},n.style,{height:this.state.height}),this.state.height>Math.max(n.style.maxHeight||1/0,this.state.maxHeight)&&(n.style.overflow="hidden"),e.createElement("textarea",m({},n,{onChange:this._onChange,ref:this._onRootDOMNode}))},n.prototype.componentDidMount=function(){this._resizeComponent(),window.addEventListener("resize",this._resizeComponent)},n.prototype.componentWillReceiveProps=function(){this._clearNextFrame(),this._onNextFrameActionId=i(this._resizeComponent)},n.prototype.componentDidUpdate=function(e,t){this.state.height!==t.height&&this.props.onHeightChange(this.state.height)},n.prototype.componentWillUnmount=function(){this._clearNextFrame(),window.removeEventListener("resize",this._resizeComponent)},n.prototype._clearNextFrame=function(){this._onNextFrameActionId&&r(this._onNextFrameActionId)},n.prototype.focus=function(){this._rootDOMNode.focus()},n.prototype.blur=function(){this._rootDOMNode.blur()},g(n,[{key:"value",get:function(){return this._rootDOMNode.value},set:function(e){this._rootDOMNode.value=e}},{key:"selectionStart",get:function(){return this._rootDOMNode.selectionStart},set:function(e){this._rootDOMNode.selectionStart=e}},{key:"selectionEnd",get:function(){return this._rootDOMNode.selectionEnd},set:function(e){this._rootDOMNode.selectionEnd=e}}]),n}(e.Component);return x.propTypes={value:t.string,onChange:t.func,onHeightChange:t.func,useCacheForDOMMeasurements:t.bool,rows:t.number,minRows:t.number,maxRows:t.number,inputRef:t.func},x.defaultProps={onChange:v,onHeightChange:v,useCacheForDOMMeasurements:!1},x});
/**
* calculateNodeHeight(uiTextNode, useCache = false)
*/
var browser = typeof window !== 'undefined' && typeof document !== 'undefined';
var isIE = browser ? !!document.documentElement.currentStyle : false;
var boxSizingProp = function () {
if (!browser) {
return 'box-sizing';
}
var documentStyle = window.getComputedStyle(document.documentElement);
// TODO: remove prefixed - they are probably obsolete, were introduced in by df79cf502630744d40233b64cad01770e5584610 in 2014
return documentStyle.getPropertyValue('box-sizing') ? 'box-sizing' : documentStyle.getPropertyValue('-moz-box-sizing') ? '-moz-box-sizing' : documentStyle.getPropertyValue('-webkit-box-sizing') ? '-webkit-box-sizing' : 'box-sizing';
}();
var isIE = document.documentElement.currentStyle;
var documentStyle = window.getComputedStyle(document.documentElement);
// TODO: remove prefixed - they are probably obsolete, were introduced in by df79cf502630744d40233b64cad01770e5584610 in 2014
var boxSizingProp = documentStyle.getPropertyValue('box-sizing') ? 'box-sizing' : documentStyle.getPropertyValue('-moz-box-sizing') ? '-moz-box-sizing' : documentStyle.getPropertyValue('-webkit-box-sizing') ? '-webkit-box-sizing' : 'box-sizing';
var HIDDEN_TEXTAREA_STYLE = {

@@ -11,0 +16,0 @@ 'min-height': '0',

@@ -8,8 +8,13 @@ 'use strict';

*/
var browser = typeof window !== 'undefined' && typeof document !== 'undefined';
var isIE = browser ? !!document.documentElement.currentStyle : false;
var boxSizingProp = function () {
if (!browser) {
return 'box-sizing';
}
var documentStyle = window.getComputedStyle(document.documentElement);
// TODO: remove prefixed - they are probably obsolete, were introduced in by df79cf502630744d40233b64cad01770e5584610 in 2014
return documentStyle.getPropertyValue('box-sizing') ? 'box-sizing' : documentStyle.getPropertyValue('-moz-box-sizing') ? '-moz-box-sizing' : documentStyle.getPropertyValue('-webkit-box-sizing') ? '-webkit-box-sizing' : 'box-sizing';
}();
var isIE = document.documentElement.currentStyle;
var documentStyle = window.getComputedStyle(document.documentElement);
// TODO: remove prefixed - they are probably obsolete, were introduced in by df79cf502630744d40233b64cad01770e5584610 in 2014
var boxSizingProp = documentStyle.getPropertyValue('box-sizing') ? 'box-sizing' : documentStyle.getPropertyValue('-moz-box-sizing') ? '-moz-box-sizing' : documentStyle.getPropertyValue('-webkit-box-sizing') ? '-webkit-box-sizing' : 'box-sizing';
var HIDDEN_TEXTAREA_STYLE = {

@@ -16,0 +21,0 @@ 'min-height': '0',

{
"name": "react-textarea-autosize",
"description": "textarea component for React which grows with content",
"version": "4.3.1",
"version": "4.3.2",
"keywords": "autosize, grow, react, react-component, textarea",

@@ -6,0 +6,0 @@ "repository": "andreypopp/react-textarea-autosize",

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