1 line
18 KiB
JSON
1 line
18 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport SearchOutlined from \"@ant-design/icons/es/icons/SearchOutlined\";\nimport classNames from 'classnames';\nimport { composeRef } from \"rc-util/es/ref\";\nimport { cloneElement } from '../_util/reactNode';\nimport Button from '../button';\nimport { ConfigContext } from '../config-provider';\nimport useSize from '../config-provider/hooks/useSize';\nimport { useCompactItemContext } from '../space/Compact';\nimport Input from './Input';\nconst Search = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n prefixCls: customizePrefixCls,\n inputPrefixCls: customizeInputPrefixCls,\n className,\n size: customizeSize,\n suffix,\n enterButton = false,\n addonAfter,\n loading,\n disabled,\n onSearch: customOnSearch,\n onChange: customOnChange,\n onCompositionStart,\n onCompositionEnd\n } = props,\n restProps = __rest(props, [\"prefixCls\", \"inputPrefixCls\", \"className\", \"size\", \"suffix\", \"enterButton\", \"addonAfter\", \"loading\", \"disabled\", \"onSearch\", \"onChange\", \"onCompositionStart\", \"onCompositionEnd\"]);\n const {\n getPrefixCls,\n direction\n } = React.useContext(ConfigContext);\n const composedRef = React.useRef(false);\n const prefixCls = getPrefixCls('input-search', customizePrefixCls);\n const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);\n const {\n compactSize\n } = useCompactItemContext(prefixCls, direction);\n const size = useSize(ctx => {\n var _a;\n return (_a = customizeSize !== null && customizeSize !== void 0 ? customizeSize : compactSize) !== null && _a !== void 0 ? _a : ctx;\n });\n const inputRef = React.useRef(null);\n const onChange = e => {\n if ((e === null || e === void 0 ? void 0 : e.target) && e.type === 'click' && customOnSearch) {\n customOnSearch(e.target.value, e, {\n source: 'clear'\n });\n }\n customOnChange === null || customOnChange === void 0 ? void 0 : customOnChange(e);\n };\n const onMouseDown = e => {\n var _a;\n if (document.activeElement === ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input)) {\n e.preventDefault();\n }\n };\n const onSearch = e => {\n var _a, _b;\n if (customOnSearch) {\n customOnSearch((_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.value, e, {\n source: 'input'\n });\n }\n };\n const onPressEnter = e => {\n if (composedRef.current || loading) {\n return;\n }\n onSearch(e);\n };\n const searchIcon = typeof enterButton === 'boolean' ? /*#__PURE__*/React.createElement(SearchOutlined, null) : null;\n const btnClassName = `${prefixCls}-button`;\n let button;\n const enterButtonAsElement = enterButton || {};\n const isAntdButton = enterButtonAsElement.type && enterButtonAsElement.type.__ANT_BUTTON === true;\n if (isAntdButton || enterButtonAsElement.type === 'button') {\n button = cloneElement(enterButtonAsElement, Object.assign({\n onMouseDown,\n onClick: e => {\n var _a, _b;\n (_b = (_a = enterButtonAsElement === null || enterButtonAsElement === void 0 ? void 0 : enterButtonAsElement.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n onSearch(e);\n },\n key: 'enterButton'\n }, isAntdButton ? {\n className: btnClassName,\n size\n } : {}));\n } else {\n button = /*#__PURE__*/React.createElement(Button, {\n classNa
|