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 6.0.1 to 6.0.2

14

dist/react-textarea-autosize.cjs.js

@@ -76,3 +76,2 @@ 'use strict';

var isIE = isBrowser ? !!document.documentElement.currentStyle : false;
var hiddenTextarea = isBrowser && document.createElement('textarea');
var HIDDEN_TEXTAREA_STYLE = {

@@ -91,2 +90,11 @@ 'min-height': '0',

var computedStyleCache = {};
var hiddenTextarea = isBrowser && document.createElement('textarea');
var forceHiddenStyles = function forceHiddenStyles(node) {
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {
node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
});
};
forceHiddenStyles(hiddenTextarea);
function calculateNodeHeight(uiTextNode, uid, useCache, minRows, maxRows) {

@@ -127,5 +135,3 @@ if (useCache === void 0) {

});
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {
hiddenTextarea.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
});
forceHiddenStyles(hiddenTextarea);
hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || 'x';

@@ -132,0 +138,0 @@ var minHeight = -Infinity;

@@ -70,3 +70,2 @@ import React from 'react';

var isIE = isBrowser ? !!document.documentElement.currentStyle : false;
var hiddenTextarea = isBrowser && document.createElement('textarea');
var HIDDEN_TEXTAREA_STYLE = {

@@ -85,2 +84,11 @@ 'min-height': '0',

var computedStyleCache = {};
var hiddenTextarea = isBrowser && document.createElement('textarea');
var forceHiddenStyles = function forceHiddenStyles(node) {
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {
node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
});
};
forceHiddenStyles(hiddenTextarea);
function calculateNodeHeight(uiTextNode, uid, useCache, minRows, maxRows) {

@@ -121,5 +129,3 @@ if (useCache === void 0) {

});
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {
hiddenTextarea.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
});
forceHiddenStyles(hiddenTextarea);
hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || 'x';

@@ -126,0 +132,0 @@ var minHeight = -Infinity;

@@ -922,3 +922,2 @@ (function (global, factory) {

var isIE = isBrowser ? !!document.documentElement.currentStyle : false;
var hiddenTextarea = isBrowser && document.createElement('textarea');
var HIDDEN_TEXTAREA_STYLE = {

@@ -937,2 +936,11 @@ 'min-height': '0',

var computedStyleCache = {};
var hiddenTextarea = isBrowser && document.createElement('textarea');
var forceHiddenStyles = function forceHiddenStyles(node) {
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {
node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
});
};
forceHiddenStyles(hiddenTextarea);
function calculateNodeHeight(uiTextNode, uid, useCache, minRows, maxRows) {

@@ -973,5 +981,3 @@ if (useCache === void 0) {

});
Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {
hiddenTextarea.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');
});
forceHiddenStyles(hiddenTextarea);
hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || 'x';

@@ -978,0 +984,0 @@ var minHeight = -Infinity;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.TextareaAutosize={},e.React)}(this,function(e,t){"use strict";function n(){return(n=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}t=t&&t.hasOwnProperty("default")?t.default:t;var r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e};"object"==typeof Reflect&&Reflect;function o(e){return function(){return e}}var i=function(){};i.thatReturns=o,i.thatReturnsFalse=o(!1),i.thatReturnsTrue=o(!0),i.thatReturnsNull=o(null),i.thatReturnsThis=function(){return this},i.thatReturnsArgument=function(e){return e};var a=i;var s=function(e,t,n,r,o,i,a,s){if(!e){var u;if(void 0===t)u=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,r,o,i,a,s],h=0;(u=Error(t.replace(/%s/g,function(){return p[h++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}},u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;!function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;10>n;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}();var l,c="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",d=(function(e){e.exports=function(){function e(e,t,n,r,o,i){i!==c&&s(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=a,n.PropTypes=n,n}()}(l={exports:{}},l.exports),l.exports),f="undefined"!=typeof window&&"undefined"!=typeof document,m=!!f&&!!document.documentElement.currentStyle,g=f&&document.createElement("textarea"),b={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},y=["letter-spacing","line-height","font-family","font-weight","font-size","font-style","tab-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","box-sizing"],v={};function _(e,t,n,r,o){void 0===n&&(n=!1),void 0===r&&(r=null),void 0===o&&(o=null),null===g.parentNode&&document.body.appendChild(g);var i=function(e,t,n){void 0===n&&(n=!1);if(n&&v[t])return v[t];var r=window.getComputedStyle(e);if(null===r)return null;var o=y.reduce(function(e,t){return e[t]=r.getPropertyValue(t),e},{}),i=o["box-sizing"];if(""===i)return null;m&&"border-box"===i&&(o.width=parseFloat(o.width)+parseFloat(r["border-right-width"])+parseFloat(r["border-left-width"])+parseFloat(r["padding-right"])+parseFloat(r["padding-left"])+"px");var a={sizingStyle:o,paddingSize:parseFloat(o["padding-bottom"])+parseFloat(o["padding-top"]),borderSize:parseFloat(o["border-bottom-width"])+parseFloat(o["border-top-width"]),boxSizing:i};n&&(v[t]=a);return a}(e,t,n);if(null===i)return null;var a=i.paddingSize,s=i.borderSize,u=i.boxSizing,p=i.sizingStyle;Object.keys(p).forEach(function(e){g.style[e]=p[e]}),Object.keys(b).forEach(function(e){g.style.setProperty(e,b[e],"important")}),g.value=e.value||e.placeholder||"x";var h=-1/0,l=1/0,c=g.scrollHeight;"border-box"===u?c+=s:"content-box"===u&&(c-=a),g.value="x";var d=g.scrollHeight-a;return null===r&&null===o||(null!==r&&(h=d*r,"border-box"===u&&(h=h+a+s),c=Math.max(h,c)),null!==o&&(l=d*o,"border-box"===u&&(l=l+a+s),c=Math.min(l,c))),{height:c,minHeight:h,maxHeight:l,rowCount:Math.floor(c/d)}}var w,x=(void 0===w&&(w=0),function(){return++w}),O=function(){},C=f&&window.requestAnimationFrame?[window.requestAnimationFrame,window.cancelAnimationFrame]:[setTimeout,clearTimeout],z=C[0],R=C[1],j=function(e){var r,o;function i(t){var n;return(n=e.call(this,t)||this)._resizeLock=!1,n._onRootDOMNode=function(e){n._rootDOMNode=e,n.props.inputRef&&n.props.inputRef(e)},n._onChange=function(e){n._controlled||n._resizeComponent(),n.props.onChange(e)},n._resizeComponent=function(e){if(void 0===e&&(e=O),void 0!==n._rootDOMNode){var t=_(n._rootDOMNode,n._uid,n.props.useCacheForDOMMeasurements,n.props.minRows,n.props.maxRows);if(null!==t){var r=t.height,o=t.minHeight,i=t.maxHeight;n.rowCount=t.rowCount,n.state.height===r&&n.state.minHeight===o&&n.state.maxHeight===i?e():n.setState({height:r,minHeight:o,maxHeight:i},e)}else e()}else e()},n.state={height:t.style&&t.style.height||0,minHeight:-1/0,maxHeight:1/0},n._uid=x(),n._controlled="string"==typeof t.value,n}(r=i).prototype=Object.create((o=e).prototype),r.prototype.constructor=r,r.__proto__=o;var a=i.prototype;return a.render=function(){var e=this.props,r=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;i.length>r;r++)0>t.indexOf(n=i[r])&&(o[n]=e[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;a.length>r;r++)0>t.indexOf(n=a[r])&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["minRows","maxRows","onHeightChange","useCacheForDOMMeasurements","inputRef"]);return r.style=n({},r.style,{height:this.state.height}),this.state.height>Math.max(r.style.maxHeight||1/0,this.state.maxHeight)&&(r.style.overflow="hidden"),t.createElement("textarea",n({},r,{onChange:this._onChange,ref:this._onRootDOMNode}))},a.componentDidMount=function(){var e=this;this._resizeComponent(),this._resizeListener=function(){e._resizeLock||(e._resizeLock=!0,e._resizeComponent(function(){return e._resizeLock=!1}))},window.addEventListener("resize",this._resizeListener)},a.componentWillReceiveProps=function(){var e=this;this._clearNextFrame(),this._onNextFrameActionId=z(function(){return e._resizeComponent()})},a.componentDidUpdate=function(e,t){this.state.height!==t.height&&this.props.onHeightChange(this.state.height,this)},a.componentWillUnmount=function(){this._clearNextFrame(),window.removeEventListener("resize",this._resizeListener),delete v[this._uid]},a._clearNextFrame=function(){R(this._onNextFrameActionId)},i}(t.Component);j.propTypes={value:d.string,onChange:d.func,onHeightChange:d.func,useCacheForDOMMeasurements:d.bool,minRows:d.number,maxRows:d.number,inputRef:d.func},j.defaultProps={onChange:O,onHeightChange:O,useCacheForDOMMeasurements:!1},e.default=j,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.TextareaAutosize={},e.React)}(this,function(e,t){"use strict";function n(){return(n=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}t=t&&t.hasOwnProperty("default")?t.default:t;var r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e};"object"==typeof Reflect&&Reflect;function o(e){return function(){return e}}var i=function(){};i.thatReturns=o,i.thatReturnsFalse=o(!1),i.thatReturnsTrue=o(!0),i.thatReturnsNull=o(null),i.thatReturnsThis=function(){return this},i.thatReturnsArgument=function(e){return e};var a=i;var s=function(e,t,n,r,o,i,a,s){if(!e){var u;if(void 0===t)u=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,r,o,i,a,s],h=0;(u=Error(t.replace(/%s/g,function(){return p[h++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}},u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;!function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;10>n;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}();var l,c="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",d=(function(e){e.exports=function(){function e(e,t,n,r,o,i){i!==c&&s(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=a,n.PropTypes=n,n}()}(l={exports:{}},l.exports),l.exports),f="undefined"!=typeof window&&"undefined"!=typeof document,m=!!f&&!!document.documentElement.currentStyle,g={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},b=["letter-spacing","line-height","font-family","font-weight","font-size","font-style","tab-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","box-sizing"],y={},v=f&&document.createElement("textarea"),_=function(e){Object.keys(g).forEach(function(t){e.style.setProperty(t,g[t],"important")})};function w(e,t,n,r,o){void 0===n&&(n=!1),void 0===r&&(r=null),void 0===o&&(o=null),null===v.parentNode&&document.body.appendChild(v);var i=function(e,t,n){void 0===n&&(n=!1);if(n&&y[t])return y[t];var r=window.getComputedStyle(e);if(null===r)return null;var o=b.reduce(function(e,t){return e[t]=r.getPropertyValue(t),e},{}),i=o["box-sizing"];if(""===i)return null;m&&"border-box"===i&&(o.width=parseFloat(o.width)+parseFloat(r["border-right-width"])+parseFloat(r["border-left-width"])+parseFloat(r["padding-right"])+parseFloat(r["padding-left"])+"px");var a={sizingStyle:o,paddingSize:parseFloat(o["padding-bottom"])+parseFloat(o["padding-top"]),borderSize:parseFloat(o["border-bottom-width"])+parseFloat(o["border-top-width"]),boxSizing:i};n&&(y[t]=a);return a}(e,t,n);if(null===i)return null;var a=i.paddingSize,s=i.borderSize,u=i.boxSizing,p=i.sizingStyle;Object.keys(p).forEach(function(e){v.style[e]=p[e]}),_(v),v.value=e.value||e.placeholder||"x";var h=-1/0,l=1/0,c=v.scrollHeight;"border-box"===u?c+=s:"content-box"===u&&(c-=a),v.value="x";var d=v.scrollHeight-a;return null===r&&null===o||(null!==r&&(h=d*r,"border-box"===u&&(h=h+a+s),c=Math.max(h,c)),null!==o&&(l=d*o,"border-box"===u&&(l=l+a+s),c=Math.min(l,c))),{height:c,minHeight:h,maxHeight:l,rowCount:Math.floor(c/d)}}_(v);var x,O=(void 0===x&&(x=0),function(){return++x}),C=function(){},z=f&&window.requestAnimationFrame?[window.requestAnimationFrame,window.cancelAnimationFrame]:[setTimeout,clearTimeout],R=z[0],j=z[1],F=function(e){var r,o;function i(t){var n;return(n=e.call(this,t)||this)._resizeLock=!1,n._onRootDOMNode=function(e){n._rootDOMNode=e,n.props.inputRef&&n.props.inputRef(e)},n._onChange=function(e){n._controlled||n._resizeComponent(),n.props.onChange(e)},n._resizeComponent=function(e){if(void 0===e&&(e=C),void 0!==n._rootDOMNode){var t=w(n._rootDOMNode,n._uid,n.props.useCacheForDOMMeasurements,n.props.minRows,n.props.maxRows);if(null!==t){var r=t.height,o=t.minHeight,i=t.maxHeight;n.rowCount=t.rowCount,n.state.height===r&&n.state.minHeight===o&&n.state.maxHeight===i?e():n.setState({height:r,minHeight:o,maxHeight:i},e)}else e()}else e()},n.state={height:t.style&&t.style.height||0,minHeight:-1/0,maxHeight:1/0},n._uid=O(),n._controlled="string"==typeof t.value,n}(r=i).prototype=Object.create((o=e).prototype),r.prototype.constructor=r,r.__proto__=o;var a=i.prototype;return a.render=function(){var e=this.props,r=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;i.length>r;r++)0>t.indexOf(n=i[r])&&(o[n]=e[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;a.length>r;r++)0>t.indexOf(n=a[r])&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["minRows","maxRows","onHeightChange","useCacheForDOMMeasurements","inputRef"]);return r.style=n({},r.style,{height:this.state.height}),this.state.height>Math.max(r.style.maxHeight||1/0,this.state.maxHeight)&&(r.style.overflow="hidden"),t.createElement("textarea",n({},r,{onChange:this._onChange,ref:this._onRootDOMNode}))},a.componentDidMount=function(){var e=this;this._resizeComponent(),this._resizeListener=function(){e._resizeLock||(e._resizeLock=!0,e._resizeComponent(function(){return e._resizeLock=!1}))},window.addEventListener("resize",this._resizeListener)},a.componentWillReceiveProps=function(){var e=this;this._clearNextFrame(),this._onNextFrameActionId=R(function(){return e._resizeComponent()})},a.componentDidUpdate=function(e,t){this.state.height!==t.height&&this.props.onHeightChange(this.state.height,this)},a.componentWillUnmount=function(){this._clearNextFrame(),window.removeEventListener("resize",this._resizeListener),delete y[this._uid]},a._clearNextFrame=function(){j(this._onNextFrameActionId)},i}(t.Component);F.propTypes={value:d.string,onChange:d.func,onHeightChange:d.func,useCacheForDOMMeasurements:d.bool,minRows:d.number,maxRows:d.number,inputRef:d.func},F.defaultProps={onChange:C,onHeightChange:C,useCacheForDOMMeasurements:!1},e.default=F,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "react-textarea-autosize",
"description": "textarea component for React which grows with content",
"version": "6.0.1",
"version": "6.0.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