/** * TODO: 4.0 * - remove `dataSource` * - `size` not work with customizeInput * - customizeInput not feedback `ENTER` key since accessibility enhancement */ import * as React from 'react'; import toArray from 'rc-util/lib/Children/toArray'; import { SelectProps as RcSelectProps } from 'rc-select'; import classNames from 'classnames'; import omit from 'omit.js'; import Select, { InternalSelectProps, OptionType } from '../select'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import devWarning from '../_util/devWarning'; import { isValidElement } from '../_util/reactNode'; const { Option } = Select; const InternalSelect = Select as React.ComponentClass; export interface DataSourceItemObject { value: string; text: string; } export type DataSourceItemType = string | DataSourceItemObject; export interface AutoCompleteProps extends Omit< InternalSelectProps, 'inputIcon' | 'loading' | 'mode' | 'optionLabelProp' | 'labelInValue' > { dataSource?: DataSourceItemType[]; } function isSelectOptionOrSelectOptGroup(child: any): Boolean { return child && child.type && (child.type.isSelectOption || child.type.isSelectOptGroup); } const AutoComplete: React.RefForwardingComponent = (props, ref) => { const { prefixCls: customizePrefixCls, className, children, dataSource } = props; const childNodes: React.ReactElement[] = toArray(children); const selectRef = React.useRef