import { Field, FieldConfig, FieldConfigs, FieldError, FieldProps, IField } from '../common'; import React from 'react'; export interface ObjectFieldConfig extends FieldConfig { type: 'object'; fields: FieldConfigs[]; insertText?: string; removeText?: string; } export interface IObjectField { insertText: string; onInsert: () => Promise; children: React.ReactNode[]; } export interface IObjectFieldItem { key: string; removeText: string; onChange: (key: string) => Promise; onRemove: () => Promise; children: React.ReactNode[]; } export interface IObjectFieldItemField { index: number; label: string; status: 'normal' | 'error' | 'loading'; description?: string; message?: string; extra?: string; required: boolean; layout: 'horizontal' | 'vertical' | 'inline'; visitable: boolean; fieldType: string; children: React.ReactNode; } export interface ObjectFieldState { didMount: boolean; formDataList: { [key: string]: { status: 'normal' | 'error' | 'loading'; message?: string; }[]; }; extra?: S; } export default class ObjectField extends Field> implements IField<{ [key: string]: any; }> { getALLComponents: (type: any) => typeof Field; formFieldsList: { [key: string]: Array | null>; }; formFieldsMountedList: { [key: string]: Array; }; constructor(props: FieldProps); didMount: () => Promise; get: () => Promise; validate: (value: { [key: string]: any; }) => Promise; handleMount: (key: string, formFieldIndex: number) => Promise; handleInsert: () => Promise; handleRemove: (key: string) => Promise; handleChangeKey: (prev: string, next: string) => Promise; handleChange: (key: string, formFieldIndex: number, value: any) => Promise; handleValueSet: (key: string, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueUnset: (key: string, formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueListAppend: (key: string, formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueListSplice: (key: string, formFieldIndex: number, path: string, _index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueListSort: (key: string, formFieldIndex: number, path: string, _index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; /** * 用于展示子表单组件 * @param _props * @returns */ renderComponent: (_props: IObjectField) => JSX.Element; /** * 用于展示子表单组件中的每一个子项 * @param props * @returns */ renderItemComponent: (props: IObjectFieldItem) => JSX.Element; /** * 用于展示子表单组件中的每一子项中的每一个子表单项组件 * @param props * @returns */ renderItemFieldComponent: (props: IObjectFieldItemField) => JSX.Element; render: () => JSX.Element; }