import { IconComponent, IconPropSize } from '@consta/icons/Icon'; import React from 'react'; import { PropForm, PropSize, PropStatus, PropView, RenderItemProps } from '../SelectComponents/types'; import { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes'; export type ComboboxItemDefault = { label: string; id: string | number; groupId?: string | number; disabled?: boolean; }; export type ComboboxGroupDefault = { label: string; id: string | number; }; type RenderValueProps = { item: ITEM; handleRemove?: (e: React.SyntheticEvent) => void; }; export type ComboboxPropGetItemLabel = (item: ITEM) => string; export type ComboboxPropGetItemKey = (item: ITEM) => string | number; export type ComboboxPropGetItemGroupKey = (item: ITEM) => string | number | undefined; export type ComboboxPropGetItemDisabled = (item: ITEM) => boolean | undefined; export type ComboboxPropGetGroupKey = (group: GROUP) => string | number; export type ComboboxPropGetGroupLabel = (group: GROUP) => string; type ComboboxPropSearchFunction = (item: ITEM, searchValue: string) => boolean; type ComboboxPropOnChange = (value: (MULTIPLE extends true ? ITEM[] : ITEM) | null, props: { e: React.SyntheticEvent; }) => void; type ComboboxPropValue = (MULTIPLE extends true ? ITEM[] : ITEM) | null | undefined; export type ComboboxPropRenderItem = (props: RenderItemProps) => React.ReactNode | null; export type ComboboxPropRenderValue = (props: RenderValueProps) => React.ReactNode | null; type ComboboxPropOnCreate = (label: string, props: { e: React.SyntheticEvent; }) => void; export type ComboboxProps = PropsWithHTMLAttributesAndRef<{ items: ITEM[]; onChange: ComboboxPropOnChange; 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?: ComboboxPropRenderItem; renderValue?: ComboboxPropRenderValue; onFocus?: React.FocusEventHandler; onBlur?: React.FocusEventHandler; onCreate?: ComboboxPropOnCreate; inputRef?: React.Ref; labelForNotFound?: string; required?: boolean; labelForCreate?: string; labelForEmptyItems?: string; searchFunction?: ComboboxPropSearchFunction; searchValue?: string; multiple?: MULTIPLE; value?: ComboboxPropValue; groups?: GROUP[]; getItemLabel?: ComboboxPropGetItemLabel; getItemKey?: ComboboxPropGetItemKey; getItemGroupKey?: ComboboxPropGetItemGroupKey; getItemDisabled?: ComboboxPropGetItemDisabled; getGroupLabel?: ComboboxPropGetGroupLabel; getGroupKey?: ComboboxPropGetGroupKey; label?: string; labelIcon?: IconComponent; caption?: string; labelPosition?: 'top' | 'left'; virtualScroll?: boolean; onScrollToBottom?: (length: number) => void; onSearchValueChange?: (value: string) => void; onDropdownOpen?: (isOpen: boolean) => void; dropdownOpen?: boolean; dropdownViewportRef?: React.RefObject; dropdownContainer?: Element; ignoreOutsideClicksRefs?: ReadonlyArray>; }, HTMLDivElement> & (MULTIPLE extends true ? { selectAll?: boolean; allSelectedAllLabel?: string; } : { selectAll?: never; allSelectedAllLabel?: never; }) & (ITEM extends { label: ComboboxItemDefault['label']; } ? {} : { getItemLabel: ComboboxPropGetItemLabel; }) & (ITEM extends { id: ComboboxItemDefault['id']; } ? {} : { getItemKey: ComboboxPropGetItemKey; }) & (GROUP extends { label: ComboboxGroupDefault['label']; } ? {} : { getGroupLabel: ComboboxPropGetGroupLabel; }) & (GROUP extends { id: ComboboxGroupDefault['id']; } ? {} : { getGroupKey: ComboboxPropGetGroupKey; }); export type ComboboxComponent = (props: ComboboxProps) => React.ReactNode | null; export declare const defaultGetItemKey: ComboboxPropGetItemKey; export declare const defaultGetItemLabel: ComboboxPropGetItemLabel; export declare const defaultGetItemGroupKey: ComboboxPropGetItemGroupKey; export declare const defaultGetItemDisabled: ComboboxPropGetItemDisabled; export declare const defaultGetGroupKey: ComboboxPropGetGroupKey; export declare const defaultGetGroupLabel: ComboboxPropGetGroupLabel; 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: ComboboxPropOnChange; 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?: ComboboxPropRenderItem | undefined; renderValue?: ComboboxPropRenderValue | undefined; onFocus?: React.FocusEventHandler; onBlur?: React.FocusEventHandler; onCreate?: ComboboxPropOnCreate; inputRef?: React.Ref; labelForNotFound?: string; required?: boolean; labelForCreate?: string; labelForEmptyItems?: string; searchFunction?: ComboboxPropSearchFunction | undefined; searchValue?: string; multiple?: MULTIPLE | undefined; value?: ComboboxPropValue; groups?: GROUP[] | undefined; getItemLabel?: ComboboxPropGetItemLabel | undefined; getItemKey?: ComboboxPropGetItemKey | undefined; getItemGroupKey?: ComboboxPropGetItemGroupKey | undefined; getItemDisabled?: ComboboxPropGetItemDisabled | undefined; getGroupLabel?: ComboboxPropGetGroupLabel | undefined; getGroupKey?: ComboboxPropGetGroupKey | undefined; label?: string; labelIcon?: IconComponent; caption?: string; labelPosition?: "top" | "left"; virtualScroll?: boolean; onScrollToBottom?: (length: number) => void; onSearchValueChange?: (value: string) => void; onDropdownOpen?: (isOpen: boolean) => void; dropdownOpen?: boolean; dropdownViewportRef?: React.RefObject; dropdownContainer?: Element; ignoreOutsideClicksRefs?: ReadonlyArray>; } & 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" | "onScrollToBottom" | "labelForCreate" | "searchFunction" | "searchValue" | "onDropdownOpen" | "onSearchValueChange" | "dropdownOpen" | "ignoreOutsideClicksRefs" | "labelForNotFound" | "virtualScroll" | "dropdownViewportRef" | "dropdownContainer" | "onCreate"> & React.RefAttributes & (MULTIPLE extends true ? { selectAll?: boolean; allSelectedAllLabel?: string; } : { selectAll?: never; allSelectedAllLabel?: never; }) & (ITEM extends { label: ComboboxItemDefault["label"]; } ? {} : { getItemLabel: ComboboxPropGetItemLabel; }) & (ITEM extends { id: ComboboxItemDefault["id"]; } ? {} : { getItemKey: ComboboxPropGetItemKey; }) & (GROUP extends { label: ComboboxGroupDefault["label"]; } ? {} : { getGroupLabel: ComboboxPropGetGroupLabel; }) & (GROUP extends { id: ComboboxGroupDefault["id"]; } ? {} : { getGroupKey: ComboboxPropGetGroupKey; }) & { getItemLabel: ComboboxPropGetItemLabel | ComboboxPropGetItemLabel; getItemKey: ComboboxPropGetItemKey | ComboboxPropGetItemKey; getItemGroupKey: ComboboxPropGetItemGroupKey | ComboboxPropGetItemGroupKey; getItemDisabled: ComboboxPropGetItemDisabled | ComboboxPropGetItemDisabled; getGroupLabel: ComboboxPropGetGroupLabel | ComboboxPropGetGroupLabel; getGroupKey: ComboboxPropGetGroupKey | ComboboxPropGetGroupKey; }; export declare const clearSizeMap: Record; export declare const iconSizeMap: Record; export {};