@bolttech/form-engine-core 1.0.2-beta.1 → 1.0.2

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.
Files changed (46) hide show
  1. package/index.d.ts +2314 -0
  2. package/index.esm.js +131 -81
  3. package/package.json +9 -10
  4. package/index.esm.d.ts +0 -1
  5. package/src/constants/constants.d.ts +0 -10
  6. package/src/formatters/creditCard.d.ts +0 -23
  7. package/src/formatters/custom.d.ts +0 -29
  8. package/src/formatters/handler.d.ts +0 -2
  9. package/src/formatters/regex.d.ts +0 -47
  10. package/src/formatters/splitter.d.ts +0 -17
  11. package/src/formatters/string.d.ts +0 -88
  12. package/src/helpers/SafeSubject.d.ts +0 -11
  13. package/src/helpers/creditCard.d.ts +0 -95
  14. package/src/helpers/helpers.d.ts +0 -67
  15. package/src/helpers/validation.d.ts +0 -27
  16. package/src/index.d.ts +0 -10
  17. package/src/interfaces/schema.d.ts +0 -112
  18. package/src/interfaces/state.d.ts +0 -22
  19. package/src/managers/field.d.ts +0 -326
  20. package/src/managers/form.d.ts +0 -346
  21. package/src/managers/formGroup.d.ts +0 -110
  22. package/src/managers/index.d.ts +0 -3
  23. package/src/masks/creditCard.d.ts +0 -60
  24. package/src/masks/generic.d.ts +0 -39
  25. package/src/masks/handler.d.ts +0 -2
  26. package/src/masks/string.d.ts +0 -99
  27. package/src/types/event.d.ts +0 -109
  28. package/src/types/form.d.ts +0 -55
  29. package/src/types/mapper.d.ts +0 -95
  30. package/src/types/schema.d.ts +0 -835
  31. package/src/types/template.d.ts +0 -50
  32. package/src/types/utility.d.ts +0 -6
  33. package/src/validations/creditCard.d.ts +0 -52
  34. package/src/validations/custom.d.ts +0 -25
  35. package/src/validations/date.d.ts +0 -79
  36. package/src/validations/document.d.ts +0 -25
  37. package/src/validations/handler.d.ts +0 -2
  38. package/src/validations/length.d.ts +0 -39
  39. package/src/validations/list.d.ts +0 -32
  40. package/src/validations/logical.d.ts +0 -75
  41. package/src/validations/multiple.d.ts +0 -31
  42. package/src/validations/namedRule.d.ts +0 -22
  43. package/src/validations/number.d.ts +0 -145
  44. package/src/validations/object.d.ts +0 -44
  45. package/src/validations/regex.d.ts +0 -217
  46. package/src/validations/string.d.ts +0 -53
package/index.d.ts ADDED
@@ -0,0 +1,2314 @@
1
+ import * as rxjs from 'rxjs';
2
+ import { Subject, Subscription } from 'rxjs';
3
+ import { TCurrencyLocalCode, TCurrencyCode } from '@gaignoux/currency';
4
+ import { OutgoingHttpHeaders } from 'http2';
5
+
6
+ type AllowOnly<T, K extends keyof T> = Pick<T, K> & {
7
+ [P in keyof Omit<T, K>]?: never;
8
+ };
9
+ type OneOf<T, K = keyof T> = K extends keyof T ? AllowOnly<T, K> : never;
10
+ type TValidationHandler = Record<string, (value: unknown, validations: TValidationMethods) => boolean>;
11
+
12
+ type TComponentPropsMappingSubset = keyof (Pick<TEventPropsEnum, 'onBlur' | 'onChange' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'onClick'> & Pick<TEventDataPropsEnum, 'onSubmit'>);
13
+ /**
14
+ * @type TComponentPropsMapping
15
+ * Represents the mapping of component properties for various events and actions.
16
+ * @property {string} [getValue] - component function name to get the value.
17
+ * @property {string} [setValue] - component function name to set the value.
18
+ * @property {string} [setErrorMessage] - component function name to set the error message.
19
+ * @property {string} [setErrorState] - component function name to set the error state.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const componentProps: TComponentPropsMapping = {
24
+ * getValue: 'getValueFunction',
25
+ * setValue: 'setValueFunction',
26
+ * onBlur: 'handleBlur',
27
+ * onClick: 'handleClick',
28
+ * onFocus: 'handleFocus',
29
+ * onKeyUp: 'handleKeyUp',
30
+ * onKeyDown: 'handleKeyDown',
31
+ * setErrorMessage: 'setErrorMessageFunction',
32
+ * setErrorState: 'setErrorStateFunction'
33
+ * };
34
+ * ```
35
+ * @interface
36
+ */
37
+ type TComponentPropsMapping = Partial<Record<TComponentPropsMappingSubset, string>> & {
38
+ getValue?: string;
39
+ setValue?: string;
40
+ setErrorMessage?: string;
41
+ setErrorState?: string;
42
+ };
43
+ /**
44
+ * @type TMapper
45
+ * Represents the mapping of a component, including the component type,
46
+ * name, events, and an optional function to handle value changes.
47
+ *
48
+ * @property {ElementType} component - The component that will represent the input.
49
+ * * @property {ElementType} asynccomponent - The component that will represent the input but dynamically imported (suspense/lazy).
50
+ * @property {string} componentName - The name of the component.
51
+ * @property {TComponentPropsMapping} [events] - Mapping event properties for the component.
52
+ * @property {TValueChangeEvent} [valueChangeEvent] - Optional function to handle value changes.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const mappers: TMapper<ElementType>[] = [
57
+ * {
58
+ * component: InputElement,
59
+ * componentName: 'input',
60
+ * events: {
61
+ * getValue: 'onChange2',
62
+ * onBlur: 'onBlur2',
63
+ * onFocus: 'onFocus2',
64
+ * }
65
+ * },
66
+ * {
67
+ * component: Container,
68
+ * componentName: 'row',
69
+ * },
70
+ * {
71
+ * component: Dropdown,
72
+ * componentName: 'dropdown',
73
+ * valueChangeEvent: (event: {
74
+ * id: string;
75
+ * label: string;
76
+ * value: string;
77
+ * }) => ({ _value: event.value, _stateValue: event.id }),
78
+ * },
79
+ * {
80
+ * component: DatePicker,
81
+ * componentName: 'datepicker',
82
+ * valueChangeEvent: (event: string) => event,
83
+ * },
84
+ * ];
85
+ * ```
86
+ * @interface
87
+ */
88
+ type TMapper<T> = {
89
+ componentName: string;
90
+ events?: TComponentPropsMapping;
91
+ valueChangeEvent?: TValueChangeEvent;
92
+ } & OneOf<{
93
+ component: T;
94
+ asynccomponent: T;
95
+ }>;
96
+
97
+ /**
98
+ * @interface IComponentSchema
99
+ * Represents the schema for a component within a form.
100
+ *
101
+ * @property {string} component - The type of component (e.g., 'input', 'button').
102
+ * @property {TProps} props - The properties of the component.
103
+ * @property {string} name - The name of the component.
104
+ * @property {string} nameToSubmit - The name of the field when submit values (optional).
105
+ * @property {TValidations} [validations] - The validation methods for the component.
106
+ * @property {TVisibility[]} [visibilityConditions] - The visibility conditions for the component.
107
+ * @property {TResetValueMethods[]} [resetValues] - The reset value methods for the component.
108
+ * @property {TApiEvent} [api] - The API configuration for the component.
109
+ * @property {TFormatters} [formatters] - The formatters for the component.
110
+ * @property {TMasks} [masks] - The masks for the component.
111
+ * @property {IComponentSchema[]} [children] - The child components.
112
+ * @property {boolean} visibility - visibility status the component will mount (to avoid SSR blinking)
113
+ * @property {boolean} persistValue - check this if you want the last visible value to be restored after a visiblity schema rule applied
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const schema: IComponentSchema = {
118
+ * component: 'input',
119
+ * props: { type: 'text', placeholder: 'Enter your name' },
120
+ * name: 'name',
121
+ * nameToSubmit: 'applicant.firstName',
122
+ * validations: {
123
+ * methods: {
124
+ * required: true,
125
+ * regex: '^([0-9]+)*$',
126
+ * max: 5,
127
+ * },
128
+ * eventMessages: {
129
+ * ON_FIELD_MOUNT: ['required'],
130
+ * ON_FIELD_CHANGE: ['regex', 'required'],
131
+ * ON_FIELD_BLUR: ['max', 'required'],
132
+ * },
133
+ * messages: {
134
+ * default: 'This field is required',
135
+ * regex: 'Only numbers are available.',
136
+ * max: 'Max of 5',
137
+ * },
138
+ * },
139
+ * visibilityConditions: [{ conditions: { field: 'age', value: 18 } }],
140
+ * resetValues: [{ field: 'age', resetTo: '' }],
141
+ * api: {
142
+ * defaultConfig: {
143
+ * config: { method: 'POST', url: 'https://api.example.com/submit' },
144
+ * events: [{ eventName: 'ON_FIELD_BLUR' }]
145
+ * }
146
+ * },
147
+ * formatters: { capitalize: true },
148
+ * masks: { currency: { align: 'left', decimal: '.', precision: 2, prefix: '$', thousands: ',' } },
149
+ * children: [],
150
+ * visibility: true,
151
+ * persistValue: true,
152
+ * };
153
+ * ```
154
+ */
155
+ interface IComponentSchema {
156
+ /** The type of component (e.g., 'input', 'button'). */
157
+ component: string;
158
+ /** The properties of the component. */
159
+ props?: TProps;
160
+ /** The name of the component. */
161
+ name: string;
162
+ /** The name of the field when submit values. */
163
+ nameToSubmit?: string;
164
+ /** The validation methods for the component. */
165
+ validations?: TValidations;
166
+ /** The API configuration for the component. */
167
+ api?: TApiEvent;
168
+ /** The visibility conditions for the component. */
169
+ visibilityConditions?: TVisibility[];
170
+ /** The reset value methods for the component. */
171
+ resetValues?: TResetValueMethods[];
172
+ /** The reset property values for the component. */
173
+ resetPropertyValues?: TResetPathMethods[];
174
+ /** The formatters for the component. */
175
+ formatters?: TFormatters;
176
+ /** The masks for the component. */
177
+ masks?: TMasks;
178
+ /** The child components. */
179
+ children?: IComponentSchema[];
180
+ /** Visibility status the component will mount (to avoid SSR blinking) */
181
+ visibility?: boolean;
182
+ /** Check this if you want the last visible value to be restored after a visiblity schema rule applied */
183
+ persistValue?: boolean;
184
+ }
185
+ interface IComponentSchemaAsFormField<T> extends IComponentSchema {
186
+ mapper?: TMapper<T>;
187
+ children?: IComponentSchemaAsFormField<T>[];
188
+ }
189
+ /**
190
+ * @interface IFormSchema
191
+ * Represents the schema for a form.
192
+ *
193
+ * @property {string} index - The unique index or identifier for the form.
194
+ * @property {string} [action] - The URL to which the form data will be submitted. (experimental)
195
+ * @property {string} [method] - The HTTP method used to submit the form (e.g., 'POST', 'GET') (experimental).
196
+ * @property {Record<string, unknown>} [initialValues] - The initial values for the form fields.
197
+ * @property {Record<string, unknown>} [iVars] - Dynamic key value pairs that change from any external source
198
+ * @property {IComponentSchema[]} [components] - The list of components included in the form.
199
+ * @property {boolean} [stopEventsOnSubmit] - stop all the events declared as callback on useForm/Form once form is submitted
200
+ * @property {TSchemaFormConfig} [config] - form configurations to change event debouncers and debugging tools
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const formSchema: IFormSchema = {
205
+ * index: 'userForm',
206
+ * initialValues: { name: '', email: '' },
207
+ * iVars: iVarsState,
208
+ * config: {
209
+ * defaultLogVerbose: true
210
+ * },
211
+ * components: [
212
+ * { component: 'input', name: 'name', props: { placeholder: 'Enter your name' } },
213
+ * { component: 'input', name: 'email', props: { placeholder: 'Enter your email' } }
214
+ * ]
215
+ * };
216
+ * ```
217
+ */
218
+ interface IFormSchema {
219
+ index: string;
220
+ action?: string;
221
+ method?: string;
222
+ config?: TSchemaFormConfig;
223
+ initialValues?: Record<string, unknown>;
224
+ iVars?: Record<string, unknown>;
225
+ components?: IComponentSchema[];
226
+ stopEventsOnSubmit?: boolean;
227
+ }
228
+
229
+ /**
230
+ * @type TFormValues<T>
231
+ * 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.
232
+ *
233
+ * @property {Generic Type} values - The current values of the form fields.
234
+ * @property {string[]} erroredFields - A list of field names that have errors.
235
+ * @property {boolean} isValid - Indicates whether the form is valid.
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const formValues: TFormValues = {
240
+ * values: { name: 'John', age: 30 },
241
+ * erroredFields: ['email'],
242
+ * isValid: false
243
+ * };
244
+ * ```
245
+ */
246
+ type TFormValues<T> = {
247
+ values: T;
248
+ metadata: unknown;
249
+ erroredFields: string[];
250
+ isValid: boolean;
251
+ };
252
+ /**
253
+ * @type TFormEntry
254
+ * Represents the entry configuration for a form.
255
+ *
256
+ * @property {IFormSchema} [schema] - The schema defining the structure and behavior of the form.
257
+ * @property {Record<string, unknown>} [initialValues] - The initial values for the form fields.
258
+ * @property {(data: TFormValues) => void} [onSubmit] - Callback function to handle form submission.
259
+ * @property {Subject<TFormDataPayload>} [dataSubject$] - data subject passed from formGroup instance
260
+ * @property {Subject<TFormValidationPayload>} [formValidSubject$] - formValid subject passed from formGroup instance
261
+ * @property {Subject<TFormSubmitPayload<unknown>>} [submitSubject$] - submit subject passed from formGroup instance
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * const formEntry: TFormEntry = {
266
+ * schema: [{ component: 'input', props: {}, name: 'name' }],
267
+ * initialValues: { name: 'John' },
268
+ * onSubmit: (data) => { console.log(data); }
269
+ * };
270
+ * ```
271
+ */
272
+ type TFormEntry = Omit<IFormSchema, 'components'> & {
273
+ schema?: IFormSchema;
274
+ mappers?: TMapper<unknown>[];
275
+ dataSubject$?: Subject<TFormDataPayload>;
276
+ formValidSubject$?: Subject<TFormValidationPayload>;
277
+ submitSubject$?: Subject<TFormSubmitPayload<unknown>>;
278
+ };
279
+
280
+ declare const TEMPLATE_AVALIABLE_SCOPES: readonly ["fields", "iVars", "form"];
281
+ declare const ALLOWED_RESET_PROPS_MUTATIONS: (keyof Pick<IFormField, "api" | "apiSchema" | "props" | "validations" | "visibilityConditions" | "resetValues">)[];
282
+
283
+ /** @virtual */
284
+
285
+ type TAllowedResetPropsMutations = (typeof ALLOWED_RESET_PROPS_MUTATIONS)[number];
286
+ /**
287
+ * @type TAllowedResetPropsMutationsEnum
288
+ * Represents the allowed properties to be changed on resetPropertyValues.
289
+ *
290
+ * @property {never} api - api property
291
+ * @property {never} apiSchema - apiSchema property
292
+ * @property {never} props - props property
293
+ * @property {never} validations - validations property
294
+ * @property {never} visibilityConditions - visibilityConditions property
295
+ * @property {never} resetValues - resetValues property
296
+ *
297
+ * @interface
298
+ */
299
+ type TAllowedResetPropsMutationsEnum = Record<TAllowedResetPropsMutations, never>;
300
+ /**
301
+ * @type TLengthValidation
302
+ * Represents the validation rules based on the length of the input.
303
+ *
304
+ * @property {'equal' | 'notEqual' | 'less' | 'lessOrEqual' | 'greater' | 'greaterOrEqual'} rule - The rule to apply.
305
+ * @property {number} target - The target value to compare against.
306
+ *
307
+ * @example
308
+ * ```typescript
309
+ * const lengthValidation: TLengthValidation = { rule: 'greaterOrEqual', target: 8 };
310
+ * ```
311
+ */
312
+ type TLengthValidation = {
313
+ rule: 'equal' | 'notEqual' | 'less' | 'lessOrEqual' | 'greater' | 'greaterOrEqual';
314
+ target: number;
315
+ };
316
+ /**
317
+ * @type TCallbackValidation
318
+ * A custom validation function.
319
+ *
320
+ * @param {unknown} value - The value to validate.
321
+ * @returns {boolean} - The result of the validation.
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * const callbackValidation: TCallbackValidation = (value) => typeof value === 'string';
326
+ * ```
327
+ */
328
+ type TCallbackValidation = (value: unknown) => boolean;
329
+ /**
330
+ * @type TBetweenValidation
331
+ * Represents validation rules that check if a value is between a range.
332
+ *
333
+ * @property {number} start - The start of the range.
334
+ * @property {number} end - The end of the range.
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * const betweenValidation: TBetweenValidation = { start: 1, end: 10 };
339
+ * ```
340
+ */
341
+ type TBetweenValidation = {
342
+ start: number;
343
+ end: number;
344
+ };
345
+ /**
346
+ * @type TCreditCardMatch
347
+ * Represents the options for credit card matching.
348
+ *
349
+ * @property {string} numberCard - The credit card number.
350
+ * @property {string[]} availableOptions - The available options for matching.
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * const creditCardMatch: TCreditCardMatch = { numberCard: '1234', availableOptions: ['Visa', 'MasterCard'] };
355
+ * ```
356
+ */
357
+ type TCreditCardMatch = {
358
+ numberCard: string;
359
+ availableOptions: string[];
360
+ };
361
+ /**
362
+ * @type TDocumentValidation
363
+ * Represents validation for specific document types.
364
+ *
365
+ * @property {'NIF' | 'NIE' | 'CIF' | 'IBAN'} type - The type of document.
366
+ * @property {TCurrencyLocalCode} [locale] - The locale code for validation.
367
+ *
368
+ * @example
369
+ * ```typescript
370
+ * const documentValidation: TDocumentValidation = { type: 'NIF', locale: 'ES' };
371
+ * ```
372
+ */
373
+ type TDocumentValidation = {
374
+ type: 'NIF' | 'NIE' | 'CIF' | 'IBAN';
375
+ locale?: TCurrencyLocalCode;
376
+ };
377
+ /**
378
+ * @type TDateOperatorsValidation
379
+ * Represents the operators used for date validation conditions.
380
+ *
381
+ * @property {'<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin'}
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * const operator: TDateOperatorsValidation = '<';
386
+ * ```
387
+ */
388
+ type TDateOperatorsValidation = '<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin';
389
+ /**
390
+ * @type TConditionsValidationSet
391
+ * Represents a single validation condition set.
392
+ *
393
+ * @property {boolean} [forceDefinedOrigin] - Flag to force the origin value to be defined.
394
+ * @property {boolean} [forceDefinedTarget] - Flag to force the target value to be defined.
395
+ * @property {string | number | boolean} [origin] - The origin value for the condition.
396
+ * @property {TDateOperatorsValidation} condition - The validation condition operator.
397
+ * @property {string | number | boolean} [target] - The target value for the condition.
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * const conditionSet: TConditionsValidationSet = {
402
+ * forceDefinedOrigin: true,
403
+ * forceDefinedTarget: true,
404
+ * origin: '2023-01-01',
405
+ * condition: '>',
406
+ * target: '2022-01-01'
407
+ * };
408
+ * ```
409
+ */
410
+ type TConditionsValidationSet = {
411
+ forceDefinedOrigin?: boolean;
412
+ forceDefinedTarget?: boolean;
413
+ origin?: string | number | boolean | null;
414
+ condition: TDateOperatorsValidation;
415
+ target?: string | number | boolean;
416
+ };
417
+ /**
418
+ * @type TConditionsValidation
419
+ * Represents a set of validation conditions.
420
+ *
421
+ * @property {'and' | 'or'} rule - The logical rule to combine the conditions (AND/OR).
422
+ * @property {TConditionsValidationSet[]} set - The array of validation condition sets.
423
+ * @property {TConditionsValidation} [conditions] - Nested conditions for more complex validation logic.
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * const conditionsValidation: TConditionsValidation = {
428
+ * rule: 'and',
429
+ * set: [
430
+ * {
431
+ * forceDefinedOrigin: true,
432
+ * forceDefinedTarget: true,
433
+ * origin: '2023-01-01',
434
+ * condition: '>',
435
+ * target: '2022-01-01'
436
+ * }
437
+ * ],
438
+ * conditions: {
439
+ * rule: 'or',
440
+ * set: [
441
+ * {
442
+ * origin: true,
443
+ * condition: '!!origin',
444
+ * target: false
445
+ * }
446
+ * ]
447
+ * }
448
+ * };
449
+ * ```
450
+ */
451
+ type TConditionsValidation = {
452
+ rule: 'and' | 'or';
453
+ set: TConditionsValidationSet[];
454
+ conditions?: TConditionsValidation;
455
+ };
456
+ type TAvailableValidations = Omit<TValidationMethods, 'multipleValidations'> | TGenericValidationRule;
457
+ /**
458
+ * @type TMultipleValidation
459
+ * Represents a set of multiple validation methods combined with a logical rule.
460
+ *
461
+ * @property {'AND' | 'OR' | 'NOT'} rule - The logical rule to combine the validation methods (AND, OR, NOT).
462
+ * @property {TAvailableValidations} validations - The validation methods to be combined.
463
+ *
464
+ * @example
465
+ * ```typescript
466
+ * const multipleValidation: TMultipleValidation = {
467
+ * rule: 'AND',
468
+ * validations: {
469
+ * required: true,
470
+ * min: 5,
471
+ * max: 10
472
+ * }
473
+ * };
474
+ * ```
475
+ */
476
+ type TMultipleValidation = {
477
+ rule: 'AND' | 'OR' | 'NOT';
478
+ validations: TAvailableValidations;
479
+ };
480
+ /**
481
+ * @type TBetweenDatesValidation
482
+ * Represents a validation method to check if a value falls between specified dates.
483
+ *
484
+ * @property {TDateValidation[]} [TBetweenDatesValidation] - An array of date validation methods.
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * const betweenDatesValidation: TBetweenDatesValidation = [
489
+ * {
490
+ * onlyValidDate: true,
491
+ * operator: '>=',
492
+ * origin: {
493
+ * format: 'MMDDYYYY',
494
+ * intervals: {
495
+ * years: 1
496
+ * }
497
+ * },
498
+ * target: {
499
+ * value: Date.now(),
500
+ * format: 'timestamp',
501
+ * value: '01/01/2023',
502
+ * }
503
+ * },
504
+ * {
505
+ * onlyValidDate: true,
506
+ * operator: '<=',
507
+ * origin: {
508
+ * format: 'MMDDYYYY',
509
+ * intervals: {
510
+ * years: 1
511
+ * }
512
+ * },
513
+ * target: {
514
+ * format: 'timestamp',
515
+ * value: '31/12/2023',
516
+ * }
517
+ * }
518
+ * ];
519
+ * ```
520
+ */
521
+ type TBetweenDatesValidation = TDateValidation[];
522
+ /**
523
+ * @type TDateFormatsValidation
524
+ * Represents the supported date formats for validation.
525
+ *
526
+ * @type {'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp'}
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * const dateFormat: TDateFormatsValidation = 'MMDDYYYY';
531
+ * ```
532
+ */
533
+ type TDateFormatsValidation = 'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp';
534
+ type TDateInterval = {
535
+ years?: number;
536
+ months?: number;
537
+ days?: number;
538
+ };
539
+ /**
540
+ * @type TDateValidation
541
+ * Represents a validation method for date values.
542
+ *
543
+ * @property {boolean} [onlyValidDate] - Flag to validate only if the date is valid.
544
+ * @property {TDateOperatorsValidation} operator - The validation operator to be used.
545
+ * @property {Object} origin - The origin date configuration.
546
+ * @property {string | number} [origin.value] - The origin date value.
547
+ * @property {TDateFormatsValidation} origin.format - The format of the origin date.
548
+ * @property {Object} [origin.intervals] - The intervals to add to the origin date for comparison.
549
+ * @property {number} [origin.intervals.years] - The number of years to add.
550
+ * @property {number} [origin.intervals.months] - The number of months to add.
551
+ * @property {number} [origin.intervals.days] - The number of days to add.
552
+ * @property {Object} [target] - The target date configuration.
553
+ * @property {string | number} target.value - The target date value.
554
+ * @property {TDateFormatsValidation} target.format - The format of the target date.
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * const dateValidation: TDateValidation = {
559
+ * onlyValidDate: true,
560
+ * operator: '===',
561
+ * origin: {
562
+ * value: '10/10/2022',
563
+ * format: 'MMDDYYYY',
564
+ * intervals: {
565
+ * years: 1
566
+ * }
567
+ * },
568
+ * target: {
569
+ * value: Date.now(),
570
+ * format: 'timestamp'
571
+ * }
572
+ * };
573
+ * ```
574
+ */
575
+ type TDateValidation = {
576
+ onlyValidDate?: boolean;
577
+ operator: TDateOperatorsValidation;
578
+ origin: {
579
+ value?: string | number;
580
+ format: TDateFormatsValidation;
581
+ /**
582
+ * Intervals to compare with the original date.
583
+ *
584
+ * It will use today's date for comparison.
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * origin date = 10/10/2022
589
+ * interval.year = 1
590
+ * operator = '==='
591
+ * ```
592
+ *
593
+ * It will compare (10/10/2022 + 1) with the current date and check if they are the same
594
+ */
595
+ intervals?: TDateInterval;
596
+ };
597
+ target?: {
598
+ value: string | number;
599
+ format: TDateFormatsValidation;
600
+ };
601
+ };
602
+ /**
603
+ * @type TValidationMethods
604
+ * Represents the various validation methods that can be applied to form fields.
605
+ *
606
+ * @property {number} [max] - Maximum value or length.
607
+ * @property {number} [min] - Minimum value or length.
608
+ * @property {number} [lessThan] - Minimum value or length.
609
+ * @property {number} [greaterThan] - Minimum value or length.
610
+ * @property {TLengthValidation} [length] - Length validation rule.
611
+ * @property {boolean} [required] - Indicates if the field is required.
612
+ * @property {unknown} [value] - Specific value to match.
613
+ * @property {string} [regex] - Regular expression for validation.
614
+ * @property {boolean} [email] - Indicates if the value should be a valid email.
615
+ * @property {boolean} [url] - Indicates if the value should be a valid URL.
616
+ * @property {boolean} [onlyLetters] - Indicates if the value should contain only letters.
617
+ * @property {boolean} [notAllowSpaces] - Indicates if spaces are not allowed.
618
+ * @property {TCallbackValidation} [callback] - Custom validation callback function.
619
+ * @property {boolean} [isNumber] - Indicates if the value should be a number.
620
+ * @property {boolean} [bool] - Indicates if the value should be a boolean or a string that can be converted to a boolean.
621
+ * @property {boolean | string} [exists] - Indicates if the value should exist or match a specific existence condition.
622
+ * @property {boolean} [hasNoExtraSpaces] - Indicates if there should be no extra spaces.
623
+ * @property {boolean} [notEmpty] - Indicates if the field should not be empty.
624
+ * @property {TBetweenValidation} [between] - Validation rule for range between two values.
625
+ * @property {boolean} [sequential] - Indicates if the value should be sequential.
626
+ * @property {boolean} [repeated] - Indicates if the value should not be repeated.
627
+ * @property {string[] | number[]} [includes] - Array of values that should be included.
628
+ * @property {string[]} [isCreditCard] - Array of valid credit card numbers.
629
+ * @property {TCreditCardMatch} [isCreditCodeMatch] - Validation rule for credit card matching.
630
+ * @property {string[]} [isCreditCardAndLength] - Array of valid credit card numbers with length check.
631
+ * @property {TDocumentValidation} [document] - Document validation rule.
632
+ * @property {TConditionsValidation} [conditions] - Conditional validation rules.
633
+ * @property {TMultipleValidation} [multipleValidations] - Multiple validation rules combined with a logical rule.
634
+ * @property {TBetweenDatesValidation} [betweenDates] - Validation rule for checking if a date falls between two dates.
635
+ * @property {TDateValidation} [date] - Validation rule for date values.
636
+ * @property {TDateFormatsValidation} [validDate] - Validation rule for valid date formats.
637
+ *
638
+ * @example
639
+ * ```typescript
640
+ * const validationMethods: TValidationMethods = {
641
+ * max: 100,
642
+ * min: 1,
643
+ * lessThan: 1995,
644
+ * greaterThan: 82000,
645
+ * length: { rule: 'greaterOrEqual', target: 8 },
646
+ * required: true,
647
+ * regex: '^[a-zA-Z0-9]+$',
648
+ * email: true,
649
+ * conditions: {
650
+ * rule: 'and',
651
+ * set: [
652
+ * {
653
+ * forceDefinedOrigin: true,
654
+ * forceDefinedTarget: true,
655
+ * origin: '2023-01-01',
656
+ * condition: '>',
657
+ * target: '2022-01-01'
658
+ * }
659
+ * ]
660
+ * },
661
+ * multipleValidations: {
662
+ * rule: 'AND',
663
+ * validations: {
664
+ * required: true,
665
+ * min: 5,
666
+ * max: 10
667
+ * }
668
+ * },
669
+ * betweenDates: {
670
+ * start: Date.parse('2023-01-01'),
671
+ * end: Date.parse('2023-12-31'),
672
+ * isIncludedBoundaries: true
673
+ * },
674
+ * date: {
675
+ * operator: '===',
676
+ * origin: {
677
+ * value: '10/10/2022',
678
+ * format: 'MMDDYYYY',
679
+ * intervals: {
680
+ * years: 1
681
+ * }
682
+ * },
683
+ * target: {
684
+ * value: Date.now(),
685
+ * format: 'timestamp'
686
+ * }
687
+ * },
688
+ * validDate: 'MMDDYYYY'
689
+ * };
690
+ * ```
691
+ */
692
+ type TValidationMethods = {
693
+ /** Maximum value or length. */
694
+ max?: number;
695
+ /** Minimum value or length. */
696
+ min?: number;
697
+ /** Minimum value or length. */
698
+ lessThan?: number;
699
+ /** Minimum value or length. */
700
+ greaterThan?: number;
701
+ /** Length validation rule. */
702
+ length?: TLengthValidation;
703
+ /** Indicates if the field is required. */
704
+ required?: boolean;
705
+ /** Specific value to match. */
706
+ value?: unknown;
707
+ /** Regular expression for validation. */
708
+ regex?: string;
709
+ /** Indicates if the value should be a valid email. */
710
+ email?: boolean;
711
+ /** Indicates if the value should be a valid URL. */
712
+ url?: boolean;
713
+ /** Indicates if the value should contain only letters. */
714
+ onlyLetters?: boolean;
715
+ /** Indicates if spaces are not allowed. */
716
+ notAllowSpaces?: boolean;
717
+ /** Custom validation callback function. */
718
+ callback?: TCallbackValidation;
719
+ /** Indicates if the value should be a number. */
720
+ isNumber?: boolean;
721
+ /** Indicates if the value should be a boolean or a string that can be converted to a boolean. */
722
+ bool?: boolean | string;
723
+ /** Indicates if the value should exist or match a specific existence condition. */
724
+ exists?: boolean | string;
725
+ /** Indicates if there should be no extra spaces. */
726
+ hasNoExtraSpaces?: boolean;
727
+ /** Indicates if the field should not be empty. */
728
+ notEmpty?: boolean;
729
+ /** Validation rule for range between two values. */
730
+ between?: TBetweenValidation;
731
+ /** Indicates if the value should be sequential. */
732
+ sequential?: boolean;
733
+ /** Indicates if the value should not be repeated. */
734
+ repeated?: boolean;
735
+ /** Array of values that should be included. */
736
+ includes?: (string | number)[];
737
+ /** Array of valid credit card numbers. */
738
+ isCreditCard?: string[];
739
+ /** Validation rule for credit card matching. */
740
+ isCreditCodeMatch?: TCreditCardMatch;
741
+ /** Array of valid credit card numbers with length check. */
742
+ isCreditCardAndLength?: string[];
743
+ /** Document validation rule. */
744
+ document?: TDocumentValidation;
745
+ /** Conditional validation rules. */
746
+ conditions?: TConditionsValidation;
747
+ /** Multiple validation rules combined with a logical rule. */
748
+ multipleValidations?: TMultipleValidation;
749
+ /** Validation rule for checking if a date falls between two dates. */
750
+ betweenDates?: TBetweenDatesValidation;
751
+ /** Validation rule for date values. */
752
+ date?: TDateValidation;
753
+ /** Validation rule for valid date formats. */
754
+ validDate?: TDateFormatsValidation;
755
+ };
756
+ /**
757
+ * @type {Object.<string, TValidationMethods>} TGenericValidationRule
758
+ * Represents a generic validation rule where each key is associated with a set of validation methods.
759
+ *
760
+ * @example
761
+ * const genericValidationRule = {
762
+ * email: {
763
+ * required: true,
764
+ * email: true,
765
+ * },
766
+ * password: {
767
+ * required: true,
768
+ * minLength: 8,
769
+ * },
770
+ * };
771
+ */
772
+ type TGenericValidationRule = Record<string, TValidationMethods>;
773
+ /**
774
+ * @type {TValidationMethods | TGenericValidationRule} TSchemaValidation
775
+ * Represents the schema validation which can be either a set of validation methods or a generic validation rule.
776
+ *
777
+ * @example
778
+ * const schemaValidation = {
779
+ * required: true,
780
+ * maxLength: 10,
781
+ * };
782
+ *
783
+ * const genericSchemaValidation = {
784
+ * email: {
785
+ * required: true,
786
+ * email: true,
787
+ * },
788
+ * password: {
789
+ * required: true,
790
+ * minLength: 8,
791
+ * },
792
+ * };
793
+ * @interface
794
+ */
795
+ type TSchemaValidation = TValidationMethods | TGenericValidationRule;
796
+ /**
797
+ * Formatter types
798
+ * @type TSplitterFormatterValue
799
+ * Represents a value and its position for splitting or formatting purposes.
800
+ *
801
+ * @property {string} value - The value to be split or formatted.
802
+ * @property {number} position - The position for splitting or formatting.
803
+ *
804
+ * @example
805
+ * ```typescript
806
+ * const splitterFormatter: TSplitterFormatterValue = { value: '-', position: 3 };
807
+ * ```
808
+ */
809
+ type TSplitterFormatterValue = {
810
+ value: string;
811
+ position: number;
812
+ };
813
+ /**
814
+ * @type TFormatters
815
+ * Represents the various formatting options that can be applied to form field values.
816
+ *
817
+ * @property {boolean} [dotEvery3chars] - Add a dot every 3 characters.
818
+ * @property {boolean} [capitalize] - Capitalize the value.
819
+ * @property {boolean} [uppercase] - Convert the value to uppercase.
820
+ * @property {boolean} [onlyNumbers] - Allow only numbers.
821
+ * @property {boolean} [onlyLetters] - Allow only letters.
822
+ * @property {Pick<TCurrencyMask, 'precision' | 'decimal'>} [onlyFloatNumber] - Allow only float numbers with specific precision and decimal.
823
+ * @property {string} [regex] - Regular expression for formatting.
824
+ * @property {string[]} [gapsCreditCard] - Gaps to insert in credit card numbers.
825
+ * @property {(value: unknown) => unknown} [callback] - Custom formatter callback function.
826
+ * @property {TSplitterFormatterValue[]} [splitter] - Splitter values for formatting.
827
+ * @property {boolean} [trim] - Removes whitespace from both ends of this string and returns a new string, without modifying the original string.
828
+ * @property {number} [maxLength] - Truncates the input value to a specified maximum length if necessary.
829
+ *
830
+ * @example
831
+ * ```json
832
+ * {
833
+ * formatters: {
834
+ * dotEvery3chars: true,
835
+ * capitalize: true,
836
+ * uppercase: true,
837
+ * onlyNumbers: true,
838
+ * regex: '^[a-zA-Z0-9]+$',
839
+ * gapsCreditCard: [' ', ' '],
840
+ * callback: (value) => value.toString().toUpperCase(),
841
+ * splitter: [{ value: '-', position: 3 }],
842
+ * trim: true,
843
+ * maxLength: 15
844
+ * }
845
+ * }
846
+ * ```
847
+ */
848
+ type TFormatters = {
849
+ /** Add a dot every 3 characters. */
850
+ dotEvery3chars?: boolean;
851
+ /** Capitalize the value. */
852
+ capitalize?: boolean;
853
+ /** Convert the value to uppercase. */
854
+ uppercase?: boolean;
855
+ /** Allow only numbers. */
856
+ onlyNumbers?: boolean;
857
+ /** Allow only letters. */
858
+ onlyLetters?: boolean;
859
+ /** Allow only float numbers with specific precision and decimal. */
860
+ onlyFloatNumber?: Pick<TCurrencyMask, 'precision' | 'decimal'>;
861
+ /** Regular expression for formatting. */
862
+ regex?: string;
863
+ gapsCreditCard?: string[] | boolean;
864
+ callback?: ((value: unknown) => unknown) | null;
865
+ splitter?: TSplitterFormatterValue[];
866
+ /** Removes whitespace from both ends of this string and returns a new string, without modifying the original string. */
867
+ trim?: boolean;
868
+ /** Truncates the input value to a specified maximum length if necessary. */
869
+ maxLength?: number;
870
+ };
871
+ /**
872
+ * Mask types
873
+ * @type TCurrencyMask
874
+ * Represents the mask configuration for currency values.
875
+ *
876
+ * @property {'left' | 'right'} [align] - The alignment of the currency symbol. (default: right)
877
+ * @property {string} [decimal] - The decimal separator. (default: '.')
878
+ * @property {number} [precision] - The number of decimal places. (default: 2)
879
+ * @property {TCurrencyCode} [prefix] - The currency symbol prefix. (default: '$')
880
+ * @property {string} [thousands] - The thousands separator. (default: ',')
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * const currencyMask: TCurrencyMask = {
885
+ * align: 'left',
886
+ * decimal: '.',
887
+ * precision: 2,
888
+ * prefix: '$',
889
+ * thousands: ','
890
+ * };
891
+ * ```
892
+ */
893
+ type TCurrencyMask = {
894
+ align?: 'left' | 'right';
895
+ decimal?: string;
896
+ precision?: number;
897
+ prefix?: TCurrencyCode;
898
+ thousands?: string;
899
+ };
900
+ /**
901
+ * @type TMaskGeneric
902
+ * Represents a generic mask configuration.
903
+ *
904
+ * @property {number} to - The ending position of the mask.
905
+ * @property {number} from - The starting position of the mask.
906
+ * @property {string} mask - The mask pattern to apply.
907
+ *
908
+ * @example
909
+ * ```typescript
910
+ * const maskGeneric: TMaskGeneric = { to: 4, from: 0, mask: '****' };
911
+ * ```
912
+ */
913
+ type TMaskGeneric = {
914
+ to: number;
915
+ from: number;
916
+ mask: string;
917
+ };
918
+ /**
919
+ * @type TMasks
920
+ * Represents the different types of masks that can be applied to form field values.
921
+ *
922
+ * @property {TCurrencyMask} [currency] - Mask for currency values.
923
+ * @property {TMaskGeneric[]} [generic] - Array of generic masks.
924
+ * @property {string} [custom] - Custom mask pattern.
925
+ * @property {boolean} [secureCreditCard] - Mask for securing credit card values.
926
+ * @property {boolean} [card] - Mask for card values.
927
+ * @property {boolean} [cardDate] - Mask for card date values.
928
+ * @property {boolean} [fein] - Mask for FEIN (Federal Employer Identification Number).
929
+ * @property {string | number} [replaceAll] - Value to replace all matches.
930
+ * @property {(value: unknown) => string} [callback] - Custom mask callback function.
931
+ *
932
+ * @example
933
+ * ```typescript
934
+ * const masks: TMasks = {
935
+ * currency: { align: 'left', decimal: '.', precision: 2, prefix: '$', thousands: ',' },
936
+ * generic: [{ to: 4, from: 0, mask: '****' }],
937
+ * custom: '###-##-####',
938
+ * secureCreditCard: true,
939
+ * card: true,
940
+ * cardDate: true,
941
+ * fein: true,
942
+ * replaceAll: '*',
943
+ * callback: (value) => value.toString().replace(/\d/g, '*')
944
+ * };
945
+ * ```
946
+ */
947
+ type TMasks = {
948
+ /** Mask for currency values. */
949
+ currency?: TCurrencyMask;
950
+ /** Array of generic masks. */
951
+ generic?: TMaskGeneric[];
952
+ /** Custom mask pattern. */
953
+ custom?: string | null;
954
+ /** Mask for securing credit card values. */
955
+ secureCreditCard?: boolean;
956
+ /** Mask for card values. */
957
+ card?: boolean;
958
+ /** Mask for card date values. */
959
+ cardDate?: boolean;
960
+ /** Mask for FEIN (Federal Employer Identification Number). */
961
+ fein?: boolean;
962
+ /** Value to replace all matches. */
963
+ replaceAll?: string | number;
964
+ /** Custom mask callback function. */
965
+ callback?: (value: unknown) => string;
966
+ };
967
+ /**
968
+ * @type TVisibility
969
+ * Represents the visibility conditions for form fields based on validations.
970
+ *
971
+ * @property {boolean} showOnlyIfTrue - Enables visibility of fields only if any or all validation conditions are positive.
972
+ * @property {TSchemaValidation} validations - The validation methods to determine visibility.
973
+ * @property {string[] | string} fields - The fields to be shown or hidden based on validations.
974
+ * @property {string[]} events - Events where visibility will occur.
975
+ *
976
+ * @example
977
+ * ```typescript
978
+ * const visibility: TVisibility = {
979
+ * showOnlyIfTrue: false,
980
+ * validations: { required: true },
981
+ * fields: ['fieldName'],
982
+ * events: ['ON_FIELD_CHANGE']
983
+ * };
984
+ * ```
985
+ */
986
+ type TVisibility = {
987
+ showOnlyIfTrue?: boolean;
988
+ validations: TSchemaValidation;
989
+ fields: string[] | string;
990
+ events: TEvents[];
991
+ };
992
+ /**
993
+ * @type TResetValueMethods
994
+ * @extends TVisibility with methods to reset values.
995
+ * @summary schema method to reset values from event
996
+ * much cool such wow
997
+ *
998
+ * @property {unknown[] | unknown} resettledValue - The values to reset.
999
+ * @property {Partial<TEvents>[]} events - events that will react to the value reset
1000
+ * @property {string | string[]} fields - fields that will react to the value reset
1001
+ * @property {TSchemaValidation} validations - validations to trigger the property reset
1002
+ *
1003
+ *
1004
+ * @example
1005
+ * ```typescript
1006
+ * const resetValueMethods: TResetValueMethods = {
1007
+ * validations: { required: true },
1008
+ * fields: ['fieldName'],
1009
+ * resettledValue: [''],
1010
+ * events: ['ON_FIELD_CHANGE]
1011
+ * };
1012
+ * ```
1013
+ * @interface
1014
+ */
1015
+ type TResetValueMethods = Omit<TVisibility, 'showOnlyIfTrue' | 'validations'> & {
1016
+ resettledValue: unknown[] | unknown;
1017
+ validations?: TSchemaValidation;
1018
+ };
1019
+ /**
1020
+ * @type TResetPathMethods
1021
+ * Method to reset some field properties other than component props or field value
1022
+ *
1023
+ * @property {TAllowedResetPropsMutations} property property to be changed, ex: api, resetValues, etc..
1024
+ * @property {string} path path where the property to be changed is located
1025
+ * @property {string} field field that will recieve the property change
1026
+ * @property {unknown} resettledValue value to be replaced onto the property
1027
+ * @property {TSchemaValidation} validations validations rules to be validated to change the property value
1028
+ * @property {Partial<TEvents>[]} events events to listen to apply this change
1029
+ *
1030
+ * @example
1031
+ * ```typescript
1032
+ * const resetValueMethods: TResetValueMethods = {
1033
+ * validations: { required: true },
1034
+ * fields: ['fieldName'],
1035
+ * resettledValue: ['']
1036
+ * };
1037
+ * ```
1038
+ */
1039
+ type TResetPathMethods = {
1040
+ property: TAllowedResetPropsMutations;
1041
+ path: string;
1042
+ field: string;
1043
+ resettledValue: unknown;
1044
+ validations: TSchemaValidation;
1045
+ events: Partial<TEvents>[];
1046
+ };
1047
+ /**
1048
+ * @type TApiConfig
1049
+ * Represents the configuration for an API request.
1050
+ *
1051
+ * @property {'GET' | 'POST'} method - The HTTP method for the request.
1052
+ * @property {string} url - The URL for the request.
1053
+ * @property {OutgoingHttpHeaders} [headers] - The headers for the request.
1054
+ * @property {Record<string, string>} queryParams - query parameters for request.
1055
+ * @property {string} [resultPath] - The path to extract the result from the response.
1056
+ * @property {unknown} [fallbackValue] - The fallback value if the request fails.
1057
+ * @property {TSchemaValidation} preConditions - validation conditions to execute the API call
1058
+ * @property {boolean} blockRequestWhenInvalid - blocks request when field validation fails
1059
+ *
1060
+ * @example
1061
+ * ```typescript
1062
+ * const apiConfig: TApiConfig = {
1063
+ * method: 'POST',
1064
+ * url: 'https://api.example.com/data',
1065
+ * headers: { 'Content-Type': 'application/json' },
1066
+ * resultPath: 'data.results',
1067
+ * fallbackValue: [],
1068
+ * preConditions: {
1069
+ * required: true,
1070
+ * }
1071
+ * blockRequestWhenInvalid: true,
1072
+ * };
1073
+ * ```
1074
+ */
1075
+ type TApiConfig = {
1076
+ /** The HTTP method for the request. */
1077
+ method: 'GET' | 'POST';
1078
+ /** The URL for the request. */
1079
+ url: string;
1080
+ /** The body payload for the request. */
1081
+ body?: Record<string, unknown>;
1082
+ /** The headers for the request. */
1083
+ headers?: OutgoingHttpHeaders;
1084
+ /** Query parameters for the request. */
1085
+ queryParams?: Record<string, string>;
1086
+ /** The path to extract the result from the response. */
1087
+ resultPath?: string;
1088
+ /** The fallback value if the request fails. */
1089
+ fallbackValue?: unknown;
1090
+ /** Validation conditions to execute the API call. */
1091
+ preConditions?: TSchemaValidation;
1092
+ /** Blocks request when field validation fails. */
1093
+ blockRequestWhenInvalid?: boolean;
1094
+ /** Custom transform callback for the request payload. */
1095
+ transform?: {
1096
+ callback(callbackPayload: {
1097
+ payload: unknown;
1098
+ formValues: TFormValues<unknown>;
1099
+ }): unknown;
1100
+ };
1101
+ };
1102
+ /**
1103
+ * @type TProps
1104
+ * Represents the properties for a component.
1105
+ */
1106
+ type TProps = Record<string, unknown>;
1107
+ /**
1108
+ * @type TValidations
1109
+ * Represents the validation configuration for form fields, including methods, event-specific messages, and error messages.
1110
+ *
1111
+ * @property {TSchemaValidation} methods - The validation methods to be applied.
1112
+ * @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
1113
+ * @property {TErrorMessages} messages - The general error messages for validation methods.
1114
+ *
1115
+ * @interface
1116
+ *
1117
+ * @example
1118
+ * ```typescript
1119
+ * const validations: TValidations = {
1120
+ * methods: {
1121
+ * max: 100,
1122
+ * required: true,
1123
+ * regex: '^[a-zA-Z0-9]+$',
1124
+ * },
1125
+ * eventMessages: {
1126
+ * ON_FIELD_MOUNT: ['required'],
1127
+ * ON_FIELD_CHANGE: ['regex', 'required'],
1128
+ * ON_FIELD_BLUR: ['max', 'required'],
1129
+ * },
1130
+ * messages: {
1131
+ * default: 'This field is required',
1132
+ * max: 'Value exceeds the maximum limit',
1133
+ * regex: 'Value does not match the pattern',
1134
+ * },
1135
+ * };
1136
+ * ```
1137
+ */
1138
+ type TValidations = {
1139
+ methods: TSchemaValidation;
1140
+ eventMessages?: TEventMessages;
1141
+ messages?: TErrorMessages;
1142
+ };
1143
+ /**
1144
+ * @type TValidations
1145
+ * Represents the validation configuration for form fields, including methods, event-specific messages, and error messages.
1146
+ *
1147
+ * @property {TSchemaValidation} methods - The validation methods to be applied.
1148
+ * @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
1149
+ * @property {TErrorMessages} messages - The general error messages for validation methods.
1150
+ *
1151
+ * @example
1152
+ * ```typescript
1153
+ * const eventMessages: {
1154
+ * ON_FIELD_MOUNT: ['required'],
1155
+ * ON_FIELD_CHANGE: ['regex', 'required'],
1156
+ * ON_FIELD_BLUR: ['max', 'required'],
1157
+ * },
1158
+ * ```
1159
+ * @interface
1160
+ */
1161
+ type TEventMessages = Partial<Record<TEvents, TEventMessagesValidationMethods[]>>;
1162
+ /**
1163
+ * @type TEventMessagesValidationMethods
1164
+ *
1165
+ * allowed validation methods to trigger the event messages desc
1166
+ *
1167
+ * @property {keyof TValidationMethods | TAnyKey;} TEventMessagesValidationMethods - allowed validation methods to trigger the event messages
1168
+ */
1169
+ type TEventMessagesValidationMethods = keyof TValidationMethods | TAnyKey;
1170
+ type TAnyKey = string & NonNullable<unknown>;
1171
+ /**
1172
+ * @type TErrorMessages
1173
+ * Represents the error messages for different validation methods.
1174
+ * @property {string} default - the message to display regardless the validation
1175
+ *
1176
+ * @example
1177
+ * ```typescript
1178
+ * const errorMessages: TErrorMessages = {
1179
+ * required: 'This field is required.',
1180
+ * max: 'The value cannot exceed the maximum limit.'
1181
+ * default: 'Default error message'
1182
+ * };
1183
+ * ```
1184
+ * @interface
1185
+ */
1186
+ type TErrorMessages = Partial<Record<keyof TSchemaValidation | 'default' | (string & NonNullable<unknown>), string>>;
1187
+ /**
1188
+ * Represents an event configuration with a specific type.
1189
+ *
1190
+ * @template T
1191
+ * @property {T} config - The configuration of the event.
1192
+ * @property {Partial<TEvents>[]} events - The events associated with the configuration.
1193
+ */
1194
+ type TEvent<T> = {
1195
+ config: T;
1196
+ events: TEvents[];
1197
+ };
1198
+ /**
1199
+ * Represents the API event configurations.
1200
+ *
1201
+ * @property {TEvent<TApiConfig>} [defaultConfig] - The default event configuration.
1202
+ * @property {Record<string, TEvent<TApiConfig>>} [configs] - Named event configurations.
1203
+ *
1204
+ * @example
1205
+ * ```typescript
1206
+ * const apiEvent: TApiEvent = {
1207
+ * defaultConfig: {
1208
+ * config: {
1209
+ * method: 'POST',
1210
+ * url: 'https://api.example.com/data',
1211
+ * headers: { 'Content-Type': 'application/json' },
1212
+ * resultPath: 'data.results',
1213
+ * fallbackValue: [],
1214
+ * preConditions: {
1215
+ * required: true,
1216
+ * },
1217
+ * blockRequestWhenInvalid: true,
1218
+ * },
1219
+ * events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
1220
+ * },
1221
+ * configs: {
1222
+ * example_config_name: {
1223
+ * config: {
1224
+ * method: 'POST',
1225
+ * url: 'https://api.example.com/data',
1226
+ * headers: { 'Content-Type': 'application/json' },
1227
+ * resultPath: 'data.results',
1228
+ * fallbackValue: [],
1229
+ * preConditions: {
1230
+ * required: true,
1231
+ * },
1232
+ * blockRequestWhenInvalid: true,
1233
+ * },
1234
+ * events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
1235
+ * },
1236
+ * },
1237
+ * };
1238
+ * ```
1239
+ */
1240
+ type TApiEvent = {
1241
+ defaultConfig?: TEvent<TApiConfig>;
1242
+ configs?: Record<string, TEvent<TApiConfig>>;
1243
+ };
1244
+ /**
1245
+ * Represents the API response return payload for handling.
1246
+ *
1247
+ * @property {unknown} response - The default response.
1248
+ * @property {number | null} status - response http status number.
1249
+ */
1250
+ type TApiResponsePayload = {
1251
+ response: unknown;
1252
+ status: number | null;
1253
+ };
1254
+ /**
1255
+ * Represents the API response structure.
1256
+ *
1257
+ * @property {TApiResponsePayload} default - The default response.
1258
+ * @property {Record<string, TApiResponsePayload>} [named] - Named responses.
1259
+ */
1260
+ type TApiResponse = {
1261
+ default: TApiResponsePayload;
1262
+ named?: Record<string, TApiResponsePayload>;
1263
+ apiState: {
1264
+ loading: boolean;
1265
+ lastEvent?: TEvents;
1266
+ };
1267
+ };
1268
+ /**
1269
+ * Represents the schema config structure
1270
+ *
1271
+ * @property {number} defaultAPIdebounceTimeMS - default API debounce time between request events.
1272
+ * @property {boolean} defaultLogVerbose - flag to turn warning log messages on client.
1273
+ * @property {number} [defaultStateRefreshTimeMS] - default state refresh between events side effects.
1274
+ */
1275
+ type TSchemaFormConfig = {
1276
+ defaultAPIdebounceTimeMS?: number;
1277
+ defaultStateRefreshTimeMS?: number;
1278
+ defaultLogVerbose?: boolean;
1279
+ };
1280
+
1281
+ /**
1282
+ * @interface IState
1283
+ * Represents the state of a form component.
1284
+ *
1285
+ * @property {string[]} errors - The list of error messages.
1286
+ * @property {boolean} visibility - The visibility state of the component.
1287
+ * @property {Record<string, unknown>} props - The properties of the component.
1288
+ *
1289
+ * @example
1290
+ * ```typescript
1291
+ * const state: IState = {
1292
+ * visibility: true,
1293
+ * props: { type: 'text', value: 'John' }
1294
+ * };
1295
+ * ```
1296
+ */
1297
+ interface IState {
1298
+ visibility: boolean;
1299
+ props: Record<string, unknown>;
1300
+ errors: Record<string, unknown>;
1301
+ }
1302
+
1303
+ /**
1304
+ * Custom RXJS Subject to gracefully handle errors on unsubscribed Subjects
1305
+ * that were unmounted due to adapter external handling such as visibility
1306
+ */
1307
+ declare class SafeSubject<T> extends Subject<T> {
1308
+ private isMounted;
1309
+ constructor(isMounted: () => boolean);
1310
+ next(value: T): void;
1311
+ }
1312
+
1313
+ type TTemplateAvaliableScopes = (typeof TEMPLATE_AVALIABLE_SCOPES)[number];
1314
+ /**
1315
+ * @type TTemplateAvaliableScopesEnum
1316
+ * Represents the different types of events that can occur on form fields.
1317
+ * @property {never} fields - scope related to field content ex: '${fields.fieldName.value}'
1318
+ * @property {never} iVars - scope related to iVars content ex: '${iVars.test}'
1319
+ * @property {never} form - scope related to form content ex: '${form.valid}'
1320
+ *
1321
+ * @example
1322
+ * ```typescript
1323
+ * const scope: TTemplateAvaliableScopesEnum = 'fields';
1324
+ * ```
1325
+ * @interface
1326
+ */
1327
+ type TTemplateAvaliableScopesEnum = Record<TTemplateAvaliableScopes, never>;
1328
+ /**
1329
+ * @type TSubscribedTemplates
1330
+ * Represents the subscribed templates for dynamic updates.
1331
+ *
1332
+ * @property {string} originExpression - The expression to evaluate.
1333
+ * @property {TTemplateAvaliableScopes[]} originScopeKeys - Origin scope of the updated template value
1334
+ * @property {string[]} originPropertyKeys - The properties of the origin fields.
1335
+ * @property {string[]} originFieldKeys - The keys of the origin fields.
1336
+ * @property {string} destinationKey - The key of the destination field.
1337
+ * @property {string} destinationProperty - The property of the destination field.
1338
+ * @property {string[]} destinationPath - The path to the destination property.
1339
+ *
1340
+ * @example
1341
+ * ```typescript
1342
+ * const subscribedTemplates: TSubscribedTemplates = {
1343
+ * originExpression: 'originField1 + originField2',
1344
+ * originScopeKeys: ['field','field'],
1345
+ * originPropertyKeys: ['value', 'props'],
1346
+ * originFieldKeys: ['originField1', 'originField2'],
1347
+ * destinationKey: 'resultField',
1348
+ * destinationProperty: 'value',
1349
+ * destinationPath: ['path', 'to', 'resultField']
1350
+ * };
1351
+ * ```
1352
+ */
1353
+ type TSubscribedTemplates = {
1354
+ originExpression: string;
1355
+ originScopeKeys: TTemplateAvaliableScopes[];
1356
+ originPropertyKeys: string[];
1357
+ originFieldKeys: string[];
1358
+ destinationKey: string;
1359
+ destinationProperty: string;
1360
+ destinationPath: string[];
1361
+ };
1362
+ /**
1363
+ * @type TTemplateEvent
1364
+ * Represents the event occuring on templates that changes property values.
1365
+ *
1366
+ * @property {TTemplateAvaliableScopes} scope - template scope triggering the event.
1367
+ * @property {string} key - field triggering the template refresh
1368
+ * @property {TMutationEvents} event - template event triggering the template refresh.
1369
+ */
1370
+ type TTemplateEvent = {
1371
+ scope: TTemplateAvaliableScopes;
1372
+ key?: string;
1373
+ event: TMutationEvents;
1374
+ };
1375
+
1376
+ /**
1377
+ * Represents a form field with observables for managing form state, validations, and API requests.
1378
+ */
1379
+ declare class FormField {
1380
+ formIndex: string;
1381
+ name: string;
1382
+ nameToSubmit?: string;
1383
+ component: string;
1384
+ children?: string[];
1385
+ originalSchema: IComponentSchemaAsFormField<unknown>;
1386
+ validations?: TValidations;
1387
+ visibilityConditions?: TVisibility[];
1388
+ resetValues?: TResetValueMethods[];
1389
+ resetPropertyValues?: TResetPathMethods[];
1390
+ apiSchema?: TApiEvent;
1391
+ formatters?: TFormatters;
1392
+ masks?: TMasks;
1393
+ valuePropName?: string;
1394
+ config: Required<TSchemaFormConfig>;
1395
+ mapper: TMapper<unknown>;
1396
+ errorsString: string;
1397
+ errorsList: string[];
1398
+ private _props;
1399
+ private _value;
1400
+ private _stateValue;
1401
+ private _metadata;
1402
+ private _visibility;
1403
+ private _errors;
1404
+ private _api;
1405
+ private _valid;
1406
+ private _mounted;
1407
+ propsSubject$: SafeSubject<Record<string, unknown>>;
1408
+ errorSubject$: SafeSubject<Record<string, unknown>>;
1409
+ valueSubject$: SafeSubject<Record<string, unknown>>;
1410
+ valueSubscription$: Subscription;
1411
+ visibilitySubject$: SafeSubject<boolean>;
1412
+ fieldEventSubject$: Subject<TFieldEvent>;
1413
+ apiEventQueueSubject$: SafeSubject<{
1414
+ event: TEvents;
1415
+ }>;
1416
+ fieldStateSubscription$: Subscription;
1417
+ templateSubject$: Subject<TTemplateEvent>;
1418
+ dataSubject$: Subject<TFormDataPayload>;
1419
+ fieldValidNotification$: Subject<TFieldValidationPayload>;
1420
+ mountSubject$: Subject<{
1421
+ key: string;
1422
+ status: boolean;
1423
+ }>;
1424
+ validateVisibility: (payload: {
1425
+ event: TEvents;
1426
+ key: string;
1427
+ }) => void;
1428
+ resetValue: (payload: {
1429
+ event: TEvents;
1430
+ key: string;
1431
+ }) => void;
1432
+ resetProperty: (payload: {
1433
+ event: TEvents;
1434
+ key: string;
1435
+ }) => void;
1436
+ getFormValues: () => TFormValues<unknown>;
1437
+ valueChangeEvent: TValueChangeEvent;
1438
+ submitEvent: () => void;
1439
+ persistValue?: boolean;
1440
+ /**
1441
+ * Creates an instance of FormField.
1442
+ *
1443
+ * @param {object} options - Configuration options for the form field.
1444
+ * @param {IComponentSchema} options.schemaComponent - The schema definition for the form field.
1445
+ * @param {TSchemaFormConfig} options.config - The schema default configuration for debounced actions.
1446
+ * @param {string} [options.path] - The path within the form field (used internally during recursion).
1447
+ * @param {string[]} options.children - An array of children fields names.
1448
+ * @param {Function} options.validateVisibility - A function to validate the visibility of the field.
1449
+ * @param {Function} options.resetValue - A function to reset the field value.
1450
+ * @param {Function} options.resetProperty - A function to reset a field property.
1451
+ * @param {Subject<{ key: string }>} options.templateSubject$ - A subject for template updates.
1452
+ * @param {Subject<TFieldEvent>} options.fieldEventSubject$, - Subject for basic event mapped field emissions, except onData to form instance
1453
+ * @param {Subject<{ key: string; event: TEvents }>} options.dataSubject$, - Subject to emit onData events to form instance
1454
+ * @param {Subject<{ key: string }>} options.formValidNotification$, - Subject to emit field valid change to form instance
1455
+ * @param {TMapper<unknown>} options.mapper, - component generic mapper containing render parameters for adapters
1456
+ * @param {() => TFormValues<unknown>} options.getFormValues, - form instance function that builds onData parameter payload from fields
1457
+ */
1458
+ constructor({ formIndex, schemaComponent, config, path, children, validateVisibility, resetValue, resetProperty, templateSubject$, fieldEventSubject$, dataSubject$, fieldValidNotification$, mountSubject$, mapper, getFormValues, submitEvent, visibility, persistValue, }: {
1459
+ formIndex: string;
1460
+ schemaComponent: IComponentSchema;
1461
+ config?: TSchemaFormConfig;
1462
+ path?: string;
1463
+ children?: string[];
1464
+ validateVisibility: (payload: {
1465
+ event: TEvents;
1466
+ key: string;
1467
+ }) => void;
1468
+ resetValue: (payload: {
1469
+ event: TEvents;
1470
+ key: string;
1471
+ }) => void;
1472
+ resetProperty: (payload: {
1473
+ event: TEvents;
1474
+ key: string;
1475
+ }) => void;
1476
+ submitEvent: () => void;
1477
+ templateSubject$: Subject<TTemplateEvent>;
1478
+ fieldEventSubject$: Subject<TFieldEvent>;
1479
+ dataSubject$: Subject<TFormDataPayload>;
1480
+ fieldValidNotification$: Subject<TFieldValidationPayload>;
1481
+ mountSubject$: Subject<{
1482
+ key: string;
1483
+ status: boolean;
1484
+ }>;
1485
+ mapper: TMapper<unknown>;
1486
+ getFormValues: () => TFormValues<unknown>;
1487
+ visibility?: boolean;
1488
+ persistValue?: boolean;
1489
+ });
1490
+ /**
1491
+ * method to initialize all recycled Subjects and initialize Observers on field instance creation or rerender
1492
+ * due to some visibility conditions unmounts the field from the adapter if they are children of it and avoid
1493
+ * emissions to unsubscribed fields
1494
+ */
1495
+ initializeObservers(): void;
1496
+ /**
1497
+ * Retrieves the properties associated with the form field.
1498
+ *
1499
+ * @returns {Record<string, unknown>} - The properties of the form field.
1500
+ */
1501
+ get props(): Record<string, unknown>;
1502
+ /**
1503
+ * Sets the properties of the form field and notifies subscribers about the change.
1504
+ *
1505
+ * @param {Record<string, unknown>} props - The new properties to be set.
1506
+ */
1507
+ set props(props: Record<string, unknown>);
1508
+ /**
1509
+ * Static function to remove templates form the component props that will be shown when
1510
+ * the field mounts and the template routine executes, to be used on the adapter
1511
+ *
1512
+ * @param {unknown} props - the properties from the adapter components.
1513
+ */
1514
+ static filterProps(props: unknown): unknown;
1515
+ /**
1516
+ * Retrieves the current state value of the form field.
1517
+ *
1518
+ * @returns {Record<string,unknown>} - The current state value of the form field.
1519
+ */
1520
+ get stateValue(): Record<string, unknown>;
1521
+ get metadata(): unknown;
1522
+ /**
1523
+ * Retrieves the current value of the form field.
1524
+ *
1525
+ * @returns {unknown} - The current value of the form field.
1526
+ */
1527
+ get value(): unknown;
1528
+ /**
1529
+ * Sets the value of the form field and notifies subscribers about the change.
1530
+ *
1531
+ * @param {unknown} value - The new value to be set.
1532
+ */
1533
+ set value(value: unknown);
1534
+ /**
1535
+ * Retrieves the visibility status of the form field.
1536
+ *
1537
+ * @returns {boolean} - The visibility status of the form field.
1538
+ */
1539
+ get visibility(): boolean;
1540
+ /**
1541
+ * Sets the visibility status of the form field and notifies subscribers about the change.
1542
+ *
1543
+ * @param {boolean} visible - The new visibility status to be set.
1544
+ */
1545
+ set visibility(visible: boolean);
1546
+ /**
1547
+ * sets valid field state and notifies form instance via formValidNotification$
1548
+ */
1549
+ set valid(valid: boolean);
1550
+ /**
1551
+ * Retrieves the validity status of the form field.
1552
+ *
1553
+ * @returns {boolean} - The validity status of the form field.
1554
+ */
1555
+ get valid(): boolean;
1556
+ /**
1557
+ * triggers field valid notification to handle the form instance valid notification
1558
+ *
1559
+ * Note: since form unmount can occur before field unmount, this subject might already be closed by form instance
1560
+ * quick workaround is to check if the subject is already closed before emitting
1561
+ * if form instance onValid or template form.valid doesn't work properly, might be due to this workaround
1562
+ */
1563
+ triggerFieldValidNotification(): void;
1564
+ /**
1565
+ * Retrieves the error messages associated with the form field.
1566
+ *
1567
+ * @returns {TErrorMessages} - The error messages associated with the form field.
1568
+ */
1569
+ get errors(): TErrorMessages;
1570
+ /**
1571
+ * Sets the error messages associated with the form field and notifies subscribers about the change.
1572
+ *
1573
+ * @param {TErrorMessages} errors - The new error messages to be set.
1574
+ */
1575
+ set errors(errors: TErrorMessages);
1576
+ /**
1577
+ * Retrieves the API response data associated with the form field.
1578
+ *
1579
+ * @returns {TApiResponse} - The API response data associated with the form field.
1580
+ */
1581
+ get api(): TApiResponse;
1582
+ /**
1583
+ * Sets the API response data associated with the form field and notifies subscribers about the change.
1584
+ *
1585
+ * @param {TApiResponse} response - The new API response data to be set.
1586
+ */
1587
+ set api(response: TApiResponse);
1588
+ /**
1589
+ * notifies templates and event binded field configurations that a request starts it's processing
1590
+ */
1591
+ notifyApiRequest(): void;
1592
+ /** Retrieves the mounted status of the field.
1593
+ *
1594
+ * @returns {boolean} - the mounted status of the field.
1595
+ */
1596
+ get mounted(): boolean;
1597
+ /**
1598
+ * sets the mountedStatus and notifies the form that the field was mounted on the adapter
1599
+ * and it's ready to be handled by the form instance
1600
+ *
1601
+ * @param {boolean} mountedStatus - the mounted status to be set from the mountField function.
1602
+ */
1603
+ set mounted(mountedStatus: boolean);
1604
+ /**
1605
+ * Mounts the form field by initializing necessary subjects and combining their streams.
1606
+ *
1607
+ * @param {object} mountOpts - Adapter mount options.
1608
+ * @param {(value: unknown) => unknown} prop.valueSubscription - Adapter value change function
1609
+ * @param {(payload: Partial<IState>) => unknown} prop.propsSubscription - Adapter prop change function
1610
+ * @returns {void}
1611
+ */
1612
+ mountField({ valueSubscription, propsSubscription, }: {
1613
+ valueSubscription: (value: Record<string, unknown>) => void;
1614
+ propsSubscription: (payload: Partial<IState>) => void;
1615
+ }): void;
1616
+ /**
1617
+ * Sets the value of the form field and emits associated events.
1618
+ *
1619
+ * @param {unknown} prop.value - The new value to be set.
1620
+ * @param {TEvents} prop.event - The event associated with setting the value.
1621
+ * @returns {void}
1622
+ */
1623
+ emitValue(prop: {
1624
+ value: unknown;
1625
+ event: TEvents;
1626
+ }): void;
1627
+ /**
1628
+ * Emits events to trigger field-related actions such as validation, visibility checks, value resets, and API requests.
1629
+ *
1630
+ * @param {TEvents} event - The event type that triggers the field actions.
1631
+ * @returns {void}
1632
+ */
1633
+ emitEvents({ event }: {
1634
+ event: TEvents;
1635
+ }): void;
1636
+ /**
1637
+ * Sets the validity state of the field based on the provided validation rules and triggers error message updates.
1638
+ *
1639
+ * @param {TEvents} event - The event type associated with the field action.
1640
+ * @returns {void}
1641
+ */
1642
+ setFieldValidity({ event }: {
1643
+ event: TEvents;
1644
+ }): void;
1645
+ /**
1646
+ * Formats the field value using the specified formatters, if available.
1647
+ *
1648
+ * @param {unknown} value - The value to be formatted.
1649
+ * @returns {unknown} - The formatted value.
1650
+ */
1651
+ formatValue(value: unknown): unknown;
1652
+ /**
1653
+ * Masks the field value using the specified masks, if available.
1654
+ *
1655
+ * @param {unknown} value - The value to be masked.
1656
+ * @returns {unknown} - The masked value.
1657
+ */
1658
+ maskValue(value: unknown): unknown;
1659
+ checkApiRequestValidations(config: TApiConfig): boolean;
1660
+ /**
1661
+ * Makes an API request based on the field's API configuration and event type, updating the field's API response data.
1662
+ *
1663
+ * @param {TEvents} event - The event type associated with the API request.
1664
+ * @returns {Promise<void>}
1665
+ */
1666
+ apiRequest({ event }: {
1667
+ event: TEvents;
1668
+ }): Promise<void>;
1669
+ /**
1670
+ * Unsubscribes from all subject subscriptions associated with the field, cleaning up resources.
1671
+ *
1672
+ * @returns {void}
1673
+ */
1674
+ destroyField(): void;
1675
+ /**
1676
+ * Subscribes to changes in the field state and executes the provided callback function.
1677
+ *
1678
+ * @param {Function} callback - The callback function to be executed when the field state changes.
1679
+ * @returns {void}
1680
+ */
1681
+ subscribeState(callback: (payload: Partial<IState>) => void): void;
1682
+ /**
1683
+ * Subscribes to changes in the field value and executes the provided callback function.
1684
+ *
1685
+ * @param {Function} callback - The callback function to be executed when the field value changes.
1686
+ * @returns {void}
1687
+ */
1688
+ subscribeValue(callback: (value: unknown) => void): void;
1689
+ }
1690
+ type IFormField = FormField;
1691
+
1692
+ /**
1693
+ * Represents the core logic for managing a form, including field management, validation, and submission.
1694
+ */
1695
+ declare class FormCore {
1696
+ index: string;
1697
+ schema?: IFormSchema;
1698
+ fields: Map<string, IFormField>;
1699
+ private _iVars;
1700
+ templateSubject$: Subject<TTemplateEvent>;
1701
+ templateSubscription$: Subscription;
1702
+ submitSubject$: Subject<TFormSubmitPayload<unknown>>;
1703
+ mountSubject$: Subject<{
1704
+ key: string;
1705
+ status: boolean;
1706
+ }>;
1707
+ fieldEventSubject$: Subject<TFieldEvent>;
1708
+ dataSubject$: Subject<TFormDataPayload>;
1709
+ formValidSubject$: Subject<TFormValidationPayload>;
1710
+ fieldValidNotification$: Subject<TFieldValidationPayload>;
1711
+ subscribedTemplates: TSubscribedTemplates[];
1712
+ action?: string;
1713
+ method?: string;
1714
+ config: Required<TSchemaFormConfig>;
1715
+ mappers: Map<string, TMapper<unknown>>;
1716
+ queuedFieldVisibilityEvents: Map<string, {
1717
+ hasError: boolean;
1718
+ showOnlyIfTrue?: boolean;
1719
+ }>;
1720
+ queuedFieldResetValuesEvents: Map<string, {
1721
+ value: unknown;
1722
+ }>;
1723
+ queuedFieldResetPropertyEvents: Map<string, {
1724
+ property: string;
1725
+ path: string;
1726
+ value: unknown;
1727
+ }>;
1728
+ queuedInitialValues: Map<string, unknown>;
1729
+ _valid: boolean;
1730
+ stopEventsOnSubmit: boolean;
1731
+ submitted: boolean;
1732
+ /**
1733
+ * Creates an instance of FormCore.
1734
+ *
1735
+ * @param {TFormEntry & Omit<IFormSchema, 'components'>} entry - Configuration options for the form.
1736
+ * @param {IFormSchema} entry.schema - The schema definition for the form.
1737
+ * @param {Record<string, unknown> | IFormSchema.initialValues} [entry.initialValues] - Initial values for the form fields.
1738
+ * @param {string} [entry.action] - The action attribute of the form.
1739
+ * @param {string} [entry.method] - The method attribute of the form.
1740
+ * @param {IFormSchema.iVars} [entry.iVars] - The internal variables of the form.
1741
+ * @param {((payload: {field: string;data: TFormValues;}) => void) | undefined} [entry.onData] - A callback function to handle data emission.
1742
+ */
1743
+ constructor(entry: TFormEntry & Omit<IFormSchema, 'components'>);
1744
+ /**
1745
+ * mock function to simulate form mount onto the adapter
1746
+ */
1747
+ generateFields(): void;
1748
+ /**
1749
+ *flag utility to prevent Subjects from emitting after form submission and stopEventsOnSubmit
1750
+ * @returns {boolean} - result of the flag utility.
1751
+ */
1752
+ private submitChecker;
1753
+ /**
1754
+ * callback function passed to field instance to notify field adapter mount status
1755
+ * once the field has all field instance properties set, this function will handle all
1756
+ * field routines
1757
+ *
1758
+ * @param { string } entry.key field unique identifier
1759
+ * @param { boolean } entry.status mount status notified from field
1760
+ */
1761
+ mountActions({ key, status }: {
1762
+ key: string;
1763
+ status: boolean;
1764
+ }): void;
1765
+ /**
1766
+ * initialValues setter to handle field values set externally from the adapter
1767
+ *
1768
+ * @param { Record<string, unknown> | undefined } payload initialValues to set onto fields
1769
+ */
1770
+ set initialValues(payload: Record<string, unknown> | undefined);
1771
+ /**
1772
+ * Retrieves the internal variables (iVars) of the form.
1773
+ *
1774
+ * @returns {Record<string, unknown>} - The internal variables of the form.
1775
+ */
1776
+ get iVars(): Record<string, unknown>;
1777
+ /**
1778
+ * Sets the internal variables (iVars) of the form and notifies subscribers about the change.
1779
+ *
1780
+ * @param {Record<string, unknown>} payload - The new internal variables to be set.
1781
+ */
1782
+ set iVars(payload: Record<string, unknown>);
1783
+ /**
1784
+ * Validates all form fields and sets the form valid flag
1785
+ *
1786
+ */
1787
+ validateForm(): boolean;
1788
+ get valid(): boolean;
1789
+ set valid(valid: boolean);
1790
+ /**
1791
+ * Subscribes to templates for dynamic updates.
1792
+ */
1793
+ subscribeTemplates(): void;
1794
+ /**
1795
+ * Gets the value of a property from a field.
1796
+ *
1797
+ * @param {object} options - Options for getting the value.
1798
+ * @param {string} options.key - The key of the field.
1799
+ * @param {string} options.property - The property to retrieve.
1800
+ * @param {string[]} options.path - The path to the property if it's nested.
1801
+ * @returns {unknown | undefined} The value of the property, or undefined if the field doesn't exist.
1802
+ */
1803
+ getValue({ scope, key, property, path, }: {
1804
+ scope: TTemplateAvaliableScopes;
1805
+ key: string;
1806
+ property: string;
1807
+ path: string[];
1808
+ }): unknown | undefined;
1809
+ /**
1810
+ * Sets the value of a property in a field.
1811
+ *
1812
+ * @param {object} options - Options for setting the value.
1813
+ * @param {string} options.key - The key of the field.
1814
+ * @param {string} options.property - The property to set.
1815
+ * @param {string[]} options.path - The path to the property if it's nested.
1816
+ * @param {unknown} options.originKey - field that called templating
1817
+ * @param {unknown} options.value - The value to set.
1818
+ * @param {TMutationEvents} options.event - Internal Event for template Handling.
1819
+ */
1820
+ setValue({ key, property, path, originKey, value, }: {
1821
+ key: string;
1822
+ property: string;
1823
+ path: string[];
1824
+ originKey?: string;
1825
+ value: unknown;
1826
+ event: TMutationEvents;
1827
+ }): void;
1828
+ /**
1829
+ * Extracts parameters from an expression.
1830
+ *
1831
+ * @param {string} expression - The expression containing parameters.
1832
+ * @returns {string[]} An array of extracted parameters.
1833
+ */
1834
+ extractParams(expression: string): unknown[];
1835
+ /**
1836
+ * Replaces expressions marked by ${...} in the expression string with the provided values.
1837
+ *
1838
+ * @param {string} expression - The expression string containing the marked expressions.
1839
+ * @param {string[]} values - The values to be inserted into the marked expressions.
1840
+ * @returns {string} The expression string with the replacements made.
1841
+ */
1842
+ replaceExpression(expression: string, values: unknown[]): string;
1843
+ /**
1844
+ * Checks if an expression string contains string concatenation within a marked expression.
1845
+ *
1846
+ * @param {string} expression - The expression string to be checked.
1847
+ * @returns {boolean} True if the expression contains string concatenation, otherwise false.
1848
+ */
1849
+ hasStringConcatenation(expression: string): boolean;
1850
+ /**
1851
+ * Refreshes templates with updated values.
1852
+ *
1853
+ * @param {object} options - Options for refreshing templates.
1854
+ * @param {string} options.key - The key of the field triggering the update.
1855
+ * @param {TMutationEvents} options.event - Internal event descriptor to handle templating.
1856
+ */
1857
+ refreshTemplates({ key, event }: TTemplateEvent): void;
1858
+ /**
1859
+ * executes events that were stored due to field unavaliability
1860
+ *
1861
+ * @param {string} field field to check
1862
+ */
1863
+ checkFieldEventQueues(field: string): void;
1864
+ /**
1865
+ * Validates and collects the names of form fields in the provided schema structure.
1866
+ *
1867
+ * @param {IComponentSchema[]} [struct] - The schema structure of the form components.
1868
+ * @param {string[]} [indexes=[]] - An array to collect the names of the form fields.
1869
+ * @returns {string[]} - An array of form field names.
1870
+ * @throws {Error} - Throws an error if a field name matches the reserved name defined by `IVARPROPNAME`.
1871
+ * @private
1872
+ */
1873
+ private static checkIndexes;
1874
+ /**
1875
+ * @internal
1876
+ * Update field visibility accordingly.
1877
+ *
1878
+ * @param {object} options - options to set field visibility
1879
+ * @param {string} options.field - Field name to be updated.
1880
+ * @param {boolean} options.hasError - Condition to be used as visibility.
1881
+ * @param {boolean|undefined} options.showOnlyIfTrue - Flag to be considered when update field visibility. If it's true, then considered error, if it's false, always considered the opposite.
1882
+ */
1883
+ private setFieldVisibility;
1884
+ /**
1885
+ * Validates visibility conditions for a given event and updates field visibility accordingly.
1886
+ *
1887
+ * @param {object} options - Options for validating visibility.
1888
+ * @param {TEvents} options.event - The event triggering visibility validation.
1889
+ * @param {string} options.key - The key of the field.
1890
+ */
1891
+ validateVisibility({ event, key }: {
1892
+ event: TEvents;
1893
+ key: string;
1894
+ }): void;
1895
+ /**
1896
+ * @internal
1897
+ * Update field value and emit change and cleared event.
1898
+ *
1899
+ * @param {options} options to reset the field value
1900
+ * @param {string} options.key - Field name to be updated.
1901
+ * @param {unknown} options.value - Value to be inserted into field.
1902
+ */
1903
+ private setResetFieldValue;
1904
+ /**
1905
+ * Resets field values based on reset conditions defined in the schema.
1906
+ *
1907
+ * @param {object} options - Options for resetting field values.
1908
+ * @param {TEvents} options.event - The event triggering the reset.
1909
+ * @param {string} options.key - The key of the field.
1910
+ */
1911
+ resetValue({ event, key }: {
1912
+ event: TEvents;
1913
+ key: string;
1914
+ }): void;
1915
+ /**
1916
+ * @internal
1917
+ * Update field property and emit template change.
1918
+ *
1919
+ * @param {object} options - Options for resetting field property
1920
+ * @param {string} options.key - Field name to be updated.
1921
+ * @param {string} options.property - field property to change.
1922
+ * @param {string} options.path - field property path to change.
1923
+ * @param {unknown} options.value - Value to be inserted into field.
1924
+ */
1925
+ private setResetPathValue;
1926
+ /**
1927
+ * Resets field properties based on reset conditions defined in the schema.
1928
+ *
1929
+ * @param {object} options - Options for resetting field property.
1930
+ * @param {TEvents} options.event - The event triggering the reset.
1931
+ * @param {string} options.key - The key of the field.
1932
+ */
1933
+ resetProperty({ event, key }: {
1934
+ event: TEvents;
1935
+ key: string;
1936
+ }): void;
1937
+ /**
1938
+ * Adds a field onto the form instance regardless there is a schema or not
1939
+ *
1940
+ * @param fieldSchema
1941
+ * @param mapperElement
1942
+ */
1943
+ addField({ fieldSchema, mapperElement, path, }: {
1944
+ fieldSchema: IComponentSchema;
1945
+ mapperElement?: TMapper<unknown>;
1946
+ path?: string;
1947
+ }): void;
1948
+ /**
1949
+ * function to be called from the adapter to remove a field when a field is removed from it
1950
+ *
1951
+ * @param {{ key: string }} entry.key
1952
+ */
1953
+ removeField({ key }: {
1954
+ key: string;
1955
+ }): void;
1956
+ /**
1957
+ * Serializes the schema structure to create form fields.
1958
+ *
1959
+ * @param {IComponentSchema[]} [struct] - The schema structure to serialize.
1960
+ * @param {string} [path] - The path of the parent component.
1961
+ */
1962
+ serializeStructure(struct?: IComponentSchemaAsFormField<unknown>[], path?: string): void;
1963
+ /**
1964
+ * Refreshes form fields based on changes in the schema structure.
1965
+ *
1966
+ * @param {IComponentSchema[]} struct - The updated schema structure.
1967
+ */
1968
+ refreshFields(struct: IComponentSchemaAsFormField<unknown>[]): void;
1969
+ /**
1970
+ * Gets a form field by its key.
1971
+ *
1972
+ * @param {object} options - Options for getting the form field.
1973
+ * @param {string} options.key - The key of the form field.
1974
+ * @returns {IFormField | undefined} The form field, or undefined if not found.
1975
+ */
1976
+ getField({ key }: {
1977
+ key: string;
1978
+ }): IFormField | undefined;
1979
+ /**
1980
+ * Prints the current values of all form fields.
1981
+ */
1982
+ printValues(): void;
1983
+ /**
1984
+ * Gets the current values of all form fields.
1985
+ *
1986
+ * @returns {TFormValues} The current form values.
1987
+ */
1988
+ getFormValues<T>(): TFormValues<T>;
1989
+ /**
1990
+ * function to be called to events sent from the adapter
1991
+ *
1992
+ * @param {{callback: (payload: TFieldEvent) => void}} entry.callback callback function from the adapter
1993
+ * @returns
1994
+ */
1995
+ subscribeFieldEvent({ callback, }: {
1996
+ callback: (payload: TFieldEvent) => void;
1997
+ }): Subscription;
1998
+ /**
1999
+ * to be called from the adapter when the form mounts
2000
+ *
2001
+ * @param {(payload: TFormValues<T>) => void} callback
2002
+ * @returns Subscription
2003
+ */
2004
+ subscribeOnMount<T>(callback: (payload: TFormValues<T>) => void): Subscription;
2005
+ /**
2006
+ *
2007
+ * @param {(payload: { field: string; data: TFormValues }) => void} callback callback function to call onData
2008
+ */
2009
+ subscribeData<T>(callback: (payload: {
2010
+ field: string;
2011
+ data: TFormValues<T>;
2012
+ }) => void): Subscription;
2013
+ /**
2014
+ * method to register a callback function to be called when the form is valid
2015
+ *
2016
+ * @param {(payload: TFormValues<T>) => void} callback callback function to call when the submit action occurs
2017
+ */
2018
+ subscribeOnSubmit<T>(callback: (payload: TFormValues<T>) => void): Subscription;
2019
+ /**
2020
+ * method to check whenever the validity status of the form changes, only emits on status change
2021
+ *
2022
+ * @param {(payload: TFormValidationPayload) => void} callback callback function to call onValid
2023
+ */
2024
+ subscribeFormValidation(callback: (payload: TFormValidationPayload) => void): Subscription;
2025
+ /**
2026
+ * Submits the form by triggering form field events and invoking the onSubmit callback.
2027
+ */
2028
+ submit<T>(): void;
2029
+ /**
2030
+ * recycles all the Suscriptions, to be called from the adapter when the form leaves the page
2031
+ */
2032
+ destroy(): void;
2033
+ }
2034
+ type TFormCore = FormCore;
2035
+
2036
+ /**
2037
+ * Represents a group that manages multiple forms.
2038
+ */
2039
+ declare class FormGroup<ComponentElementType> {
2040
+ forms: Map<string, TFormCore>;
2041
+ config: Required<TSchemaFormConfig>;
2042
+ dataSubject$: Subject<TFormDataPayload>;
2043
+ formValidSubject$: Subject<TFormValidationPayload>;
2044
+ submitSubject$: Subject<TFormSubmitPayload<unknown>>;
2045
+ mappers?: TMapper<ComponentElementType>[];
2046
+ /**
2047
+ * Creates an instance of FormGroup.
2048
+ */
2049
+ constructor(entry?: {
2050
+ mappers?: TMapper<ComponentElementType>[];
2051
+ config?: TSchemaFormConfig;
2052
+ });
2053
+ /**
2054
+ * Creates an empty form with given index
2055
+ *
2056
+ * @param {string} options.index
2057
+ * @param {TMapper<unknown>} options.mappers
2058
+ */
2059
+ createFormWithIndex({ index, mappers, }: {
2060
+ index: string;
2061
+ mappers?: TMapper<unknown>[];
2062
+ }): void;
2063
+ /**
2064
+ * Adds a form instance to the form group.
2065
+ *
2066
+ * @param {object} options - Options for adding a form.
2067
+ * @param {string} options.key - The key associated with the form instance.
2068
+ * @param {TFormCore} options.formInstance - The instance of the form to add.
2069
+ */
2070
+ addForm({ key, params }: {
2071
+ key: string;
2072
+ params: TFormEntry;
2073
+ }): void;
2074
+ /**
2075
+ * Retrieves a form instance from the form group.
2076
+ *
2077
+ * @param {object} options - Options for retrieving a form.
2078
+ * @param {string} options.key - The key associated with the form instance.
2079
+ * @returns {TFormCore | undefined} The instance of the form, if found; otherwise, undefined.
2080
+ */
2081
+ getForm({ key }: {
2082
+ key: string;
2083
+ }): TFormCore | undefined;
2084
+ /**
2085
+ * Removes a form instance from the form group.
2086
+ *
2087
+ * @param {object} options - Options for removing a form.
2088
+ * @param {string} options.key - The key associated with the form instance to remove.
2089
+ */
2090
+ removeForm({ key }: {
2091
+ key: string;
2092
+ }): void;
2093
+ /**
2094
+ * removes a field given a form and field index
2095
+ *
2096
+ * @param {string} options.formIndex
2097
+ * @param {string} options.fieldIndex
2098
+ */
2099
+ removeField({ formIndex, fieldIndex, }: {
2100
+ formIndex: string;
2101
+ fieldIndex: string;
2102
+ }): void;
2103
+ /**
2104
+ * Checks if the specified key already exists in the form group.
2105
+ *
2106
+ * @param {object} options - Options for checking the key.
2107
+ * @param {string} options.key - The key to check.
2108
+ * @throws {Error} Throws an error if the key already exists in the form group.
2109
+ */
2110
+ checkIndexes({ key }: {
2111
+ key: string;
2112
+ }): void;
2113
+ /**
2114
+ * Prints the form group instance to the console.
2115
+ */
2116
+ printFormGroupInstance(): void;
2117
+ /**
2118
+ * Prototype submit function to multiple forms
2119
+ * @param {string[]} indexes form indexes to be submitted
2120
+ * @param callback
2121
+ * @returns
2122
+ */
2123
+ submitMultipleFormsByIndex<T>(indexes: string[], callback?: (payload: TFormValues<T>) => void): void;
2124
+ onDataSubscription<T>({ ids, callback, }: {
2125
+ ids: string[];
2126
+ callback: (payload: TFormGroupOnDataEventPayload<T>) => void;
2127
+ }): rxjs.Subscription;
2128
+ onValidSubscription({ ids, callback, }: {
2129
+ ids: string[];
2130
+ callback: (payload: TFormGroupOnValidEventPayload) => void;
2131
+ }): rxjs.Subscription;
2132
+ onSubmitSubscription<T>({ ids, callback, }: {
2133
+ ids: string[];
2134
+ callback: (payload: TFormGroupOnSubmitEventPayload<T>) => void;
2135
+ }): rxjs.Subscription;
2136
+ destroy: () => void;
2137
+ }
2138
+ type TFormGroup<T> = FormGroup<T>;
2139
+
2140
+ /**
2141
+ * @type TEventEnum
2142
+ * Represents the different types of events that can occur on form fields.
2143
+ * @property {never} ON_FIELD_MOUNT - when field mounts on page
2144
+ * @property {never} ON_FIELD_UNMOUNT - when field unmounts on page (also triggered when form is unmounted from page)
2145
+ * @property {never} ON_FIELD_CHANGE - when field changes value by user inout
2146
+ * @property {never} ON_FIELD_BLUR - when field is blurred
2147
+ * @property {never} ON_FIELD_FOCUS - when field is focused
2148
+ * @property {never} ON_FIELD_CLICK - when field is clicked
2149
+ * @property {never} ON_FIELD_KEYUP - when the pressing key button on field is lifted up
2150
+ * @property {never} ON_FIELD_KEYDOWN - when a key button on field is pressed down
2151
+ * @property {never} ON_FIELD_CLEARED - when a field was changed with a resetValues rule
2152
+ * @property {never} ON_FORM_SUBMIT - when the form is submitted (only type="submit" buttons)
2153
+ * @property {never} ON_FIELD_VALIDATION - when a field is validaded by a validation rule
2154
+ * @property {never} ON_FORM_MOUNT - emitted when the form mounts
2155
+ * @property {never} ON_API_FIELD_REQUEST - emitted when an api request from schema is called
2156
+ * @property {never} ON_API_FIELD_RESPONSE - emitted when an api response from schema is received
2157
+ *
2158
+ * @example
2159
+ * ```typescript
2160
+ * const event: TEvents = 'ON_FIELD_CHANGE';
2161
+ * ```
2162
+ */
2163
+ type TEventEnum = {
2164
+ ON_FIELD_MOUNT: never;
2165
+ ON_FIELD_UNMOUNT: never;
2166
+ ON_FIELD_CHANGE: never;
2167
+ ON_FIELD_BLUR: never;
2168
+ ON_FIELD_FOCUS: never;
2169
+ ON_FIELD_CLICK: never;
2170
+ ON_FIELD_KEYUP: never;
2171
+ ON_FIELD_KEYDOWN: never;
2172
+ ON_FIELD_CLEARED: never;
2173
+ ON_FORM_SUBMIT: never;
2174
+ ON_FIELD_VALIDATION: never;
2175
+ ON_FORM_MOUNT: never;
2176
+ ON_API_FIELD_REQUEST: never;
2177
+ ON_API_FIELD_RESPONSE: never;
2178
+ };
2179
+ type TEvents = keyof TEventEnum;
2180
+ /**
2181
+ * Represents the possible event properties for form fields callbacks.
2182
+ * * Represents a mapping of event properties to their corresponding callback functions.
2183
+ * @property {string} onChange - trigger bind component change event
2184
+ * @property {string} onBlur - trigger bind component blur event
2185
+ * @property {string} onFocus - trigger bind component focus event
2186
+ * @property {string} onKeyDown - trigger bind component keydown event
2187
+ * @property {string} onKeyUp - trigger bind component keyup event
2188
+ * @property {string} onMount - triggered on field mount
2189
+ * @property {string} onApiResponse - triggered when schema api call is completed
2190
+ * @property {string} onApiRequest - triggered when schema api call starts
2191
+ * @property {string} onClick - trigger bind component keyup event
2192
+ * @property {string} onCleared - triggered when a resetValue rule apply on the target field
2193
+ * @property {string} onUnmount - triggered when a field unmounts
2194
+ */
2195
+ type TEventPropsEnum = {
2196
+ onChange: never;
2197
+ onBlur: never;
2198
+ onFocus: never;
2199
+ onKeyDown: never;
2200
+ onKeyUp: never;
2201
+ onMount: never;
2202
+ onApiResponse: never;
2203
+ onApiRequest: never;
2204
+ onClick: never;
2205
+ onCleared: never;
2206
+ onUnmount: never;
2207
+ };
2208
+ type TEventProps = keyof TEventPropsEnum;
2209
+ type TEventDataPropsEnum = {
2210
+ onFormMount: never;
2211
+ onData: never;
2212
+ onSubmit: never;
2213
+ onValid: never;
2214
+ };
2215
+ type TEventDataProps = keyof TEventDataPropsEnum;
2216
+ /**
2217
+ * @type TMutationEvents
2218
+ * Represents the different types of events that can occur internally that triggers templating.
2219
+ *
2220
+ * @example
2221
+ * ```typescript
2222
+ * const event: TMutationEvents = 'ON_VALUE';
2223
+ * ```
2224
+ */
2225
+ type TMutationEvents = 'ON_VALUE' | 'ON_PROPS' | 'ON_VISIBILITY' | 'ON_API_REQUEST' | 'ON_API_RESPONSE' | 'ON_IVARS' | 'ON_FIELDS' | 'ON_RESET' | 'ON_FORM';
2226
+ declare enum TMutationEnum {
2227
+ ON_VALUE = "value",
2228
+ ON_PROPS = "props",
2229
+ ON_VISIBILITY = "visibility",
2230
+ ON_API = "api",
2231
+ ON_IVARS = "iVars",
2232
+ ON_FIELDS = "fields"
2233
+ }
2234
+ /**
2235
+ * @type TValueChangeEvent
2236
+ * Represents the custom change handle function to perform value changes.
2237
+ *
2238
+ * @example
2239
+ * ```typescript
2240
+ * handleChangeEvent (value, opts) {
2241
+ * return value
2242
+ * }
2243
+ * ```
2244
+ */
2245
+ type TValueChangeEvent = (value: unknown, opts?: {
2246
+ props: Record<string, unknown>;
2247
+ }) => void;
2248
+ /**
2249
+ * @type TFieldEvent
2250
+ * Event emitted on all basic form events, except onData
2251
+ */
2252
+ type TFieldEvent = {
2253
+ event: TEvents;
2254
+ fieldName: string;
2255
+ fieldInstance?: IFormField;
2256
+ };
2257
+ /**
2258
+ * @type TFormDataPayload
2259
+ * Event emitted to formGroup instance to capture onData form events
2260
+ */
2261
+ type TFormDataPayload = {
2262
+ formIndex: string;
2263
+ fieldIndex: string;
2264
+ event: TEvents;
2265
+ };
2266
+ /**
2267
+ * @type TFormSubmitPayload
2268
+ * Event emitted to formGroup instance to capture onSubmit form events
2269
+ */
2270
+ type TFormSubmitPayload<T> = {
2271
+ formIndex: string;
2272
+ values: TFormValues<T>;
2273
+ };
2274
+ /**
2275
+ * @type TFormValidationPayload
2276
+ * Form onValid event emmited payload on callback function parameter
2277
+ */
2278
+ type TFormValidationPayload = {
2279
+ formIndex: string;
2280
+ valid: boolean;
2281
+ };
2282
+ /**
2283
+ * @type TFieldValidationPayload
2284
+ * field event emmited payload on field validation
2285
+ */
2286
+ type TFieldValidationPayload = {
2287
+ fieldTrigger: string;
2288
+ };
2289
+ type TFormDataValues<T> = {
2290
+ formId: string;
2291
+ formField: string;
2292
+ values?: TFormValues<T>;
2293
+ };
2294
+ /**
2295
+ * @type TFormGroupOnDataEventPayload
2296
+ * Form Group onData event emitted payload on callback function parameter
2297
+ */
2298
+ type TFormGroupOnDataEventPayload<T> = Record<string, TFormDataValues<T>>;
2299
+ /**
2300
+ * @type TFormGroupOnValidEventPayload
2301
+ * Form Group onValid event emitted payload on callback function parameter
2302
+ */
2303
+ type TFormGroupOnValidEventPayload = {
2304
+ groupValid: boolean;
2305
+ forms: Record<string, boolean>;
2306
+ };
2307
+ /**
2308
+ * @type TFormGroupOnSubmitEventPayload
2309
+ * Form Group onSubmit event emitted payload on callback function parameter
2310
+ */
2311
+ type TFormGroupOnSubmitEventPayload<T> = Record<string, TFormValues<T> | undefined>;
2312
+
2313
+ export { FormCore, FormField, FormGroup, TMutationEnum };
2314
+ export type { AllowOnly, IComponentSchema, IComponentSchemaAsFormField, IFormField, IFormSchema, IState, OneOf, TAllowedResetPropsMutationsEnum, TApiConfig, TApiEvent, TApiResponse, TApiResponsePayload, TAvailableValidations, TBetweenDatesValidation, TBetweenValidation, TCallbackValidation, TComponentPropsMapping, TConditionsValidation, TConditionsValidationSet, TCreditCardMatch, TCurrencyMask, TDateFormatsValidation, TDateInterval, TDateOperatorsValidation, TDateValidation, TDocumentValidation, TErrorMessages, TEvent, TEventDataProps, TEventDataPropsEnum, TEventEnum, TEventMessages, TEventMessagesValidationMethods, TEventProps, TEventPropsEnum, TEvents, TFieldEvent, TFieldValidationPayload, TFormCore, TFormDataPayload, TFormDataValues, TFormEntry, TFormGroup, TFormGroupOnDataEventPayload, TFormGroupOnSubmitEventPayload, TFormGroupOnValidEventPayload, TFormSubmitPayload, TFormValidationPayload, TFormValues, TFormatters, TGenericValidationRule, TLengthValidation, TMapper, TMaskGeneric, TMasks, TMultipleValidation, TMutationEvents, TProps, TResetPathMethods, TResetValueMethods, TSchemaFormConfig, TSchemaValidation, TSplitterFormatterValue, TSubscribedTemplates, TTemplateAvaliableScopes, TTemplateAvaliableScopesEnum, TTemplateEvent, TValidationHandler, TValidationMethods, TValidations, TValueChangeEvent, TVisibility };