///
import type { FormState } from '@sinoui/rx-form-state';
import type AppInfo from '../app/AppInfo';
import type FormItem from '../core-form/FormItem';
import type FormFieldConfigPanelProps from './FormFieldConfigPanelProps';
import type FormFieldGroup from './FormFieldGroup';
import type FormFieldRenderProps from './FormFieldRenderProps';
import type ReadonlyRenderProps from './ReadonlyRenderProps';
import type { TextRenderResult } from './TextRenderResult';
import type ValidateFunction from './ValidateFunction';
import type ValidateFunctionContext from './ValidateFunctionContext';
/**
* 表单字段配置
*/
export default interface FormFieldConfig {
/**
* 字段类型
*/
type: string;
/**
* 字段标题
*/
title: string;
/**
* 字段小图标
*/
icon?: React.ReactNode;
/**
* 所属组别。默认为 `senior`
*/
group: FormFieldGroup;
/**
* 字段在表单中的渲染组件
*/
render: React.FunctionComponent>;
/**
* 字段在子表单中的渲染组件。如果不指定,则采用 `render` 组件在子表单中渲染。
*/
subformRender?: React.FunctionComponent>;
/**
* 表单字段在设计器中的预览组件
*/
preview: React.FunctionComponent;
/**
* 表单字段在设计器子表单中的预览组件
*/
subformPreview?: React.FunctionComponent;
/**
* 表单字段面板配置
*/
configPanel: React.FunctionComponent;
/**
* 新增表单项时需要产生的默认配置的方法
*
* @param fieldName 字段名称
* @param fieldConfig 字段配置
* @param formItem 表单项
*/
defaultConfig?: (fieldName: string, fieldConfig: FormFieldConfig, formItem: Omit) => {
[x: string]: any;
};
/**
* 将表单项的配置做转化
*
* @param fieldConfig 字段配置
*/
transformConfig?: (fieldConfig: FormItem) => Promise;
/**
* 禁止在子表单中渲染。默认为 `false`,表示可以在子表单中渲染。
*/
disallowInSubform?: boolean;
/**
* 只读渲染器。在需要只读显示的地方使用。如子表单中的字段只读显示、数据查询列表中的显示。如果不指定,则默认直接展示表单项值的值。
*/
readonlyRender?: React.ElementType>;
/**
* 文本渲染。用于打印输出场景。
*
* @param value 表单项的值
* @param formItem 表单项
* @param printOutSetting 打印输出设置
* @param inSubform 是否在子表单中使用
*/
textRender?: ((value: ValueType, formItem: FormItemType, printOutSetting: any, inSubform?: boolean) => TextRenderResult) | ((value: ValueType, formItem: FormItemType, printOutSetting: any, inSubform?: boolean) => Promise);
/**
* 格式化复杂数据类型。用于高级搜索和导出
*
*/
formatRender?: (value: ValueType, fieldConfig: FormItem) => string;
/**
* 获取默认值的方法
*
* @param formItem 表单项
* @param appInfo 应用信息
*/
defaultValueGetter?: (formItem: FormItem, appInfo: AppInfo, value: any) => ValueType | null | undefined | Promise;
/**
* 表单值发生变化的回调函数
*/
onFormChange?: (formItem: FormItem, appInfo: AppInfo, formState: FormState) => Promise;
/**
* 禁止在数据表格中出现
*/
disabledInList?: boolean;
/**
* 禁止在查询中出现
*/
disabledInSeniorSearch?: boolean;
/**
* 表单字段支持的控制条件
*/
controlConditions?: string[];
/**
* 是否禁止作为路由的控制条件
*/
disabledInControlConditions?: boolean;
/**
* 字段级默认校验规则函数
*/
defaultValidate?: (value: any, context: ValidateFunctionContext) => string | undefined | null;
/**
* 字段级校验规则函数
*/
validates?: {
[validateName: string]: ValidateFunction;
};
/**
* 是否支持浮动布局
*/
enableFloating?: boolean;
/**
* 其他选项类型
*/
otherOptionType?: 'input' | 'userSelect' | 'deptSelect';
/**
* 其他选项用户部门范围
*/
optherOptionScope?: {
id: string;
title: string;
}[];
/**
* 其他选项用户部门范围选择类型
*/
userDeptSelectType?: 'single' | 'multiple';
/**
* 是否为布局字段
*/
layoutFormField?: boolean;
/**
* 默认子项
*/
defaultChildren?: FormItem[];
/**
* 容器字段
*/
containerFormField?: boolean;
}