1 | import * as React from 'react';
|
2 | import { Simplify } from '@mui/types';
|
3 | import { SelectValue, UseSelectButtonSlotProps, UseSelectListboxSlotProps } from '../useSelect';
|
4 | import { SelectOption } from '../useOption';
|
5 | import { PopupProps } from '../Unstable_Popup';
|
6 | import { PolymorphicProps, SlotComponentProps } from '../utils';
|
7 | export interface SelectRootSlotPropsOverrides {
|
8 | }
|
9 | export interface SelectListboxSlotPropsOverrides {
|
10 | }
|
11 | export interface SelectPopupSlotPropsOverrides {
|
12 | }
|
13 | export interface SelectOwnProps<OptionValue extends {}, Multiple extends boolean> {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | areOptionsEqual?: (a: OptionValue, b: OptionValue) => boolean;
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 | autoComplete?: string;
|
28 | |
29 |
|
30 |
|
31 |
|
32 | autoFocus?: boolean;
|
33 | children?: React.ReactNode;
|
34 | className?: string;
|
35 | |
36 |
|
37 |
|
38 |
|
39 | defaultListboxOpen?: boolean;
|
40 | |
41 |
|
42 |
|
43 | defaultValue?: SelectValue<OptionValue, Multiple>;
|
44 | |
45 |
|
46 |
|
47 |
|
48 | disabled?: boolean;
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 | getSerializedValue?: (option: SelectValue<SelectOption<OptionValue>, Multiple>) => React.InputHTMLAttributes<HTMLInputElement>['value'];
|
55 | |
56 |
|
57 |
|
58 | listboxId?: string;
|
59 | |
60 |
|
61 |
|
62 |
|
63 | listboxOpen?: boolean;
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | multiple?: Multiple;
|
71 | |
72 |
|
73 |
|
74 | name?: string;
|
75 | |
76 |
|
77 |
|
78 | onChange?: (event: React.MouseEvent | React.KeyboardEvent | React.FocusEvent | null, value: SelectValue<OptionValue, Multiple>) => void;
|
79 | |
80 |
|
81 |
|
82 |
|
83 | onListboxOpenChange?: (isOpen: boolean) => void;
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | getOptionAsString?: (option: SelectOption<OptionValue>) => string;
|
92 | |
93 |
|
94 |
|
95 | renderValue?: (option: SelectValue<SelectOption<OptionValue>, Multiple>) => React.ReactNode;
|
96 | |
97 |
|
98 |
|
99 | placeholder?: React.ReactNode;
|
100 | |
101 |
|
102 |
|
103 |
|
104 | slotProps?: {
|
105 | root?: SlotComponentProps<'button', SelectRootSlotPropsOverrides, SelectOwnerState<OptionValue, Multiple>>;
|
106 | listbox?: SlotComponentProps<'ul', SelectListboxSlotPropsOverrides, SelectOwnerState<OptionValue, Multiple>>;
|
107 | popup?: SlotComponentProps<'div', SelectPopupSlotPropsOverrides & PopupProps, SelectOwnerState<OptionValue, Multiple>>;
|
108 | };
|
109 | |
110 |
|
111 |
|
112 |
|
113 | required?: boolean;
|
114 | |
115 |
|
116 |
|
117 |
|
118 |
|
119 | slots?: SelectSlots;
|
120 | |
121 |
|
122 |
|
123 |
|
124 | value?: SelectValue<OptionValue, Multiple>;
|
125 | }
|
126 | export interface SelectSlots {
|
127 | |
128 |
|
129 |
|
130 |
|
131 | root?: React.ElementType;
|
132 | |
133 |
|
134 |
|
135 |
|
136 | listbox?: React.ElementType;
|
137 | |
138 |
|
139 |
|
140 |
|
141 | popup?: React.ElementType;
|
142 | }
|
143 | export interface SelectTypeMap<OptionValue extends {}, Multiple extends boolean, AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
|
144 | props: SelectOwnProps<OptionValue, Multiple> & AdditionalProps;
|
145 | defaultComponent: RootComponentType;
|
146 | }
|
147 | export type SelectProps<OptionValue extends {}, Multiple extends boolean, RootComponentType extends React.ElementType = SelectTypeMap<OptionValue, Multiple>['defaultComponent']> = PolymorphicProps<SelectTypeMap<OptionValue, Multiple, {}, RootComponentType>, RootComponentType>;
|
148 | export interface SelectType {
|
149 | <OptionValue extends {}, Multiple extends boolean = false, RootComponentType extends React.ElementType = SelectTypeMap<OptionValue, Multiple>['defaultComponent']>(props: PolymorphicProps<SelectTypeMap<OptionValue, Multiple>, RootComponentType>): JSX.Element | null;
|
150 | propTypes?: any;
|
151 | displayName?: string | undefined;
|
152 | }
|
153 | export type SelectOwnerState<OptionValue extends {}, Multiple extends boolean> = Simplify<SelectOwnProps<OptionValue, Multiple> & {
|
154 | active: boolean;
|
155 | disabled: boolean;
|
156 | focusVisible: boolean;
|
157 | open: boolean;
|
158 | }>;
|
159 | export type SelectRootSlotProps<OptionValue extends {}, Multiple extends boolean> = Simplify<UseSelectButtonSlotProps & {
|
160 | className?: string;
|
161 | children?: React.ReactNode;
|
162 | ownerState: SelectOwnerState<OptionValue, Multiple>;
|
163 | }>;
|
164 | export type SelectListboxSlotProps<OptionValue extends {}, Multiple extends boolean> = Simplify<UseSelectListboxSlotProps & {
|
165 | className?: string;
|
166 | children?: React.ReactNode;
|
167 | ownerState: SelectOwnerState<OptionValue, Multiple>;
|
168 | }>;
|
169 | export type SelectPopupSlotProps<OptionValue extends {}, Multiple extends boolean> = {
|
170 | anchor: PopupProps['anchor'];
|
171 | children?: React.ReactNode;
|
172 | className?: string;
|
173 | keepMounted: PopupProps['keepMounted'];
|
174 | open: PopupProps['open'];
|
175 | ownerState: SelectOwnerState<OptionValue, Multiple>;
|
176 | placement: PopupProps['placement'];
|
177 | };
|