From fe3c7bde8e5b8725a06a4578e4e5719a9946f458 Mon Sep 17 00:00:00 2001 From: oddvernes Date: Thu, 13 Jun 2024 12:44:19 +0200 Subject: [PATCH] Revert changes from #3408 --- .../components/Autocomplete/Autocomplete.tsx | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx b/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx index 0393780c7e..0e2ff5a23a 100644 --- a/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx +++ b/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx @@ -223,29 +223,6 @@ const handleListFocus = (e: FocusEvent) => { const defaultOptionDisabled = () => false // MARK: types -// prettier-ignore -type OptionLabelProps = T extends string | number - ? { - /** Custom option label */ - optionLabel?: (option: T) => string - /** Disable option - * @default () => false - */ - optionDisabled?: (option: T) => boolean - /** List of options in dropdown */ - options: (string | number)[] - } - : { - /** Custom option label */ - optionLabel: (option: T) => string - /** Disable option - * @default () => false - */ - optionDisabled?: (option: T) => boolean - /** List of options in dropdown */ - options: T[] - } - export type AutocompleteChanges = { selectedItems: T[] } export type AutocompleteProps = { @@ -302,12 +279,18 @@ export type AutocompleteProps = { multiple?: boolean /** Add select-all option. Throws an error if true while multiple = false */ allowSelectAll?: boolean + /** Custom option label. NOTE: This is required when option is an object */ + optionLabel?: (option: T) => string /** Custom option template */ optionComponent?: (option: T, isSelected: boolean) => ReactNode /** Disable use of react portal for dropdown * @deprecated Autocomplete now uses the native popover api to render the dropdown. This prop will be removed in a future version */ disablePortal?: boolean + /** Disable option + * @default () => false + */ + optionDisabled?: (option: T) => boolean /** Custom filter function for options */ optionsFilter?: (option: T, inputValue: string) => boolean /** If `true` the width of the dropdown will adjust to the width of the input */ @@ -330,8 +313,7 @@ export type AutocompleteProps = { * Method that is used to compare objects by value. If omitted, objects are matched by reference. */ itemCompare?: (value: T, compare: T) => boolean -} & HTMLAttributes & - OptionLabelProps +} & HTMLAttributes // MARK: component function AutocompleteInner(