From cd1a0a7fdd982fc6a3b4b3120759c48af9e4f7b3 Mon Sep 17 00:00:00 2001 From: Hans Aarne Liblik Date: Mon, 27 Feb 2023 08:42:05 +0200 Subject: [PATCH 1/6] Add generic option type --- src/behaviors/async.tsx | 8 +-- src/behaviors/item.tsx | 4 +- src/behaviors/token.tsx | 10 +-- src/components/MenuItem/MenuItem.stories.tsx | 3 +- src/components/Token/Token.stories.tsx | 3 +- src/components/Token/Token.tsx | 7 +- .../Typeahead/Typeahead.stories.tsx | 11 ++-- src/components/Typeahead/Typeahead.test.tsx | 12 ++-- src/components/Typeahead/Typeahead.tsx | 64 +++++++++++-------- .../TypeaheadInputMulti.stories.tsx | 3 +- .../TypeaheadInputMulti.tsx | 8 +-- .../TypeaheadMenu/TypeaheadMenu.stories.tsx | 4 +- .../TypeaheadMenu/TypeaheadMenu.tsx | 16 ++--- src/core/Context.tsx | 10 +-- src/core/Typeahead.tsx | 17 +++-- src/core/TypeaheadManager.tsx | 12 ++-- src/tests/data.ts | 4 +- src/types.ts | 58 ++++++++--------- src/utils/addCustomOption.ts | 6 +- src/utils/defaultFilterBy.ts | 6 +- src/utils/getHintText.ts | 6 +- src/utils/getInputText.ts | 6 +- src/utils/getIsOnlyResult.ts | 4 +- src/utils/getOptionLabel.ts | 4 +- src/utils/getOptionProperty.ts | 4 +- src/utils/getStringLabelKey.ts | 3 +- src/utils/getTruncatedOptions.ts | 4 +- src/utils/getUpdatedActiveIndex.ts | 8 +-- src/utils/validateSelectedPropChange.ts | 6 +- 29 files changed, 166 insertions(+), 145 deletions(-) diff --git a/src/behaviors/async.tsx b/src/behaviors/async.tsx index cb061621..e5dfb240 100644 --- a/src/behaviors/async.tsx +++ b/src/behaviors/async.tsx @@ -18,7 +18,7 @@ import { optionType } from '../propTypes'; import { getDisplayName, isFunction, warn } from '../utils'; import { TypeaheadComponentProps } from '../components/Typeahead'; -import type { Option } from '../types'; +import type { OptionType } from '../types'; const propTypes = { /** @@ -57,7 +57,7 @@ const propTypes = { useCache: PropTypes.bool, }; -export interface UseAsyncProps extends TypeaheadComponentProps { +export interface UseAsyncProps