import React from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import type { IconName } from '../Icon'; import { renderSuffix } from './utils'; import { StyledBadge, StyledSuffixContainer } from './StyledSearch'; import type { BadgeProps } from '../Badge'; interface SearchSuffixIconProps { /** * Name of Icon or ReactElement to render on the right side of the input. */ suffix?: IconName | React.ReactElement; /** * Additional wrapper style. */ style?: StyleProp; /** * Testing id of the component. */ testID?: string; /** * Badge props to be render on the suffix. */ badge?: Omit; } const renderBadge = (props: Omit) => { const { content, icon, ...rest } = props; if (content) return ( ); if (icon) return ; return null; }; const SearchSuffixIcon = (props: SearchSuffixIconProps) => { const { suffix, testID, style, badge } = props; return ( {!!badge && renderBadge(badge)} {renderSuffix({ suffix })} ); }; export default SearchSuffixIcon;