1 | import { ComponentType, ReactElement as Element } from 'react';
|
2 | import {
|
3 | IndicatorContainerProps,
|
4 | ContainerProps,
|
5 | ValueContainerProps,
|
6 | IndicatorsContainer,
|
7 | SelectContainer,
|
8 | ValueContainer,
|
9 | } from './containers';
|
10 | import {
|
11 | IndicatorProps,
|
12 | LoadingIconProps,
|
13 | ClearIndicator,
|
14 | DropdownIndicator,
|
15 | LoadingIndicator,
|
16 | IndicatorSeparator,
|
17 | DownChevron,
|
18 | CrossIcon,
|
19 | } from './indicators';
|
20 |
|
21 | import Control, { ControlProps } from './Control';
|
22 | import Group, { GroupProps, GroupHeading } from './Group';
|
23 | import Input, { InputProps } from './Input';
|
24 | import Menu, {
|
25 | MenuProps,
|
26 | MenuList,
|
27 | MenuListComponentProps,
|
28 | MenuPortal,
|
29 | MenuPortalProps,
|
30 | NoticeProps,
|
31 | NoOptionsMessage,
|
32 | LoadingMessage,
|
33 | } from './Menu';
|
34 | import MultiValue, { MultiValueProps, MultiValueContainer, MultiValueLabel, MultiValueRemove } from './MultiValue';
|
35 | import Option, { OptionProps } from './Option';
|
36 | import Placeholder, { PlaceholderProps } from './Placeholder';
|
37 | import SingleValue, { SingleValueProps } from './SingleValue';
|
38 | import { GroupTypeBase, OptionTypeBase } from '../types';
|
39 |
|
40 | export type PlaceholderOrValue<
|
41 | OptionType extends OptionTypeBase,
|
42 | IsMulti extends boolean,
|
43 | GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
|
44 | > =
|
45 | | Element<ComponentType<PlaceholderProps<OptionType, IsMulti, GroupType>>>
|
46 | | Element<ComponentType<SingleValueProps<OptionType, GroupType>>>
|
47 | | Array<Element<ComponentType<MultiValueProps<OptionType, GroupType>>>>;
|
48 |
|
49 | export type IndicatorComponentType<
|
50 | OptionType extends OptionTypeBase,
|
51 | IsMulti extends boolean,
|
52 | GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
|
53 | > = ComponentType<IndicatorProps<OptionType, IsMulti, GroupType>>;
|
54 |
|
55 | export interface SelectComponents<
|
56 | OptionType extends OptionTypeBase,
|
57 | IsMulti extends boolean,
|
58 | GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
|
59 | > {
|
60 | ClearIndicator: IndicatorComponentType<OptionType, IsMulti, GroupType> | null;
|
61 | Control: ComponentType<ControlProps<OptionType, IsMulti, GroupType>>;
|
62 | DropdownIndicator: IndicatorComponentType<OptionType, IsMulti, GroupType> | null;
|
63 | DownChevron: ComponentType<any>;
|
64 | CrossIcon: ComponentType<any>;
|
65 | Group: ComponentType<GroupProps<OptionType, IsMulti, GroupType>>;
|
66 | GroupHeading: ComponentType<any>;
|
67 | IndicatorsContainer: ComponentType<IndicatorContainerProps<OptionType, IsMulti, GroupType>>;
|
68 | IndicatorSeparator: IndicatorComponentType<OptionType, IsMulti, GroupType> | null;
|
69 | Input: ComponentType<InputProps>;
|
70 | LoadingIndicator: ComponentType<LoadingIconProps<OptionType, IsMulti, GroupType>> | null;
|
71 | Menu: ComponentType<MenuProps<OptionType, IsMulti, GroupType>>;
|
72 | MenuList: ComponentType<MenuListComponentProps<OptionType, IsMulti, GroupType>>;
|
73 | MenuPortal: ComponentType<MenuPortalProps<OptionType, IsMulti, GroupType>>;
|
74 | LoadingMessage: ComponentType<NoticeProps<OptionType, IsMulti, GroupType>>;
|
75 | NoOptionsMessage: ComponentType<NoticeProps<OptionType, IsMulti, GroupType>>;
|
76 | MultiValue: ComponentType<MultiValueProps<OptionType, GroupType>>;
|
77 | MultiValueContainer: ComponentType<any>;
|
78 | MultiValueLabel: ComponentType<any>;
|
79 | MultiValueRemove: ComponentType<any>;
|
80 | Option: ComponentType<OptionProps<OptionType, IsMulti, GroupType>>;
|
81 | Placeholder: ComponentType<PlaceholderProps<OptionType, IsMulti, GroupType>>;
|
82 | SelectContainer: ComponentType<ContainerProps<OptionType, IsMulti, GroupType>>;
|
83 | SingleValue: ComponentType<SingleValueProps<OptionType, GroupType>>;
|
84 | ValueContainer: ComponentType<ValueContainerProps<OptionType, IsMulti, GroupType>>;
|
85 | }
|
86 |
|
87 | export type SelectComponentsConfig<
|
88 | OptionType extends OptionTypeBase,
|
89 | IsMulti extends boolean,
|
90 | GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
|
91 | > = Partial<SelectComponents<OptionType, IsMulti, GroupType>>;
|
92 |
|
93 | export interface Components {
|
94 | ClearIndicator: typeof ClearIndicator;
|
95 | Control: typeof Control;
|
96 | DropdownIndicator: typeof DropdownIndicator;
|
97 | DownChevron: typeof DownChevron;
|
98 | CrossIcon: typeof CrossIcon;
|
99 | Group: typeof Group;
|
100 | GroupHeading: typeof GroupHeading;
|
101 | IndicatorsContainer: typeof IndicatorsContainer;
|
102 | IndicatorSeparator: typeof IndicatorSeparator;
|
103 | Input: typeof Input;
|
104 | LoadingIndicator: typeof LoadingIndicator;
|
105 | Menu: typeof Menu;
|
106 | MenuList: typeof MenuList;
|
107 | MenuPortal: typeof MenuPortal;
|
108 | LoadingMessage: typeof LoadingMessage;
|
109 | NoOptionsMessage: typeof NoOptionsMessage;
|
110 | MultiValue: typeof MultiValue;
|
111 | MultiValueContainer: typeof MultiValueContainer;
|
112 | MultiValueLabel: typeof MultiValueLabel;
|
113 | MultiValueRemove: typeof MultiValueRemove;
|
114 | Option: typeof Option;
|
115 | Placeholder: typeof Placeholder;
|
116 | SelectContainer: typeof SelectContainer;
|
117 | SingleValue: typeof SingleValue;
|
118 | ValueContainer: typeof ValueContainer;
|
119 | }
|
120 |
|
121 | export const components: Components;
|
122 |
|
123 | export interface Props<
|
124 | OptionType extends OptionTypeBase,
|
125 | IsMulti extends boolean,
|
126 | GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
|
127 | > {
|
128 | components: SelectComponentsConfig<OptionType, IsMulti, GroupType>;
|
129 | }
|
130 |
|
131 | export function defaultComponents<
|
132 | OptionType extends OptionTypeBase,
|
133 | IsMulti extends boolean,
|
134 | GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType>
|
135 | >(props: Props<OptionType, IsMulti, GroupType>): SelectComponents<OptionType, IsMulti, GroupType>;
|