UNPKG

cosmo-ui

Version:
42 lines (37 loc) 1.07 kB
import { AbstractFormField, StylableComponent } from '.' /** * A Form is an object that maps string keys * to an AbstractFormField */ export interface FormModel { [key: string]: AbstractFormField<any> } /** * Props for the container component of the form */ export interface FormProps extends StylableComponent { name: string onSubmit?: FormSubmitHandler } /** * Props for the display component of a form */ export interface FormComponentProps extends FormProps { formData: FormModel resetForm: (formName: string) => any destroyForm: (formName: string) => any submitFormValid: (formName: string, data?: any) => any submitFormInvalid: (formName: string, data?: any) => any } /** * The on submit function should take a single argument * Which is the validated form data - if the data is not * valid then this function will not be triggered */ export type FormSubmitHandler = (formData: FormModel) => any /** * React context type for passing form name down to children */ export interface FormContext { formName: string }