@open-condo/ui
Version:
A set of React UI components for developing applications inside the condo ecosystem
49 lines • 2.14 kB
TypeScript
import { Select as DefaultSelect } from 'antd';
import React from 'react';
import type { TypographyTextProps } from '@open-condo/ui/src';
import { SELECT_TYPES } from './constants';
import type { Either } from '../_utils/types';
import type { SelectProps as DefaultSelectProps } from 'antd';
export declare const SELECT_CLASS_PREFIX = "condo-select";
export declare const Option: typeof DefaultSelect.Option;
export declare const OptGroup: typeof DefaultSelect.OptGroup;
export type OptionType = {
label: string;
value?: string | number | null;
disabled?: boolean;
textType?: TypographyTextProps['type'];
title?: string;
key?: React.Key;
hidden?: boolean;
};
export type OptionsGroupType = {
label: string;
options: Array<OptionType>;
key?: React.Key;
};
export type OptionsItem = Either<OptionType, OptionsGroupType> | null;
type OnChangeType = (value: OptionType['value'] | Array<OptionType['value']>, option: React.PropsWithChildren<OptionType> | Array<React.PropsWithChildren<OptionType>>) => void;
/**
* NOTE: Ant have bad interface for Select
* It may work with multiple values, but it is not specified in the interface.
*/
type CustomSelectProps<ValueType = SelectValueTypeBase> = Either<{
value?: ValueType | null;
}, {
mode: 'multiple';
value?: Array<ValueType>;
}>;
type SelectValueTypeBase = string | number | null | undefined;
export type SelectProps<ValueType = SelectValueTypeBase> = Pick<DefaultSelectProps<ValueType, OptionType>, 'disabled' | 'loading' | 'id' | 'dropdownAlign' | 'filterOption' | 'optionFilterProp' | 'allowClear' | 'showSearch' | 'defaultValue' | 'onSearch' | 'searchValue'> & {
placeholder?: string;
options: Array<OptionsItem>;
displayMode?: 'fill-parent' | 'fit-content';
type?: typeof SELECT_TYPES[number];
onChange?: OnChangeType;
notFoundContentLabel?: string;
ellipsis?: 'end' | 'start';
showArrow?: boolean;
} & CustomSelectProps<ValueType>;
declare const Select: <ValueType extends SelectValueTypeBase>(props: SelectProps<ValueType>) => React.ReactElement;
export { Select, };
//# sourceMappingURL=select.d.ts.map