UNPKG

@alifd/meet-react

Version:

Fusion Mobile React UI System Component

52 lines (51 loc) 1.72 kB
/// <reference types="react" /> import { Component } from 'react'; import Field from '../field'; import { BaseComponentAttributes, HTMLAttributesWeak } from '../utils/types'; import { ItemSize, LabelAlign, TextAlign } from './context'; import { SubmitCallback } from './utils'; type onChangeOptions = { name: string; value: any; field: Field; }; export interface FormProps extends HTMLAttributesWeak, BaseComponentAttributes { labelAlign?: LabelAlign; labelWidth?: string | number; labelTextAlign?: TextAlign; contentAlign?: TextAlign; size?: ItemSize; field?: Field; saveField?: (field: Field) => void; scrollToFirstError?: boolean; autoUnmount?: boolean; autoValidate?: boolean; value?: any; defaultValue?: any; useLabelForErrorMessage?: boolean; onChange?: (value: any, options: onChangeOptions) => void; onSubmit?: SubmitCallback; isPreview?: boolean; children?: any; } export default class Form extends Component<FormProps> { mapNameToGuid: { [x: string]: string; }; protected field: Field; protected validateCallback: Array<() => void>; constructor(props: FormProps); submit(callback: SubmitCallback, skipValidate?: boolean): void; submit(names: string[], callback: SubmitCallback, skipValidate?: boolean): void; reset(toDefault?: boolean, names?: string[]): void; getValue(names?: string[]): any; setValue(values: { [x: string]: any; }): void; componentDidUpdate(prevProps: FormProps): void; handleChange(name: string, value: any): void; handleAfterValidate(data: any): void; onValidate(cb: () => void): () => void; render(): JSX.Element; } export {};