1 | import * as React from "react";
|
2 | import { BoxProps } from "../Box/index";
|
3 | import { IInput } from "../Input";
|
4 | import { PseudoBoxProps } from "../PseudoBox";
|
5 | import { Omit, Merge } from "../common-types";
|
6 |
|
7 | type SelectAttributes = Omit<
|
8 | React.SelectHTMLAttributes<HTMLSelectElement>,
|
9 | "size" | "disabled" | "required" | "defaultChecked"
|
10 | >;
|
11 |
|
12 | type MergeSelectAttributes = Merge<
|
13 | Omit<PseudoBoxProps, "ref" | "as" | "defaultChecked">,
|
14 | SelectAttributes
|
15 | >;
|
16 |
|
17 | export type ISelect = IInput<HTMLSelectElement> &
|
18 | MergeSelectAttributes &
|
19 | React.RefAttributes<HTMLSelectElement>;
|
20 |
|
21 | export type SelectProps = ISelect & {
|
22 | /**
|
23 | * The props passed to the select's root element.
|
24 | *
|
25 | * The internal structure looks like this:
|
26 | *
|
27 | * ```jsx
|
28 | * <SelectWrapper {...rootProps}>
|
29 | * <Select /> <== most props go here directly
|
30 | * <SelectIconWrapper />
|
31 | * </SelectWrapper>
|
32 | * ```
|
33 | *
|
34 | * In some scenario, you might want to pass some other props to the root.
|
35 | */
|
36 | rootProps?: BoxProps;
|
37 | /**
|
38 | * The placeholder for the select. This renders an `<option>` with empty value
|
39 | *
|
40 | * ```jsx
|
41 | * <option value="">{placeholder}</option>
|
42 | * ```
|
43 | */
|
44 | placeholder?: string;
|
45 | /**
|
46 | * The icon component to render.
|
47 | * You can use an icon in Chakra or pass a custom icon
|
48 | * from libraries like `react-icons`
|
49 | *
|
50 | * @example
|
51 | * ```jsx
|
52 | * <Select icon="arrow-down" />
|
53 | * <Select icon={MdArrowDownward} />
|
54 | * ```
|
55 | */
|
56 | icon?: string | React.ElementType;
|
57 | /**
|
58 | * The size of the icon
|
59 | */
|
60 | iconSize?: BoxProps["size"];
|
61 | /**
|
62 | * The color of the icon
|
63 | */
|
64 | iconColor?: BoxProps["color"];
|
65 | };
|
66 |
|
67 | declare const Select: React.FC<SelectProps>;
|
68 | export default Select;
|