import { FormComponentProps, ValidationRule } from 'antd/es/form'; import React from 'react'; export interface FormConfig { initialValue?: (itemValue: any, value: T | undefined) => any; valuePropName?: string; validateTrigger?: string | string[]; validateFirst?: boolean; trigger?: string; required?: string; rules?: ValidationRule[]; transformDot?: boolean; getValueFromEvent?: (...args: any[]) => any; exclusive?: boolean; onChange?: (e: any) => void; } export interface FormConfigs { [key: string]: FormConfig; } /** * 配置表单验证规则 * @example * const { fields: f } = useFormItem(form, value, { * 'alarmRules.rule_lockIp.enabled': { valuePropName: 'checked' }, * 'alarmRules.rule_lockIp.count': {}, * 'alarmRules.rule_lockAccount.enabled': { valuePropName: 'checked' }, * 'alarmRules.rule_lockAccount.count': {}, * }) */ export default function useFormItem>(form: FormComponentProps['form'], value: T | undefined, items: P): { fields: { [key in keyof P]: (node: N) => N; }; validate: (cb: any) => void; };