kwikid-forms 0.1.8 → 0.1.9

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 +387 -848
  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 +103 -88
  10. package/esm2015/lib/renderer/form-view/form-view.service.js +6 -6
  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 +14 -15
  13. package/esm2015/lib/renderer/form-view/helpers/form-view.fields.helper.js +41 -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 +279 -671
  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,12 @@ 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
+ convertedValue = convertFormFieldTypeDateToStandardFormat(value);
738
334
  break;
739
335
  case EFieldType.RADIO:
740
336
  convertedValue = value.label;
@@ -744,7 +340,7 @@ const convertValueFromKwikUIFormatToBasicFormat = (field, value) => {
744
340
  }
745
341
  return convertedValue;
746
342
  };
747
- const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
343
+ const convertFormFieldValueToKwikUIFormat = (field, value) => {
748
344
  let convertedValue = value;
749
345
  if (isNotEmptyValue(value)) {
750
346
  switch (field.type) {
@@ -758,7 +354,7 @@ const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
758
354
  }
759
355
  break;
760
356
  case EFieldType.DATE:
761
- convertedValue = convertDateStringToTuiDayFormat(value);
357
+ convertedValue = convertFormFieldTypeDateToKwikUIFormat(value);
762
358
  break;
763
359
  case EFieldType.TITLE:
764
360
  break;
@@ -766,49 +362,124 @@ const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
766
362
  break;
767
363
  }
768
364
  }
365
+ else {
366
+ convertedValue = convertFormFieldEmptyValueToKwikUIFormat(field);
367
+ }
769
368
  return convertedValue;
770
369
  };
370
+ const convertFormFieldEmptyValueToKwikUIFormat = (field) => {
371
+ const fieldType = field.type;
372
+ let value;
373
+ switch (fieldType) {
374
+ case EFieldType.CHECKBOX:
375
+ value = false;
376
+ break;
377
+ case EFieldType.NUMBER:
378
+ value = null;
379
+ break;
380
+ case EFieldType.DATE:
381
+ value = null;
382
+ break;
383
+ default:
384
+ value = "";
385
+ break;
386
+ }
387
+ return value;
388
+ };
771
389
 
772
- class Validations {
773
- constructor(field, formFields, formData, previousFormData, allFormsData, takeAction) {
390
+ class Defaults {
391
+ constructor(field, formFields, allFormsData, formData, previousFormData, takeAction) {
774
392
  this._field = field;
775
393
  this._formFields = formFields;
394
+ this._allFormsData = allFormsData;
776
395
  this._formData = formData;
777
396
  this._previousFormData = previousFormData;
778
- this._allFormsData = allFormsData;
779
397
  this._takeAction = takeAction;
780
398
  }
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;
399
+ getFormFieldValue() {
400
+ return __awaiter(this, void 0, void 0, function* () {
401
+ let defaultValue;
402
+ const sources = this._field.default.value.sources;
403
+ let sourceIndex = 0;
404
+ for (let source of sources) {
405
+ const sources = new Source({
406
+ FIELD_CONFIG: this._field,
407
+ FORM_FIELDS: this._formFields,
408
+ FORM_DATA: this._formData,
409
+ PREVIOUS_FORM_DATA: this._previousFormData,
410
+ ALL_FORMS_DATA: this._allFormsData
411
+ });
412
+ const value = sources.getValueFromSource(source);
413
+ // Set the Value of current source.
414
+ this._field = setValueToObjectPath(this._field, `default.value.sources.[${sourceIndex}].value`, value);
415
+ const validation = source.validation;
416
+ const triggers = validation.triggers;
417
+ const rules = validation.rules;
418
+ const actions = validation.actions;
419
+ const rulesMapping = new Rule(rules, {
420
+ FIELD_CONFIG: this._field,
421
+ FORM_FIELDS: this._formFields,
422
+ FORM_DATA: this._formData,
423
+ PREVIOUS_FORM_DATA: this._previousFormData,
424
+ ALL_FORMS_DATA: this._allFormsData
425
+ }).mapping();
426
+ for (let action of actions) {
427
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
428
+ if (conditionEvaluation) {
429
+ const actions = new Action(action, rulesMapping, {
430
+ FIELD_CONFIG: this._field,
431
+ FORM_FIELDS: this._formFields,
432
+ FORM_DATA: this._formData,
433
+ PREVIOUS_FORM_DATA: this._previousFormData,
434
+ ALL_FORMS_DATA: this._allFormsData
435
+ }, this._takeAction);
436
+ yield actions.execute();
437
+ }
438
+ }
439
+ sourceIndex++;
440
+ }
441
+ defaultValue = this._field.default.value.value;
442
+ if (isEmptyValue(defaultValue)) {
443
+ defaultValue = convertFormFieldEmptyValueToKwikUIFormat(this._field);
444
+ }
445
+ return defaultValue;
446
+ });
807
447
  }
808
- set formFields(value) {
809
- this._formFields = value;
448
+ getFormFieldOptions() {
449
+ return __awaiter(this, void 0, void 0, function* () {
450
+ const optionsConfig = this._field.default.options;
451
+ const rules = optionsConfig.rules;
452
+ const actions = optionsConfig.actions;
453
+ const rulesMapping = new Rule(rules, {
454
+ FIELD_CONFIG: this._field,
455
+ FORM_FIELDS: this._formFields,
456
+ FORM_DATA: this._formData,
457
+ PREVIOUS_FORM_DATA: this._previousFormData,
458
+ ALL_FORMS_DATA: this._allFormsData
459
+ }).mapping();
460
+ for (let action of actions) {
461
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
462
+ if (conditionEvaluation) {
463
+ const actions = new Action(action, rulesMapping, {
464
+ FIELD_CONFIG: this._field,
465
+ FORM_FIELDS: this._formFields,
466
+ FORM_DATA: this._formData,
467
+ PREVIOUS_FORM_DATA: this._previousFormData,
468
+ ALL_FORMS_DATA: this._allFormsData
469
+ }, this._takeAction);
470
+ yield actions.execute();
471
+ }
472
+ }
473
+ });
810
474
  }
811
- getFieldValidators(field) {
475
+ }
476
+ __decorate([
477
+ logMethod
478
+ ], Defaults.prototype, "getFormFieldValue", null);
479
+
480
+ class FormValidation {
481
+ constructor() { }
482
+ getFormFieldValidators(field) {
812
483
  let validators = [];
813
484
  if (checkObjectKeyExists(field, "validators") &&
814
485
  checkObjectKeyExists(field.validators, "min") &&
@@ -840,20 +511,20 @@ class Validations {
840
511
  checkObjectKeyExists(field.validators, "pattern") &&
841
512
  isNotEmptyValue(field.validators.pattern)) {
842
513
  if (checkObjectKeyExists(field.validators.pattern, "key")) {
843
- if (field.validators.pattern.key === EPatternKey.CUSTOM) {
514
+ if (field.validators.pattern.key === "CUSTOM") {
844
515
  validators.push(Validators.pattern(field.validators.pattern.pattern));
845
516
  }
846
517
  else {
847
- validators.push(Validators.pattern(EPattern[field.validators.pattern.key]));
518
+ validators.push(Validators.pattern(PATTERNS[field.validators.pattern.key]));
848
519
  }
849
520
  }
850
521
  }
851
522
  return validators;
852
523
  }
853
- getFormValidationErrors(control) {
524
+ getFormFieldsValidationErrors(formGroup) {
854
525
  let errors = [];
855
- for (const key in control.controls) {
856
- const controlErrors = control.controls[key].errors;
526
+ for (const key in formGroup.controls) {
527
+ const controlErrors = formGroup.controls[key].errors;
857
528
  if (controlErrors !== null && controlErrors !== undefined) {
858
529
  Object.keys(controlErrors).forEach((keyError) => {
859
530
  errors.push({
@@ -865,7 +536,7 @@ class Validations {
865
536
  }
866
537
  return errors;
867
538
  }
868
- findInvalidControlsRecursive(formToInvestigate) {
539
+ getFormFieldsInvalidControls(formToInvestigate) {
869
540
  var controls = [];
870
541
  let recursiveFunc = (form) => {
871
542
  Object.keys(form.controls).forEach((field) => {
@@ -893,47 +564,16 @@ class Validations {
893
564
  recursiveFunc(formToInvestigate);
894
565
  return controls;
895
566
  }
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
567
  }
925
568
  __decorate([
926
569
  logMethod
927
- ], Validations.prototype, "getFieldValidators", null);
570
+ ], FormValidation.prototype, "getFormFieldValidators", null);
928
571
  __decorate([
929
572
  logMethod
930
- ], Validations.prototype, "getFormValidationErrors", null);
573
+ ], FormValidation.prototype, "getFormFieldsValidationErrors", null);
931
574
  __decorate([
932
575
  logMethod
933
- ], Validations.prototype, "findInvalidControlsRecursive", null);
934
- __decorate([
935
- logMethod
936
- ], Validations.prototype, "validateField", null);
576
+ ], FormValidation.prototype, "getFormFieldsInvalidControls", null);
937
577
 
938
578
  class KwikIDFormViewService {
939
579
  constructor() { }
@@ -944,9 +584,9 @@ class KwikIDFormViewService {
944
584
  for (let field of fields) {
945
585
  if (field.isFormElement) {
946
586
  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);
587
+ let value = yield defaults.getFormFieldValue();
588
+ value = convertFormFieldValueToKwikUIFormat(field, value);
589
+ const validators = new FormValidation().getFormFieldValidators(field);
950
590
  formGroup.addControl(field.key, new FormControl({ value: value, disabled: field.disabled }, { validators: validators }));
951
591
  }
952
592
  }
@@ -959,19 +599,21 @@ __decorate([
959
599
  ], KwikIDFormViewService.prototype, "createFormGroup", null);
960
600
 
961
601
  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;
602
+ constructor(object, takeAction) {
603
+ this._object = object;
968
604
  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;
605
+ this._api = this._object.FIELD_CONFIG.api;
606
+ this._request = this._object.FIELD_CONFIG.api.request;
607
+ this._response = this._object.FIELD_CONFIG.api.response;
608
+ this._status = this._object.FIELD_CONFIG.api.status;
973
609
  }
974
- setRequestBodyParams() {
610
+ get object() {
611
+ return this._object;
612
+ }
613
+ set object(value) {
614
+ this._object = value;
615
+ }
616
+ setRequestBody() {
975
617
  var _a, _b, _c, _d;
976
618
  return __awaiter(this, void 0, void 0, function* () {
977
619
  let params = this._request.body.params;
@@ -980,37 +622,19 @@ class Apis {
980
622
  let sources = param.sources;
981
623
  let sourceIndex = 0;
982
624
  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
- });
625
+ const sources = new Source(this._object);
990
626
  const value = sources.getValueFromSource(source);
991
627
  // Set the Value of current source.
992
- this._field = setValueToObject(this._field, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
628
+ this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
993
629
  const validation = source.validation;
994
630
  const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
995
631
  const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
996
632
  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();
633
+ const rulesMapping = new Rule(rules, this._object).mapping();
1004
634
  for (let action of actions) {
1005
635
  const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
1006
636
  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);
637
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1014
638
  yield actions.execute();
1015
639
  }
1016
640
  }
@@ -1018,7 +642,7 @@ class Apis {
1018
642
  }
1019
643
  paramIndex++;
1020
644
  }
1021
- return this._field;
645
+ return this._object.FIELD_CONFIG;
1022
646
  });
1023
647
  }
1024
648
  validateRequestBody() {
@@ -1029,77 +653,44 @@ class Apis {
1029
653
  const triggers = validation.triggers;
1030
654
  const rules = validation.rules;
1031
655
  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();
656
+ const rulesMapping = new Rule(rules, this._object).mapping();
1039
657
  for (let action of actions) {
1040
658
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1041
659
  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);
660
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1049
661
  yield actions.execute();
1050
662
  }
1051
663
  }
1052
- return this._field;
664
+ return this._object.FIELD_CONFIG;
1053
665
  });
1054
666
  }
1055
- validateApiCallResponse() {
667
+ validateResponse() {
1056
668
  return __awaiter(this, void 0, void 0, function* () {
1057
669
  const validation = this._response.validation;
1058
670
  const triggers = validation.triggers;
1059
671
  const rules = validation.rules;
1060
672
  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();
673
+ const rulesMapping = new Rule(rules, this._object).mapping();
1068
674
  for (let action of actions) {
1069
675
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1070
676
  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);
677
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1078
678
  yield actions.execute();
1079
679
  }
1080
680
  }
1081
- return this._field;
681
+ return this._object.FIELD_CONFIG;
1082
682
  });
1083
683
  }
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
684
  }
1094
685
  __decorate([
1095
686
  logMethod
1096
- ], Apis.prototype, "setRequestBodyParams", null);
687
+ ], Apis.prototype, "setRequestBody", null);
1097
688
  __decorate([
1098
689
  logMethod
1099
690
  ], Apis.prototype, "validateRequestBody", null);
1100
691
  __decorate([
1101
692
  logMethod
1102
- ], Apis.prototype, "validateApiCallResponse", null);
693
+ ], Apis.prototype, "validateResponse", null);
1103
694
 
1104
695
  /**
1105
696
  * Generated class for the SafeHtmlPipe pipe.
@@ -1169,10 +760,16 @@ class KwikIDFormViewComponent {
1169
760
  this.formGroup.patchValue({
1170
761
  [this.apiCallResponse.key]: this.apiCallResponse.response
1171
762
  }, { 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));
763
+ let field = getFormFieldByKey(this.formFields, this.apiCallResponse.key);
764
+ const apis = new Apis({
765
+ FIELD_CONFIG: field,
766
+ FORM_FIELDS: this.formFields,
767
+ FORM_DATA: this.formData,
768
+ PREVIOUS_FORM_DATA: this.previousFormData,
769
+ ALL_FORMS_DATA: this.allFormsData
770
+ }, this.takeAction.bind(this));
1174
771
  (() => __awaiter(this, void 0, void 0, function* () {
1175
- field = yield apis.validateApiCallResponse();
772
+ field = yield apis.validateResponse();
1176
773
  }))();
1177
774
  }
1178
775
  if (verifyChange("isMobileView")) {
@@ -1199,36 +796,40 @@ class KwikIDFormViewComponent {
1199
796
  this.formGroup = yield this.formViewService.createFormGroup(this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
1200
797
  for (let field of this.formFields) {
1201
798
  if (field.isFormElement) {
1202
- this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: this.formGroup.controls[field.key].value });
799
+ this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, this.formGroup.controls[field.key].value) });
1203
800
  this.formGroup.controls[field.key].valueChanges
1204
801
  .pipe(pairwise())
1205
802
  .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 });
803
+ this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, previousValue) });
804
+ this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: convertFormFieldValueToStandardFormat(field, currentValue) });
1208
805
  });
1209
806
  }
1210
807
  }
1211
808
  for (let field of this.formFields) {
1212
809
  if (field.isFormElement) {
1213
810
  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));
811
+ const validations = new Validation({
812
+ FIELD_CONFIG: field,
813
+ FORM_FIELDS: this.formFields,
814
+ FORM_DATA: this.formData,
815
+ PREVIOUS_FORM_DATA: this.previousFormData,
816
+ ALL_FORMS_DATA: this.allFormsData
817
+ }, this.takeAction.bind(this));
1215
818
  (() => __awaiter(this, void 0, void 0, function* () {
1216
- yield validations.validateField();
819
+ yield validations.validate(field.validation);
1217
820
  }))();
1218
821
  }
1219
822
  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
- }
823
+ this.handleConnectedElements({
824
+ key: field.key,
825
+ value: this.formGroup.controls[field.key].value
826
+ }, "ON_INIT");
1226
827
  }
1227
828
  if (checkObjectKeyExists(field, "default")) {
1228
829
  if (checkObjectKeyExists(field.default, "options")) {
1229
830
  if (field.default.options.triggers.includes("ON_INIT")) {
1230
831
  const defaults = new Defaults(field, this.formFields, this.allFormsData, this.formData, this.previousFormData, this.takeAction);
1231
- yield defaults.getDefaultDropdownOptions();
832
+ yield defaults.getFormFieldOptions();
1232
833
  }
1233
834
  }
1234
835
  }
@@ -1259,7 +860,7 @@ class KwikIDFormViewComponent {
1259
860
  handleConnectedElementFieldGroupActions(childFieldGroupConfig, parentField) {
1260
861
  return __awaiter(this, void 0, void 0, function* () {
1261
862
  if (checkObjectKeyExists(childFieldGroupConfig, "rules")) {
1262
- const rulesMapping = new Rules(childFieldGroupConfig.rules, {
863
+ const rulesMapping = new Rule(childFieldGroupConfig.rules, {
1263
864
  FIELD_CONFIG: parentField,
1264
865
  FORM_DATA: this.formData,
1265
866
  PREVIOUS_FORM_DATA: this.previousFormData,
@@ -1268,7 +869,7 @@ class KwikIDFormViewComponent {
1268
869
  for (let action of childFieldGroupConfig.actions) {
1269
870
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1270
871
  if (conditionSuccess) {
1271
- const actions = new Actions(action, rulesMapping, {
872
+ const actions = new Action(action, rulesMapping, {
1272
873
  FIELD_CONFIG: parentField,
1273
874
  FORM_FIELDS: this.formFields,
1274
875
  FORM_DATA: this.formData,
@@ -1293,7 +894,7 @@ class KwikIDFormViewComponent {
1293
894
  handleConnectedElementFieldActions(connectedFieldConfig, connectedField) {
1294
895
  return __awaiter(this, void 0, void 0, function* () {
1295
896
  if (checkObjectKeyExists(connectedFieldConfig, "rules")) {
1296
- const rulesMapping = new Rules(connectedFieldConfig.rules, {
897
+ const rulesMapping = new Rule(connectedFieldConfig.rules, {
1297
898
  FIELD_CONFIG: connectedField,
1298
899
  FORM_DATA: this.formData,
1299
900
  PREVIOUS_FORM_DATA: this.previousFormData,
@@ -1302,7 +903,7 @@ class KwikIDFormViewComponent {
1302
903
  for (let action of connectedFieldConfig.actions) {
1303
904
  const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1304
905
  if (conditionSuccess) {
1305
- const actions = new Actions(action, rulesMapping, {
906
+ const actions = new Action(action, rulesMapping, {
1306
907
  FORM_FIELDS: this.formFields,
1307
908
  FIELD_CONFIG: connectedField,
1308
909
  FORM_DATA: this.formData,
@@ -1318,30 +919,21 @@ class KwikIDFormViewComponent {
1318
919
  }
1319
920
  handleConnectedElementFields(currentField, connectedFieldConfig, eventType, nested) {
1320
921
  return __awaiter(this, void 0, void 0, function* () {
1321
- let connectedField = findFieldFromKey(this.formFields, connectedFieldConfig["key"]);
922
+ let connectedField = getFormFieldByKey(this.formFields, connectedFieldConfig["key"]);
1322
923
  if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
1323
924
  if (connectedFieldConfig.triggers.includes(eventType)) {
1324
925
  connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
1325
926
  }
1326
927
  }
1327
928
  if (checkObjectKeyExists(connectedFieldConfig, "handleNestedFields")) {
1328
- 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
- }
1337
- }
929
+ this.handleConnectedElements({ key: connectedFieldConfig.key }, eventType);
1338
930
  }
1339
931
  return currentField;
1340
932
  });
1341
933
  }
1342
934
  handleConnectedElements(e, eventType) {
1343
935
  return __awaiter(this, void 0, void 0, function* () {
1344
- let currentField = findFieldFromKey(this.formFields, e.key);
936
+ let currentField = getFormFieldByKey(this.formFields, e.key);
1345
937
  if (currentField !== undefined) {
1346
938
  if (checkObjectKeyExists(currentField, "connectedElements")) {
1347
939
  if (checkObjectKeyExists(currentField.connectedElements, "connectedFieldGroups")) {
@@ -1368,31 +960,35 @@ class KwikIDFormViewComponent {
1368
960
  this.formGroup.patchValue({
1369
961
  [e.key]: e.value
1370
962
  }, { emitEvent: false });
1371
- // Currently set only for dropdown-with-search connected fields
1372
- let field = findFieldFromKey(this.formFields, e.key);
963
+ const field = getFormFieldByKey(this.formFields, e.key);
964
+ this.formData[e.key] = convertFormFieldValueToStandardFormat(field, e.value);
1373
965
  if (field.isFormElement &&
1374
966
  field.validation.triggers.includes("ON_CHANGE")) {
1375
- const validations = new Validations(field, this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
967
+ const validations = new Validation({
968
+ FIELD_CONFIG: field,
969
+ FORM_FIELDS: this.formFields,
970
+ FORM_DATA: this.formData,
971
+ PREVIOUS_FORM_DATA: this.previousFormData,
972
+ ALL_FORMS_DATA: this.allFormsData
973
+ }, this.takeAction.bind(this));
1376
974
  (() => __awaiter(this, void 0, void 0, function* () {
1377
- yield validations.validateField();
975
+ yield validations.validate(field.validation);
1378
976
  }))();
1379
977
  }
1380
978
  if (field.isFormElement &&
1381
979
  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
- }
980
+ this.handleConnectedElements({
981
+ key: field.key,
982
+ value: this.formGroup.controls[field.key].value
983
+ }, "ON_CHANGE");
1388
984
  }
1389
985
  }
1390
986
  handleOnClickResetFormFields(e, field) {
1391
987
  return __awaiter(this, void 0, void 0, function* () {
1392
988
  for (let f of field.reset.fields) {
1393
989
  for (let action of f.actions) {
1394
- const resetField = findFieldFromKey(this.formFields, action.props.fieldKey);
1395
- const actions = new Actions(action, {}, {
990
+ const resetField = getFormFieldByKey(this.formFields, action.props.fieldKey);
991
+ const actions = new Action(action, {}, {
1396
992
  FIELD_CONFIG: resetField,
1397
993
  FORM_FIELDS: this.formFields,
1398
994
  FORM_DATA: this.formData,
@@ -1406,7 +1002,7 @@ class KwikIDFormViewComponent {
1406
1002
  }
1407
1003
  handleOnClickApiCall(e) {
1408
1004
  return __awaiter(this, void 0, void 0, function* () {
1409
- let field = findFieldFromKey(this.formFields, e.key);
1005
+ let field = getFormFieldByKey(this.formFields, e.key);
1410
1006
  if (field.type === "api-call") {
1411
1007
  // set button status to loading
1412
1008
  field["api"]["status"]["value"] = EApiStatusType.LOADING;
@@ -1415,8 +1011,14 @@ class KwikIDFormViewComponent {
1415
1011
  this.viewFormsButton["showLoader"] = true;
1416
1012
  this.saveFormButton["disabled"] = true;
1417
1013
  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();
1014
+ const apis = new Apis({
1015
+ FIELD_CONFIG: field,
1016
+ FORM_FIELDS: this.formFields,
1017
+ FORM_DATA: this.formData,
1018
+ PREVIOUS_FORM_DATA: this.previousFormData,
1019
+ ALL_FORMS_DATA: this.allFormsData
1020
+ }, this.takeAction.bind(this));
1021
+ field = yield apis.setRequestBody();
1420
1022
  field = yield apis.validateRequestBody();
1421
1023
  if (field.api.request.body.validation.is_valid) {
1422
1024
  // Call API Here
@@ -1433,7 +1035,7 @@ class KwikIDFormViewComponent {
1433
1035
  else {
1434
1036
  // Request Body Validation Failed
1435
1037
  // Highlight Error in UI to User to Retry After Sometime.
1436
- // Take Actions based on Validation
1038
+ // Take Action based on Validation
1437
1039
  setTimeout(() => {
1438
1040
  field["api"]["status"]["value"] = EApiStatusType.FAILED;
1439
1041
  field["showLoader"] = false;
@@ -1454,32 +1056,38 @@ class KwikIDFormViewComponent {
1454
1056
  handleOnClickSaveForm(e) {
1455
1057
  let formData = this.formGroup.getRawValue();
1456
1058
  for (let field of this.formFields) {
1457
- if (field.type !== EFieldType.TITLE) {
1059
+ if (field.isFormElement) {
1458
1060
  if (field.hidden) {
1459
1061
  delete formData[field.key];
1460
1062
  }
1461
1063
  else {
1462
- formData[field.key] = convertValueFromKwikUIFormatToBasicFormat(field, formData[field.key]);
1064
+ formData[field.key] = convertFormFieldValueToStandardFormat(field, formData[field.key]);
1463
1065
  }
1464
1066
  }
1465
1067
  }
1466
1068
  for (let field of this.formFields) {
1467
- if (field.type !== EFieldType.TITLE &&
1069
+ if (field.isFormElement &&
1468
1070
  field.validation.triggers.includes("ON_SAVE")) {
1469
- const validations = new Validations(field, this.formFields, formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
1071
+ const validations = new Validation({
1072
+ FIELD_CONFIG: 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.bind(this));
1470
1078
  (() => __awaiter(this, void 0, void 0, function* () {
1471
- yield validations.validateField();
1079
+ yield validations.validate(field.validation);
1472
1080
  }))();
1473
1081
  }
1474
1082
  }
1475
1083
  if (this.formGroup.invalid) {
1476
- const controls = new Validations(undefined, this.formFields, formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this)).findInvalidControlsRecursive(this.formGroup);
1084
+ const controls = new FormValidation().getFormFieldsInvalidControls(this.formGroup);
1477
1085
  let firstFieldWithError = "";
1478
1086
  for (let control of controls) {
1479
1087
  if (control.invalid && isEmptyValue(firstFieldWithError)) {
1480
1088
  firstFieldWithError = control.key;
1481
1089
  }
1482
- this.formFields = setFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
1090
+ this.formFields = showFormFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
1483
1091
  }
1484
1092
  this.toggleErrorNotification(true);
1485
1093
  setTimeout(() => {
@@ -1499,7 +1107,7 @@ class KwikIDFormViewComponent {
1499
1107
  }
1500
1108
  // Component Helpers
1501
1109
  fieldHide(fieldKey) {
1502
- let field = findFieldFromKey(this.formFields, fieldKey);
1110
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1503
1111
  let fieldIndex = this.formFields.findIndex((_) => {
1504
1112
  return field.key === _.key;
1505
1113
  });
@@ -1512,7 +1120,7 @@ class KwikIDFormViewComponent {
1512
1120
  }
1513
1121
  }
1514
1122
  fieldShow(fieldKey) {
1515
- let field = findFieldFromKey(this.formFields, fieldKey);
1123
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1516
1124
  let fieldIndex = this.formFields.findIndex((_) => {
1517
1125
  return field.key === _.key;
1518
1126
  });
@@ -1525,11 +1133,11 @@ class KwikIDFormViewComponent {
1525
1133
  }
1526
1134
  }
1527
1135
  fieldDisable(fieldKey) {
1528
- let field = findFieldFromKey(this.formFields, fieldKey);
1136
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1529
1137
  let fieldIndex = this.formFields.findIndex((_) => {
1530
1138
  return field.key === _.key;
1531
1139
  });
1532
- if (field.type !== EFieldType.TITLE) {
1140
+ if (field.isFormElement) {
1533
1141
  this.formFields[fieldIndex]["disabled"] = true;
1534
1142
  if (isNotEmptyValue(this.formGroup.controls)) {
1535
1143
  this.formGroup.controls[field.key].disable({
@@ -1545,11 +1153,11 @@ class KwikIDFormViewComponent {
1545
1153
  }
1546
1154
  }
1547
1155
  fieldEnable(fieldKey) {
1548
- let field = findFieldFromKey(this.formFields, fieldKey);
1156
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1549
1157
  let fieldIndex = this.formFields.findIndex((_) => {
1550
1158
  return field.key === _.key;
1551
1159
  });
1552
- if (field.type !== EFieldType.TITLE) {
1160
+ if (field.isFormElement) {
1553
1161
  this.formFields[fieldIndex]["disabled"] = false;
1554
1162
  if (isNotEmptyValue(this.formGroup.controls)) {
1555
1163
  this.formGroup.controls[field.key].enable({
@@ -1566,20 +1174,20 @@ class KwikIDFormViewComponent {
1566
1174
  }
1567
1175
  fieldReset(fieldKey) {
1568
1176
  // Find the field and its index in the formFields array
1569
- let field = findFieldFromKey(this.formFields, fieldKey);
1570
- let fieldIndex = findFieldIndexFromKey(this.formFields, fieldKey);
1177
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1178
+ let fieldIndex = getFormFieldIndexByKey(this.formFields, fieldKey);
1571
1179
  // Delete the field from the formData object
1572
1180
  delete this.formData[fieldKey];
1573
1181
  // Reset the value of the field in the formGroup
1574
- this.formGroup.controls[field.key].reset(setEmptyValue(field), {
1182
+ this.formGroup.controls[field.key].reset(convertFormFieldEmptyValueToKwikUIFormat(field), {
1575
1183
  emitEvent: false
1576
1184
  });
1577
1185
  // Reset the messages and errors for the field
1578
- field = removeMessage(field, {
1186
+ field = removeFormFieldMessage(field, {
1579
1187
  type: EMessageType.WARNING,
1580
1188
  message: ""
1581
1189
  });
1582
- field = removeMessage(field, {
1190
+ field = removeFormFieldMessage(field, {
1583
1191
  type: EMessageType.SUCCESS,
1584
1192
  message: ""
1585
1193
  });
@@ -1602,37 +1210,37 @@ class KwikIDFormViewComponent {
1602
1210
  }
1603
1211
  }
1604
1212
  fieldErrorShow(fieldKey, message) {
1605
- let field = findFieldFromKey(this.formFields, fieldKey);
1213
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1606
1214
  let fieldIndex = this.formFields.findIndex((_) => {
1607
1215
  return field.key === _.key;
1608
1216
  });
1609
- field = highlightFieldError(field, true);
1610
- field = addMessage(field, message);
1217
+ field = highlightFormFieldError(field, true);
1218
+ field = appendFormFieldMessage(field, message);
1611
1219
  this.formFields[fieldIndex] = field;
1612
1220
  }
1613
1221
  fieldErrorHide(fieldKey, message) {
1614
- let field = findFieldFromKey(this.formFields, fieldKey);
1222
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1615
1223
  let fieldIndex = this.formFields.findIndex((_) => {
1616
1224
  return field.key === _.key;
1617
1225
  });
1618
- field = highlightFieldError(field, false);
1619
- field = removeMessage(field, message);
1226
+ field = highlightFormFieldError(field, false);
1227
+ field = removeFormFieldMessage(field, message);
1620
1228
  this.formFields[fieldIndex] = field;
1621
1229
  }
1622
1230
  fieldMessageShow(fieldKey, message) {
1623
- let field = findFieldFromKey(this.formFields, fieldKey);
1231
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1624
1232
  let fieldIndex = this.formFields.findIndex((_) => {
1625
1233
  return field.key === _.key;
1626
1234
  });
1627
- field = addMessage(field, message);
1235
+ field = appendFormFieldMessage(field, message);
1628
1236
  this.formFields[fieldIndex] = field;
1629
1237
  }
1630
1238
  fieldMessageHide(fieldKey, message) {
1631
- let field = findFieldFromKey(this.formFields, fieldKey);
1239
+ let field = getFormFieldByKey(this.formFields, fieldKey);
1632
1240
  let fieldIndex = this.formFields.findIndex((_) => {
1633
1241
  return field.key === _.key;
1634
1242
  });
1635
- field = removeMessage(field, message);
1243
+ field = removeFormFieldMessage(field, message);
1636
1244
  this.formFields[fieldIndex] = field;
1637
1245
  }
1638
1246
  setObjectValue(field, path, value) { }
@@ -1642,7 +1250,7 @@ class KwikIDFormViewComponent {
1642
1250
  }, { emitEvent: false });
1643
1251
  }
1644
1252
  patchFormGroup(formData) {
1645
- if (isUndefined$1(this.formGroup) || isUndefined$1(formData)) {
1253
+ if (isUndefined(this.formGroup) || isUndefined(formData)) {
1646
1254
  throw new Error(`formGroup or formData is 'undefined'.`);
1647
1255
  }
1648
1256
  else {
@@ -1658,7 +1266,7 @@ class KwikIDFormViewComponent {
1658
1266
  getFormGroupRawValues() {
1659
1267
  return this.formGroup.getRawValue();
1660
1268
  }
1661
- takeActionOnFieldGroup(action, field, allFormsData, formData, previousFormData) {
1269
+ takeActionOnFieldGroup(action, object) {
1662
1270
  return __awaiter(this, void 0, void 0, function* () {
1663
1271
  switch (action.key) {
1664
1272
  case EActionKey.FIELD_GROUP_HIDE:
@@ -1709,7 +1317,7 @@ class KwikIDFormViewComponent {
1709
1317
  this.fieldMessageHide(action.props.fieldKey, action.props.message);
1710
1318
  break;
1711
1319
  case EActionKey.SET_VALUE:
1712
- const setValue_Sources = new Sources(object);
1320
+ const setValue_Sources = new Source(object);
1713
1321
  const sourceValue = yield setValue_Sources.getValueFromSource(action.props.value.source);
1714
1322
  setValue_Sources.setValueToSource(action.props.value.destination, sourceValue);
1715
1323
  object.FIELD_CONFIG = setValue_Sources.object.FIELD_CONFIG;
@@ -1719,13 +1327,13 @@ class KwikIDFormViewComponent {
1719
1327
  this.previousFormData = setValue_Sources.object.PREVIOUS_FORM_DATA;
1720
1328
  break;
1721
1329
  case EActionKey.SET_DROPDOWN_OPTIONS:
1722
- const setDropdownValue_Sources = new Sources(object);
1330
+ const setDropdownValue_Sources = new Source(object);
1723
1331
  let dropdownValue = yield setDropdownValue_Sources.getValueFromSource(action.props.value.source);
1724
1332
  if (checkObjectKeyExists(action.props, "options")) {
1725
1333
  if (checkObjectKeyExists(action.props.options, "appendToPath")) {
1726
1334
  let appendToPath = yield setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source);
1727
1335
  if (isNotEmptyValue(appendToPath)) {
1728
- const appendToPathStr = replaceString$1(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
1336
+ const appendToPathStr = replaceString(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
1729
1337
  const optionsPath = `${action.props.options.path}${appendToPathStr}`;
1730
1338
  dropdownValue = getObjectValueFromPath(dropdownValue, optionsPath);
1731
1339
  }
@@ -1742,7 +1350,7 @@ class KwikIDFormViewComponent {
1742
1350
  setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
1743
1351
  break;
1744
1352
  case EActionKey.HANDLE_CONNECTED_ELEMENTS:
1745
- this.handleConnectedElements({ key: action.props.fieldKey }, "ACTION");
1353
+ this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
1746
1354
  break;
1747
1355
  case EActionKey.CUSTOM:
1748
1356
  break;
@@ -2065,14 +1673,14 @@ class Converter {
2065
1673
  const formatFieldTypeDate = (field) => {
2066
1674
  field = this.setFieldKeyValue(field, "isFormElement", true);
2067
1675
  if (checkObjectKeyExists(field, "min")) {
2068
- const tuiDay = convertDateStringToTuiDayFormat(field["min"]);
1676
+ const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["min"]);
2069
1677
  field.properties = this.setFieldKeyValue(field.properties, "min", tuiDay);
2070
1678
  }
2071
1679
  else {
2072
1680
  field.properties = this.setMissingFieldKeyValue(field.properties, "min", new TuiDay(0, 0, 1)); // Year - 0000, Month - 0 (0 Indexing), Day - 1
2073
1681
  }
2074
1682
  if (checkObjectKeyExists(field, "max")) {
2075
- const tuiDay = convertDateStringToTuiDayFormat(field["max"]);
1683
+ const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["max"]);
2076
1684
  field.properties = this.setFieldKeyValue(field.properties, "max", tuiDay);
2077
1685
  }
2078
1686
  else {
@@ -2675,9 +2283,8 @@ class KwikIDRendererService {
2675
2283
  markFormInFormsListAsCompleted(formsList, formsListCompleted) {
2676
2284
  for (let form of formsList) {
2677
2285
  if (formsListCompleted.includes(form.key)) {
2678
- console.log(formsListCompleted.includes(form.key));
2679
- form = setValueToObject(form, "status", "completed");
2680
- form = setValueToObject(form, "disabled", false);
2286
+ form = setValueToObjectPath(form, "status", "completed");
2287
+ form = setValueToObjectPath(form, "disabled", false);
2681
2288
  }
2682
2289
  }
2683
2290
  return formsList;
@@ -2688,18 +2295,18 @@ class KwikIDRendererService {
2688
2295
  if (checkObjectKeyExists(form, "dependentOn")) {
2689
2296
  const isDependent = form.dependentOn.every((r) => formsListCompleted.includes(r));
2690
2297
  if (isDependent) {
2691
- form = setValueToObject(form, "status", "editable");
2692
- form = setValueToObject(form, "disabled", false);
2298
+ form = setValueToObjectPath(form, "status", "editable");
2299
+ form = setValueToObjectPath(form, "disabled", false);
2693
2300
  }
2694
2301
  else {
2695
- form = setValueToObject(form, "status", "locked");
2696
- form = setValueToObject(form, "disabled", true);
2302
+ form = setValueToObjectPath(form, "status", "locked");
2303
+ form = setValueToObjectPath(form, "disabled", true);
2697
2304
  }
2698
2305
  }
2699
2306
  else {
2700
- form = setValueToObject(form, "dependentOn", []);
2701
- form = setValueToObject(form, "status", "editable");
2702
- form = setValueToObject(form, "disabled", false);
2307
+ form = setValueToObjectPath(form, "dependentOn", []);
2308
+ form = setValueToObjectPath(form, "status", "editable");
2309
+ form = setValueToObjectPath(form, "disabled", false);
2703
2310
  }
2704
2311
  }
2705
2312
  }
@@ -2733,7 +2340,6 @@ class KwikIDRendererService {
2733
2340
  * this particular User Form only has to LOCAL METHOD Variable.
2734
2341
  */
2735
2342
  const currentUserFormAllFormsData = this.filterAllFormsData(this.allFormsData, formsList);
2736
- console.log(JSON.parse(JSON.stringify(formsList)));
2737
2343
  formsListCompleted = this.findCompletedFormsList(currentUserFormAllFormsData);
2738
2344
  formsList = this.markFormInFormsListAsCompleted(formsList, formsListCompleted);
2739
2345
  formsList = this.markFormInFormsListAsDisabled(formsList, formsListCompleted);
@@ -2890,6 +2496,9 @@ class KwikIDFormsRendererComponent {
2890
2496
  }
2891
2497
  handleResize(formsList) {
2892
2498
  if (this.hostElement.nativeElement.offsetWidth < 600) {
2499
+ const isSingleForm = (formsList) => {
2500
+ return formsList.length === 1;
2501
+ };
2893
2502
  if (!isSingleForm(formsList)) {
2894
2503
  this.showFormSections = true;
2895
2504
  this.showFormFields = false;
@@ -2936,9 +2545,8 @@ class KwikIDFormsRendererComponent {
2936
2545
  }
2937
2546
  // forms-list listener
2938
2547
  handleOnClickSubmitForms(e) {
2939
- console.log(e);
2940
2548
  if (this.userConfig.userFormFieldsConfig.validation) {
2941
- const validations = new Validations$1({
2549
+ const validations = new Validation({
2942
2550
  USER_CONFIG: this.userConfig,
2943
2551
  ALL_FORMS_DATA: this.formsData
2944
2552
  }, this.takeAction.bind(this));
@@ -2989,7 +2597,7 @@ class KwikIDFormsRendererComponent {
2989
2597
  return __awaiter(this, void 0, void 0, function* () {
2990
2598
  switch (action.key) {
2991
2599
  case EActionKey.SET_VALUE:
2992
- const sources = new Sources({
2600
+ const sources = new Source({
2993
2601
  USER_CONFIG: this.userConfig,
2994
2602
  ALL_FORMS_DATA: this.formsData
2995
2603
  });