Skip to content

Commit 56aaa92

Browse files
committed
fix types
1 parent f81b2bc commit 56aaa92

File tree

1 file changed

+169
-167
lines changed

1 file changed

+169
-167
lines changed

packages/core/src/components/next/Dropdown/Dropdown.types.ts

Lines changed: 169 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -91,188 +91,190 @@ type BoxModeConstraint =
9191
boxMode?: boolean;
9292
};
9393

94-
export type BaseDropdownProps<Item extends BaseListItemData<Record<string, unknown>>> = VibeComponentProps & {
95-
/**
96-
* The list of options available in the list.
97-
*/
98-
options: DropdownGroupOption<Item>;
99-
/**
100-
* Props to be passed to the Tooltip component that wraps the dropdown.
101-
*/
102-
tooltipProps?: Partial<TooltipProps>;
103-
/**
104-
* If true, displays dividers between grouped options.
105-
*/
106-
withGroupDivider?: boolean;
107-
/**
108-
* If true, makes the group title sticky.
109-
*/
110-
stickyGroupTitle?: boolean;
111-
/**
112-
* The size of the dropdown.
113-
*/
114-
size?: DropdownSizes;
115-
/**
116-
* The direction of the dropdown.
117-
*/
118-
dir?: DropdownDirection;
119-
/**
120-
* The function to call to render an option.
121-
*/
122-
optionRenderer?: (option: Item) => React.ReactNode;
123-
/**
124-
* The function to call to render the menu.
125-
*/
126-
menuRenderer?: (props: {
127-
children: React.ReactNode;
128-
filteredOptions: ListGroup<Item>[];
129-
selectedItems: Item[];
130-
getItemProps: (options: any) => Record<string, unknown>;
131-
}) => React.ReactNode;
132-
/**
133-
* The message to display when there are no options.
134-
*/
135-
noOptionsMessage?: string | React.ReactNode;
136-
/**
137-
* The placeholder to display when the dropdown is empty.
138-
*/
139-
placeholder?: string;
140-
/**
141-
* If true, the dropdown is disabled.
142-
*/
143-
disabled?: boolean;
144-
/**
145-
* If true, the dropdown is read only.
146-
*/
147-
readOnly?: boolean;
148-
/**
149-
* If true, the dropdown is in an error state.
150-
*/
151-
error?: boolean;
152-
/**
153-
* The helper text to display below the dropdown.
154-
*/
155-
helperText?: string;
156-
/**
157-
* If true, the dropdown is required.
158-
*/
159-
required?: boolean;
160-
/**
161-
* The label to display above the dropdown.
162-
*/
163-
label?: string;
164-
/**
165-
* The ARIA label for the dropdown.
166-
*/
167-
ariaLabel?: string;
168-
/**
169-
* The ARIA label for the dropdown input.
170-
*/
171-
inputAriaLabel?: string;
172-
/**
173-
* The ARIA label for the menu container.
174-
*/
175-
menuAriaLabel?: string;
176-
/**
177-
* The ARIA label for the clear button.
178-
*/
179-
clearAriaLabel?: string;
180-
/**
181-
* The current value of the input field.
182-
*/
183-
inputValue?: string;
184-
/**
185-
* The maximum height of the dropdown menu.
186-
*/
187-
maxMenuHeight?: number;
188-
/**
189-
* If true, controls the menu open state.
190-
*/
191-
isMenuOpen?: boolean;
192-
/**
193-
* If true, closes the menu when an option is selected.
194-
*/
195-
closeMenuOnSelect?: boolean;
196-
/**
197-
* If true, the dropdown menu will be auto focused.
198-
*/
199-
autoFocus?: boolean;
200-
/**
201-
* If true, the dropdown will have a clear button.
202-
*/
203-
clearable?: boolean;
204-
/**
205-
* Callback fired when the dropdown loses focus.
206-
*/
207-
onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
208-
/**
209-
* Callback fired when the clear button is clicked.
210-
*/
211-
onClear?: () => void;
212-
/**
213-
* Callback fired when the dropdown gains focus.
214-
*/
215-
onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;
216-
/**
217-
* Callback fired when the dropdown input value changes.
218-
*/
219-
onInputChange?: (input: string | null) => void;
220-
/**
221-
* Callback fired when a key is pressed inside the dropdown.
222-
*/
223-
onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
224-
/**
225-
* Callback fired when the dropdown menu opens.
226-
*/
227-
onMenuOpen?: () => void;
228-
/**
229-
* Callback fired when the dropdown menu closes.
230-
*/
231-
onMenuClose?: () => void;
232-
/**
233-
* Callback fired when an option is selected.
234-
*/
235-
onOptionSelect?: (option: Item) => void;
236-
/**
237-
* Callback fired when scrolling inside the dropdown.
238-
*/
239-
onScroll?: (event: React.UIEvent<HTMLUListElement>) => void;
240-
/**
241-
* A function to customize the filtering of options.
242-
* It receives an option and the current input value, and should return true if the option should be included, false otherwise.
243-
*/
244-
filterOption?: (option: Item, inputValue: string) => boolean;
245-
/**
246-
* If false, selected options will be hidden from the list. Defaults to true.
247-
*/
248-
showSelectedOptions?: boolean;
249-
/**
250-
* The class name to be applied to the menu wrapper.
251-
*/
252-
menuWrapperClassName?: string;
253-
/**
254-
* If true, displays a loading indicator in the dropdown controls.
255-
*/
256-
loading?: boolean;
257-
} & BoxModeConstraint &
258-
(MultiSelectSpecifics<Item> | SingleSelectSpecifics<Item>);
94+
export type BaseDropdownProps<Item extends BaseListItemData<Record<string, unknown>>> = VibeComponentProps &
95+
BoxModeConstraint & {
96+
/**
97+
* The list of options available in the list.
98+
*/
99+
options: DropdownGroupOption<Item>;
100+
/**
101+
* Props to be passed to the Tooltip component that wraps the dropdown.
102+
*/
103+
tooltipProps?: Partial<TooltipProps>;
104+
/**
105+
* If true, displays dividers between grouped options.
106+
*/
107+
withGroupDivider?: boolean;
108+
/**
109+
* If true, makes the group title sticky.
110+
*/
111+
stickyGroupTitle?: boolean;
112+
/**
113+
* The size of the dropdown.
114+
*/
115+
size?: DropdownSizes;
116+
/**
117+
* The direction of the dropdown.
118+
*/
119+
dir?: DropdownDirection;
120+
/**
121+
* The function to call to render an option.
122+
*/
123+
optionRenderer?: (option: Item) => React.ReactNode;
124+
/**
125+
* The function to call to render the menu.
126+
*/
127+
menuRenderer?: (props: {
128+
children: React.ReactNode;
129+
filteredOptions: ListGroup<Item>[];
130+
selectedItems: Item[];
131+
getItemProps: (options: any) => Record<string, unknown>;
132+
}) => React.ReactNode;
133+
/**
134+
* The message to display when there are no options.
135+
*/
136+
noOptionsMessage?: string | React.ReactNode;
137+
/**
138+
* The placeholder to display when the dropdown is empty.
139+
*/
140+
placeholder?: string;
141+
/**
142+
* If true, the dropdown is disabled.
143+
*/
144+
disabled?: boolean;
145+
/**
146+
* If true, the dropdown is read only.
147+
*/
148+
readOnly?: boolean;
149+
/**
150+
* If true, the dropdown is in an error state.
151+
*/
152+
error?: boolean;
153+
/**
154+
* The helper text to display below the dropdown.
155+
*/
156+
helperText?: string;
157+
/**
158+
* If true, the dropdown is required.
159+
*/
160+
required?: boolean;
161+
/**
162+
* The label to display above the dropdown.
163+
*/
164+
label?: string;
165+
/**
166+
* The ARIA label for the dropdown.
167+
*/
168+
ariaLabel?: string;
169+
/**
170+
* The ARIA label for the dropdown input.
171+
*/
172+
inputAriaLabel?: string;
173+
/**
174+
* The ARIA label for the menu container.
175+
*/
176+
menuAriaLabel?: string;
177+
/**
178+
* The ARIA label for the clear button.
179+
*/
180+
clearAriaLabel?: string;
181+
/**
182+
* The current value of the input field.
183+
*/
184+
inputValue?: string;
185+
/**
186+
* The maximum height of the dropdown menu.
187+
*/
188+
maxMenuHeight?: number;
189+
/**
190+
* If true, controls the menu open state.
191+
*/
192+
isMenuOpen?: boolean;
193+
/**
194+
* If true, closes the menu when an option is selected.
195+
*/
196+
closeMenuOnSelect?: boolean;
197+
/**
198+
* If true, the dropdown menu will be auto focused.
199+
*/
200+
autoFocus?: boolean;
201+
/**
202+
* If true, the dropdown will have a clear button.
203+
*/
204+
clearable?: boolean;
205+
/**
206+
* Callback fired when the dropdown loses focus.
207+
*/
208+
onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
209+
/**
210+
* Callback fired when the clear button is clicked.
211+
*/
212+
onClear?: () => void;
213+
/**
214+
* Callback fired when the dropdown gains focus.
215+
*/
216+
onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;
217+
/**
218+
* Callback fired when the dropdown input value changes.
219+
*/
220+
onInputChange?: (input: string | null) => void;
221+
/**
222+
* Callback fired when a key is pressed inside the dropdown.
223+
*/
224+
onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
225+
/**
226+
* Callback fired when the dropdown menu opens.
227+
*/
228+
onMenuOpen?: () => void;
229+
/**
230+
* Callback fired when the dropdown menu closes.
231+
*/
232+
onMenuClose?: () => void;
233+
/**
234+
* Callback fired when an option is selected.
235+
*/
236+
onOptionSelect?: (option: Item) => void;
237+
/**
238+
* Callback fired when scrolling inside the dropdown.
239+
*/
240+
onScroll?: (event: React.UIEvent<HTMLUListElement>) => void;
241+
/**
242+
* A function to customize the filtering of options.
243+
* It receives an option and the current input value, and should return true if the option should be included, false otherwise.
244+
*/
245+
filterOption?: (option: Item, inputValue: string) => boolean;
246+
/**
247+
* If false, selected options will be hidden from the list. Defaults to true.
248+
*/
249+
showSelectedOptions?: boolean;
250+
/**
251+
* The class name to be applied to the menu wrapper.
252+
*/
253+
menuWrapperClassName?: string;
254+
/**
255+
* If true, displays a loading indicator in the dropdown controls.
256+
*/
257+
loading?: boolean;
258+
} & (MultiSelectSpecifics<Item> | SingleSelectSpecifics<Item>);
259259

260260
export type DropdownSizes = "small" | "medium" | "large";
261261

262262
export type DropdownDirection = "ltr" | "rtl" | "auto";
263263

264264
export type DropdownMultiControllerProps<Item extends BaseListItemData<Record<string, unknown>>> = Omit<
265265
BaseDropdownProps<Item>,
266-
keyof MultiSelectSpecifics<Item>
266+
keyof MultiSelectSpecifics<Item> | keyof BoxModeConstraint
267267
> &
268+
BoxModeConstraint &
268269
MultiSelectSpecifics<Item> & {
269270
dropdownRef: React.Ref<HTMLDivElement>;
270271
};
271272

272273
export type DropdownSingleControllerProps<Item extends BaseListItemData<Record<string, unknown>>> = Omit<
273274
BaseDropdownProps<Item>,
274-
keyof SingleSelectSpecifics<Item>
275+
keyof SingleSelectSpecifics<Item> | keyof BoxModeConstraint
275276
> &
277+
BoxModeConstraint &
276278
SingleSelectSpecifics<Item> & {
277279
dropdownRef: React.Ref<HTMLDivElement>;
278280
};

0 commit comments

Comments
 (0)