/// import { ReactNode, RefObject, FocusEvent, SyntheticEvent, ChangeEvent, KeyboardEvent, FC } from 'react'; import { Menu, MenuItemId, MenuPopperProps, MenuProps } from '@befe/brick-comp-menu'; import { Input, InputProps } from '@befe/brick-comp-input'; import { ConfiguredComponent } from '@befe/brick-core'; import { DelayHandler } from '@befe/brick-utils'; type SuggestPropsFromInput = Pick; export declare const SUGGEST_SIZES: readonly ["sm", "md", "lg", "xl"]; type SuggestSize = (typeof SUGGEST_SIZES)[number]; /** * @public */ export interface SuggestOption { /** * 唯一标识 */ id: MenuItemId; /** * 显示文字,用于已选择 */ label: string; /** * 显示内容,用于选项,如不指定则使用 label */ content?: ReactNode; /** * 是否禁用 */ disabled?: boolean; /** * 子选项,只支持一层,用于 group */ children?: SuggestOption[]; } export type SuggestValue = SuggestOption | null; export type SuggestOnChange = { bivarianceHack(value: Val): void; }['bivarianceHack']; export interface BaseSuggestProps extends SuggestPropsFromInput { /** * 自定义 class */ className?: string; /** * 选中控制值 * @type SuggestValue */ value?: Val; /** * 选中默认值 * @type SuggestValue */ defaultValue?: Val; /** * 是否禁用 */ disabled?: boolean; /** * 未选择占位提示 */ placeholder?: string; /** * 尺寸 */ size?: SuggestSize; /** * 选项列表弹出位置 */ placement?: MenuPopperProps['placement']; /** * 值变化时的回调 * @type (value: SuggestValue) => void */ onChange?: SuggestOnChange; /** * 查询回调 */ onSearch?: (query: string) => Promise; /** * 键盘按下回调 */ onKeyDown?: (e: KeyboardEvent) => void; /** * loading 图标的延迟响应时间 * 单位 ms * 0 为立即显示 */ loadingDelay?: number; /** * 是否使用 trimmed 过的 inputValue 作为 fetch 的 query 参数 */ trim?: boolean; /** * 空字符串是是否进行 search * 设为 true 则空字符串在 focus 状态下亦会触发 search */ shouldEmptySearch?: boolean; /** * 控件框状态 */ status?: 'normal' | 'error'; /** * 将选项列表的宽度固定为 selection 宽度 */ fixDropdownWidth?: MenuPopperProps['matchWidthToTarget']; /** * 后缀图标, * * 如果为 falsy 则显示为下拉箭头 * * @default SvgSearch */ suffixIcon?: FC | null; /** * 无选项提示内容 */ noOptionsHint?: ReactNode | ((input: string) => ReactNode); } export interface SuggestState { selected: SuggestOption[]; popperVisible: boolean; loading: boolean; fetched: boolean; inputValue: string; options: SuggestOption[]; } /** * @docgen-skip */ export declare class BaseSuggest extends ConfiguredComponent { static displayName: string; static defaultProps: BaseSuggestProps; static getDerivedStateFromProps(nextProps: BaseSuggestProps): { selected: SuggestOption[]; } | null; componentLocale: import("@befe/brick-core").ComponentLocale<{ en_us: { no_data: string; }; zh_cn: { no_data: string; }; }>; multiple: boolean; state: State; fetchId: number; focused: boolean; inCompositing: boolean; refSuggest: RefObject; refInput: RefObject; refOptionsPopperWrap: RefObject; refMenu: RefObject; loadingDelayHandler: DelayHandler; constructor(props: Props); get loadingDelay(): number | Required["loadingDelay"]; get className(): string; get size(): "sm" | "md" | Required["size"]; get nodeInput(): Input | null; get value(): SuggestOption | SuggestOption[]; get isLoading(): boolean; get isFetched(): boolean; get noOptionsHint(): ReactNode; get caretIcon(): (props: import("react").SVGProps) => Omit; get menuProps(): Partial & { ref: RefObject; }; get menuPopperProps(): MenuPopperProps; get selectedIds(): MenuItemId[]; get flatAvailableOptions(): SuggestOption[]; handlePopperVisibleChange: (popperVisible: boolean, e?: Event | SyntheticEvent) => void; handleChangeSelectedIds: (selectedIds: MenuItemId[]) => void; handleKeyDownBase(e: KeyboardEvent): void; handleKeyDown: (e: KeyboardEvent) => void; handleBlurInput: (e: FocusEvent) => void; handleFocusInput: (e: FocusEvent) => void; handleChangeInput: (e: ChangeEvent) => void; handleClickClear: () => void; handleMouseDownPopperMenu: MenuProps['onMouseDown']; handleCompositionStart: () => void; handleCompositionEnd: () => void; search: import("lodash").DebouncedFunc<(inputValue: string) => void>; initLoadingDelayHandler(): void; moveMenuCursor(step: number): void; getValue(selected?: SuggestOption[]): SuggestOption | SuggestOption[]; findOption(id: MenuItemId, options?: SuggestOption[]): SuggestOption | null; fetch(query: string): Promise; selectInCursor(): void; changeSelectedByIds(selectedIds: MenuItemId[]): void; clearSelection(): void; autoResetInputValue(): void; resetInputValue(value?: SuggestOption | SuggestOption[]): void; hideMenuPopper(): void; reset(): void; focus(): void; blur(): void; changeSelected(selected: SuggestOption[]): void; getMenuItemProps(opt: SuggestOption): Pick; renderInputSuffix(): import("react/jsx-runtime").JSX.Element; renderSelection(): import("react/jsx-runtime").JSX.Element; renderMenuItem(opt: SuggestOption, idx: number): import("react/jsx-runtime").JSX.Element; renderMenuItemGroup(opt: SuggestOption, idx: number): import("react/jsx-runtime").JSX.Element | null; renderOptions(): (import("react/jsx-runtime").JSX.Element | null)[] | null; renderPopper(): import("react/jsx-runtime").JSX.Element | null; renderTarget(): import("react/jsx-runtime").JSX.Element; componentDidMount(): void; componentDidUpdate(): void; componentWillUnmount(): void; render(): import("react/jsx-runtime").JSX.Element; } export interface SuggestProps extends BaseSuggestProps { } /** * @types * SuggestValue = SuggestOption | null */ export declare class Suggest extends BaseSuggest { static defaultProps: BaseSuggestProps; } export {};