-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix types and add example for renderOption
- Loading branch information
Showing
3 changed files
with
155 additions
and
25 deletions.
There are no files selected for viewing
20 changes: 18 additions & 2 deletions
20
packages/react-ui/src/components/molecules/Autocomplete.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
import { ChipTypeMap } from '@mui/material'; | ||
import { AutocompleteProps as MuiAutocompleteProps } from '@mui/material/Autocomplete'; | ||
|
||
export type AutocompleteProps = MuiAutocompleteProps & { | ||
// Boilerplate to avoid Typescript error with generic types: we must repeat all original typings in declaration, so variants like multiple/freesolo, etc. have proper typings | ||
export type AutocompleteProps< | ||
Value, | ||
Multiple extends boolean | undefined, | ||
DisableClearable extends boolean | undefined, | ||
FreeSolo extends boolean | undefined, | ||
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'] | ||
> = MuiAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> & { | ||
creatable?: boolean; | ||
}; | ||
|
||
declare const Autocomplete: (props: AutocompleteProps) => JSX.Element; | ||
declare const Autocomplete: < | ||
Value, | ||
Multiple extends boolean | undefined, | ||
DisableClearable extends boolean | undefined, | ||
FreeSolo extends boolean | undefined, | ||
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'] | ||
>( | ||
props: AutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> | ||
) => JSX.Element; | ||
export default Autocomplete; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters