fix: grid-layout-form 类型精化——widget 返回 JSX.Element|null,消除 any 类型

This commit is contained in:
2026-09-22 16:17:03 +08:00
parent 1726a18093
commit f9d1b01f18
2 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -836,7 +836,7 @@ const $r = { null2json: (t) => Object.create(), null2array: (t) => [], null2numb
const o = Lr(t, e), [a, l] = Ui(o, r, n, i), [c, u] = L(); const o = Lr(t, e), [a, l] = Ui(o, r, n, i), [c, u] = L();
return z(() => { return z(() => {
a && X.getWidgetComponent(a).then(({ defaultProps: p = {}, default: m }) => ({ default: Wi(m, p, i) })).catch((p) => ({ default: () => `${p}` })).then((p) => u(E.createElement(p.default, s))); a && X.getWidgetComponent(a).then(({ defaultProps: p = {}, default: m }) => ({ default: Wi(m, p, i) })).catch((p) => ({ default: () => `${p}` })).then((p) => u(E.createElement(p.default, s)));
}, [a]), c && E.cloneElement(c, { ...s, ...l }); }, [a]), c ? E.cloneElement(c, { ...s, ...l }) : null;
}, Wi = (t, e = {}, r = null) => (n) => { }, Wi = (t, e = {}, r = null) => (n) => {
const { type: i, code: s, label: o, noStyle: a, style: l, placeholder: c, required: u = !1, extras: p, validators: m, help: g, isVirtual: w, $isReserved: f, initialValue: C, initialValueLanguage: b, ...S } = y.omit(y.merge({}, e, n), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), k = Li(Object.assign({}, m, u ? { required: !0 } : {}), s, i), $ = W(() => { const { type: i, code: s, label: o, noStyle: a, style: l, placeholder: c, required: u = !1, extras: p, validators: m, help: g, isVirtual: w, $isReserved: f, initialValue: C, initialValueLanguage: b, ...S } = y.omit(y.merge({}, e, n), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), k = Li(Object.assign({}, m, u ? { required: !0 } : {}), s, i), $ = W(() => {
const T = Object.keys((e == null ? void 0 : e.extras) || {}); const T = Object.keys((e == null ? void 0 : e.extras) || {});
+10 -9
View File
@@ -273,14 +273,15 @@ declare function useFieldArray(value: any, onChange: (value: any[]) => void): Us
* @param {boolean} [props.required] 是否必填 * @param {boolean} [props.required] 是否必填
* @param {string} [props.placeholder] 输入占位文字,透传给实际控件 * @param {string} [props.placeholder] 输入占位文字,透传给实际控件
* @param {boolean} [props.noStyle] 是否隐藏 FormItem 的 label/border 等样式 * @param {boolean} [props.noStyle] 是否隐藏 FormItem 的 label/border 等样式
* @param {Object} [props.style] FormItem 根节点行内样式 * @param {CSSProperties} [props.style] FormItem 根节点行内样式
* @param {string} [props.help] 字段提示文字(tooltip) * @param {string} [props.help] 字段提示文字(tooltip)
* @param {GridLayoutFormFieldValidators} [props.validators] 校验规则配置,合并到 rc-field-form rules * @param {GridLayoutFormFieldValidators} [props.validators] 校验规则配置,合并到 rc-field-form rules
* @param {Object} [props.extras] 透传给 ItemWidget.$setting 的扩展配置(key 由 defaultProps.extras 定义) * @param {Record<string, unknown>} [props.extras] 透传给 ItemWidget.$setting 的扩展配置(key 由 defaultProps.extras 定义)
* @param {*} [props.initialValue] 字段初始值 * @param {*} [props.initialValue] 字段初始值
* @param {string} [props.initialValueLanguage] 初始值语言(用于特定类型的取值转换) * @param {string} [props.initialValueLanguage] 初始值语言(用于特定类型的取值转换)
* @param {boolean} [props.isVirtual] 虚拟字段,不参与表单提交 * @param {boolean} [props.isVirtual] 虚拟字段,不参与表单提交
* 其余未识别的 props 经 itemWidgetRender 透传到实际控件的 fieldProps 中 * 其余未识别的 props 经 itemWidgetRender 透传到实际控件的 fieldProps 中
* @returns {React.JSX.Element | null}
*/ */
declare function GridLayoutFormWidget({ widget, widgetPrefix, widgetDecorator, subWidgets, basicForm, ...props }: { declare function GridLayoutFormWidget({ widget, widgetPrefix, widgetDecorator, subWidgets, basicForm, ...props }: {
widget?: string; widget?: string;
@@ -294,14 +295,14 @@ declare function GridLayoutFormWidget({ widget, widgetPrefix, widgetDecorator, s
required?: boolean; required?: boolean;
placeholder?: string; placeholder?: string;
noStyle?: boolean; noStyle?: boolean;
style?: any; style?: React.CSSProperties;
help?: string; help?: string;
validators?: GridLayoutFormFieldValidators; validators?: GridLayoutFormFieldValidators;
extras?: any; extras?: Record<string, unknown>;
initialValue?: any; initialValue?: any;
initialValueLanguage?: string; initialValueLanguage?: string;
isVirtual?: boolean; isVirtual?: boolean;
}): undefined; }): React.JSX.Element | null;
/** /**
* 弹窗表单容器:包裹 GridLayoutForm 并附带保存/取消操作按钮,保存时校验并提交表单, * 弹窗表单容器:包裹 GridLayoutForm 并附带保存/取消操作按钮,保存时校验并提交表单,
@@ -341,10 +342,10 @@ declare function GridLayoutFormHelper({ $setting, $close, extras, code, primaryK
* @param {Record<string, unknown>} [props.formProps={}] 注入为 `__PROPS__` 字段值的表单级参数 * @param {Record<string, unknown>} [props.formProps={}] 注入为 `__PROPS__` 字段值的表单级参数
* @param {GridLayoutFormItem[]} [props.formFields=[]] 额外注入的表单字段(与 formProps/primaryKey 一并作为初始 fields) * @param {GridLayoutFormItem[]} [props.formFields=[]] 额外注入的表单字段(与 formProps/primaryKey 一并作为初始 fields)
* @param {string[]} [props.listenChangeFields] 触发联动表达式重新求值的字段列表 * @param {string[]} [props.listenChangeFields] 触发联动表达式重新求值的字段列表
* @param {*} [props.listenChangeFieldsFunc] 字段值变化时执行的联动表达式(经 func.exec 执行) * @param {GridLayoutFormWidgetDecorator} [props.listenChangeFieldsFunc] 字段值变化时执行的联动表达式(经 func.exec 执行)
* @param {(changedValues: Object, allValues: Object) => void} [props.onValuesChange] 表单值变化回调,先于联动表达式执行 * @param {(changedValues: Object, allValues: Object) => void} [props.onValuesChange] 表单值变化回调,先于联动表达式执行
* @param {string} [props.theme] 主题组件标识,指定时通过 GridLayoutFramework 渲染主题外壳 * @param {string} [props.theme] 主题组件标识,指定时通过 GridLayoutFramework 渲染主题外壳
* @param {Object} [props.themeProps={}] 传给主题组件的额外参数 * @param {Record<string, unknown>} [props.themeProps={}] 传给主题组件的额外参数
* @param {GridLayoutFormGroup[]} [props.groups=[{key:'default',label:'默认'}]] 字段分组配置,用于主题多分组渲染 * @param {GridLayoutFormGroup[]} [props.groups=[{key:'default',label:'默认'}]] 字段分组配置,用于主题多分组渲染
* @param {ReactNode} [props.children] 附加渲染在字段项之后的内容 * @param {ReactNode} [props.children] 附加渲染在字段项之后的内容
*/ */
@@ -364,10 +365,10 @@ declare function GridLayoutForm({ name, form: initForm, basicForm, style, classN
formProps?: Record<string, unknown>; formProps?: Record<string, unknown>;
formFields?: GridLayoutFormItem[]; formFields?: GridLayoutFormItem[];
listenChangeFields?: string[]; listenChangeFields?: string[];
listenChangeFieldsFunc?: any; listenChangeFieldsFunc?: GridLayoutFormWidgetDecorator;
onValuesChange?: (changedValues: any, allValues: any) => void; onValuesChange?: (changedValues: any, allValues: any) => void;
theme?: string; theme?: string;
themeProps?: any; themeProps?: Record<string, unknown>;
groups?: GridLayoutFormGroup[]; groups?: GridLayoutFormGroup[];
children?: React.ReactNode; children?: React.ReactNode;
}): React.JSX.Element; }): React.JSX.Element;