form-test-victor
Version:
# Performant forms and wizard library for React
47 lines • 1.61 kB
TypeScript
import { ReactNode } from 'react';
import { AnyRecord, FieldValue, ValidationStatus } from '../../shared';
export interface FieldRenderProps {
name: string;
value: FieldValue;
onFocus: () => void;
onBlur: () => void;
onChange: (e: FieldValue) => void;
}
export interface FieldRenderState {
isPristine: boolean;
validationStatus: ValidationStatus;
}
export interface FieldProps<T extends AnyRecord = AnyRecord> {
name: string;
children?: ReactNode;
render: (fieldProps: FieldRenderProps, fieldState: FieldRenderState) => JSX.Element | null;
data?: T;
}
/**
* Component to integrate a form content in the form system. Every components like input,
* checkbox has to be rendered by this component
* @param name - Name of the field, used as identifier
* @param children Rules (optional)
* @param render Function to render
* @param data data transmitted to onUpdateAfterBlur
* @example
* ```
* <Field
* name="foo"
* render={(props) => {
* const { onChange, ...rest } = props;
* return (<input {...rest} onChange={(e) => onChange(e.target.value)} />);
* }}
* >
* {children}
* </Field>
* ```
*/
export declare function Field({ name, children, render, data, }: FieldProps): JSX.Element;
export declare namespace Field {
var defaultProps: {
children: null;
};
}
export declare function composeEventHandlers(originalEventHandler: (...args: unknown[]) => void, formEventHandler: (...args: unknown[]) => void): (...args: unknown[]) => void;
//# sourceMappingURL=Field.d.ts.map