import React, { JSX } from 'react'; import { Model } from '@singularsystems/neo-core'; import { AxiosPromise } from 'axios'; import { DropDownBase, ICommonDropDownProps, IOption, ItemSource } from './DropDownBase'; import type { Props, SelectInstance } from 'react-select'; import { ICommonEditorProps } from '../PropTypes'; import { FormContext } from '../FormContext'; interface IAutoCompleteCommonProps extends ICommonEditorProps, Props, ICommonDropDownProps { /** * Callback for loading data. */ itemSource?: (searchValue: string) => (Promise | AxiosPromise); /** * Items to display for non async drop down, or default items to display in async drop down before typing. */ items?: ItemSource; valueMember?: NoInfer; displayMember?: NoInfer; /** * Function used to filter items out of the datasource. * **Note:** this will only apply to the `items` prop. */ filterPredicate?: (item: TChild, itemParent?: T) => boolean; /** * Function used to filter items based on what the user has typed. * Applies after `filterPredicate`, and is ignored if `itemSource` is specified. * Use if you are displaying multiple columns and need to match on any of the columns. */ inputFilter?: (input: string, item: TChild, parent?: T) => boolean; /** * Property of an item to use as the description. * * Description will be shown in muted text below the item name. */ descriptionMember?: NoInfer | false; /** * Callback used to provide a custom option component instead of displaying the display member value. */ option?: (item: T | TChild) => JSX.Element; /** * Text to display when the user has typed something, but no records were returned. */ noRecordsPrompt?: string; /** * Text to display when the user clicks in the text area, and no search value has been entered. */ typeToSearchPrompt?: string; /** * Callback which fires when an item is selected. * The removedItem parameter will be provided when removing an item from a multi select drop down. * The addedItem parameter will be provided when an item is selected in a multi select drop down. This is the item stored in the bindItems list. */ onItemSelected?: (item?: TChild, removedItem?: Model.ISelectedItem, addedItem?: Model.ISelectedItem, parent?: T) => void; /** * Millisecond delay from the last typed character, to when the itemSource function is called. * Default is 500ms. */ delayMs?: number; /** * Minimum no of characters a user must type before a search is performed. * Default is 1. */ minCharacters?: number; } export interface IAutoCompleteProps extends IAutoCompleteCommonProps { bind: Model.IPropertyInstance; bindDisplay?: Model.IPropertyInstance; } export interface IAutoCompleteMultiSelectProps extends IAutoCompleteCommonProps { /** * A list of ids and labels to use as the selected list. */ bindItems: Model.IPropertyInstance; /** * Optional list of ids. This will be kept in sync with the bindItems prop. */ bindIds?: (string | number)[] | Model.IPropertyInstance<(string | number)[]>; /** * The max no of items to record in the field info if bound to a field info class. (Defaults to 5) * If the selected items exceeds this limit, the field info will be recorded as "x items selected". */ fieldInfoLimit?: number; } export default class AutoCompleteDropDown extends DropDownBase | IAutoCompleteMultiSelectProps> { static contextType: React.Context; context: React.ContextType; private asyncSelectImplementation; private selectImplementation; constructor(props: IAutoCompleteProps | IAutoCompleteMultiSelectProps); private bindProperty; private bindIdsList?; private bindIdsProperty?; static getBindProp(props: IAutoCompleteProps | IAutoCompleteMultiSelectProps): Model.IPropertyInstance; protected get commonProps(): ICommonDropDownProps; private onKeyPress; private setBindProperty; private onItemSelected; render(): string | number | bigint | boolean | Iterable | Promise> | Iterable | null | undefined> | JSX.Element | null | undefined; private getOption; } export {};