import { CSSProperties, ReactNode } from 'react'; import { TriggerProps } from '../trigger'; import { ButtonProps } from '../button'; import { MenuProps } from '../menu'; /** * @title Dropdown */ export interface DropdownProps { children?: ReactNode; /** * classNames */ classNames?: string; /** * 下拉框的内容 */ style?: CSSProperties; /** * 下拉框的内容 */ droplist?: ReactNode | MenuProps['items']; /** * 开启搜索,内部使用的是menu组件 只搜索一层 */ showSearch?: boolean; /** * 下拉框的弹出位置 * @defaultValue bl */ position?: 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br'; /** * 触发下拉框弹出的方式 * @defaultValue hover */ trigger?: TriggerProps['trigger']; /** * 是否禁用弹出 */ disabled?: boolean; /** * 隐藏后是否销毁 DOM 结构 * @defaultValue true */ unmountOnExit?: boolean; /** * 控制下拉框是否默认打开 */ defaultPopupVisible?: boolean; /** * 控制下拉框是否打开(受控模式) */ popupVisible?: boolean; /** * 弹出框下可接受所有 `Trigger` 组件的 `Props` */ triggerProps?: Partial; /** * 弹出框打开/关闭时会触发 */ onVisibleChange?: (visible: boolean) => void; /** * 选中菜单时触发 */ onChange?: (...args: any[]) => any; /** * 弹出框挂在的父级节点 */ getPopupContainer?: (node: HTMLElement) => Element; /** * value指定字段,下拉框默认为key */ valueField?: string; } /** * @title Dropdown.Button */ export interface DropdownButtonProps extends Omit { style?: CSSProperties; className?: string | string[]; /** * 下拉框的弹出位置 * @defaultValue br */ position?: 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br'; /** * 等同于 `Button` 的 size */ size?: 'small' | 'middle' | 'large'; /** * 等同于 `Button` 的 type * @defaultValue default */ type?: 'primary' | 'secondary' | 'default' | 'dashed' | 'text' | 'link' | 'ghost'; /** * 按钮状态 * @defaultValue default */ level?: 'primary' | 'secondary' | 'warning' | 'danger' | 'success' | 'default'; /** * 接收 button 按钮的所有 Props,应用于左侧按钮 */ buttonProps?: ButtonProps; /** * 接收 button 按钮的所有 Props,应用于右侧按钮 */ buttonIconProps?: ButtonProps; /** * 右侧显示内容,可以是 icon 或者任意 dom 元素 * @defaultValue */ icon?: ReactNode; /** * 自定义两个按钮的渲染 */ buttonsRender?: (buttons: React.ReactElement[]) => React.ReactElement[]; /** * 左侧按钮的点击事件 */ onClick?: (e: Event) => void; children?: ReactNode; }