@bolttech/form-engine 0.4.6 → 0.5.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.
- package/CHANGELOG.md +15 -0
- package/README.md +395 -2
- package/asFormField-ff27f10a.js +2 -0
- package/asFormField-ff27f10a.js.map +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/react.js +1 -1
- package/src/core/handlers/common/templating.d.ts +6 -0
- package/src/core/types/index.d.ts +193 -74
- package/types.js.map +1 -1
- package/asFormField-ea28b423.js +0 -2
- package/asFormField-ea28b423.js.map +0 -1
|
@@ -128,55 +128,85 @@ export declare type TVAvailableValitationConditions = {
|
|
|
128
128
|
conditions?: TVAvailableValitationConditions;
|
|
129
129
|
};
|
|
130
130
|
export declare type TVAvailableValidations = {
|
|
131
|
+
/**
|
|
132
|
+
* The bool function is a validation function that checks if a given value indicating whether the validation has failed or not.
|
|
133
|
+
*
|
|
134
|
+
* @example - in a test environment
|
|
135
|
+
* ```
|
|
136
|
+
* const result = bool({
|
|
137
|
+
* validationValue: false,
|
|
138
|
+
* });
|
|
139
|
+
* console.log(result); // { fail: false }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example - real json usage with field value
|
|
143
|
+
* ```
|
|
144
|
+
* {
|
|
145
|
+
* validations: {
|
|
146
|
+
* bool: '${fields.input.value}'
|
|
147
|
+
* },
|
|
148
|
+
* },
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @example - real json usage with iVar value
|
|
152
|
+
* ```
|
|
153
|
+
* {
|
|
154
|
+
* validations: {
|
|
155
|
+
* bool: '${global.validation}'
|
|
156
|
+
* },
|
|
157
|
+
* },
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
bool?: string | boolean;
|
|
131
161
|
/**
|
|
132
162
|
* Validation based on conditions
|
|
133
163
|
*
|
|
134
164
|
* @example - Compare own field to two. Origin and target default to field value
|
|
135
165
|
* ```
|
|
136
166
|
* conditions: {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
167
|
+
* rule: 'and',
|
|
168
|
+
* set: [
|
|
169
|
+
* {
|
|
170
|
+
* condition: '===',
|
|
171
|
+
* target: '2',
|
|
172
|
+
* },
|
|
173
|
+
* {
|
|
174
|
+
* origin: '2',
|
|
175
|
+
* condition: '===',
|
|
176
|
+
* },
|
|
177
|
+
* ],
|
|
178
|
+
* },
|
|
149
179
|
* ```
|
|
150
180
|
* @example - Binded to Postcode field value. Must be greater than or equal two
|
|
151
181
|
* ```
|
|
152
182
|
* conditions: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
* rule: 'or',
|
|
184
|
+
* set: [
|
|
185
|
+
* {
|
|
186
|
+
* origin: '${fields.postcode.value}',
|
|
187
|
+
* condition: '>',
|
|
188
|
+
* target: '2',
|
|
189
|
+
* },
|
|
190
|
+
* {
|
|
191
|
+
* origin: '${fields.postcode.value}',
|
|
192
|
+
* condition: '===',
|
|
193
|
+
* target: '2',
|
|
194
|
+
* },
|
|
195
|
+
* ],
|
|
196
|
+
* },
|
|
167
197
|
* ```
|
|
168
198
|
* @example - Binded to Postcode field value. Must be equal to two
|
|
169
199
|
* ```
|
|
170
200
|
* conditions: {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
* rule: 'or',
|
|
202
|
+
* set: [
|
|
203
|
+
* {
|
|
204
|
+
* origin: '${fields.postcode.value}',
|
|
205
|
+
* condition: '===',
|
|
206
|
+
* target: '2',
|
|
207
|
+
* },
|
|
208
|
+
* ],
|
|
209
|
+
* },
|
|
180
210
|
* ```
|
|
181
211
|
*/
|
|
182
212
|
conditions?: TVAvailableValitationConditions;
|
|
@@ -186,27 +216,27 @@ export declare type TVAvailableValidations = {
|
|
|
186
216
|
* @example - Between ages
|
|
187
217
|
* ``` type teste = Pick<TVAvailableValidations, 'date'>
|
|
188
218
|
* between: {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
* dates: [
|
|
220
|
+
* {
|
|
221
|
+
* operator: '>=',
|
|
222
|
+
* origin: {
|
|
223
|
+
* format: 'YYYYMMDD',
|
|
224
|
+
* intervals: {
|
|
225
|
+
* years: 18,
|
|
226
|
+
* },
|
|
227
|
+
* },
|
|
228
|
+
* },
|
|
229
|
+
* {
|
|
230
|
+
* operator: '<=',
|
|
231
|
+
* origin: {
|
|
232
|
+
* format: 'YYYYMMDD',
|
|
233
|
+
* intervals: {
|
|
234
|
+
* years: 75,
|
|
235
|
+
* },
|
|
236
|
+
* },
|
|
237
|
+
* }
|
|
238
|
+
* ]
|
|
239
|
+
* }
|
|
210
240
|
* ```
|
|
211
241
|
*
|
|
212
242
|
* @example - Between numbers
|
|
@@ -243,15 +273,15 @@ export declare type TVAvailableValidations = {
|
|
|
243
273
|
* @example - Dates should be different
|
|
244
274
|
* ```
|
|
245
275
|
* date: {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
276
|
+
* operator: '!==',
|
|
277
|
+
* origin: {
|
|
278
|
+
* format: 'DDMMYYYY',
|
|
279
|
+
* },
|
|
280
|
+
* target: {
|
|
281
|
+
* format: 'DDMMYYYY',
|
|
282
|
+
* value: '10/10/2001',
|
|
283
|
+
* },
|
|
284
|
+
* },*
|
|
255
285
|
* ```
|
|
256
286
|
*
|
|
257
287
|
* @example - Compare only valid dates using intervals
|
|
@@ -271,15 +301,15 @@ export declare type TVAvailableValidations = {
|
|
|
271
301
|
* @example - Should have at max 85 years
|
|
272
302
|
* ```
|
|
273
303
|
* {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
304
|
+
* operator: '>',
|
|
305
|
+
* origin: {
|
|
306
|
+
* format: 'DDMMYYYY',
|
|
307
|
+
* value: eightyFiveYearsDate,
|
|
308
|
+
* intervals: {
|
|
309
|
+
* years: 85,
|
|
310
|
+
* },
|
|
311
|
+
* },
|
|
312
|
+
* }
|
|
283
313
|
* }
|
|
284
314
|
*
|
|
285
315
|
* ```
|
|
@@ -339,43 +369,132 @@ export declare type TVAvailableValidations = {
|
|
|
339
369
|
* Will look into the input length and send an error if if not greater than this value
|
|
340
370
|
*/
|
|
341
371
|
greaterThan?: number | string;
|
|
372
|
+
/**
|
|
373
|
+
* Specifies a regular expression pattern that the value should match.
|
|
374
|
+
*/
|
|
342
375
|
regex?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Specifies the maximum length of the value (if it's a string).
|
|
378
|
+
*/
|
|
343
379
|
maxLength?: number;
|
|
380
|
+
/**
|
|
381
|
+
* Specifies the minimum length of the value (if it's a string).
|
|
382
|
+
*/
|
|
344
383
|
minLength?: number;
|
|
384
|
+
/**
|
|
385
|
+
* Specifies whether the field is required.
|
|
386
|
+
*/
|
|
345
387
|
required?: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Specifies that the value should contain only letters.
|
|
390
|
+
*/
|
|
346
391
|
onlyLetters?: boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Specifies a value that the field should match.
|
|
394
|
+
*/
|
|
347
395
|
value?: string | number | boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Specifies that the field should not be empty.
|
|
398
|
+
*/
|
|
348
399
|
notEmpty?: boolean;
|
|
400
|
+
/**
|
|
401
|
+
* A callback function that performs custom validation on the value.
|
|
402
|
+
* @param value - The value to be validated.
|
|
403
|
+
* @returns An object with validation results.
|
|
404
|
+
*/
|
|
349
405
|
callback?(value: string | number): {
|
|
350
406
|
fail: boolean;
|
|
351
407
|
errorMessage?: string;
|
|
352
408
|
};
|
|
409
|
+
/**
|
|
410
|
+
* Specifies a numeric range for the value.
|
|
411
|
+
*/
|
|
353
412
|
numericRange?: {
|
|
354
413
|
start: number | string;
|
|
355
414
|
end: number | string;
|
|
356
415
|
};
|
|
416
|
+
/**
|
|
417
|
+
* Specifies whether the value should be a number.
|
|
418
|
+
*/
|
|
357
419
|
isNumber?: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Specifies that the field should not have extra spaces.
|
|
422
|
+
*/
|
|
358
423
|
hasNoExtraSpaces?: boolean;
|
|
424
|
+
/**
|
|
425
|
+
* Specifies that the value should be an email address.
|
|
426
|
+
*/
|
|
359
427
|
email?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* Specifies that the value should be less than a given number or string.
|
|
430
|
+
*/
|
|
360
431
|
lessThan?: number | string;
|
|
432
|
+
/**
|
|
433
|
+
* Specifies that the value should be a sequential number.
|
|
434
|
+
*/
|
|
361
435
|
sequentialNumber?: boolean;
|
|
436
|
+
/**
|
|
437
|
+
* Specifies that the value should not contain repeated numbers.
|
|
438
|
+
*/
|
|
362
439
|
repeatedNumbers?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Specifies that the value should be a URL.
|
|
442
|
+
*/
|
|
363
443
|
url?: boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Specifies a path error type.
|
|
446
|
+
*/
|
|
364
447
|
path?: TPathError;
|
|
448
|
+
/**
|
|
449
|
+
* Specifies that the value should be a valid credit card number.
|
|
450
|
+
*/
|
|
365
451
|
isCreditCard?: string[];
|
|
452
|
+
/**
|
|
453
|
+
* Specifies that the value should be a valid credit card number with a specific length.
|
|
454
|
+
*/
|
|
366
455
|
isCreditCardAndLength?: string[];
|
|
456
|
+
/**
|
|
457
|
+
* Specifies that the value should match a credit card code with available options.
|
|
458
|
+
*/
|
|
367
459
|
isCreditCodeMatch?: {
|
|
368
460
|
numberCard: string;
|
|
369
461
|
availableOptions: string[];
|
|
370
462
|
};
|
|
463
|
+
/**
|
|
464
|
+
* Specifies custom validation options for the field.
|
|
465
|
+
*/
|
|
371
466
|
customValidation?: ICustomValidationValue[];
|
|
467
|
+
/**
|
|
468
|
+
* Specifies that spaces are not allowed in the field.
|
|
469
|
+
*/
|
|
372
470
|
notAllowSpaces?: true;
|
|
471
|
+
/**
|
|
472
|
+
* Specifies that the value should be in a predefined list of values.
|
|
473
|
+
*/
|
|
373
474
|
isInTheList?: string[] | number[] | string;
|
|
475
|
+
/**
|
|
476
|
+
* Specifies field validation rules for nested fields.
|
|
477
|
+
*/
|
|
374
478
|
fields?: {
|
|
479
|
+
/**
|
|
480
|
+
* The rule for validating nested fields (e.g., 'every').
|
|
481
|
+
*/
|
|
375
482
|
rule: 'every';
|
|
483
|
+
/**
|
|
484
|
+
* An array of nested field validation configurations.
|
|
485
|
+
*/
|
|
376
486
|
set: {
|
|
487
|
+
/**
|
|
488
|
+
* The binding for the nested field.
|
|
489
|
+
*/
|
|
377
490
|
bind: string;
|
|
491
|
+
/**
|
|
492
|
+
* The field name for the nested field.
|
|
493
|
+
*/
|
|
378
494
|
fieldName: string;
|
|
495
|
+
/**
|
|
496
|
+
* Validation options for the nested field, excluding the 'fields' property.
|
|
497
|
+
*/
|
|
379
498
|
validations: Omit<TVAvailableValidations, 'fields'>;
|
|
380
499
|
}[];
|
|
381
500
|
};
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../libs/form-engine/src/core/types/index.ts"],"sourcesContent":["import { ICustomValidationValue } from '@core/apis/validations';\nimport { EEVents } from '@core/constants';\nimport { TEventInformation } from '@core/events';\n\nexport type TObserverData = {\n data: any;\n event: TEventsKeys;\n namespace: string;\n payload: any;\n};\n\nexport type TObservable = (data: any, unsubscribe: () => void) => any;\n\nexport type TEvents = Record<string, TObservable[]>;\n\nexport interface IObservable {\n events: TEvents;\n}\n\nexport type TScopeNamespaces =\n | 'global'\n | 'api'\n | 'hooks'\n | 'fields'\n | 'configs';\n\nexport type TSetGlobalScope = {\n namespace: TScopeNamespaces;\n key?: string;\n data: any;\n merge?: boolean;\n};\nexport type TScope = {\n global?: any;\n api?: any;\n hooks?: any;\n configs?: TConfigs & {\n disable?: boolean;\n enableLogging?: boolean;\n };\n fields?: any;\n};\n\nexport type TMapper = Record<string, Record<string, unknown>>;\n\nexport type TMaskGeneric = {\n to: number;\n from: number;\n mask: string;\n}[];\n\ntype TCurrencyMask = {\n locale: string;\n currency: string;\n};\n\nexport type TComponentMasks = {\n generic?: TMaskGeneric;\n cardNumber?: boolean;\n hideCardNumber?: boolean;\n cardMask?: boolean;\n cardDate?: boolean;\n currencyMask?: TCurrencyMask;\n feinMask?: boolean;\n replaceAll?: string | number;\n};\n\ntype TFormMessages = Record<\n string,\n { name: string; value?: any; values?: string[]; required?: boolean }\n>;\n\nexport type TChildrenOptions = {\n childrenScope?: string[];\n blurredChildren?: string[];\n changedChildren?: string[];\n scopeBlurredChildren?: boolean;\n scopeChangedChildren?: boolean;\n};\n\nexport type TFieldData = Record<string, TField>;\n\nexport type TFormRefActions = {\n submit(): void;\n step(index: number | string): TFormValues;\n stepForward(index?: number | string): TFormValues;\n stepBack(index?: number | string): TFormValues;\n validateForm(opts?: TChildrenOptions): Promise<TFormValues>;\n values(\n opts: Pick<\n TChildrenOptions,\n 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'\n >,\n ): TFormValues;\n};\n\nexport type THookPayload = {\n setScope(data: TSetGlobalScope): void;\n};\n\nexport type THooks = {\n preMount?: () => Record<string, unknown>;\n preUnmount?: () => Record<string, unknown>;\n preSubmit?: (formData: TFormValues) => Record<string, unknown>;\n posSubmit?: (formData: TFormValues) => Record<string, unknown>;\n};\n\nexport type TIVars = Record<string, unknown>;\n\nexport type TEventsKeys = keyof typeof EEVents;\nexport enum TAvailableHooks {\n 'preMount' = 'preMount',\n 'preUnmount' = 'preUnmount',\n 'preSubmit' = 'preSubmit',\n 'postSubmit' = 'postSubmit',\n}\nexport type TField = {\n value?: string | number | boolean;\n errors?: TErrors;\n visible?: boolean;\n failedErrorMessages?: string[];\n mask?: string;\n changed?: boolean;\n blured?: boolean;\n focused?: boolean;\n name: string;\n mounted: boolean;\n metadata?: any;\n ignore?: boolean;\n schemaLocation?: {\n step: number;\n depth: number;\n index: number;\n };\n};\n\ntype TPathError = Omit<TSchemaValidation, 'path'> & {\n path?: string;\n paths?: string[];\n preventUnMountValidation?: boolean;\n};\n\nexport type TValidationDateFormats =\n | 'MMDDYYYY'\n | 'DDMMYYYY'\n | 'YYYYMMDD'\n | 'YYYYDDMM'\n | 'timestamp';\nexport type TValidationDateOperators = '<' | '>' | '===' | '>=' | '<=' | '!==';\n\nexport type TVAvailableValitationConditionsSet = {\n forceDefinedOrigin?: boolean;\n forceDefinedTarget?: boolean;\n origin?: string | number | boolean;\n condition: TValidationDateOperators;\n target?: string | number | boolean;\n};\n\nexport type TVAvailableValitationConditions = {\n rule: 'and' | 'or';\n set: TVAvailableValitationConditionsSet[];\n conditions?: TVAvailableValitationConditions;\n};\n\nexport type TVAvailableValidations = {\n /**\n * Validation based on conditions\n *\n * @example - Compare own field to two. Origin and target default to field value\n * ```\n * conditions: {\n rule: 'and',\n set: [\n {\n condition: '===',\n target: '2',\n },\n {\n origin: '2',\n condition: '===',\n },\n ],\n },\n * ```\n * @example - Binded to Postcode field value. Must be greater than or equal two\n * ```\n * conditions: {\n rule: 'or',\n set: [\n {\n origin: '${fields.postcode.value}',\n condition: '>',\n target: '2',\n },\n {\n origin: '${fields.postcode.value}',\n condition: '===',\n target: '2',\n },\n ],\n },\n * ```\n * @example - Binded to Postcode field value. Must be equal to two\n * ```\n * conditions: {\n rule: 'or',\n set: [\n {\n origin: '${fields.postcode.value}',\n condition: '===',\n target: '2',\n },\n ],\n },\n * ```\n */\n conditions?: TVAvailableValitationConditions;\n /**\n * Between validations\n *\n * @example - Between ages\n * ``` type teste = Pick<TVAvailableValidations, 'date'>\n * between: {\n dates: [\n {\n operator: '>=',\n origin: {\n format: 'YYYYMMDD',\n intervals: {\n years: 18,\n },\n },\n },\n {\n operator: '<=',\n origin: {\n format: 'YYYYMMDD',\n intervals: {\n years: 75,\n },\n },\n }\n ]\n }\n * ```\n *\n * @example - Between numbers\n * ```\n * between: {\n * start: '3',\n * end: '4',\n * isIncludedBoundaries: true\n * },\n * ```\n *\n */\n between?: {\n /**\n * Array of date validations. To make it possible, ensure that the conditions is > and < in both date validations.\n */\n dates?: TVAvailableValidations['date'][];\n /**\n * The first number of the validation. If the current value is grater than this number, the validation will pass.\n */\n start?: number;\n /**\n * The second number of the validation. If the current value is lower than this number, the validation will pass.\n */\n end?: number;\n /**\n * If it's true, the comparision is transformed to >= and <=. So, the numbers that were passed are included in the validation.\n */\n isIncludedBoundaries?: boolean;\n };\n /**\n * Dates validations\n *\n * @example - Dates should be different\n * ```\n * date: {\n operator: '!==',\n origin: {\n format: 'DDMMYYYY',\n },\n target: {\n format: 'DDMMYYYY',\n value: '10/10/2001',\n },\n },\n * ```\n *\n * @example - Compare only valid dates using intervals\n * ```\n * date: {\n * onlyValidDate: true,\n * operator: '<',\n * origin: {\n * format: 'DD/MM/YYYY',\n * intervals: {\n * years: 1,\n * },\n * },\n * },\n * ```\n *\n * @example - Should have at max 85 years\n * ```\n * {\n operator: '>',\n origin: {\n format: 'DDMMYYYY',\n value: eightyFiveYearsDate,\n intervals: {\n years: 85,\n },\n },\n }\n * }\n *\n * ```\n */\n date?: {\n /**\n * Flag to force only valid dates. Valid dates must be of min length of 8\n */\n onlyValidDate?: boolean;\n /**\n * List of operations you can do\n * - between origin and target dates\n * - between origin and intervals\n */\n operator: TValidationDateOperators;\n /**\n * The origin configurations\n */\n origin: {\n /**\n * Origin date value\n */\n value?: string | number;\n /**\n * The available date formats\n */\n format: TValidationDateFormats;\n /**\n * Intervals to compare with the original date.\n *\n * It will use todays date for comparison.\n *\n * @example\n *\n * origin date = 10/10/2022\n * interval.year = 1\n * operator = '==='\n *\n * It will compare (10/10/2022 + 1) with the current date and check if they are the same\n */\n intervals?: {\n years?: number;\n months?: number;\n days?: number;\n };\n };\n target?: {\n value: string | number;\n format: TValidationDateFormats;\n };\n };\n /**\n * Allow to define a maximum length for the input to have no error\n */\n length?: number;\n /**\n * Will look into the input length and send an error if if not greater than this value\n */\n greaterThan?: number | string;\n regex?: string;\n maxLength?: number;\n minLength?: number;\n required?: boolean;\n onlyLetters?: boolean;\n value?: string | number | boolean;\n notEmpty?: boolean;\n callback?(value: string | number): { fail: boolean; errorMessage?: string };\n numericRange?: { start: number | string; end: number | string };\n isNumber?: boolean;\n hasNoExtraSpaces?: boolean;\n email?: boolean;\n lessThan?: number | string;\n sequentialNumber?: boolean;\n repeatedNumbers?: boolean;\n url?: boolean;\n path?: TPathError;\n isCreditCard?: string[];\n isCreditCardAndLength?: string[];\n isCreditCodeMatch?: { numberCard: string; availableOptions: string[] };\n customValidation?: ICustomValidationValue[];\n notAllowSpaces?: true;\n isInTheList?: string[] | number[] | string;\n fields?: {\n rule: 'every';\n set: {\n bind: string;\n fieldName: string;\n validations: Omit<TVAvailableValidations, 'fields'>;\n }[];\n };\n};\n\nexport type TGenericValidationRule = {\n [key: string]: TVAvailableValidations;\n};\n\nexport type TSchemaValidation = TVAvailableValidations | TGenericValidationRule;\n\nexport type TStepData = {\n navigated: boolean;\n index: number;\n data: Record<\n number,\n Pick<\n TFormValues,\n 'fields' | 'erroredFields' | 'formatted' | 'filteredFields'\n >\n >;\n currentStepSchema?: TComponent;\n isValid: boolean;\n numSteps?: number;\n};\n\nexport type TFormValues = {\n predictableErroredFields: string[];\n erroredFields: string[];\n fields: TFieldData;\n formatted: Record<string, unknown>;\n filteredFields?: Record<string, unknown>;\n form: {\n steps: TStepData;\n isValid: boolean;\n messages: string[];\n scope: TScope;\n };\n};\n\nexport type TError = {\n value: unknown;\n message?: string;\n fail: boolean;\n};\n\nexport type TErrors = Record<string, TError> | undefined;\n\n// TODO - object with the available errors has props\nexport type TErrorMessages = Record<string, string>;\n\nexport type TSchemaValidations = TSchemaHandler<TSchemaValidation>;\n\ntype TFormLevelSchemaHandler<T> = Partial<\n Record<\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FORM_REHYDRATE\n | EEVents.ON_FORM_MOUNT\n | EEVents.ON_SCOPE_CHANGE,\n T\n >\n>;\n\ntype TSchemaHandler<T> = Partial<\n Record<\n | EEVents.ON_FIELD_REHYDRATE\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS,\n T\n >\n>;\n\nexport type TSchemaVisibilityConditions = {\n /**\n * The validations that will say if the target field will be visible or not\n *\n * Those validations will run against your field (the one that has this directive)\n */\n validations: TSchemaValidation;\n /**\n * Target field that will have the visibility toggled\n */\n fieldName?: string;\n /**\n * Target fields that will have the visibility toggled\n */\n fieldNames?: string[];\n}[];\n\nexport type TSchemaClearFields = {\n /**\n * Validations to run for the target field\n */\n validations?: TSchemaValidation;\n /**\n * target fields that will be used in the validation specified\n */\n fields: string[];\n /**\n * The cleared values on the fields in case they do no pass the validation\n */\n clearedValue: string | number | boolean;\n}[];\n\nexport type TSchemaApi = {\n /**\n * Specify a debounce time in miliseconds for your call\n */\n debounceTime?: number;\n method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n url: string;\n headers?: HeadersInit | undefined;\n body?: Record<string, any>;\n scope?: string;\n blockRequestWhenInvalid?: boolean;\n preConditions?: TSchemaValidation;\n}[];\n\nexport type TSchemaMasks = { cleanMask?: boolean } & TComponentMasks;\n\nexport type TFormEventDirectives = {\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TEventReducedSchema = {\n api: TSchemaApi;\n clearFields: TSchemaClearFields;\n formatters: TSchemaFormatters;\n masks: TSchemaMasks;\n validations: TSchemaValidation;\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TComponent = {\n /**\n * This name will be used latter to corelate the field with the value and you will be able to read it\n *\n * You can also mount here complex objects like\n *\n * name={a.b.c}\n *\n * that will result in\n * a: {\n * b: {\n * c: 'field_value'\n * }\n * }\n */\n name: string;\n /**\n * A component name that should map to the one you gave in the from mappings\n *\n * @example - For React\n * ```\n * const mappings: TMapper = {\n * input: { component: Input },\n * formGroup: { component: FormGroup },\n * };\n * ```\n *\n * The component name for the Input element will be \"input\" ending up like\n * ```\n * {\n * component: 'input'\n * }\n * ```\n */\n component: string;\n /**\n * You can attach metadata to your component that will be forwarded to you after on your frontend\n * callback methods link `onData`, `onBlur` etc\n */\n metadata?: Record<string, any>;\n /**\n * This property allows you to specify a virtual fieldName that can be in several fields\n *\n * USAGE - You have two fields but you want to have the value stored only under one name\n *\n */\n group?: string;\n wrapper?: new () => React.Component;\n children?: TComponent[];\n /**\n * Field error messages in case any validation fails\n *\n * @example - Set a default error message for all the validations\n *\n * ```\n * {\n * errorMessages: {\n * default: 'default error message'\n * }\n * }\n * ```\n *\n * @example - Set error message for a given validation\n *\n * ```\n * {\n * validations: {\n * ON_FIELD_CHANGE: {\n * required: true\n * }\n * },\n * errorMessages: {\n * required: 'This field is required'\n * }\n * }\n * ```\n *\n */\n errorMessages?: TErrorMessages;\n type?: 'text' | 'number' | string;\n /**\n * Allow you to set a initial state for this field\n */\n state?: {\n /**\n * Hide the field\n */\n hidden?: boolean;\n /**\n * Ignore value from field\n */\n ignoreValue?: boolean;\n };\n /**\n * This key lets you inject props directly into the component\n */\n props?: Record<string, unknown>;\n /**\n * Setup validations to be used in the field.\n *\n * You can setup validations in several life-cycle methods\n *\n * @example - Required validation\n * ```\n * validations: {\n ON_FIELD_CHANGE: {\n required: true,\n },\n },\n * ```\n */\n validations?: TSchemaHandler<\n Pick<TEventReducedSchema, 'validations'>['validations']\n >;\n filter?: Pick<TEventReducedSchema, 'validations'>['validations'];\n /**\n * Allows you to specify the conditions a given field will be visible\n * what will run when this field meets the specified life-cycle\n */\n visibilityConditions?: TSchemaHandler<\n Pick<TEventReducedSchema, 'visibilityConditions'>['visibilityConditions']\n >;\n /**\n * Will clear target fields in case they do not pass with the specified validations\n */\n clearFields?: TSchemaHandler<\n Pick<TEventReducedSchema, 'clearFields'>['clearFields']\n >;\n api?: TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>;\n masks?: Partial<\n Record<\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CHANGE,\n Pick<TEventReducedSchema, 'masks'>['masks']\n >\n >;\n formatters?: TSchemaHandler<\n Pick<TEventReducedSchema, 'formatters'>['formatters']\n >;\n};\n\nexport type TStep = {\n component: string;\n name: string;\n children: TComponent[];\n props?: Record<string, string>;\n};\n\nexport type TComponentPropsMapping = {\n getValue?: string;\n setValue?: string;\n onBlur?: string;\n onClick?: string;\n onFocus?: string;\n setErrorMessage?: string;\n setErrorState?: string;\n};\n\nexport type TPropsMapping = Record<string, TComponentPropsMapping>;\n\nexport type TSchema = {\n action?: string;\n method?: string;\n /**\n * Give some configurations to the form\n */\n configs?: TConfigs;\n /**\n * Allows you to expose some messages to the outside world when something happen\n */\n messages?: TFormMessages;\n /**\n * Specify some static field defaults before rendereing the form.\n *\n * If you have initialValues in the frontend setted, those will ovewride this\n */\n formattedDataDefaults?: Record<string, unknown>;\n /**\n * Form level props mapping\n */\n propsMapping?: TPropsMapping;\n visibilityConditions?: TFormLevelSchemaHandler<TSchemaVisibilityConditions>;\n /**\n * Entry point for the form should be a step (even if you have only one)\n */\n components: TStep[];\n /**\n * You can have many fields in the form, but be interested only in some\n *\n * You can put here the fields you want to read onSubmit for example\n *\n * You will receive those in TFormValues.filteredFields\n */\n filteredFields?: string[];\n /**\n * Schema level iVars.\n *\n * These iVars will go to the global scope namespace\n */\n iVars?: TIVars;\n};\n\nexport type TSplitterFormatterValue = {\n value: string;\n position: number;\n}[];\n\nexport type TSchemaFormatters = {\n splitter?: TSplitterFormatterValue;\n capitalize?: boolean;\n upperCase?: boolean;\n gapsCreditCard?: string[];\n onlyNumbers?: boolean;\n onlyLetters?: boolean;\n};\n\nexport type TConfigs = {\n observables?: { templates?: { exclude?: string[] } };\n};\n\nexport type TFlowType = {\n [x: string]: {\n events: (component?: TComponent) => EEVents[];\n handler: (args: TEventInformation) => void;\n }[];\n};\n"],"names":["TAvailableHooks"],"mappings":"aA8GA,IAAYA,yDAAAA,QAKXA,qBAAA,GALWA,EAAAA,QAAeA,kBAAfA,wBAKX,CAAA,IAJC,SAAA,WACAA,EAAA,WAAA,aACAA,EAAA,UAAA,YACAA,EAAA,WAAA"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../libs/form-engine/src/core/types/index.ts"],"sourcesContent":["import { ICustomValidationValue } from '@core/apis/validations';\nimport { EEVents } from '@core/constants';\nimport { TEventInformation } from '@core/events';\n\nexport type TObserverData = {\n data: any;\n event: TEventsKeys;\n namespace: string;\n payload: any;\n};\n\nexport type TObservable = (data: any, unsubscribe: () => void) => any;\n\nexport type TEvents = Record<string, TObservable[]>;\n\nexport interface IObservable {\n events: TEvents;\n}\n\nexport type TScopeNamespaces =\n | 'global'\n | 'api'\n | 'hooks'\n | 'fields'\n | 'configs';\n\nexport type TSetGlobalScope = {\n namespace: TScopeNamespaces;\n key?: string;\n data: any;\n merge?: boolean;\n};\nexport type TScope = {\n global?: any;\n api?: any;\n hooks?: any;\n configs?: TConfigs & {\n disable?: boolean;\n enableLogging?: boolean;\n };\n fields?: any;\n};\n\nexport type TMapper = Record<string, Record<string, unknown>>;\n\nexport type TMaskGeneric = {\n to: number;\n from: number;\n mask: string;\n}[];\n\ntype TCurrencyMask = {\n locale: string;\n currency: string;\n};\n\nexport type TComponentMasks = {\n generic?: TMaskGeneric;\n cardNumber?: boolean;\n hideCardNumber?: boolean;\n cardMask?: boolean;\n cardDate?: boolean;\n currencyMask?: TCurrencyMask;\n feinMask?: boolean;\n replaceAll?: string | number;\n};\n\ntype TFormMessages = Record<\n string,\n { name: string; value?: any; values?: string[]; required?: boolean }\n>;\n\nexport type TChildrenOptions = {\n childrenScope?: string[];\n blurredChildren?: string[];\n changedChildren?: string[];\n scopeBlurredChildren?: boolean;\n scopeChangedChildren?: boolean;\n};\n\nexport type TFieldData = Record<string, TField>;\n\nexport type TFormRefActions = {\n submit(): void;\n step(index: number | string): TFormValues;\n stepForward(index?: number | string): TFormValues;\n stepBack(index?: number | string): TFormValues;\n validateForm(opts?: TChildrenOptions): Promise<TFormValues>;\n values(\n opts: Pick<\n TChildrenOptions,\n 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'\n >,\n ): TFormValues;\n};\n\nexport type THookPayload = {\n setScope(data: TSetGlobalScope): void;\n};\n\nexport type THooks = {\n preMount?: () => Record<string, unknown>;\n preUnmount?: () => Record<string, unknown>;\n preSubmit?: (formData: TFormValues) => Record<string, unknown>;\n posSubmit?: (formData: TFormValues) => Record<string, unknown>;\n};\n\nexport type TIVars = Record<string, unknown>;\n\nexport type TEventsKeys = keyof typeof EEVents;\nexport enum TAvailableHooks {\n 'preMount' = 'preMount',\n 'preUnmount' = 'preUnmount',\n 'preSubmit' = 'preSubmit',\n 'postSubmit' = 'postSubmit',\n}\nexport type TField = {\n value?: string | number | boolean;\n errors?: TErrors;\n visible?: boolean;\n failedErrorMessages?: string[];\n mask?: string;\n changed?: boolean;\n blured?: boolean;\n focused?: boolean;\n name: string;\n mounted: boolean;\n metadata?: any;\n ignore?: boolean;\n schemaLocation?: {\n step: number;\n depth: number;\n index: number;\n };\n};\n\ntype TPathError = Omit<TSchemaValidation, 'path'> & {\n path?: string;\n paths?: string[];\n preventUnMountValidation?: boolean;\n};\n\nexport type TValidationDateFormats =\n | 'MMDDYYYY'\n | 'DDMMYYYY'\n | 'YYYYMMDD'\n | 'YYYYDDMM'\n | 'timestamp';\nexport type TValidationDateOperators = '<' | '>' | '===' | '>=' | '<=' | '!==';\n\nexport type TVAvailableValitationConditionsSet = {\n forceDefinedOrigin?: boolean;\n forceDefinedTarget?: boolean;\n origin?: string | number | boolean;\n condition: TValidationDateOperators;\n target?: string | number | boolean;\n};\n\nexport type TVAvailableValitationConditions = {\n rule: 'and' | 'or';\n set: TVAvailableValitationConditionsSet[];\n conditions?: TVAvailableValitationConditions;\n};\n\nexport type TVAvailableValidations = {\n /**\n * The bool function is a validation function that checks if a given value indicating whether the validation has failed or not.\n *\n * @example - in a test environment\n * ```\n * const result = bool({\n * validationValue: false,\n * });\n * console.log(result); // { fail: false }\n * ```\n *\n * @example - real json usage with field value\n * ```\n * {\n * validations: {\n * bool: '${fields.input.value}'\n * },\n * },\n * ```\n *\n * @example - real json usage with iVar value\n * ```\n * {\n * validations: {\n * bool: '${global.validation}'\n * },\n * },\n * ```\n */\n bool?: string | boolean;\n /**\n * Validation based on conditions\n *\n * @example - Compare own field to two. Origin and target default to field value\n * ```\n * conditions: {\n * rule: 'and',\n * set: [\n * {\n * condition: '===',\n * target: '2',\n * },\n * {\n * origin: '2',\n * condition: '===',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be greater than or equal two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '>',\n * target: '2',\n * },\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be equal to two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n */\n conditions?: TVAvailableValitationConditions;\n /**\n * Between validations\n *\n * @example - Between ages\n * ``` type teste = Pick<TVAvailableValidations, 'date'>\n * between: {\n * dates: [\n * {\n * operator: '>=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 18,\n * },\n * },\n * },\n * {\n * operator: '<=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 75,\n * },\n * },\n * }\n * ]\n * }\n * ```\n *\n * @example - Between numbers\n * ```\n * between: {\n * start: '3',\n * end: '4',\n * isIncludedBoundaries: true\n * },\n * ```\n *\n */\n between?: {\n /**\n * Array of date validations. To make it possible, ensure that the conditions is > and < in both date validations.\n */\n dates?: TVAvailableValidations['date'][];\n /**\n * The first number of the validation. If the current value is grater than this number, the validation will pass.\n */\n start?: number;\n /**\n * The second number of the validation. If the current value is lower than this number, the validation will pass.\n */\n end?: number;\n /**\n * If it's true, the comparision is transformed to >= and <=. So, the numbers that were passed are included in the validation.\n */\n isIncludedBoundaries?: boolean;\n };\n /**\n * Dates validations\n *\n * @example - Dates should be different\n * ```\n * date: {\n * operator: '!==',\n * origin: {\n * format: 'DDMMYYYY',\n * },\n * target: {\n * format: 'DDMMYYYY',\n * value: '10/10/2001',\n * },\n * },*\n * ```\n *\n * @example - Compare only valid dates using intervals\n * ```\n * date: {\n * onlyValidDate: true,\n * operator: '<',\n * origin: {\n * format: 'DD/MM/YYYY',\n * intervals: {\n * years: 1,\n * },\n * },\n * },\n * ```\n *\n * @example - Should have at max 85 years\n * ```\n * {\n * operator: '>',\n * origin: {\n * format: 'DDMMYYYY',\n * value: eightyFiveYearsDate,\n * intervals: {\n * years: 85,\n * },\n * },\n * }\n * }\n *\n * ```\n */\n date?: {\n /**\n * Flag to force only valid dates. Valid dates must be of min length of 8\n */\n onlyValidDate?: boolean;\n /**\n * List of operations you can do\n * - between origin and target dates\n * - between origin and intervals\n */\n operator: TValidationDateOperators;\n /**\n * The origin configurations\n */\n origin: {\n /**\n * Origin date value\n */\n value?: string | number;\n /**\n * The available date formats\n */\n format: TValidationDateFormats;\n /**\n * Intervals to compare with the original date.\n *\n * It will use todays date for comparison.\n *\n * @example\n *\n * origin date = 10/10/2022\n * interval.year = 1\n * operator = '==='\n *\n * It will compare (10/10/2022 + 1) with the current date and check if they are the same\n */\n intervals?: {\n years?: number;\n months?: number;\n days?: number;\n };\n };\n target?: {\n value: string | number;\n format: TValidationDateFormats;\n };\n };\n /**\n * Allow to define a maximum length for the input to have no error\n */\n length?: number;\n /**\n * Will look into the input length and send an error if if not greater than this value\n */\n greaterThan?: number | string;\n\n /**\n * Specifies a regular expression pattern that the value should match.\n */\n regex?: string;\n\n /**\n * Specifies the maximum length of the value (if it's a string).\n */\n maxLength?: number;\n\n /**\n * Specifies the minimum length of the value (if it's a string).\n */\n minLength?: number;\n\n /**\n * Specifies whether the field is required.\n */\n required?: boolean;\n\n /**\n * Specifies that the value should contain only letters.\n */\n onlyLetters?: boolean;\n\n /**\n * Specifies a value that the field should match.\n */\n value?: string | number | boolean;\n\n /**\n * Specifies that the field should not be empty.\n */\n notEmpty?: boolean;\n\n /**\n * A callback function that performs custom validation on the value.\n * @param value - The value to be validated.\n * @returns An object with validation results.\n */\n callback?(value: string | number): { fail: boolean; errorMessage?: string };\n\n /**\n * Specifies a numeric range for the value.\n */\n numericRange?: { start: number | string; end: number | string };\n\n /**\n * Specifies whether the value should be a number.\n */\n isNumber?: boolean;\n\n /**\n * Specifies that the field should not have extra spaces.\n */\n hasNoExtraSpaces?: boolean;\n\n /**\n * Specifies that the value should be an email address.\n */\n email?: boolean;\n\n /**\n * Specifies that the value should be less than a given number or string.\n */\n lessThan?: number | string;\n\n /**\n * Specifies that the value should be a sequential number.\n */\n sequentialNumber?: boolean;\n\n /**\n * Specifies that the value should not contain repeated numbers.\n */\n repeatedNumbers?: boolean;\n\n /**\n * Specifies that the value should be a URL.\n */\n url?: boolean;\n\n /**\n * Specifies a path error type.\n */\n path?: TPathError;\n\n /**\n * Specifies that the value should be a valid credit card number.\n */\n isCreditCard?: string[];\n\n /**\n * Specifies that the value should be a valid credit card number with a specific length.\n */\n isCreditCardAndLength?: string[];\n\n /**\n * Specifies that the value should match a credit card code with available options.\n */\n isCreditCodeMatch?: { numberCard: string; availableOptions: string[] };\n\n /**\n * Specifies custom validation options for the field.\n */\n customValidation?: ICustomValidationValue[];\n\n /**\n * Specifies that spaces are not allowed in the field.\n */\n notAllowSpaces?: true;\n\n /**\n * Specifies that the value should be in a predefined list of values.\n */\n isInTheList?: string[] | number[] | string;\n\n /**\n * Specifies field validation rules for nested fields.\n */\n fields?: {\n /**\n * The rule for validating nested fields (e.g., 'every').\n */\n rule: 'every';\n\n /**\n * An array of nested field validation configurations.\n */\n set: {\n /**\n * The binding for the nested field.\n */\n bind: string;\n\n /**\n * The field name for the nested field.\n */\n fieldName: string;\n\n /**\n * Validation options for the nested field, excluding the 'fields' property.\n */\n validations: Omit<TVAvailableValidations, 'fields'>;\n }[];\n };\n};\n\nexport type TGenericValidationRule = {\n [key: string]: TVAvailableValidations;\n};\n\nexport type TSchemaValidation = TVAvailableValidations | TGenericValidationRule;\n\nexport type TStepData = {\n navigated: boolean;\n index: number;\n data: Record<\n number,\n Pick<\n TFormValues,\n 'fields' | 'erroredFields' | 'formatted' | 'filteredFields'\n >\n >;\n currentStepSchema?: TComponent;\n isValid: boolean;\n numSteps?: number;\n};\n\nexport type TFormValues = {\n predictableErroredFields: string[];\n erroredFields: string[];\n fields: TFieldData;\n formatted: Record<string, unknown>;\n filteredFields?: Record<string, unknown>;\n form: {\n steps: TStepData;\n isValid: boolean;\n messages: string[];\n scope: TScope;\n };\n};\n\nexport type TError = {\n value: unknown;\n message?: string;\n fail: boolean;\n};\n\nexport type TErrors = Record<string, TError> | undefined;\n\n// TODO - object with the available errors has props\nexport type TErrorMessages = Record<string, string>;\n\nexport type TSchemaValidations = TSchemaHandler<TSchemaValidation>;\n\ntype TFormLevelSchemaHandler<T> = Partial<\n Record<\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FORM_REHYDRATE\n | EEVents.ON_FORM_MOUNT\n | EEVents.ON_SCOPE_CHANGE,\n T\n >\n>;\n\ntype TSchemaHandler<T> = Partial<\n Record<\n | EEVents.ON_FIELD_REHYDRATE\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS,\n T\n >\n>;\n\nexport type TSchemaVisibilityConditions = {\n /**\n * The validations that will say if the target field will be visible or not\n *\n * Those validations will run against your field (the one that has this directive)\n */\n validations: TSchemaValidation;\n /**\n * Target field that will have the visibility toggled\n */\n fieldName?: string;\n /**\n * Target fields that will have the visibility toggled\n */\n fieldNames?: string[];\n}[];\n\nexport type TSchemaClearFields = {\n /**\n * Validations to run for the target field\n */\n validations?: TSchemaValidation;\n /**\n * target fields that will be used in the validation specified\n */\n fields: string[];\n /**\n * The cleared values on the fields in case they do no pass the validation\n */\n clearedValue: string | number | boolean;\n}[];\n\nexport type TSchemaApi = {\n /**\n * Specify a debounce time in miliseconds for your call\n */\n debounceTime?: number;\n method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n url: string;\n headers?: HeadersInit | undefined;\n body?: Record<string, any>;\n scope?: string;\n blockRequestWhenInvalid?: boolean;\n preConditions?: TSchemaValidation;\n}[];\n\nexport type TSchemaMasks = { cleanMask?: boolean } & TComponentMasks;\n\nexport type TFormEventDirectives = {\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TEventReducedSchema = {\n api: TSchemaApi;\n clearFields: TSchemaClearFields;\n formatters: TSchemaFormatters;\n masks: TSchemaMasks;\n validations: TSchemaValidation;\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TComponent = {\n /**\n * This name will be used latter to corelate the field with the value and you will be able to read it\n *\n * You can also mount here complex objects like\n *\n * name={a.b.c}\n *\n * that will result in\n * a: {\n * b: {\n * c: 'field_value'\n * }\n * }\n */\n name: string;\n /**\n * A component name that should map to the one you gave in the from mappings\n *\n * @example - For React\n * ```\n * const mappings: TMapper = {\n * input: { component: Input },\n * formGroup: { component: FormGroup },\n * };\n * ```\n *\n * The component name for the Input element will be \"input\" ending up like\n * ```\n * {\n * component: 'input'\n * }\n * ```\n */\n component: string;\n /**\n * You can attach metadata to your component that will be forwarded to you after on your frontend\n * callback methods link `onData`, `onBlur` etc\n */\n metadata?: Record<string, any>;\n /**\n * This property allows you to specify a virtual fieldName that can be in several fields\n *\n * USAGE - You have two fields but you want to have the value stored only under one name\n *\n */\n group?: string;\n wrapper?: new () => React.Component;\n children?: TComponent[];\n /**\n * Field error messages in case any validation fails\n *\n * @example - Set a default error message for all the validations\n *\n * ```\n * {\n * errorMessages: {\n * default: 'default error message'\n * }\n * }\n * ```\n *\n * @example - Set error message for a given validation\n *\n * ```\n * {\n * validations: {\n * ON_FIELD_CHANGE: {\n * required: true\n * }\n * },\n * errorMessages: {\n * required: 'This field is required'\n * }\n * }\n * ```\n *\n */\n errorMessages?: TErrorMessages;\n type?: 'text' | 'number' | string;\n /**\n * Allow you to set a initial state for this field\n */\n state?: {\n /**\n * Hide the field\n */\n hidden?: boolean;\n /**\n * Ignore value from field\n */\n ignoreValue?: boolean;\n };\n /**\n * This key lets you inject props directly into the component\n */\n props?: Record<string, unknown>;\n /**\n * Setup validations to be used in the field.\n *\n * You can setup validations in several life-cycle methods\n *\n * @example - Required validation\n * ```\n * validations: {\n ON_FIELD_CHANGE: {\n required: true,\n },\n },\n * ```\n */\n validations?: TSchemaHandler<\n Pick<TEventReducedSchema, 'validations'>['validations']\n >;\n filter?: Pick<TEventReducedSchema, 'validations'>['validations'];\n /**\n * Allows you to specify the conditions a given field will be visible\n * what will run when this field meets the specified life-cycle\n */\n visibilityConditions?: TSchemaHandler<\n Pick<TEventReducedSchema, 'visibilityConditions'>['visibilityConditions']\n >;\n /**\n * Will clear target fields in case they do not pass with the specified validations\n */\n clearFields?: TSchemaHandler<\n Pick<TEventReducedSchema, 'clearFields'>['clearFields']\n >;\n api?: TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>;\n masks?: Partial<\n Record<\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CHANGE,\n Pick<TEventReducedSchema, 'masks'>['masks']\n >\n >;\n formatters?: TSchemaHandler<\n Pick<TEventReducedSchema, 'formatters'>['formatters']\n >;\n};\n\nexport type TStep = {\n component: string;\n name: string;\n children: TComponent[];\n props?: Record<string, string>;\n};\n\nexport type TComponentPropsMapping = {\n getValue?: string;\n setValue?: string;\n onBlur?: string;\n onClick?: string;\n onFocus?: string;\n setErrorMessage?: string;\n setErrorState?: string;\n};\n\nexport type TPropsMapping = Record<string, TComponentPropsMapping>;\n\nexport type TSchema = {\n action?: string;\n method?: string;\n /**\n * Give some configurations to the form\n */\n configs?: TConfigs;\n /**\n * Allows you to expose some messages to the outside world when something happen\n */\n messages?: TFormMessages;\n /**\n * Specify some static field defaults before rendereing the form.\n *\n * If you have initialValues in the frontend setted, those will ovewride this\n */\n formattedDataDefaults?: Record<string, unknown>;\n /**\n * Form level props mapping\n */\n propsMapping?: TPropsMapping;\n visibilityConditions?: TFormLevelSchemaHandler<TSchemaVisibilityConditions>;\n /**\n * Entry point for the form should be a step (even if you have only one)\n */\n components: TStep[];\n /**\n * You can have many fields in the form, but be interested only in some\n *\n * You can put here the fields you want to read onSubmit for example\n *\n * You will receive those in TFormValues.filteredFields\n */\n filteredFields?: string[];\n /**\n * Schema level iVars.\n *\n * These iVars will go to the global scope namespace\n */\n iVars?: TIVars;\n};\n\nexport type TSplitterFormatterValue = {\n value: string;\n position: number;\n}[];\n\nexport type TSchemaFormatters = {\n splitter?: TSplitterFormatterValue;\n capitalize?: boolean;\n upperCase?: boolean;\n gapsCreditCard?: string[];\n onlyNumbers?: boolean;\n onlyLetters?: boolean;\n};\n\nexport type TConfigs = {\n observables?: { templates?: { exclude?: string[] } };\n};\n\nexport type TFlowType = {\n [x: string]: {\n events: (component?: TComponent) => EEVents[];\n handler: (args: TEventInformation) => void;\n }[];\n};\n"],"names":["TAvailableHooks"],"mappings":"aA8GA,IAAYA,yDAAAA,QAKXA,qBAAA,GALWA,EAAAA,QAAeA,kBAAfA,wBAKX,CAAA,IAJC,SAAA,WACAA,EAAA,WAAA,aACAA,EAAA,UAAA,YACAA,EAAA,WAAA"}
|