PromoCursed/node_modules/.cache/babel-loader/8485e82ac5a47ff0e876a3d3d7e00d9be69cbcd57ce83bec02d043320552ae97.json

1 line
21 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"prefixCls\", \"defaultValue\", \"value\", \"autoSize\", \"onResize\", \"className\", \"style\", \"disabled\", \"onChange\", \"onInternalAutoSize\"];\nimport classNames from 'classnames';\nimport ResizeObserver from 'rc-resize-observer';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport raf from \"rc-util/es/raf\";\nimport * as React from 'react';\nimport calculateAutoSizeStyle from \"./calculateNodeHeight\";\nvar RESIZE_START = 0;\nvar RESIZE_MEASURING = 1;\nvar RESIZE_STABLE = 2;\nvar ResizableTextArea = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _ref = props,\n prefixCls = _ref.prefixCls,\n defaultValue = _ref.defaultValue,\n value = _ref.value,\n autoSize = _ref.autoSize,\n onResize = _ref.onResize,\n className = _ref.className,\n style = _ref.style,\n disabled = _ref.disabled,\n onChange = _ref.onChange,\n onInternalAutoSize = _ref.onInternalAutoSize,\n restProps = _objectWithoutProperties(_ref, _excluded);\n\n // =============================== Value ================================\n var _useMergedState = useMergedState(defaultValue, {\n value: value,\n postState: function postState(val) {\n return val !== null && val !== void 0 ? val : '';\n }\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n mergedValue = _useMergedState2[0],\n setMergedValue = _useMergedState2[1];\n var onInternalChange = function onInternalChange(event) {\n setMergedValue(event.target.value);\n onChange === null || onChange === void 0 || onChange(event);\n };\n\n // ================================ Ref =================================\n var textareaRef = React.useRef();\n React.useImperativeHandle(ref, function () {\n return {\n textArea: textareaRef.current\n };\n });\n\n // ============================== AutoSize ==============================\n var _React$useMemo = React.useMemo(function () {\n if (autoSize && _typeof(autoSize) === 'object') {\n return [autoSize.minRows, autoSize.maxRows];\n }\n return [];\n }, [autoSize]),\n _React$useMemo2 = _slicedToArray(_React$useMemo, 2),\n minRows = _React$useMemo2[0],\n maxRows = _React$useMemo2[1];\n var needAutoSize = !!autoSize;\n\n // =============================== Scroll ===============================\n // https://github.com/ant-design/ant-design/issues/21870\n var fixFirefoxAutoScroll = function fixFirefoxAutoScroll() {\n try {\n // FF has bug with jump of scroll to top. We force back here.\n if (document.activeElement === textareaRef.current) {\n var _textareaRef$current = textareaRef.current,\n selectionStart = _textareaRef$current.selectionStart,\n selectionEnd = _textareaRef$current.selectionEnd,\n scrollTop = _textareaRef$current.scrollTop;\n\n // Fix Safari bug which not rollback when break line\n // This makes Chinese IME can't input. Do not fix this\n // const { value: tmpValue } = textareaRef.current;\n // textareaRef.current.value = '';\n // textareaRef.current.value = tmpValue;\n\n textareaRef.current.setSelectionRange(selectionStart, selectionEnd);\n textareaRef.current.scrollTop = scrollTop;\n }\n } catch (e) {\n // Fix error in Chrome:\n // Failed to read the 'selectionStart' property from 'HTMLInputElement'\n // http://stackoverflow.com/q/21177489/3040605\n }\n };\n\n // =============================== Resize ==========================