kwikid-forms 0.1.8 → 0.1.10

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 (55) hide show
  1. package/bundles/kwikid-forms.umd.js +405 -878
  2. package/bundles/kwikid-forms.umd.js.map +1 -1
  3. package/esm2015/lib/renderer/form-view/definitions/form-view.actions.definition.js +21 -0
  4. package/esm2015/lib/renderer/form-view/definitions/form-view.apis.definition.js +8 -0
  5. package/esm2015/lib/renderer/form-view/definitions/form-view.commons.definition.js +8 -0
  6. package/esm2015/lib/renderer/form-view/definitions/form-view.fields.definition.js +16 -0
  7. package/esm2015/lib/renderer/form-view/definitions/form-view.form-validations.definition.js +2 -0
  8. package/esm2015/lib/renderer/form-view/definitions/form-view.triggers.definition.js +2 -0
  9. package/esm2015/lib/renderer/form-view/form-view.component.js +101 -93
  10. package/esm2015/lib/renderer/form-view/form-view.service.js +14 -7
  11. package/esm2015/lib/renderer/form-view/helpers/form-view.apis.helper.js +29 -79
  12. package/esm2015/lib/renderer/form-view/helpers/form-view.defaults.helper.js +17 -15
  13. package/esm2015/lib/renderer/form-view/helpers/form-view.fields.helper.js +43 -59
  14. package/esm2015/lib/renderer/form-view/helpers/form-view.form-validations.helper.js +101 -0
  15. package/esm2015/lib/renderer/renderer.component.js +8 -7
  16. package/esm2015/lib/renderer/renderer.config-converter.helper.js +5 -5
  17. package/esm2015/lib/renderer/renderer.service.js +11 -14
  18. package/fesm2015/kwikid-forms.js +289 -675
  19. package/fesm2015/kwikid-forms.js.map +1 -1
  20. package/lib/renderer/form-view/definitions/{actions/form-view.actions.type.definitions.d.ts → form-view.actions.definition.d.ts} +21 -9
  21. package/lib/renderer/form-view/definitions/{apis/form-view.apis.type.definitions.d.ts → form-view.apis.definition.d.ts} +7 -3
  22. package/lib/renderer/form-view/definitions/form-view.commons.definition.d.ts +11 -0
  23. package/lib/renderer/form-view/definitions/{fields/form-view.fields.type.definitions.d.ts → form-view.fields.definition.d.ts} +19 -6
  24. package/lib/renderer/form-view/definitions/form-view.form-validations.definition.d.ts +8 -0
  25. package/lib/renderer/form-view/definitions/{triggers/form-view.triggers.type.definitions.d.ts → form-view.triggers.definition.d.ts} +0 -0
  26. package/lib/renderer/form-view/form-view.component.d.ts +3 -3
  27. package/lib/renderer/form-view/helpers/form-view.apis.helper.d.ts +7 -10
  28. package/lib/renderer/form-view/helpers/form-view.defaults.helper.d.ts +3 -3
  29. package/lib/renderer/form-view/helpers/form-view.fields.helper.d.ts +12 -17
  30. package/lib/renderer/form-view/helpers/form-view.form-validations.helper.d.ts +10 -0
  31. package/package.json +2 -2
  32. package/esm2015/lib/renderer/form-view/definitions/actions/form-view.actions.enum.definitions.js +0 -21
  33. package/esm2015/lib/renderer/form-view/definitions/actions/form-view.actions.type.definitions.js +0 -2
  34. package/esm2015/lib/renderer/form-view/definitions/apis/form-view.apis.enum.definitions.js +0 -8
  35. package/esm2015/lib/renderer/form-view/definitions/apis/form-view.apis.type.definitions.js +0 -2
  36. package/esm2015/lib/renderer/form-view/definitions/common/form-view.common.enum.definitions.js +0 -101
  37. package/esm2015/lib/renderer/form-view/definitions/common/form-view.common.type.definitions.js +0 -2
  38. package/esm2015/lib/renderer/form-view/definitions/fields/form-view.fields.enum.definitions.js +0 -16
  39. package/esm2015/lib/renderer/form-view/definitions/fields/form-view.fields.type.definitions.js +0 -2
  40. package/esm2015/lib/renderer/form-view/definitions/sources/form-view.sources.type.definitions.js +0 -2
  41. package/esm2015/lib/renderer/form-view/definitions/triggers/form-view.triggers.type.definitions.js +0 -2
  42. package/esm2015/lib/renderer/form-view/definitions/validations/form-view.validations.type.definitions.js +0 -2
  43. package/esm2015/lib/renderer/form-view/helpers/form-view.common.helper.js +0 -136
  44. package/esm2015/lib/renderer/form-view/helpers/form-view.validations.helper.js +0 -170
  45. package/esm2015/lib/renderer/renderer.helper.js +0 -50
  46. package/lib/renderer/form-view/definitions/actions/form-view.actions.enum.definitions.d.ts +0 -19
  47. package/lib/renderer/form-view/definitions/apis/form-view.apis.enum.definitions.d.ts +0 -6
  48. package/lib/renderer/form-view/definitions/common/form-view.common.enum.definitions.d.ts +0 -97
  49. package/lib/renderer/form-view/definitions/common/form-view.common.type.definitions.d.ts +0 -7
  50. package/lib/renderer/form-view/definitions/fields/form-view.fields.enum.definitions.d.ts +0 -14
  51. package/lib/renderer/form-view/definitions/sources/form-view.sources.type.definitions.d.ts +0 -16
  52. package/lib/renderer/form-view/definitions/validations/form-view.validations.type.definitions.d.ts +0 -16
  53. package/lib/renderer/form-view/helpers/form-view.common.helper.d.ts +0 -19
  54. package/lib/renderer/form-view/helpers/form-view.validations.helper.d.ts +0 -28
  55. package/lib/renderer/renderer.helper.d.ts +0 -6
@@ -5,15 +5,14 @@ import * as i6 from '@angular/forms';
5
5
  import { FormGroup, FormControl, Validators, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
6
6
  import * as i2 from 'kwikui';
7
7
  import { KwikUIButtonComponent, KwikUIProgressSegmentedComponent, KwikUIInputComponent, KwikUIModule } from 'kwikui';
8
- import _, { cloneDeep } from 'lodash';
8
+ import { cloneDeep } from 'lodash';
9
9
  import { __awaiter, __decorate } from 'tslib';
10
10
  import * as i3 from '@taiga-ui/core';
11
11
  import { TuiAlertService, TuiLabelModule, TuiSvgModule, TuiLoaderModule } from '@taiga-ui/core';
12
12
  import * as i4 from '@taiga-ui/kit';
13
13
  import { TuiPushService, TuiPushModule } from '@taiga-ui/kit';
14
- import { Sources, Rules, Condition, Actions, logMethod, isNotEmptyValue, checkObjectKeyExists, isEmptyValue, isUndefined as isUndefined$1, replaceString as replaceString$1, getObjectValueFromPath, Validations as Validations$1 } from 'kwikid-toolkit';
14
+ import { checkObjectKeyExists, isNotEmptyValue, Source, setValueToObjectPath, Rule, Condition, Action, isEmptyValue, logMethod, PATTERNS, Validation, isUndefined, replaceString, getObjectValueFromPath } from 'kwikid-toolkit';
15
15
  import { pairwise } from 'rxjs/operators';
16
- import jp from 'jsonpath';
17
16
  import { TuiDay } from '@taiga-ui/cdk';
18
17
  import * as i5 from '@angular/common';
19
18
  import { CommonModule } from '@angular/common';
@@ -182,99 +181,6 @@ var EApiStatusType;
182
181
  EApiStatusType["FAILED"] = "failed";
183
182
  })(EApiStatusType || (EApiStatusType = {}));
184
183
 
185
- var EPatternKey;
186
- (function (EPatternKey) {
187
- EPatternKey["CUSTOM"] = "CUSTOM";
188
- EPatternKey["IS_ADDRESS"] = "IS_ADDRESS";
189
- EPatternKey["IS_ALPHA"] = "IS_ALPHA";
190
- EPatternKey["IS_ALPHANUMERIC"] = "IS_ALPHANUMERIC";
191
- EPatternKey["IS_BOOLEAN"] = "IS_BOOLEAN";
192
- EPatternKey["IS_EMAIL"] = "IS_EMAIL";
193
- EPatternKey["IS_EMPTY"] = "IS_EMPTY";
194
- EPatternKey["IS_FALSE"] = "IS_FALSE";
195
- EPatternKey["IS_HTML"] = "IS_HTML";
196
- EPatternKey["IS_INTEGER"] = "IS_INTEGER";
197
- EPatternKey["IS_IP_ADDRESS"] = "IS_IP_ADDRESS";
198
- EPatternKey["IS_JSON"] = "IS_JSON";
199
- EPatternKey["IS_LOWERCASE"] = "IS_LOWERCASE";
200
- EPatternKey["IS_NOT_EMPTY"] = "IS_NOT_EMPTY";
201
- EPatternKey["IS_NUMBER"] = "IS_NUMBER";
202
- EPatternKey["IS_TRUE"] = "IS_TRUE";
203
- EPatternKey["IS_UPPERCASE"] = "IS_UPPERCASE";
204
- EPatternKey["IS_URL"] = "IS_URL";
205
- EPatternKey["IS_AADHAAR_NUMBER"] = "IS_AADHAAR_NUMBER";
206
- EPatternKey["IS_BANK_ACCOUNT_NO"] = "IS_BANK_ACCOUNT_NO";
207
- EPatternKey["IS_BANK_SWIFT_CODE"] = "IS_BANK_SWIFT_CODE";
208
- EPatternKey["IS_BIRTH_CERTIFICATE_NO"] = "IS_BIRTH_CERTIFICATE_NO";
209
- EPatternKey["IS_CHEQUE_NO"] = "IS_CHEQUE_NO";
210
- EPatternKey["IS_CIN"] = "IS_CIN";
211
- EPatternKey["IS_CREDIT_CARD_NO"] = "IS_CREDIT_CARD_NO";
212
- EPatternKey["IS_DRIVING_LICENSE"] = "IS_DRIVING_LICENSE";
213
- EPatternKey["IS_GSTIN"] = "IS_GSTIN";
214
- EPatternKey["IS_IFSC_NO"] = "IS_IFSC_NO";
215
- EPatternKey["IS_MICR_CODE"] = "IS_MICR_CODE";
216
- EPatternKey["IS_MOBILE_NO"] = "IS_MOBILE_NO";
217
- EPatternKey["IS_MOBILE_NO_IN"] = "IS_MOBILE_NO_IN";
218
- EPatternKey["IS_NEFT_OR_RTGS_NO"] = "IS_NEFT_OR_RTGS_NO";
219
- EPatternKey["IS_PAN_NUMBER"] = "IS_PAN_NUMBER";
220
- EPatternKey["IS_PASSPORT"] = "IS_PASSPORT";
221
- EPatternKey["IS_PHONE_NO"] = "IS_PHONE_NO";
222
- EPatternKey["IS_PINCODE"] = "IS_PINCODE";
223
- EPatternKey["IS_PURCHASE_ORDER_NO"] = "IS_PURCHASE_ORDER_NO";
224
- EPatternKey["IS_RATION_CARD_NO"] = "IS_RATION_CARD_NO";
225
- EPatternKey["IS_SERVICE_TAX_NO"] = "IS_SERVICE_TAX_NO";
226
- EPatternKey["IS_SOCIAL_SECURITY_NO"] = "IS_SOCIAL_SECURITY_NO";
227
- EPatternKey["IS_UPI_TRANSACTION_REFERENCE_NO"] = "IS_UPI_TRANSACTION_REFERENCE_NO";
228
- EPatternKey["IS_VAT_TIN_NO"] = "IS_VAT_TIN_NO";
229
- EPatternKey["IS_VEHICLE_REGISTRATION_NO"] = "IS_VEHICLE_REGISTRATION_NO";
230
- EPatternKey["IS_VOTER_ID"] = "IS_VOTER_ID";
231
- })(EPatternKey || (EPatternKey = {}));
232
- var EPattern;
233
- (function (EPattern) {
234
- EPattern["IS_ALPHA"] = "^[a-zA-Z]+$";
235
- EPattern["IS_ADDRESS"] = "^(\\w*\\s*[#-,/.()&]*)+";
236
- EPattern["IS_ALPHANUMERIC"] = "^[a-zA-Z0-9]+$";
237
- EPattern["IS_BOOLEAN"] = "(true|false)";
238
- EPattern["IS_EMAIL"] = "^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$";
239
- EPattern["IS_EMPTY"] = "^$";
240
- EPattern["IS_FALSE"] = "false";
241
- EPattern["IS_HTML"] = "^<([a-z]+)([^<]+)(?:>(.)</\\1>|\\s+/>)$";
242
- EPattern["IS_INTEGER"] = "^[+-]?d+$";
243
- EPattern["IS_IP_ADDRESS"] = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
244
- EPattern["IS_JSON"] = "^\\s*({(.|\\s)}|[(.|\\s)])\\s*$";
245
- EPattern["IS_LOWERCASE"] = "^[a-z]+$";
246
- EPattern["IS_NOT_EMPTY"] = "^.+$";
247
- EPattern["IS_NUMBER"] = "^[+-]?d+(.d+)?$";
248
- EPattern["IS_TRUE"] = "true";
249
- EPattern["IS_UPPERCASE"] = "^[A-Z]+$";
250
- EPattern["IS_URL"] = "^(?:http(s)?://)?[w.-]+(?:.[w.-]+)+[w-._~:/?#[]@!$&'()*+,;=.]+$";
251
- EPattern["IS_AADHAAR_NUMBER"] = "^[0-9]{12}$";
252
- EPattern["IS_BANK_ACCOUNT_NO"] = "^[0-9]{9,18}$";
253
- EPattern["IS_BANK_SWIFT_CODE"] = "^[A-Z]{4}[A-Z]{2}[0-9A-Z]{2}[0-9A-Z]{3}$";
254
- EPattern["IS_BIRTH_CERTIFICATE_NO"] = "^[A-Z]{2}[0-9]{6}[A-Z]{1}[0-9]{2}$";
255
- EPattern["IS_CHEQUE_NO"] = "^[0-9]{6,14}$";
256
- EPattern["IS_CIN"] = "^[A-Z]{3}[0-9]{5}[0-9A-Z]{3}$";
257
- EPattern["IS_CREDIT_CARD_NO"] = "^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$";
258
- EPattern["IS_DRIVING_LICENSE"] = "^[A-Z]{2}[0-9]{2}((19|20)[0-9][0-9])[0-9]{7}$";
259
- EPattern["IS_GSTIN"] = "^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$";
260
- EPattern["IS_IFSC_NO"] = "^[A-Z]{4}[0][A-Z0-9]{6}$";
261
- EPattern["IS_MICR_CODE"] = "^[0-9]{9}$";
262
- EPattern["IS_MOBILE_NO"] = "^[6-9]\\d{9}$";
263
- EPattern["IS_MOBILE_NO_IN"] = "^(\\+91)[6-9]\\d{9}$";
264
- EPattern["IS_NEFT_OR_RTGS_NO"] = "^[A-Z]{4}[0-9]{7}$";
265
- EPattern["IS_PAN_NUMBER"] = "^[A-Z]{5}[[0-9]{4}[A-Z]{1}$";
266
- EPattern["IS_PASSPORT"] = "^[A-PR-WYa-pr-wy][1-9]\\d\\s?\\d{4}[1-9]$";
267
- EPattern["IS_PHONE_NO"] = "^[6-9]\\d{9}$";
268
- EPattern["IS_PINCODE"] = "^[1-9][0-9]{5}$";
269
- EPattern["IS_PURCHASE_ORDER_NO"] = "^[0-9]{1,5}$";
270
- EPattern["IS_RATION_CARD_NO"] = "^[A-Z]{3}[0-9]{7}$";
271
- EPattern["IS_SERVICE_TAX_NO"] = "^[A-Z]{5}[0-9]{4}[A-Z]{1}$";
272
- EPattern["IS_SOCIAL_SECURITY_NO"] = "^[0-9]{3}-[0-9]{2}-[0-9]{4}$";
273
- EPattern["IS_UPI_TRANSACTION_REFERENCE_NO"] = "^[a-zA-Z0-9]{3,128}@[a-z]{3,9}$";
274
- EPattern["IS_VAT_TIN_NO"] = "^[0-9]{11}$";
275
- EPattern["IS_VEHICLE_REGISTRATION_NO"] = "^[A-Z]{2}[0-9]{2}((19|20)[0-9][0-9])[0-9]{6}$";
276
- EPattern["IS_VOTER_ID"] = "^[A-Z]{3}[0-9]{7}$";
277
- })(EPattern || (EPattern = {}));
278
184
  var EMessageType;
279
185
  (function (EMessageType) {
280
186
  EMessageType["DEFAULT"] = "default";
@@ -299,278 +205,7 @@ var EFieldType;
299
205
  EFieldType["AADHAAR_NUMBER"] = "aadhaar-number";
300
206
  })(EFieldType || (EFieldType = {}));
301
207
 
302
- const hasKey$1 = (object, key) => {
303
- return object.hasOwnProperty(key);
304
- };
305
- const isEmpty$1 = (value) => {
306
- if (value === "" || value === undefined || value === null) {
307
- return true;
308
- }
309
- else if (value &&
310
- Object.keys(value).length === 0 &&
311
- Object.getPrototypeOf(value) === Object.prototype) {
312
- return true;
313
- }
314
- else if (Array.isArray(value)) {
315
- if (value.length === 0) {
316
- return true;
317
- }
318
- else {
319
- return false;
320
- }
321
- }
322
- else {
323
- return false;
324
- }
325
- };
326
- const isNotEmpty$1 = (value) => {
327
- return !isEmpty$1(value);
328
- };
329
- const handleJPQueryResponse$1 = (value) => {
330
- /**
331
- * jp.query doesn't always return an array with one element
332
- * so directly can't access with [0], need to check conditionally
333
- */
334
- if (Array.isArray(value)) {
335
- if (value.length > 0) {
336
- value = value[0];
337
- }
338
- else if (value.length === 0) {
339
- value = "";
340
- }
341
- }
342
- return value;
343
- };
344
- const jpQueryWrapper$1 = (obj, key) => {
345
- return handleJPQueryResponse$1(jp.query(obj, key));
346
- };
347
- const isSingleForm = (formsList) => {
348
- return formsList.length === 1;
349
- };
350
-
351
- const hasKey = (object, key) => {
352
- return object.hasOwnProperty(key);
353
- };
354
- const hasPath = (object, path) => {
355
- return _.has(object, path);
356
- };
357
- const isEmptyString = (value) => {
358
- return value === "";
359
- };
360
- const isUndefined = (value) => {
361
- return value === undefined;
362
- };
363
- const isNull = (value) => {
364
- return value === null;
365
- };
366
- const isEmptyObject = (object) => {
367
- return (object &&
368
- Object.keys(object).length === 0 &&
369
- Object.getPrototypeOf(object) === Object.prototype);
370
- };
371
- const isEmptyArray = (arr) => {
372
- return arr.length === 0;
373
- };
374
- const isEmpty = (value) => {
375
- if (isEmptyString(value) || isUndefined(value) || isNull(value)) {
376
- return true;
377
- }
378
- else if (isEmptyObject(value)) {
379
- return true;
380
- }
381
- else if (Array.isArray(value)) {
382
- if (isEmptyArray(value)) {
383
- return true;
384
- }
385
- else {
386
- return false;
387
- }
388
- }
389
- else {
390
- return false;
391
- }
392
- };
393
- const isNotEmpty = (value) => {
394
- return !isEmpty(value);
395
- };
396
- const isEmptyBrowserStorageValue = (value) => {
397
- return isNull(value) && isUndefined(value);
398
- };
399
- const isNotEmptyBrowserStorageValue = (value) => {
400
- return !isEmptyBrowserStorageValue(value);
401
- };
402
- const handleJPQueryResponse = (value) => {
403
- /**
404
- * jp.query doesn't always return an array with one element
405
- * so directly can't access with [0], need to check conditionally
406
- */
407
- if (Array.isArray(value)) {
408
- if (value.length > 0) {
409
- value = value[0];
410
- }
411
- else if (value.length === 0) {
412
- value = "";
413
- }
414
- }
415
- else {
416
- value = "";
417
- }
418
- return value;
419
- };
420
- const jpQueryWrapper = (obj, key) => {
421
- return handleJPQueryResponse(jp.query(obj, key));
422
- };
423
- const replaceString = (str, find, replace) => {
424
- return str.replace(new RegExp(find, "g"), replace);
425
- };
426
- const setFieldKeyValue = (field, path, value) => {
427
- return _.set(field, path, value);
428
- };
429
- const setValueToObject = (object, path, value) => {
430
- return _.set(object, path, value);
431
- };
432
- const formatValue = (field, fieldValue) => {
433
- const fieldType = field.type;
434
- let value;
435
- if (isNotEmpty(fieldValue)) {
436
- switch (fieldType) {
437
- case EFieldType.DATE:
438
- const splitDate = fieldValue.split("-");
439
- value = new TuiDay(Number(splitDate[2]), // Year
440
- Number(splitDate[1]) - 1, // Month, Why '-1' => Because Taiga-UI Required It, So...
441
- Number(splitDate[0]) // Day
442
- );
443
- break;
444
- case EFieldType.RADIO:
445
- const fieldRadio = field;
446
- value = fieldRadio.options.find((item) => {
447
- return item.label === fieldValue;
448
- });
449
- break;
450
- case EFieldType.CHECKBOX:
451
- value = Boolean(fieldValue);
452
- break;
453
- default:
454
- value = fieldValue;
455
- break;
456
- }
457
- }
458
- else {
459
- value = fieldValue;
460
- }
461
- return value;
462
- };
463
- const setEmptyValue = (field) => {
464
- const fieldType = field.type;
465
- let value;
466
- switch (fieldType) {
467
- case EFieldType.CHECKBOX:
468
- value = false;
469
- break;
470
- case EFieldType.NUMBER:
471
- value = null;
472
- break;
473
- case EFieldType.DATE:
474
- value = null;
475
- break;
476
- default:
477
- value = "";
478
- break;
479
- }
480
- return value;
481
- };
482
-
483
- class Defaults {
484
- constructor(field, formFields, allFormsData, formData, previousFormData, takeAction) {
485
- this._field = field;
486
- this._formFields = formFields;
487
- this._allFormsData = allFormsData;
488
- this._formData = formData;
489
- this._previousFormData = previousFormData;
490
- this._takeAction = takeAction;
491
- }
492
- getDefaultValue() {
493
- return __awaiter(this, void 0, void 0, function* () {
494
- let defaultValue;
495
- const sources = this._field.default.value.sources;
496
- let sourceIndex = 0;
497
- for (let source of sources) {
498
- const sources = new Sources({
499
- FIELD_CONFIG: this._field,
500
- FORM_FIELDS: this._formFields,
501
- FORM_DATA: this._formData,
502
- PREVIOUS_FORM_DATA: this._previousFormData,
503
- ALL_FORMS_DATA: this._allFormsData
504
- });
505
- const value = sources.getValueFromSource(source);
506
- // Set the Value of current source.
507
- this._field = setValueToObject(this._field, `default.value.sources.[${sourceIndex}].value`, value);
508
- const validation = source.validation;
509
- const triggers = validation.triggers;
510
- const rules = validation.rules;
511
- const actions = validation.actions;
512
- const rulesMapping = new Rules(rules, {
513
- FIELD_CONFIG: this._field,
514
- FORM_FIELDS: this._formFields,
515
- FORM_DATA: this._formData,
516
- PREVIOUS_FORM_DATA: this._previousFormData,
517
- ALL_FORMS_DATA: this._allFormsData
518
- }).mapping();
519
- for (let action of actions) {
520
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
521
- if (conditionEvaluation) {
522
- const actions = new Actions(action, rulesMapping, {
523
- FIELD_CONFIG: this._field,
524
- FORM_FIELDS: this._formFields,
525
- FORM_DATA: this._formData,
526
- PREVIOUS_FORM_DATA: this._previousFormData,
527
- ALL_FORMS_DATA: this._allFormsData
528
- }, this._takeAction);
529
- yield actions.execute();
530
- }
531
- }
532
- sourceIndex++;
533
- }
534
- defaultValue = this._field.default.value.value;
535
- if (isEmpty$1(defaultValue)) {
536
- defaultValue = setEmptyValue(this._field);
537
- }
538
- return defaultValue;
539
- });
540
- }
541
- getDefaultDropdownOptions() {
542
- return __awaiter(this, void 0, void 0, function* () {
543
- const optionsConfig = this._field.default.options;
544
- const rules = optionsConfig.rules;
545
- const actions = optionsConfig.actions;
546
- const rulesMapping = new Rules(rules, {
547
- FIELD_CONFIG: this._field,
548
- FORM_FIELDS: this._formFields,
549
- FORM_DATA: this._formData,
550
- PREVIOUS_FORM_DATA: this._previousFormData,
551
- ALL_FORMS_DATA: this._allFormsData
552
- }).mapping();
553
- for (let action of actions) {
554
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
555
- if (conditionEvaluation) {
556
- const actions = new Actions(action, rulesMapping, {
557
- FIELD_CONFIG: this._field,
558
- FORM_FIELDS: this._formFields,
559
- FORM_DATA: this._formData,
560
- PREVIOUS_FORM_DATA: this._previousFormData,
561
- ALL_FORMS_DATA: this._allFormsData
562
- }, this._takeAction);
563
- yield actions.execute();
564
- }
565
- }
566
- });
567
- }
568
- }
569
- __decorate([
570
- logMethod
571
- ], Defaults.prototype, "getDefaultValue", null);
572
-
573
- const findFieldFromKey = (fields, key) => {
208
+ const getFormFieldByKey = (fields, key) => {
574
209
  const field = fields.find((field) => {
575
210
  if (field.key === key) {
576
211
  return field;
@@ -578,59 +213,20 @@ const findFieldFromKey = (fields, key) => {
578
213
  });
579
214
  return field;
580
215
  };
581
- const findFieldIndexFromKey = (fields, key) => {
216
+ const getFormFieldIndexByKey = (fields, key) => {
582
217
  let fieldIndex;
583
218
  fieldIndex = fields.findIndex((_) => {
584
219
  return key === _.key;
585
220
  });
586
221
  return fieldIndex;
587
222
  };
588
- const getSearchTextOptionsFromRemoteFile = (field, childField, formGroup) => __awaiter(void 0, void 0, void 0, function* () {
589
- const parentFieldValue = formGroup.controls[field.key].value;
590
- // Determine the URL of the remote file to fetch
591
- let fileUrl;
592
- if (childField.regexToGetJsonRemoteUrlKey) {
593
- const fileKey = parentFieldValue.match(childField.regexToGetJsonRemoteUrlKey)[0];
594
- fileUrl = childField.jsonRemoteUrlMapping[fileKey];
595
- }
596
- else {
597
- fileUrl = childField.fileUrl;
598
- }
599
- // Return early if there is no file URL
600
- if (!fileUrl)
601
- return;
602
- // Fetch the remote file and parse its JSON data
603
- const response = yield fetch(fileUrl);
604
- const data = yield response.json();
605
- // Return the data for the given parent field value
606
- return data[parentFieldValue];
607
- });
608
- const getSearchTextOptionsFromFieldConfig = (field, childField, formGroup) => {
609
- let options;
610
- const fieldValue = formGroup.controls[field.key].value;
611
- if (isNotEmptyValue(childField["json"])) {
612
- options = childField["json"][fieldValue];
613
- }
614
- return options;
615
- };
616
- const formatSearchTextOptions = (options) => {
617
- return options.map(({ title }) => title);
618
- };
619
- function highlightFieldError(field, error) {
223
+ const highlightFormFieldError = (field, error) => {
620
224
  field.invalid = error;
621
225
  field.focus = error;
622
- // if (!error) {
623
- // field["messages"] = field["messages"].filter(function (fieldMessage: {
624
- // type: string;
625
- // message: string;
626
- // }) {
627
- // return fieldMessage.type === "error";
628
- // });
629
- // }
630
226
  return field;
631
- }
632
- const addMessage = (field, message) => {
633
- const isDuplicateMessage = (messages, message) => {
227
+ };
228
+ const appendFormFieldMessage = (field, message) => {
229
+ const hasDuplicateMessage = (messages, message) => {
634
230
  return messages.some((fieldMessage) => {
635
231
  return (fieldMessage.type === message.type &&
636
232
  fieldMessage.message === message.message);
@@ -638,7 +234,7 @@ const addMessage = (field, message) => {
638
234
  };
639
235
  field["messages"] = [];
640
236
  if (checkObjectKeyExists(field, "messages")) {
641
- if (!isDuplicateMessage(field["messages"], message)) {
237
+ if (!hasDuplicateMessage(field["messages"], message)) {
642
238
  field["messages"].push({
643
239
  type: message.type,
644
240
  message: message.message
@@ -650,13 +246,13 @@ const addMessage = (field, message) => {
650
246
  }
651
247
  return field;
652
248
  };
653
- const removeMessage = (field, message) => {
249
+ const removeFormFieldMessage = (field, message) => {
654
250
  field["messages"] = field["messages"].filter(function (fieldMessage) {
655
251
  return fieldMessage.type !== message.type;
656
252
  });
657
253
  return field;
658
254
  };
659
- function setFieldError(fields, errors, key, error) {
255
+ function showFormFieldError(fields, errors, key, error) {
660
256
  const fieldIndex = fields.findIndex((field) => {
661
257
  return field.key === key;
662
258
  });
@@ -695,7 +291,7 @@ function setFieldError(fields, errors, key, error) {
695
291
  return errorMessage;
696
292
  };
697
293
  Object.keys(errors).forEach((error) => {
698
- field = addMessage(field, {
294
+ field = appendFormFieldMessage(field, {
699
295
  type: "error",
700
296
  message: getErrorMessage(field.label, error)
701
297
  });
@@ -708,10 +304,10 @@ function setFieldError(fields, errors, key, error) {
708
304
  else {
709
305
  fields[fieldIndex]["messages"] = [];
710
306
  }
711
- fields[fieldIndex] = highlightFieldError(fields[fieldIndex], error);
307
+ fields[fieldIndex] = highlightFormFieldError(fields[fieldIndex], error);
712
308
  return fields;
713
309
  }
714
- const convertDateStringToTuiDayFormat = (date) => {
310
+ const convertFormFieldTypeDateToKwikUIFormat = (date) => {
715
311
  const splitDate = date.split("-");
716
312
  const tuiDay = new TuiDay(Number(splitDate[2]), // Year
717
313
  Number(splitDate[1]) - 1, // Month, Why '-1' => Because Taiga-UI Required It, So...
@@ -719,7 +315,7 @@ const convertDateStringToTuiDayFormat = (date) => {
719
315
  );
720
316
  return tuiDay;
721
317
  };
722
- const convertTuiDayFormatToDateString = (date) => {
318
+ const convertFormFieldTypeDateToStandardFormat = (date) => {
723
319
  let formattedDate;
724
320
  let year = date.year;
725
321
  let month = date.month;
@@ -729,12 +325,14 @@ const convertTuiDayFormatToDateString = (date) => {
729
325
  .padStart(2, "0")}-${year}`;
730
326
  return formattedDate;
731
327
  };
732
- const convertValueFromKwikUIFormatToBasicFormat = (field, value) => {
328
+ const convertFormFieldValueToStandardFormat = (field, value) => {
733
329
  let convertedValue = value;
734
330
  if (isNotEmptyValue(value)) {
735
331
  switch (field.type) {
736
332
  case EFieldType.DATE:
737
- convertedValue = convertTuiDayFormatToDateString(value);
333
+ if (typeof value !== "string") {
334
+ convertedValue = convertFormFieldTypeDateToStandardFormat(value);
335
+ }
738
336
  break;
739
337
  case EFieldType.RADIO:
740
338
  convertedValue = value.label;
@@ -744,7 +342,7 @@ const convertValueFromKwikUIFormatToBasicFormat = (field, value) => {
744
342
  }
745
343
  return convertedValue;
746
344
  };
747
- const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
345
+ const convertFormFieldValueToKwikUIFormat = (field, value) => {
748
346
  let convertedValue = value;
749
347
  if (isNotEmptyValue(value)) {
750
348
  switch (field.type) {
@@ -758,7 +356,7 @@ const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
758
356
  }
759
357
  break;
760
358
  case EFieldType.DATE:
761
- convertedValue = convertDateStringToTuiDayFormat(value);
359
+ convertedValue = convertFormFieldTypeDateToKwikUIFormat(value);
762
360
  break;
763
361
  case EFieldType.TITLE:
764
362
  break;
@@ -766,49 +364,127 @@ const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
766
364
  break;
767
365
  }
768
366
  }
367
+ else {
368
+ convertedValue = convertFormFieldEmptyValueToKwikUIFormat(field);
369
+ }
769
370
  return convertedValue;
770
371
  };
372
+ const convertFormFieldEmptyValueToKwikUIFormat = (field) => {
373
+ const fieldType = field.type;
374
+ let value;
375
+ switch (fieldType) {
376
+ case EFieldType.CHECKBOX:
377
+ value = false;
378
+ break;
379
+ case EFieldType.NUMBER:
380
+ value = null;
381
+ break;
382
+ case EFieldType.DATE:
383
+ value = null;
384
+ break;
385
+ default:
386
+ value = "";
387
+ break;
388
+ }
389
+ return value;
390
+ };
771
391
 
772
- class Validations {
773
- constructor(field, formFields, formData, previousFormData, allFormsData, takeAction) {
392
+ class Defaults {
393
+ constructor(field, formFields, allFormsData, formData, previousFormData, takeAction) {
774
394
  this._field = field;
775
395
  this._formFields = formFields;
396
+ this._allFormsData = allFormsData;
776
397
  this._formData = formData;
777
398
  this._previousFormData = previousFormData;
778
- this._allFormsData = allFormsData;
779
399
  this._takeAction = takeAction;
780
400
  }
781
- get formData() {
782
- return this._formData;
783
- }
784
- set formData(value) {
785
- this._formData = value;
786
- }
787
- get previousFormData() {
788
- return this._previousFormData;
789
- }
790
- set previousFormData(value) {
791
- this._previousFormData = value;
792
- }
793
- get allFormsData() {
794
- return this._allFormsData;
795
- }
796
- set allFormsData(value) {
797
- this._allFormsData = value;
798
- }
799
- get field() {
800
- return this._field;
801
- }
802
- set field(value) {
803
- this._field = value;
804
- }
805
- get formFields() {
806
- return this._formFields;
401
+ getFormFieldValue() {
402
+ return __awaiter(this, void 0, void 0, function* () {
403
+ let defaultValue;
404
+ const sources = this._field.default.value.sources;
405
+ let sourceIndex = 0;
406
+ for (let source of sources) {
407
+ const sources = new Source({
408
+ FIELD_CONFIG: this._field,
409
+ FORM_FIELDS: this._formFields,
410
+ FORM_DATA: this._formData,
411
+ PREVIOUS_FORM_DATA: this._previousFormData,
412
+ ALL_FORMS_DATA: this._allFormsData
413
+ });
414
+ const value = sources.getValueFromSource(source);
415
+ // Set the Value of current source.
416
+ this._field = setValueToObjectPath(this._field, `default.value.sources.[${sourceIndex}].value`, value);
417
+ const validation = source.validation;
418
+ const triggers = validation.triggers;
419
+ const rules = validation.rules;
420
+ const actions = validation.actions;
421
+ const rulesMapping = new Rule(rules, {
422
+ FIELD_CONFIG: this._field,
423
+ FORM_FIELDS: this._formFields,
424
+ FORM_DATA: this._formData,
425
+ PREVIOUS_FORM_DATA: this._previousFormData,
426
+ ALL_FORMS_DATA: this._allFormsData
427
+ }).mapping();
428
+ for (let action of actions) {
429
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
430
+ if (conditionEvaluation) {
431
+ const actions = new Action(action, rulesMapping, {
432
+ FIELD_CONFIG: this._field,
433
+ FORM_FIELDS: this._formFields,
434
+ FORM_DATA: this._formData,
435
+ PREVIOUS_FORM_DATA: this._previousFormData,
436
+ ALL_FORMS_DATA: this._allFormsData
437
+ }, this._takeAction);
438
+ yield actions.execute();
439
+ }
440
+ }
441
+ sourceIndex++;
442
+ }
443
+ defaultValue = this._field.default.value.value;
444
+ if (isEmptyValue(defaultValue)) {
445
+ defaultValue = convertFormFieldEmptyValueToKwikUIFormat(this._field);
446
+ }
447
+ return defaultValue;
448
+ });
807
449
  }
808
- set formFields(value) {
809
- this._formFields = value;
450
+ getFormFieldOptions() {
451
+ return __awaiter(this, void 0, void 0, function* () {
452
+ const optionsConfig = this._field.default.options;
453
+ const rules = optionsConfig.rules;
454
+ const actions = optionsConfig.actions;
455
+ const rulesMapping = new Rule(rules, {
456
+ FIELD_CONFIG: this._field,
457
+ FORM_FIELDS: this._formFields,
458
+ FORM_DATA: this._formData,
459
+ PREVIOUS_FORM_DATA: this._previousFormData,
460
+ ALL_FORMS_DATA: this._allFormsData
461
+ }).mapping();
462
+ for (let action of actions) {
463
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
464
+ if (conditionEvaluation) {
465
+ const actions = new Action(action, rulesMapping, {
466
+ FIELD_CONFIG: this._field,
467
+ FORM_FIELDS: this._formFields,
468
+ FORM_DATA: this._formData,
469
+ PREVIOUS_FORM_DATA: this._previousFormData,
470
+ ALL_FORMS_DATA: this._allFormsData
471
+ }, this._takeAction);
472
+ yield actions.execute();
473
+ }
474
+ }
475
+ });
810
476
  }
811
- getFieldValidators(field) {
477
+ }
478
+ __decorate([
479
+ logMethod
480
+ ], Defaults.prototype, "getFormFieldValue", null);
481
+ __decorate([
482
+ logMethod
483
+ ], Defaults.prototype, "getFormFieldOptions", null);
484
+
485
+ class FormValidation {
486
+ constructor() { }
487
+ getFormFieldValidators(field) {
812
488
  let validators = [];
813
489
  if (checkObjectKeyExists(field, "validators") &&
814
490
  checkObjectKeyExists(field.validators, "min") &&
@@ -840,20 +516,20 @@ class Validations {
840
516
  checkObjectKeyExists(field.validators, "pattern") &&
841
517
  isNotEmptyValue(field.validators.pattern)) {
842
518
  if (checkObjectKeyExists(field.validators.pattern, "key")) {
843
- if (field.validators.pattern.key === EPatternKey.CUSTOM) {
519
+ if (field.validators.pattern.key === "CUSTOM") {
844
520
  validators.push(Validators.pattern(field.validators.pattern.pattern));
845
521
  }
846
522
  else {
847
- validators.push(Validators.pattern(EPattern[field.validators.pattern.key]));
523
+ validators.push(Validators.pattern(PATTERNS[field.validators.pattern.key]));
848
524
  }
849
525
  }
850
526
  }
851
527
  return validators;
852
528
  }
853
- getFormValidationErrors(control) {
529
+ getFormFieldsValidationErrors(formGroup) {
854
530
  let errors = [];
855
- for (const key in control.controls) {
856
- const controlErrors = control.controls[key].errors;
531
+ for (const key in formGroup.controls) {
532
+ const controlErrors = formGroup.controls[key].errors;
857
533
  if (controlErrors !== null && controlErrors !== undefined) {
858
534
  Object.keys(controlErrors).forEach((keyError) => {
859
535
  errors.push({
@@ -865,7 +541,7 @@ class Validations {
865
541
  }
866
542
  return errors;
867
543
  }
868
- findInvalidControlsRecursive(formToInvestigate) {
544
+ getFormFieldsInvalidControls(formToInvestigate) {
869
545
  var controls = [];
870
546
  let recursiveFunc = (form) => {
871
547
  Object.keys(form.controls).forEach((field) => {
@@ -893,47 +569,16 @@ class Validations {
893
569
  recursiveFunc(formToInvestigate);
894
570
  return controls;
895
571
  }
896
- validateField() {
897
- return __awaiter(this, void 0, void 0, function* () {
898
- const validations = this._field.validation;
899
- const triggers = validations.triggers;
900
- const rules = validations.rules;
901
- const actions = validations.actions;
902
- const rulesMapping = new Rules(rules, {
903
- FIELD_CONFIG: this._field,
904
- FORM_FIELDS: this._formFields,
905
- FORM_DATA: this._formData,
906
- PREVIOUS_FORM_DATA: this._previousFormData,
907
- ALL_FORMS_DATA: this._allFormsData
908
- }).mapping();
909
- for (let action of actions) {
910
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
911
- if (conditionEvaluation) {
912
- const actions = new Actions(action, rulesMapping, {
913
- FIELD_CONFIG: this._field,
914
- FORM_FIELDS: this._formFields,
915
- FORM_DATA: this._formData,
916
- PREVIOUS_FORM_DATA: this._previousFormData,
917
- ALL_FORMS_DATA: this._allFormsData
918
- }, this._takeAction);
919
- yield actions.execute();
920
- }
921
- }
922
- });
923
- }
924
572
  }
925
573
  __decorate([
926
574
  logMethod
927
- ], Validations.prototype, "getFieldValidators", null);
575
+ ], FormValidation.prototype, "getFormFieldValidators", null);
928
576
  __decorate([
929
577
  logMethod
930
- ], Validations.prototype, "getFormValidationErrors", null);
578
+ ], FormValidation.prototype, "getFormFieldsValidationErrors", null);
931
579
  __decorate([
932
580
  logMethod
933
- ], Validations.prototype, "findInvalidControlsRecursive", null);
934
- __decorate([
935
- logMethod
936
- ], Validations.prototype, "validateField", null);
581
+ ], FormValidation.prototype, "getFormFieldsInvalidControls", null);
937
582
 
938
583
  class KwikIDFormViewService {
939
584
  constructor() { }
@@ -944,9 +589,16 @@ class KwikIDFormViewService {
944
589
  for (let field of fields) {
945
590
  if (field.isFormElement) {
946
591
  const defaults = new Defaults(field, fields, allFormsData, formData, previousFormData, takeAction);
947
- let value = yield defaults.getDefaultValue();
948
- value = convertValueFromBasicFormatToKwikUIFormat(field, value);
949
- const validators = new Validations(field, fields, formData, previousFormData, allFormsData, takeAction).getFieldValidators(field);
592
+ let value = yield defaults.getFormFieldValue();
593
+ if (checkObjectKeyExists(field, "default")) {
594
+ if (checkObjectKeyExists(field.default, "options")) {
595
+ if (field.default.options.triggers.includes("ON_INIT")) {
596
+ yield defaults.getFormFieldOptions();
597
+ }
598
+ }
599
+ }
600
+ value = convertFormFieldValueToKwikUIFormat(field, value);
601
+ const validators = new FormValidation().getFormFieldValidators(field);
950
602
  formGroup.addControl(field.key, new FormControl({ value: value, disabled: field.disabled }, { validators: validators }));
951
603
  }
952
604
  }
@@ -959,19 +611,21 @@ __decorate([
959
611
  ], KwikIDFormViewService.prototype, "createFormGroup", null);
960
612
 
961
613
  class Apis {
962
- constructor(field, formFields, formData, previousFormData, allFormsData, takeAction) {
963
- this._field = field;
964
- this._formFields = formFields;
965
- this._formData = formData;
966
- this._previousFormData = previousFormData;
967
- this._allFormsData = allFormsData;
614
+ constructor(object, takeAction) {
615
+ this._object = object;
968
616
  this._takeAction = takeAction;
969
- this._api = field.api;
970
- this._request = field.api.request;
971
- this._response = field.api.response;
972
- this._status = field.api.status;
617
+ this._api = this._object.FIELD_CONFIG.api;
618
+ this._request = this._object.FIELD_CONFIG.api.request;
619
+ this._response = this._object.FIELD_CONFIG.api.response;
620
+ this._status = this._object.FIELD_CONFIG.api.status;
621
+ }
622
+ get object() {
623
+ return this._object;
624
+ }
625
+ set object(value) {
626
+ this._object = value;
973
627
  }
974
- setRequestBodyParams() {
628
+ setRequestBody() {
975
629
  var _a, _b, _c, _d;
976
630
  return __awaiter(this, void 0, void 0, function* () {
977
631
  let params = this._request.body.params;
@@ -980,37 +634,19 @@ class Apis {
980
634
  let sources = param.sources;
981
635
  let sourceIndex = 0;
982
636
  for (let source of sources) {
983
- const sources = new Sources({
984
- FIELD_CONFIG: this._field,
985
- FORM_FIELDS: this._formFields,
986
- FORM_DATA: this._formData,
987
- PREVIOUS_FORM_DATA: this._previousFormData,
988
- ALL_FORMS_DATA: this._allFormsData
989
- });
637
+ const sources = new Source(this._object);
990
638
  const value = sources.getValueFromSource(source);
991
639
  // Set the Value of current source.
992
- this._field = setValueToObject(this._field, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
640
+ this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
993
641
  const validation = source.validation;
994
642
  const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
995
643
  const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
996
644
  const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
997
- const rulesMapping = new Rules(rules, {
998
- FIELD_CONFIG: this._field,
999
- FORM_FIELDS: this._formFields,
1000
- FORM_DATA: this._formData,
1001
- PREVIOUS_FORM_DATA: this._previousFormData,
1002
- ALL_FORMS_DATA: this._allFormsData
1003
- }).mapping();
645
+ const rulesMapping = new Rule(rules, this._object).mapping();
1004
646
  for (let action of actions) {
1005
647
  const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
1006
648
  if (conditionEvaluation) {
1007
- const actions = new Actions(action, rulesMapping, {
1008
- FIELD_CONFIG: this._field,
1009
- FORM_FIELDS: this._formFields,
1010
- FORM_DATA: this._formData,
1011
- PREVIOUS_FORM_DATA: this._previousFormData,
1012
- ALL_FORMS_DATA: this._allFormsData
1013
- }, this._takeAction);
649
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1014
650
  yield actions.execute();
1015
651
  }
1016
652
  }
@@ -1018,7 +654,7 @@ class Apis {
1018
654
  }
1019
655
  paramIndex++;
1020
656
  }
1021
- return this._field;
657
+ return this._object.FIELD_CONFIG;
1022
658
  });
1023
659
  }
1024
660
  validateRequestBody() {
@@ -1029,77 +665,44 @@ class Apis {
1029
665
  const triggers = validation.triggers;
1030
666
  const rules = validation.rules;
1031
667
  const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
1032
- const rulesMapping = new Rules(rules, {
1033
- FIELD_CONFIG: this._field,
1034
- FORM_FIELDS: this._formFields,
1035
- FORM_DATA: this._formData,
1036
- PREVIOUS_FORM_DATA: this._previousFormData,
1037
- ALL_FORMS_DATA: this._allFormsData
1038
- }).mapping();
668
+ const rulesMapping = new Rule(rules, this._object).mapping();
1039
669
  for (let action of actions) {
1040
670
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1041
671
  if (conditionSuccess) {
1042
- const actions = new Actions(action, rulesMapping, {
1043
- FIELD_CONFIG: this._field,
1044
- FORM_FIELDS: this._formFields,
1045
- FORM_DATA: this._formData,
1046
- PREVIOUS_FORM_DATA: this._previousFormData,
1047
- ALL_FORMS_DATA: this._allFormsData
1048
- }, this._takeAction);
672
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1049
673
  yield actions.execute();
1050
674
  }
1051
675
  }
1052
- return this._field;
676
+ return this._object.FIELD_CONFIG;
1053
677
  });
1054
678
  }
1055
- validateApiCallResponse() {
679
+ validateResponse() {
1056
680
  return __awaiter(this, void 0, void 0, function* () {
1057
681
  const validation = this._response.validation;
1058
682
  const triggers = validation.triggers;
1059
683
  const rules = validation.rules;
1060
684
  const actions = validation.actions;
1061
- const rulesMapping = new Rules(rules, {
1062
- FIELD_CONFIG: this._field,
1063
- FORM_FIELDS: this._formFields,
1064
- FORM_DATA: this._formData,
1065
- PREVIOUS_FORM_DATA: this._previousFormData,
1066
- ALL_FORMS_DATA: this._allFormsData
1067
- }).mapping();
685
+ const rulesMapping = new Rule(rules, this._object).mapping();
1068
686
  for (let action of actions) {
1069
687
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1070
688
  if (conditionSuccess) {
1071
- const actions = new Actions(action, rulesMapping, {
1072
- FIELD_CONFIG: this._field,
1073
- FORM_FIELDS: this._formFields,
1074
- FORM_DATA: this._formData,
1075
- PREVIOUS_FORM_DATA: this._previousFormData,
1076
- ALL_FORMS_DATA: this._allFormsData
1077
- }, this._takeAction);
689
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1078
690
  yield actions.execute();
1079
691
  }
1080
692
  }
1081
- return this._field;
693
+ return this._object.FIELD_CONFIG;
1082
694
  });
1083
695
  }
1084
- getPropsValues() {
1085
- return {
1086
- field: this._field,
1087
- formFields: this._formFields,
1088
- formData: this._formData,
1089
- previousFormData: this._previousFormData,
1090
- allFormsData: this._allFormsData
1091
- };
1092
- }
1093
696
  }
1094
697
  __decorate([
1095
698
  logMethod
1096
- ], Apis.prototype, "setRequestBodyParams", null);
699
+ ], Apis.prototype, "setRequestBody", null);
1097
700
  __decorate([
1098
701
  logMethod
1099
702
  ], Apis.prototype, "validateRequestBody", null);
1100
703
  __decorate([
1101
704
  logMethod
1102
- ], Apis.prototype, "validateApiCallResponse", null);
705
+ ], Apis.prototype, "validateResponse", null);
1103
706
 
1104
707
  /**
1105
708
  * Generated class for the SafeHtmlPipe pipe.
@@ -1169,10 +772,16 @@ class KwikIDFormViewComponent {
1169
772
  this.formGroup.patchValue({
1170
773
  [this.apiCallResponse.key]: this.apiCallResponse.response
1171
774
  }, { emitEvent: false });
1172
- let field = findFieldFromKey(this.formFields, this.apiCallResponse.key);
1173
- const apis = new Apis(field, this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
775
+ let field = getFormFieldByKey(this.formFields, this.apiCallResponse.key);
776
+ const apis = new Apis({
777
+ FIELD_CONFIG: field,
778
+ FORM_FIELDS: this.formFields,
779
+ FORM_DATA: this.formData,
780
+ PREVIOUS_FORM_DATA: this.previousFormData,
781
+ ALL_FORMS_DATA: this.allFormsData
782
+ }, this.takeAction.bind(this));
1174
783
  (() => __awaiter(this, void 0, void 0, function* () {
1175
- field = yield apis.validateApiCallResponse();
784
+ field = yield apis.validateResponse();
1176
785
  }))();
1177
786
  }
1178
787
  if (verifyChange("isMobileView")) {
@@ -1203,34 +812,30 @@ class KwikIDFormViewComponent {
1203
812
  this.formGroup.controls[field.key].valueChanges
1204
813
  .pipe(pairwise())
1205
814
  .subscribe(([previousValue, currentValue]) => {
1206
- this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: previousValue });
1207
- this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: currentValue });
815
+ this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, previousValue) });
816
+ this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: convertFormFieldValueToStandardFormat(field, currentValue) });
1208
817
  });
1209
818
  }
1210
819
  }
1211
820
  for (let field of this.formFields) {
1212
821
  if (field.isFormElement) {
1213
822
  if (field.validation.triggers.includes("ON_INIT")) {
1214
- const validations = new Validations(field, this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
823
+ const validations = new Validation({
824
+ FIELD_CONFIG: field,
825
+ FORM_FIELDS: this.formFields,
826
+ FORM_DATA: this.formData,
827
+ PREVIOUS_FORM_DATA: this.previousFormData,
828
+ ALL_FORMS_DATA: this.allFormsData
829
+ }, this.takeAction.bind(this));
1215
830
  (() => __awaiter(this, void 0, void 0, function* () {
1216
- yield validations.validateField();
831
+ yield validations.validate(field.validation);
1217
832
  }))();
1218
833
  }
1219
834
  if (checkObjectKeyExists(field, "connectedElements")) {
1220
- if (checkObjectKeyExists(field.connectedElements, "connectedFields")) {
1221
- this.handleConnectedElements({
1222
- key: field.key,
1223
- value: this.formGroup.controls[field.key].value
1224
- }, "ON_INIT");
1225
- }
1226
- }
1227
- if (checkObjectKeyExists(field, "default")) {
1228
- if (checkObjectKeyExists(field.default, "options")) {
1229
- if (field.default.options.triggers.includes("ON_INIT")) {
1230
- const defaults = new Defaults(field, this.formFields, this.allFormsData, this.formData, this.previousFormData, this.takeAction);
1231
- yield defaults.getDefaultDropdownOptions();
1232
- }
1233
- }
835
+ this.handleConnectedElements({
836
+ key: field.key,
837
+ value: this.formGroup.controls[field.key].value
838
+ }, "ON_INIT");
1234
839
  }
1235
840
  }
1236
841
  }
@@ -1259,7 +864,7 @@ class KwikIDFormViewComponent {
1259
864
  handleConnectedElementFieldGroupActions(childFieldGroupConfig, parentField) {
1260
865
  return __awaiter(this, void 0, void 0, function* () {
1261
866
  if (checkObjectKeyExists(childFieldGroupConfig, "rules")) {
1262
- const rulesMapping = new Rules(childFieldGroupConfig.rules, {
867
+ const rulesMapping = new Rule(childFieldGroupConfig.rules, {
1263
868
  FIELD_CONFIG: parentField,
1264
869
  FORM_DATA: this.formData,
1265
870
  PREVIOUS_FORM_DATA: this.previousFormData,
@@ -1268,7 +873,7 @@ class KwikIDFormViewComponent {
1268
873
  for (let action of childFieldGroupConfig.actions) {
1269
874
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1270
875
  if (conditionSuccess) {
1271
- const actions = new Actions(action, rulesMapping, {
876
+ const actions = new Action(action, rulesMapping, {
1272
877
  FIELD_CONFIG: parentField,
1273
878
  FORM_FIELDS: this.formFields,
1274
879
  FORM_DATA: this.formData,
@@ -1293,7 +898,7 @@ class KwikIDFormViewComponent {
1293
898
  handleConnectedElementFieldActions(connectedFieldConfig, connectedField) {
1294
899
  return __awaiter(this, void 0, void 0, function* () {
1295
900
  if (checkObjectKeyExists(connectedFieldConfig, "rules")) {
1296
- const rulesMapping = new Rules(connectedFieldConfig.rules, {
901
+ const rulesMapping = new Rule(connectedFieldConfig.rules, {
1297
902
  FIELD_CONFIG: connectedField,
1298
903
  FORM_DATA: this.formData,
1299
904
  PREVIOUS_FORM_DATA: this.previousFormData,
@@ -1302,7 +907,7 @@ class KwikIDFormViewComponent {
1302
907
  for (let action of connectedFieldConfig.actions) {
1303
908
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1304
909
  if (conditionSuccess) {
1305
- const actions = new Actions(action, rulesMapping, {
910
+ const actions = new Action(action, rulesMapping, {
1306
911
  FORM_FIELDS: this.formFields,
1307
912
  FIELD_CONFIG: connectedField,
1308
913
  FORM_DATA: this.formData,
@@ -1318,7 +923,7 @@ class KwikIDFormViewComponent {
1318
923
  }
1319
924
  handleConnectedElementFields(currentField, connectedFieldConfig, eventType, nested) {
1320
925
  return __awaiter(this, void 0, void 0, function* () {
1321
- let connectedField = findFieldFromKey(this.formFields, connectedFieldConfig["key"]);
926
+ let connectedField = getFormFieldByKey(this.formFields, connectedFieldConfig["key"]);
1322
927
  if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
1323
928
  if (connectedFieldConfig.triggers.includes(eventType)) {
1324
929
  connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
@@ -1326,14 +931,7 @@ class KwikIDFormViewComponent {
1326
931
  }
1327
932
  if (checkObjectKeyExists(connectedFieldConfig, "handleNestedFields")) {
1328
933
  if (connectedFieldConfig.handleNestedFields) {
1329
- if (checkObjectKeyExists(connectedField, "connectedElements")) {
1330
- if (checkObjectKeyExists(connectedField.connectedElements, "connectedFields")) {
1331
- for (const connectedFieldConfig of connectedField.connectedElements
1332
- .connectedFields) {
1333
- connectedField = this.handleConnectedElementFields(connectedField, connectedFieldConfig, eventType, "NESTED");
1334
- }
1335
- }
1336
- }
934
+ this.handleConnectedElements({ key: connectedFieldConfig.key }, eventType);
1337
935
  }
1338
936
  }
1339
937
  return currentField;
@@ -1341,7 +939,7 @@ class KwikIDFormViewComponent {
1341
939
  }
1342
940
  handleConnectedElements(e, eventType) {
1343
941
  return __awaiter(this, void 0, void 0, function* () {
1344
- let currentField = findFieldFromKey(this.formFields, e.key);
942
+ let currentField = getFormFieldByKey(this.formFields, e.key);
1345
943
  if (currentField !== undefined) {
1346
944
  if (checkObjectKeyExists(currentField, "connectedElements")) {
1347
945
  if (checkObjectKeyExists(currentField.connectedElements, "connectedFieldGroups")) {
@@ -1368,31 +966,35 @@ class KwikIDFormViewComponent {
1368
966
  this.formGroup.patchValue({
1369
967
  [e.key]: e.value
1370
968
  }, { emitEvent: false });
1371
- // Currently set only for dropdown-with-search connected fields
1372
- let field = findFieldFromKey(this.formFields, e.key);
969
+ const field = getFormFieldByKey(this.formFields, e.key);
970
+ this.formData[e.key] = convertFormFieldValueToStandardFormat(field, e.value);
1373
971
  if (field.isFormElement &&
1374
972
  field.validation.triggers.includes("ON_CHANGE")) {
1375
- const validations = new Validations(field, this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
973
+ const validations = new Validation({
974
+ FIELD_CONFIG: field,
975
+ FORM_FIELDS: this.formFields,
976
+ FORM_DATA: this.formData,
977
+ PREVIOUS_FORM_DATA: this.previousFormData,
978
+ ALL_FORMS_DATA: this.allFormsData
979
+ }, this.takeAction.bind(this));
1376
980
  (() => __awaiter(this, void 0, void 0, function* () {
1377
- yield validations.validateField();
981
+ yield validations.validate(field.validation);
1378
982
  }))();
1379
983
  }
1380
984
  if (field.isFormElement &&
1381
985
  checkObjectKeyExists(field, "connectedElements")) {
1382
- if (checkObjectKeyExists(field.connectedElements, "connectedFields")) {
1383
- this.handleConnectedElements({
1384
- key: field.key,
1385
- value: this.formGroup.controls[field.key].value
1386
- }, "ON_CHANGE");
1387
- }
986
+ this.handleConnectedElements({
987
+ key: field.key,
988
+ value: this.formGroup.controls[field.key].value
989
+ }, "ON_CHANGE");
1388
990
  }
1389
991
  }
1390
992
  handleOnClickResetFormFields(e, field) {
1391
993
  return __awaiter(this, void 0, void 0, function* () {
1392
994
  for (let f of field.reset.fields) {
1393
995
  for (let action of f.actions) {
1394
- const resetField = findFieldFromKey(this.formFields, action.props.fieldKey);
1395
- const actions = new Actions(action, {}, {
996
+ const resetField = getFormFieldByKey(this.formFields, action.props.fieldKey);
997
+ const actions = new Action(action, {}, {
1396
998
  FIELD_CONFIG: resetField,
1397
999
  FORM_FIELDS: this.formFields,
1398
1000
  FORM_DATA: this.formData,
@@ -1406,7 +1008,7 @@ class KwikIDFormViewComponent {
1406
1008
  }
1407
1009
  handleOnClickApiCall(e) {
1408
1010
  return __awaiter(this, void 0, void 0, function* () {
1409
- let field = findFieldFromKey(this.formFields, e.key);
1011
+ let field = getFormFieldByKey(this.formFields, e.key);
1410
1012
  if (field.type === "api-call") {
1411
1013
  // set button status to loading
1412
1014
  field["api"]["status"]["value"] = EApiStatusType.LOADING;
@@ -1415,8 +1017,14 @@ class KwikIDFormViewComponent {
1415
1017
  this.viewFormsButton["showLoader"] = true;
1416
1018
  this.saveFormButton["disabled"] = true;
1417
1019
  this.saveFormButton["showLoader"] = true;
1418
- const apis = new Apis(field, this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
1419
- field = yield apis.setRequestBodyParams();
1020
+ const apis = new Apis({
1021
+ FIELD_CONFIG: field,
1022
+ FORM_FIELDS: this.formFields,
1023
+ FORM_DATA: this.formData,
1024
+ PREVIOUS_FORM_DATA: this.previousFormData,
1025
+ ALL_FORMS_DATA: this.allFormsData
1026
+ }, this.takeAction.bind(this));
1027
+ field = yield apis.setRequestBody();
1420
1028
  field = yield apis.validateRequestBody();
1421
1029
  if (field.api.request.body.validation.is_valid) {
1422
1030
  // Call API Here
@@ -1433,7 +1041,7 @@ class KwikIDFormViewComponent {
1433
1041
  else {
1434
1042
  // Request Body Validation Failed
1435
1043
  // Highlight Error in UI to User to Retry After Sometime.
1436
- // Take Actions based on Validation
1044
+ // Take Action based on Validation
1437
1045
  setTimeout(() => {
1438
1046
  field["api"]["status"]["value"] = EApiStatusType.FAILED;
1439
1047
  field["showLoader"] = false;
@@ -1454,32 +1062,38 @@ class KwikIDFormViewComponent {
1454
1062
  handleOnClickSaveForm(e) {
1455
1063
  let formData = this.formGroup.getRawValue();
1456
1064
  for (let field of this.formFields) {
1457
- if (field.type !== EFieldType.TITLE) {
1065
+ if (field.isFormElement) {
1458
1066
  if (field.hidden) {
1459
1067
  delete formData[field.key];
1460
1068
  }
1461
1069
  else {
1462
- formData[field.key] = convertValueFromKwikUIFormatToBasicFormat(field, formData[field.key]);
1070
+ formData[field.key] = convertFormFieldValueToStandardFormat(field, formData[field.key]);
1463
1071
  }
1464
1072
  }
1465
1073
  }
1466
1074
  for (let field of this.formFields) {
1467
- if (field.type !== EFieldType.TITLE &&
1075
+ if (field.isFormElement &&
1468
1076
  field.validation.triggers.includes("ON_SAVE")) {
1469
- const validations = new Validations(field, this.formFields, formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
1077
+ const validations = new Validation({
1078
+ FIELD_CONFIG: field,
1079
+ FORM_FIELDS: this.formFields,
1080
+ FORM_DATA: this.formData,
1081
+ PREVIOUS_FORM_DATA: this.previousFormData,
1082
+ ALL_FORMS_DATA: this.allFormsData
1083
+ }, this.takeAction.bind(this));
1470
1084
  (() => __awaiter(this, void 0, void 0, function* () {
1471
- yield validations.validateField();
1085
+ yield validations.validate(field.validation);
1472
1086
  }))();
1473
1087
  }
1474
1088
  }
1475
1089
  if (this.formGroup.invalid) {
1476
- const controls = new Validations(undefined, this.formFields, formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this)).findInvalidControlsRecursive(this.formGroup);
1090
+ const controls = new FormValidation().getFormFieldsInvalidControls(this.formGroup);
1477
1091
  let firstFieldWithError = "";
1478
1092
  for (let control of controls) {
1479
1093
  if (control.invalid && isEmptyValue(firstFieldWithError)) {
1480
1094
  firstFieldWithError = control.key;
1481
1095
  }
1482
- this.formFields = setFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
1096
+ this.formFields = showFormFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
1483
1097
  }
1484
1098
  this.toggleErrorNotification(true);
1485
1099
  setTimeout(() => {
@@ -1499,7 +1113,7 @@ class KwikIDFormViewComponent {
1499
1113
  }
1500
1114
  // Component Helpers
1501
1115
  fieldHide(fieldKey) {
1502
- let field = findFieldFromKey(this.formFields, fieldKey);
1116
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1503
1117
  let fieldIndex = this.formFields.findIndex((_) => {
1504
1118
  return field.key === _.key;
1505
1119
  });
@@ -1512,7 +1126,7 @@ class KwikIDFormViewComponent {
1512
1126
  }
1513
1127
  }
1514
1128
  fieldShow(fieldKey) {
1515
- let field = findFieldFromKey(this.formFields, fieldKey);
1129
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1516
1130
  let fieldIndex = this.formFields.findIndex((_) => {
1517
1131
  return field.key === _.key;
1518
1132
  });
@@ -1525,11 +1139,11 @@ class KwikIDFormViewComponent {
1525
1139
  }
1526
1140
  }
1527
1141
  fieldDisable(fieldKey) {
1528
- let field = findFieldFromKey(this.formFields, fieldKey);
1142
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1529
1143
  let fieldIndex = this.formFields.findIndex((_) => {
1530
1144
  return field.key === _.key;
1531
1145
  });
1532
- if (field.type !== EFieldType.TITLE) {
1146
+ if (field.isFormElement) {
1533
1147
  this.formFields[fieldIndex]["disabled"] = true;
1534
1148
  if (isNotEmptyValue(this.formGroup.controls)) {
1535
1149
  this.formGroup.controls[field.key].disable({
@@ -1545,11 +1159,11 @@ class KwikIDFormViewComponent {
1545
1159
  }
1546
1160
  }
1547
1161
  fieldEnable(fieldKey) {
1548
- let field = findFieldFromKey(this.formFields, fieldKey);
1162
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1549
1163
  let fieldIndex = this.formFields.findIndex((_) => {
1550
1164
  return field.key === _.key;
1551
1165
  });
1552
- if (field.type !== EFieldType.TITLE) {
1166
+ if (field.isFormElement) {
1553
1167
  this.formFields[fieldIndex]["disabled"] = false;
1554
1168
  if (isNotEmptyValue(this.formGroup.controls)) {
1555
1169
  this.formGroup.controls[field.key].enable({
@@ -1566,20 +1180,20 @@ class KwikIDFormViewComponent {
1566
1180
  }
1567
1181
  fieldReset(fieldKey) {
1568
1182
  // Find the field and its index in the formFields array
1569
- let field = findFieldFromKey(this.formFields, fieldKey);
1570
- let fieldIndex = findFieldIndexFromKey(this.formFields, fieldKey);
1183
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1184
+ let fieldIndex = getFormFieldIndexByKey(this.formFields, fieldKey);
1571
1185
  // Delete the field from the formData object
1572
1186
  delete this.formData[fieldKey];
1573
1187
  // Reset the value of the field in the formGroup
1574
- this.formGroup.controls[field.key].reset(setEmptyValue(field), {
1188
+ this.formGroup.controls[field.key].reset(convertFormFieldEmptyValueToKwikUIFormat(field), {
1575
1189
  emitEvent: false
1576
1190
  });
1577
1191
  // Reset the messages and errors for the field
1578
- field = removeMessage(field, {
1192
+ field = removeFormFieldMessage(field, {
1579
1193
  type: EMessageType.WARNING,
1580
1194
  message: ""
1581
1195
  });
1582
- field = removeMessage(field, {
1196
+ field = removeFormFieldMessage(field, {
1583
1197
  type: EMessageType.SUCCESS,
1584
1198
  message: ""
1585
1199
  });
@@ -1602,37 +1216,37 @@ class KwikIDFormViewComponent {
1602
1216
  }
1603
1217
  }
1604
1218
  fieldErrorShow(fieldKey, message) {
1605
- let field = findFieldFromKey(this.formFields, fieldKey);
1219
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1606
1220
  let fieldIndex = this.formFields.findIndex((_) => {
1607
1221
  return field.key === _.key;
1608
1222
  });
1609
- field = highlightFieldError(field, true);
1610
- field = addMessage(field, message);
1223
+ field = highlightFormFieldError(field, true);
1224
+ field = appendFormFieldMessage(field, message);
1611
1225
  this.formFields[fieldIndex] = field;
1612
1226
  }
1613
1227
  fieldErrorHide(fieldKey, message) {
1614
- let field = findFieldFromKey(this.formFields, fieldKey);
1228
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1615
1229
  let fieldIndex = this.formFields.findIndex((_) => {
1616
1230
  return field.key === _.key;
1617
1231
  });
1618
- field = highlightFieldError(field, false);
1619
- field = removeMessage(field, message);
1232
+ field = highlightFormFieldError(field, false);
1233
+ field = removeFormFieldMessage(field, message);
1620
1234
  this.formFields[fieldIndex] = field;
1621
1235
  }
1622
1236
  fieldMessageShow(fieldKey, message) {
1623
- let field = findFieldFromKey(this.formFields, fieldKey);
1237
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1624
1238
  let fieldIndex = this.formFields.findIndex((_) => {
1625
1239
  return field.key === _.key;
1626
1240
  });
1627
- field = addMessage(field, message);
1241
+ field = appendFormFieldMessage(field, message);
1628
1242
  this.formFields[fieldIndex] = field;
1629
1243
  }
1630
1244
  fieldMessageHide(fieldKey, message) {
1631
- let field = findFieldFromKey(this.formFields, fieldKey);
1245
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1632
1246
  let fieldIndex = this.formFields.findIndex((_) => {
1633
1247
  return field.key === _.key;
1634
1248
  });
1635
- field = removeMessage(field, message);
1249
+ field = removeFormFieldMessage(field, message);
1636
1250
  this.formFields[fieldIndex] = field;
1637
1251
  }
1638
1252
  setObjectValue(field, path, value) { }
@@ -1642,7 +1256,7 @@ class KwikIDFormViewComponent {
1642
1256
  }, { emitEvent: false });
1643
1257
  }
1644
1258
  patchFormGroup(formData) {
1645
- if (isUndefined$1(this.formGroup) || isUndefined$1(formData)) {
1259
+ if (isUndefined(this.formGroup) || isUndefined(formData)) {
1646
1260
  throw new Error(`formGroup or formData is 'undefined'.`);
1647
1261
  }
1648
1262
  else {
@@ -1658,7 +1272,7 @@ class KwikIDFormViewComponent {
1658
1272
  getFormGroupRawValues() {
1659
1273
  return this.formGroup.getRawValue();
1660
1274
  }
1661
- takeActionOnFieldGroup(action, field, allFormsData, formData, previousFormData) {
1275
+ takeActionOnFieldGroup(action, object) {
1662
1276
  return __awaiter(this, void 0, void 0, function* () {
1663
1277
  switch (action.key) {
1664
1278
  case EActionKey.FIELD_GROUP_HIDE:
@@ -1709,7 +1323,7 @@ class KwikIDFormViewComponent {
1709
1323
  this.fieldMessageHide(action.props.fieldKey, action.props.message);
1710
1324
  break;
1711
1325
  case EActionKey.SET_VALUE:
1712
- const setValue_Sources = new Sources(object);
1326
+ const setValue_Sources = new Source(object);
1713
1327
  const sourceValue = yield setValue_Sources.getValueFromSource(action.props.value.source);
1714
1328
  setValue_Sources.setValueToSource(action.props.value.destination, sourceValue);
1715
1329
  object.FIELD_CONFIG = setValue_Sources.object.FIELD_CONFIG;
@@ -1719,13 +1333,13 @@ class KwikIDFormViewComponent {
1719
1333
  this.previousFormData = setValue_Sources.object.PREVIOUS_FORM_DATA;
1720
1334
  break;
1721
1335
  case EActionKey.SET_DROPDOWN_OPTIONS:
1722
- const setDropdownValue_Sources = new Sources(object);
1336
+ const setDropdownValue_Sources = new Source(object);
1723
1337
  let dropdownValue = yield setDropdownValue_Sources.getValueFromSource(action.props.value.source);
1724
1338
  if (checkObjectKeyExists(action.props, "options")) {
1725
1339
  if (checkObjectKeyExists(action.props.options, "appendToPath")) {
1726
1340
  let appendToPath = yield setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source);
1727
1341
  if (isNotEmptyValue(appendToPath)) {
1728
- const appendToPathStr = replaceString$1(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
1342
+ const appendToPathStr = replaceString(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
1729
1343
  const optionsPath = `${action.props.options.path}${appendToPathStr}`;
1730
1344
  dropdownValue = getObjectValueFromPath(dropdownValue, optionsPath);
1731
1345
  }
@@ -1742,7 +1356,7 @@ class KwikIDFormViewComponent {
1742
1356
  setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
1743
1357
  break;
1744
1358
  case EActionKey.HANDLE_CONNECTED_ELEMENTS:
1745
- this.handleConnectedElements({ key: action.props.fieldKey }, "ACTION");
1359
+ this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
1746
1360
  break;
1747
1361
  case EActionKey.CUSTOM:
1748
1362
  break;
@@ -2065,14 +1679,14 @@ class Converter {
2065
1679
  const formatFieldTypeDate = (field) => {
2066
1680
  field = this.setFieldKeyValue(field, "isFormElement", true);
2067
1681
  if (checkObjectKeyExists(field, "min")) {
2068
- const tuiDay = convertDateStringToTuiDayFormat(field["min"]);
1682
+ const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["min"]);
2069
1683
  field.properties = this.setFieldKeyValue(field.properties, "min", tuiDay);
2070
1684
  }
2071
1685
  else {
2072
1686
  field.properties = this.setMissingFieldKeyValue(field.properties, "min", new TuiDay(0, 0, 1)); // Year - 0000, Month - 0 (0 Indexing), Day - 1
2073
1687
  }
2074
1688
  if (checkObjectKeyExists(field, "max")) {
2075
- const tuiDay = convertDateStringToTuiDayFormat(field["max"]);
1689
+ const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["max"]);
2076
1690
  field.properties = this.setFieldKeyValue(field.properties, "max", tuiDay);
2077
1691
  }
2078
1692
  else {
@@ -2675,9 +2289,8 @@ class KwikIDRendererService {
2675
2289
  markFormInFormsListAsCompleted(formsList, formsListCompleted) {
2676
2290
  for (let form of formsList) {
2677
2291
  if (formsListCompleted.includes(form.key)) {
2678
- console.log(formsListCompleted.includes(form.key));
2679
- form = setValueToObject(form, "status", "completed");
2680
- form = setValueToObject(form, "disabled", false);
2292
+ form = setValueToObjectPath(form, "status", "completed");
2293
+ form = setValueToObjectPath(form, "disabled", false);
2681
2294
  }
2682
2295
  }
2683
2296
  return formsList;
@@ -2688,18 +2301,18 @@ class KwikIDRendererService {
2688
2301
  if (checkObjectKeyExists(form, "dependentOn")) {
2689
2302
  const isDependent = form.dependentOn.every((r) => formsListCompleted.includes(r));
2690
2303
  if (isDependent) {
2691
- form = setValueToObject(form, "status", "editable");
2692
- form = setValueToObject(form, "disabled", false);
2304
+ form = setValueToObjectPath(form, "status", "editable");
2305
+ form = setValueToObjectPath(form, "disabled", false);
2693
2306
  }
2694
2307
  else {
2695
- form = setValueToObject(form, "status", "locked");
2696
- form = setValueToObject(form, "disabled", true);
2308
+ form = setValueToObjectPath(form, "status", "locked");
2309
+ form = setValueToObjectPath(form, "disabled", true);
2697
2310
  }
2698
2311
  }
2699
2312
  else {
2700
- form = setValueToObject(form, "dependentOn", []);
2701
- form = setValueToObject(form, "status", "editable");
2702
- form = setValueToObject(form, "disabled", false);
2313
+ form = setValueToObjectPath(form, "dependentOn", []);
2314
+ form = setValueToObjectPath(form, "status", "editable");
2315
+ form = setValueToObjectPath(form, "disabled", false);
2703
2316
  }
2704
2317
  }
2705
2318
  }
@@ -2733,7 +2346,6 @@ class KwikIDRendererService {
2733
2346
  * this particular User Form only has to LOCAL METHOD Variable.
2734
2347
  */
2735
2348
  const currentUserFormAllFormsData = this.filterAllFormsData(this.allFormsData, formsList);
2736
- console.log(JSON.parse(JSON.stringify(formsList)));
2737
2349
  formsListCompleted = this.findCompletedFormsList(currentUserFormAllFormsData);
2738
2350
  formsList = this.markFormInFormsListAsCompleted(formsList, formsListCompleted);
2739
2351
  formsList = this.markFormInFormsListAsDisabled(formsList, formsListCompleted);
@@ -2890,6 +2502,9 @@ class KwikIDFormsRendererComponent {
2890
2502
  }
2891
2503
  handleResize(formsList) {
2892
2504
  if (this.hostElement.nativeElement.offsetWidth < 600) {
2505
+ const isSingleForm = (formsList) => {
2506
+ return formsList.length === 1;
2507
+ };
2893
2508
  if (!isSingleForm(formsList)) {
2894
2509
  this.showFormSections = true;
2895
2510
  this.showFormFields = false;
@@ -2936,9 +2551,8 @@ class KwikIDFormsRendererComponent {
2936
2551
  }
2937
2552
  // forms-list listener
2938
2553
  handleOnClickSubmitForms(e) {
2939
- console.log(e);
2940
2554
  if (this.userConfig.userFormFieldsConfig.validation) {
2941
- const validations = new Validations$1({
2555
+ const validations = new Validation({
2942
2556
  USER_CONFIG: this.userConfig,
2943
2557
  ALL_FORMS_DATA: this.formsData
2944
2558
  }, this.takeAction.bind(this));
@@ -2989,7 +2603,7 @@ class KwikIDFormsRendererComponent {
2989
2603
  return __awaiter(this, void 0, void 0, function* () {
2990
2604
  switch (action.key) {
2991
2605
  case EActionKey.SET_VALUE:
2992
- const sources = new Sources({
2606
+ const sources = new Source({
2993
2607
  USER_CONFIG: this.userConfig,
2994
2608
  ALL_FORMS_DATA: this.formsData
2995
2609
  });