/** * 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 warning from '../_util/warning'; 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, 'inputIcon' | 'loading' | 'mode' | 'optionLabelProp'> { 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