7e1701222337bae0e92ef7841d1fe8e4.json
14.4 KB
{"ast":null,"code":"// Thanks to https://github.com/andreypopp/react-textarea-autosize/\n\n/**\n * calculateNodeHeight(uiTextNode, useCache = false)\n */\nvar HIDDEN_TEXTAREA_STYLE = \"\\n min-height:0 !important;\\n max-height:none !important;\\n height:0 !important;\\n visibility:hidden !important;\\n overflow:hidden !important;\\n position:absolute !important;\\n z-index:-1000 !important;\\n top:0 !important;\\n right:0 !important\\n\";\nvar SIZING_STYLE = ['letter-spacing', 'line-height', 'padding-top', 'padding-bottom', 'font-family', 'font-weight', 'font-size', 'font-variant', 'text-rendering', 'text-transform', 'width', 'text-indent', 'padding-left', 'padding-right', 'border-width', 'box-sizing'];\nvar computedStyleCache = {};\nvar hiddenTextarea;\nexport function calculateNodeStyling(node) {\n var useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var nodeRef = node.getAttribute('id') || node.getAttribute('data-reactid') || node.getAttribute('name');\n\n if (useCache && computedStyleCache[nodeRef]) {\n return computedStyleCache[nodeRef];\n }\n\n var style = window.getComputedStyle(node);\n var boxSizing = style.getPropertyValue('box-sizing') || style.getPropertyValue('-moz-box-sizing') || style.getPropertyValue('-webkit-box-sizing');\n var paddingSize = parseFloat(style.getPropertyValue('padding-bottom')) + parseFloat(style.getPropertyValue('padding-top'));\n var borderSize = parseFloat(style.getPropertyValue('border-bottom-width')) + parseFloat(style.getPropertyValue('border-top-width'));\n var sizingStyle = SIZING_STYLE.map(function (name) {\n return \"\".concat(name, \":\").concat(style.getPropertyValue(name));\n }).join(';');\n var nodeInfo = {\n sizingStyle: sizingStyle,\n paddingSize: paddingSize,\n borderSize: borderSize,\n boxSizing: boxSizing\n };\n\n if (useCache && nodeRef) {\n computedStyleCache[nodeRef] = nodeInfo;\n }\n\n return nodeInfo;\n}\nexport default function calculateNodeHeight(uiTextNode) {\n var useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n\n if (!hiddenTextarea) {\n hiddenTextarea = document.createElement('textarea');\n hiddenTextarea.setAttribute('tab-index', '-1');\n hiddenTextarea.setAttribute('aria-hidden', 'true');\n document.body.appendChild(hiddenTextarea);\n } // Fix wrap=\"off\" issue\n // https://github.com/ant-design/ant-design/issues/6577\n\n\n if (uiTextNode.getAttribute('wrap')) {\n hiddenTextarea.setAttribute('wrap', uiTextNode.getAttribute('wrap'));\n } else {\n hiddenTextarea.removeAttribute('wrap');\n } // Copy all CSS properties that have an impact on the height of the content in\n // the textbox\n\n\n var _calculateNodeStyling = calculateNodeStyling(uiTextNode, useCache),\n paddingSize = _calculateNodeStyling.paddingSize,\n borderSize = _calculateNodeStyling.borderSize,\n boxSizing = _calculateNodeStyling.boxSizing,\n sizingStyle = _calculateNodeStyling.sizingStyle; // Need to have the overflow attribute to hide the scrollbar otherwise\n // text-lines will not calculated properly as the shadow will technically be\n // narrower for content\n\n\n hiddenTextarea.setAttribute('style', \"\".concat(sizingStyle, \";\").concat(HIDDEN_TEXTAREA_STYLE));\n hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';\n var minHeight = Number.MIN_SAFE_INTEGER;\n var maxHeight = Number.MAX_SAFE_INTEGER;\n var height = hiddenTextarea.scrollHeight;\n var overflowY;\n\n if (boxSizing === 'border-box') {\n // border-box: add border, since height = content + padding + border\n height += borderSize;\n } else if (boxSizing === 'content-box') {\n // remove padding, since height = content\n height -= paddingSize;\n }\n\n if (minRows !== null || maxRows !== null) {\n // measure height of a textarea with a single row\n hiddenTextarea.value = ' ';\n var singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;\n\n if (minRows !== null) {\n minHeight = singleRowHeight * minRows;\n\n if (boxSizing === 'border-box') {\n minHeight = minHeight + paddingSize + borderSize;\n }\n\n height = Math.max(minHeight, height);\n }\n\n if (maxRows !== null) {\n maxHeight = singleRowHeight * maxRows;\n\n if (boxSizing === 'border-box') {\n maxHeight = maxHeight + paddingSize + borderSize;\n }\n\n overflowY = height > maxHeight ? '' : 'hidden';\n height = Math.min(maxHeight, height);\n }\n }\n\n return {\n height: height,\n minHeight: minHeight,\n maxHeight: maxHeight,\n overflowY: overflowY\n };\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-textarea/es/calculateNodeHeight.js"],"names":["HIDDEN_TEXTAREA_STYLE","SIZING_STYLE","computedStyleCache","hiddenTextarea","calculateNodeStyling","node","useCache","arguments","length","undefined","nodeRef","getAttribute","style","window","getComputedStyle","boxSizing","getPropertyValue","paddingSize","parseFloat","borderSize","sizingStyle","map","name","concat","join","nodeInfo","calculateNodeHeight","uiTextNode","minRows","maxRows","document","createElement","setAttribute","body","appendChild","removeAttribute","_calculateNodeStyling","value","placeholder","minHeight","Number","MIN_SAFE_INTEGER","maxHeight","MAX_SAFE_INTEGER","height","scrollHeight","overflowY","singleRowHeight","Math","max","min"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA,IAAIA,qBAAqB,GAAG,gQAA5B;AACA,IAAIC,YAAY,GAAG,CAAC,gBAAD,EAAmB,aAAnB,EAAkC,aAAlC,EAAiD,gBAAjD,EAAmE,aAAnE,EAAkF,aAAlF,EAAiG,WAAjG,EAA8G,cAA9G,EAA8H,gBAA9H,EAAgJ,gBAAhJ,EAAkK,OAAlK,EAA2K,aAA3K,EAA0L,cAA1L,EAA0M,eAA1M,EAA2N,cAA3N,EAA2O,YAA3O,CAAnB;AACA,IAAIC,kBAAkB,GAAG,EAAzB;AACA,IAAIC,cAAJ;AACA,OAAO,SAASC,oBAAT,CAA8BC,IAA9B,EAAoC;AACzC,MAAIC,QAAQ,GAAGC,SAAS,CAACC,MAAV,GAAmB,CAAnB,IAAwBD,SAAS,CAAC,CAAD,CAAT,KAAiBE,SAAzC,GAAqDF,SAAS,CAAC,CAAD,CAA9D,GAAoE,KAAnF;AACA,MAAIG,OAAO,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MAAM,GAAGI,IAAI,CAACC,GAAL,CAASV,SAAT,EAAoBK,MAApB,CAAT;AACD;;AAED,QAAIf,OAAO,KAAK,IAAhB,EAAsB;AACpBa,MAAAA,SAAS,GAAGK,eAAe,GAAGlB,OAA9B;;AAEA,UAAId,SAAS,KAAK,YAAlB,EAAgC;AAC9B2B,QAAAA,SAAS,GAAGA,SAAS,GAAGzB,WAAZ,GAA0BE,UAAtC;AACD;;AAED2B,MAAAA,SAAS,GAAGF,MAAM,GAAGF,SAAT,GAAqB,EAArB,GAA0B,QAAtC;AACAE,MAAAA,MAAM,GAAGI,IAAI,CAACE,GAAL,CAASR,SAAT,EAAoBE,MAApB,CAAT;AACD;AACF;;AAED,SAAO;AACLA,IAAAA,MAAM,EAAEA,MADH;AAELL,IAAAA,SAAS,EAAEA,SAFN;AAGLG,IAAAA,SAAS,EAAEA,SAHN;AAILI,IAAAA,SAAS,EAAEA;AAJN,GAAP;AAMD","sourcesContent":["// Thanks to https://github.com/andreypopp/react-textarea-autosize/\n\n/**\n * calculateNodeHeight(uiTextNode, useCache = false)\n */\nvar HIDDEN_TEXTAREA_STYLE = \"\\n min-height:0 !important;\\n max-height:none !important;\\n height:0 !important;\\n visibility:hidden !important;\\n overflow:hidden !important;\\n position:absolute !important;\\n z-index:-1000 !important;\\n top:0 !important;\\n right:0 !important\\n\";\nvar SIZING_STYLE = ['letter-spacing', 'line-height', 'padding-top', 'padding-bottom', 'font-family', 'font-weight', 'font-size', 'font-variant', 'text-rendering', 'text-transform', 'width', 'text-indent', 'padding-left', 'padding-right', 'border-width', 'box-sizing'];\nvar computedStyleCache = {};\nvar hiddenTextarea;\nexport function calculateNodeStyling(node) {\n var useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var nodeRef = node.getAttribute('id') || node.getAttribute('data-reactid') || node.getAttribute('name');\n\n if (useCache && computedStyleCache[nodeRef]) {\n return computedStyleCache[nodeRef];\n }\n\n var style = window.getComputedStyle(node);\n var boxSizing = style.getPropertyValue('box-sizing') || style.getPropertyValue('-moz-box-sizing') || style.getPropertyValue('-webkit-box-sizing');\n var paddingSize = parseFloat(style.getPropertyValue('padding-bottom')) + parseFloat(style.getPropertyValue('padding-top'));\n var borderSize = parseFloat(style.getPropertyValue('border-bottom-width')) + parseFloat(style.getPropertyValue('border-top-width'));\n var sizingStyle = SIZING_STYLE.map(function (name) {\n return \"\".concat(name, \":\").concat(style.getPropertyValue(name));\n }).join(';');\n var nodeInfo = {\n sizingStyle: sizingStyle,\n paddingSize: paddingSize,\n borderSize: borderSize,\n boxSizing: boxSizing\n };\n\n if (useCache && nodeRef) {\n computedStyleCache[nodeRef] = nodeInfo;\n }\n\n return nodeInfo;\n}\nexport default function calculateNodeHeight(uiTextNode) {\n var useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n\n if (!hiddenTextarea) {\n hiddenTextarea = document.createElement('textarea');\n hiddenTextarea.setAttribute('tab-index', '-1');\n hiddenTextarea.setAttribute('aria-hidden', 'true');\n document.body.appendChild(hiddenTextarea);\n } // Fix wrap=\"off\" issue\n // https://github.com/ant-design/ant-design/issues/6577\n\n\n if (uiTextNode.getAttribute('wrap')) {\n hiddenTextarea.setAttribute('wrap', uiTextNode.getAttribute('wrap'));\n } else {\n hiddenTextarea.removeAttribute('wrap');\n } // Copy all CSS properties that have an impact on the height of the content in\n // the textbox\n\n\n var _calculateNodeStyling = calculateNodeStyling(uiTextNode, useCache),\n paddingSize = _calculateNodeStyling.paddingSize,\n borderSize = _calculateNodeStyling.borderSize,\n boxSizing = _calculateNodeStyling.boxSizing,\n sizingStyle = _calculateNodeStyling.sizingStyle; // Need to have the overflow attribute to hide the scrollbar otherwise\n // text-lines will not calculated properly as the shadow will technically be\n // narrower for content\n\n\n hiddenTextarea.setAttribute('style', \"\".concat(sizingStyle, \";\").concat(HIDDEN_TEXTAREA_STYLE));\n hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';\n var minHeight = Number.MIN_SAFE_INTEGER;\n var maxHeight = Number.MAX_SAFE_INTEGER;\n var height = hiddenTextarea.scrollHeight;\n var overflowY;\n\n if (boxSizing === 'border-box') {\n // border-box: add border, since height = content + padding + border\n height += borderSize;\n } else if (boxSizing === 'content-box') {\n // remove padding, since height = content\n height -= paddingSize;\n }\n\n if (minRows !== null || maxRows !== null) {\n // measure height of a textarea with a single row\n hiddenTextarea.value = ' ';\n var singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;\n\n if (minRows !== null) {\n minHeight = singleRowHeight * minRows;\n\n if (boxSizing === 'border-box') {\n minHeight = minHeight + paddingSize + borderSize;\n }\n\n height = Math.max(minHeight, height);\n }\n\n if (maxRows !== null) {\n maxHeight = singleRowHeight * maxRows;\n\n if (boxSizing === 'border-box') {\n maxHeight = maxHeight + paddingSize + borderSize;\n }\n\n overflowY = height > maxHeight ? '' : 'hidden';\n height = Math.min(maxHeight, height);\n }\n }\n\n return {\n height: height,\n minHeight: minHeight,\n maxHeight: maxHeight,\n overflowY: overflowY\n };\n}"]},"metadata":{},"sourceType":"module"}