UNPKG

@cmk/fe_utils

Version:
28 lines (26 loc) 1.9 kB
import { Ref, SyntheticEvent, ReactNode, KeyboardEvent } from 'react'; import { AutocompleteProps } from '@mui/material'; import { GenericInputFieldProps } from './types'; import { CTextFieldProps } from './TextField'; export type DefaultGenericValueType = { value: string | number | boolean; label: ReactNode; textLabel: string; }; export type CustomAutocompleteProps<ValueType = DefaultGenericValueType, IsFreeSolo extends boolean = false> = { onInputChange?: (newValue: string, e: SyntheticEvent<Element, Event>) => void; onChange?: (newValue: string, e: SyntheticEvent<Element, Event>) => void; loading?: boolean; options: ValueType[]; onKeyUp?: (e: KeyboardEvent<HTMLInputElement>) => void; value: string; renderInput?: AutocompleteProps<ValueType, false, false, IsFreeSolo>['renderInput']; slotProps?: AutocompleteProps<ValueType, false, false, IsFreeSolo>['slotProps'] & CTextFieldProps['slotProps'] & {}; enableVirtualization?: boolean; }; export type SpecificMuiAutoCompleteProps<ValueType = DefaultGenericValueType, IsFreeSolo extends boolean = false> = Omit<AutocompleteProps<ValueType, false, false, IsFreeSolo>, keyof CTextFieldProps | keyof CustomAutocompleteProps>; export type SpecificMuiTextFieldProps = Omit<CTextFieldProps, ('autoComplete' | 'defaultValue') | keyof CustomAutocompleteProps>; export type CAutoCompleteProps<ValueType = DefaultGenericValueType, IsFreeSolo extends boolean = false> = GenericInputFieldProps<'autocomplete'> & SpecificMuiTextFieldProps & SpecificMuiAutoCompleteProps<ValueType, IsFreeSolo> & CustomAutocompleteProps<ValueType, IsFreeSolo> & { ref?: Ref<HTMLInputElement>; }; export declare const CAutoComplete: <ValueType extends DefaultGenericValueType = DefaultGenericValueType, IsFreeSolo extends boolean = false>(props: CAutoCompleteProps<ValueType>) => import("react/jsx-runtime").JSX.Element;