react-formal
Version:
Classy HTML form management for React
59 lines (58 loc) • 1.76 kB
TypeScript
import PropTypes from 'prop-types';
import React from 'react';
import { MessageProps } from './Message';
/**
* Display all Form validation `errors` in a single summary list.
*
* ```jsx static
* <Form
* schema={modelSchema}
* defaultValue={modelSchema.default()}
* >
* <Form.Summary/>
*
* <Form.Field name='name.first' placeholder='first'/>
* <Form.Field name='name.last' placeholder='surname'/>
* <Form.Field name='dateOfBirth' placeholder='dob'/>
*
* <Form.Submit>Validate</Form.Submit>
* </Form>
* ```
*
* @memberof Form
*/
declare class Summary extends React.PureComponent<MessageProps & {
formatMessage: (err: any, idx: number, errors: any[]) => React.ReactNode;
}, any> {
static propTypes: {
/**
* An error message renderer, Should return a `ReactElement`
* ```ts static
* function(
* message: string,
* idx: number,
* errors: array
* ): ReactElement
* ```
*/
formatMessage: PropTypes.Validator<(...args: any[]) => any>;
/**
* A DOM node tag name or Component class the Message should render as.
*/
as: PropTypes.Validator<NonNullable<PropTypes.ReactComponentLike>>;
/**
* A css class that should be always be applied to the Summary container.
*/
errorClass: PropTypes.Requireable<string>;
/**
* Specify a group to show errors for, if empty all form errors will be shown in the Summary.
*/
group: PropTypes.Requireable<string>;
};
static defaultProps: {
as: string;
formatMessage: (message: any, idx: any) => JSX.Element;
};
render(): JSX.Element;
}
export default Summary;