Skip to content

Commit

Permalink
fix: export types for Autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGhadyani-Okta committed Apr 17, 2023
1 parent dbb1210 commit a3585cc
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/odyssey-react-mui/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ import { memo, useCallback } from "react";

import { Field } from "./Field";

declare module "react" {
// augment React types
function memo<A, B>(
Component: (props: A) => B
): (props: A) => ReactElement | null;
// return type is same as ReturnType<ExoticComponent<any>>
}

export type AutocompleteProps<OptionType> = {
isDisabled?: boolean;
hint?: string;
label: string;
onChange?: MuiAutocompleteProps<OptionType, undefined, undefined, undefined>;
options: OptionType[];
value?: OptionType | null;
onChange?: MuiAutocompleteProps<OptionType, false, false, false>["onChange"];
options: MuiAutocompleteProps<OptionType, false, false, false>["options"];
value?: MuiAutocompleteProps<OptionType, false, false, false>["value"];
};

// <TextField
// {...params}
// endAdornment={params.InputProps.endAdornment}
// hint={hint}
// label={label}
// ref={params.InputProps.ref}
// startAdornment={params.InputProps.startAdornment}
// />

const Autocomplete = <OptionType,>({
isDisabled,
hint,
Expand All @@ -50,7 +49,6 @@ const Autocomplete = <OptionType,>({
<Field
hasVisibleLabel
hint={hint}
// id={params.InputLabelProps.id} // Pretty sure this is unnecessary -Kevin
label={label}
renderFieldComponent={({ ariaDescribedBy, id }) => (
<InputBase
Expand All @@ -68,8 +66,6 @@ const Autocomplete = <OptionType,>({
return (
<MuiAutocomplete
disabled={isDisabled}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore TEMP */ // PLEASE REMOVE once we figure out the correct type.
onChange={onChange}
options={options}
renderInput={renderInput}
Expand All @@ -78,6 +74,6 @@ const Autocomplete = <OptionType,>({
);
};

const MemoizedAutocomplete = memo(Autocomplete);
const MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;

export { MemoizedAutocomplete as Autocomplete };

0 comments on commit a3585cc

Please sign in to comment.