UNPKG

@skbkontur/ui-kit

Version:

45 lines (44 loc) 1.76 kB
/// <reference types="react" /> import * as React from 'react'; import { Override } from '../../lib/types'; import { ButtonProps } from '../Button/Button'; export declare type SelectProps<Value, Item> = Override<ButtonProps, { disabled?: boolean; placeholder?: React.ReactNode; renderValue?: (value: Value | null, item: Item | null) => React.ReactNode; renderItem?: (value: Value | null, item: Item | null) => React.ReactNode; value?: Value; defaultValue?: Value; items?: Item[]; areValuesEqual?: (value1: Value | null, value2: Value | null) => boolean; onChange?: (_: any, value: Value) => void; menuMaxHeight?: number | string; menuWidth?: number | string; width?: number | string; maxWidth?: number | string; menuAlign?: 'left' | 'right'; filterItem?: (value: Value, item: Item, pattern: string) => boolean; }>; export interface SelectState<Value> { value: Value | null; } export default class Select<Value = any, Item = any> extends React.Component<SelectProps<Value, Item>, SelectState<Value>> { static defaultProps: { areValuesEqual<T>(value1: T | null, value2: T | null): boolean; renderValue(value: any, item: any): React.ReactNode; placeholder: string; }; static SEP: () => JSX.Element; static static: (element: React.ReactElement<any> | (() => React.ReactElement<any>)) => React.ReactElement<any> | (() => React.ReactElement<any>); static Item: React.SFC; constructor(props: SelectProps<Value, Item>); render(): JSX.Element; private getPopupPozitions; private getCaption; private renderLabel; private renderItems; private getValue; private getItemByValue; private normalizeEntry; private handleClick; }