UNPKG

amis

Version:

一种MIS页面生成工具

161 lines (160 loc) 6.05 kB
/** * @file Select * @description * @author fex * @date 2017-11-07 */ import React from 'react'; import 'react-datetime/css/react-datetime.css'; import { ControllerStateAndHelpers } from 'downshift'; import { noop } from '../utils/helper'; import { ClassNamesFn } from '../theme'; export interface Option { label?: string; value?: any; disabled?: boolean; children?: Options; visible?: boolean; hidden?: boolean; description?: string; [propName: string]: any; } export interface Options extends Array<Option> { } export interface OptionProps { multi?: boolean; multiple?: boolean; valueField?: string; options: Options; joinValues?: boolean; extractValue?: boolean; delimiter?: string; clearable?: boolean; placeholder?: string; autoFill?: { [propName: string]: any; }; } export declare type OptionValue = string | number | null | undefined | Option; export declare function value2array(value: OptionValue | Array<OptionValue>, props: Partial<OptionProps>): Array<Option>; export declare function expandValue(value: OptionValue, props: Partial<OptionProps>): Option | null; export declare function normalizeOptions(options: string | { [propName: string]: string; } | Array<string> | Options): Options; interface SelectProps { classPrefix: string; classnames: ClassNamesFn; className?: string; creatable: boolean; multiple: boolean; valueField: string; labelField: string; searchable?: boolean; options: Array<Option>; value: any; loadOptions?: Function; searchPromptText: string; loading?: boolean; loadingPlaceholder: string; spinnerClassName?: string; noResultsText: string; clearable: boolean; clearAllText: string; clearValueText: string; placeholder: string; inline: boolean; disabled: boolean; popOverContainer?: any; promptTextCreator: (label: string) => string; onChange: (value: void | string | Option | Array<Option>) => void; onNewOptionClick: (value: Option) => void; onFocus?: Function; onBlur?: Function; checkAll?: boolean; checkAllLabel?: string; defaultCheckAll?: boolean; simpleValue?: boolean; } interface SelectState { isOpen: boolean; isFocused: boolean; inputValue: string; highlightedIndex: number; selection: Array<Option>; } export declare class Select extends React.Component<SelectProps, SelectState> { static defaultProps: { multiple: boolean; clearable: boolean; creatable: boolean; searchPromptText: string; loadingPlaceholder: string; noResultsText: string; clearAllText: string; clearValueText: string; placeholder: string; valueField: string; labelField: string; spinnerClassName: string; promptTextCreator: (label: string) => string; onNewOptionClick: typeof noop; inline: boolean; disabled: boolean; checkAll: boolean; checkAllLabel: string; defaultCheckAll: boolean; }; input: HTMLInputElement; target: HTMLElement; menu: React.RefObject<HTMLDivElement>; constructor(props: SelectProps); componentDidMount(): void; componentWillReceiveProps(nextProps: SelectProps): void; open(): void; close(): void; toggle(e?: React.MouseEvent<HTMLDivElement>): void; onFocus(e: any): void; onBlur(e: any): void; focus(): void; blur(): void; getTarget(): HTMLElement; inputRef(ref: HTMLInputElement): void; toggleCheckAll(): void; removeItem(index: number, e?: React.MouseEvent<HTMLElement>): void; handleInputChange(evt: React.ChangeEvent<HTMLInputElement>): void; handleChange(selectItem: any): void; handleStateChange(changes: any): void; handleKeyPress(e: React.KeyboardEvent): void; clearValue(e: React.MouseEvent<any>): void; renderValue({ inputValue, isOpen }: ControllerStateAndHelpers<any>): JSX.Element | (JSX.Element | null)[] | null; renderOuter({ selectedItem, getItemProps, highlightedIndex, inputValue, isOpen }: ControllerStateAndHelpers<any>): JSX.Element; render(): JSX.Element; } declare const _default: React.ComponentClass<Pick<Pick<SelectProps, "loading" | "value" | "options" | "searchable" | "className" | "classPrefix" | "classnames" | "onFocus" | "onBlur" | "onChange" | "popOverContainer" | "loadOptions" | "simpleValue"> & Partial<Pick<SelectProps, "disabled" | "inline" | "multiple" | "valueField" | "labelField" | "placeholder" | "clearable" | "creatable" | "searchPromptText" | "loadingPlaceholder" | "spinnerClassName" | "noResultsText" | "clearAllText" | "clearValueText" | "promptTextCreator" | "onNewOptionClick" | "checkAll" | "checkAllLabel" | "defaultCheckAll">> & Partial<Pick<{ multiple: boolean; clearable: boolean; creatable: boolean; searchPromptText: string; loadingPlaceholder: string; noResultsText: string; clearAllText: string; clearValueText: string; placeholder: string; valueField: string; labelField: string; spinnerClassName: string; promptTextCreator: (label: string) => string; onNewOptionClick: typeof noop; inline: boolean; disabled: boolean; checkAll: boolean; checkAllLabel: string; defaultCheckAll: boolean; }, never>>, "disabled" | "loading" | "inline" | "multiple" | "value" | "valueField" | "labelField" | "options" | "searchable" | "className" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "clearable" | "popOverContainer" | "creatable" | "loadOptions" | "searchPromptText" | "loadingPlaceholder" | "spinnerClassName" | "noResultsText" | "clearAllText" | "clearValueText" | "promptTextCreator" | "onNewOptionClick" | "checkAll" | "checkAllLabel" | "defaultCheckAll" | "simpleValue"> & { theme?: string | undefined; classPrefix?: string | undefined; classnames?: ClassNamesFn | undefined; }, any> & { ComposedComponent: typeof Select; }; export default _default;