@bolttech/form-engine 0.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 (61) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1172 -0
  3. package/index.js +2 -0
  4. package/index.js.map +1 -0
  5. package/package.json +50 -0
  6. package/src/adapters/react/Field.d.ts +4 -0
  7. package/src/adapters/react/Form.d.ts +5 -0
  8. package/src/adapters/react/Submit.d.ts +3 -0
  9. package/src/adapters/react/asFormField.d.ts +14 -0
  10. package/src/adapters/react/context.d.ts +5 -0
  11. package/src/adapters/react/index.d.ts +6 -0
  12. package/src/adapters/react/types.d.ts +185 -0
  13. package/src/adapters/react/useForceUpdate.d.ts +3 -0
  14. package/src/adapters/react/useForm.d.ts +51 -0
  15. package/src/adapters/react/useFormGroup.d.ts +15 -0
  16. package/src/core/apis/formatters.d.ts +16 -0
  17. package/src/core/apis/index.d.ts +4 -0
  18. package/src/core/apis/masks.d.ts +3 -0
  19. package/src/core/apis/validations.d.ts +11 -0
  20. package/src/core/apis/varOps.d.ts +4 -0
  21. package/src/core/constants/events.d.ts +23 -0
  22. package/src/core/constants/index.d.ts +5 -0
  23. package/src/core/constants/observer.d.ts +7 -0
  24. package/src/core/events/ObserverError.d.ts +7 -0
  25. package/src/core/events/events.types.d.ts +27 -0
  26. package/src/core/events/index.d.ts +2 -0
  27. package/src/core/handlers/common/templating.d.ts +2 -0
  28. package/src/core/handlers/field/api.d.ts +4 -0
  29. package/src/core/handlers/field/blur.d.ts +2 -0
  30. package/src/core/handlers/field/change.d.ts +2 -0
  31. package/src/core/handlers/field/clearFields.d.ts +4 -0
  32. package/src/core/handlers/field/data.d.ts +3 -0
  33. package/src/core/handlers/field/filter.d.ts +2 -0
  34. package/src/core/handlers/field/focus.d.ts +2 -0
  35. package/src/core/handlers/field/formatters.d.ts +4 -0
  36. package/src/core/handlers/field/htmlEventParser.d.ts +6 -0
  37. package/src/core/handlers/field/masks.d.ts +4 -0
  38. package/src/core/handlers/field/mount.d.ts +2 -0
  39. package/src/core/handlers/field/validations.d.ts +4 -0
  40. package/src/core/handlers/field/visibilityConditions.d.ts +4 -0
  41. package/src/core/handlers/flows.d.ts +36 -0
  42. package/src/core/handlers/form/hooks.d.ts +3 -0
  43. package/src/core/handlers/form/steps.d.ts +2 -0
  44. package/src/core/handlers/form/templating.d.ts +2 -0
  45. package/src/core/handlers/form/validate.d.ts +2 -0
  46. package/src/core/handlers/form/visibilityConditions.d.ts +4 -0
  47. package/src/core/index.d.ts +3 -0
  48. package/src/core/managers/Base.d.ts +19 -0
  49. package/src/core/managers/Factory.d.ts +52 -0
  50. package/src/core/managers/Field.d.ts +31 -0
  51. package/src/core/managers/Form.d.ts +32 -0
  52. package/src/core/managers/Scope.d.ts +12 -0
  53. package/src/core/managers/index.d.ts +1 -0
  54. package/src/core/types/index.d.ts +621 -0
  55. package/src/core/utils/credit-card.d.ts +16 -0
  56. package/src/core/utils/index.d.ts +4 -0
  57. package/src/core/utils/object.d.ts +24 -0
  58. package/src/core/utils/string.d.ts +3 -0
  59. package/src/index.d.ts +3 -0
  60. package/types.js +2 -0
  61. package/types.js.map +1 -0
@@ -0,0 +1,32 @@
1
+ import Field from '@core/managers/Field';
2
+ import Scope from '@core/managers/Scope';
3
+ import Base from '@core/managers/Base';
4
+ import * as Events from '@core/events';
5
+ import { TComponent, TFormValues, TSchema, TStepData, TComponentPropsMapping, TFormEventDirectives, TEventsKeys } from '@core/types';
6
+ declare class Form extends Base {
7
+ #private;
8
+ formData: TFormValues;
9
+ formId: string;
10
+ schema: TSchema;
11
+ scopedSchema: TSchema;
12
+ scope: Scope;
13
+ initialValues: Record<string, unknown>;
14
+ steps: Record<number, {
15
+ [x in string]: Field;
16
+ }>;
17
+ group: string;
18
+ constructor(formId: string, observer: Events.Observer, scope: Scope, schema: TSchema, opts: {
19
+ initialValues: Record<string, unknown>;
20
+ }, group: any);
21
+ get step(): TStepData;
22
+ set step(step: TStepData);
23
+ get fields(): {
24
+ [x: string]: Field;
25
+ };
26
+ eventReducedSchema(event: TEventsKeys): TFormEventDirectives;
27
+ getFieldInstance(component: TComponent, propsMapping?: TComponentPropsMapping): Field;
28
+ rehydrate(): void;
29
+ destroyField(field: string): void;
30
+ }
31
+ export default Form;
32
+ export type { Form };
@@ -0,0 +1,12 @@
1
+ import { TScope, TSetGlobalScope } from '@core/types';
2
+ import { Observer } from '@core/events';
3
+ import Base from '@core/managers/Base';
4
+ declare class Scope extends Base {
5
+ #private;
6
+ constructor(observer: Observer);
7
+ get scope(): TScope;
8
+ getGlobalScope<T extends TScope>(namespace?: string, key?: string): T;
9
+ set initialScope(data: TScope);
10
+ set globalScope({ namespace, key, data }: TSetGlobalScope);
11
+ }
12
+ export default Scope;
@@ -0,0 +1 @@
1
+ export { getFormInstance, getGroupFormsIds } from '@core/managers/Factory';
@@ -0,0 +1,621 @@
1
+ /// <reference types="react" />
2
+ import { ICustomValidationValue } from '@core/apis/validations';
3
+ import { EEVents } from '@core/constants';
4
+ import { TEventInformation } from '@core/events';
5
+ export declare type TObserverData = {
6
+ data: any;
7
+ event: TEventsKeys;
8
+ namespace: string;
9
+ payload: any;
10
+ };
11
+ export declare type TObservable = (data: any, unsubscribe: () => void) => any;
12
+ export declare type TEvents = Record<string, TObservable[]>;
13
+ export interface IObservable {
14
+ events: TEvents;
15
+ }
16
+ export declare type TScopeNamespaces = 'global' | 'api' | 'hooks' | 'fields' | 'configs';
17
+ export declare type TSetGlobalScope = {
18
+ namespace: TScopeNamespaces;
19
+ key?: string;
20
+ data: any;
21
+ merge?: boolean;
22
+ };
23
+ export declare type TScope = {
24
+ global?: any;
25
+ api?: any;
26
+ hooks?: any;
27
+ configs?: TConfigs & {
28
+ disable?: boolean;
29
+ enableLogging?: boolean;
30
+ };
31
+ fields?: any;
32
+ };
33
+ export declare type TMapper = Record<string, Record<string, unknown>>;
34
+ export declare type TMaskGeneric = {
35
+ to: number;
36
+ from: number;
37
+ mask: string;
38
+ }[];
39
+ declare type TCurrencyMask = {
40
+ locale: string;
41
+ currency: string;
42
+ };
43
+ export declare type TComponentMasks = {
44
+ generic?: TMaskGeneric;
45
+ cardNumber?: boolean;
46
+ hideCardNumber?: boolean;
47
+ cardMask?: boolean;
48
+ cardDate?: boolean;
49
+ currencyMask?: TCurrencyMask;
50
+ feinMask?: boolean;
51
+ replaceAll?: string | number;
52
+ };
53
+ declare type TFormMessages = Record<string, {
54
+ name: string;
55
+ value?: any;
56
+ values?: string[];
57
+ required?: boolean;
58
+ }>;
59
+ export declare type TChildrenOptions = {
60
+ childrenScope?: string[];
61
+ blurredChildren?: string[];
62
+ changedChildren?: string[];
63
+ scopeBlurredChildren?: boolean;
64
+ scopeChangedChildren?: boolean;
65
+ };
66
+ export declare type TFieldData = Record<string, TField>;
67
+ export declare type TFormRefActions = {
68
+ submit(): void;
69
+ stepForward(): TFormValues;
70
+ stepBack(): TFormValues;
71
+ validateForm(opts?: TChildrenOptions): Promise<TFormValues>;
72
+ values(opts: Pick<TChildrenOptions, 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'>): TFormValues;
73
+ };
74
+ export declare type THookPayload = {
75
+ setScope(data: TSetGlobalScope): void;
76
+ };
77
+ export declare type THooks = {
78
+ preMount?: () => Record<string, unknown>;
79
+ preUnmount?: () => Record<string, unknown>;
80
+ preSubmit?: (formData: TFormValues) => Record<string, unknown>;
81
+ posSubmit?: (formData: TFormValues) => Record<string, unknown>;
82
+ };
83
+ export declare type TIVars = Record<string, unknown>;
84
+ export declare type TEventsKeys = keyof typeof EEVents;
85
+ export declare enum TAvailableHooks {
86
+ 'preMount' = "preMount",
87
+ 'preUnmount' = "preUnmount",
88
+ 'preSubmit' = "preSubmit",
89
+ 'postSubmit' = "postSubmit"
90
+ }
91
+ export declare type TField = {
92
+ value?: string | number | boolean;
93
+ errors?: TErrors;
94
+ visible?: boolean;
95
+ failedErrorMessages?: string[];
96
+ mask?: string;
97
+ changed?: boolean;
98
+ blured?: boolean;
99
+ focused?: boolean;
100
+ name: string;
101
+ mounted: boolean;
102
+ metadata?: any;
103
+ ignore?: boolean;
104
+ schemaLocation?: {
105
+ step: number;
106
+ depth: number;
107
+ index: number;
108
+ };
109
+ };
110
+ declare type TPathError = Omit<TSchemaValidation, 'path'> & {
111
+ path?: string;
112
+ paths?: string[];
113
+ preventUnMountValidation?: boolean;
114
+ };
115
+ export declare type TValidationDateFormats = 'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp';
116
+ export declare type TValidationDateOperators = '<' | '>' | '===' | '>=' | '<=' | '!==';
117
+ export declare type TVAvailableValitationConditionsSet = {
118
+ forceDefinedOrigin?: boolean;
119
+ forceDefinedTarget?: boolean;
120
+ origin?: string | number | boolean;
121
+ condition: TValidationDateOperators;
122
+ target?: string | number | boolean;
123
+ };
124
+ export declare type TVAvailableValitationConditions = {
125
+ rule: 'and' | 'or';
126
+ set: TVAvailableValitationConditionsSet[];
127
+ };
128
+ export declare type TVAvailableValidations = {
129
+ /**
130
+ * Validation based on conditions
131
+ *
132
+ * @example - Compare own field to two. Origin and target default to field value
133
+ * ```
134
+ * conditions: {
135
+ rule: 'and',
136
+ set: [
137
+ {
138
+ condition: '===',
139
+ target: '2',
140
+ },
141
+ {
142
+ origin: '2',
143
+ condition: '===',
144
+ },
145
+ ],
146
+ },
147
+ * ```
148
+ * @example - Binded to Postcode field value. Must be greater than or equal two
149
+ * ```
150
+ * conditions: {
151
+ rule: 'or',
152
+ set: [
153
+ {
154
+ origin: '${fields.postcode.value}',
155
+ condition: '>',
156
+ target: '2',
157
+ },
158
+ {
159
+ origin: '${fields.postcode.value}',
160
+ condition: '===',
161
+ target: '2',
162
+ },
163
+ ],
164
+ },
165
+ * ```
166
+ * @example - Binded to Postcode field value. Must be equal to two
167
+ * ```
168
+ * conditions: {
169
+ rule: 'or',
170
+ set: [
171
+ {
172
+ origin: '${fields.postcode.value}',
173
+ condition: '===',
174
+ target: '2',
175
+ },
176
+ ],
177
+ },
178
+ * ```
179
+ */
180
+ conditions?: TVAvailableValitationConditions;
181
+ /**
182
+ * Dates validations
183
+ *
184
+ * @example - Dates should be different
185
+ * ```
186
+ * date: {
187
+ operator: '!==',
188
+ origin: {
189
+ format: 'DDMMYYYY',
190
+ },
191
+ target: {
192
+ format: 'DDMMYYYY',
193
+ value: '10/10/2001',
194
+ },
195
+ },
196
+ * ```
197
+ *
198
+ * @example - Compare only valid dates using intervals
199
+ * ```
200
+ * date: {
201
+ * onlyValidDate: true,
202
+ * operator: '<',
203
+ * origin: {
204
+ * format: 'DD/MM/YYYY',
205
+ * intervals: {
206
+ * years: 1,
207
+ * },
208
+ * },
209
+ * },
210
+ * ```
211
+ *
212
+ * @example - Should have at max 85 years
213
+ * ```
214
+ * {
215
+ operator: '>',
216
+ origin: {
217
+ format: 'DDMMYYYY',
218
+ value: eightyFiveYearsDate,
219
+ intervals: {
220
+ years: 85,
221
+ },
222
+ },
223
+ }
224
+ * }
225
+ *
226
+ * ```
227
+ */
228
+ date?: {
229
+ /**
230
+ * Flag to force only valid dates. Valid dates must be of min length of 8
231
+ */
232
+ onlyValidDate?: boolean;
233
+ /**
234
+ * List of operations you can do
235
+ * - between origin and target dates
236
+ * - Betweeen origin and intervals
237
+ */
238
+ operator: TValidationDateOperators;
239
+ /**
240
+ * The origin configurations
241
+ */
242
+ origin: {
243
+ /**
244
+ * Origin date value
245
+ */
246
+ value?: string | number;
247
+ /**
248
+ * The available date formats
249
+ */
250
+ format: TValidationDateFormats;
251
+ /**
252
+ * Intervals to compare with the original date.
253
+ *
254
+ * It will use todays date for comparison.
255
+ *
256
+ * @example
257
+ *
258
+ * origin date = 10/10/2022
259
+ * interval.year = 1
260
+ * operator = '==='
261
+ *
262
+ * It will compare (10/10/2022 + 1) with the current date and check if they are the same
263
+ */
264
+ intervals?: {
265
+ years?: number;
266
+ months?: number;
267
+ days?: number;
268
+ };
269
+ };
270
+ target?: {
271
+ value: string | number;
272
+ format: TValidationDateFormats;
273
+ };
274
+ };
275
+ /**
276
+ * Allow to define a maximum length for the input to have no error
277
+ */
278
+ length?: number;
279
+ /**
280
+ * Will look into the input length and send an error if if not greater than this value
281
+ */
282
+ greaterThan?: number | string;
283
+ regex?: string;
284
+ maxLength?: number;
285
+ minLength?: number;
286
+ required?: boolean;
287
+ onlyLetters?: boolean;
288
+ value?: string | number | boolean;
289
+ notEmpty?: boolean;
290
+ callback?(value: string | number): {
291
+ fail: boolean;
292
+ errorMessage?: string;
293
+ };
294
+ numericRange?: {
295
+ start: number | string;
296
+ end: number | string;
297
+ };
298
+ isNumber?: boolean;
299
+ hasNoExtraSpaces?: boolean;
300
+ email?: boolean;
301
+ lessThan?: number | string;
302
+ sequentialNumber?: boolean;
303
+ repeatedNumbers?: boolean;
304
+ url?: boolean;
305
+ path?: TPathError;
306
+ isCreditCard?: string[];
307
+ isCreditCardAndLength?: string[];
308
+ isCreditCodeMatch?: {
309
+ numberCard: string;
310
+ availableOptions: string[];
311
+ };
312
+ customValidation?: ICustomValidationValue[];
313
+ notAllowSpaces?: true;
314
+ isInTheList?: string[] | number[] | string;
315
+ fields?: {
316
+ rule: 'every';
317
+ set: {
318
+ bind: string;
319
+ fieldName: string;
320
+ validations: Omit<TVAvailableValidations, 'fields'>;
321
+ }[];
322
+ };
323
+ };
324
+ export declare type TGenericValidationRule = {
325
+ [key: string]: TVAvailableValidations;
326
+ };
327
+ export declare type TSchemaValidation = TVAvailableValidations | TGenericValidationRule;
328
+ export declare type TStepData = {
329
+ navigated: boolean;
330
+ index: number;
331
+ data: Record<number, Pick<TFormValues, 'fields' | 'erroredFields' | 'formatted' | 'filteredFields'>>;
332
+ currentStepSchema?: TComponent;
333
+ isValid: boolean;
334
+ numSteps?: number;
335
+ };
336
+ export declare type TFormValues = {
337
+ predictableErroredFields: string[];
338
+ erroredFields: string[];
339
+ fields: TFieldData;
340
+ formatted: Record<string, unknown>;
341
+ filteredFields?: Record<string, unknown>;
342
+ form: {
343
+ steps: TStepData;
344
+ isValid: boolean;
345
+ messages: string[];
346
+ scope: TScope;
347
+ };
348
+ };
349
+ export declare type TError = {
350
+ value: unknown;
351
+ message?: string;
352
+ fail: boolean;
353
+ };
354
+ export declare type TErrors = Record<string, TError> | undefined;
355
+ export declare type TErrorMessages = Record<string, string>;
356
+ export declare type TSchemaValidations = TSchemaHandler<TSchemaValidation>;
357
+ declare type TFormLevelSchemaHandler<T> = Partial<Record<EEVents.ON_FIELD_CHANGE | EEVents.ON_FORM_REHYDRATE | EEVents.ON_FORM_MOUNT | EEVents.ON_SCOPE_CHANGE, T>>;
358
+ declare type TSchemaHandler<T> = Partial<Record<EEVents.ON_FIELD_REHYDRATE | EEVents.ON_FIELD_CHANGE | EEVents.ON_FIELD_BLUR | EEVents.ON_FIELD_MOUNT | EEVents.ON_FIELD_FOCUS, T>>;
359
+ export declare type TSchemaVisibilityConditions = {
360
+ /**
361
+ * The validations that will say if the target field will be visible or not
362
+ *
363
+ * Those validations will run against your field (the one that has this directive)
364
+ */
365
+ validations: TSchemaValidation;
366
+ /**
367
+ * Target field that will have the visibility toggled
368
+ */
369
+ fieldName?: string;
370
+ /**
371
+ * Target fields that will have the visibility toggled
372
+ */
373
+ fieldNames?: string[];
374
+ }[];
375
+ export declare type TSchemaClearFields = {
376
+ /**
377
+ * Validations to run for the target field
378
+ */
379
+ validations?: TSchemaValidation;
380
+ /**
381
+ * target fields that will be used in the validation specified
382
+ */
383
+ fields: string[];
384
+ /**
385
+ * The cleared values on the fields in case they do no pass the validation
386
+ */
387
+ clearedValue: string | number | boolean;
388
+ }[];
389
+ export declare type TSchemaApi = {
390
+ /**
391
+ * Specify a debounce time in miliseconds for your call
392
+ */
393
+ debounceTime?: number;
394
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH';
395
+ url: string;
396
+ headers?: HeadersInit | undefined;
397
+ body?: Record<string, any>;
398
+ scope?: string;
399
+ blockRequestWhenInvalid?: boolean;
400
+ preConditions?: TSchemaValidation;
401
+ }[];
402
+ export declare type TSchemaMasks = {
403
+ cleanMask?: boolean;
404
+ } & TComponentMasks;
405
+ export declare type TFormEventDirectives = {
406
+ visibilityConditions: TSchemaVisibilityConditions;
407
+ };
408
+ export declare type TEventReducedSchema = {
409
+ api: TSchemaApi;
410
+ clearFields: TSchemaClearFields;
411
+ formatters: TSchemaFormatters;
412
+ masks: TSchemaMasks;
413
+ validations: TSchemaValidation;
414
+ visibilityConditions: TSchemaVisibilityConditions;
415
+ };
416
+ export declare type TComponent = {
417
+ /**
418
+ * This name will be used latter to corelate the field with the value and you will be able to read it
419
+ *
420
+ * You can also mount here complex objects like
421
+ *
422
+ * name={a.b.c}
423
+ *
424
+ * that will result in
425
+ * a: {
426
+ * b: {
427
+ * c: 'field_value'
428
+ * }
429
+ * }
430
+ */
431
+ name: string;
432
+ /**
433
+ * A component name that should map to the one you gave in the from mappings
434
+ *
435
+ * @example - For React
436
+ * ```
437
+ * const mappings: TMapper = {
438
+ * input: { component: Input },
439
+ * formGroup: { component: FormGroup },
440
+ * };
441
+ * ```
442
+ *
443
+ * The component name for the Input element will be "input" ending up like
444
+ * ```
445
+ * {
446
+ * component: 'input'
447
+ * }
448
+ * ```
449
+ */
450
+ component: string;
451
+ /**
452
+ * You can attach metadata to your component that will be forwarded to you after on your frontend
453
+ * callback methods link `onData`, `onBlur` etc
454
+ */
455
+ metadata?: Record<string, any>;
456
+ /**
457
+ * This property allows you to specify a virtual fieldName that can be in several fields
458
+ *
459
+ * USAGE - You have two fields but you want to have the value stored only under one name
460
+ *
461
+ */
462
+ group?: string;
463
+ wrapper?: new () => React.Component;
464
+ children?: TComponent[];
465
+ /**
466
+ * Field error messages in case any validation fails
467
+ *
468
+ * @example - Set a default error message for all the validations
469
+ *
470
+ * ```
471
+ * {
472
+ * errorMessages: {
473
+ * default: 'default error message'
474
+ * }
475
+ * }
476
+ * ```
477
+ *
478
+ * @example - Set error message for a given validation
479
+ *
480
+ * ```
481
+ * {
482
+ * validations: {
483
+ * ON_FIELD_CHANGE: {
484
+ * required: true
485
+ * }
486
+ * },
487
+ * errorMessages: {
488
+ * required: 'This field is required'
489
+ * }
490
+ * }
491
+ * ```
492
+ *
493
+ */
494
+ errorMessages?: TErrorMessages;
495
+ type?: 'text' | 'number' | string;
496
+ /**
497
+ * Allow you to set a initial state for this field
498
+ */
499
+ state?: {
500
+ /**
501
+ * Hide the field
502
+ */
503
+ hidden?: boolean;
504
+ /**
505
+ * Ignore value from field
506
+ */
507
+ ignoreValue?: boolean;
508
+ };
509
+ /**
510
+ * This key lets you inject props directly into the component
511
+ */
512
+ props?: Record<string, unknown>;
513
+ /**
514
+ * Setup validations to be used in the field.
515
+ *
516
+ * You can setup validations in several life-cycle methods
517
+ *
518
+ * @example - Required validation
519
+ * ```
520
+ * validations: {
521
+ ON_FIELD_CHANGE: {
522
+ required: true,
523
+ },
524
+ },
525
+ * ```
526
+ */
527
+ validations?: TSchemaHandler<Pick<TEventReducedSchema, 'validations'>['validations']>;
528
+ filter?: Pick<TEventReducedSchema, 'validations'>['validations'];
529
+ /**
530
+ * Allows you to specify the conditions a given field will be visible
531
+ * what will run when this field meets the specified life-cycle
532
+ */
533
+ visibilityConditions?: TSchemaHandler<Pick<TEventReducedSchema, 'visibilityConditions'>['visibilityConditions']>;
534
+ /**
535
+ * Will clear target fields in case they do not pass with the specified validations
536
+ */
537
+ clearFields?: TSchemaHandler<Pick<TEventReducedSchema, 'clearFields'>['clearFields']>;
538
+ api?: TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>;
539
+ masks?: Partial<Record<EEVents.ON_FIELD_BLUR | EEVents.ON_FIELD_MOUNT | EEVents.ON_FIELD_FOCUS | EEVents.ON_FIELD_CHANGE, Pick<TEventReducedSchema, 'masks'>['masks']>>;
540
+ formatters?: TSchemaHandler<Pick<TEventReducedSchema, 'formatters'>['formatters']>;
541
+ };
542
+ export declare type TStep = {
543
+ component: string;
544
+ name: string;
545
+ children: TComponent[];
546
+ props?: Record<string, string>;
547
+ };
548
+ export declare type TComponentPropsMapping = {
549
+ getValue?: string;
550
+ setValue?: string;
551
+ onBlur?: string;
552
+ onFocus?: string;
553
+ setErrorMessage?: string;
554
+ setErrorState?: string;
555
+ };
556
+ export declare type TPropsMapping = Record<string, TComponentPropsMapping>;
557
+ export declare type TSchema = {
558
+ action?: string;
559
+ method?: string;
560
+ /**
561
+ * Give some configurations to the form
562
+ */
563
+ configs?: TConfigs;
564
+ /**
565
+ * Allows you to expose some messages to the outside world when something happen
566
+ */
567
+ messages?: TFormMessages;
568
+ /**
569
+ * Specify some static field defaults before rendereing the form.
570
+ *
571
+ * If you have initialValues in the frontend setted, those will ovewride this
572
+ */
573
+ formattedDataDefaults?: Record<string, unknown>;
574
+ /**
575
+ * Form level props mapping
576
+ */
577
+ propsMapping?: TPropsMapping;
578
+ visibilityConditions?: TFormLevelSchemaHandler<TSchemaVisibilityConditions>;
579
+ /**
580
+ * Entry point for the form should be a step (even if you have only one)
581
+ */
582
+ components: TStep[];
583
+ /**
584
+ * You can have many fields in the form, but be interested only in some
585
+ *
586
+ * You can put here the fields you want to read onSubmit for example
587
+ *
588
+ * You will receive those in TFormValues.filteredFields
589
+ */
590
+ filteredFields?: string[];
591
+ /**
592
+ * Schema level iVars.
593
+ *
594
+ * These iVars will go to the global scope namespace
595
+ */
596
+ iVars?: TIVars;
597
+ };
598
+ export declare type TSplitterFormatterValue = {
599
+ value: string;
600
+ position: number;
601
+ }[];
602
+ export declare type TSchemaFormatters = {
603
+ splitter?: TSplitterFormatterValue;
604
+ capitalize?: boolean;
605
+ upperCase?: boolean;
606
+ gapsCreditCard?: string[];
607
+ };
608
+ export declare type TConfigs = {
609
+ observables?: {
610
+ templates?: {
611
+ exclude?: string[];
612
+ };
613
+ };
614
+ };
615
+ export declare type TFlowType = {
616
+ [x: string]: {
617
+ events: (component?: TComponent) => EEVents[];
618
+ handler: (args: TEventInformation) => void;
619
+ }[];
620
+ };
621
+ export {};
@@ -0,0 +1,16 @@
1
+ export interface ICreditCardType {
2
+ niceType: string;
3
+ type: string;
4
+ patterns: number[] | [number[]];
5
+ gaps: number[];
6
+ lengths: number[];
7
+ code: {
8
+ size: number;
9
+ name: string;
10
+ };
11
+ matchStrength?: number;
12
+ }
13
+ declare type TGetTypeCard = [ICreditCardType, string];
14
+ export declare const getTypeCard: (value: string, availableOptions?: string[]) => TGetTypeCard;
15
+ export declare const formatValue: (value: string, type: ICreditCardType) => string;
16
+ export {};
@@ -0,0 +1,4 @@
1
+ export * as object from '@core/utils/object';
2
+ export * as creditCard from '@core/utils/credit-card';
3
+ export type { ICreditCardType } from '@core/utils/credit-card';
4
+ export * as string from '@core/utils/string';