UNPKG

@availity/mui-autocomplete

Version:

Availity MUI Autocomplete Component - part of the @availity/element design system

140 lines (132 loc) 8.48 kB
import { AutocompleteProps as AutocompleteProps$1 } from '@mui/material/Autocomplete'; export { createFilterOptions } from '@mui/material/Autocomplete'; import { ChipTypeMap } from '@mui/material/Chip'; import { TextFieldProps } from '@availity/mui-textfield'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { UseInfiniteQueryOptions } from '@tanstack/react-query'; import { ApiConfig } from '@availity/api-axios'; interface AutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<AutocompleteProps$1<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'clearIcon' | 'clearText' | 'closeText' | 'componentsProps' | 'disabledItemsFocusable' | 'forcePopupIcon' | 'fullWidth' | 'handleHomeEndKeys' | 'includeInputInList' | 'openOnFocus' | 'openText' | 'PaperComponent' | 'PopperComponent' | 'popupIcon' | 'selectOnFocus' | 'size' | 'renderInput' | 'slotProps'> { /** Props applied to the `TextField` component */ FieldProps?: TextFieldProps; name?: string; } declare const Autocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ FieldProps, ...props }: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => JSX.Element; interface AsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<AutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'options' | 'disableListWrap' | 'loading'> { /** Function that is called to fetch the options for the list. Returns a promise with options, hasMore, and offset */ loadOptions: (offset: number, limit: number, inputValue?: string) => Promise<{ options: Option[]; hasMore: boolean; offset: number; }>; /** The key used by @tanstack/react-query to cache the response */ queryKey: string; /** The number of options to request from the api * @default 50 */ limit?: number; /** Config options for the useInfiniteQuery hook */ queryOptions?: UseInfiniteQueryOptions<{ options: Option[]; hasMore: boolean; offset: number; }>; /** Object of parameters used for the cacheKey. Options are re-refetched when a value in the object changes */ watchParams?: Record<string, unknown>; /** Time to wait before searching with the input value typed into the component */ debounceTimeout?: number; } declare const AsyncAutocomplete: <Option, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ loadOptions, limit, queryKey, ListboxProps, queryOptions, watchParams, debounceTimeout, FieldProps, onInputChange, ...rest }: AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element; type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>; type Code = { code: string; value: string; }; declare const fetchCodes: (config: ApiConfig) => Promise<{ options: Code[]; hasMore: boolean; offset: any; }>; interface CodesAutocompleteProps<Option = Code, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> { /** The code list id. */ list: string; /** Config passed to the AvCodesApi.query function */ apiConfig?: ApiConfig; } declare const handleGetCodesOptionLabel: (option: Code) => string; declare const CodesAutocomplete: <Option = Code, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: CodesAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element; type Organization = { customerId: string; name: string; id: string; createDate: string; links: Record<string, Record<string, string>>; }; declare const fetchOrgs: (config: ApiConfig) => Promise<{ options: Organization[]; hasMore: boolean; offset: number; }>; interface OrgAutocompleteProps<Option = Organization, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> { /** Axios ApiConfig */ apiConfig?: ApiConfig; } declare const handleGetOrgOptionLabel: (org: Organization) => string; declare const OrganizationAutocomplete: <Option = Organization, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, queryKey, ...rest }: OrgAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element; type Provider = { id: string; businessName: string; uiDisplayName: string; lastName?: string; firstName?: string; payerAssignedIdentifiers?: { payerId: string; identifier: string; }[]; atypical: boolean; npi: string; customerIds: string[]; roles: { code: string; value: string; }[]; primaryPhone: { internationalCellularCode: string; areaCode: string; phoneNumber: string; }; primaryFax: { internationalCellularCode: string; areaCode: string; phoneNumber: string; }; taxId?: string; ssn?: string; primaryAddress: { line1: string; line2: string; city: string; state: string; stateCode: string; zip: { code: string; addon: string; }; }; primarySpecialty?: { code: string; value: string; }; }; declare const fetchProviders: (customerId: string, config: ApiConfig) => Promise<{ options: Provider[]; hasMore: boolean; offset: number; }>; interface ProviderAutocompleteProps<Option = Provider, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> { /** Customer ID of the Organization you are requesting the providers for */ customerId: string; /** Config passed to the AvProvidersApi.getProviders function */ apiConfig?: ApiConfig; } declare const handleGetProviderOptionLabel: (option: Provider) => string; declare const ProviderAutocomplete: <Option = Provider, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, customerId, queryKey, ...rest }: ProviderAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element; export { AsyncAutocomplete, type AsyncAutocompleteProps, Autocomplete, type AutocompleteProps, type Code, CodesAutocomplete, type CodesAutocompleteProps, type OrgAutocompleteProps, type Organization, OrganizationAutocomplete, type Provider, ProviderAutocomplete, type ProviderAutocompleteProps, fetchCodes, fetchOrgs, fetchProviders, handleGetCodesOptionLabel, handleGetOrgOptionLabel, handleGetProviderOptionLabel };