import type { BuildInPlacements } from '@rc-component/trigger'; import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from '@rc-component/select'; import * as React from 'react'; import Panel from './Panel'; import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil'; export interface BaseOptionType { disabled?: boolean; disableCheckbox?: boolean; label?: React.ReactNode; value?: string | number | null; children?: DefaultOptionType[]; } export type DefaultOptionType = BaseOptionType & Record; export interface SearchConfig { filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames) => boolean; render?: (inputValue: string, path: OptionType[], prefixCls: string, fieldNames: FieldNames) => React.ReactNode; sort?: (a: OptionType[], b: OptionType[], inputValue: string, fieldNames: FieldNames) => number; matchInputWidth?: boolean; limit?: number | false; searchValue?: string; onSearch?: (value: string) => void; autoClearSearchValue?: boolean; } export type ShowCheckedStrategy = typeof SHOW_PARENT | typeof SHOW_CHILD; interface BaseCascaderProps extends Omit { id?: string; prefixCls?: string; fieldNames?: FieldNames; optionRender?: (option: OptionType) => React.ReactNode; children?: React.ReactElement; changeOnSelect?: boolean; displayRender?: (label: string[], selectedOptions?: OptionType[]) => React.ReactNode; checkable?: boolean | React.ReactNode; showCheckedStrategy?: ShowCheckedStrategy; /** @deprecated please use showSearch.autoClearSearchValue */ autoClearSearchValue?: boolean; showSearch?: boolean | SearchConfig; /** @deprecated please use showSearch.searchValue */ searchValue?: string; /** @deprecated please use showSearch.onSearch */ onSearch?: (value: string) => void; expandTrigger?: 'hover' | 'click'; options?: OptionType[]; /** @private Internal usage. Do not use in your production. */ popupPrefixCls?: string; loadData?: (selectOptions: OptionType[]) => void; popupClassName?: string; popupMenuColumnStyle?: React.CSSProperties; placement?: BaseSelectPropsWithoutPrivate['placement']; builtinPlacements?: BuildInPlacements; onPopupVisibleChange?: (open: boolean) => void; expandIcon?: React.ReactNode; loadingIcon?: React.ReactNode; } export interface FieldNames { label?: keyof OptionType; value?: keyof OptionType | ValueField; children?: keyof OptionType; } export type ValueType = keyof OptionType extends ValueField ? unknown extends OptionType['value'] ? OptionType[ValueField] : OptionType['value'] : OptionType[ValueField]; export type GetValueType = false extends Multiple ? ValueType, ValueField>[] : ValueType, ValueField>[][]; export type GetOptionType = false extends Multiple ? OptionType[] : OptionType[][]; type SemanticName = 'input' | 'prefix' | 'suffix' | 'placeholder' | 'content' | 'item' | 'itemContent' | 'itemRemove'; type PopupSemantic = 'list' | 'listItem'; export interface CascaderProps extends BaseCascaderProps { styles?: Partial> & { popup?: Partial>; }; classNames?: Partial> & { popup?: Partial>; }; checkable?: Multiple; value?: GetValueType; defaultValue?: GetValueType; onChange?: (value: GetValueType, selectOptions: GetOptionType) => void; } export type SingleValueType = (string | number)[]; export type LegacyKey = string | number; export type InternalValueType = SingleValueType | SingleValueType[]; export interface InternalFieldNames extends Required { key: string; } export type InternalCascaderProps = Omit & { value?: InternalValueType; defaultValue?: InternalValueType; onChange?: (value: InternalValueType, selectOptions: BaseOptionType[] | BaseOptionType[][]) => void; }; export type CascaderRef = Omit; declare const Cascader: ((props: React.PropsWithChildren> & { ref?: React.Ref; }) => React.ReactElement) & { displayName?: string | undefined; SHOW_PARENT: typeof SHOW_PARENT; SHOW_CHILD: typeof SHOW_CHILD; Panel: typeof Panel; }; export default Cascader;