Skip to content

Commit

Permalink
Rename Value to AutocompleteValue
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Jul 28, 2021
1 parent a370d1e commit 82e8239
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function createFilterOptions<T>(

export type AutocompleteFreeSoloValueMapping<FreeSolo> = FreeSolo extends true ? string : never;

export type Value<T, Multiple, DisableClearable, FreeSolo> = Multiple extends undefined | false
export type AutocompleteValue<T, Multiple, DisableClearable, FreeSolo> = Multiple extends
| undefined
| false
? DisableClearable extends true
? NonNullable<T | AutocompleteFreeSoloValueMapping<FreeSolo>>
: T | null | AutocompleteFreeSoloValueMapping<FreeSolo>
Expand Down Expand Up @@ -246,12 +248,12 @@ export interface UseAutocompleteProps<
* The value must have reference equality with the option in order to be selected.
* You can customize the equality behavior with the `isOptionEqualToValue` prop.
*/
value?: Value<T, Multiple, DisableClearable, FreeSolo>;
value?: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>;
/**
* The default value. Use when the component is not controlled.
* @default props.multiple ? [] : null
*/
defaultValue?: Value<T, Multiple, DisableClearable, FreeSolo>;
defaultValue?: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>;
/**
* Callback fired when the value changes.
*
Expand All @@ -262,7 +264,7 @@ export interface UseAutocompleteProps<
*/
onChange?: (
event: React.SyntheticEvent,
value: Value<T, Multiple, DisableClearable, FreeSolo>,
value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>,
reason: AutocompleteChangeReason,
details?: AutocompleteChangeDetails<T>,
) => void;
Expand Down Expand Up @@ -320,7 +322,7 @@ export default function useAutocomplete<
}) => React.HTMLAttributes<HTMLLIElement>;
id: string;
inputValue: string;
value: Value<T, Multiple, DisableClearable, FreeSolo>;
value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>;
dirty: boolean;
popupOpen: boolean;
focused: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export {
AutocompleteGroupedOption,
AutocompleteHighlightChangeReason,
AutocompleteInputChangeReason,
AutocompleteValue as Value,
createFilterOptions,
CreateFilterOptionsConfig,
FilterOptionsState,
UseAutocompleteProps,
Value,
} from '@material-ui/unstyled';

0 comments on commit 82e8239

Please sign in to comment.