import type React from 'react'; import type { PopupPropsCommon } from '../popup/interface'; export type ActionSheetAction = 'cancel' | 'item' | 'overlay'; export interface Action { /** 标题 */ name: string; /** 选项描述信息 */ description?: string; /** 选项文字颜色 */ color?: string; /** 是否为加载状态 */ loading?: boolean; /** 是否为禁用状态 */ disabled?: boolean; /** 点击时触发的回调函数 */ callback?: () => void; } export interface ActionSheetProps extends PopupPropsCommon { /** * 面板选项列表 */ actions: Action[]; /** * 顶部标题 */ title?: React.ReactNode; /** * 取消按钮文字 */ cancelText?: string; /** * 选项上方的描述信息 */ description?: React.ReactNode; /** * 顶部安全高度 * @default safeAreaInsets.top */ safeAreaInsetTop?: number; /** * 是否显示圆角 * @default true */ round?: boolean; /** * 是否在显示弹层时才渲染节点 * @default true */ lazyRender?: boolean; /** * 点击取消按钮时触发 */ onCancel?: () => void; /** * 点击选项时触发,禁用或加载状态下不会触发 */ onSelect?: (action: Action, index: number) => void; } export interface ActionSheetOptions extends Omit< ActionSheetProps, 'visible' | 'actions' | 'onCancel' | 'onRequestClose' > { /** * 面板选项列表 */ actions: (string | Action)[]; /** * 关闭前的回调函数,返回 false 可阻止关闭,支持返回 Promise */ beforeClose?: ( action: ActionSheetAction, item?: Action, index?: number ) => boolean | Promise; /** * 触发了某个机制 */ onResponse?: ( action: ActionSheetAction, item?: Action, index?: number ) => void; /** * 当同时存在多个 provider 时,指定哪个 provider 触发打开 */ portalTag?: string; } export interface ActionSheetMethodProps extends ActionSheetOptions {} export interface ActionSheetInstance { (p: ActionSheetOptions): Promise<{ item: Action; index: number }>; Component: React.FC; }