1 line
31 KiB
JSON
1 line
31 KiB
JSON
|
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"autoComplete\", \"onChange\", \"onFocus\", \"onBlur\", \"onPressEnter\", \"onKeyDown\", \"onKeyUp\", \"prefixCls\", \"disabled\", \"htmlSize\", \"className\", \"maxLength\", \"suffix\", \"showCount\", \"count\", \"type\", \"classes\", \"classNames\", \"styles\", \"onCompositionStart\", \"onCompositionEnd\"];\nimport clsx from 'classnames';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport omit from \"rc-util/es/omit\";\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport BaseInput from \"./BaseInput\";\nimport useCount from \"./hooks/useCount\";\nimport { resolveOnChange, triggerFocus } from \"./utils/commonUtils\";\nvar Input = /*#__PURE__*/forwardRef(function (props, ref) {\n var autoComplete = props.autoComplete,\n onChange = props.onChange,\n onFocus = props.onFocus,\n onBlur = props.onBlur,\n onPressEnter = props.onPressEnter,\n onKeyDown = props.onKeyDown,\n onKeyUp = props.onKeyUp,\n _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? 'rc-input' : _props$prefixCls,\n disabled = props.disabled,\n htmlSize = props.htmlSize,\n className = props.className,\n maxLength = props.maxLength,\n suffix = props.suffix,\n showCount = props.showCount,\n count = props.count,\n _props$type = props.type,\n type = _props$type === void 0 ? 'text' : _props$type,\n classes = props.classes,\n classNames = props.classNames,\n styles = props.styles,\n _onCompositionStart = props.onCompositionStart,\n onCompositionEnd = props.onCompositionEnd,\n rest = _objectWithoutProperties(props, _excluded);\n var _useState = useState(false),\n _useState2 = _slicedToArray(_useState, 2),\n focused = _useState2[0],\n setFocused = _useState2[1];\n var compositionRef = useRef(false);\n var keyLockRef = useRef(false);\n var inputRef = useRef(null);\n var holderRef = useRef(null);\n var focus = function focus(option) {\n if (inputRef.current) {\n triggerFocus(inputRef.current, option);\n }\n };\n\n // ====================== Value =======================\n var _useMergedState = useMergedState(props.defaultValue, {\n value: props.value\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n value = _useMergedState2[0],\n setValue = _useMergedState2[1];\n var formatValue = value === undefined || value === null ? '' : String(value);\n\n // =================== Select Range ===================\n var _useState3 = useState(null),\n _useState4 = _slicedToArray(_useState3, 2),\n selection = _useState4[0],\n setSelection = _useState4[1];\n\n // ====================== Count =======================\n var countConfig = useCount(count, showCount);\n var mergedMax = countConfig.max || maxLength;\n var valueLength = countConfig.strategy(formatValue);\n var isOutOfRange = !!mergedMax && valueLength > mergedMax;\n\n // ======================= Ref ========================\n useImperativeHandle(ref, function () {\n var _holderRef$current;\n return {\n focus: focus,\n blur: function blur() {\n var _inputRef$current;\n (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.blur();\n },\n setSelectionRange: function setSelectionRange(start, end, direction) {\n var _inputRef$current2;\n (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.setSelectionRange(start, end, direction);\n },\n select
|