UNPKG

textarea-autosizer

Version:

Textarea Autosizer automatically resizes the height of a textarea based on the content entered or pasted inside it.

3 lines (2 loc) 2.35 kB
var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var H=(i,e)=>{for(var r in e)p(i,r,{get:e[r],enumerable:!0})},T=(i,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w(e))!f.call(i,a)&&a!==r&&p(i,a,{get:()=>e[a],enumerable:!(n=y(e,a))||n.enumerable});return i};var z=i=>T(p({},"__esModule",{value:!0}),i);var v=(i,e,r)=>{if(!e.has(i))throw TypeError("Cannot "+r)};var t=(i,e,r)=>(v(i,e,"read from private field"),r?r.call(i):e.get(i)),l=(i,e,r)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,r)},u=(i,e,r,n)=>(v(i,e,"write to private field"),n?n.call(i,r):e.set(i,r),r);var x=(i,e,r)=>(v(i,e,"access private method"),r);var A={};H(A,{TextareaAutosizer:()=>d,setTextareaAutosizer:()=>c});module.exports=z(A);var s,o,h,m,g,d=class{constructor(){l(this,m);l(this,s,null);l(this,o,null);l(this,h,void 0);u(this,h,x(this,m,g).bind(this)),typeof window!="undefined"&&window.Math===Math&&typeof window.ResizeObserver!="undefined"&&u(this,o,new ResizeObserver(t(this,h)))}set(e,r){return u(this,s,e),this.updateOptions(r),t(this,s).addEventListener("input",t(this,h)),t(this,o)?t(this,o).observe(t(this,s)):window.addEventListener("resize",t(this,h)),this}updateOptions(e){e.minHeight&&(t(this,s).style.minHeight=`${e.minHeight}px`),e.maxHeight&&(t(this,s).style.maxHeight=`${e.maxHeight}px`),x(this,m,g).call(this)}remove(){return t(this,s).removeEventListener("input",t(this,h)),t(this,o)?t(this,o).unobserve(t(this,s)):window.removeEventListener("resize",t(this,h)),t(this,s).style.removeProperty("height"),t(this,s).style.removeProperty("min-height"),t(this,s).style.removeProperty("max-height"),t(this,s).style.removeProperty("overflow-y"),this}};s=new WeakMap,o=new WeakMap,h=new WeakMap,m=new WeakSet,g=function(){if(!t(this,s)||t(this,s).tagName!=="TEXTAREA")return;t(this,s).style.overflowY="hidden",t(this,s).style.height="0";let e=window.getComputedStyle(t(this,s)),r=t(this,s).scrollHeight+parseInt(e.height,10)-t(this,s).clientHeight,n=parseInt(e.maxHeight,10);n&&r>=n&&(t(this,s).style.overflowY="auto"),t(this,s).style.height=`${r}px`};var c=(i,e)=>new d().set(i,e);0&&(module.exports={TextareaAutosizer,setTextareaAutosizer}); //# sourceMappingURL=index.js.map