-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31065 from VickyStash/ts-migration/autoCompleteSu…
…ggestions-component [TS migration] Migrate 'AutoCompleteSuggestions' component to TypeScript
- Loading branch information
Showing
6 changed files
with
76 additions
and
85 deletions.
There are no files selected for viewing
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
36 changes: 0 additions & 36 deletions
36
src/components/AutoCompleteSuggestions/autoCompleteSuggestionsPropTypes.js
This file was deleted.
Oops, something went wrong.
7 changes: 3 additions & 4 deletions
7
...s/AutoCompleteSuggestions/index.native.js → .../AutoCompleteSuggestions/index.native.tsx
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,18 +1,17 @@ | ||
import {Portal} from '@gorhom/portal'; | ||
import React from 'react'; | ||
import {propTypes} from './autoCompleteSuggestionsPropTypes'; | ||
import BaseAutoCompleteSuggestions from './BaseAutoCompleteSuggestions'; | ||
import type {AutoCompleteSuggestionsProps} from './types'; | ||
|
||
function AutoCompleteSuggestions({measureParentContainer, ...props}) { | ||
function AutoCompleteSuggestions<TSuggestion>({measureParentContainer, ...props}: AutoCompleteSuggestionsProps<TSuggestion>) { | ||
return ( | ||
<Portal hostName="suggestions"> | ||
{/* eslint-disable-next-line react/jsx-props-no-spreading */} | ||
<BaseAutoCompleteSuggestions {...props} /> | ||
<BaseAutoCompleteSuggestions<TSuggestion> {...props} /> | ||
</Portal> | ||
); | ||
} | ||
|
||
AutoCompleteSuggestions.propTypes = propTypes; | ||
AutoCompleteSuggestions.displayName = 'AutoCompleteSuggestions'; | ||
|
||
export default AutoCompleteSuggestions; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {ReactElement} from 'react'; | ||
|
||
type MeasureParentContainerCallback = (x: number, y: number, width: number) => void; | ||
|
||
type RenderSuggestionMenuItemProps<TSuggestion> = { | ||
item: TSuggestion; | ||
index: number; | ||
}; | ||
|
||
type AutoCompleteSuggestionsProps<TSuggestion> = { | ||
/** Array of suggestions */ | ||
suggestions: TSuggestion[]; | ||
|
||
/** Function used to render each suggestion, returned JSX will be enclosed inside a Pressable component */ | ||
renderSuggestionMenuItem: (item: TSuggestion, index: number) => ReactElement; | ||
|
||
/** Create unique keys for each suggestion item */ | ||
keyExtractor: (item: TSuggestion, index: number) => string; | ||
|
||
/** The index of the highlighted suggestion */ | ||
highlightedSuggestionIndex: number; | ||
|
||
/** Fired when the user selects a suggestion */ | ||
onSelect: (index: number) => void; | ||
|
||
/** Show that we can use large auto-complete suggestion picker. | ||
* Depending on available space and whether the input is expanded, we can have a small or large mention suggester. | ||
* When this value is false, the suggester will have a height of 2.5 items. When this value is true, the height can be up to 5 items. */ | ||
isSuggestionPickerLarge: boolean; | ||
|
||
/** create accessibility label for each item */ | ||
accessibilityLabelExtractor: (item: TSuggestion, index: number) => string; | ||
|
||
/** Meaures the parent container's position and dimensions. */ | ||
measureParentContainer?: (callback: MeasureParentContainerCallback) => void; | ||
}; | ||
|
||
export type {AutoCompleteSuggestionsProps, RenderSuggestionMenuItemProps}; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {ForwardedRef} from 'react'; | ||
import {View} from 'react-native'; | ||
|
||
const viewForwardedRef = (ref: ForwardedRef<View | HTMLDivElement>) => ref as ForwardedRef<View>; | ||
|
||
export default viewForwardedRef; |