1 line
23 KiB
JSON
1 line
23 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 _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport clsx from 'classnames';\nimport React, { cloneElement, useRef } from 'react';\nimport { hasAddon, hasPrefixSuffix } from \"./utils/commonUtils\";\nvar BaseInput = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _element$props, _element$props2;\n var inputEl = props.inputElement,\n children = props.children,\n prefixCls = props.prefixCls,\n prefix = props.prefix,\n suffix = props.suffix,\n addonBefore = props.addonBefore,\n addonAfter = props.addonAfter,\n className = props.className,\n style = props.style,\n disabled = props.disabled,\n readOnly = props.readOnly,\n focused = props.focused,\n triggerFocus = props.triggerFocus,\n allowClear = props.allowClear,\n value = props.value,\n handleReset = props.handleReset,\n hidden = props.hidden,\n classes = props.classes,\n classNames = props.classNames,\n dataAttrs = props.dataAttrs,\n styles = props.styles,\n components = props.components,\n onClear = props.onClear;\n var inputElement = children !== null && children !== void 0 ? children : inputEl;\n var AffixWrapperComponent = (components === null || components === void 0 ? void 0 : components.affixWrapper) || 'span';\n var GroupWrapperComponent = (components === null || components === void 0 ? void 0 : components.groupWrapper) || 'span';\n var WrapperComponent = (components === null || components === void 0 ? void 0 : components.wrapper) || 'span';\n var GroupAddonComponent = (components === null || components === void 0 ? void 0 : components.groupAddon) || 'span';\n var containerRef = useRef(null);\n var onInputClick = function onInputClick(e) {\n var _containerRef$current;\n if ((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(e.target)) {\n triggerFocus === null || triggerFocus === void 0 || triggerFocus();\n }\n };\n var hasAffix = hasPrefixSuffix(props);\n var element = /*#__PURE__*/cloneElement(inputElement, {\n value: value,\n className: clsx(inputElement.props.className, !hasAffix && (classNames === null || classNames === void 0 ? void 0 : classNames.variant)) || null\n });\n\n // ======================== Ref ======================== //\n var groupRef = useRef(null);\n React.useImperativeHandle(ref, function () {\n return {\n nativeElement: groupRef.current || containerRef.current\n };\n });\n\n // ================== Prefix & Suffix ================== //\n if (hasAffix) {\n // ================== Clear Icon ================== //\n var clearIcon = null;\n if (allowClear) {\n var needClear = !disabled && !readOnly && value;\n var clearIconCls = \"\".concat(prefixCls, \"-clear-icon\");\n var iconNode = _typeof(allowClear) === 'object' && allowClear !== null && allowClear !== void 0 && allowClear.clearIcon ? allowClear.clearIcon : '✖';\n clearIcon = /*#__PURE__*/React.createElement(\"span\", {\n onClick: function onClick(event) {\n handleReset === null || handleReset === void 0 || handleReset(event);\n onClear === null || onClear === void 0 || onClear();\n }\n // Do not trigger onBlur when clear input\n // https://github.com/ant-design/ant-design/issues/31200\n ,\n\n onMouseDown: function onMouseDown(e) {\n return e.preventDefault();\n },\n className: clsx(clearIconCls, _defineProperty(_defineProperty({}, \"\".concat(clearIconCls, \"-hidden\"), !needClear), \"\".concat(clearIconCls, \"-has-suffix\"), !!suffix)),\n role: \"button\",\n tabIndex: -1\n }, iconNode);\n }\n var affixWrapperPrefixCls = \"\".concat(prefixCls, \"-affix-wrapper\");\n var affixWrapperCls = clsx(affixWrapperPrefixC
|