@@ -12,12 +12,11 @@ import type {ObjectSchema} from 'yup';
1212 *
1313 * */
1414export type FormProps < Inf = Record < string , unknown > > = {
15- class ?: string ;
1615 initialValues : Inf ;
1716 onSubmit : ( ( values : Inf ) => any ) | ( ( values : Inf ) => Promise < any > ) ;
1817 validate ?: ( values : Inf ) => any | undefined ;
1918 validationSchema ?: ObjectSchema < any > ;
20- } ;
19+ }
2120
2221type FieldProps = {
2322 name : string ;
@@ -43,12 +42,7 @@ type TextareaProps = {
4342 rows ?: number ;
4443} ;
4544
46- declare function createForm < Inf = Record < string , unknown > > ( formProps : {
47- initialValues : Inf ;
48- onSubmit : ( values : Inf ) => any | Promise < any > ;
49- validate ?: ( values : Inf ) => any | undefined ;
50- validationSchema ?: ObjectSchema < any > ;
51- } ) : {
45+ type FormState < Inf = Record < string , unknown > > = {
5246 form : Writable < Inf > ;
5347 errors : Writable < Record < keyof Inf , string > > ;
5448 touched : Writable < Record < keyof Inf , boolean > > ;
@@ -77,12 +71,31 @@ declare function createForm<Inf = Record<string, unknown>>(formProps: {
7771 handleSubmit : ( ) => any ;
7872} ;
7973
74+ declare function createForm < Inf = Record < string , unknown > > ( formProps : {
75+ initialValues : Inf ;
76+ onSubmit : ( values : Inf ) => any | Promise < any > ;
77+ validate ?: ( values : Inf ) => any | undefined ;
78+ validationSchema ?: ObjectSchema < any > ;
79+ } ) : FormState < Inf > ;
80+
8081declare class Form extends SvelteComponentTyped <
8182 FormProps & {
8283 class ?: string ;
8384 } ,
8485 { } ,
85- { default : any }
86+ {
87+ default : Pick <
88+ FormState ,
89+ | 'errors'
90+ | 'touched'
91+ | 'updateField'
92+ | 'updateTouched'
93+ | 'handleChange'
94+ | 'handleSubmit'
95+ | 'form'
96+ | 'state'
97+ > ;
98+ }
8699> { }
87100
88101declare class Field extends SvelteComponentTyped < FieldProps , { } , { } > { }
0 commit comments