This commit is contained in:
2026-09-16 16:11:51 +08:00
parent b96b15d737
commit 4961a5c606
42 changed files with 560 additions and 536 deletions
+161
View File
@@ -0,0 +1,161 @@
import * as React from 'react';
import React__default, { ReactElement, ComponentType } from 'react';
import PropTypes from 'prop-types';
/**
* 渲染一个 iconfont symbol 图标(依赖 Iconfont.init 注入的 SVG symbol 脚本)
* @param {Object} props
* @param {string} [props.className] 额外的 class 名
* @param {string} props.type 图标名,对应 svg symbol 的 id
* @param {Object} [props.style] 行内样式
*/
declare function Iconfont({ className, type, style, rotate, spin, twoToneColor, compact, ...props }: {
className?: string;
type: string;
style?: any;
}): React__default.JSX.Element;
declare namespace Iconfont {
export namespace propTypes {
let className: PropTypes.Requireable<string>;
let type: PropTypes.Validator<string>;
let style: PropTypes.Requireable<object>;
}
export { createScriptUrlElements as init };
}
/**
* 依次注入 iconfont symbol 的 script 地址(单个 url 只会注入一次);
* 也是 Iconfont.init 挂载的实现,支持传入多个 url 按顺序加载(前一个 load/error 后再加载下一个)
* @param {string[]} [scriptUrls] iconfont symbol 脚本地址列表
* @param {number} [index] 内部递归用的当前下标
*/
declare function createScriptUrlElements(scriptUrls?: string[], index?: number): void;
/**
* 包装一个弹窗内容组件,让它可以通过 $setProps 更新自己的 props(与外部传入的 widgetProps 做浅合并),
* 同时注入 $close 用于关闭弹窗
* @param {Object} props
* @param {import('react').ReactElement|Function} props.widget 要渲染的元素或组件
* @param {Object} [props.widgetProps] 外部传入的初始 props,变化时会合并进内部状态
* @param {(result?: *) => void} props.$close 关闭弹窗的函数,会透传给 widget
* @param {(patch: Object) => void} [props.onSetProps] $setProps 被调用时的回调,用于同步外部状态
*/
declare function SetPropsWrapper({ widget, widgetProps: externalProps, $close, onSetProps }: {
widget: React.ReactElement | Function;
widgetProps?: any;
$close: (result?: any) => void;
onSetProps?: (patch: any) => void;
}): Function | React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>>;
/**
* 通用错误边界组件
* @param {Object} props
* @param {*} props.children
* @param {ReactNode|((error: Error, reset: () => void) => ReactNode)} [props.fallback]
* 错误时的 UI。函数形式可接收 error 和 reset,不传则显示错误字符串。
* @param {Function} [props.onError] 错误回调 (error, info) => void
* @param {Function} [props.onReset] 重置回调 () => void
* @param {any[]} [props.resetKeys] 任一值变化时自动重置(类似 react-error-boundary)
*/
declare class ErrorBoundary extends React__default.Component<any, any, any> {
static getDerivedStateFromError(error: any): {
error: any;
};
constructor(props: any);
constructor(props: any, context: any);
state: {
error: any;
};
componentDidCatch(error: any, info: any): void;
componentDidUpdate(prevProps: any): void;
reset: () => void;
render(): any;
}
/** widget 支持的三种形式 */
type WidgetInput = string | ReactElement | ComponentType
/**
* 按组件名动态加载并渲染组件,支持 theme 容器框架(string 异步加载 或 function render prop)
* @param {WidgetInput} [props.widget] 组件名(@pkg/xxx)、ReactElement 或组件函数/类
* @param {Object} [props.widgetProps] 直接 spread 给 widget 的 props
* @param {Object} [props.widgetSetting] 传给 widget 的 $setting
* @param {string | ThemeRenderer} [props.theme]
* 容器框架:string 异步加载,function render prop(接收 {@link ThemeContext})
* @param {Object} [props.themeProps] 传给 theme 的 $setting(即 ThemeContext.$setting)
* @param {string} [props.className] 透传给 theme 的根节点 className
* @param {Partial<Record<LayoutKey, string>>} [props.classNames] 各布局区块的 className
* @param {CSSProperties} [props.style] 透传给 theme 的根节点行内样式
* @param {Partial<Record<LayoutKey, CSSProperties>>} [props.styles] 各布局区块的行内样式
* @param {*} [props.fallback] 加载中占位 UI,默认 null
* @param {ReactNode | FallbackOnError} [props.fallbackOnError]
* @param {(error: Error, info: null) => void} [props.onError]
*/
declare function ImportWidgetComponent({ widget, widgetProps, widgetSetting, theme, themeProps, className, classNames, style, styles, fallback, fallbackOnError, onError, }?: WidgetInput): any;
/** 空状态占位组件 */
declare function Empty(): React__default.JSX.Element;
/** 加载中占位组件 */
declare function Loading(): React__default.JSX.Element;
/** 未找到占位组件 */
declare function NotFound(): React__default.JSX.Element;
declare namespace FFPopup {
export { modal };
export { confirm };
export { form };
export { notification };
export { success };
export { error };
}
/**
* 打开一个任意组件的弹窗
* @param {Function} widget 要渲染的组件
* @param {Object} [widgetData] 传给组件的 props
* @param {Object} [widgetContainerProps] 传给弹窗容器(PopupContainer)的 props
* @returns {Promise<*>&{update: Function}} resolve 弹窗关闭时传入的值;promise.update(patch, containerPatch) 可用来更新弹窗内容
*/
declare function modal(widget: Function, widgetData?: any, widgetContainerProps?: any): Promise<any> & {
update: Function;
};
/**
* 弹出一个确认框
* @param {*} content 确认框内容
* @param {Object} [opts] 其余透传给 Confirm 组件的 props
* @returns {Promise<*>} 点击确认时 resolve,点击取消/关闭时按 modal 的语义处理
*/
declare function confirm(content: any, opts?: any): Promise<any>;
/**
* 弹出一个模态表单;取消时 reject(false)
* @param {Array} fields 表单字段配置(传给 FormModal 的 fields)
* @param {Object} [widgetContainerProps] 传给弹窗容器的 props
* @param {Object} [formProps] 传给表单的额外 props
* @returns {Promise<Object>} 提交后的表单数据
*/
declare function form(fields: any[], widgetContainerProps?: any, formProps?: any): Promise<any>;
/**
* 弹出一条消息提示
* @param {*} content 提示内容
* @param {Object} [opts] 其余透传给 Notification 组件的 props,duration/showProgress 会转发到容器 props
* @returns {Promise<*>}
*/
declare function notification(content: any, { showProgress, duration, ...opts }?: any): Promise<any>;
/**
* 成功提示(绿色图标样式的 notification)
* @param {*} content 提示内容
* @param {Object} [opts] 其余透传给 notification 的选项
* @returns {Promise<*>}
*/
declare function success(content: any, opts?: any): Promise<any>;
/**
* 错误提示(红色图标样式的 notification)
* @param {*} content 提示内容
* @param {Object} [opts] 其余透传给 notification 的选项
* @returns {Promise<*>}
*/
declare function error(content: any, opts?: any): Promise<any>;
export { Empty, ErrorBoundary, Iconfont as Icon, ImportWidgetComponent, Loading, NotFound, FFPopup as Popup, SetPropsWrapper };