import React from 'react'; import { ComposibleValidatable as State, FormState, ValidatableFields as Fields } from 'formstate-x'; import { FormProps as BaseFormProps, ModalFormProps as BaseModalFormProps, DrawerFormProps as BaseDrawerFormProps } from '../Form'; export declare type SubmitHandler = (value: V) => (void | Promise); export declare type WithState; }> = (Omit & { /** 表单状态,`FormState` 实例 */ state: FormState; /** 提交行为的回调函数,表单校验通过才会触发回调 */ onSubmit?: SubmitHandler; }); export declare type Props = WithState; export default function Form({ state, onSubmit, ...formProps }: Props): React.JSX.Element; export declare type ModalFormProps = WithState; export declare function ModalForm({ state, onSubmit, ...formProps }: ModalFormProps): React.JSX.Element; export declare type DrawerFormProps = WithState; export declare function DrawerForm({ state, onSubmit, ...formProps }: DrawerFormProps): React.JSX.Element; /** * 在 React 组件中构造 `FormState` / `FieldState` 实例的 hooks * * 使用姿势: * function createState(foo: Foo, bar?: Bar) { * return new FormState({ * foo: new FieldState(foo) * bar: new FieldState(bar) * }) * } * * function Comp({ foo, bar }) { * const state = useFormstateX(createState, [foo, bar]) * } * */ export declare function useFormstateX, Fn extends (...args: D) => R>(createState: Fn, parameters: [...D]): ReturnType;