///
import * as Icons from '@alipay/sofa-icons';
export interface SuggestionItemType {
/**
* 展示文本
* @type { string }
* @default ''
*/
text: string;
/**
* 省略展示配置
* 可以是布尔值,也可以是对象,对象中可以包含rows属性,表示省略展示的行数
* @type { { rows?: number } | boolean }
* @default true
*/
ellipsis?: {
rows?: number;
} | boolean;
/**
* 前置图标
* @type { React.ReactNode }
* @default undefined
*/
icon?: React.ReactNode;
/**
* 是否禁用
* @type { boolean }
* @default false
*/
disabled?: boolean;
/**
* 右侧动作图标/箭头
* @type { React.ReactNode | keyof typeof Icons }
* @default undefined
*/
actionIcon?: React.ReactNode | keyof typeof Icons;
}
export type ItemClickHandler = (item: SuggestionItemType) => void | Promise;
export type Variant = 'outlined' | 'filled' | 'shadow' | 'borderless';
export interface SuggestionsProps {
/**
* 标题
* @type { string }
* @default undefined
*/
title?: string;
/**
* 建议项列表
* @type { SuggestionItem[] }
* @default []
*/
items?: SuggestionItemType[];
/**
* 变体样式
* @type { 'outlined' | 'filled' | 'borderless' }
* @default undefined
*/
variant?: Variant;
/**
* 自定义类名
* @type { string }
* @default undefined
*/
className?: string;
/**
* 自定义样式
* @type { React.CSSProperties }
* @default undefined
*/
style?: React.CSSProperties;
/**
* 点击回调
* @type { ItemClickHandler }
* @default undefined
*/
onClick?: ItemClickHandler;
}
export interface SuggestionItemProps extends SuggestionItemType {
onClick?: ItemClickHandler;
}