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