/** * @file Select * @description * @author fex * @date 2017-11-07 */ import {uncontrollable} from 'uncontrollable'; import React from 'react'; import VirtualList from './virtual-list'; import Overlay from './Overlay'; import PopOver from './PopOver'; import Downshift, {ControllerStateAndHelpers} from 'downshift'; import {closeIcon, Icon} from './icons'; // @ts-ignore import matchSorter from 'match-sorter'; import {noop, isObject, findTree, autobind} from '../utils/helper'; import find from 'lodash/find'; import isPlainObject from 'lodash/isPlainObject'; import union from 'lodash/union'; import {highlight} from '../renderers/Form/Options'; import {findDOMNode} from 'react-dom'; import {ClassNamesFn, themeable, ThemeProps} from '../theme'; import Checkbox from './Checkbox'; import Input from './Input'; import {Api} from '../types'; import {LocaleProps, localeable} from '../locale'; import Spinner from './Spinner'; import {Option, Options} from '../Schema'; import {RemoteOptionsProps, withRemoteConfig} from './WithRemoteConfig'; export {Option, Options}; export interface OptionProps { className?: string; multi?: boolean; multiple?: boolean; valueField?: string; labelField?: string; simpleValue?: boolean; // 默认onChange 出去是整个 option 节点,如果配置了 simpleValue 就只包含值。 options: Options; loading?: boolean; joinValues?: boolean; extractValue?: boolean; delimiter?: string; clearable?: boolean; resetValue: any; placeholder?: string; disabled?: boolean; creatable?: boolean; onAdd?: ( idx?: number | Array, value?: any, skipForm?: boolean ) => void; editable?: boolean; onEdit?: (value: Option, origin?: Option, skipForm?: boolean) => void; removable?: boolean; onDelete?: (value: Option) => void; } export type OptionValue = string | number | null | undefined | Option; export function value2array( value: OptionValue | Array, props: Pick< OptionProps, 'multi' | 'multiple' | 'delimiter' | 'valueField' | 'options' > ): Array