diff --git a/common/main.js b/common/main.js index e1b3305..4c443a2 100644 --- a/common/main.js +++ b/common/main.js @@ -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(); 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]), c && E.cloneElement(c, { ...s, ...l }); + }, [a]), c ? E.cloneElement(c, { ...s, ...l }) : null; }, 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 T = Object.keys((e == null ? void 0 : e.extras) || {}); diff --git a/grid-layout-form.d.ts b/grid-layout-form.d.ts index bbf0672..3235ebf 100644 --- a/grid-layout-form.d.ts +++ b/grid-layout-form.d.ts @@ -273,14 +273,15 @@ declare function useFieldArray(value: any, onChange: (value: any[]) => void): Us * @param {boolean} [props.required] 是否必填 * @param {string} [props.placeholder] 输入占位文字,透传给实际控件 * @param {boolean} [props.noStyle] 是否隐藏 FormItem 的 label/border 等样式 - * @param {Object} [props.style] FormItem 根节点行内样式 + * @param {CSSProperties} [props.style] FormItem 根节点行内样式 * @param {string} [props.help] 字段提示文字(tooltip) * @param {GridLayoutFormFieldValidators} [props.validators] 校验规则配置,合并到 rc-field-form rules - * @param {Object} [props.extras] 透传给 ItemWidget.$setting 的扩展配置(key 由 defaultProps.extras 定义) + * @param {Record} [props.extras] 透传给 ItemWidget.$setting 的扩展配置(key 由 defaultProps.extras 定义) * @param {*} [props.initialValue] 字段初始值 * @param {string} [props.initialValueLanguage] 初始值语言(用于特定类型的取值转换) * @param {boolean} [props.isVirtual] 虚拟字段,不参与表单提交 * 其余未识别的 props 经 itemWidgetRender 透传到实际控件的 fieldProps 中 + * @returns {React.JSX.Element | null} */ declare function GridLayoutFormWidget({ widget, widgetPrefix, widgetDecorator, subWidgets, basicForm, ...props }: { widget?: string; @@ -294,14 +295,14 @@ declare function GridLayoutFormWidget({ widget, widgetPrefix, widgetDecorator, s required?: boolean; placeholder?: string; noStyle?: boolean; - style?: any; + style?: React.CSSProperties; help?: string; validators?: GridLayoutFormFieldValidators; - extras?: any; + extras?: Record; initialValue?: any; initialValueLanguage?: string; isVirtual?: boolean; -}): undefined; +}): React.JSX.Element | null; /** * 弹窗表单容器:包裹 GridLayoutForm 并附带保存/取消操作按钮,保存时校验并提交表单, @@ -341,10 +342,10 @@ declare function GridLayoutFormHelper({ $setting, $close, extras, code, primaryK * @param {Record} [props.formProps={}] 注入为 `__PROPS__` 字段值的表单级参数 * @param {GridLayoutFormItem[]} [props.formFields=[]] 额外注入的表单字段(与 formProps/primaryKey 一并作为初始 fields) * @param {string[]} [props.listenChangeFields] 触发联动表达式重新求值的字段列表 - * @param {*} [props.listenChangeFieldsFunc] 字段值变化时执行的联动表达式(经 func.exec 执行) + * @param {GridLayoutFormWidgetDecorator} [props.listenChangeFieldsFunc] 字段值变化时执行的联动表达式(经 func.exec 执行) * @param {(changedValues: Object, allValues: Object) => void} [props.onValuesChange] 表单值变化回调,先于联动表达式执行 * @param {string} [props.theme] 主题组件标识,指定时通过 GridLayoutFramework 渲染主题外壳 - * @param {Object} [props.themeProps={}] 传给主题组件的额外参数 + * @param {Record} [props.themeProps={}] 传给主题组件的额外参数 * @param {GridLayoutFormGroup[]} [props.groups=[{key:'default',label:'默认'}]] 字段分组配置,用于主题多分组渲染 * @param {ReactNode} [props.children] 附加渲染在字段项之后的内容 */ @@ -364,10 +365,10 @@ declare function GridLayoutForm({ name, form: initForm, basicForm, style, classN formProps?: Record; formFields?: GridLayoutFormItem[]; listenChangeFields?: string[]; - listenChangeFieldsFunc?: any; + listenChangeFieldsFunc?: GridLayoutFormWidgetDecorator; onValuesChange?: (changedValues: any, allValues: any) => void; theme?: string; - themeProps?: any; + themeProps?: Record; groups?: GridLayoutFormGroup[]; children?: React.ReactNode; }): React.JSX.Element;