1 line
12 KiB
JSON
1 line
12 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport omit from \"rc-util/es/omit\";\nimport { useZIndex } from '../_util/hooks/useZIndex';\nimport genPurePanel from '../_util/PurePanel';\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport Select from '../select';\nconst {\n Option\n} = Select;\nfunction isSelectOptionOrSelectOptGroup(child) {\n return (child === null || child === void 0 ? void 0 : child.type) && (child.type.isSelectOption || child.type.isSelectOptGroup);\n}\nconst AutoComplete = (props, ref) => {\n var _a;\n const {\n prefixCls: customizePrefixCls,\n className,\n popupClassName,\n dropdownClassName,\n children,\n dataSource\n } = props;\n const childNodes = toArray(children);\n // ============================= Input =============================\n let customizeInput;\n if (childNodes.length === 1 && /*#__PURE__*/React.isValidElement(childNodes[0]) && !isSelectOptionOrSelectOptGroup(childNodes[0])) {\n [customizeInput] = childNodes;\n }\n const getInputElement = customizeInput ? () => customizeInput : undefined;\n // ============================ Options ============================\n let optionChildren;\n // [Legacy] convert `children` or `dataSource` into option children\n if (childNodes.length && isSelectOptionOrSelectOptGroup(childNodes[0])) {\n optionChildren = children;\n } else {\n optionChildren = dataSource ? dataSource.map(item => {\n if ( /*#__PURE__*/React.isValidElement(item)) {\n return item;\n }\n switch (typeof item) {\n case 'string':\n return /*#__PURE__*/React.createElement(Option, {\n key: item,\n value: item\n }, item);\n case 'object':\n {\n const {\n value: optionValue\n } = item;\n return /*#__PURE__*/React.createElement(Option, {\n key: optionValue,\n value: optionValue\n }, item.text);\n }\n default:\n return undefined;\n }\n }) : [];\n }\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('AutoComplete');\n warning.deprecated(!('dataSource' in props), 'dataSource', 'options');\n process.env.NODE_ENV !== \"production\" ? warning(!customizeInput || !('size' in props), 'usage', 'You need to control style self instead of setting `size` when using customize input.') : void 0;\n warning.deprecated(!dropdownClassName, 'dropdownClassName', 'popupClassName');\n }\n const {\n getPrefixCls\n } = React.useContext(ConfigContext);\n const prefixCls = getPrefixCls('select', customizePrefixCls);\n // ============================ zIndex ============================\n const [zIndex] = useZIndex('SelectLike', (_a = props.dropdownStyle) === null || _a === void 0 ? void 0 : _a.zIndex);\n return /*#__PURE__*/React.createElement(Select, Object.assign({\n ref: ref,\n suffixIcon: null\n }, omit(props, ['dataSource', 'dropdownClassName']), {\n prefixCls: prefixCls,\n popupClassName: popupClassName || dropdownClassName,\n dropdownStyle: Object.assign(Object.assign({}, props.dropdownStyle), {\n zIndex\n }),\n className: classNames(`${prefixCls}-auto-complete`, className),\n mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,\n // Internal api\n getInputElement\n }), optionChildren);\n};\nconst RefAutoComplete = /*#__PURE__*/React.forwardRef(AutoComplete);\n// We don't care debug panel\n/* istanbul ignore next */\nconst PurePanel = genPurePanel(RefAutoComplete);\nRefAutoComplete.Option = Option;\nRefAutoComplete._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;\nif (process.env.NODE_ENV !== 'production') {\n RefAutoComplete.displayName = 'AutoComplete';\n}\nexport default RefAutoComplete;","map":{"version":3,"names":["React","classNames","toArray","omit","useZIndex","genPurePanel","devUseWarning","ConfigContex
|