UNPKG

1.39 kBTypeScriptView Raw
1import { ComponentType, ReactElement, ReactNode, Ref as ElementRef } from 'react';
2import { CSSObject } from '@emotion/serialize';
3
4import { borderRadius, colors, spacing } from '../theme';
5import { CommonProps, GroupTypeBase, OptionTypeBase } from '../types';
6
7interface State {
8 /** Whether the select is disabled. */
9 isDisabled: boolean;
10 /** Whether the select is focused. */
11 isFocused: boolean;
12 /** Whether the select is expanded. */
13 menuIsOpen: boolean;
14}
15
16export type ControlProps<
17 OptionType extends OptionTypeBase,
18 IsMulti extends boolean,
19 GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
20> = CommonProps<OptionType, IsMulti, GroupType> &
21 State & {
22 /** Children to render. */
23 children: ReactNode;
24 innerRef: ElementRef<any>;
25 /** The mouse down event and the innerRef to pass down to the controller element. */
26 innerProps: {
27 onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;
28 };
29 };
30
31export function css(state: State): CSSObject;
32
33declare function Control<
34 OptionType extends OptionTypeBase,
35 IsMulti extends boolean,
36 GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
37 // tslint:disable-next-line:no-unnecessary-generics
38>(props: ControlProps<OptionType, IsMulti, GroupType>): ReactElement;
39
40export default Control;