import React from 'react'; /** 属性路径类型 */ export type Path = string | string[]; /** withAlert 配置 */ export type WithAlertConfig = { /** 控制显示的 prop 名称,如 'open' 或 'visible' */ visibleKey: Path; /** 确定事件的 prop 名称,如 'onOk'(可选) */ okEventKey?: Path; /** 取消/关闭事件的 prop 名称,如 'onCancel' */ cancelEventKey: Path; /** 关闭后回调的 prop 名称,如 'afterClose'(可选) */ afterCloseEventKey?: Path; /** 关闭动画时长(毫秒),用于延迟销毁组件 */ closeDuring?: number; }; /** 弹框实例返回类型 */ export type AlertInstance = { /** 关闭弹框 */ close: (props?: Partial) => void; /** 更新弹框 props */ update: (props?: Partial) => void; }; /** * withAlertContext 高阶函数 * 将任意组件包装成命令式调用的弹框(基于 Context 实现) * * @example * ```tsx * const launch = withAlertContext({ * visibleKey: 'open', * cancelEventKey: 'onCancel', * }); * * const alertMyModal = launch(MyModal); * * // 调用 * const instance = alertMyModal({ title: '标题' }); * instance.close(); // 关闭 * instance.update({ title: '新标题' }); // 更新 * ``` */ export declare const withAlertContext: (config: WithAlertConfig, extraProps?: Record) =>

>(ModalComponent: React.ComponentType

) => (props: P) => AlertInstance

; export default withAlertContext;