@bolttech/form-engine-core 0.0.1-beta.7 → 0.0.1-beta.9

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.
package/index.esm.js CHANGED
@@ -174,6 +174,53 @@ function traverseObject(obj, path) {
174
174
  }
175
175
  return result;
176
176
  }
177
+ /**
178
+ * Recursively creates a nested object structure based on the given parts array,
179
+ * setting the specified value at the appropriate nested level.
180
+ *
181
+ * @param {string[]} parts - Array of strings representing the keys for the nested object.
182
+ * @param {Record<string, unknown>} subObject - The sub-object to be updated or used for recursion.
183
+ * @param {unknown} value - The value to be set at the final nested level.
184
+ * @returns {Record<string, unknown>} - The updated object with the new nested structure and value.
185
+ */
186
+ const getNewPart = (parts, subObject, value) => {
187
+ const clonedParts = [...parts];
188
+ clonedParts.splice(0, 1);
189
+ const part = parts.length !== 1 ? getNewPart(clonedParts, subObject ? subObject[parts[0]] : {}, value) : value;
190
+ return Object.assign(Object.assign({}, subObject), {
191
+ [parts[0]]: part
192
+ });
193
+ };
194
+ /**
195
+ * Encapsulates in a given object, at a given path the provided value
196
+ *
197
+ * @example
198
+ * ORIGINAL object
199
+ *
200
+ * encapsulateIn({maintain: 'spread_me'}, 'a.b.c','test')
201
+ *
202
+ * RESULT
203
+ *
204
+ * {
205
+ * maintain: 'spread_me',
206
+ * c: 'test
207
+ * }
208
+ * }
209
+ *
210
+ * @param origin - The original object where the new value will be appended
211
+ * @param path - The path at which the new value will be placed
212
+ * @param value - The new value
213
+ * @returns One new object with the new value at the provided path merged with the given object
214
+ */
215
+ const encapsulateIn = (origin, path, value) => {
216
+ const parts = path.split('.');
217
+ if (parts.length === 1) {
218
+ return Object.assign(Object.assign({}, origin), {
219
+ [path]: value
220
+ });
221
+ }
222
+ return getNewPart(parts, origin, value);
223
+ };
177
224
 
178
225
  /**
179
226
  * Splits a string by inserting specified values at given positions.
@@ -681,16 +728,9 @@ const currency = (value, masks) => {
681
728
  if (integerPart === '') {
682
729
  integerPart = '0';
683
730
  }
684
- console.log('Before', {
685
- convertedValue
686
- });
687
731
  if (align === 'right' && String(value).endsWith(' ')) {
688
732
  convertedValue = convertedValue.slice(0, -1);
689
733
  }
690
- console.log('After', {
691
- value,
692
- convertedValue
693
- });
694
734
  let newRawValue = integerPart;
695
735
  let decimalPart = convertedValue.slice(convertedValue.length - precision);
696
736
  if (precision > 0) {
@@ -2297,6 +2337,7 @@ class FormField {
2297
2337
  defaultStateRefreshTimeMS: Number(config === null || config === void 0 ? void 0 : config.defaultStateRefreshTimeMS) ? Number(config === null || config === void 0 ? void 0 : config.defaultStateRefreshTimeMS) : DEFAULT_STATE_REFRESH_TIME
2298
2338
  };
2299
2339
  this.name = schemaComponent.name;
2340
+ this.nameToSubmit = schemaComponent.nameToSubmit;
2300
2341
  this.component = schemaComponent.component;
2301
2342
  this.path = path;
2302
2343
  this.children = children;
@@ -2309,7 +2350,6 @@ class FormField {
2309
2350
  this.masks = schemaComponent.masks;
2310
2351
  if (mapper.valueChangeEvent) this.valueChangeEvent = mapper.valueChangeEvent;
2311
2352
  if ((_a = mapper.events) === null || _a === void 0 ? void 0 : _a.setValue) this.valuePropName = mapper.events.setValue;
2312
- if ((_b = mapper.events) === null || _b === void 0 ? void 0 : _b.setErrorMessage) this.errorMessagePropName = mapper.events.setErrorMessage;
2313
2353
  this.mapper = mapper;
2314
2354
  this.validateVisibility = validateVisibility;
2315
2355
  this.resetValue = resetValue;
@@ -2318,8 +2358,12 @@ class FormField {
2318
2358
  this.dataSubject$ = dataSubject$;
2319
2359
  this._props = schemaComponent.props || {};
2320
2360
  this._value = '';
2321
- this._stateValue = '';
2361
+ this._stateValue = ((_b = this.mapper.events) === null || _b === void 0 ? void 0 : _b.setValue) ? {
2362
+ [this.mapper.events.setValue]: ''
2363
+ } : {};
2322
2364
  this._metadata = '';
2365
+ this.errorsString = '';
2366
+ this.errorsList = [];
2323
2367
  this.initialValue = initialValue;
2324
2368
  this._visibility = true;
2325
2369
  this._api = {
@@ -2335,7 +2379,6 @@ class FormField {
2335
2379
  }, {})
2336
2380
  };
2337
2381
  this._errors = {};
2338
- this._errorsString = '';
2339
2382
  this._valid = false;
2340
2383
  this.initializeObservers();
2341
2384
  }
@@ -2343,6 +2386,7 @@ class FormField {
2343
2386
  * method to initialize all recycled Subjects and initialize Observers on field instance creation or rerender
2344
2387
  */
2345
2388
  initializeObservers() {
2389
+ var _a;
2346
2390
  if (!this.valueSubject$ || this.valueSubject$.closed) {
2347
2391
  this.valueSubject$ = new Subject();
2348
2392
  }
@@ -2365,10 +2409,11 @@ class FormField {
2365
2409
  this.apiEventQueueSubject$ = new Subject();
2366
2410
  }
2367
2411
  this.fieldState$ = combineLatest({
2368
- errors: this.errorSubject$.pipe(startWith([])),
2369
2412
  visibility: this.visibilitySubject$.pipe(startWith(this._visibility)),
2370
- apiResponse: this.apiSubject$.pipe(startWith(this._api)),
2371
- props: this.propsSubject$.pipe(startWith(this._props))
2413
+ props: this.propsSubject$.pipe(startWith(this._props)),
2414
+ errors: this.errorSubject$.pipe(startWith(Object.assign({}, ((_a = this.mapper.events) === null || _a === void 0 ? void 0 : _a.setErrorMessage) && {
2415
+ [this.mapper.events.setErrorMessage]: this.errorsString
2416
+ })))
2372
2417
  });
2373
2418
  !this.apiEventQueueSubject$.observed && this.apiEventQueueSubject$.pipe(groupBy(({
2374
2419
  event
@@ -2404,7 +2449,7 @@ class FormField {
2404
2449
  /**
2405
2450
  * Retrieves the current state value of the form field.
2406
2451
  *
2407
- * @returns {unknown} - The current state value of the form field.
2452
+ * @returns {Record<string,unknown>} - The current state value of the form field.
2408
2453
  */
2409
2454
  get stateValue() {
2410
2455
  return this._stateValue;
@@ -2412,14 +2457,6 @@ class FormField {
2412
2457
  get metadata() {
2413
2458
  return this._metadata;
2414
2459
  }
2415
- /**
2416
- * Retrieves the concatenated string of errors associated with the form field.
2417
- *
2418
- * @returns {string} - The concatenated string of errors.
2419
- */
2420
- get errorsString() {
2421
- return this._errorsString;
2422
- }
2423
2460
  /**
2424
2461
  * Retrieves the current value of the form field.
2425
2462
  *
@@ -2434,6 +2471,7 @@ class FormField {
2434
2471
  * @param {unknown} value - The new value to be set.
2435
2472
  */
2436
2473
  set value(value) {
2474
+ var _a, _b, _c;
2437
2475
  /*
2438
2476
  too much unstable, if the valueChangeEvent parses the template event
2439
2477
  value, might occur unexpected results
@@ -2453,14 +2491,19 @@ class FormField {
2453
2491
  if (typeof val === 'undefined' || val === null) return;
2454
2492
  if (typeof val === 'object' && '_value' in val && '_metadata' in val) {
2455
2493
  this._value = this.formatValue(val['_value']);
2456
- this._stateValue = this.maskValue(this.formatValue(val['_value']));
2494
+ this._stateValue = ((_a = this.mapper.events) === null || _a === void 0 ? void 0 : _a.setValue) ? {
2495
+ [this.mapper.events.setValue]: this.maskValue(this.formatValue(val['_value']))
2496
+ } : {};
2457
2497
  this._metadata = val._metadata;
2458
2498
  } else {
2459
2499
  this._value = this.formatValue(val);
2460
- this._stateValue = this.maskValue(this.formatValue(val));
2500
+ this._stateValue = ((_b = this.mapper.events) === null || _b === void 0 ? void 0 : _b.setValue) ? {
2501
+ [(_c = this.mapper.events) === null || _c === void 0 ? void 0 : _c.setValue]: this.maskValue(this.formatValue(val))
2502
+ } : {};
2503
+ this.maskValue(this.formatValue(val));
2461
2504
  this._metadata = val;
2462
2505
  }
2463
- this.valueSubject$.next(this._stateValue);
2506
+ this.stateValue && this.valueSubject$.next(this.stateValue);
2464
2507
  this.templateSubject$.next({
2465
2508
  key: this.name,
2466
2509
  event: 'ON_VALUE'
@@ -2510,10 +2553,17 @@ class FormField {
2510
2553
  * @param {TErrorMessages} errors - The new error messages to be set.
2511
2554
  */
2512
2555
  set errors(errors) {
2556
+ var _a;
2513
2557
  if (typeof errors === 'undefined' || isEqual(errors, this.errors)) return;
2514
2558
  this._errors = errors;
2515
- this._errorsString = Object.values(this.errors).join(', ');
2516
- this.errorSubject$.next(Object.values(this.errors));
2559
+ this.errorsList = Object.values(this.errors);
2560
+ this.errorsString = this.errorsList.join(', ');
2561
+ /**
2562
+ * if any error receieves a list of errors, set a prop for it, currently only supporting a single string
2563
+ */
2564
+ ((_a = this.mapper.events) === null || _a === void 0 ? void 0 : _a.setErrorMessage) && this.errorSubject$.next({
2565
+ [this.mapper.events.setErrorMessage]: this.errorsString
2566
+ });
2517
2567
  this.templateSubject$.next({
2518
2568
  key: this.name,
2519
2569
  event: 'ON_PROPS'
@@ -2549,11 +2599,8 @@ class FormField {
2549
2599
  * Mounts the form field by initializing necessary subjects and combining their streams.
2550
2600
  *
2551
2601
  * @param {object} mountOpts - Adapter mount options.
2552
- * @param {string} prop.valuePropName - Adapter value property name.
2553
- * @param {(event: unknown) => unknown} prop.valueChangeEvent - Adapter change event handler function
2554
2602
  * @param {(value: unknown) => unknown} prop.valueSubscription - Adapter value change function
2555
2603
  * @param {(payload: Partial<IState>) => unknown} prop.propsSubscription - Adapter prop change function
2556
- * @param {string} prop.errorMessagePropName - error message property name to set errors onto component
2557
2604
  * @returns {void}
2558
2605
  */
2559
2606
  mountField({
@@ -2634,14 +2681,19 @@ class FormField {
2634
2681
  const errors = Object.assign({}, this.errors);
2635
2682
  const schemaValidations = (_a = this.validations) === null || _a === void 0 ? void 0 : _a.config;
2636
2683
  schemaValidations && Object.keys(schemaValidations).forEach(validationKey => {
2637
- var _a, _b;
2684
+ var _a;
2638
2685
  const error = validations[validationKey](this.value, schemaValidations);
2639
2686
  // setting valid flag
2640
2687
  valid = !error && valid;
2641
2688
  // setting error messages
2642
2689
  if (((_a = this.validations) === null || _a === void 0 ? void 0 : _a.events.includes(event)) || event === 'ON_FORM_SUBMIT') {
2643
- if (error && ((_b = this.errorMessages) === null || _b === void 0 ? void 0 : _b[validationKey])) {
2644
- errors[validationKey] = this.errorMessages[validationKey];
2690
+ if (error && this.errorMessages) {
2691
+ if (validationKey in this.errorMessages) {
2692
+ const messages = this.errorMessages;
2693
+ errors[validationKey] = messages[validationKey];
2694
+ } else if ('default' in this.errorMessages) {
2695
+ errors[validationKey] = this.errorMessages.default;
2696
+ }
2645
2697
  } else {
2646
2698
  delete errors[validationKey];
2647
2699
  }
@@ -2649,10 +2701,6 @@ class FormField {
2649
2701
  });
2650
2702
  this._valid = valid;
2651
2703
  this.errors = errors;
2652
- // remove later
2653
- if (this.errorMessagePropName) this.props = Object.assign(Object.assign({}, this.props), {
2654
- [this.errorMessagePropName]: this.errorsString
2655
- });
2656
2704
  }
2657
2705
  /**
2658
2706
  * WIP expensive function to get updated field validity on each event
@@ -3387,11 +3435,11 @@ class FormCore {
3387
3435
  * @returns {TFormValues} The current form values.
3388
3436
  */
3389
3437
  getFormValues() {
3390
- const values = {};
3438
+ let values = {};
3391
3439
  const erroredFields = [];
3392
3440
  this.fields.forEach((val, key) => {
3393
3441
  if (val.value) {
3394
- values[key] = val.value;
3442
+ values = Object.assign(Object.assign({}, values), encapsulateIn(values, val.nameToSubmit || key, val.value));
3395
3443
  }
3396
3444
  if (!val.valid) {
3397
3445
  erroredFields.push(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine-core",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.9",
4
4
  "module": "./index.esm.js",
5
5
  "type": "module",
6
6
  "main": "./index.esm.js",
@@ -61,4 +61,26 @@ declare function extractFieldKeys(expression: string): {
61
61
  * ```
62
62
  */
63
63
  declare function traverseObject(obj: any, path?: string): TSubscribedTemplates[];
64
- export { makeRequest, traverseObject, extractFieldKeys };
64
+ /**
65
+ * Encapsulates in a given object, at a given path the provided value
66
+ *
67
+ * @example
68
+ * ORIGINAL object
69
+ *
70
+ * encapsulateIn({maintain: 'spread_me'}, 'a.b.c','test')
71
+ *
72
+ * RESULT
73
+ *
74
+ * {
75
+ * maintain: 'spread_me',
76
+ * c: 'test
77
+ * }
78
+ * }
79
+ *
80
+ * @param origin - The original object where the new value will be appended
81
+ * @param path - The path at which the new value will be placed
82
+ * @param value - The new value
83
+ * @returns One new object with the new value at the provided path merged with the given object
84
+ */
85
+ declare const encapsulateIn: (origin: Record<string, unknown>, path: string, value: unknown) => Record<string, unknown>;
86
+ export { makeRequest, traverseObject, extractFieldKeys, encapsulateIn };
@@ -6,6 +6,7 @@ import { TApiEvent, TErrorMessages, TEvent, TFormatters, TMasks, TProps, TResetV
6
6
  * @property {string} component - The type of component (e.g., 'input', 'button').
7
7
  * @property {TProps} props - The properties of the component.
8
8
  * @property {string} name - The name of the component.
9
+ * @property {string} nameToSubmit - The name of the field when submit values (optional).
9
10
  * @property {TEvent<TValidationMethods>} [validations] - The validation methods for the component.
10
11
  * @property {TVisibility[]} [visibilityConditions] - The visibility conditions for the component.
11
12
  * @property {TResetValueMethods[]} [resetValues] - The reset value methods for the component.
@@ -21,6 +22,7 @@ import { TApiEvent, TErrorMessages, TEvent, TFormatters, TMasks, TProps, TResetV
21
22
  * component: 'input',
22
23
  * props: { type: 'text', placeholder: 'Enter your name' },
23
24
  * name: 'name',
25
+ * nameToSubmit: 'applicant.firstName',
24
26
  * validations: { config: { required: true }, events: [{ eventName: 'ON_FIELD_BLUR' }] },
25
27
  * visibilityConditions: [{ conditions: { field: 'age', value: 18 } }],
26
28
  * resetValues: [{ field: 'age', resetTo: '' }],
@@ -36,6 +38,7 @@ interface IComponentSchema {
36
38
  component: string;
37
39
  props?: TProps;
38
40
  name: string;
41
+ nameToSubmit?: string;
39
42
  validations?: TEvent<TValidationMethods>;
40
43
  api?: TApiEvent;
41
44
  visibilityConditions?: TVisibility[];
@@ -1,27 +1,22 @@
1
- import { TApiResponse } from '../types/schema';
2
1
  /**
3
2
  * @interface IState
4
3
  * Represents the state of a form component.
5
4
  *
6
5
  * @property {string[]} errors - The list of error messages.
7
6
  * @property {boolean} visibility - The visibility state of the component.
8
- * @property {TApiResponse} apiResponse - The API response data.
9
7
  * @property {Record<string, unknown>} props - The properties of the component.
10
8
  *
11
9
  * @example
12
10
  * ```typescript
13
11
  * const state: IState = {
14
- * errors: ['This field is required.'],
15
12
  * visibility: true,
16
- * apiResponse: { default: { response: null } },
17
13
  * props: { type: 'text', value: 'John' }
18
14
  * };
19
15
  * ```
20
16
  */
21
17
  interface IState {
22
- errors: string[];
23
18
  visibility: boolean;
24
- apiResponse: TApiResponse;
25
19
  props: Record<string, unknown>;
20
+ errors: Record<string, unknown>;
26
21
  }
27
22
  export { IState };
@@ -9,6 +9,7 @@ import { TMapper } from '../types/mapper';
9
9
  */
10
10
  declare class FormField {
11
11
  name: string;
12
+ nameToSubmit?: string;
12
13
  component: string;
13
14
  path?: string;
14
15
  children?: string[];
@@ -21,22 +22,22 @@ declare class FormField {
21
22
  formatters?: TFormatters;
22
23
  masks?: TMasks;
23
24
  valuePropName?: string;
24
- errorMessagePropName?: string;
25
25
  initialValue?: unknown;
26
26
  config: Required<TSchemaFormConfig>;
27
27
  mapper: TMapper<unknown>;
28
+ errorsString: string;
29
+ errorsList: string[];
28
30
  private _props;
29
31
  private _value;
30
32
  private _stateValue;
31
33
  private _metadata;
32
34
  private _visibility;
33
35
  private _errors;
34
- private _errorsString;
35
36
  private _api;
36
37
  private _valid;
37
38
  propsSubject$: Subject<Record<string, unknown>>;
38
- errorSubject$: Subject<string[]>;
39
- valueSubject$: Subject<unknown>;
39
+ errorSubject$: Subject<Record<string, unknown>>;
40
+ valueSubject$: Subject<Record<string, unknown>>;
40
41
  visibilitySubject$: Subject<boolean>;
41
42
  apiSubject$: Subject<TApiResponse>;
42
43
  fieldEventSubject$: Subject<TFieldEvent>;
@@ -119,16 +120,10 @@ declare class FormField {
119
120
  /**
120
121
  * Retrieves the current state value of the form field.
121
122
  *
122
- * @returns {unknown} - The current state value of the form field.
123
+ * @returns {Record<string,unknown>} - The current state value of the form field.
123
124
  */
124
- get stateValue(): unknown;
125
+ get stateValue(): Record<string, unknown>;
125
126
  get metadata(): unknown;
126
- /**
127
- * Retrieves the concatenated string of errors associated with the form field.
128
- *
129
- * @returns {string} - The concatenated string of errors.
130
- */
131
- get errorsString(): string;
132
127
  /**
133
128
  * Retrieves the current value of the form field.
134
129
  *
@@ -187,15 +182,12 @@ declare class FormField {
187
182
  * Mounts the form field by initializing necessary subjects and combining their streams.
188
183
  *
189
184
  * @param {object} mountOpts - Adapter mount options.
190
- * @param {string} prop.valuePropName - Adapter value property name.
191
- * @param {(event: unknown) => unknown} prop.valueChangeEvent - Adapter change event handler function
192
185
  * @param {(value: unknown) => unknown} prop.valueSubscription - Adapter value change function
193
186
  * @param {(payload: Partial<IState>) => unknown} prop.propsSubscription - Adapter prop change function
194
- * @param {string} prop.errorMessagePropName - error message property name to set errors onto component
195
187
  * @returns {void}
196
188
  */
197
189
  mountField({ valueSubscription, propsSubscription, }: {
198
- valueSubscription: (value: unknown) => void;
190
+ valueSubscription: (value: Record<string, unknown>) => void;
199
191
  propsSubscription: (payload: Partial<IState>) => void;
200
192
  }): void;
201
193
  /**
@@ -206,10 +198,7 @@ declare class FormField {
206
198
  * @returns {void}
207
199
  */
208
200
  emitValue(prop: {
209
- value: unknown | {
210
- _value: unknown;
211
- _stateValue: unknown;
212
- };
201
+ value: unknown;
213
202
  event: TEvents;
214
203
  }): void;
215
204
  /**
@@ -18,7 +18,7 @@ declare class FormCore {
18
18
  key: string;
19
19
  event: TMutationEvents;
20
20
  }>;
21
- submitSubject$: Subject<TFormValues>;
21
+ submitSubject$: Subject<TFormValues<Record<string, unknown>>>;
22
22
  fieldEventSubject$: Subject<TFieldEvent>;
23
23
  dataSubject$: Subject<{
24
24
  key: string;
@@ -30,7 +30,7 @@ declare class FormCore {
30
30
  method?: string;
31
31
  config: Required<TSchemaFormConfig>;
32
32
  mappers?: TMapper<unknown>[];
33
- onSubmit?: (data: TFormValues) => void;
33
+ onSubmit?: (data: TFormValues<Record<string, unknown>>) => void;
34
34
  /**
35
35
  * Creates an instance of FormCore.
36
36
  *
@@ -72,7 +72,7 @@ declare class FormCore {
72
72
  */
73
73
  subscribeData(callback: (payload: {
74
74
  field: string;
75
- data: TFormValues;
75
+ data: TFormValues<Record<string, unknown>>;
76
76
  }) => void): void;
77
77
  /**
78
78
  * Gets the value of a property from a field.
@@ -216,7 +216,7 @@ declare class FormCore {
216
216
  *
217
217
  * @returns {TFormValues} The current form values.
218
218
  */
219
- getFormValues(): TFormValues;
219
+ getFormValues(): TFormValues<Record<string, unknown>>;
220
220
  subscribeFieldEvent({ callback, }: {
221
221
  callback: (payload: TFieldEvent) => void;
222
222
  }): Subscription;
@@ -56,7 +56,7 @@ declare class FormGroup {
56
56
  * @param {string} options.formIndex
57
57
  * @param {string} options.fieldIndex
58
58
  */
59
- removeField({ formIndex, fieldIndex }: {
59
+ removeField({ formIndex, fieldIndex, }: {
60
60
  formIndex: string;
61
61
  fieldIndex: string;
62
62
  }): void;
@@ -79,7 +79,7 @@ declare class FormGroup {
79
79
  * @param {string[]} indexes form indexes to be submitted
80
80
  * @returns
81
81
  */
82
- submitMultipleFormsByIndex(indexes: string[]): TFormValues;
82
+ submitMultipleFormsByIndex<T>(indexes: string[]): TFormValues<T>;
83
83
  }
84
84
  type TFormGroup = FormGroup;
85
85
  export { TFormGroup, FormGroup };
@@ -1,10 +1,10 @@
1
1
  import { IFormSchema } from '../interfaces/schema';
2
2
  import { TMapper } from './mapper';
3
3
  /**
4
- * @type TFormValues
5
- * Represents the values and state of a form.
4
+ * @type TFormValues<T>
5
+ * Represents the values and state of a form. It has a generic type that allows the importer to determine which type values key will return.
6
6
  *
7
- * @property {Record<string, unknown>} values - The current values of the form fields.
7
+ * @property {Generic Type} values - The current values of the form fields.
8
8
  * @property {string[]} erroredFields - A list of field names that have errors.
9
9
  * @property {boolean} isValid - Indicates whether the form is valid.
10
10
  *
@@ -17,8 +17,8 @@ import { TMapper } from './mapper';
17
17
  * };
18
18
  * ```
19
19
  */
20
- type TFormValues = {
21
- values: Record<string, unknown>;
20
+ type TFormValues<T> = {
21
+ values: T;
22
22
  erroredFields: string[];
23
23
  isValid: boolean;
24
24
  };
@@ -41,10 +41,10 @@ type TFormValues = {
41
41
  */
42
42
  type TFormEntry = Omit<IFormSchema, 'components'> & {
43
43
  schema?: IFormSchema;
44
- onSubmit?: (data: TFormValues) => void;
45
- onData?: (payload: {
44
+ onSubmit?: <T>(data: TFormValues<T>) => void;
45
+ onData?: <T>(payload: {
46
46
  field: string;
47
- data: TFormValues;
47
+ data: TFormValues<T>;
48
48
  }) => void;
49
49
  mappers?: TMapper<unknown>[];
50
50
  };
@@ -700,10 +700,11 @@ type TResetValues = Partial<Record<TEvents, TResetValueMethods[]>>;
700
700
  * const errorMessages: TErrorMessages = {
701
701
  * required: 'This field is required.',
702
702
  * max: 'The value cannot exceed the maximum limit.'
703
+ * default: 'Default error message'
703
704
  * };
704
705
  * ```
705
706
  */
706
- type TErrorMessages = Partial<Record<keyof TValidationMethods, string>>;
707
+ type TErrorMessages = Partial<Record<keyof TValidationMethods & 'default', string>>;
707
708
  /**
708
709
  * Represents an event configuration with a specific type.
709
710
  *