@bolttech/form-engine-core 1.0.10 → 1.1.0

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