UNPKG

test-nut-ui

Version:

<p align="center"> <img alt="logo" src="https://img11.360buyimg.com/imagetools/jfs/t1/211965/25/7152/22022/61b16785E433119bb/aa41d7a9f7e823f3.png" width="150" style="margin-bottom: 10px;"> </p>

105 lines (104 loc) 2.39 kB
import React, { CSSProperties, FunctionComponent } from 'react'; import { PopupProps } from '../../packages/popup/popup'; import '@nascent/nutui-icons-react/lib/style.css'; export type PopoverLocation = 'bottom' | 'top' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'; export type ButtonPosition = 'right' | 'bottom'; export interface List { key?: string; name: string; icon?: React.ReactNode; disabled?: boolean; className?: string; style?: CSSProperties; rightIcon?: boolean; } export interface PopoverProps extends PopupProps { /** * 自定义按钮区域 * @default - */ button: React.ReactNode buttonPosition: ButtonPosition | string; /** * 显示关闭图标 * @default false */ showClose: boolean /** * 标题内容 * @default - */ title: string /** * 文本内容 * @default - */ text: string /** * 深色模式 * @default true */ dark: boolean /** * 选项列表 * @default [] */ list: List[] /** * 弹出位置,里面具体的参数值可以参考上面的位置自定义例子 * @default bottom */ location: PopoverLocation | string /** * 是否展示气泡弹出层 * @default false */ visible: boolean /** * 出现位置的偏移量 * @default [0, 12] */ offset: string[] | number[] /** * 自定义目标元素 id * @default - */ targetId: string /** * 是否显示小箭头 * @default true */ showArrow: boolean /** * 是否在点击外部元素后关闭菜单 * @default true */ closeOnOutsideClick: boolean /** * 是否在点击选项后关闭 * @default true */ closeOnActionClick: boolean children?: React.ReactNode; /** * 点击切换 popover 展示状态 * @default () => {} */ onClick: () => void /** * 点击菜单时触发 * @default () => {} */ onOpen: () => void /** * 关闭菜单时触发 * @default () => {} */ onClose: () => void /** * 点击选项时触发 * @default (item, index) => {} */ onSelect: (item: List, index: number) => void } export declare const Popover: FunctionComponent<Partial<PopoverProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'>>;