{"version":3,"file":"react-textarea-autosize-DwKFRWTG.js","sources":["../../node_modules/react-textarea-autosize/dist/react-textarea-autosize.browser.esm.js"],"sourcesContent":["import _extends from '@babel/runtime/helpers/esm/extends';\nimport _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';\nimport * as React from 'react';\nimport useLatest from 'use-latest';\nimport useComposedRef from 'use-composed-ref';\n\nvar HIDDEN_TEXTAREA_STYLE = {\n 'min-height': '0',\n 'max-height': 'none',\n height: '0',\n visibility: 'hidden',\n overflow: 'hidden',\n position: 'absolute',\n 'z-index': '-1000',\n top: '0',\n right: '0',\n display: 'block'\n};\nvar forceHiddenStyles = function forceHiddenStyles(node) {\n Object.keys(HIDDEN_TEXTAREA_STYLE).forEach(function (key) {\n node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');\n });\n};\nvar forceHiddenStyles$1 = forceHiddenStyles;\n\nvar hiddenTextarea = null;\nvar getHeight = function getHeight(node, sizingData) {\n var height = node.scrollHeight;\n if (sizingData.sizingStyle.boxSizing === 'border-box') {\n // border-box: add border, since height = content + padding + border\n return height + sizingData.borderSize;\n }\n\n // remove padding, since height = content\n return height - sizingData.paddingSize;\n};\nfunction calculateNodeHeight(sizingData, value, minRows, maxRows) {\n if (minRows === void 0) {\n minRows = 1;\n }\n if (maxRows === void 0) {\n maxRows = Infinity;\n }\n if (!hiddenTextarea) {\n hiddenTextarea = document.createElement('textarea');\n hiddenTextarea.setAttribute('tabindex', '-1');\n hiddenTextarea.setAttribute('aria-hidden', 'true');\n forceHiddenStyles$1(hiddenTextarea);\n }\n if (hiddenTextarea.parentNode === null) {\n document.body.appendChild(hiddenTextarea);\n }\n var paddingSize = sizingData.paddingSize,\n borderSize = sizingData.borderSize,\n sizingStyle = sizingData.sizingStyle;\n var boxSizing = sizingStyle.boxSizing;\n Object.keys(sizingStyle).forEach(function (_key) {\n var key = _key;\n hiddenTextarea.style[key] = sizingStyle[key];\n });\n forceHiddenStyles$1(hiddenTextarea);\n hiddenTextarea.value = value;\n var height = getHeight(hiddenTextarea, sizingData);\n // Double set and calc due to Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1795904\n hiddenTextarea.value = value;\n height = getHeight(hiddenTextarea, sizingData);\n\n // measure height of a textarea with a single row\n hiddenTextarea.value = 'x';\n var rowHeight = hiddenTextarea.scrollHeight - paddingSize;\n var minHeight = rowHeight * minRows;\n if (boxSizing === 'border-box') {\n minHeight = minHeight + paddingSize + borderSize;\n }\n height = Math.max(minHeight, height);\n var maxHeight = rowHeight * maxRows;\n if (boxSizing === 'border-box') {\n maxHeight = maxHeight + paddingSize + borderSize;\n }\n height = Math.min(maxHeight, height);\n return [height, rowHeight];\n}\n\nvar noop = function noop() {};\nvar pick = function pick(props, obj) {\n return props.reduce(function (acc, prop) {\n acc[prop] = obj[prop];\n return acc;\n }, {});\n};\n\nvar SIZING_STYLE = ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth', 'boxSizing', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'letterSpacing', 'lineHeight', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop',\n// non-standard\n'tabSize', 'textIndent',\n// non-standard\n'textRendering', 'textTransform', 'width', 'wordBreak', 'wordSpacing', 'scrollbarGutter'];\nvar isIE = !!document.documentElement.currentStyle ;\nvar getSizingData = function getSizingData(node) {\n var style = window.getComputedStyle(node);\n if (style === null) {\n return null;\n }\n var sizingStyle = pick(SIZING_STYLE, style);\n var boxSizing = sizingStyle.boxSizing;\n\n // probably node is detached from DOM, can't read computed dimensions\n if (boxSizing === '') {\n return null;\n }\n\n // IE (Edge has already correct behaviour) returns content width as computed width\n // so we need to add manually padding and border widths\n if (isIE && boxSizing === 'border-box') {\n sizingStyle.width = parseFloat(sizingStyle.width) + parseFloat(sizingStyle.borderRightWidth) + parseFloat(sizingStyle.borderLeftWidth) + parseFloat(sizingStyle.paddingRight) + parseFloat(sizingStyle.paddingLeft) + 'px';\n }\n var paddingSize = parseFloat(sizingStyle.paddingBottom) + parseFloat(sizingStyle.paddingTop);\n var borderSize = parseFloat(sizingStyle.borderBottomWidth) + parseFloat(sizingStyle.borderTopWidth);\n return {\n sizingStyle: sizingStyle,\n paddingSize: paddingSize,\n borderSize: borderSize\n };\n};\nvar getSizingData$1 = getSizingData;\n\nfunction useListener(target, type, listener) {\n var latestListener = useLatest(listener);\n React.useLayoutEffect(function () {\n var handler = function handler(ev) {\n return latestListener.current(ev);\n };\n // might happen if document.fonts is not defined, for instance\n if (!target) {\n return;\n }\n target.addEventListener(type, handler);\n return function () {\n return target.removeEventListener(type, handler);\n };\n }, []);\n}\nvar useFormResetListener = function useFormResetListener(libRef, listener) {\n useListener(document.body, 'reset', function (ev) {\n if (libRef.current.form === ev.target) {\n listener(ev);\n }\n });\n};\nvar useWindowResizeListener = function useWindowResizeListener(listener) {\n useListener(window, 'resize', listener);\n};\nvar useFontsLoadedListener = function useFontsLoadedListener(listener) {\n useListener(document.fonts, 'loadingdone', listener);\n};\n\nvar _excluded = [\"cacheMeasurements\", \"maxRows\", \"minRows\", \"onChange\", \"onHeightChange\"];\nvar TextareaAutosize = function TextareaAutosize(_ref, userRef) {\n var cacheMeasurements = _ref.cacheMeasurements,\n maxRows = _ref.maxRows,\n minRows = _ref.minRows,\n _ref$onChange = _ref.onChange,\n onChange = _ref$onChange === void 0 ? noop : _ref$onChange,\n _ref$onHeightChange = _ref.onHeightChange,\n onHeightChange = _ref$onHeightChange === void 0 ? noop : _ref$onHeightChange,\n props = _objectWithoutPropertiesLoose(_ref, _excluded);\n var isControlled = props.value !== undefined;\n var libRef = React.useRef(null);\n var ref = useComposedRef(libRef, userRef);\n var heightRef = React.useRef(0);\n var measurementsCacheRef = React.useRef();\n var resizeTextarea = function resizeTextarea() {\n var node = libRef.current;\n var nodeSizingData = cacheMeasurements && measurementsCacheRef.current ? measurementsCacheRef.current : getSizingData$1(node);\n if (!nodeSizingData) {\n return;\n }\n measurementsCacheRef.current = nodeSizingData;\n var _calculateNodeHeight = calculateNodeHeight(nodeSizingData, node.value || node.placeholder || 'x', minRows, maxRows),\n height = _calculateNodeHeight[0],\n rowHeight = _calculateNodeHeight[1];\n if (heightRef.current !== height) {\n heightRef.current = height;\n node.style.setProperty('height', height + \"px\", 'important');\n onHeightChange(height, {\n rowHeight: rowHeight\n });\n }\n };\n var handleChange = function handleChange(event) {\n if (!isControlled) {\n resizeTextarea();\n }\n onChange(event);\n };\n {\n React.useLayoutEffect(resizeTextarea);\n useFormResetListener(libRef, function () {\n if (!isControlled) {\n var node = libRef.current;\n var currentValue = node.value;\n requestAnimationFrame(function () {\n if (currentValue !== node.value) {\n resizeTextarea();\n }\n });\n }\n });\n useWindowResizeListener(resizeTextarea);\n useFontsLoadedListener(resizeTextarea);\n return /*#__PURE__*/React.createElement(\"textarea\", _extends({}, props, {\n onChange: handleChange,\n ref: ref\n }));\n }\n};\nvar index = /* #__PURE__ */React.forwardRef(TextareaAutosize);\n\nexport { index as default };\n"],"names":["HIDDEN_TEXTAREA_STYLE","height","visibility","overflow","position","top","right","display","forceHiddenStyles$1","node","Object","keys","forEach","key","style","setProperty","hiddenTextarea","getHeight","sizingData","scrollHeight","sizingStyle","boxSizing","borderSize","paddingSize","noop","SIZING_STYLE","isIE","document","documentElement","currentStyle","getSizingData$1","window","getComputedStyle","obj","reduce","acc","prop","width","parseFloat","borderRightWidth","borderLeftWidth","paddingRight","paddingLeft","paddingBottom","paddingTop","borderBottomWidth","borderTopWidth","useListener","target","type","listener","latestListener","useLatest","React.useLayoutEffect","handler","ev","current","addEventListener","removeEventListener","_excluded","TextareaAutosize","_ref","userRef","cacheMeasurements","maxRows","minRows","_ref$onChange","onChange","_ref$onHeightChange","onHeightChange","props","_objectWithoutPropertiesLoose","isControlled","value","libRef","React.useRef","ref","useComposedRef","heightRef","measurementsCacheRef","resizeTextarea","nodeSizingData","_calculateNodeHeight","Infinity","createElement","setAttribute","parentNode","body","appendChild","_key","rowHeight","minHeight","Math","max","maxHeight","min","calculateNodeHeight","placeholder","useLayoutEffect","form","useFormResetListener","currentValue","requestAnimationFrame","fonts","useFontsLoadedListener","_extends","event","index","reactExports","forwardRef"],"mappings":"mLAMA,IAAIA,EAAwB,CAC1B,aAAc,IACd,aAAc,OACdC,OAAQ,IACRC,WAAY,SACZC,SAAU,SACVC,SAAU,WACV,UAAW,QACXC,IAAK,IACLC,MAAO,IACPC,QAAS,SAOPC,EALoB,SAA2BC,GACjDC,OAAOC,KAAKX,GAAuBY,SAAQ,SAAUC,GACnDJ,EAAKK,MAAMC,YAAYF,EAAKb,EAAsBa,GAAM,YAC5D,GACA,EAGIG,EAAiB,KACjBC,EAAY,SAAmBR,EAAMS,GACvC,IAAIjB,EAASQ,EAAKU,aACd,MAAqC,eAArCD,EAAWE,YAAYC,UAElBpB,EAASiB,EAAWI,WAItBrB,EAASiB,EAAWK,WAC7B,EAgDA,IAAIC,EAAO,aAQPC,EAAe,CAAC,oBAAqB,kBAAmB,mBAAoB,iBAAkB,YAAa,aAAc,WAAY,YAAa,aAAc,gBAAiB,aAAc,gBAAiB,cAAe,eAAgB,aAEnP,UAAW,aAEX,gBAAiB,gBAAiB,QAAS,YAAa,cAAe,mBACnEC,IAASC,SAASC,gBAAgBC,aA2BlCC,EA1BgB,SAAuBrB,GACrC,IAAAK,EAAQiB,OAAOC,iBAAiBvB,GACpC,GAAc,OAAVK,EACK,OAAA,KAEL,IAlB0BmB,EAkB1Bb,GAlB0Ba,EAkBOnB,EAAdW,EAjBVS,QAAO,SAAUC,EAAKC,GAE1B,OADHD,EAAAC,GAAQH,EAAIG,GACTD,CACR,GAAE,CAAE,IAeDd,EAAYD,EAAYC,UAG5B,MAAkB,KAAdA,EACK,MAKLK,GAAsB,eAAdL,IACED,EAAAiB,MAAQC,WAAWlB,EAAYiB,OAASC,WAAWlB,EAAYmB,kBAAoBD,WAAWlB,EAAYoB,iBAAmBF,WAAWlB,EAAYqB,cAAgBH,WAAWlB,EAA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