import type { StyleProp, ViewStyle } from 'react-native'; import type { DataModel } from '../../chat'; import type { ListItemActions, ListItemProps, ListItemRequestProps, ListRequestProps, PropsWithCancel, PropsWithError, PropsWithTest, SearchType, } from '../types'; /** * List Search Component model. */ export type DefaultComponentModel = DataModel; /** * List Search Item Component. */ export type ListSearchItemComponent< ComponentModel extends DefaultComponentModel = DefaultComponentModel, > = React.FC>; /** * List Search Item Component properties. */ export type ListSearchItemProps< ComponentModel extends DefaultComponentModel = DefaultComponentModel, > = ListItemProps & ListItemRequestProps & Omit< ListItemActions, 'onToRightSlide' | 'onToLeftSlide' | 'onLongPressed' > & { /** * Data model. The data model is generic. For example: `GroupSearchModel`, `ContactSearchModel`, `ConversationSearchModel` etc. */ data: ComponentModel; /** * Search keyword. */ keyword: string; /** * Search type. */ searchType: SearchType; }; /** * List Search Component properties. */ export type ListSearchProps< ComponentModel extends DefaultComponentModel = DefaultComponentModel, > = ListRequestProps & PropsWithTest & PropsWithError & PropsWithCancel & Omit< ListItemActions, 'onToRightSlide' | 'onToLeftSlide' | 'onLongPressed' > & { /** * Container style for the list search component. */ containerStyle?: StyleProp; /** * Search type. */ searchType: SearchType; /** * Initial data. */ initData?: | ReadonlyArray | (() => Promise>) | (() => ReadonlyArray); /** * Callback notification when the search keyword changes. */ onSearch?: | ((keyword: string) => Promise>) | ((keyword: string) => ReadonlyArray); /** * @description Custom item rendering. * * It is automatically wrapped using `React.memo` technology. */ ItemRender?: ListSearchItemComponent; }; /** * List Search Component. */ export type UseListSearchProps< ComponentModel extends DefaultComponentModel = DefaultComponentModel, > = ListSearchProps;