import { IconComponent, IconPropSize } from '@consta/icons/Icon'; import React from 'react'; import { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes'; import { PropForm, PropSize, PropStatus, PropView, RenderItemProps } from '../SelectComponentsDeprecated/types'; import { TextFieldPropOnChange } from '../TextField'; export type DefaultItem = { label: string; id: string | number; groupId?: string | number; disabled?: boolean; }; export type DefaultGroup = { label: string; id: string | number; }; type RenderValueProps = { item: ITEM; handleRemove?: (e: React.SyntheticEvent) => void; }; export type PropGetItemLabel = (item: ITEM) => string; export type PropGetItemKey = (item: ITEM) => string | number; export type PropGetItemGroupKey = (item: ITEM) => string | number | undefined; export type PropGetItemDisabled = (item: ITEM) => boolean | undefined; export type PropGetGroupKey = (group: GROUP) => string | number; export type PropGetGroupLabel = (group: GROUP) => string; type PropSearchFunction = (item: ITEM, searchValue: string) => boolean; type PropOnChange = (props: { value: (MULTIPLE extends true ? ITEM[] : ITEM) | null; e: React.SyntheticEvent; }) => void; type PropValue = (MULTIPLE extends true ? ITEM[] : ITEM) | null | undefined; export type PropRenderItem = (props: RenderItemProps) => React.ReactNode | null; export type PropRenderValue = (props: RenderValueProps) => React.ReactNode | null; export type ComboboxProps = PropsWithHTMLAttributesAndRef<{ items: ITEM[]; onChange: PropOnChange; disabled?: boolean; form?: PropForm; dropdownForm?: 'default' | 'brick' | 'round'; size?: PropSize; view?: PropView; placeholder?: string; ariaLabel?: string; status?: PropStatus; isLoading?: boolean; dropdownClassName?: string; dropdownRef?: React.Ref; name?: string; renderItem?: PropRenderItem; renderValue?: PropRenderValue; onFocus?: React.FocusEventHandler; onBlur?: React.FocusEventHandler; onCreate?: (props: { e: React.SyntheticEvent; label: string; }) => void; inputRef?: React.Ref; labelForNotFound?: string; required?: boolean; labelForCreate?: string; labelForEmptyItems?: string; searchFunction?: PropSearchFunction; searchValue?: string; multiple?: MULTIPLE; value?: PropValue; groups?: GROUP[]; onInputChange?: TextFieldPropOnChange; getItemLabel?: PropGetItemLabel; getItemKey?: PropGetItemKey; getItemGroupKey?: PropGetItemGroupKey; getItemDisabled?: PropGetItemDisabled; getGroupLabel?: PropGetGroupLabel; getGroupKey?: PropGetGroupKey; label?: string; labelIcon?: IconComponent; caption?: string; labelPosition?: 'top' | 'left'; }, HTMLDivElement> & (MULTIPLE extends true ? { selectAll?: boolean; } : { selectAll?: never; }) & (ITEM extends { label: DefaultItem['label']; } ? {} : { getItemLabel: PropGetItemLabel; }) & (ITEM extends { id: DefaultItem['id']; } ? {} : { getItemKey: PropGetItemKey; }) & (GROUP extends { label: DefaultGroup['label']; } ? {} : { getGroupLabel: PropGetGroupLabel; }) & (GROUP extends { id: DefaultGroup['id']; } ? {} : { getGroupKey: PropGetGroupKey; }); export type ComboboxComponent = (props: ComboboxProps) => React.ReactNode | null; export declare const defaultGetItemKey: PropGetItemKey; export declare const defaultGetItemLabel: PropGetItemLabel; export declare const defaultGetItemGroupKey: PropGetItemGroupKey; export declare const defaultGetItemDisabled: PropGetItemDisabled; export declare const defaultGetGroupKey: PropGetGroupKey; export declare const defaultGetGroupLabel: PropGetGroupLabel; export declare const isMultipleParams: (params: ComboboxProps) => params is ComboboxProps; export declare const isNotMultipleParams: (params: ComboboxProps) => params is ComboboxProps; export declare function withDefaultGetters(props: ComboboxProps): { items: ITEM[]; onChange: PropOnChange; disabled?: boolean; form?: PropForm; dropdownForm?: "default" | "brick" | "round"; size?: PropSize; view?: PropView; placeholder?: string; ariaLabel?: string; status?: PropStatus; isLoading?: boolean; dropdownClassName?: string; dropdownRef?: React.Ref; name?: string; renderItem?: PropRenderItem | undefined; renderValue?: PropRenderValue | undefined; onFocus?: React.FocusEventHandler; onBlur?: React.FocusEventHandler; onCreate?: (props: { e: React.SyntheticEvent; label: string; }) => void; inputRef?: React.Ref; labelForNotFound?: string; required?: boolean; labelForCreate?: string; labelForEmptyItems?: string; searchFunction?: PropSearchFunction | undefined; searchValue?: string; multiple?: MULTIPLE | undefined; value?: PropValue; groups?: GROUP[] | undefined; onInputChange?: TextFieldPropOnChange; getItemLabel?: PropGetItemLabel | undefined; getItemKey?: PropGetItemKey | undefined; getItemGroupKey?: PropGetItemGroupKey | undefined; getItemDisabled?: PropGetItemDisabled | undefined; getGroupLabel?: PropGetGroupLabel | undefined; getGroupKey?: PropGetGroupKey | undefined; label?: string; labelIcon?: IconComponent; caption?: string; labelPosition?: "top" | "left"; } & Omit, "css" | "onFocus" | "onBlur" | "onChange" | "size" | "view" | "form" | "status" | "caption" | "label" | "name" | "disabled" | "value" | "multiple" | "placeholder" | "required" | "inputRef" | "items" | "dropdownForm" | "ariaLabel" | "dropdownClassName" | "dropdownRef" | "isLoading" | "labelForEmptyItems" | "renderItem" | "renderValue" | "groups" | "getItemLabel" | "getItemKey" | "getItemGroupKey" | "getItemDisabled" | "getGroupLabel" | "getGroupKey" | "labelIcon" | "labelPosition" | "labelForCreate" | "searchFunction" | "searchValue" | "labelForNotFound" | "onInputChange" | "onCreate"> & React.RefAttributes & (MULTIPLE extends true ? { selectAll?: boolean; } : { selectAll?: never; }) & (ITEM extends { label: DefaultItem["label"]; } ? {} : { getItemLabel: PropGetItemLabel; }) & (ITEM extends { id: DefaultItem["id"]; } ? {} : { getItemKey: PropGetItemKey; }) & (GROUP extends { label: DefaultGroup["label"]; } ? {} : { getGroupLabel: PropGetGroupLabel; }) & (GROUP extends { id: DefaultGroup["id"]; } ? {} : { getGroupKey: PropGetGroupKey; }) & { getItemLabel: PropGetItemLabel | PropGetItemLabel; getItemKey: PropGetItemKey | PropGetItemKey; getItemGroupKey: PropGetItemGroupKey | PropGetItemGroupKey; getItemDisabled: PropGetItemDisabled | PropGetItemDisabled; getGroupLabel: PropGetGroupLabel | PropGetGroupLabel; getGroupKey: PropGetGroupKey | PropGetGroupKey; }; export declare const clearSizeMap: Record; export declare const iconSizeMap: Record; export {};