@radicalbit/formbit 1.2.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,55 @@
1
1
  import { ObjectSchema, ValidationError as YupValidationError, ValidateOptions as YupValidateOptions } from 'yup';
2
2
  import { ACTIONS } from '../helpers/constants';
3
3
  /**
4
+ * @internal
4
5
  * @private
5
6
  */
6
7
  export type Action = keyof typeof ACTIONS;
7
8
  /**
8
- * Checks the given json against the form schema and returns and array of errors.
9
- * It returns undefined if the json is valid.
10
- *
9
+ * @internal
10
+ * Generic object with string keys.
11
11
  */
12
- export type Check<Values extends InitialValues> = (json: Form, options?: CheckFnOptions<Values>) => ValidationError[] | undefined;
12
+ export type FormbitRecord = Record<string, unknown>;
13
+ /** @deprecated Use {@link FormbitRecord} instead. Renamed to avoid shadowing the global `Object`. */
14
+ export type Object = FormbitRecord;
13
15
  /**
14
- * Reset isDirty value to false
16
+ * @internal
15
17
  */
16
- export type ClearIsDirty = () => void;
18
+ export type GenericCallback<Values extends InitialValues> = SuccessCallback<Values> | ErrorCallback<Values>;
17
19
  /**
18
- * Invoked in case of errors raised by validation
20
+ * @internal
19
21
  */
20
- export type ErrorCallback<Values extends InitialValues> = (writer: Writer<Values>, setError: SetError) => void;
22
+ export type ValidationFormbitError = Pick<ValidationError, 'message' | 'path'>;
21
23
  /**
22
- * Invoked in case of errors raised by validation of check method
23
- *
24
+ * @internal
25
+ * @private
24
26
  */
25
- export type ErrorCheckCallback<Values extends InitialValues> = (json: Form, inner: ValidationError[], writer: Writer<Values>, setError: SetError) => void;
27
+ export type WriteOrRemove<Values extends Form> = (path: keyof Values | string, value: unknown, options?: WriteFnOptions<Values>, action?: Action) => void;
26
28
  /**
27
- * Returns the error message for the given path if any.
28
- * It doesn't trigger any validation
29
- *
29
+ * @internal
30
+ * @private
30
31
  */
31
- export type ErrorFn = (path: string) => string | undefined;
32
+ export type PrivateValidateForm<Values extends InitialValues> = (successCallback?: SuccessCallback<Values>, errorCallback?: ErrorCallback<Partial<Values>>, options?: {
33
+ options?: ValidateOptions;
34
+ isDirty?: boolean;
35
+ }) => void;
36
+ /**
37
+ * Base type for form values: a record of string keys with an optional `__metadata` field.
38
+ */
39
+ export type FormbitValues = {
40
+ __metadata?: FormbitRecord;
41
+ } & FormbitRecord;
42
+ /** Object containing the updated form. */
43
+ export type Form = FormbitValues;
44
+ /** InitialValues used to set up formbit; also used to reset the form to its original version. */
45
+ export type InitialValues = FormbitValues;
32
46
  /**
33
- * Object including all the registered errors messages since the last validation.
47
+ * Object including all the registered error messages since the last validation.
34
48
  * Errors are stored using the same path of the corresponding form values.
35
49
  *
36
50
  * @example
37
51
  * If the form object has this structure:
38
- * ```json
52
+ * ```json
39
53
  * {
40
54
  * "age": 1
41
55
  * }
@@ -46,54 +60,20 @@ export type ErrorFn = (path: string) => string | undefined;
46
60
  * "age": "Age must be greater then 18"
47
61
  * }
48
62
  * ```
49
- *
50
63
  */
51
64
  export type Errors = Record<string, string>;
52
- /**
53
- * Object containing the updated form
54
- */
55
- export type Form = {
56
- __metadata?: Object;
57
- } & Object;
58
- export type GenericCallback<Values extends InitialValues> = SuccessCallback<Values> | ErrorCallback<Values>;
59
- /**
60
- * Initialize the form with new initial values
61
- */
62
- export type Initialize<Values extends InitialValues> = (values: Partial<Values>) => void;
63
- /**
64
- * InitialValues used to setup formbit, used also to reset the form to the original version.
65
- *
66
- */
67
- export type InitialValues = {
68
- __metadata?: Object;
69
- } & Object;
70
- /**
71
- * Returns true if the form is Dirty (user already interacted with the form), false otherwise.
72
- *
73
- */
74
- export type IsDirty = boolean;
75
- /**
76
- * Returns true if the form is NOT valid
77
- * It doesn't perform any validation, it checks if any errors are present
78
- */
79
- export type IsFormInvalid = () => boolean;
80
- /**
81
- * Returns true id the form is valid
82
- * It doesn't perform any validation, it checks if any errors are present
83
- */
84
- export type IsFormValid = () => boolean;
85
65
  /**
86
66
  * Object including all the values that are being live validated.
87
- * Usually fields that fail validation (using one of the method that triggers validation)
88
- * will automatically set to be live-validated.
67
+ * Usually fields that fail validation (using one of the methods that triggers validation)
68
+ * will automatically be set to live-validated.
89
69
  *
90
70
  * A value/path is live-validated when validated at every change of the form.
91
71
  *
92
- * By default no field is live-validated
72
+ * By default no field is live-validated.
93
73
  *
94
74
  * @example
95
75
  * If the form object has this structure:
96
- * ```json
76
+ * ```json
97
77
  * {
98
78
  * "age": 1
99
79
  * }
@@ -101,169 +81,121 @@ export type IsFormValid = () => boolean;
101
81
  * and age is a field that is being live-validated, liveValidation object will look like this
102
82
  * ```json
103
83
  * {
104
- * "age": "Age must be greater then 18"
84
+ * "age": true
105
85
  * }
106
86
  * ```
107
- *
108
87
  */
109
88
  export type LiveValidation = Record<string, true>;
110
89
  /**
111
- * Returns true if live validation is active for the given path
112
- *
113
- */
114
- export type LiveValidationFn = (path: string) => true | undefined;
115
- /**
116
- * Generic object with string as keys
117
- *
118
- */
119
- export type Object = Record<string, unknown>;
120
- /**
121
- * @private
90
+ * Internal form state storing all the data of the form (except the validation schema).
122
91
  */
123
- export type PrivateValidateForm<Values extends InitialValues> = (successCallback?: SuccessCallback<Values>, errorCallback?: ErrorCallback<Partial<Values>>, options?: {
124
- options?: ValidateOptions;
125
- isDirty?: boolean;
126
- }) => void;
127
- /**
128
- *
129
- * This method updates the form state deleting value and set isDirty to true.
130
- *
131
- * After writing, it validates all the paths contained into pathsToValidate (if any)
132
- * and all the fields that have the live validation active.
133
- *
134
- *
135
- */
136
- export type Remove<Values extends InitialValues> = (path: string, options?: WriteFnOptions<Values>) => void;
137
- /**
138
- * Reset form to the initial state.
139
- * Errors and liveValidation are set back to empty objects.
140
- * isDirty is set back to false
141
- *
142
- */
143
- export type ResetForm = () => void;
92
+ export type FormState<Values extends InitialValues> = {
93
+ form: Values;
94
+ initialValues: Values;
95
+ errors: Errors;
96
+ liveValidation: LiveValidation;
97
+ isDirty: boolean;
98
+ };
99
+ /** @deprecated Use {@link FormState} instead. */
100
+ export type Writer<Values extends InitialValues> = FormState<Values>;
144
101
  /**
145
102
  * Type imported from the yup library.
146
- * It represents any validation schema created with the yup.object() method
103
+ * It represents any validation schema created with the yup.object() method.
147
104
  *
148
105
  * Link to the Yup documentation {@link https://github.com/jquense/yup}
149
- *
150
106
  */
151
107
  export type ValidationSchema<Values extends InitialValues> = ObjectSchema<Values>;
152
108
  /**
153
- * Set a message(value) to the given error path.
109
+ * Type imported from the yup library.
110
+ * It represents the object with all the options that can be passed to the internal yup validation method.
154
111
  *
112
+ * Link to the Yup documentation {@link https://github.com/jquense/yup}
155
113
  */
156
- export type SetError = (path: string, value: string) => void;
114
+ export type ValidateOptions = YupValidateOptions;
157
115
  /**
158
- * Override the current schema with the given one.
116
+ * Type imported from the yup library.
117
+ * It represents the error object returned when a validation fails.
159
118
  *
119
+ * Link to the Yup documentation {@link https://github.com/jquense/yup}
160
120
  */
161
- export type SetSchema<Values extends InitialValues> = (newSchema: ValidationSchema<Values>) => void;
121
+ export type ValidationError = YupValidationError;
162
122
  /**
163
- * Perform a validation against the current form object, and execute the successCallback if the validation pass
164
- * otherwise it executes the errorCallback
165
- *
123
+ * Success callback invoked by some formbit methods when the operation is successful.
166
124
  */
167
- export type SubmitForm<Values extends InitialValues> = (successCallback: SuccessSubmitCallback<Values>, errorCallback?: ErrorCallback<Partial<Values>>, options?: ValidateOptions) => void;
125
+ export type SuccessCallback<Values extends InitialValues> = (writer: FormState<Values>, setError: SetError) => void;
168
126
  /**
169
- * Success callback invoked by some formbit methods when the operation is successful.
170
- *
127
+ * Invoked in case of errors raised by validation.
171
128
  */
172
- export type SuccessCallback<Values extends InitialValues> = (writer: Writer<Values>, setError: SetError) => void;
129
+ export type ErrorCallback<Values extends InitialValues> = (writer: FormState<Values>, setError: SetError) => void;
173
130
  /**
174
131
  * Success callback invoked by the check method when the operation is successful.
175
- *
176
132
  */
177
- export type SuccessCheckCallback<Values extends InitialValues> = (json: Form, writer: Writer<Values>, setError: SetError) => void;
133
+ export type CheckSuccessCallback<Values extends InitialValues> = (json: Form, writer: FormState<Values>, setError: SetError) => void;
134
+ /** @deprecated Use {@link CheckSuccessCallback} instead. */
135
+ export type SuccessCheckCallback<Values extends InitialValues> = CheckSuccessCallback<Values>;
178
136
  /**
179
- * Success callback invoked by the submit method when the validation is successful.
180
- * Is the right place to send your data to the backend.
181
- *
137
+ * Invoked in case of errors raised by validation of check method.
182
138
  */
183
- export type SuccessSubmitCallback<Values extends InitialValues> = (writer: Writer<Values | Omit<Values, '__metadata'>>, setError: SetError, clearIsDirty: ClearIsDirty) => void;
139
+ export type CheckErrorCallback<Values extends InitialValues> = (json: Form, inner: ValidationError[], writer: FormState<Values>, setError: SetError) => void;
140
+ /** @deprecated Use {@link CheckErrorCallback} instead. */
141
+ export type ErrorCheckCallback<Values extends InitialValues> = CheckErrorCallback<Values>;
184
142
  /**
185
- *
186
- * This method only validate the specified path. Do not check for fields that have the
187
- * live validation active.
143
+ * Success callback invoked by the submit method when the validation is successful.
144
+ * Is the right place to send your data to the backend.
188
145
  */
146
+ export type SubmitSuccessCallback<Values extends InitialValues> = (writer: FormState<Values | Omit<Values, '__metadata'>>, setError: SetError, clearIsDirty: () => void) => void;
147
+ /** @deprecated Inlined into {@link FormbitObject}. */
148
+ export type ErrorFn = (path: string) => string | undefined;
149
+ /** @deprecated Inlined into {@link FormbitObject}. */
150
+ export type IsFormValid = () => boolean;
151
+ /** @deprecated Inlined into {@link FormbitObject}. */
152
+ export type IsFormInvalid = () => boolean;
153
+ /** @deprecated Inlined into {@link FormbitObject}. */
154
+ export type ClearIsDirty = () => void;
155
+ /** @deprecated Inlined into {@link FormbitObject}. */
156
+ export type ResetForm = () => void;
157
+ /** @deprecated Inlined into {@link FormbitObject}. */
158
+ export type LiveValidationFn = (path: string) => true | undefined;
159
+ /** @deprecated Inlined into {@link FormbitObject}. */
160
+ export type IsDirty = boolean;
161
+ /** See {@link FormbitObject.check}. */
162
+ export type Check<Values extends InitialValues> = (json: Form, options?: CheckFnOptions<Values>) => ValidationError[] | undefined;
163
+ /** See {@link FormbitObject.initialize}. */
164
+ export type Initialize<Values extends InitialValues> = (values: Partial<Values>) => void;
165
+ /** See {@link FormbitObject.remove}. */
166
+ export type Remove<Values extends InitialValues> = (path: string, options?: WriteFnOptions<Values>) => void;
167
+ /** See {@link FormbitObject.setError}. */
168
+ export type SetError = (path: string, value: string) => void;
169
+ /** See {@link FormbitObject.setSchema}. */
170
+ export type SetSchema<Values extends InitialValues> = (newSchema: ValidationSchema<Values>) => void;
171
+ /** See {@link FormbitObject.submitForm}. */
172
+ export type SubmitForm<Values extends InitialValues> = (successCallback: SubmitSuccessCallback<Values>, errorCallback?: ErrorCallback<Partial<Values>>, options?: ValidateOptions) => void;
173
+ /** See {@link FormbitObject.validate}. */
189
174
  export type Validate<Values extends InitialValues> = (path: string, options?: ValidateFnOptions<Values>) => void;
190
- /**
191
- *
192
- * This method only validate the specified paths. Do not check for fields that have the
193
- * live validation active.
194
- */
175
+ /** See {@link FormbitObject.validateAll}. */
195
176
  export type ValidateAll<Values extends InitialValues> = (paths: string[], options?: ValidateFnOptions<Values>) => void;
196
- /**
197
- * This method validates the entire form and set the corresponding errors if any.
198
- *
199
- */
177
+ /** See {@link FormbitObject.validateForm}. */
200
178
  export type ValidateForm<Values extends InitialValues> = (successCallback?: SuccessCallback<Values>, errorCallback?: ErrorCallback<Values>, options?: ValidateOptions) => void;
201
- export type ValidationFormbitError = Pick<ValidationError, 'message' | 'path'>;
202
- /**
203
- * Type imported from the yup library.
204
- * It represents the object with all the options that can be passed to the internal yup validation method,
205
- *
206
- * Link to the Yup documentation {@link https://github.com/jquense/yup}
207
- *
208
- */
209
- export type ValidateOptions = YupValidateOptions;
210
- /**
211
- *
212
- * This method update the form state writing $value into the $path, setting isDirty to true.
213
- *
214
- * After writing, it validates all the paths contained into $pathsToValidate (if any)
215
- * and all the fields that have the live validation active.
216
- */
179
+ /** See {@link FormbitObject.write}. */
217
180
  export type Write<Values extends InitialValues> = (path: keyof Values | string, value: unknown, options?: WriteFnOptions<Values>) => void;
218
- /**
219
- * This method takes an array of [path, value] and update the form state writing
220
- * all those values into the specified paths.
221
- *
222
- * It set isDirty to true.
223
- *
224
- * After writing, it validate all the paths contained into $pathToValidate and all
225
- * the fields that have the live validation active.
226
- *
227
- */
181
+ /** See {@link FormbitObject.writeAll}. */
228
182
  export type WriteAll<Values extends InitialValues> = (arr: WriteAllValue<Values>[], options?: WriteFnOptions<Values>) => void;
229
- /**
230
- *
231
- * This method updates the form state deleting multiple values, setting isDirty to true.
232
- *
233
- */
183
+ /** See {@link FormbitObject.removeAll}. */
234
184
  export type RemoveAll<Values extends InitialValues> = (arr: string[], options?: WriteFnOptions<Values>) => void;
235
185
  /**
236
186
  * Tuple of [key, value] pair.
237
- *
238
187
  */
239
188
  export type WriteAllValue<Values extends InitialValues> = [keyof Values | string, unknown];
240
189
  /**
241
- * @private
242
- */
243
- export type WriteOrRemove<Values extends Form> = (path: keyof Values | string, value: unknown, options?: WriteFnOptions<Values>, action?: Action) => void;
244
- /**
245
- * Internal form state storing all the data of the form (except the validation schema)
246
- *
247
- */
248
- export type Writer<Values extends InitialValues> = {
249
- form: Values;
250
- initialValues: Values;
251
- errors: Errors;
252
- liveValidation: LiveValidation;
253
- isDirty: IsDirty;
254
- };
255
- /**
256
- * Options object to change the behavior of the check method
257
- *
190
+ * Options object to change the behavior of the check method.
258
191
  */
259
192
  export type CheckFnOptions<Values extends InitialValues> = {
260
- successCallback?: SuccessCheckCallback<Values>;
261
- errorCallback?: ErrorCheckCallback<Values>;
193
+ successCallback?: CheckSuccessCallback<Values>;
194
+ errorCallback?: CheckErrorCallback<Values>;
262
195
  options?: ValidateOptions;
263
196
  };
264
197
  /**
265
- * Options object to change the behavior of the validate methods
266
- *
198
+ * Options object to change the behavior of the validate methods.
267
199
  */
268
200
  export type ValidateFnOptions<Values extends InitialValues> = {
269
201
  successCallback?: SuccessCallback<Partial<Values>>;
@@ -271,160 +203,131 @@ export type ValidateFnOptions<Values extends InitialValues> = {
271
203
  options?: ValidateOptions;
272
204
  };
273
205
  /**
274
- * Type imported from the yup library.
275
- * It represents the error object returned when a validation fails
276
- *
277
- * Link to the Yup documentation {@link https://github.com/jquense/yup}
278
- *
279
- */
280
- export type ValidationError = YupValidationError;
281
- /**
282
- * Options object to change the behavior of the write methods
283
- *
206
+ * Options object to change the behavior of the write methods.
284
207
  */
285
208
  export type WriteFnOptions<Values extends InitialValues> = {
286
209
  noLiveValidation?: boolean;
287
210
  pathsToValidate?: string[];
288
211
  } & ValidateFnOptions<Values>;
289
212
  /**
290
- * Object returned by useFormbit() and useFormbitContextHook()
213
+ * Object returned by useFormbit() and useFormbitContextHook().
291
214
  * It contains all the data and methods needed to handle the form.
292
- *
293
215
  */
294
216
  export type FormbitObject<Values extends InitialValues> = {
295
217
  /**
296
- * Checks the given json against the form schema and returns and array of errors.
297
- * It returns undefined if the json is valid.
298
- *
218
+ * Object containing the updated form.
299
219
  */
300
- check: Check<Partial<Values>>;
301
- /**
302
- * Returns the error message for the given path if any.
303
- * It doesn't trigger any validation
304
- *
305
- */
306
- error: ErrorFn;
220
+ form: Partial<Values>;
307
221
  /**
308
- * Object including all the registered errors messages since the last validation.
222
+ * Object including all the registered error messages since the last validation.
309
223
  * Errors are stored using the same path of the corresponding form values.
310
224
  *
311
225
  * @example
312
226
  * If the form object has this structure:
313
- * ```json
314
- * {
315
- * "age": 1
316
- * }
317
- * ```
318
- * and age is a non valid field, errors object will look like this
319
- * ```json
320
- * {
321
- * "age": "Age must be greater then 18"
322
- * }
323
- * ```
324
- *
325
- */
227
+ * ```json
228
+ * {
229
+ * "age": 1
230
+ * }
231
+ * ```
232
+ * and age is a non valid field, errors object will look like this
233
+ * ```json
234
+ * {
235
+ * "age": "Age must be greater then 18"
236
+ * }
237
+ * ```
238
+ */
326
239
  errors: Errors;
327
240
  /**
328
- * Object containing the updated form
241
+ * Returns true if the form is Dirty (user already interacted with the form), false otherwise.
329
242
  */
330
- form: Partial<Values>;
243
+ isDirty: boolean;
331
244
  /**
332
- * Initialize the form with new initial values
245
+ * Returns the error message for the given path if any.
246
+ * It doesn't trigger any validation.
333
247
  */
334
- initialize: Initialize<Values>;
248
+ error: (path: string) => string | undefined;
335
249
  /**
336
- * Returns true if the form is Dirty (user already interacted with the form), false otherwise.
337
- *
250
+ * Returns true if the form is valid.
251
+ * It doesn't perform any validation, it checks if any errors are present.
338
252
  */
339
- isDirty: boolean;
253
+ isFormValid: () => boolean;
340
254
  /**
341
- * Returns true if the form is NOT valid
342
- * It doesn't perform any validation, it checks if any errors are present
255
+ * Returns true if the form is NOT valid.
256
+ * It doesn't perform any validation, it checks if any errors are present.
343
257
  */
344
- isFormInvalid: IsFormInvalid;
258
+ isFormInvalid: () => boolean;
345
259
  /**
346
- * Returns true id the form is valid
347
- * It doesn't perform any validation, it checks if any errors are present
260
+ * Returns true if live validation is active for the given path.
348
261
  */
349
- isFormValid: IsFormValid;
262
+ liveValidation: (path: string) => true | undefined;
350
263
  /**
351
- * Returns true if live validation is active for the given path
264
+ * Checks the given json against the form schema and returns an array of errors.
265
+ * It returns undefined if the json is valid.
266
+ */
267
+ check: Check<Partial<Values>>;
268
+ /**
269
+ * This method updates the form state writing $value into the $path, setting isDirty to true.
270
+ *
271
+ * After writing, it validates all the paths contained into $pathsToValidate (if any)
272
+ * and all the fields that have the live validation active.
352
273
  */
353
- liveValidation: LiveValidationFn;
274
+ write: Write<Values>;
354
275
  /**
276
+ * This method takes an array of [path, value] and updates the form state writing
277
+ * all those values into the specified paths.
278
+ *
279
+ * It sets isDirty to true.
355
280
  *
281
+ * After writing, it validates all the paths contained into $pathToValidate and all
282
+ * the fields that have the live validation active.
283
+ */
284
+ writeAll: WriteAll<Values>;
285
+ /**
356
286
  * This method updates the form state deleting value, setting isDirty to true.
357
287
  *
358
288
  * After writing, it validates all the paths contained into pathsToValidate (if any)
359
289
  * and all the fields that have the live validation active.
360
- *
361
- *
362
290
  */
363
291
  remove: Remove<Values>;
292
+ /**
293
+ * This method updates the form state deleting multiple values, setting isDirty to true.
294
+ */
295
+ removeAll: RemoveAll<Values>;
296
+ /**
297
+ * Initialize the form with new initial values.
298
+ */
299
+ initialize: Initialize<Values>;
364
300
  /**
365
301
  * Reset form to the initial state.
366
302
  * Errors and liveValidation are set back to empty objects.
367
- * isDirty is set back to false
368
- *
303
+ * isDirty is set back to false.
369
304
  */
370
- resetForm: ResetForm;
305
+ resetForm: () => void;
371
306
  /**
372
- * Set a message(value) to the given error path.
373
- *
307
+ * Set a message (value) to the given error path.
374
308
  */
375
309
  setError: SetError;
376
310
  /**
377
311
  * Override the current schema with the given one.
378
- *
379
312
  */
380
313
  setSchema: SetSchema<Values>;
381
314
  /**
382
- * Perform a validation against the current form object, and execute the successCallback if the validation pass
383
- * otherwise it executes the errorCallback
384
- *
385
- */
386
- submitForm: SubmitForm<Values>;
387
- /**
388
- *
389
- * This method only validate the specified path. Do not check for fields that have the
315
+ * This method only validates the specified path. Does not check for fields that have the
390
316
  * live validation active.
391
317
  */
392
318
  validate: Validate<Values>;
393
319
  /**
394
- *
395
- * This method only validate the specified paths. Do not check for fields that have the
320
+ * This method only validates the specified paths. Does not check for fields that have the
396
321
  * live validation active.
397
322
  */
398
323
  validateAll: ValidateAll<Values>;
399
324
  /**
400
- * This method validates the entire form and set the corresponding errors if any.
401
- *
325
+ * This method validates the entire form and sets the corresponding errors if any.
402
326
  */
403
327
  validateForm: ValidateForm<Partial<Values>>;
404
328
  /**
405
- *
406
- * This method update the form state writing $value into the $path, setting isDirty to true.
407
- *
408
- * After writing, it validates all the paths contained into $pathsToValidate (if any)
409
- * and all the fields that have the live validation active.
329
+ * Perform a validation against the current form object, and execute the successCallback if the validation passes,
330
+ * otherwise it executes the errorCallback.
410
331
  */
411
- write: Write<Values>;
412
- /**
413
- *
414
- *
415
- * This method takes an array of [path, value] and update the form state writing
416
- * all those values into the specified paths.
417
- *
418
- * It set isDirty to true.
419
- *
420
- * After writing, it validate all the paths contained into $pathToValidate and all
421
- * the fields that have the live validation active.
422
- */
423
- writeAll: WriteAll<Values>;
424
- /**
425
- *
426
- * This method updates the form state deleting multiple values, setting isDirty to true.
427
- *
428
- */
429
- removeAll: RemoveAll<Values>;
332
+ submitForm: SubmitForm<Values>;
430
333
  };
@@ -1,4 +1,4 @@
1
- import { GenericCallback, InitialValues, SetError, Writer } from './types';
1
+ import { FormState, GenericCallback, SetError } from './types';
2
2
  /**
3
3
  * useExecuteCallbacks
4
4
  *
@@ -7,5 +7,5 @@ import { GenericCallback, InitialValues, SetError, Writer } from './types';
7
7
  *
8
8
  *
9
9
  */
10
- declare const _default: <Values extends InitialValues>(writer: Writer<Values>, setError: SetError) => (uuid: string, cb?: GenericCallback<Partial<Values>>) => void;
10
+ declare const _default: <Values extends import("./types").FormbitValues>(writer: FormState<Values>, setError: SetError) => (uuid: string, cb?: GenericCallback<Partial<Values>>) => void;
11
11
  export default _default;
@@ -3,5 +3,5 @@ type UseFormbitParams<Values extends InitialValues> = {
3
3
  initialValues?: Partial<Values>;
4
4
  yup: ValidationSchema<Values>;
5
5
  };
6
- declare const _default: <Values extends InitialValues>({ initialValues, yup: schema }: UseFormbitParams<Values>) => FormbitObject<Values>;
6
+ declare const _default: <Values extends import("./types").FormbitValues>({ initialValues, yup: schema }: UseFormbitParams<Values>) => FormbitObject<Values>;
7
7
  export default _default;
@@ -1,2 +1,2 @@
1
- import { Form, InitialValues, ValidateOptions, ValidationFormbitError, ValidationSchema } from './types';
2
- export declare const validateSyncAll: <Values extends InitialValues>(paths: string[], schema: ValidationSchema<Values>, form: Form, options?: ValidateOptions) => ValidationFormbitError[];
1
+ import { Form, ValidateOptions, ValidationFormbitError, ValidationSchema } from './types';
2
+ export declare const validateSyncAll: <Values extends import("./types").FormbitValues>(paths: string[], schema: ValidationSchema<Values>, form: Form, options?: ValidateOptions) => ValidationFormbitError[];