import { ICalloutProps } from 'office-ui-fabric-react/lib/Callout'; import { IStyle } from '@uifabric/styling'; import { IFloatingSuggestionItemProps, IFloatingSuggestionOnRenderItemProps, IFloatingSuggestionItem, } from './FloatingSuggestionsItem/FloatingSuggestionsItem.types'; import { IRenderFunction, IRefObject } from '@uifabric/utilities'; /** * FloatingSuggestions component props * Type T is option data parameter to render custom suggestions */ export interface IBaseFloatingSuggestionsProps { /** * Component reference in case needed to focus FloatingSuggestions */ componentRef?: IRefObject; /** * List of suggestions to be displayed with Type T */ suggestions: IFloatingSuggestionItem[]; /** * This param decides whether to display suggestions or not * Must be set by parent component */ isSuggestionsVisible: boolean; /** * Custom component to render suggestion */ onRenderSuggestion?: (renderProps: IFloatingSuggestionOnRenderItemProps) => JSX.Element; /** * Callback function on remove of suggestion from list */ onRemoveSuggestion?: (ev: React.MouseEvent, item: IFloatingSuggestionItemProps) => void; /** * Callback function on selection of suggestion from list */ onSuggestionSelected?: (ev: React.MouseEvent, item: IFloatingSuggestionItemProps) => void; /** * Custom header renderer which takes suggestions and headertext if passed * Going forward, this should accept the user defined type as parameter */ onRenderHeader?: (suggestionItems?: IFloatingSuggestionItemProps[], suggestionsHeaderText?: string) => JSX.Element; /** * Custom footer renderer which takes suggestions as param * Going forward, this should accept the user defined type as param */ onRenderFooter?: (suggestionItems?: IFloatingSuggestionItemProps[]) => JSX.Element; /** * Callback when the callout dismiss is called * When this callback is called parent comoponent must handle suggestion visibility */ onFloatingSuggestionsDismiss?: (ev?: React.MouseEvent) => void; /** * Option to show suggestion remove button * By default this is false */ showSuggestionRemoveButton?: boolean; /** * class name for the FloatingSuggestions div */ className?: string; /** * Target element here callout should be mounted * Pass the element current value to position the callout */ targetElement: HTMLInputElement | undefined | null; /** * Callout width */ calloutWidth?: number; /** * Callout props */ calloutProps?: ICalloutProps; /** * Class name for suggestion list container */ suggestionListClassName?: string; /** * Clas name for Suggestion item */ suggestionsItemClassName?: string; /** * Header text to display */ suggestionsHeaderText?: string; /** * Custom renderer when there are no results found */ onRenderNoResultFound?: IRenderFunction; /** * Text to display when there are no results found */ noResultsFoundText?: string; /** * Maximum suggestions to how * Might not be used as showing suggestion must be by sending the suggestions */ maximumSuggestionsToShow?: number; /** * Aria label for suggestions container */ suggestionsContainerAriaLabel?: string; /** * Aria label for suggestions list container */ suggestionListAriaLabel?: string; /** * Aria label for suggestion remove button */ removeItemButtonAriaLabel?: string; /** * Index to indicate the selected suggestion * This logic must be driven by parent component by setting isSelected in data model * There should be no logic to handle this in Suggestion component as the focus is never on this component */ selectedSuggestionIndex?: number; /** * Arrow key callback */ onKeyDown?: (ev: React.KeyboardEvent) => void; } /** * FLoatingSuggestions style props */ export interface IBaseFloatingSuggestionsStylesProps {} /** * FLoatingSuggestions styles */ export interface IBaseFloatingSuggestionsStyles { root: IStyle; callout: IStyle; }