kwikid-forms 0.1.20 → 0.1.21

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.
@@ -5,7 +5,7 @@ import * as i0 from '@angular/core';
5
5
  import { EventEmitter, Component, Input, Output, ViewEncapsulation, Pipe, Inject, HostListener, NgModule } from '@angular/core';
6
6
  import * as i1 from '@angular/forms';
7
7
  import { FormGroup, FormControl, FormArray, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
8
- import { logMethod, setMissingKeyValue, getObjectFromLocalStorage, isNotEmptyValue, isEmptyValue, checkObjectKeyExists, Source, setValueToObjectPath, Rule, Condition, Action, PATTERNS, Validation, isUndefined, replaceString, getObjectValueFromPath, ESourceKey } from 'kwikid-toolkit';
8
+ import { logMethod, setMissingKeyValue, getObjectFromLocalStorage, isNotEmptyValue, isEmptyValue, checkObjectKeyExists, setValueToObjectPath, Source, Rule, Condition, Action, PATTERNS, Validation, isUndefined, replaceString, getObjectValueFromPath, ESourceKey } from 'kwikid-toolkit';
9
9
  import * as i2 from 'kwikui';
10
10
  import { KwikUIButtonModule, KwikUIInputModule, KwikUIButtonIconModule, KwikUIModule } from 'kwikui';
11
11
  import _ from 'lodash';
@@ -1366,44 +1366,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
1366
1366
  }]
1367
1367
  }], ctorParameters: function () { return []; }, propDecorators: { handleGetKeyValue: [], drop: [], exit: [], enter: [], removeElement: [], editElement: [], handleOnSaveUpdateElement: [] } });
1368
1368
 
1369
- var EActionKey;
1370
- (function (EActionKey) {
1371
- EActionKey["SET_VALUE"] = "SET_VALUE";
1372
- EActionKey["SET_FIELD_DEFAULT_VALUE"] = "SET_FIELD_DEFAULT_VALUE";
1373
- EActionKey["FIELD_MESSAGE_SHOW"] = "FIELD_MESSAGE_SHOW";
1374
- EActionKey["FIELD_MESSAGES_HIDE"] = "FIELD_MESSAGES_HIDE";
1375
- EActionKey["FIELD_ERROR_SHOW"] = "FIELD_ERROR_SHOW";
1376
- EActionKey["FIELD_ERROR_HIDE"] = "FIELD_ERROR_HIDE";
1377
- EActionKey["FIELD_SHOW"] = "FIELD_SHOW";
1378
- EActionKey["FIELD_HIDE"] = "FIELD_HIDE";
1379
- EActionKey["FIELD_ENABLE"] = "FIELD_ENABLE";
1380
- EActionKey["FIELD_DISABLE"] = "FIELD_DISABLE";
1381
- EActionKey["FIELD_RESET"] = "FIELD_RESET";
1382
- EActionKey["HANDLE_CONNECTED_ELEMENTS"] = "HANDLE_CONNECTED_ELEMENTS";
1383
- EActionKey["CUSTOM"] = "CUSTOM";
1384
- EActionKey["FIELD_GROUP_SHOW"] = "FIELD_GROUP_SHOW";
1385
- EActionKey["FIELD_GROUP_HIDE"] = "FIELD_GROUP_HIDE";
1386
- EActionKey["FIELD_GROUP_ENABLE"] = "FIELD_GROUP_ENABLE";
1387
- EActionKey["FIELD_GROUP_DISABLE"] = "FIELD_GROUP_DISABLE";
1388
- EActionKey["SET_DROPDOWN_OPTIONS"] = "SET_DROPDOWN_OPTIONS";
1389
- })(EActionKey || (EActionKey = {}));
1390
-
1391
- var EApiStatusType;
1392
- (function (EApiStatusType) {
1393
- EApiStatusType["DEFAULT"] = "default";
1394
- EApiStatusType["LOADING"] = "loading";
1395
- EApiStatusType["SUCCESS"] = "success";
1396
- EApiStatusType["FAILED"] = "failed";
1397
- })(EApiStatusType || (EApiStatusType = {}));
1398
-
1399
- var EMessageType;
1400
- (function (EMessageType) {
1401
- EMessageType["DEFAULT"] = "default";
1402
- EMessageType["ERROR"] = "error";
1403
- EMessageType["SUCCESS"] = "success";
1404
- EMessageType["WARNING"] = "warning";
1405
- })(EMessageType || (EMessageType = {}));
1406
-
1407
1369
  var EFieldType;
1408
1370
  (function (EFieldType) {
1409
1371
  EFieldType["HTML"] = "html";
@@ -1560,6 +1522,9 @@ const convertFormFieldValueToStandardFormat = (field, value) => {
1560
1522
  break;
1561
1523
  }
1562
1524
  }
1525
+ else {
1526
+ convertedValue = "";
1527
+ }
1563
1528
  return convertedValue;
1564
1529
  };
1565
1530
  const convertFormFieldValueToKwikUIFormat = (field, value) => {
@@ -1609,1296 +1574,1098 @@ const convertFormFieldEmptyValueToKwikUIFormat = (field) => {
1609
1574
  return value;
1610
1575
  };
1611
1576
 
1612
- class Defaults {
1613
- constructor(field, formFields, allFormsData, formData, previousFormData, takeAction) {
1614
- this._field = field;
1615
- this._formFields = formFields;
1616
- this._allFormsData = allFormsData;
1617
- this._formData = formData;
1618
- this._previousFormData = previousFormData;
1619
- this._takeAction = takeAction;
1620
- }
1621
- getFormFieldValue() {
1622
- return __awaiter(this, void 0, void 0, function* () {
1623
- let defaultValue;
1624
- const sources = this._field.default.value.sources;
1625
- let sourceIndex = 0;
1626
- for (let source of sources) {
1627
- const sources = new Source({
1628
- FIELD_CONFIG: this._field,
1629
- FORM_FIELDS: this._formFields,
1630
- FORM_DATA: this._formData,
1631
- PREVIOUS_FORM_DATA: this._previousFormData,
1632
- ALL_FORMS_DATA: this._allFormsData
1633
- });
1634
- const value = sources.getValueFromSource(source);
1635
- // Set the Value of current source.
1636
- this._field = setValueToObjectPath(this._field, `default.value.sources.[${sourceIndex}].value`, value);
1637
- const validation = source.validation;
1638
- const triggers = validation.triggers;
1639
- const rules = validation.rules;
1640
- const actions = validation.actions;
1641
- const rulesMapping = new Rule(rules, {
1642
- FIELD_CONFIG: this._field,
1643
- FORM_FIELDS: this._formFields,
1644
- FORM_DATA: this._formData,
1645
- PREVIOUS_FORM_DATA: this._previousFormData,
1646
- ALL_FORMS_DATA: this._allFormsData
1647
- }).mapping();
1648
- for (let action of actions) {
1649
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
1650
- if (conditionEvaluation) {
1651
- const actions = new Action(action, rulesMapping, {
1652
- FIELD_CONFIG: this._field,
1653
- FORM_FIELDS: this._formFields,
1654
- FORM_DATA: this._formData,
1655
- PREVIOUS_FORM_DATA: this._previousFormData,
1656
- ALL_FORMS_DATA: this._allFormsData
1657
- }, this._takeAction);
1658
- yield actions.execute();
1659
- }
1660
- }
1661
- sourceIndex++;
1577
+ class Converter {
1578
+ constructor() {
1579
+ this.getFormFields = (formConfig) => {
1580
+ let fields;
1581
+ if (checkObjectKeyExists(formConfig, "multiForm")) {
1582
+ fields = formConfig.multiForm.fields;
1662
1583
  }
1663
- defaultValue = this._field.default.value.value;
1664
- if (isEmptyValue(defaultValue)) {
1665
- defaultValue = convertFormFieldEmptyValueToKwikUIFormat(this._field);
1584
+ else {
1585
+ fields = formConfig.fields;
1666
1586
  }
1667
- return defaultValue;
1668
- });
1669
- }
1670
- getFormFieldOptions() {
1671
- return __awaiter(this, void 0, void 0, function* () {
1672
- const optionsConfig = this._field.default.options;
1673
- const rules = optionsConfig.rules;
1674
- const actions = optionsConfig.actions;
1675
- const rulesMapping = new Rule(rules, {
1676
- FIELD_CONFIG: this._field,
1677
- FORM_FIELDS: this._formFields,
1678
- FORM_DATA: this._formData,
1679
- PREVIOUS_FORM_DATA: this._previousFormData,
1680
- ALL_FORMS_DATA: this._allFormsData
1681
- }).mapping();
1682
- for (let action of actions) {
1683
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
1684
- if (conditionEvaluation) {
1685
- const actions = new Action(action, rulesMapping, {
1686
- FIELD_CONFIG: this._field,
1687
- FORM_FIELDS: this._formFields,
1688
- FORM_DATA: this._formData,
1689
- PREVIOUS_FORM_DATA: this._previousFormData,
1690
- ALL_FORMS_DATA: this._allFormsData
1691
- }, this._takeAction);
1692
- yield actions.execute();
1693
- }
1587
+ return fields;
1588
+ };
1589
+ this.setMissingFieldKeyValue = (field, key, value) => {
1590
+ if (!checkObjectKeyExists(field, key)) {
1591
+ field[key] = value;
1694
1592
  }
1695
- });
1696
- }
1697
- }
1698
- __decorate([
1699
- logMethod
1700
- ], Defaults.prototype, "getFormFieldValue", null);
1701
- __decorate([
1702
- logMethod
1703
- ], Defaults.prototype, "getFormFieldOptions", null);
1704
-
1705
- class FormValidation {
1706
- constructor() { }
1707
- getFormFieldValidators(field) {
1708
- let validators = [];
1709
- if (checkObjectKeyExists(field, "validators") &&
1710
- checkObjectKeyExists(field.validators, "min") &&
1711
- isNotEmptyValue(field.validators.min)) {
1712
- validators.push(Validators.min(field.validators.min));
1713
- }
1714
- if (checkObjectKeyExists(field, "validators") &&
1715
- checkObjectKeyExists(field.validators, "max") &&
1716
- isNotEmptyValue(field.validators.max)) {
1717
- validators.push(Validators.max(field.validators.max));
1718
- }
1719
- if ((checkObjectKeyExists(field, "required") && field.required) ||
1720
- (checkObjectKeyExists(field, "validators") &&
1721
- checkObjectKeyExists(field.validators, "required") &&
1722
- field.validators.required)) {
1723
- validators.push(Validators.required);
1724
- }
1725
- if (checkObjectKeyExists(field, "validators") &&
1726
- checkObjectKeyExists(field.validators, "minLength") &&
1727
- isNotEmptyValue(field.validators.minLength)) {
1728
- validators.push(Validators.minLength(field.validators.minLength));
1729
- }
1730
- if (checkObjectKeyExists(field, "validators") &&
1731
- checkObjectKeyExists(field.validators, "maxLength") &&
1732
- isNotEmptyValue(field.validators.maxLength)) {
1733
- validators.push(Validators.maxLength(field.validators.maxLength));
1734
- }
1735
- if (checkObjectKeyExists(field, "validators") &&
1736
- checkObjectKeyExists(field.validators, "pattern") &&
1737
- isNotEmptyValue(field.validators.pattern)) {
1738
- if (checkObjectKeyExists(field.validators.pattern, "key")) {
1739
- if (field.validators.pattern.key === "CUSTOM") {
1740
- validators.push(Validators.pattern(field.validators.pattern.pattern));
1741
- }
1742
- else {
1743
- validators.push(Validators.pattern(PATTERNS[field.validators.pattern.key]));
1744
- }
1593
+ return field;
1594
+ };
1595
+ this.setFieldKeyValue = (field, key, value) => {
1596
+ field[key] = value;
1597
+ return field;
1598
+ };
1599
+ this.removeFieldKey = (field, key) => {
1600
+ if (checkObjectKeyExists(field, key)) {
1601
+ delete field[key];
1745
1602
  }
1746
- }
1747
- return validators;
1603
+ return field;
1604
+ };
1748
1605
  }
1749
- getFormFieldsValidationErrors(formGroup) {
1750
- let errors = [];
1751
- for (const key in formGroup.controls) {
1752
- const controlErrors = formGroup.controls[key].errors;
1753
- if (controlErrors !== null && controlErrors !== undefined) {
1754
- Object.keys(controlErrors).forEach((keyError) => {
1755
- errors.push({
1756
- name: keyError,
1757
- value: controlErrors[keyError]
1758
- });
1759
- });
1760
- }
1606
+ updateFormConfigMiscellaneous(formConfig, args) {
1607
+ if (checkObjectKeyExists(args, "formsListLength")) {
1608
+ formConfig = setValueToObjectPath(formConfig, "formsListLength", args.formsListLength);
1761
1609
  }
1762
- return errors;
1610
+ return formConfig;
1763
1611
  }
1764
- getFormFieldsInvalidControls(formToInvestigate) {
1765
- var controls = [];
1766
- let recursiveFunc = (form) => {
1767
- Object.keys(form.controls).forEach((field) => {
1768
- const control = form.get(field);
1769
- if (control.invalid) {
1770
- controls.push({
1771
- key: field,
1772
- invalid: true
1773
- });
1774
- }
1775
- else {
1776
- controls.push({
1777
- key: field,
1778
- invalid: false
1779
- });
1780
- }
1781
- if (control instanceof FormGroup) {
1782
- recursiveFunc(control);
1612
+ updateFormConfigProperties(formConfig) {
1613
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
1614
+ const formProperties = {
1615
+ header: {
1616
+ title: {
1617
+ hidden: false,
1618
+ label: formConfig.title
1619
+ },
1620
+ steps: {
1621
+ hidden: false
1783
1622
  }
1784
- else if (control instanceof FormArray) {
1785
- recursiveFunc(control);
1623
+ },
1624
+ footer: {
1625
+ viewFormsButton: {
1626
+ hidden: false,
1627
+ label: "View Forms"
1628
+ },
1629
+ saveButton: {
1630
+ hidden: false,
1631
+ label: "Save"
1786
1632
  }
1787
- });
1633
+ }
1788
1634
  };
1789
- recursiveFunc(formToInvestigate);
1790
- return controls;
1635
+ if (checkObjectKeyExists(formConfig, "properties")) {
1636
+ const headerTitleHidden = (_c = (_b = (_a = formConfig.properties.header) === null || _a === void 0 ? void 0 : _a.title) === null || _b === void 0 ? void 0 : _b.hidden) !== null && _c !== void 0 ? _c : formProperties.header.title.hidden;
1637
+ const headerTitleLabel = (_f = (_e = (_d = formConfig.properties.header) === null || _d === void 0 ? void 0 : _d.title) === null || _e === void 0 ? void 0 : _e.label) !== null && _f !== void 0 ? _f : formConfig.title;
1638
+ const headerStepsHidden = (_j = (_h = (_g = formConfig.properties.header) === null || _g === void 0 ? void 0 : _g.steps) === null || _h === void 0 ? void 0 : _h.hidden) !== null && _j !== void 0 ? _j : formProperties.header.steps.hidden;
1639
+ const viewFormsButtonHidden = (_m = (_l = (_k = formConfig.properties.footer) === null || _k === void 0 ? void 0 : _k.viewFormsButton) === null || _l === void 0 ? void 0 : _l.hidden) !== null && _m !== void 0 ? _m : formProperties.footer.viewFormsButton.hidden;
1640
+ const viewFormsButtonLabel = (_q = (_p = (_o = formConfig.properties.footer) === null || _o === void 0 ? void 0 : _o.viewFormsButton) === null || _p === void 0 ? void 0 : _p.label) !== null && _q !== void 0 ? _q : formProperties.footer.viewFormsButton.label;
1641
+ const saveButtonHidden = (_t = (_s = (_r = formConfig.properties.footer) === null || _r === void 0 ? void 0 : _r.saveButton) === null || _s === void 0 ? void 0 : _s.hidden) !== null && _t !== void 0 ? _t : formProperties.footer.saveButton.hidden;
1642
+ const saveButtonLabel = (_w = (_v = (_u = formConfig.properties.footer) === null || _u === void 0 ? void 0 : _u.saveButton) === null || _v === void 0 ? void 0 : _v.label) !== null && _w !== void 0 ? _w : formProperties.footer.saveButton.label;
1643
+ formConfig.properties = {
1644
+ header: {
1645
+ title: {
1646
+ hidden: headerTitleHidden,
1647
+ label: headerTitleLabel
1648
+ },
1649
+ steps: {
1650
+ hidden: headerStepsHidden
1651
+ }
1652
+ },
1653
+ footer: {
1654
+ viewFormsButton: {
1655
+ hidden: viewFormsButtonHidden,
1656
+ label: viewFormsButtonLabel
1657
+ },
1658
+ saveButton: {
1659
+ hidden: saveButtonHidden,
1660
+ label: saveButtonLabel
1661
+ }
1662
+ }
1663
+ };
1664
+ }
1665
+ else {
1666
+ formConfig.properties = formProperties;
1667
+ }
1668
+ return formConfig;
1791
1669
  }
1792
- }
1793
- __decorate([
1794
- logMethod
1795
- ], FormValidation.prototype, "getFormFieldValidators", null);
1796
- __decorate([
1797
- logMethod
1798
- ], FormValidation.prototype, "getFormFieldsValidationErrors", null);
1799
- __decorate([
1800
- logMethod
1801
- ], FormValidation.prototype, "getFormFieldsInvalidControls", null);
1802
-
1803
- class KwikIDFormViewService {
1804
- constructor() { }
1805
- // 'init' stage of the form
1806
- createFormGroup(fields, formData, previousFormData, allFormsData, takeAction) {
1807
- return __awaiter(this, void 0, void 0, function* () {
1808
- let formGroup = new FormGroup({});
1809
- for (let field of fields) {
1810
- if (field.isFormElement) {
1811
- const defaults = new Defaults(field, fields, allFormsData, formData, previousFormData, takeAction);
1812
- let value = yield defaults.getFormFieldValue();
1813
- if (checkObjectKeyExists(field, "default")) {
1814
- if (checkObjectKeyExists(field.default, "options")) {
1815
- if (field.default.options.triggers.includes("ON_INIT")) {
1816
- yield defaults.getFormFieldOptions();
1817
- }
1818
- }
1670
+ convertFormConfig(formConfig) {
1671
+ const updateOnFieldType = (field) => {
1672
+ const formatFieldTypeHtml = (field) => {
1673
+ field = this.setFieldKeyValue(field, "isFormElement", false);
1674
+ return field;
1675
+ };
1676
+ const formatFieldTypeTitle = (field) => {
1677
+ field = this.setFieldKeyValue(field, "hidden", false);
1678
+ field = this.setFieldKeyValue(field, "isFormElement", false);
1679
+ return field;
1680
+ };
1681
+ const formatFieldTypeText = (field) => {
1682
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1683
+ field.properties = this.setMissingFieldKeyValue(field.properties, "case", "default");
1684
+ return field;
1685
+ };
1686
+ const formatFieldTypeCheckbox = (field) => {
1687
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1688
+ return field;
1689
+ };
1690
+ const formatFieldTypeNumber = (field) => {
1691
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1692
+ if (checkObjectKeyExists(field, "key")) {
1693
+ if (field.key === "aadhaar_number") {
1694
+ field = this.setFieldKeyValue(field, "type", "aadhaar_number");
1819
1695
  }
1820
- value = convertFormFieldValueToKwikUIFormat(field, value);
1821
- const validators = new FormValidation().getFormFieldValidators(field);
1822
- formGroup.addControl(field.key, new FormControl({ value: value, disabled: field.disabled }, { validators: validators }));
1823
- }
1824
- }
1825
- return formGroup;
1826
- });
1827
- }
1828
- }
1829
- __decorate([
1830
- logMethod
1831
- ], KwikIDFormViewService.prototype, "createFormGroup", null);
1832
-
1833
- class Apis {
1834
- constructor(object, takeAction) {
1835
- this._object = object;
1836
- this._takeAction = takeAction;
1837
- this._api = this._object.FIELD_CONFIG.api;
1838
- this._request = this._object.FIELD_CONFIG.api.request;
1839
- this._response = this._object.FIELD_CONFIG.api.response;
1840
- this._status = this._object.FIELD_CONFIG.api.status;
1841
- }
1842
- get object() {
1843
- return this._object;
1844
- }
1845
- set object(value) {
1846
- this._object = value;
1847
- }
1848
- setRequestBody() {
1849
- var _a, _b, _c, _d;
1850
- return __awaiter(this, void 0, void 0, function* () {
1851
- let params = this._request.body.params;
1852
- let paramIndex = 0;
1853
- for (let param of params) {
1854
- let sources = param.sources;
1855
- let sourceIndex = 0;
1856
- for (let source of sources) {
1857
- const sources = new Source(this._object);
1858
- const value = sources.getValueFromSource(source);
1859
- // Set the Value of current source.
1860
- this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
1861
- const validation = source.validation;
1862
- const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
1863
- const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
1864
- const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
1865
- const rulesMapping = new Rule(rules, this._object).mapping();
1866
- for (let action of actions) {
1867
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
1868
- if (conditionEvaluation) {
1869
- const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1870
- yield actions.execute();
1871
- }
1696
+ if (field.key === "contact_number") {
1697
+ field = this.setFieldKeyValue(field, "type", "phone");
1698
+ }
1699
+ if (field.type === "phone" || field.type === "number") {
1700
+ field.properties = this.setMissingFieldKeyValue(field.properties, "countryCode", "+91");
1701
+ field.properties = this.setMissingFieldKeyValue(field.properties, "phoneMaskAfterCountryCode", "####-######");
1702
+ field.properties = this.setMissingFieldKeyValue(field.properties, "removeCountryCodeFromValue", true);
1703
+ field.properties = this.setMissingFieldKeyValue(field.properties, "decimal", "never");
1704
+ field.properties = this.setMissingFieldKeyValue(field.properties, "prefix", "");
1705
+ field.properties = this.setMissingFieldKeyValue(field.properties, "postfix", "");
1706
+ field.properties = this.setMissingFieldKeyValue(field.properties, "min", -Infinity);
1707
+ field.properties = this.setMissingFieldKeyValue(field.properties, "max", Infinity);
1708
+ field.properties = this.setMissingFieldKeyValue(field.properties, "precision", 2);
1872
1709
  }
1873
- sourceIndex++;
1874
1710
  }
1875
- paramIndex++;
1876
- }
1877
- return this._object.FIELD_CONFIG;
1878
- });
1879
- }
1880
- validateRequestBody() {
1881
- var _a;
1882
- return __awaiter(this, void 0, void 0, function* () {
1883
- const body = this._request.body;
1884
- const validation = body.validation;
1885
- const triggers = validation.triggers;
1886
- const rules = validation.rules;
1887
- const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
1888
- const rulesMapping = new Rule(rules, this._object).mapping();
1889
- for (let action of actions) {
1890
- const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1891
- if (conditionSuccess) {
1892
- const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1893
- yield actions.execute();
1711
+ field = this.setFieldKeyValue(field, "hidden", false);
1712
+ return field;
1713
+ };
1714
+ const formatFieldTypeDate = (field) => {
1715
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1716
+ if (checkObjectKeyExists(field, "min")) {
1717
+ const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["min"]);
1718
+ field.properties = this.setFieldKeyValue(field.properties, "min", tuiDay);
1894
1719
  }
1895
- }
1896
- return this._object.FIELD_CONFIG;
1897
- });
1898
- }
1899
- setRequestHeaders() {
1900
- var _a, _b, _c, _d;
1901
- return __awaiter(this, void 0, void 0, function* () {
1902
- if (checkObjectKeyExists(this._request, "headers")) {
1903
- if (checkObjectKeyExists(this._request.headers, "params")) {
1904
- let params = this._request.headers.params;
1905
- let paramIndex = 0;
1906
- for (let param of params) {
1907
- let sources = param.sources;
1908
- let sourceIndex = 0;
1909
- for (let source of sources) {
1910
- const sources = new Source(this._object);
1911
- const value = sources.getValueFromSource(source);
1912
- // Set the Value of current source.
1913
- this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.headers.params[${paramIndex}].sources[${sourceIndex}].value`, value);
1914
- const validation = source.validation;
1915
- const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
1916
- const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
1917
- const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
1918
- const rulesMapping = new Rule(rules, this._object).mapping();
1919
- for (let action of actions) {
1920
- const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
1921
- if (conditionEvaluation) {
1922
- const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1923
- yield actions.execute();
1924
- }
1925
- }
1926
- sourceIndex++;
1927
- }
1928
- paramIndex++;
1929
- }
1930
- return this._object.FIELD_CONFIG;
1720
+ else {
1721
+ field.properties = this.setMissingFieldKeyValue(field.properties, "min", new TuiDay(0, 0, 1)); // Year - 0000, Month - 0 (0 Indexing), Day - 1
1722
+ }
1723
+ if (checkObjectKeyExists(field, "max")) {
1724
+ const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["max"]);
1725
+ field.properties = this.setFieldKeyValue(field.properties, "max", tuiDay);
1931
1726
  }
1932
1727
  else {
1933
- return this._object.FIELD_CONFIG;
1728
+ field.properties = this.setMissingFieldKeyValue(field.properties, "max", new TuiDay(new Date().getFullYear(), // Year - 9999
1729
+ new Date().getMonth(), // Month - 11 (0 Indexing)
1730
+ new Date().getDate() // Day - 31
1731
+ ));
1934
1732
  }
1935
- }
1936
- else {
1937
- return this._object.FIELD_CONFIG;
1938
- }
1939
- });
1940
- }
1941
- validateRequestHeaders() {
1942
- var _a;
1943
- return __awaiter(this, void 0, void 0, function* () {
1944
- const headers = this._request.headers;
1945
- if (checkObjectKeyExists(this._request, "headers")) {
1946
- if (checkObjectKeyExists(this._request.headers, "validation")) {
1947
- const validation = headers.validation;
1948
- const triggers = validation.triggers;
1949
- const rules = validation.rules;
1950
- const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
1951
- const rulesMapping = new Rule(rules, this._object).mapping();
1952
- for (let action of actions) {
1953
- const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1954
- if (conditionSuccess) {
1955
- const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1956
- yield actions.execute();
1733
+ field.properties = this.setMissingFieldKeyValue(field.properties, "placeholder", "");
1734
+ field = this.setFieldKeyValue(field, "hidden", false);
1735
+ return field;
1736
+ };
1737
+ const formatFieldTypePhone = (field) => {
1738
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1739
+ return field;
1740
+ };
1741
+ const formatFieldTypeRadio = (field) => {
1742
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1743
+ field.properties = this.setMissingFieldKeyValue(field.properties, "size", "m");
1744
+ field.properties = this.setMissingFieldKeyValue(field.properties, "orientation", "vertical");
1745
+ field = this.setFieldKeyValue(field, "hidden", false);
1746
+ field.options = field.options.map((x) => {
1747
+ if (typeof x === "string" || typeof x === "number") {
1748
+ return { label: x, disabled: false, description: "" };
1749
+ }
1750
+ else {
1751
+ if (checkObjectKeyExists(x, "label") &&
1752
+ checkObjectKeyExists(x, "disabled") &&
1753
+ checkObjectKeyExists(x, "description")) {
1754
+ return x;
1957
1755
  }
1756
+ if (!checkObjectKeyExists(x, "disabled")) {
1757
+ x = Object.assign(Object.assign({}, x), { disabled: false });
1758
+ }
1759
+ if (!checkObjectKeyExists(x, "description")) {
1760
+ x = Object.assign(Object.assign({}, x), { description: false });
1761
+ }
1762
+ return x;
1763
+ }
1764
+ });
1765
+ return field;
1766
+ };
1767
+ const formatFieldTypeSearchText = (field) => {
1768
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1769
+ if (checkObjectKeyExists(field, "type")) {
1770
+ if (field.type === "search-text") {
1771
+ field = this.setFieldKeyValue(field, "type", "dropdown-with-search");
1958
1772
  }
1959
- return this._object.FIELD_CONFIG;
1960
1773
  }
1961
- else {
1962
- return this._object.FIELD_CONFIG;
1774
+ return field;
1775
+ };
1776
+ const formatFieldTypeDropdownWithSearch = (field) => {
1777
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1778
+ return field;
1779
+ };
1780
+ const formatFieldTypeApiCall = (field) => {
1781
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1782
+ if (!checkObjectKeyExists(field.properties, "shape")) {
1783
+ field.properties = this.setFieldKeyValue(field.properties, "shape", null);
1963
1784
  }
1964
- }
1965
- else {
1966
- return this._object.FIELD_CONFIG;
1967
- }
1968
- });
1969
- }
1970
- validateResponse() {
1971
- return __awaiter(this, void 0, void 0, function* () {
1972
- const validation = this._response.validation;
1973
- const triggers = validation.triggers;
1974
- const rules = validation.rules;
1975
- const actions = validation.actions;
1976
- const rulesMapping = new Rule(rules, this._object).mapping();
1977
- for (let action of actions) {
1978
- const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
1979
- if (conditionSuccess) {
1980
- const actions = new Action(action, rulesMapping, this._object, this._takeAction);
1981
- yield actions.execute();
1982
- }
1983
- }
1984
- return this._object.FIELD_CONFIG;
1985
- });
1986
- }
1987
- }
1988
- __decorate([
1989
- logMethod
1990
- ], Apis.prototype, "setRequestBody", null);
1991
- __decorate([
1992
- logMethod
1993
- ], Apis.prototype, "validateRequestBody", null);
1994
- __decorate([
1995
- logMethod
1996
- ], Apis.prototype, "setRequestHeaders", null);
1997
- __decorate([
1998
- logMethod
1999
- ], Apis.prototype, "validateRequestHeaders", null);
2000
- __decorate([
2001
- logMethod
2002
- ], Apis.prototype, "validateResponse", null);
2003
-
2004
- /**
2005
- * Generated class for the SafeHtmlPipe pipe.
2006
- *
2007
- * See https://angular.io/api/core/Pipe for more info on Angular Pipes.
2008
- */
2009
- class SafeHtmlPipe$1 {
2010
- constructor(sanitizer) {
2011
- this.sanitizer = sanitizer;
2012
- }
2013
- transform(html) {
2014
- return this.sanitizer.bypassSecurityTrustHtml(html);
2015
- }
2016
- }
2017
- /** @nocollapse */ SafeHtmlPipe$1.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe$1, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
2018
- /** @nocollapse */ SafeHtmlPipe$1.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe$1, name: "safeHtml" });
2019
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe$1, decorators: [{
2020
- type: Pipe,
2021
- args: [{
2022
- name: "safeHtml"
2023
- }]
2024
- }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
2025
-
2026
- class KwikIDFormViewComponent {
2027
- constructor(push, alert, formViewService) {
2028
- this.push = push;
2029
- this.alert = alert;
2030
- this.formViewService = formViewService;
2031
- this.isMobileView = false;
2032
- this.onClickViewForms = new EventEmitter();
2033
- this.onClickSaveForm = new EventEmitter();
2034
- this.onClickApiCall = new EventEmitter();
2035
- this.fieldGroups = {};
2036
- this.formFields = [];
2037
- this.previousFormData = {};
2038
- this.formsListLength = 0;
2039
- this.loading = true;
2040
- this.viewFormsButton = {
2041
- disabled: false,
2042
- showLoader: false
2043
- };
2044
- this.saveFormButton = {
2045
- disabled: false,
2046
- showLoader: false
2047
- };
2048
- this.formGroup = new FormGroup({});
2049
- this.showErrorNotification = false;
2050
- }
2051
- ngOnInit() {
2052
- (() => __awaiter(this, void 0, void 0, function* () {
2053
- this.formsList = this.formsList.filter((form) => {
2054
- if (checkObjectKeyExists(form, "hidden")) {
2055
- if (!form.hidden) {
2056
- return form;
2057
- }
1785
+ if (!checkObjectKeyExists(field, "showLoader")) {
1786
+ field = this.setFieldKeyValue(field, "showLoader", false);
2058
1787
  }
2059
- });
2060
- this.formsListLength = this.findFormsListLength(this.formsList);
2061
- yield this.initFormConfig(this.formConfig);
2062
- this.loading = false;
2063
- }))();
2064
- }
2065
- ngAfterViewInit() { }
2066
- ngOnChanges(changes) {
2067
- const verifyChange = (key) => {
2068
- return checkObjectKeyExists(changes, key) && !changes[key].firstChange;
2069
- };
2070
- if (verifyChange("formData")) {
2071
- this.formData = Object.assign(Object.assign({}, this.formData), changes.formData.currentValue);
2072
- }
2073
- if (verifyChange("isMobileView")) {
2074
- this.isMobileView = changes.isMobileView.currentValue;
2075
- }
2076
- if (verifyChange("allFormsData")) {
2077
- this.allFormsData = changes.allFormsData.currentValue;
2078
- }
2079
- if (verifyChange("formsList")) {
2080
- this.formsList = changes.formsList.currentValue.filter((form) => {
2081
- if (checkObjectKeyExists(form, "hidden")) {
2082
- if (!form.hidden) {
2083
- return form;
2084
- }
1788
+ if (!checkObjectKeyExists(field.properties, "size")) {
1789
+ field.properties = this.setFieldKeyValue(field.properties, "size", "m");
2085
1790
  }
2086
- });
2087
- this.formsListLength = this.findFormsListLength(this.formsList);
2088
- }
2089
- if (verifyChange("formConfig")) {
2090
- this.formConfig = changes.formConfig.currentValue;
2091
- (() => __awaiter(this, void 0, void 0, function* () {
2092
- yield this.initFormConfig(this.formConfig);
2093
- }))();
2094
- }
2095
- }
2096
- findFormsListLength(formsList) {
2097
- const _formsList = formsList.filter((form) => {
2098
- if (checkObjectKeyExists(form, "type")) {
2099
- if (form.type === "form") {
2100
- if (checkObjectKeyExists(form, "hidden")) {
2101
- if (!form.hidden) {
2102
- return form;
2103
- }
2104
- }
1791
+ if (!checkObjectKeyExists(field, "api")) {
1792
+ field = this.setFieldKeyValue(field, "api", {});
1793
+ field.api = this.setMissingFieldKeyValue(field.api, "url", "");
1794
+ field.api = this.setMissingFieldKeyValue(field.api, "request", "");
1795
+ field.api = this.setMissingFieldKeyValue(field.api, "response", "");
1796
+ field.api = this.setMissingFieldKeyValue(field.api, "status", "");
1797
+ field.api.status = this.setMissingFieldKeyValue(field.api.status, "value", "default");
1798
+ field.api.status = this.setMissingFieldKeyValue(field.api.status, "labels", {
1799
+ default: "Call API",
1800
+ loading: "Call API",
1801
+ success: "API Success",
1802
+ failed: "API Failed"
1803
+ });
2105
1804
  }
1805
+ return field;
1806
+ };
1807
+ const formatFieldTypeOtp = (field) => {
1808
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1809
+ field.properties = this.setMissingFieldKeyValue(field.properties, "mask", new Array(field.properties.otpLength).fill("#").join(" "));
1810
+ field = this.setFieldKeyValue(field, "hidden", false);
1811
+ return field;
1812
+ };
1813
+ const formatFieldTypeAadhaarNumber = (field) => {
1814
+ field = this.setFieldKeyValue(field, "isFormElement", true);
1815
+ return field;
1816
+ };
1817
+ switch (field.type) {
1818
+ case EFieldType.HTML:
1819
+ field = formatFieldTypeHtml(field);
1820
+ break;
1821
+ case EFieldType.TITLE:
1822
+ field = formatFieldTypeTitle(field);
1823
+ break;
1824
+ case EFieldType.TEXT:
1825
+ field = formatFieldTypeText(field);
1826
+ break;
1827
+ case EFieldType.CHECKBOX:
1828
+ field = formatFieldTypeCheckbox(field);
1829
+ break;
1830
+ case EFieldType.NUMBER:
1831
+ field = formatFieldTypeNumber(field);
1832
+ break;
1833
+ case EFieldType.DATE:
1834
+ field = formatFieldTypeDate(field);
1835
+ break;
1836
+ case EFieldType.PHONE:
1837
+ field = formatFieldTypePhone(field);
1838
+ break;
1839
+ case EFieldType.RADIO:
1840
+ field = formatFieldTypeRadio(field);
1841
+ break;
1842
+ case "search-text":
1843
+ field = formatFieldTypeSearchText(field);
1844
+ break;
1845
+ case EFieldType.DROPDOWN_WITH_SEARCH:
1846
+ field = formatFieldTypeDropdownWithSearch(field);
1847
+ break;
1848
+ case EFieldType.API_CALL:
1849
+ field = formatFieldTypeApiCall(field);
1850
+ break;
1851
+ case EFieldType.OTP:
1852
+ field = formatFieldTypeOtp(field);
1853
+ break;
1854
+ case EFieldType.AADHAAR_NUMBER:
1855
+ field = formatFieldTypeAadhaarNumber(field);
1856
+ break;
1857
+ default:
1858
+ break;
2106
1859
  }
2107
- else if (checkObjectKeyExists(form, "hidden")) {
2108
- if (!form.hidden) {
2109
- return form;
1860
+ return field;
1861
+ };
1862
+ const getConnectedElementTypeValueObject = (key) => {
1863
+ const object = {
1864
+ key: key,
1865
+ conditions: { formula: "", rules: [] },
1866
+ actions: { success: [], failure: [] }
1867
+ };
1868
+ return object;
1869
+ };
1870
+ const formatFieldKeys = (field) => {
1871
+ if (checkObjectKeyExists(field, "connectedTo")) {
1872
+ if (typeof field["connectedTo"] === "string") {
1873
+ field["connectedElements"] = [
1874
+ getConnectedElementTypeValueObject(field["connectedTo"])
1875
+ ];
2110
1876
  }
2111
- }
2112
- });
2113
- return _formsList.length;
2114
- }
2115
- initFormConfig(formConfig) {
2116
- return __awaiter(this, void 0, void 0, function* () {
2117
- this.setFormFieldsFromFormConfig(formConfig);
2118
- this.setFormFieldGroupsFromFormConfig(formConfig);
2119
- this.setFormDataFromAllFormsData();
2120
- this.formGroup = yield this.formViewService.createFormGroup(this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
2121
- for (let field of this.formFields) {
2122
- if (field.isFormElement) {
2123
- this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: this.formGroup.controls[field.key].value });
2124
- this.formGroup.controls[field.key].valueChanges
2125
- .pipe(pairwise())
2126
- .subscribe(([previousValue, currentValue]) => {
2127
- this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, previousValue) });
2128
- this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: convertFormFieldValueToStandardFormat(field, currentValue) });
1877
+ else {
1878
+ field["connectedTo"] = field["connectedTo"].map((key) => {
1879
+ return getConnectedElementTypeValueObject(key);
2129
1880
  });
1881
+ field["connectedElements"] = field["connectedTo"];
2130
1882
  }
2131
1883
  }
2132
- for (let field of this.formFields) {
2133
- if (field.isFormElement) {
2134
- if (field.validation.triggers.includes("ON_INIT")) {
2135
- const validations = new Validation({
2136
- FIELD_CONFIG: field,
2137
- FORM_FIELDS: this.formFields,
2138
- FORM_DATA: this.formData,
2139
- PREVIOUS_FORM_DATA: this.previousFormData,
2140
- ALL_FORMS_DATA: this.allFormsData
2141
- }, this.takeAction.bind(this));
2142
- yield validations.validate(field.validation);
2143
- }
2144
- if (checkObjectKeyExists(field, "connectedElements")) {
2145
- this.handleConnectedElements({
2146
- key: field.key,
2147
- value: this.formGroup.controls[field.key].value
2148
- }, "ON_INIT");
2149
- }
1884
+ this.removeFieldKey(field, "connectedTo");
1885
+ if (checkObjectKeyExists(field, "connectedToParent")) {
1886
+ if (typeof field["connectedToParent"] === "string") {
1887
+ field["connectedParentFields"] = [
1888
+ getConnectedElementTypeValueObject(field["connectedToParent"])
1889
+ ];
1890
+ }
1891
+ else {
1892
+ field["connectedParentFields"] = getConnectedElementTypeValueObject(field["connectedToParent"]);
2150
1893
  }
2151
1894
  }
2152
- });
2153
- }
2154
- setFormFieldsFromFormConfig(formConfig) {
2155
- if (checkObjectKeyExists(formConfig, "fields")) {
2156
- this.formFields = formConfig.fields;
2157
- }
2158
- else if (checkObjectKeyExists(formConfig, "multiForm") &&
2159
- checkObjectKeyExists(formConfig.multiForm, "fields")) {
2160
- this.formFields = formConfig.multiForm.fields;
2161
- }
2162
- }
2163
- setFormFieldGroupsFromFormConfig(formConfig) {
2164
- this.fieldGroups = formConfig.fieldGroups;
2165
- }
2166
- setFormDataFromAllFormsData() {
2167
- if (checkObjectKeyExists(this.allFormsData, this.formConfig.key)) {
2168
- this.formData = this.allFormsData[this.formConfig.key];
2169
- }
2170
- else {
2171
- this.formData = {};
2172
- }
2173
- }
2174
- handleConnectedElementFieldGroupActions(childFieldGroupConfig, parentField) {
2175
- return __awaiter(this, void 0, void 0, function* () {
2176
- if (checkObjectKeyExists(childFieldGroupConfig, "rules")) {
2177
- const rulesMapping = new Rule(childFieldGroupConfig.rules, {
2178
- FIELD_CONFIG: parentField,
2179
- FORM_DATA: this.formData,
2180
- PREVIOUS_FORM_DATA: this.previousFormData,
2181
- ALL_FORMS_DATA: this.allFormsData
2182
- }).mapping();
2183
- for (let action of childFieldGroupConfig.actions) {
2184
- const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2185
- if (conditionSuccess) {
2186
- const actions = new Action(action, rulesMapping, {
2187
- FIELD_CONFIG: parentField,
2188
- FORM_FIELDS: this.formFields,
2189
- FORM_DATA: this.formData,
2190
- PREVIOUS_FORM_DATA: this.previousFormData,
2191
- ALL_FORMS_DATA: this.allFormsData
2192
- }, this.takeActionOnFieldGroup.bind(this));
2193
- yield actions.execute();
2194
- }
1895
+ this.removeFieldKey(field, "connectedToParent");
1896
+ this.removeFieldKey(field, "sideEffect");
1897
+ return field;
1898
+ };
1899
+ const updateFieldValidatorConfig = (field) => {
1900
+ var _a, _b, _c, _d, _e;
1901
+ if (field.isFormElement) {
1902
+ const validators = checkObjectKeyExists(field, "validators")
1903
+ ? field.validators
1904
+ : {};
1905
+ field = this.setMissingFieldKeyValue(field, "validators", {});
1906
+ field = this.setFieldKeyValue(field, "validators", Object.assign(Object.assign({}, field["validators"]), { min: checkObjectKeyExists(validators, "min")
1907
+ ? isNotEmptyValue(validators.min)
1908
+ ? Number(validators.min)
1909
+ : null
1910
+ : checkObjectKeyExists(field, "min")
1911
+ ? Number(field.min)
1912
+ : null, max: checkObjectKeyExists(validators, "max")
1913
+ ? isNotEmptyValue(validators.max)
1914
+ ? Number(validators.max)
1915
+ : null
1916
+ : checkObjectKeyExists(field, "max")
1917
+ ? Number(field.max)
1918
+ : null, required: checkObjectKeyExists(validators, "required")
1919
+ ? Boolean(validators.required)
1920
+ : checkObjectKeyExists(field, "required")
1921
+ ? Boolean(field.required)
1922
+ : false, minLength: checkObjectKeyExists(validators, "minLength")
1923
+ ? isNotEmptyValue(validators.minLength)
1924
+ ? Number(validators.minLength)
1925
+ : null
1926
+ : checkObjectKeyExists(field, "minLength")
1927
+ ? Number(field.minLength)
1928
+ : null, maxLength: checkObjectKeyExists(validators, "maxLength")
1929
+ ? isNotEmptyValue(validators.maxLength)
1930
+ ? Number(validators.maxLength)
1931
+ : null
1932
+ : checkObjectKeyExists(field, "length")
1933
+ ? Number(field.length)
1934
+ : checkObjectKeyExists(field, "maxLength")
1935
+ ? Number(field.maxLength)
1936
+ : null, pattern: checkObjectKeyExists(validators, "pattern")
1937
+ ? isNotEmptyValue(validators.pattern)
1938
+ ? validators.pattern
1939
+ : undefined
1940
+ : checkObjectKeyExists(field, "pattern")
1941
+ ? { key: "CUSTOM", pattern: String(field.pattern) }
1942
+ : checkObjectKeyExists(field, "regex")
1943
+ ? { key: "CUSTOM", pattern: String(field.regex) }
1944
+ : undefined }));
1945
+ delete field.min;
1946
+ delete field.max;
1947
+ delete field.required;
1948
+ delete field.minLength;
1949
+ delete field.length;
1950
+ delete field.maxLength;
1951
+ delete field.pattern;
1952
+ delete field.regex;
1953
+ switch (field.type) {
1954
+ case EFieldType.TEXT:
1955
+ delete field.validators.min;
1956
+ delete field.validators.max;
1957
+ break;
1958
+ case EFieldType.CHECKBOX:
1959
+ delete field.validators.min;
1960
+ delete field.validators.max;
1961
+ break;
1962
+ default:
1963
+ break;
2195
1964
  }
2196
- }
2197
- });
2198
- }
2199
- handleConnectedElementFieldGroup(currentField, connectedFieldGroupConfig, eventType) {
2200
- return __awaiter(this, void 0, void 0, function* () {
2201
- if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers")) {
2202
- if (connectedFieldGroupConfig.triggers.includes(eventType)) {
2203
- yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
1965
+ if (isEmptyValue((_a = field.validators) === null || _a === void 0 ? void 0 : _a.min)) {
1966
+ delete field.validators.min;
2204
1967
  }
2205
- }
2206
- });
2207
- }
2208
- handleConnectedElementFieldActions(connectedFieldConfig, connectedField) {
2209
- return __awaiter(this, void 0, void 0, function* () {
2210
- if (checkObjectKeyExists(connectedFieldConfig, "rules")) {
2211
- const rulesMapping = new Rule(connectedFieldConfig.rules, {
2212
- FIELD_CONFIG: connectedField,
2213
- FORM_DATA: this.formData,
2214
- PREVIOUS_FORM_DATA: this.previousFormData,
2215
- ALL_FORMS_DATA: this.allFormsData
2216
- }).mapping();
2217
- for (let action of connectedFieldConfig.actions) {
2218
- const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2219
- if (conditionSuccess) {
2220
- const actions = new Action(action, rulesMapping, {
2221
- FORM_FIELDS: this.formFields,
2222
- FIELD_CONFIG: connectedField,
2223
- FORM_DATA: this.formData,
2224
- PREVIOUS_FORM_DATA: this.previousFormData,
2225
- ALL_FORMS_DATA: this.allFormsData
2226
- }, this.takeAction.bind(this));
2227
- yield actions.execute();
2228
- }
1968
+ if (isEmptyValue((_b = field.validators) === null || _b === void 0 ? void 0 : _b.max)) {
1969
+ delete field.validators.min;
2229
1970
  }
2230
- }
2231
- return connectedField;
2232
- });
2233
- }
2234
- handleConnectedElementFields(currentField, connectedFieldConfig, eventType, nested) {
2235
- return __awaiter(this, void 0, void 0, function* () {
2236
- let connectedField = getFormFieldByKey(this.formFields, connectedFieldConfig["key"]);
2237
- if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
2238
- if (connectedFieldConfig.triggers.includes(eventType)) {
2239
- connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
1971
+ if (isEmptyValue((_c = field.validators) === null || _c === void 0 ? void 0 : _c.minLength)) {
1972
+ delete field.validators.minLength;
2240
1973
  }
2241
- }
2242
- if (checkObjectKeyExists(connectedFieldConfig, "handleNestedFields")) {
2243
- if (connectedFieldConfig.handleNestedFields) {
2244
- this.handleConnectedElements({ key: connectedFieldConfig.key }, eventType);
1974
+ if (isEmptyValue((_d = field.validators) === null || _d === void 0 ? void 0 : _d.maxLength)) {
1975
+ delete field.validators.maxLength;
2245
1976
  }
2246
- }
2247
- return currentField;
2248
- });
2249
- }
2250
- handleConnectedElements(e, eventType) {
2251
- return __awaiter(this, void 0, void 0, function* () {
2252
- let currentField = getFormFieldByKey(this.formFields, e.key);
2253
- if (currentField !== undefined) {
2254
- if (checkObjectKeyExists(currentField, "connectedElements")) {
2255
- if (checkObjectKeyExists(currentField.connectedElements, "connectedFieldGroups")) {
2256
- let connectedFieldGroups = currentField.connectedElements.connectedFieldGroups;
2257
- for (let connectedFieldGroupConfig of connectedFieldGroups) {
2258
- yield this.handleConnectedElementFieldGroup(currentField, connectedFieldGroupConfig, eventType);
2259
- }
2260
- }
2261
- if (checkObjectKeyExists(currentField.connectedElements, "connectedFields")) {
2262
- let connectedFields = currentField.connectedElements.connectedFields;
2263
- for (let connectedFieldConfig of connectedFields) {
2264
- currentField = yield this.handleConnectedElementFields(currentField, connectedFieldConfig, eventType, eventType);
2265
- }
2266
- }
1977
+ if (isEmptyValue((_e = field.validators) === null || _e === void 0 ? void 0 : _e.pattern)) {
1978
+ delete field.validators.pattern;
2267
1979
  }
1980
+ field.focus = false;
1981
+ field.invalid = false;
2268
1982
  }
2269
- else {
2270
- throw new Error(`Field for the given key ['${e.key}'] is not found with eventType: '${eventType}'.`);
2271
- }
2272
- });
2273
- }
2274
- // DOM Event Handlers
2275
- handleGetKeyValue(e) {
2276
- this.formGroup.patchValue({
2277
- [e.key]: e.value
2278
- }, { emitEvent: false });
2279
- const field = getFormFieldByKey(this.formFields, e.key);
2280
- this.formData[e.key] = convertFormFieldValueToStandardFormat(field, e.value);
2281
- if (field.isFormElement &&
2282
- field.validation.triggers.includes("ON_CHANGE")) {
2283
- const validations = new Validation({
2284
- FIELD_CONFIG: field,
2285
- FORM_FIELDS: this.formFields,
2286
- FORM_DATA: this.formData,
2287
- PREVIOUS_FORM_DATA: this.previousFormData,
2288
- ALL_FORMS_DATA: this.allFormsData
2289
- }, this.takeAction.bind(this));
2290
- (() => __awaiter(this, void 0, void 0, function* () {
2291
- yield validations.validate(field.validation);
2292
- }))();
2293
- }
2294
- if (field.isFormElement &&
2295
- checkObjectKeyExists(field, "connectedElements")) {
2296
- this.handleConnectedElements({
2297
- key: field.key,
2298
- value: this.formGroup.controls[field.key].value
2299
- }, "ON_CHANGE");
2300
- }
2301
- }
2302
- handleOnClickResetFormFields(e, field) {
2303
- return __awaiter(this, void 0, void 0, function* () {
2304
- for (let f of field.reset.fields) {
2305
- for (let action of f.actions) {
2306
- const resetField = getFormFieldByKey(this.formFields, action.props.fieldKey);
2307
- const actions = new Action(action, {}, {
2308
- FIELD_CONFIG: resetField,
2309
- FORM_FIELDS: this.formFields,
2310
- FORM_DATA: this.formData,
2311
- PREVIOUS_FORM_DATA: this.previousFormData,
2312
- ALL_FORMS_DATA: this.allFormsData
2313
- }, this.takeAction.bind(this));
2314
- yield actions.execute();
1983
+ return field;
1984
+ };
1985
+ const updateFieldDefaultValueConfig = (field) => {
1986
+ if (field.isFormElement) {
1987
+ if (checkObjectKeyExists(field, "defaultValue")) {
1988
+ return field;
2315
1989
  }
2316
- }
2317
- });
2318
- }
2319
- handleOnClickApiCall(e) {
2320
- var _a, _b, _c, _d, _e, _f, _g;
2321
- return __awaiter(this, void 0, void 0, function* () {
2322
- let field = getFormFieldByKey(this.formFields, e.key);
2323
- if (field.type === "api-call") {
2324
- // set button status to loading
2325
- field["api"]["status"]["value"] = EApiStatusType.LOADING;
2326
- field["showLoader"] = true;
2327
- this.viewFormsButton["disabled"] = true;
2328
- this.viewFormsButton["showLoader"] = true;
2329
- this.saveFormButton["disabled"] = true;
2330
- this.saveFormButton["showLoader"] = true;
2331
- const apis = new Apis({
2332
- FIELD_CONFIG: field,
2333
- FORM_FIELDS: this.formFields,
2334
- FORM_DATA: this.formData,
2335
- PREVIOUS_FORM_DATA: this.previousFormData,
2336
- ALL_FORMS_DATA: this.allFormsData
2337
- }, this.takeAction.bind(this));
2338
- field = yield apis.setRequestHeaders();
2339
- field = yield apis.validateRequestHeaders();
2340
- field = yield apis.setRequestBody();
2341
- field = yield apis.validateRequestBody();
2342
- if (field.api.request.body.validation.is_valid) {
2343
- // Call API Here
2344
- let apiCallResponse = undefined;
2345
- if (field.api.request.url.hasOwnProperty("type") &&
2346
- field.api.request.url.type === "MOCK") {
2347
- apiCallResponse = field.api.request.url.data;
2348
- }
2349
- else {
2350
- const url = field.api.request.url;
2351
- const method = (_b = (_a = field.api.request) === null || _a === void 0 ? void 0 : _a.method) !== null && _b !== void 0 ? _b : "POST";
2352
- const headers = Object.assign({ "Content-Type": "application/json" }, (((_d = (_c = field.api.request) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d.value) || {}));
2353
- const body = (_g = (_f = (_e = field.api.request) === null || _e === void 0 ? void 0 : _e.body) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : null;
2354
- const response = yield fetch(url, {
2355
- method: method,
2356
- headers: Object.assign({}, headers),
2357
- body: JSON.stringify(body)
2358
- });
2359
- apiCallResponse = yield response.json();
2360
- }
2361
- this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: apiCallResponse });
2362
- this.formGroup.patchValue({
2363
- [field.key]: apiCallResponse
2364
- }, { emitEvent: false });
2365
- const apis = new Apis({
2366
- FIELD_CONFIG: field,
2367
- FORM_FIELDS: this.formFields,
2368
- FORM_DATA: this.formData,
2369
- PREVIOUS_FORM_DATA: this.previousFormData,
2370
- ALL_FORMS_DATA: this.allFormsData
2371
- }, this.takeAction.bind(this));
2372
- (() => __awaiter(this, void 0, void 0, function* () {
2373
- field = yield apis.validateResponse();
2374
- }))();
1990
+ else if (checkObjectKeyExists(field, "default")) {
1991
+ return field;
2375
1992
  }
2376
1993
  else {
2377
- // Request Body Validation Failed
2378
- // Highlight Error in UI to User to Retry After Sometime.
2379
- // Take Action based on Validation
2380
- setTimeout(() => {
2381
- field["api"]["status"]["value"] = EApiStatusType.FAILED;
2382
- field["showLoader"] = false;
2383
- }, 500);
2384
- }
2385
- this.viewFormsButton["disabled"] = false;
2386
- this.viewFormsButton["showLoader"] = false;
2387
- this.saveFormButton["disabled"] = false;
2388
- this.saveFormButton["showLoader"] = false;
2389
- }
2390
- });
2391
- }
2392
- handleOnClickViewForms(e) {
2393
- this.onClickViewForms.emit({
2394
- clicked: true
2395
- });
2396
- }
2397
- handleOnClickSaveForm(e) {
2398
- return __awaiter(this, void 0, void 0, function* () {
2399
- let formData = this.formGroup.getRawValue();
2400
- for (let field of this.formFields) {
2401
- if (field.isFormElement) {
2402
- if (field.hidden) {
2403
- delete formData[field.key];
1994
+ if (checkObjectKeyExists(field, "defaultVal")) {
1995
+ // Currently below line is commented because it caused issues in setting Default Value.
1996
+ // field["defaultValue"] = field["defaultVal"];
1997
+ // delete field["defaultVal"];
1998
+ }
1999
+ // TODO: Condition for all_forms_data is not considered yet.
2000
+ if (field.autoPopulateFromSummaryData) {
2001
+ field["defaultValue"] = {
2002
+ is_found: false,
2003
+ value: "",
2004
+ sources: [
2005
+ {
2006
+ source: "summary_data",
2007
+ summary_data: {
2008
+ path: `$.${field.key}`,
2009
+ validation: {
2010
+ rules: [
2011
+ {
2012
+ key: "1",
2013
+ type: "is_not_empty",
2014
+ is_not_empty: {
2015
+ value: true
2016
+ }
2017
+ }
2018
+ ],
2019
+ actions: [
2020
+ {
2021
+ type: "set_default_value_found",
2022
+ condition: "1",
2023
+ set_default_value_found: {
2024
+ value: true
2025
+ }
2026
+ },
2027
+ {
2028
+ type: "enable_field",
2029
+ condition: "1 OR NOT(1)",
2030
+ enable_field: { value: true }
2031
+ }
2032
+ ]
2033
+ }
2034
+ }
2035
+ }
2036
+ ]
2037
+ };
2038
+ }
2039
+ else if (checkObjectKeyExists(field, "autofill")) {
2040
+ if (checkObjectKeyExists(field.autofill, "type")) {
2041
+ if (field.autofill.type === "storage") {
2042
+ field["defaultValue"] = {
2043
+ is_found: false,
2044
+ value: "",
2045
+ sources: [
2046
+ {
2047
+ source: "browser_storage",
2048
+ browser_storage: {
2049
+ path: `$.${field.key}`,
2050
+ validation: {
2051
+ rules: [
2052
+ {
2053
+ key: "1",
2054
+ type: "is_not_empty",
2055
+ is_not_empty: {
2056
+ value: true
2057
+ }
2058
+ }
2059
+ ],
2060
+ actions: [
2061
+ {
2062
+ type: "set_default_value_found",
2063
+ condition: "1",
2064
+ set_default_value_found: {
2065
+ value: true
2066
+ }
2067
+ },
2068
+ {
2069
+ type: "enable_field",
2070
+ condition: "1 OR NOT(1)",
2071
+ enable_field: { value: true }
2072
+ }
2073
+ ]
2074
+ }
2075
+ }
2076
+ }
2077
+ ]
2078
+ };
2079
+ }
2080
+ else if (field.autofill.type === "config") {
2081
+ field["defaultValue"] = {
2082
+ is_found: false,
2083
+ value: "",
2084
+ sources: [
2085
+ {
2086
+ source: "field_config",
2087
+ field_config: {
2088
+ path: `$.${field.key}`,
2089
+ validation: {
2090
+ rules: [
2091
+ {
2092
+ key: "1",
2093
+ type: "is_not_empty",
2094
+ is_not_empty: {
2095
+ value: true
2096
+ }
2097
+ }
2098
+ ],
2099
+ actions: [
2100
+ {
2101
+ type: "set_default_value_found",
2102
+ condition: "1",
2103
+ set_default_value_found: {
2104
+ value: true
2105
+ }
2106
+ },
2107
+ {
2108
+ type: "enable_field",
2109
+ condition: "1 OR NOT(1)",
2110
+ enable_field: { value: true }
2111
+ }
2112
+ ]
2113
+ }
2114
+ }
2115
+ }
2116
+ ]
2117
+ };
2118
+ }
2119
+ }
2404
2120
  }
2405
2121
  else {
2406
- formData[field.key] = convertFormFieldValueToStandardFormat(field, formData[field.key]);
2122
+ field["defaultValue"] = {
2123
+ is_found: false,
2124
+ value: "",
2125
+ sources: [
2126
+ {
2127
+ source: "form_data",
2128
+ form_data: {
2129
+ path: `$.${field.key}`,
2130
+ validation: {
2131
+ rules: [
2132
+ {
2133
+ key: "1",
2134
+ type: "is_not_empty",
2135
+ is_not_empty: {
2136
+ value: true
2137
+ }
2138
+ }
2139
+ ],
2140
+ actions: [
2141
+ {
2142
+ type: "set_default_value_found",
2143
+ condition: "1",
2144
+ set_default_value_found: {
2145
+ value: true
2146
+ }
2147
+ },
2148
+ {
2149
+ type: "enable_field",
2150
+ condition: "1 OR NOT(1)",
2151
+ enable_field: { value: true }
2152
+ }
2153
+ ]
2154
+ }
2155
+ }
2156
+ }
2157
+ ]
2158
+ };
2407
2159
  }
2408
2160
  }
2161
+ delete field["defaultVal"];
2409
2162
  }
2410
- if (this.formGroup.invalid) {
2411
- const controls = new FormValidation().getFormFieldsInvalidControls(this.formGroup);
2412
- let firstFieldWithError = "";
2413
- for (let control of controls) {
2414
- if (control.invalid && isEmptyValue(firstFieldWithError)) {
2415
- firstFieldWithError = control.key;
2416
- }
2417
- this.formFields = showFormFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
2418
- }
2419
- this.toggleErrorNotification(true);
2420
- setTimeout(() => {
2421
- this.toggleErrorNotification(false);
2422
- }, 3000);
2423
- return;
2163
+ return field;
2164
+ };
2165
+ const updateFieldMessages = (field) => {
2166
+ if (field.isFormElement) {
2167
+ field = this.setMissingFieldKeyValue(field, "messages", []);
2424
2168
  }
2425
- for (let field of this.formFields) {
2426
- if (field.isFormElement &&
2427
- field.validation.triggers.includes("ON_SAVE")) {
2428
- const validations = new Validation({
2429
- FIELD_CONFIG: field,
2430
- FORM_FIELDS: this.formFields,
2431
- FORM_DATA: this.formData,
2432
- PREVIOUS_FORM_DATA: this.previousFormData,
2433
- ALL_FORMS_DATA: this.allFormsData
2434
- }, this.takeAction.bind(this));
2435
- yield validations.validate(field.validation);
2436
- if (!field.validation.is_valid) {
2437
- this.toggleErrorNotification(true);
2438
- setTimeout(() => {
2439
- this.toggleErrorNotification(false);
2440
- }, 3000);
2441
- return;
2442
- }
2169
+ return field;
2170
+ };
2171
+ const updateFieldResetButton = (field) => {
2172
+ if (field.isFormElement) {
2173
+ if (checkObjectKeyExists(field, "action") &&
2174
+ field.action === "reset" &&
2175
+ checkObjectKeyExists(field, "fields")) {
2176
+ field = this.setFieldKeyValue(field, "reset", {
2177
+ fields: field.fields
2178
+ });
2443
2179
  }
2444
2180
  }
2445
- Object.keys(formData).map((key) => {
2446
- if (isEmptyValue(formData[key])) {
2447
- formData[key] = "";
2181
+ return field;
2182
+ };
2183
+ const setFormFields = (formConfig, fields) => {
2184
+ if (checkObjectKeyExists(formConfig, "multiForm")) {
2185
+ formConfig.multiForm["fields"] = fields;
2186
+ }
2187
+ else {
2188
+ formConfig["fields"] = fields;
2189
+ }
2190
+ return formConfig;
2191
+ };
2192
+ const setFormFieldGroups = (formConfig, groups) => {
2193
+ formConfig["fieldGroups"] = groups;
2194
+ return formConfig;
2195
+ };
2196
+ const updateFormFieldGroups = (fieldGroups, field) => {
2197
+ if (checkObjectKeyExists(field, "groupKey")) {
2198
+ if (checkObjectKeyExists(fieldGroups, field.groupKey)) {
2199
+ fieldGroups[field.groupKey].push(field.key);
2200
+ }
2201
+ else {
2202
+ fieldGroups[field.groupKey] = [field.key];
2448
2203
  }
2449
- });
2450
- this.onClickSaveForm.emit({ formConfig: this.formConfig, data: formData });
2451
- });
2452
- }
2453
- toggleErrorNotification(show) {
2454
- this.showErrorNotification = show;
2455
- }
2456
- // Component Helpers
2457
- fieldHide(fieldKey) {
2458
- let field = getFormFieldByKey(this.formFields, fieldKey);
2459
- let fieldIndex = this.formFields.findIndex((_) => {
2460
- return field.key === _.key;
2461
- });
2462
- this.formFields[fieldIndex]["hidden"] = true;
2463
- this.formGroup.updateValueAndValidity();
2464
- }
2465
- fieldGroupHide(fieldGroup) {
2466
- for (let fieldKey of this.fieldGroups[fieldGroup]) {
2467
- this.fieldHide(fieldKey);
2468
- }
2469
- }
2470
- fieldShow(fieldKey) {
2471
- let field = getFormFieldByKey(this.formFields, fieldKey);
2472
- let fieldIndex = this.formFields.findIndex((_) => {
2473
- return field.key === _.key;
2474
- });
2475
- this.formFields[fieldIndex]["hidden"] = false;
2476
- this.formGroup.updateValueAndValidity();
2477
- }
2478
- fieldGroupShow(fieldGroup) {
2479
- for (let fieldKey of this.fieldGroups[fieldGroup]) {
2480
- this.fieldShow(fieldKey);
2481
- }
2482
- }
2483
- fieldDisable(fieldKey) {
2484
- let field = getFormFieldByKey(this.formFields, fieldKey);
2485
- let fieldIndex = this.formFields.findIndex((_) => {
2486
- return field.key === _.key;
2487
- });
2488
- if (field.isFormElement) {
2489
- this.formFields[fieldIndex]["disabled"] = true;
2490
- if (isNotEmptyValue(this.formGroup.controls)) {
2491
- this.formGroup.controls[field.key].disable({
2492
- emitEvent: false
2493
- });
2494
2204
  }
2495
- this.formGroup.updateValueAndValidity();
2205
+ return fieldGroups;
2206
+ };
2207
+ let fields = this.getFormFields(formConfig);
2208
+ let fieldGroups = {};
2209
+ for (let field of fields) {
2210
+ field = updateOnFieldType(field);
2211
+ field = formatFieldKeys(field);
2212
+ fieldGroups = updateFormFieldGroups(fieldGroups, field);
2213
+ field = updateFieldDefaultValueConfig(field);
2214
+ field = updateFieldValidatorConfig(field);
2215
+ field = updateFieldResetButton(field);
2216
+ field = updateFieldMessages(field);
2496
2217
  }
2218
+ formConfig = setFormFieldGroups(formConfig, fieldGroups);
2219
+ formConfig = setFormFields(formConfig, fields);
2220
+ return formConfig;
2497
2221
  }
2498
- fieldGroupDisable(fieldGroup) {
2499
- for (let fieldKey of this.fieldGroups[fieldGroup]) {
2500
- this.fieldDisable(fieldKey);
2501
- }
2222
+ }
2223
+ __decorate([
2224
+ logMethod
2225
+ ], Converter.prototype, "updateFormConfigMiscellaneous", null);
2226
+ __decorate([
2227
+ logMethod
2228
+ ], Converter.prototype, "updateFormConfigProperties", null);
2229
+ __decorate([
2230
+ logMethod
2231
+ ], Converter.prototype, "convertFormConfig", null);
2232
+
2233
+ var EActionKey;
2234
+ (function (EActionKey) {
2235
+ EActionKey["SET_VALUE"] = "SET_VALUE";
2236
+ EActionKey["SET_FIELD_DEFAULT_VALUE"] = "SET_FIELD_DEFAULT_VALUE";
2237
+ EActionKey["FIELD_MESSAGE_SHOW"] = "FIELD_MESSAGE_SHOW";
2238
+ EActionKey["FIELD_MESSAGES_HIDE"] = "FIELD_MESSAGES_HIDE";
2239
+ EActionKey["FIELD_ERROR_SHOW"] = "FIELD_ERROR_SHOW";
2240
+ EActionKey["FIELD_ERROR_HIDE"] = "FIELD_ERROR_HIDE";
2241
+ EActionKey["FIELD_SHOW"] = "FIELD_SHOW";
2242
+ EActionKey["FIELD_HIDE"] = "FIELD_HIDE";
2243
+ EActionKey["FIELD_ENABLE"] = "FIELD_ENABLE";
2244
+ EActionKey["FIELD_DISABLE"] = "FIELD_DISABLE";
2245
+ EActionKey["FIELD_RESET"] = "FIELD_RESET";
2246
+ EActionKey["HANDLE_CONNECTED_ELEMENTS"] = "HANDLE_CONNECTED_ELEMENTS";
2247
+ EActionKey["CUSTOM"] = "CUSTOM";
2248
+ EActionKey["FIELD_GROUP_SHOW"] = "FIELD_GROUP_SHOW";
2249
+ EActionKey["FIELD_GROUP_HIDE"] = "FIELD_GROUP_HIDE";
2250
+ EActionKey["FIELD_GROUP_ENABLE"] = "FIELD_GROUP_ENABLE";
2251
+ EActionKey["FIELD_GROUP_DISABLE"] = "FIELD_GROUP_DISABLE";
2252
+ EActionKey["SET_DROPDOWN_OPTIONS"] = "SET_DROPDOWN_OPTIONS";
2253
+ })(EActionKey || (EActionKey = {}));
2254
+
2255
+ var EApiStatusType;
2256
+ (function (EApiStatusType) {
2257
+ EApiStatusType["DEFAULT"] = "default";
2258
+ EApiStatusType["LOADING"] = "loading";
2259
+ EApiStatusType["SUCCESS"] = "success";
2260
+ EApiStatusType["FAILED"] = "failed";
2261
+ })(EApiStatusType || (EApiStatusType = {}));
2262
+
2263
+ var EMessageType;
2264
+ (function (EMessageType) {
2265
+ EMessageType["DEFAULT"] = "default";
2266
+ EMessageType["ERROR"] = "error";
2267
+ EMessageType["SUCCESS"] = "success";
2268
+ EMessageType["WARNING"] = "warning";
2269
+ })(EMessageType || (EMessageType = {}));
2270
+
2271
+ class Defaults {
2272
+ constructor(field, formFields, allFormsData, formData, previousFormData, takeAction) {
2273
+ this._field = field;
2274
+ this._formFields = formFields;
2275
+ this._allFormsData = allFormsData;
2276
+ this._formData = formData;
2277
+ this._previousFormData = previousFormData;
2278
+ this._takeAction = takeAction;
2502
2279
  }
2503
- fieldEnable(fieldKey) {
2504
- let field = getFormFieldByKey(this.formFields, fieldKey);
2505
- let fieldIndex = this.formFields.findIndex((_) => {
2506
- return field.key === _.key;
2507
- });
2508
- if (field.isFormElement) {
2509
- this.formFields[fieldIndex]["disabled"] = false;
2510
- if (isNotEmptyValue(this.formGroup.controls)) {
2511
- this.formGroup.controls[field.key].enable({
2512
- emitEvent: false
2280
+ getFormFieldValue() {
2281
+ return __awaiter(this, void 0, void 0, function* () {
2282
+ let defaultValue;
2283
+ const sources = this._field.default.value.sources;
2284
+ let sourceIndex = 0;
2285
+ for (let source of sources) {
2286
+ const sources = new Source({
2287
+ FIELD_CONFIG: this._field,
2288
+ FORM_FIELDS: this._formFields,
2289
+ FORM_DATA: this._formData,
2290
+ PREVIOUS_FORM_DATA: this._previousFormData,
2291
+ ALL_FORMS_DATA: this._allFormsData
2513
2292
  });
2293
+ const value = sources.getValueFromSource(source);
2294
+ // Set the Value of current source.
2295
+ this._field = setValueToObjectPath(this._field, `default.value.sources.[${sourceIndex}].value`, value);
2296
+ const validation = source.validation;
2297
+ const triggers = validation.triggers;
2298
+ const rules = validation.rules;
2299
+ const actions = validation.actions;
2300
+ const rulesMapping = new Rule(rules, {
2301
+ FIELD_CONFIG: this._field,
2302
+ FORM_FIELDS: this._formFields,
2303
+ FORM_DATA: this._formData,
2304
+ PREVIOUS_FORM_DATA: this._previousFormData,
2305
+ ALL_FORMS_DATA: this._allFormsData
2306
+ }).mapping();
2307
+ for (let action of actions) {
2308
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
2309
+ if (conditionEvaluation) {
2310
+ const actions = new Action(action, rulesMapping, {
2311
+ FIELD_CONFIG: this._field,
2312
+ FORM_FIELDS: this._formFields,
2313
+ FORM_DATA: this._formData,
2314
+ PREVIOUS_FORM_DATA: this._previousFormData,
2315
+ ALL_FORMS_DATA: this._allFormsData
2316
+ }, this._takeAction);
2317
+ yield actions.execute();
2318
+ }
2319
+ }
2320
+ sourceIndex++;
2514
2321
  }
2515
- this.formGroup.updateValueAndValidity();
2516
- }
2322
+ defaultValue = this._field.default.value.value;
2323
+ if (isEmptyValue(defaultValue)) {
2324
+ defaultValue = convertFormFieldEmptyValueToKwikUIFormat(this._field);
2325
+ }
2326
+ return defaultValue;
2327
+ });
2517
2328
  }
2518
- fieldGroupEnable(fieldGroup) {
2519
- for (let fieldKey of this.fieldGroups[fieldGroup]) {
2520
- this.fieldEnable(fieldKey);
2521
- }
2329
+ getFormFieldOptions() {
2330
+ return __awaiter(this, void 0, void 0, function* () {
2331
+ const optionsConfig = this._field.default.options;
2332
+ const rules = optionsConfig.rules;
2333
+ const actions = optionsConfig.actions;
2334
+ const rulesMapping = new Rule(rules, {
2335
+ FIELD_CONFIG: this._field,
2336
+ FORM_FIELDS: this._formFields,
2337
+ FORM_DATA: this._formData,
2338
+ PREVIOUS_FORM_DATA: this._previousFormData,
2339
+ ALL_FORMS_DATA: this._allFormsData
2340
+ }).mapping();
2341
+ for (let action of actions) {
2342
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
2343
+ if (conditionEvaluation) {
2344
+ const actions = new Action(action, rulesMapping, {
2345
+ FIELD_CONFIG: this._field,
2346
+ FORM_FIELDS: this._formFields,
2347
+ FORM_DATA: this._formData,
2348
+ PREVIOUS_FORM_DATA: this._previousFormData,
2349
+ ALL_FORMS_DATA: this._allFormsData
2350
+ }, this._takeAction);
2351
+ yield actions.execute();
2352
+ }
2353
+ }
2354
+ });
2522
2355
  }
2523
- fieldReset(fieldKey) {
2524
- // Find the field and its index in the formFields array
2525
- let field = getFormFieldByKey(this.formFields, fieldKey);
2526
- let fieldIndex = getFormFieldIndexByKey(this.formFields, fieldKey);
2527
- // Delete the field from the formData object
2528
- delete this.formData[fieldKey];
2529
- // Reset the value of the field in the formGroup
2530
- this.formGroup.controls[field.key].reset(convertFormFieldEmptyValueToKwikUIFormat(field), {
2531
- emitEvent: false
2532
- });
2533
- // Reset the messages and errors for the field
2534
- field = removeFormFieldMessage(field, {
2535
- type: EMessageType.WARNING,
2536
- message: ""
2537
- });
2538
- field = removeFormFieldMessage(field, {
2539
- type: EMessageType.SUCCESS,
2540
- message: ""
2541
- });
2542
- this.fieldErrorHide(fieldKey, {
2543
- type: EMessageType.ERROR,
2544
- message: ""
2545
- });
2546
- // Reset the value of the field in the formFields array
2547
- switch (field.type) {
2548
- case "api-call":
2549
- const fieldApiCall = field;
2550
- fieldApiCall.api.status.value = EApiStatusType.DEFAULT;
2551
- this.formFields[fieldIndex] = fieldApiCall;
2552
- break;
2553
- default:
2554
- field.focus = false;
2555
- field.invalid = false;
2556
- this.formFields[fieldIndex] = field;
2557
- break;
2356
+ }
2357
+ __decorate([
2358
+ logMethod
2359
+ ], Defaults.prototype, "getFormFieldValue", null);
2360
+ __decorate([
2361
+ logMethod
2362
+ ], Defaults.prototype, "getFormFieldOptions", null);
2363
+
2364
+ class FormValidation {
2365
+ constructor() { }
2366
+ getFormFieldValidators(field) {
2367
+ let validators = [];
2368
+ if (checkObjectKeyExists(field, "validators") &&
2369
+ checkObjectKeyExists(field.validators, "min") &&
2370
+ isNotEmptyValue(field.validators.min)) {
2371
+ validators.push(Validators.min(field.validators.min));
2558
2372
  }
2559
- }
2560
- fieldErrorShow(fieldKey, message) {
2561
- let field = getFormFieldByKey(this.formFields, fieldKey);
2562
- let fieldIndex = this.formFields.findIndex((_) => {
2563
- return field.key === _.key;
2564
- });
2565
- field = highlightFormFieldError(field, true);
2566
- field = appendFormFieldMessage(field, message);
2567
- this.formFields[fieldIndex] = field;
2568
- }
2569
- fieldErrorHide(fieldKey, message) {
2570
- let field = getFormFieldByKey(this.formFields, fieldKey);
2571
- let fieldIndex = this.formFields.findIndex((_) => {
2572
- return field.key === _.key;
2573
- });
2574
- field = highlightFormFieldError(field, false);
2575
- field = removeFormFieldMessage(field, message);
2576
- this.formFields[fieldIndex] = field;
2577
- }
2578
- fieldMessageShow(fieldKey, message) {
2579
- let field = getFormFieldByKey(this.formFields, fieldKey);
2580
- let fieldIndex = this.formFields.findIndex((_) => {
2581
- return field.key === _.key;
2582
- });
2583
- field = appendFormFieldMessage(field, message);
2584
- this.formFields[fieldIndex] = field;
2585
- }
2586
- fieldMessageHide(fieldKey, message) {
2587
- let field = getFormFieldByKey(this.formFields, fieldKey);
2588
- let fieldIndex = this.formFields.findIndex((_) => {
2589
- return field.key === _.key;
2590
- });
2591
- field = removeFormFieldMessage(field, message);
2592
- this.formFields[fieldIndex] = field;
2593
- }
2594
- setObjectValue(field, path, value) { }
2595
- patchFieldControlValue(key, value) {
2596
- this.formGroup.patchValue({
2597
- [key]: value
2598
- }, { emitEvent: false });
2599
- }
2600
- patchFormGroup(formData) {
2601
- if (isUndefined(this.formGroup) || isUndefined(formData)) {
2602
- throw new Error(`formGroup or formData is 'undefined'.`);
2373
+ if (checkObjectKeyExists(field, "validators") &&
2374
+ checkObjectKeyExists(field.validators, "max") &&
2375
+ isNotEmptyValue(field.validators.max)) {
2376
+ validators.push(Validators.max(field.validators.max));
2603
2377
  }
2604
- else {
2605
- this.formGroup.patchValue(formData, { emitEvent: false });
2378
+ if ((checkObjectKeyExists(field, "required") && field.required) ||
2379
+ (checkObjectKeyExists(field, "validators") &&
2380
+ checkObjectKeyExists(field.validators, "required") &&
2381
+ field.validators.required)) {
2382
+ validators.push(Validators.required);
2606
2383
  }
2384
+ if (checkObjectKeyExists(field, "validators") &&
2385
+ checkObjectKeyExists(field.validators, "minLength") &&
2386
+ isNotEmptyValue(field.validators.minLength)) {
2387
+ validators.push(Validators.minLength(field.validators.minLength));
2388
+ }
2389
+ if (checkObjectKeyExists(field, "validators") &&
2390
+ checkObjectKeyExists(field.validators, "maxLength") &&
2391
+ isNotEmptyValue(field.validators.maxLength)) {
2392
+ validators.push(Validators.maxLength(field.validators.maxLength));
2393
+ }
2394
+ if (checkObjectKeyExists(field, "validators") &&
2395
+ checkObjectKeyExists(field.validators, "pattern") &&
2396
+ isNotEmptyValue(field.validators.pattern)) {
2397
+ if (checkObjectKeyExists(field.validators.pattern, "key")) {
2398
+ if (field.validators.pattern.key === "CUSTOM") {
2399
+ validators.push(Validators.pattern(field.validators.pattern.pattern));
2400
+ }
2401
+ else {
2402
+ validators.push(Validators.pattern(PATTERNS[field.validators.pattern.key]));
2403
+ }
2404
+ }
2405
+ }
2406
+ return validators;
2607
2407
  }
2608
- isFieldValid(fieldKey) {
2609
- return this.formGroup.controls[fieldKey].valid;
2610
- }
2611
- isFieldEnabled(fieldKey) {
2612
- return this.formGroup.controls[fieldKey].enabled;
2408
+ getFormFieldsValidationErrors(formGroup) {
2409
+ let errors = [];
2410
+ for (const key in formGroup.controls) {
2411
+ const controlErrors = formGroup.controls[key].errors;
2412
+ if (controlErrors !== null && controlErrors !== undefined) {
2413
+ Object.keys(controlErrors).forEach((keyError) => {
2414
+ errors.push({
2415
+ name: keyError,
2416
+ value: controlErrors[keyError]
2417
+ });
2418
+ });
2419
+ }
2420
+ }
2421
+ return errors;
2613
2422
  }
2614
- getFormGroupRawValues() {
2615
- return this.formGroup.getRawValue();
2423
+ getFormFieldsInvalidControls(formToInvestigate) {
2424
+ var controls = [];
2425
+ let recursiveFunc = (form) => {
2426
+ Object.keys(form.controls).forEach((field) => {
2427
+ const control = form.get(field);
2428
+ if (control.invalid) {
2429
+ controls.push({
2430
+ key: field,
2431
+ invalid: true
2432
+ });
2433
+ }
2434
+ else {
2435
+ controls.push({
2436
+ key: field,
2437
+ invalid: false
2438
+ });
2439
+ }
2440
+ if (control instanceof FormGroup) {
2441
+ recursiveFunc(control);
2442
+ }
2443
+ else if (control instanceof FormArray) {
2444
+ recursiveFunc(control);
2445
+ }
2446
+ });
2447
+ };
2448
+ recursiveFunc(formToInvestigate);
2449
+ return controls;
2616
2450
  }
2617
- takeActionOnFieldGroup(action, object) {
2451
+ }
2452
+ __decorate([
2453
+ logMethod
2454
+ ], FormValidation.prototype, "getFormFieldValidators", null);
2455
+ __decorate([
2456
+ logMethod
2457
+ ], FormValidation.prototype, "getFormFieldsValidationErrors", null);
2458
+ __decorate([
2459
+ logMethod
2460
+ ], FormValidation.prototype, "getFormFieldsInvalidControls", null);
2461
+
2462
+ class KwikIDFormViewService {
2463
+ constructor() { }
2464
+ // 'init' stage of the form
2465
+ createFormGroup(fields, formData, previousFormData, allFormsData, takeAction) {
2618
2466
  return __awaiter(this, void 0, void 0, function* () {
2619
- switch (action.key) {
2620
- case EActionKey.FIELD_GROUP_HIDE:
2621
- this.fieldGroupHide(action.props.groupKey);
2622
- break;
2623
- case EActionKey.FIELD_GROUP_SHOW:
2624
- this.fieldGroupShow(action.props.groupKey);
2625
- break;
2626
- case EActionKey.FIELD_GROUP_ENABLE:
2627
- this.fieldGroupEnable(action.props.groupKey);
2628
- break;
2629
- case EActionKey.FIELD_GROUP_DISABLE:
2630
- this.fieldGroupDisable(action.props.groupKey);
2631
- break;
2632
- default:
2633
- break;
2467
+ let formGroup = new FormGroup({});
2468
+ for (let field of fields) {
2469
+ if (field.isFormElement) {
2470
+ const defaults = new Defaults(field, fields, allFormsData, formData, previousFormData, takeAction);
2471
+ let value = yield defaults.getFormFieldValue();
2472
+ if (checkObjectKeyExists(field, "default")) {
2473
+ if (checkObjectKeyExists(field.default, "options")) {
2474
+ if (field.default.options.triggers.includes("ON_INIT")) {
2475
+ yield defaults.getFormFieldOptions();
2476
+ }
2477
+ }
2478
+ }
2479
+ value = convertFormFieldValueToKwikUIFormat(field, value);
2480
+ const validators = new FormValidation().getFormFieldValidators(field);
2481
+ formGroup.addControl(field.key, new FormControl({ value: value, disabled: field.disabled }, { validators: validators }));
2482
+ }
2634
2483
  }
2484
+ return formGroup;
2635
2485
  });
2636
2486
  }
2637
- takeAction(action, object) {
2487
+ }
2488
+ __decorate([
2489
+ logMethod
2490
+ ], KwikIDFormViewService.prototype, "createFormGroup", null);
2491
+
2492
+ class Apis {
2493
+ constructor(object, takeAction) {
2494
+ this._object = object;
2495
+ this._takeAction = takeAction;
2496
+ this._api = this._object.FIELD_CONFIG.api;
2497
+ this._request = this._object.FIELD_CONFIG.api.request;
2498
+ this._response = this._object.FIELD_CONFIG.api.response;
2499
+ this._status = this._object.FIELD_CONFIG.api.status;
2500
+ }
2501
+ get object() {
2502
+ return this._object;
2503
+ }
2504
+ set object(value) {
2505
+ this._object = value;
2506
+ }
2507
+ setRequestBody() {
2508
+ var _a, _b, _c, _d;
2638
2509
  return __awaiter(this, void 0, void 0, function* () {
2639
- switch (action.key) {
2640
- case EActionKey.FIELD_HIDE:
2641
- this.fieldHide(action.props.fieldKey);
2642
- break;
2643
- case EActionKey.FIELD_SHOW:
2644
- this.fieldShow(action.props.fieldKey);
2645
- break;
2646
- case EActionKey.FIELD_DISABLE:
2647
- this.fieldDisable(action.props.fieldKey);
2648
- break;
2649
- case EActionKey.FIELD_ENABLE:
2650
- this.fieldEnable(action.props.fieldKey);
2651
- break;
2652
- case EActionKey.FIELD_RESET:
2653
- this.fieldReset(action.props.fieldKey);
2654
- break;
2655
- case EActionKey.FIELD_ERROR_SHOW:
2656
- this.fieldErrorShow(action.props.fieldKey, action.props.message);
2657
- break;
2658
- case EActionKey.FIELD_ERROR_HIDE:
2659
- this.fieldErrorHide(action.props.fieldKey, action.props.message);
2660
- break;
2661
- case EActionKey.FIELD_MESSAGE_SHOW:
2662
- this.fieldMessageShow(action.props.fieldKey, action.props.message);
2663
- break;
2664
- case EActionKey.FIELD_MESSAGES_HIDE:
2665
- this.fieldMessageHide(action.props.fieldKey, action.props.message);
2666
- break;
2667
- case EActionKey.SET_VALUE:
2668
- const setValue_Source = new Source(object);
2669
- const sourceValue = yield setValue_Source.getValueFromSource(action.props.value.source);
2670
- setValue_Source.setValueToSource(action.props.value.destination, sourceValue);
2671
- object.FIELD_CONFIG = setValue_Source.object.FIELD_CONFIG;
2672
- this.formData = setValue_Source.object.FORM_DATA;
2673
- this.patchFormGroup(this.formData);
2674
- this.allFormsData = setValue_Source.object.ALL_FORMS_DATA;
2675
- this.previousFormData = setValue_Source.object.PREVIOUS_FORM_DATA;
2676
- break;
2677
- case EActionKey.SET_FIELD_DEFAULT_VALUE:
2678
- const setDefaultValue_Source = new Source(object);
2679
- const sourceDefaultValue = yield setDefaultValue_Source.getValueFromSource(action.props.value.source);
2680
- const destinationDefaultValue_FieldConfig_Config = {
2681
- key: ESourceKey.OBJECT,
2682
- props: {
2683
- object: {
2684
- key: "FIELD_CONFIG",
2685
- path: "default.value.value"
2686
- }
2687
- }
2688
- };
2689
- setDefaultValue_Source.setValueToSource(destinationDefaultValue_FieldConfig_Config, sourceDefaultValue);
2690
- const destinationDefaultValue_FormData_Config__Props__Object__Path = String(`${action.props.fieldKey}`);
2691
- const destinationDefaultValue_FormData_Config = {
2692
- key: ESourceKey.OBJECT,
2693
- props: {
2694
- object: {
2695
- key: "FORM_DATA",
2696
- path: String(action.props.fieldKey)
2697
- }
2510
+ let params = this._request.body.params;
2511
+ let paramIndex = 0;
2512
+ for (let param of params) {
2513
+ let sources = param.sources;
2514
+ let sourceIndex = 0;
2515
+ for (let source of sources) {
2516
+ const sources = new Source(this._object);
2517
+ const value = sources.getValueFromSource(source);
2518
+ // Set the Value of current source.
2519
+ this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
2520
+ const validation = source.validation;
2521
+ const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
2522
+ const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
2523
+ const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
2524
+ const rulesMapping = new Rule(rules, this._object).mapping();
2525
+ for (let action of actions) {
2526
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
2527
+ if (conditionEvaluation) {
2528
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
2529
+ yield actions.execute();
2698
2530
  }
2699
- };
2700
- setDefaultValue_Source.setValueToSource(destinationDefaultValue_FormData_Config, sourceDefaultValue);
2701
- object.FIELD_CONFIG = setDefaultValue_Source.object.FIELD_CONFIG;
2702
- this.formData = setDefaultValue_Source.object.FORM_DATA;
2703
- this.patchFormGroup(this.formData);
2704
- this.allFormsData = setDefaultValue_Source.object.ALL_FORMS_DATA;
2705
- this.previousFormData =
2706
- setDefaultValue_Source.object.PREVIOUS_FORM_DATA;
2707
- break;
2708
- case EActionKey.SET_DROPDOWN_OPTIONS:
2709
- const setDropdownValue_Sources = new Source(object);
2710
- let dropdownValue = yield setDropdownValue_Sources.getValueFromSource(action.props.value.source);
2711
- if (checkObjectKeyExists(action.props, "options")) {
2712
- if (checkObjectKeyExists(action.props.options, "appendToPath")) {
2713
- let appendToPath = yield setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source);
2714
- if (isNotEmptyValue(appendToPath)) {
2715
- const appendToPathStr = replaceString(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
2716
- const optionsPath = `${action.props.options.path}${appendToPathStr}`;
2717
- dropdownValue = getObjectValueFromPath(dropdownValue, optionsPath);
2531
+ }
2532
+ sourceIndex++;
2533
+ }
2534
+ paramIndex++;
2535
+ }
2536
+ return this._object.FIELD_CONFIG;
2537
+ });
2538
+ }
2539
+ validateRequestBody() {
2540
+ var _a;
2541
+ return __awaiter(this, void 0, void 0, function* () {
2542
+ const body = this._request.body;
2543
+ const validation = body.validation;
2544
+ const triggers = validation.triggers;
2545
+ const rules = validation.rules;
2546
+ const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
2547
+ const rulesMapping = new Rule(rules, this._object).mapping();
2548
+ for (let action of actions) {
2549
+ const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2550
+ if (conditionSuccess) {
2551
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
2552
+ yield actions.execute();
2553
+ }
2554
+ }
2555
+ return this._object.FIELD_CONFIG;
2556
+ });
2557
+ }
2558
+ setRequestHeaders() {
2559
+ var _a, _b, _c, _d;
2560
+ return __awaiter(this, void 0, void 0, function* () {
2561
+ if (checkObjectKeyExists(this._request, "headers")) {
2562
+ if (checkObjectKeyExists(this._request.headers, "params")) {
2563
+ let params = this._request.headers.params;
2564
+ let paramIndex = 0;
2565
+ for (let param of params) {
2566
+ let sources = param.sources;
2567
+ let sourceIndex = 0;
2568
+ for (let source of sources) {
2569
+ const sources = new Source(this._object);
2570
+ const value = sources.getValueFromSource(source);
2571
+ // Set the Value of current source.
2572
+ this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.headers.params[${paramIndex}].sources[${sourceIndex}].value`, value);
2573
+ const validation = source.validation;
2574
+ const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
2575
+ const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
2576
+ const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
2577
+ const rulesMapping = new Rule(rules, this._object).mapping();
2578
+ for (let action of actions) {
2579
+ const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
2580
+ if (conditionEvaluation) {
2581
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
2582
+ yield actions.execute();
2583
+ }
2718
2584
  }
2585
+ sourceIndex++;
2719
2586
  }
2720
- else {
2721
- dropdownValue = getObjectValueFromPath(dropdownValue, action.props.options.path);
2587
+ paramIndex++;
2588
+ }
2589
+ return this._object.FIELD_CONFIG;
2590
+ }
2591
+ else {
2592
+ return this._object.FIELD_CONFIG;
2593
+ }
2594
+ }
2595
+ else {
2596
+ return this._object.FIELD_CONFIG;
2597
+ }
2598
+ });
2599
+ }
2600
+ validateRequestHeaders() {
2601
+ var _a;
2602
+ return __awaiter(this, void 0, void 0, function* () {
2603
+ const headers = this._request.headers;
2604
+ if (checkObjectKeyExists(this._request, "headers")) {
2605
+ if (checkObjectKeyExists(this._request.headers, "validation")) {
2606
+ const validation = headers.validation;
2607
+ const triggers = validation.triggers;
2608
+ const rules = validation.rules;
2609
+ const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
2610
+ const rulesMapping = new Rule(rules, this._object).mapping();
2611
+ for (let action of actions) {
2612
+ const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2613
+ if (conditionSuccess) {
2614
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
2615
+ yield actions.execute();
2722
2616
  }
2723
2617
  }
2724
- setDropdownValue_Sources.setValueToSource(action.props.value.destination, dropdownValue);
2725
- object.FIELD_CONFIG = setDropdownValue_Sources.object.FIELD_CONFIG;
2726
- this.formData = setDropdownValue_Sources.object.FORM_DATA;
2727
- this.allFormsData = setDropdownValue_Sources.object.ALL_FORMS_DATA;
2728
- this.previousFormData =
2729
- setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
2730
- break;
2731
- case EActionKey.HANDLE_CONNECTED_ELEMENTS:
2732
- this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
2733
- break;
2734
- case EActionKey.CUSTOM:
2735
- break;
2736
- default:
2737
- break;
2618
+ return this._object.FIELD_CONFIG;
2619
+ }
2620
+ else {
2621
+ return this._object.FIELD_CONFIG;
2622
+ }
2623
+ }
2624
+ else {
2625
+ return this._object.FIELD_CONFIG;
2626
+ }
2627
+ });
2628
+ }
2629
+ validateResponse() {
2630
+ return __awaiter(this, void 0, void 0, function* () {
2631
+ const validation = this._response.validation;
2632
+ const triggers = validation.triggers;
2633
+ const rules = validation.rules;
2634
+ const actions = validation.actions;
2635
+ const rulesMapping = new Rule(rules, this._object).mapping();
2636
+ for (let action of actions) {
2637
+ const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2638
+ if (conditionSuccess) {
2639
+ const actions = new Action(action, rulesMapping, this._object, this._takeAction);
2640
+ yield actions.execute();
2641
+ }
2738
2642
  }
2643
+ return this._object.FIELD_CONFIG;
2739
2644
  });
2740
2645
  }
2741
2646
  }
2742
- /** @nocollapse */ KwikIDFormViewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewComponent, deps: [{ token: TuiPushService }, { token: TuiAlertService }, { token: KwikIDFormViewService }], target: i0.ɵɵFactoryTarget.Component });
2743
- /** @nocollapse */ KwikIDFormViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: { formConfig: "formConfig", formData: "formData", isMobileView: "isMobileView", allFormsData: "allFormsData", formsList: "formsList" }, outputs: { onClickViewForms: "onClickViewForms", onClickSaveForm: "onClickSaveForm", onClickApiCall: "onClickApiCall" }, providers: [KwikIDFormViewService], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"kwikid-form-container\"\n *ngIf=\"!loading\"\n>\n <div id=\"uf-form-fields-header-container\">\n <div id=\"uf-form-fields-title\">\n {{ formConfig.title }}\n </div>\n <div id=\"uf-form-fields-steps\">\n Step {{ formConfig.sequenceNo }} of {{ this.formsListLength }}\n </div>\n <hr />\n </div>\n <form\n class=\"kwikid-form show\"\n [formGroup]=\"formGroup\"\n >\n <ng-container *ngFor=\"let field of formFields; let i = index\">\n <ng-container [ngSwitch]=\"field.type\">\n <!-- HTML Content -->\n <ng-container *ngSwitchCase=\"'html'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div [innerHtml]=\"field.html | safeHtml\"></div>\n </div>\n </ng-container>\n <!-- Form Title -->\n <ng-container *ngSwitchCase=\"'title'\">\n <div\n class=\"title\"\n [class.hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div>\n {{ field.label }}\n </div>\n <kwikui-button\n *ngIf=\"field?.reset\"\n appearance=\"whiteblock\"\n size=\"s\"\n label=\"Reset\"\n (onClick)=\"handleOnClickResetFormFields($event, field)\"\n ></kwikui-button>\n </div>\n </ng-container>\n <!-- Input Text -->\n <ng-container *ngSwitchCase=\"'text'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input\n [case]=\"field?.properties?.case\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [placeholder]=\"field?.properties?.placeholder\"\n [type]=\"'text'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Checkbox -->\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-checkbox-block\n [contentAlign]=\"field?.properties?.contentAlign ?? 'left'\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.properties?.placeholder\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size ?? 'l'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-checkbox-block\n ><kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Number -->\n <ng-container *ngSwitchCase=\"'number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-number\n [decimal]=\"field?.properties?.decimal\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [postfix]=\"field?.properties?.postfix ?? ''\"\n [precision]=\"field?.properties?.precision\"\n [prefix]=\"field?.properties?.prefix ?? ''\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-number\n ><kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Date -->\n <ng-container *ngSwitchCase=\"'date'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-date\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-date>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Phone -->\n <ng-container *ngSwitchCase=\"'phone'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-phone\n [countryCode]=\"field?.properties?.countryCode\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [phoneMaskAfterCountryCode]=\"\n field?.properties?.phoneMaskAfterCountryCode\n \"\n [removeCountryCodeFromValue]=\"\n field?.properties?.removeCountryCodeFromValue\n \"\n [placeholder]=\"field?.properties?.placeholder\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-phone>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Radio -->\n <ng-container *ngSwitchCase=\"'radio'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <label\n [tuiLabel]=\"labelTemplate\"\n style=\"min-height: auto; padding: 0px 0.5rem\"\n >\n <kwikui-radio-list\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [items]=\"field?.options\"\n [label]=\"field?.label\"\n [orientation]=\"field?.properties?.orientation\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-radio-list>\n </label>\n <ng-template #labelTemplate>\n <p\n class=\"tui-space_bottom-2\"\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <b>\n {{ field.label }}\n <span *ngIf=\"field.validators?.required\"></span>\n </b>\n </p>\n </ng-template>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Dropdown -->\n <ng-container *ngSwitchCase=\"'dropdown-with-search'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-select-combobox\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [options]=\"field.options\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-select-combobox>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- API Call -->\n <ng-container *ngSwitchCase=\"'api-call'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-button-api-call\n [apiStatus]=\"field?.api?.status?.value\"\n [class]=\"field?.class\"\n [disabled]=\"field?.disabled\"\n [id]=\"field.key\"\n [label]=\"field?.api?.status?.labels[field?.api?.status?.value]\"\n [showLoader]=\"field?.disabled === 'loading'\"\n shape=\"null\"\n size=\"m\"\n styles=\"width: fit-content\"\n (onClick)=\"handleOnClickApiCall($event)\"\n ></kwikui-button-api-call>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Mobile OTP -->\n <ng-container *ngSwitchCase=\"'otp'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-otp\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [mask]=\"field?.properties?.mask\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-otp>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Aadhaar Number -->\n <ng-container *ngSwitchCase=\"'aadhaar-number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-aadhaar\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [placeholder]=\"field?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-aadhaar>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n </form>\n <div class=\"kwikid-form-buttons\">\n <kwikui-button\n *ngIf=\"isMobileView\"\n [disabled]=\"viewFormsButton.disabled\"\n id=\"\"\n label=\"View Forms\"\n [showLoader]=\"viewFormsButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"secondary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"handleOnClickViewForms($event)\"\n ></kwikui-button>\n <kwikui-button\n [disabled]=\"saveFormButton.disabled\"\n id=\"\"\n label=\"Save\"\n [showLoader]=\"saveFormButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"primary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"handleOnClickSaveForm($event)\"\n ></kwikui-button>\n </div>\n</div>\n<div\n class=\"kwikid-form-container-loading\"\n *ngIf=\"loading\"\n>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n</div>\n<tui-push\n id=\"field-error-notification\"\n *tuiPush=\"showErrorNotification\"\n heading=\"Missing/Incorrect Fields!\"\n type=\"Error\"\n (close)=\"toggleErrorNotification(false)\"\n>\n <tui-svg\n src=\"tuiIconCancel\"\n style=\"color: #fff !important\"\n >\n </tui-svg>\n</tui-push>\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{border-radius:10px}::-webkit-scrollbar-thumb{background:lightgray;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:gray}.kwikid-form-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}.kwikid-form.show{width:100%;height:100%;padding:1rem;overflow-y:auto;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch;grid-row-gap:1rem;row-gap:1rem}.kwikid-form-buttons{width:100%;bottom:0px;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-column-gap:10px;column-gap:10px}.kwikid-form-buttons *{flex-grow:1}#uf-form-fields-header-container{display:flex;flex-direction:column;align-content:center;justify-content:center;align-items:flex-start;grid-row-gap:.5rem;row-gap:.5rem;padding:1rem}#uf-form-fields-header-container hr{width:100%}#uf-form-fields-title{color:#000;font-size:1.75em;font-weight:bold}#uf-form-fields-steps{color:var(--color-on-secondary-container);font-size:1em}.title{border-left:.25rem solid var(--tui-primary);padding:.75rem;font-size:1.4em;font-weight:bold;background-color:var(--tui-secondary);display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-gap:.5rem;gap:.5rem}.title:not(:first-child){margin-top:.5rem}.title.hidden{display:none}.large-wrapper{width:100%;height:60px}.large-wrapper:first-child{margin-bottom:auto}.large-wrapper:last-child{margin-top:auto}.kwikid-form-container-loading{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;grid-row-gap:1rem;row-gap:1rem;padding:1rem}#field-error-notification{background-color:var(--tui-error-fill);color:#fff!important}#field-error-notification .t-top{color:#fff!important}#field-error-notification .t-close{color:#fff!important}\n"], components: [{ type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }, { type: i2.KwikUIInputComponent, selector: "kwikui-input", inputs: ["label", "id", "type", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "validators", "case", "size", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIMessagesComponent, selector: "kwikui-messages", inputs: ["messages", "id"] }, { type: i2.KwikUICheckboxBlockComponent, selector: "kwikui-checkbox-block", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "contentAlign", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputNumberComponent, selector: "kwikui-input-number", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "prefix", "postfix", "precision", "decimal", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputDateComponent, selector: "kwikui-input-date", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputPhoneComponent, selector: "kwikui-input-phone", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "countryCode", "phoneMaskAfterCountryCode", "removeCountryCodeFromValue", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i3$1.TuiLabelComponent, selector: "label[tuiLabel]", inputs: ["tuiLabel", "context"] }, { type: i2.KwikUIRadioListComponent, selector: "kwikui-radio-list", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "orientation", "items", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUISelectComboboxComponent, selector: "kwikui-select-combobox", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "options", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIButtonApiCallComponent, selector: "kwikui-button-api-call", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "shape", "size", "apiStatus"], outputs: ["onClick"] }, { type: i2.KwikUIInputOtpComponent, selector: "kwikui-input-otp", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputAadhaarComponent, selector: "kwikui-input-aadhaar", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i4$1.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3$1.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["disabled", "formControl", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i4$1.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4$1.TuiPushDirective, selector: "tui-push" }], pipes: { "safeHtml": SafeHtmlPipe$1 } });
2744
- __decorate([
2745
- logMethod
2746
- ], KwikIDFormViewComponent.prototype, "ngOnInit", null);
2747
- __decorate([
2748
- logMethod
2749
- ], KwikIDFormViewComponent.prototype, "ngAfterViewInit", null);
2750
- __decorate([
2751
- logMethod
2752
- ], KwikIDFormViewComponent.prototype, "ngOnChanges", null);
2753
- __decorate([
2754
- logMethod
2755
- ], KwikIDFormViewComponent.prototype, "findFormsListLength", null);
2756
- __decorate([
2757
- logMethod
2758
- ], KwikIDFormViewComponent.prototype, "initFormConfig", null);
2759
- __decorate([
2760
- logMethod
2761
- ], KwikIDFormViewComponent.prototype, "setFormFieldsFromFormConfig", null);
2762
2647
  __decorate([
2763
2648
  logMethod
2764
- ], KwikIDFormViewComponent.prototype, "setFormFieldGroupsFromFormConfig", null);
2765
- __decorate([
2766
- logMethod
2767
- ], KwikIDFormViewComponent.prototype, "setFormDataFromAllFormsData", null);
2768
- __decorate([
2769
- logMethod
2770
- ], KwikIDFormViewComponent.prototype, "handleConnectedElementFieldGroupActions", null);
2771
- __decorate([
2772
- logMethod
2773
- ], KwikIDFormViewComponent.prototype, "handleConnectedElementFieldGroup", null);
2774
- __decorate([
2775
- logMethod
2776
- ], KwikIDFormViewComponent.prototype, "handleConnectedElementFieldActions", null);
2777
- __decorate([
2778
- logMethod
2779
- ], KwikIDFormViewComponent.prototype, "handleConnectedElementFields", null);
2780
- __decorate([
2781
- logMethod
2782
- ], KwikIDFormViewComponent.prototype, "handleConnectedElements", null);
2783
- __decorate([
2784
- logMethod
2785
- ], KwikIDFormViewComponent.prototype, "handleGetKeyValue", null);
2786
- __decorate([
2787
- logMethod
2788
- ], KwikIDFormViewComponent.prototype, "handleOnClickResetFormFields", null);
2649
+ ], Apis.prototype, "setRequestBody", null);
2789
2650
  __decorate([
2790
2651
  logMethod
2791
- ], KwikIDFormViewComponent.prototype, "handleOnClickApiCall", null);
2652
+ ], Apis.prototype, "validateRequestBody", null);
2792
2653
  __decorate([
2793
2654
  logMethod
2794
- ], KwikIDFormViewComponent.prototype, "handleOnClickViewForms", null);
2655
+ ], Apis.prototype, "setRequestHeaders", null);
2795
2656
  __decorate([
2796
2657
  logMethod
2797
- ], KwikIDFormViewComponent.prototype, "handleOnClickSaveForm", null);
2658
+ ], Apis.prototype, "validateRequestHeaders", null);
2798
2659
  __decorate([
2799
2660
  logMethod
2800
- ], KwikIDFormViewComponent.prototype, "toggleErrorNotification", null);
2801
- __decorate([
2802
- logMethod
2803
- ], KwikIDFormViewComponent.prototype, "fieldHide", null);
2804
- __decorate([
2805
- logMethod
2806
- ], KwikIDFormViewComponent.prototype, "fieldGroupHide", null);
2807
- __decorate([
2808
- logMethod
2809
- ], KwikIDFormViewComponent.prototype, "fieldShow", null);
2810
- __decorate([
2811
- logMethod
2812
- ], KwikIDFormViewComponent.prototype, "fieldGroupShow", null);
2813
- __decorate([
2814
- logMethod
2815
- ], KwikIDFormViewComponent.prototype, "fieldDisable", null);
2816
- __decorate([
2817
- logMethod
2818
- ], KwikIDFormViewComponent.prototype, "fieldGroupDisable", null);
2819
- __decorate([
2820
- logMethod
2821
- ], KwikIDFormViewComponent.prototype, "fieldEnable", null);
2822
- __decorate([
2823
- logMethod
2824
- ], KwikIDFormViewComponent.prototype, "fieldGroupEnable", null);
2825
- __decorate([
2826
- logMethod
2827
- ], KwikIDFormViewComponent.prototype, "fieldReset", null);
2828
- __decorate([
2829
- logMethod
2830
- ], KwikIDFormViewComponent.prototype, "fieldErrorShow", null);
2831
- __decorate([
2832
- logMethod
2833
- ], KwikIDFormViewComponent.prototype, "fieldErrorHide", null);
2834
- __decorate([
2835
- logMethod
2836
- ], KwikIDFormViewComponent.prototype, "fieldMessageShow", null);
2837
- __decorate([
2838
- logMethod
2839
- ], KwikIDFormViewComponent.prototype, "fieldMessageHide", null);
2840
- __decorate([
2841
- logMethod
2842
- ], KwikIDFormViewComponent.prototype, "setObjectValue", null);
2843
- __decorate([
2844
- logMethod
2845
- ], KwikIDFormViewComponent.prototype, "patchFieldControlValue", null);
2846
- __decorate([
2847
- logMethod
2848
- ], KwikIDFormViewComponent.prototype, "patchFormGroup", null);
2849
- __decorate([
2850
- logMethod
2851
- ], KwikIDFormViewComponent.prototype, "isFieldValid", null);
2852
- __decorate([
2853
- logMethod
2854
- ], KwikIDFormViewComponent.prototype, "isFieldEnabled", null);
2855
- __decorate([
2856
- logMethod
2857
- ], KwikIDFormViewComponent.prototype, "getFormGroupRawValues", null);
2858
- __decorate([
2859
- logMethod
2860
- ], KwikIDFormViewComponent.prototype, "takeActionOnFieldGroup", null);
2861
- __decorate([
2862
- logMethod
2863
- ], KwikIDFormViewComponent.prototype, "takeAction", null);
2864
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewComponent, decorators: [{
2865
- type: Component,
2866
- args: [{
2867
- selector: "kwikid-form-view",
2868
- templateUrl: "./form-view.component.html",
2869
- styleUrls: ["./form-view.component.scss"],
2870
- providers: [KwikIDFormViewService]
2871
- }]
2872
- }], ctorParameters: function () { return [{ type: i4$1.TuiPushService, decorators: [{
2873
- type: Inject,
2874
- args: [TuiPushService]
2875
- }] }, { type: i3$1.TuiAlertService, decorators: [{
2876
- type: Inject,
2877
- args: [TuiAlertService]
2878
- }] }, { type: KwikIDFormViewService }]; }, propDecorators: { formConfig: [{
2879
- type: Input
2880
- }], formData: [{
2881
- type: Input
2882
- }], isMobileView: [{
2883
- type: Input
2884
- }], allFormsData: [{
2885
- type: Input
2886
- }], formsList: [{
2887
- type: Input
2888
- }], onClickViewForms: [{
2889
- type: Output
2890
- }], onClickSaveForm: [{
2891
- type: Output
2892
- }], onClickApiCall: [{
2893
- type: Output
2894
- }], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], findFormsListLength: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleOnClickApiCall: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setObjectValue: [], patchFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], takeActionOnFieldGroup: [], takeAction: [] } });
2661
+ ], Apis.prototype, "validateResponse", null);
2895
2662
 
2896
2663
  /**
2897
2664
  * Generated class for the SafeHtmlPipe pipe.
2898
2665
  *
2899
2666
  * See https://angular.io/api/core/Pipe for more info on Angular Pipes.
2900
2667
  */
2901
- class SafeHtmlPipe {
2668
+ class SafeHtmlPipe$1 {
2902
2669
  constructor(sanitizer) {
2903
2670
  this.sanitizer = sanitizer;
2904
2671
  }
@@ -2906,803 +2673,1038 @@ class SafeHtmlPipe {
2906
2673
  return this.sanitizer.bypassSecurityTrustHtml(html);
2907
2674
  }
2908
2675
  }
2909
- /** @nocollapse */ SafeHtmlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
2910
- /** @nocollapse */ SafeHtmlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, name: "safeHtml" });
2911
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, decorators: [{
2676
+ /** @nocollapse */ SafeHtmlPipe$1.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe$1, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
2677
+ /** @nocollapse */ SafeHtmlPipe$1.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe$1, name: "safeHtml" });
2678
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe$1, decorators: [{
2912
2679
  type: Pipe,
2913
2680
  args: [{
2914
2681
  name: "safeHtml"
2915
2682
  }]
2916
2683
  }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
2917
2684
 
2918
- class KwikIDFormsListComponent {
2919
- constructor() {
2920
- this.showFormFields = {};
2921
- this.userConfig = {};
2922
- this.activeFormConfig = {};
2923
- this.formsList = [];
2924
- this.formsListCompleted = [];
2685
+ class KwikIDFormViewComponent {
2686
+ constructor(push, alert, formViewService) {
2687
+ this.push = push;
2688
+ this.alert = alert;
2689
+ this.formViewService = formViewService;
2925
2690
  this.isMobileView = false;
2926
- this.onClickSetActiveForm = new EventEmitter();
2927
- this.onClickHideFormsList = new EventEmitter();
2928
- this.onClickSubmitForms = new EventEmitter();
2929
- this.selectedForm = "";
2930
- this.formsListLength = 0;
2931
- this.isAllFormsCompleted = true;
2691
+ this.onClickViewForms = new EventEmitter();
2692
+ this.onClickSaveForm = new EventEmitter();
2693
+ this.onClickApiCall = new EventEmitter();
2694
+ this.fieldGroups = {};
2695
+ this.formFields = [];
2696
+ this.previousFormData = {};
2697
+ this.loading = true;
2698
+ this.viewFormsButton = {
2699
+ disabled: false,
2700
+ showLoader: false
2701
+ };
2702
+ this.saveFormButton = {
2703
+ disabled: false,
2704
+ showLoader: false
2705
+ };
2706
+ this.formGroup = new FormGroup({});
2707
+ this.showErrorNotification = false;
2932
2708
  }
2933
2709
  ngOnInit() {
2934
- this.formsList = this.filterHiddenForms(this.formsList);
2935
- this.formsListLength = this.findFormsListLength(this.formsList);
2936
- this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
2710
+ (() => __awaiter(this, void 0, void 0, function* () {
2711
+ yield this.initFormConfig(this.formConfig);
2712
+ this.loading = false;
2713
+ }))();
2937
2714
  }
2715
+ ngAfterViewInit() { }
2938
2716
  ngOnChanges(changes) {
2939
2717
  const verifyChange = (key) => {
2940
2718
  return checkObjectKeyExists(changes, key) && !changes[key].firstChange;
2941
2719
  };
2942
- if (verifyChange("showFormFields")) {
2943
- this.showFormFields = changes.showFormFields.currentValue;
2944
- }
2945
- if (verifyChange("formsList")) {
2946
- this.formsList = this.filterHiddenForms(this.formsList);
2947
- this.formsListLength = this.findFormsListLength(this.formsList);
2948
- this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
2720
+ if (verifyChange("formData")) {
2721
+ this.formData = Object.assign(Object.assign({}, this.formData), changes.formData.currentValue);
2949
2722
  }
2950
2723
  if (verifyChange("isMobileView")) {
2951
2724
  this.isMobileView = changes.isMobileView.currentValue;
2952
2725
  }
2726
+ if (verifyChange("allFormsData")) {
2727
+ this.allFormsData = changes.allFormsData.currentValue;
2728
+ }
2729
+ if (verifyChange("formConfig")) {
2730
+ this.formConfig = changes.formConfig.currentValue;
2731
+ (() => __awaiter(this, void 0, void 0, function* () {
2732
+ yield this.initFormConfig(this.formConfig);
2733
+ }))();
2734
+ }
2953
2735
  }
2954
- filterHiddenForms(formsList) {
2955
- return formsList.filter((form) => {
2956
- if (checkObjectKeyExists(form, "hidden")) {
2957
- if (!form.hidden) {
2958
- return form;
2736
+ initFormConfig(formConfig) {
2737
+ return __awaiter(this, void 0, void 0, function* () {
2738
+ formConfig = new Converter().convertFormConfig(formConfig);
2739
+ formConfig = new Converter().updateFormConfigProperties(formConfig);
2740
+ this.setFormFieldsFromFormConfig(formConfig);
2741
+ this.setFormFieldGroupsFromFormConfig(formConfig);
2742
+ this.setFormDataFromAllFormsData();
2743
+ this.formGroup = yield this.formViewService.createFormGroup(this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
2744
+ for (let field of this.formFields) {
2745
+ if (field.isFormElement) {
2746
+ this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: this.formGroup.controls[field.key].value });
2747
+ this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: this.formGroup.controls[field.key].value });
2748
+ this.formGroup.controls[field.key].valueChanges
2749
+ .pipe(pairwise())
2750
+ .subscribe(([previousValue, currentValue]) => {
2751
+ this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, previousValue) });
2752
+ this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: convertFormFieldValueToStandardFormat(field, currentValue) });
2753
+ });
2959
2754
  }
2960
2755
  }
2961
- });
2962
- }
2963
- findFormsListLength(formsList) {
2964
- const _formsList = formsList.filter((form) => {
2965
- if (checkObjectKeyExists(form, "type")) {
2966
- if (form.type === "form") {
2967
- if (checkObjectKeyExists(form, "hidden")) {
2968
- if (!form.hidden) {
2969
- return form;
2756
+ for (let field of this.formFields) {
2757
+ if (field.isFormElement) {
2758
+ if (checkObjectKeyExists(field, "validation")) {
2759
+ if (field.validation.triggers.includes("ON_INIT")) {
2760
+ const validations = new Validation({
2761
+ FIELD_CONFIG: field,
2762
+ FORM_FIELDS: this.formFields,
2763
+ FORM_DATA: this.formData,
2764
+ PREVIOUS_FORM_DATA: this.previousFormData,
2765
+ ALL_FORMS_DATA: this.allFormsData
2766
+ }, this.takeAction.bind(this));
2767
+ yield validations.validate(field.validation);
2970
2768
  }
2971
2769
  }
2972
- }
2973
- }
2974
- else if (checkObjectKeyExists(form, "hidden")) {
2975
- if (!form.hidden) {
2976
- return form;
2770
+ if (checkObjectKeyExists(field, "connectedElements")) {
2771
+ this.handleConnectedElements({
2772
+ key: field.key,
2773
+ value: this.formGroup.controls[field.key].value
2774
+ }, "ON_INIT");
2775
+ }
2977
2776
  }
2978
2777
  }
2979
2778
  });
2980
- return _formsList.length;
2981
2779
  }
2982
- checkIsAllFormsCompleted(formsList) {
2983
- let isAllFormsCompleted = true;
2984
- for (let form of formsList) {
2985
- if (checkObjectKeyExists(form, "type")) {
2986
- if (form.type === "form") {
2987
- if (form.status !== "completed") {
2988
- isAllFormsCompleted = false;
2989
- break;
2990
- }
2991
- }
2992
- }
2780
+ setFormFieldsFromFormConfig(formConfig) {
2781
+ if (checkObjectKeyExists(formConfig, "fields")) {
2782
+ this.formFields = formConfig.fields;
2993
2783
  }
2994
- return isAllFormsCompleted;
2995
- }
2996
- handleOnClickSetActiveForm(selectedForm) {
2997
- if (this.selectedForm !== selectedForm ||
2998
- (this.isAllFormsCompleted && !this.showFormFields)) {
2999
- this.selectedForm = selectedForm;
3000
- this.onClickSetActiveForm.emit(selectedForm);
2784
+ else if (checkObjectKeyExists(formConfig, "multiForm") &&
2785
+ checkObjectKeyExists(formConfig.multiForm, "fields")) {
2786
+ this.formFields = formConfig.multiForm.fields;
3001
2787
  }
3002
2788
  }
3003
- handleOnSubmitForms(e) {
3004
- this.onClickSubmitForms.emit(e);
2789
+ setFormFieldGroupsFromFormConfig(formConfig) {
2790
+ this.fieldGroups = formConfig.fieldGroups;
3005
2791
  }
3006
- }
3007
- /** @nocollapse */ KwikIDFormsListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormsListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3008
- /** @nocollapse */ KwikIDFormsListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: { showFormFields: "showFormFields", userConfig: "userConfig", activeFormConfig: "activeFormConfig", formsList: "formsList", formsListCompleted: "formsListCompleted", isMobileView: "isMobileView" }, outputs: { onClickSetActiveForm: "onClickSetActiveForm", onClickHideFormsList: "onClickHideFormsList", onClickSubmitForms: "onClickSubmitForms" }, usesOnChanges: true, ngImport: i0, template: "<div id=\"sidebar-container\">\n <div id=\"sidebar\">\n <div ngClass=\"kwikid-form-header\">\n <div id=\"uf-header\">\n <div id=\"uf-header-logo-container\">\n <img\n id=\"uf-header-logo\"\n src=\"{{ this.userConfig.theme.clientLogo }}\"\n [ngClass]=\"'large-icon'\"\n />\n </div>\n </div>\n <hr />\n </div>\n <div id=\"uf-progress\">\n <div id=\"uf-progress-steps\">\n {{ this.formsListCompleted.length }} / {{ this.formsListLength }} Steps\n Completed\n </div>\n <kwikui-progress-segmented\n [max]=\"this.formsListLength\"\n size=\"m\"\n [value]=\"this.formsListCompleted.length\"\n ></kwikui-progress-segmented>\n </div>\n <div id=\"uf-sections-container\">\n <ng-container *ngFor=\"let form of formsList; let i = index\">\n <ng-container [ngSwitch]=\"form.type\">\n <!-- HTML Content -->\n <ng-container *ngSwitchCase=\"'html'\">\n <div [innerHtml]=\"form.props.htmlContent | safeHtml\"></div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'form'\">\n <div\n [class]=\"'uf-section-item'\"\n [class.completed]=\"form.status === 'completed' && !form.disabled\"\n [class.edit]=\"form.status === 'editable' && !form.disabled\"\n [class.locked]=\"form.status === 'locked' && form.disabled\"\n [class.active]=\"\n activeFormConfig !== undefined &&\n form.key === activeFormConfig.key\n \"\n (click)=\"\n form.status === 'locked' && form.disabled\n ? undefined\n : handleOnClickSetActiveForm(form.key)\n \"\n >\n <div class=\"uf-form-section-card-title\">\n {{ form.props.title }}&nbsp;<span *ngIf=\"form?.required\"\n >*</span\n >\n </div>\n <div class=\"uf-form-section-card-status\">\n <div\n *ngIf=\"form.status === 'completed' && !form.disabled\"\n class=\"uf-form-section-card-status-img completed\"\n >\n <tui-svg src=\"tuiIconCheckLarge\"></tui-svg>\n </div>\n <div\n *ngIf=\"form.status !== 'completed' && !form.disabled\"\n class=\"uf-form-section-card-status-img edit\"\n >\n <tui-svg src=\"tuiIconEdit\"></tui-svg>\n </div>\n <div\n *ngIf=\"form.status !== 'completed' && form.disabled\"\n class=\"uf-form-section-card-status-img locked\"\n >\n <tui-svg src=\"tuiIconLock\"></tui-svg>\n </div>\n </div>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n </div>\n <div id=\"submit-sidebar-btn-container\">\n <kwikui-button\n [disabled]=\"false\"\n id=\"\"\n label=\"Submit\"\n [showLoader]=\"false\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"primary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"handleOnSubmitForms($event)\"\n ></kwikui-button>\n </div>\n </div>\n</div>\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{border-radius:10px}::-webkit-scrollbar-thumb{background:lightgray;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:gray}#sidebar-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}#sidebar{width:100%;height:100%;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch}.uf-section-item{width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;align-content:center;padding:1rem;grid-gap:1rem;gap:1rem;cursor:pointer;box-shadow:0 1px 3px -1px var(--tui-base-05);border-radius:.5rem;background-color:var(--tui-base-02);position:relative}.uf-section-item:hover{box-shadow:0 1px 3px -1px var(--tui-base-08)}#submit-sidebar-btn-container{width:100%;bottom:0px;z-index:1;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-gap:1rem;gap:1rem}#submit-sidebar-btn-container *{flex-grow:1}#uf-sections-container{display:flex;flex-direction:column;height:100%;grid-row-gap:20px;row-gap:20px;padding:1rem;overflow-y:auto}.uf-form-section-card{display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-column-gap:10px;column-gap:10px;border:none;border-radius:8px;background-color:#e9e9e9;height:-moz-fit-content;height:fit-content;min-height:60px;padding:10px 15px;width:100%;max-width:350px;margin:0 auto}.uf-section-item.locked{-webkit-user-select:none;user-select:none;cursor:not-allowed}.uf-form-section-card .uf-form-section-card-title{font-size:1.2em;text-align:left;line-height:1.25em}.uf-form-section-card .uf-form-section-card-status{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}.uf-form-section-card .uf-form-section-card-status .uf-form-section-card-status-img{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;border-radius:100%;color:#fff;font-weight:bold}.uf-form-section-card-status-img.completed{background-color:var(--tui-success-fill);padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-status-img.edit{background-color:var(--tui-error-fill);padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-status-img.locked{background-color:var(--tui-neutral-fill);padding:.25rem;border-radius:50%;color:#fff}#uf-progress{display:flex;padding:1rem;flex-direction:column;align-content:center;justify-content:center;align-items:stretch;grid-gap:.5rem;gap:.5rem}#uf-progress-steps{font-size:1em;text-align:right;color:#3d3d3d}.uf-form-section-card-title{font-size:1em;font-weight:bold;color:#000}@media screen and (max-width: 600px){#sidebar-container{max-width:unset}}.kwikid-form-header{height:70px;z-index:6}.kwikid-form-header hr{width:calc(100% - 1rem);margin-left:auto;margin-right:auto}#uf-header{display:flex;flex-direction:row;align-content:center;align-items:center;justify-content:flex-start;grid-column-gap:10px;column-gap:10px;padding:10px 20px;width:100%;max-width:calc(400px + 50vw + 2rem);margin:0 auto;height:70px;z-index:1}#uf-header #uf-header-goback-container{display:none}#uf-header #uf-header-goback-container:hover{border-radius:50%;background-color:#d3d3d3}#uf-header #uf-header-goback-container #uf-header-goback{width:100%;height:auto}#uf-header #uf-header-logo-container{display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}#uf-header #uf-header-logo-container #uf-header-logo.small-icon{width:100%;height:50px}#uf-header #uf-header-logo-container #uf-header-logo.large-icon{width:100%;height:50px}#uf-header #uf-header-title-container{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;grid-row-gap:4px;row-gap:4px}#uf-header #uf-header-title-container #uf-header-title{font-size:1.4em;color:#121212}#uf-header #uf-header-title-container #uf-header-subtitle{font-size:1.2em;color:#121212}\n"], components: [{ type: i2.KwikUIProgressSegmentedComponent, selector: "kwikui-progress-segmented", inputs: ["id", "value", "max", "size", "colors"] }, { type: i3$1.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }, { type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "safeHtml": SafeHtmlPipe } });
3009
- __decorate([
3010
- logMethod
3011
- ], KwikIDFormsListComponent.prototype, "ngOnChanges", null);
3012
- __decorate([
3013
- logMethod
3014
- ], KwikIDFormsListComponent.prototype, "filterHiddenForms", null);
3015
- __decorate([
3016
- logMethod
3017
- ], KwikIDFormsListComponent.prototype, "findFormsListLength", null);
3018
- __decorate([
3019
- logMethod
3020
- ], KwikIDFormsListComponent.prototype, "checkIsAllFormsCompleted", null);
3021
- __decorate([
3022
- logMethod
3023
- ], KwikIDFormsListComponent.prototype, "handleOnClickSetActiveForm", null);
3024
- __decorate([
3025
- logMethod
3026
- ], KwikIDFormsListComponent.prototype, "handleOnSubmitForms", null);
3027
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormsListComponent, decorators: [{
3028
- type: Component,
3029
- args: [{
3030
- selector: "kwikid-forms-list",
3031
- templateUrl: "./forms-list.component.html",
3032
- styleUrls: ["./forms-list.component.scss"]
3033
- }]
3034
- }], ctorParameters: function () { return []; }, propDecorators: { showFormFields: [{
3035
- type: Input
3036
- }], userConfig: [{
3037
- type: Input
3038
- }], activeFormConfig: [{
3039
- type: Input
3040
- }], formsList: [{
3041
- type: Input
3042
- }], formsListCompleted: [{
3043
- type: Input
3044
- }], isMobileView: [{
3045
- type: Input
3046
- }], onClickSetActiveForm: [{
3047
- type: Output
3048
- }], onClickHideFormsList: [{
3049
- type: Output
3050
- }], onClickSubmitForms: [{
3051
- type: Output
3052
- }], ngOnChanges: [], filterHiddenForms: [], findFormsListLength: [], checkIsAllFormsCompleted: [], handleOnClickSetActiveForm: [], handleOnSubmitForms: [] } });
3053
-
3054
- var EFormsListStatus;
3055
- (function (EFormsListStatus) {
3056
- EFormsListStatus["COMPLETED"] = "completed";
3057
- EFormsListStatus["EDITABLE"] = "editable";
3058
- EFormsListStatus["LOCKED"] = "locked";
3059
- })(EFormsListStatus || (EFormsListStatus = {}));
3060
-
3061
- var ERendererActionKey;
3062
- (function (ERendererActionKey) {
3063
- ERendererActionKey["SET_VALUE"] = "SET_VALUE";
3064
- ERendererActionKey["FORM_HIDE"] = "FORM_HIDE";
3065
- ERendererActionKey["FORM_SHOW"] = "FORM_SHOW";
3066
- ERendererActionKey["FORM_DISABLE"] = "FORM_DISABLE";
3067
- ERendererActionKey["FORM_ENABLE"] = "FORM_ENABLE";
3068
- })(ERendererActionKey || (ERendererActionKey = {}));
3069
-
3070
- class Converter {
3071
- constructor() {
3072
- this.getFormFields = (formConfig) => {
3073
- let fields;
3074
- if (checkObjectKeyExists(formConfig, "multiForm")) {
3075
- fields = formConfig.multiForm.fields;
3076
- }
3077
- else {
3078
- fields = formConfig.fields;
3079
- }
3080
- return fields;
3081
- };
3082
- this.setMissingFieldKeyValue = (field, key, value) => {
3083
- if (!checkObjectKeyExists(field, key)) {
3084
- field[key] = value;
3085
- }
3086
- return field;
3087
- };
3088
- this.setFieldKeyValue = (field, key, value) => {
3089
- field[key] = value;
3090
- return field;
3091
- };
3092
- this.removeFieldKey = (field, key) => {
3093
- if (checkObjectKeyExists(field, key)) {
3094
- delete field[key];
3095
- }
3096
- return field;
3097
- };
2792
+ setFormDataFromAllFormsData() {
2793
+ if (checkObjectKeyExists(this.allFormsData, this.formConfig.key)) {
2794
+ this.formData = this.allFormsData[this.formConfig.key];
2795
+ }
2796
+ else {
2797
+ this.formData = {};
2798
+ }
3098
2799
  }
3099
- convertFormConfig(formConfig) {
3100
- const updateOnFieldType = (field) => {
3101
- const formatFieldTypeHtml = (field) => {
3102
- field = this.setFieldKeyValue(field, "isFormElement", false);
3103
- return field;
3104
- };
3105
- const formatFieldTypeTitle = (field) => {
3106
- field = this.setFieldKeyValue(field, "hidden", false);
3107
- field = this.setFieldKeyValue(field, "isFormElement", false);
3108
- return field;
3109
- };
3110
- const formatFieldTypeText = (field) => {
3111
- field = this.setFieldKeyValue(field, "isFormElement", true);
3112
- field.properties = this.setMissingFieldKeyValue(field.properties, "case", "default");
3113
- return field;
3114
- };
3115
- const formatFieldTypeCheckbox = (field) => {
3116
- field = this.setFieldKeyValue(field, "isFormElement", true);
3117
- return field;
3118
- };
3119
- const formatFieldTypeNumber = (field) => {
3120
- field = this.setFieldKeyValue(field, "isFormElement", true);
3121
- if (checkObjectKeyExists(field, "key")) {
3122
- if (field.key === "aadhaar_number") {
3123
- field = this.setFieldKeyValue(field, "type", "aadhaar_number");
3124
- }
3125
- if (field.key === "contact_number") {
3126
- field = this.setFieldKeyValue(field, "type", "phone");
3127
- }
3128
- if (field.type === "phone" || field.type === "number") {
3129
- field.properties = this.setMissingFieldKeyValue(field.properties, "countryCode", "+91");
3130
- field.properties = this.setMissingFieldKeyValue(field.properties, "phoneMaskAfterCountryCode", "####-######");
3131
- field.properties = this.setMissingFieldKeyValue(field.properties, "removeCountryCodeFromValue", true);
3132
- field.properties = this.setMissingFieldKeyValue(field.properties, "decimal", "never");
3133
- field.properties = this.setMissingFieldKeyValue(field.properties, "prefix", "");
3134
- field.properties = this.setMissingFieldKeyValue(field.properties, "postfix", "");
3135
- field.properties = this.setMissingFieldKeyValue(field.properties, "min", -Infinity);
3136
- field.properties = this.setMissingFieldKeyValue(field.properties, "max", Infinity);
3137
- field.properties = this.setMissingFieldKeyValue(field.properties, "precision", 2);
2800
+ handleConnectedElementFieldGroupActions(childFieldGroupConfig, parentField) {
2801
+ return __awaiter(this, void 0, void 0, function* () {
2802
+ if (checkObjectKeyExists(childFieldGroupConfig, "rules")) {
2803
+ const rulesMapping = new Rule(childFieldGroupConfig.rules, {
2804
+ FIELD_CONFIG: parentField,
2805
+ FORM_DATA: this.formData,
2806
+ PREVIOUS_FORM_DATA: this.previousFormData,
2807
+ ALL_FORMS_DATA: this.allFormsData
2808
+ }).mapping();
2809
+ for (let action of childFieldGroupConfig.actions) {
2810
+ const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2811
+ if (conditionSuccess) {
2812
+ const actions = new Action(action, rulesMapping, {
2813
+ FIELD_CONFIG: parentField,
2814
+ FORM_FIELDS: this.formFields,
2815
+ FORM_DATA: this.formData,
2816
+ PREVIOUS_FORM_DATA: this.previousFormData,
2817
+ ALL_FORMS_DATA: this.allFormsData
2818
+ }, this.takeActionOnFieldGroup.bind(this));
2819
+ yield actions.execute();
3138
2820
  }
3139
2821
  }
3140
- field = this.setFieldKeyValue(field, "hidden", false);
3141
- return field;
3142
- };
3143
- const formatFieldTypeDate = (field) => {
3144
- field = this.setFieldKeyValue(field, "isFormElement", true);
3145
- if (checkObjectKeyExists(field, "min")) {
3146
- const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["min"]);
3147
- field.properties = this.setFieldKeyValue(field.properties, "min", tuiDay);
2822
+ }
2823
+ });
2824
+ }
2825
+ handleConnectedElementFieldGroup(currentField, connectedFieldGroupConfig, eventType) {
2826
+ return __awaiter(this, void 0, void 0, function* () {
2827
+ if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers")) {
2828
+ if (connectedFieldGroupConfig.triggers.includes(eventType)) {
2829
+ yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
3148
2830
  }
3149
- else {
3150
- field.properties = this.setMissingFieldKeyValue(field.properties, "min", new TuiDay(0, 0, 1)); // Year - 0000, Month - 0 (0 Indexing), Day - 1
2831
+ }
2832
+ });
2833
+ }
2834
+ handleConnectedElementFieldActions(connectedFieldConfig, connectedField) {
2835
+ return __awaiter(this, void 0, void 0, function* () {
2836
+ if (checkObjectKeyExists(connectedFieldConfig, "rules")) {
2837
+ const rulesMapping = new Rule(connectedFieldConfig.rules, {
2838
+ FIELD_CONFIG: connectedField,
2839
+ FORM_DATA: this.formData,
2840
+ PREVIOUS_FORM_DATA: this.previousFormData,
2841
+ ALL_FORMS_DATA: this.allFormsData
2842
+ }).mapping();
2843
+ for (let action of connectedFieldConfig.actions) {
2844
+ const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
2845
+ if (conditionSuccess) {
2846
+ const actions = new Action(action, rulesMapping, {
2847
+ FORM_FIELDS: this.formFields,
2848
+ FIELD_CONFIG: connectedField,
2849
+ FORM_DATA: this.formData,
2850
+ PREVIOUS_FORM_DATA: this.previousFormData,
2851
+ ALL_FORMS_DATA: this.allFormsData
2852
+ }, this.takeAction.bind(this));
2853
+ yield actions.execute();
2854
+ }
3151
2855
  }
3152
- if (checkObjectKeyExists(field, "max")) {
3153
- const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["max"]);
3154
- field.properties = this.setFieldKeyValue(field.properties, "max", tuiDay);
2856
+ }
2857
+ return connectedField;
2858
+ });
2859
+ }
2860
+ handleConnectedElementFields(currentField, connectedFieldConfig, eventType, nested) {
2861
+ return __awaiter(this, void 0, void 0, function* () {
2862
+ let connectedField = getFormFieldByKey(this.formFields, connectedFieldConfig["key"]);
2863
+ if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
2864
+ if (connectedFieldConfig.triggers.includes(eventType)) {
2865
+ connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
3155
2866
  }
3156
- else {
3157
- field.properties = this.setMissingFieldKeyValue(field.properties, "max", new TuiDay(new Date().getFullYear(), // Year - 9999
3158
- new Date().getMonth(), // Month - 11 (0 Indexing)
3159
- new Date().getDate() // Day - 31
3160
- ));
2867
+ }
2868
+ if (checkObjectKeyExists(connectedFieldConfig, "handleNestedFields")) {
2869
+ if (connectedFieldConfig.handleNestedFields) {
2870
+ this.handleConnectedElements({ key: connectedFieldConfig.key }, eventType);
3161
2871
  }
3162
- field.properties = this.setMissingFieldKeyValue(field.properties, "placeholder", "");
3163
- field = this.setFieldKeyValue(field, "hidden", false);
3164
- return field;
3165
- };
3166
- const formatFieldTypePhone = (field) => {
3167
- field = this.setFieldKeyValue(field, "isFormElement", true);
3168
- return field;
3169
- };
3170
- const formatFieldTypeRadio = (field) => {
3171
- field = this.setFieldKeyValue(field, "isFormElement", true);
3172
- field.properties = this.setMissingFieldKeyValue(field.properties, "size", "m");
3173
- field.properties = this.setMissingFieldKeyValue(field.properties, "orientation", "vertical");
3174
- field = this.setFieldKeyValue(field, "hidden", false);
3175
- field.options = field.options.map((x) => {
3176
- if (typeof x === "string" || typeof x === "number") {
3177
- return { label: x, disabled: false, description: "" };
3178
- }
3179
- else {
3180
- if (checkObjectKeyExists(x, "label") &&
3181
- checkObjectKeyExists(x, "disabled") &&
3182
- checkObjectKeyExists(x, "description")) {
3183
- return x;
3184
- }
3185
- if (!checkObjectKeyExists(x, "disabled")) {
3186
- x = Object.assign(Object.assign({}, x), { disabled: false });
2872
+ }
2873
+ return currentField;
2874
+ });
2875
+ }
2876
+ handleConnectedElements(e, eventType) {
2877
+ return __awaiter(this, void 0, void 0, function* () {
2878
+ let currentField = getFormFieldByKey(this.formFields, e.key);
2879
+ if (currentField !== undefined) {
2880
+ if (checkObjectKeyExists(currentField, "connectedElements")) {
2881
+ if (checkObjectKeyExists(currentField.connectedElements, "connectedFieldGroups")) {
2882
+ let connectedFieldGroups = currentField.connectedElements.connectedFieldGroups;
2883
+ for (let connectedFieldGroupConfig of connectedFieldGroups) {
2884
+ yield this.handleConnectedElementFieldGroup(currentField, connectedFieldGroupConfig, eventType);
3187
2885
  }
3188
- if (!checkObjectKeyExists(x, "description")) {
3189
- x = Object.assign(Object.assign({}, x), { description: false });
2886
+ }
2887
+ if (checkObjectKeyExists(currentField.connectedElements, "connectedFields")) {
2888
+ let connectedFields = currentField.connectedElements.connectedFields;
2889
+ for (let connectedFieldConfig of connectedFields) {
2890
+ currentField = yield this.handleConnectedElementFields(currentField, connectedFieldConfig, eventType, eventType);
3190
2891
  }
3191
- return x;
3192
2892
  }
3193
- });
3194
- return field;
3195
- };
3196
- const formatFieldTypeSearchText = (field) => {
3197
- field = this.setFieldKeyValue(field, "isFormElement", true);
3198
- if (checkObjectKeyExists(field, "type")) {
3199
- if (field.type === "search-text") {
3200
- field = this.setFieldKeyValue(field, "type", "dropdown-with-search");
3201
- }
3202
- }
3203
- return field;
3204
- };
3205
- const formatFieldTypeDropdownWithSearch = (field) => {
3206
- field = this.setFieldKeyValue(field, "isFormElement", true);
3207
- return field;
3208
- };
3209
- const formatFieldTypeApiCall = (field) => {
3210
- field = this.setFieldKeyValue(field, "isFormElement", true);
3211
- if (!checkObjectKeyExists(field.properties, "shape")) {
3212
- field.properties = this.setFieldKeyValue(field.properties, "shape", null);
3213
- }
3214
- if (!checkObjectKeyExists(field, "showLoader")) {
3215
- field = this.setFieldKeyValue(field, "showLoader", false);
3216
- }
3217
- if (!checkObjectKeyExists(field.properties, "size")) {
3218
- field.properties = this.setFieldKeyValue(field.properties, "size", "m");
3219
- }
3220
- if (!checkObjectKeyExists(field, "api")) {
3221
- field = this.setFieldKeyValue(field, "api", {});
3222
- field.api = this.setMissingFieldKeyValue(field.api, "url", "");
3223
- field.api = this.setMissingFieldKeyValue(field.api, "request", "");
3224
- field.api = this.setMissingFieldKeyValue(field.api, "response", "");
3225
- field.api = this.setMissingFieldKeyValue(field.api, "status", "");
3226
- field.api.status = this.setMissingFieldKeyValue(field.api.status, "value", "default");
3227
- field.api.status = this.setMissingFieldKeyValue(field.api.status, "labels", {
3228
- default: "Call API",
3229
- loading: "Call API",
3230
- success: "API Success",
3231
- failed: "API Failed"
3232
- });
3233
2893
  }
3234
- return field;
3235
- };
3236
- const formatFieldTypeOtp = (field) => {
3237
- field = this.setFieldKeyValue(field, "isFormElement", true);
3238
- field.properties = this.setMissingFieldKeyValue(field.properties, "mask", new Array(field.properties.otpLength).fill("#").join(" "));
3239
- field = this.setFieldKeyValue(field, "hidden", false);
3240
- return field;
3241
- };
3242
- const formatFieldTypeAadhaarNumber = (field) => {
3243
- field = this.setFieldKeyValue(field, "isFormElement", true);
3244
- return field;
3245
- };
3246
- switch (field.type) {
3247
- case "html":
3248
- field = formatFieldTypeHtml(field);
3249
- break;
3250
- case "title":
3251
- field = formatFieldTypeTitle(field);
3252
- break;
3253
- case "text":
3254
- field = formatFieldTypeText(field);
3255
- break;
3256
- case "checkbox":
3257
- field = formatFieldTypeCheckbox(field);
3258
- break;
3259
- case "number":
3260
- field = formatFieldTypeNumber(field);
3261
- break;
3262
- case "date":
3263
- field = formatFieldTypeDate(field);
3264
- break;
3265
- case "phone":
3266
- field = formatFieldTypePhone(field);
3267
- break;
3268
- case "radio":
3269
- field = formatFieldTypeRadio(field);
3270
- break;
3271
- case "search-text":
3272
- field = formatFieldTypeSearchText(field);
3273
- break;
3274
- case "dropdown-with-search":
3275
- field = formatFieldTypeDropdownWithSearch(field);
3276
- break;
3277
- case "api-call":
3278
- field = formatFieldTypeApiCall(field);
3279
- break;
3280
- case "otp":
3281
- field = formatFieldTypeOtp(field);
3282
- break;
3283
- case "aadhaar-number":
3284
- field = formatFieldTypeAadhaarNumber(field);
3285
- break;
3286
- default:
3287
- break;
3288
2894
  }
3289
- return field;
3290
- };
3291
- const getConnectedelementTypeValueObject = (key) => {
3292
- const object = {
3293
- key: key,
3294
- conditions: { formula: "", rules: [] },
3295
- actions: { success: [], failure: [] }
3296
- };
3297
- return object;
3298
- };
3299
- const formatFieldKeys = (field) => {
3300
- if (checkObjectKeyExists(field, "connectedTo")) {
3301
- if (typeof field["connectedTo"] === "string") {
3302
- field["connectedElements"] = [
3303
- getConnectedelementTypeValueObject(field["connectedTo"])
3304
- ];
3305
- }
3306
- else {
3307
- field["connectedTo"] = field["connectedTo"].map((key) => {
3308
- return getConnectedelementTypeValueObject(key);
3309
- });
3310
- field["connectedElements"] = field["connectedTo"];
2895
+ else {
2896
+ throw new Error(`Field for the given key ['${e.key}'] is not found with eventType: '${eventType}'.`);
2897
+ }
2898
+ });
2899
+ }
2900
+ // DOM Event Handlers
2901
+ handleGetKeyValue(e) {
2902
+ this.formGroup.patchValue({
2903
+ [e.key]: e.value
2904
+ }, { emitEvent: false });
2905
+ const field = getFormFieldByKey(this.formFields, e.key);
2906
+ this.formData[e.key] = convertFormFieldValueToStandardFormat(field, e.value);
2907
+ if (field.isFormElement &&
2908
+ checkObjectKeyExists(field, "validation") &&
2909
+ field.validation.triggers.includes("ON_CHANGE")) {
2910
+ const validations = new Validation({
2911
+ FIELD_CONFIG: field,
2912
+ FORM_FIELDS: this.formFields,
2913
+ FORM_DATA: this.formData,
2914
+ PREVIOUS_FORM_DATA: this.previousFormData,
2915
+ ALL_FORMS_DATA: this.allFormsData
2916
+ }, this.takeAction.bind(this));
2917
+ (() => __awaiter(this, void 0, void 0, function* () {
2918
+ yield validations.validate(field.validation);
2919
+ }))();
2920
+ }
2921
+ if (field.isFormElement &&
2922
+ checkObjectKeyExists(field, "connectedElements")) {
2923
+ this.handleConnectedElements({
2924
+ key: field.key,
2925
+ value: this.formGroup.controls[field.key].value
2926
+ }, "ON_CHANGE");
2927
+ }
2928
+ }
2929
+ handleOnClickResetFormFields(e, field) {
2930
+ return __awaiter(this, void 0, void 0, function* () {
2931
+ for (let f of field.reset.fields) {
2932
+ for (let action of f.actions) {
2933
+ const resetField = getFormFieldByKey(this.formFields, action.props.fieldKey);
2934
+ const actions = new Action(action, {}, {
2935
+ FIELD_CONFIG: resetField,
2936
+ FORM_FIELDS: this.formFields,
2937
+ FORM_DATA: this.formData,
2938
+ PREVIOUS_FORM_DATA: this.previousFormData,
2939
+ ALL_FORMS_DATA: this.allFormsData
2940
+ }, this.takeAction.bind(this));
2941
+ yield actions.execute();
3311
2942
  }
3312
2943
  }
3313
- this.removeFieldKey(field, "connectedTo");
3314
- if (checkObjectKeyExists(field, "connectedToParent")) {
3315
- if (typeof field["connectedToParent"] === "string") {
3316
- field["connectedParentFields"] = [
3317
- getConnectedelementTypeValueObject(field["connectedToParent"])
3318
- ];
2944
+ });
2945
+ }
2946
+ handleOnClickApiCall(e) {
2947
+ var _a, _b, _c, _d, _e, _f, _g;
2948
+ return __awaiter(this, void 0, void 0, function* () {
2949
+ let field = getFormFieldByKey(this.formFields, e.key);
2950
+ if (field.type === "api-call") {
2951
+ // set button status to loading
2952
+ field["api"]["status"]["value"] = EApiStatusType.LOADING;
2953
+ field["showLoader"] = true;
2954
+ this.viewFormsButton["disabled"] = true;
2955
+ this.viewFormsButton["showLoader"] = true;
2956
+ this.saveFormButton["disabled"] = true;
2957
+ this.saveFormButton["showLoader"] = true;
2958
+ const apis = new Apis({
2959
+ FIELD_CONFIG: field,
2960
+ FORM_FIELDS: this.formFields,
2961
+ FORM_DATA: this.formData,
2962
+ PREVIOUS_FORM_DATA: this.previousFormData,
2963
+ ALL_FORMS_DATA: this.allFormsData
2964
+ }, this.takeAction.bind(this));
2965
+ field = yield apis.setRequestHeaders();
2966
+ field = yield apis.validateRequestHeaders();
2967
+ field = yield apis.setRequestBody();
2968
+ field = yield apis.validateRequestBody();
2969
+ if (field.api.request.body.validation.is_valid) {
2970
+ // Call API Here
2971
+ let apiCallResponse = undefined;
2972
+ if (field.api.request.url.hasOwnProperty("type") &&
2973
+ field.api.request.url.type === "MOCK") {
2974
+ apiCallResponse = field.api.request.url.data;
2975
+ }
2976
+ else {
2977
+ const url = field.api.request.url;
2978
+ const method = (_b = (_a = field.api.request) === null || _a === void 0 ? void 0 : _a.method) !== null && _b !== void 0 ? _b : "POST";
2979
+ const headers = Object.assign({ "Content-Type": "application/json" }, (((_d = (_c = field.api.request) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d.value) || {}));
2980
+ const body = (_g = (_f = (_e = field.api.request) === null || _e === void 0 ? void 0 : _e.body) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : null;
2981
+ const response = yield fetch(url, {
2982
+ method: method,
2983
+ headers: Object.assign({}, headers),
2984
+ body: JSON.stringify(body)
2985
+ });
2986
+ apiCallResponse = yield response.json();
2987
+ }
2988
+ this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: apiCallResponse });
2989
+ this.formGroup.patchValue({
2990
+ [field.key]: apiCallResponse
2991
+ }, { emitEvent: false });
2992
+ const apis = new Apis({
2993
+ FIELD_CONFIG: field,
2994
+ FORM_FIELDS: this.formFields,
2995
+ FORM_DATA: this.formData,
2996
+ PREVIOUS_FORM_DATA: this.previousFormData,
2997
+ ALL_FORMS_DATA: this.allFormsData
2998
+ }, this.takeAction.bind(this));
2999
+ (() => __awaiter(this, void 0, void 0, function* () {
3000
+ field = yield apis.validateResponse();
3001
+ }))();
3319
3002
  }
3320
3003
  else {
3321
- field["connectedParentFields"] = getConnectedelementTypeValueObject(field["connectedToParent"]);
3004
+ // Request Body Validation Failed
3005
+ // Highlight Error in UI to User to Retry After Sometime.
3006
+ // Take Action based on Validation
3007
+ setTimeout(() => {
3008
+ field["api"]["status"]["value"] = EApiStatusType.FAILED;
3009
+ field["showLoader"] = false;
3010
+ }, 500);
3322
3011
  }
3012
+ this.viewFormsButton["disabled"] = false;
3013
+ this.viewFormsButton["showLoader"] = false;
3014
+ this.saveFormButton["disabled"] = false;
3015
+ this.saveFormButton["showLoader"] = false;
3323
3016
  }
3324
- this.removeFieldKey(field, "connectedToParent");
3325
- this.removeFieldKey(field, "sideEffect");
3326
- return field;
3327
- };
3328
- const getConnectedElementFieldMapping = (field, connectedFieldMapping) => {
3329
- const getConnectedElementChildFieldMapping = (field, connectedFieldMapping) => {
3330
- if (checkObjectKeyExists(field, "connectedElements")) {
3331
- connectedFieldMapping["child"][field.key] = field.connectedElements;
3332
- }
3333
- else if (checkObjectKeyExists(connectedFieldMapping["child"], field.key)) {
3334
- field["connectedElements"] =
3335
- connectedFieldMapping["child"][field.key];
3336
- }
3337
- return { field: field, connectedFieldMapping: connectedFieldMapping };
3338
- };
3339
- const getConnectedElementParentFieldMapping = (field, connectedFieldMapping) => {
3340
- if (checkObjectKeyExists(connectedFieldMapping["child"], field.key)) {
3341
- for (let connectedParentKey of connectedFieldMapping["child"][field.key]) {
3342
- if (checkObjectKeyExists(connectedFieldMapping["parent"], connectedParentKey["key"])) {
3343
- connectedFieldMapping["parent"][connectedParentKey["key"]].push(field.key);
3344
- }
3345
- else {
3346
- connectedFieldMapping["parent"][connectedParentKey["key"]] = [
3347
- field.key
3348
- ];
3349
- }
3017
+ });
3018
+ }
3019
+ /**
3020
+ * Method to optimize the DOM update by Angular for using *ngFor on large no. of items.
3021
+ * @param index number
3022
+ * @param item fieldConfig
3023
+ * @returns string
3024
+ */
3025
+ getUniqueIdentifier(index, item) {
3026
+ return item.key;
3027
+ }
3028
+ handleOnClickViewForms(e) {
3029
+ this.onClickViewForms.emit({
3030
+ clicked: true
3031
+ });
3032
+ }
3033
+ handleOnClickSaveForm(e) {
3034
+ return __awaiter(this, void 0, void 0, function* () {
3035
+ let formData = this.formGroup.getRawValue();
3036
+ for (let field of this.formFields) {
3037
+ if (field.isFormElement) {
3038
+ if (field.hidden) {
3039
+ delete formData[field.key];
3040
+ }
3041
+ else {
3042
+ formData[field.key] = convertFormFieldValueToStandardFormat(field, formData[field.key]);
3350
3043
  }
3351
3044
  }
3352
- return { field: field, connectedFieldMapping: connectedFieldMapping };
3353
- };
3354
- const connectedChildFieldMapping = getConnectedElementChildFieldMapping(field, connectedFieldMapping);
3355
- field = connectedChildFieldMapping["field"];
3356
- connectedFieldMapping =
3357
- connectedChildFieldMapping["connectedFieldMapping"];
3358
- const connectedParentFieldMapping = getConnectedElementParentFieldMapping(field, connectedFieldMapping);
3359
- field = connectedParentFieldMapping["field"];
3360
- connectedFieldMapping =
3361
- connectedParentFieldMapping["connectedFieldMapping"];
3362
- return connectedFieldMapping;
3363
- };
3364
- const updateConnectedElementsKeyValue = (field, connectedFieldMapping) => {
3365
- if (checkObjectKeyExists(connectedFieldMapping["child"], field.key)) {
3366
- field["connectedElements"] = connectedFieldMapping["child"][field.key];
3367
- }
3368
- if (checkObjectKeyExists(connectedFieldMapping["parent"], field.key)) {
3369
- field["connectedParentFields"] =
3370
- connectedFieldMapping["parent"][field.key];
3371
3045
  }
3372
- return field;
3373
- };
3374
- const updateFieldValidatorConfig = (field) => {
3375
- var _a, _b, _c, _d, _e;
3376
- if (field.isFormElement) {
3377
- const validators = checkObjectKeyExists(field, "validators")
3378
- ? field.validators
3379
- : {};
3380
- field = this.setMissingFieldKeyValue(field, "validators", {});
3381
- field = this.setFieldKeyValue(field, "validators", Object.assign(Object.assign({}, field["validators"]), { min: checkObjectKeyExists(validators, "min")
3382
- ? isNotEmptyValue(validators.min)
3383
- ? Number(validators.min)
3384
- : null
3385
- : checkObjectKeyExists(field, "min")
3386
- ? Number(field.min)
3387
- : null, max: checkObjectKeyExists(validators, "max")
3388
- ? isNotEmptyValue(validators.max)
3389
- ? Number(validators.max)
3390
- : null
3391
- : checkObjectKeyExists(field, "max")
3392
- ? Number(field.max)
3393
- : null, required: checkObjectKeyExists(validators, "required")
3394
- ? Boolean(validators.required)
3395
- : checkObjectKeyExists(field, "required")
3396
- ? Boolean(field.required)
3397
- : false, minLength: checkObjectKeyExists(validators, "minLength")
3398
- ? isNotEmptyValue(validators.minLength)
3399
- ? Number(validators.minLength)
3400
- : null
3401
- : checkObjectKeyExists(field, "minLength")
3402
- ? Number(field.minLength)
3403
- : null, maxLength: checkObjectKeyExists(validators, "maxLength")
3404
- ? isNotEmptyValue(validators.maxLength)
3405
- ? Number(validators.maxLength)
3406
- : null
3407
- : checkObjectKeyExists(field, "length")
3408
- ? Number(field.length)
3409
- : checkObjectKeyExists(field, "maxLength")
3410
- ? Number(field.maxLength)
3411
- : null, pattern: checkObjectKeyExists(validators, "pattern")
3412
- ? isNotEmptyValue(validators.pattern)
3413
- ? validators.pattern
3414
- : undefined
3415
- : checkObjectKeyExists(field, "pattern")
3416
- ? { key: "CUSTOM", pattern: String(field.pattern) }
3417
- : checkObjectKeyExists(field, "regex")
3418
- ? { key: "CUSTOM", pattern: String(field.regex) }
3419
- : undefined }));
3420
- delete field.min;
3421
- delete field.max;
3422
- delete field.required;
3423
- delete field.minLength;
3424
- delete field.length;
3425
- delete field.maxLength;
3426
- delete field.pattern;
3427
- delete field.regex;
3428
- switch (field.type) {
3429
- case "text":
3430
- delete field.validators.min;
3431
- delete field.validators.max;
3432
- break;
3433
- default:
3434
- break;
3435
- }
3436
- if (isEmptyValue((_a = field.validators) === null || _a === void 0 ? void 0 : _a.min)) {
3437
- delete field.validators.min;
3438
- }
3439
- if (isEmptyValue((_b = field.validators) === null || _b === void 0 ? void 0 : _b.max)) {
3440
- delete field.validators.min;
3441
- }
3442
- if (isEmptyValue((_c = field.validators) === null || _c === void 0 ? void 0 : _c.minLength)) {
3443
- delete field.validators.minLength;
3046
+ if (this.formGroup.invalid) {
3047
+ const controls = new FormValidation().getFormFieldsInvalidControls(this.formGroup);
3048
+ let firstFieldWithError = "";
3049
+ for (let control of controls) {
3050
+ if (control.invalid && isEmptyValue(firstFieldWithError)) {
3051
+ firstFieldWithError = control.key;
3052
+ }
3053
+ this.formFields = showFormFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
3444
3054
  }
3445
- if (isEmptyValue((_d = field.validators) === null || _d === void 0 ? void 0 : _d.maxLength)) {
3446
- delete field.validators.maxLength;
3055
+ this.toggleErrorNotification(true);
3056
+ setTimeout(() => {
3057
+ this.toggleErrorNotification(false);
3058
+ }, 3000);
3059
+ return;
3060
+ }
3061
+ for (let field of this.formFields) {
3062
+ if (field.isFormElement &&
3063
+ checkObjectKeyExists(field, "validation") &&
3064
+ field.validation.triggers.includes("ON_SAVE")) {
3065
+ const validations = new Validation({
3066
+ FIELD_CONFIG: field,
3067
+ FORM_FIELDS: this.formFields,
3068
+ FORM_DATA: this.formData,
3069
+ PREVIOUS_FORM_DATA: this.previousFormData,
3070
+ ALL_FORMS_DATA: this.allFormsData
3071
+ }, this.takeAction.bind(this));
3072
+ yield validations.validate(field.validation);
3073
+ if (!field.validation.is_valid) {
3074
+ this.toggleErrorNotification(true);
3075
+ setTimeout(() => {
3076
+ this.toggleErrorNotification(false);
3077
+ }, 3000);
3078
+ return;
3079
+ }
3447
3080
  }
3448
- if (isEmptyValue((_e = field.validators) === null || _e === void 0 ? void 0 : _e.pattern)) {
3449
- delete field.validators.pattern;
3081
+ }
3082
+ Object.keys(formData).map((key) => {
3083
+ if (isEmptyValue(formData[key])) {
3084
+ formData[key] = "";
3450
3085
  }
3086
+ });
3087
+ this.onClickSaveForm.emit({ formConfig: this.formConfig, data: formData });
3088
+ });
3089
+ }
3090
+ toggleErrorNotification(show) {
3091
+ this.showErrorNotification = show;
3092
+ }
3093
+ // Component Helpers
3094
+ fieldHide(fieldKey) {
3095
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3096
+ let fieldIndex = this.formFields.findIndex((_) => {
3097
+ return field.key === _.key;
3098
+ });
3099
+ this.formFields[fieldIndex]["hidden"] = true;
3100
+ this.formGroup.updateValueAndValidity();
3101
+ }
3102
+ fieldGroupHide(fieldGroup) {
3103
+ for (let fieldKey of this.fieldGroups[fieldGroup]) {
3104
+ this.fieldHide(fieldKey);
3105
+ }
3106
+ }
3107
+ fieldShow(fieldKey) {
3108
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3109
+ let fieldIndex = this.formFields.findIndex((_) => {
3110
+ return field.key === _.key;
3111
+ });
3112
+ this.formFields[fieldIndex]["hidden"] = false;
3113
+ this.formGroup.updateValueAndValidity();
3114
+ }
3115
+ fieldGroupShow(fieldGroup) {
3116
+ for (let fieldKey of this.fieldGroups[fieldGroup]) {
3117
+ this.fieldShow(fieldKey);
3118
+ }
3119
+ }
3120
+ fieldDisable(fieldKey) {
3121
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3122
+ let fieldIndex = this.formFields.findIndex((_) => {
3123
+ return field.key === _.key;
3124
+ });
3125
+ if (field.isFormElement) {
3126
+ this.formFields[fieldIndex]["disabled"] = true;
3127
+ if (isNotEmptyValue(this.formGroup.controls)) {
3128
+ this.formGroup.controls[field.key].disable({
3129
+ emitEvent: false
3130
+ });
3131
+ }
3132
+ this.formGroup.updateValueAndValidity();
3133
+ }
3134
+ }
3135
+ fieldGroupDisable(fieldGroup) {
3136
+ for (let fieldKey of this.fieldGroups[fieldGroup]) {
3137
+ this.fieldDisable(fieldKey);
3138
+ }
3139
+ }
3140
+ fieldEnable(fieldKey) {
3141
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3142
+ let fieldIndex = this.formFields.findIndex((_) => {
3143
+ return field.key === _.key;
3144
+ });
3145
+ if (field.isFormElement) {
3146
+ this.formFields[fieldIndex]["disabled"] = false;
3147
+ if (isNotEmptyValue(this.formGroup.controls)) {
3148
+ this.formGroup.controls[field.key].enable({
3149
+ emitEvent: false
3150
+ });
3151
+ }
3152
+ this.formGroup.updateValueAndValidity();
3153
+ }
3154
+ }
3155
+ fieldGroupEnable(fieldGroup) {
3156
+ for (let fieldKey of this.fieldGroups[fieldGroup]) {
3157
+ this.fieldEnable(fieldKey);
3158
+ }
3159
+ }
3160
+ fieldReset(fieldKey) {
3161
+ // Find the field and its index in the formFields array
3162
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3163
+ let fieldIndex = getFormFieldIndexByKey(this.formFields, fieldKey);
3164
+ // Reset the value of the field in the formGroup
3165
+ const resetValue = convertFormFieldEmptyValueToKwikUIFormat(field);
3166
+ this.formData[fieldKey] = resetValue;
3167
+ this.formGroup.controls[field.key].reset(resetValue, {
3168
+ emitEvent: false,
3169
+ onlySelf: true
3170
+ });
3171
+ this.formGroup.patchValue({
3172
+ [field.key]: resetValue
3173
+ }, { emitEvent: false });
3174
+ this.formGroup.controls[field.key].updateValueAndValidity({
3175
+ emitEvent: true
3176
+ });
3177
+ // Reset the messages and errors for the field
3178
+ field = removeFormFieldMessage(field, {
3179
+ type: EMessageType.WARNING,
3180
+ message: ""
3181
+ });
3182
+ field = removeFormFieldMessage(field, {
3183
+ type: EMessageType.SUCCESS,
3184
+ message: ""
3185
+ });
3186
+ this.fieldErrorHide(fieldKey, {
3187
+ type: EMessageType.ERROR,
3188
+ message: ""
3189
+ });
3190
+ // Reset the value of the field in the formFields array
3191
+ switch (field.type) {
3192
+ case "api-call":
3193
+ const fieldApiCall = field;
3194
+ fieldApiCall.api.status.value = EApiStatusType.DEFAULT;
3195
+ this.formFields[fieldIndex] = fieldApiCall;
3196
+ break;
3197
+ default:
3451
3198
  field.focus = false;
3452
3199
  field.invalid = false;
3453
- }
3454
- return field;
3455
- };
3456
- const updateFieldDefaultValueConfig = (field) => {
3457
- if (field.isFormElement) {
3458
- if (checkObjectKeyExists(field, "defaultValue")) {
3459
- return field;
3460
- }
3461
- else if (checkObjectKeyExists(field, "default")) {
3462
- return field;
3463
- }
3464
- else {
3465
- if (checkObjectKeyExists(field, "defaultVal")) {
3466
- // Currently below line is commented because it caused issues in setting Default Value.
3467
- // field["defaultValue"] = field["defaultVal"];
3468
- // delete field["defaultVal"];
3469
- }
3470
- // TODO: Condition for all_forms_data is not considered yet.
3471
- if (field.autoPopulateFromSummaryData) {
3472
- field["defaultValue"] = {
3473
- is_found: false,
3474
- value: "",
3475
- sources: [
3476
- {
3477
- source: "summary_data",
3478
- summary_data: {
3479
- path: `$.${field.key}`,
3480
- validation: {
3481
- rules: [
3482
- {
3483
- key: "1",
3484
- type: "is_not_empty",
3485
- is_not_empty: {
3486
- value: true
3487
- }
3488
- }
3489
- ],
3490
- actions: [
3491
- {
3492
- type: "set_default_value_found",
3493
- condition: "1",
3494
- set_default_value_found: {
3495
- value: true
3496
- }
3497
- },
3498
- {
3499
- type: "enable_field",
3500
- condition: "1 OR NOT(1)",
3501
- enable_field: { value: true }
3502
- }
3503
- ]
3504
- }
3505
- }
3506
- }
3507
- ]
3508
- };
3509
- }
3510
- else if (checkObjectKeyExists(field, "autofill")) {
3511
- if (checkObjectKeyExists(field.autofill, "type")) {
3512
- if (field.autofill.type === "storage") {
3513
- field["defaultValue"] = {
3514
- is_found: false,
3515
- value: "",
3516
- sources: [
3517
- {
3518
- source: "browser_storage",
3519
- browser_storage: {
3520
- path: `$.${field.key}`,
3521
- validation: {
3522
- rules: [
3523
- {
3524
- key: "1",
3525
- type: "is_not_empty",
3526
- is_not_empty: {
3527
- value: true
3528
- }
3529
- }
3530
- ],
3531
- actions: [
3532
- {
3533
- type: "set_default_value_found",
3534
- condition: "1",
3535
- set_default_value_found: {
3536
- value: true
3537
- }
3538
- },
3539
- {
3540
- type: "enable_field",
3541
- condition: "1 OR NOT(1)",
3542
- enable_field: { value: true }
3543
- }
3544
- ]
3545
- }
3546
- }
3547
- }
3548
- ]
3549
- };
3200
+ this.formFields[fieldIndex] = field;
3201
+ break;
3202
+ }
3203
+ }
3204
+ fieldErrorShow(fieldKey, message) {
3205
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3206
+ let fieldIndex = this.formFields.findIndex((_) => {
3207
+ return field.key === _.key;
3208
+ });
3209
+ field = highlightFormFieldError(field, true);
3210
+ field = appendFormFieldMessage(field, message);
3211
+ this.formFields[fieldIndex] = field;
3212
+ }
3213
+ fieldErrorHide(fieldKey, message) {
3214
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3215
+ let fieldIndex = this.formFields.findIndex((_) => {
3216
+ return field.key === _.key;
3217
+ });
3218
+ field = highlightFormFieldError(field, false);
3219
+ field = removeFormFieldMessage(field, message);
3220
+ this.formFields[fieldIndex] = field;
3221
+ }
3222
+ fieldMessageShow(fieldKey, message) {
3223
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3224
+ let fieldIndex = this.formFields.findIndex((_) => {
3225
+ return field.key === _.key;
3226
+ });
3227
+ field = appendFormFieldMessage(field, message);
3228
+ this.formFields[fieldIndex] = field;
3229
+ }
3230
+ fieldMessageHide(fieldKey, message) {
3231
+ let field = getFormFieldByKey(this.formFields, fieldKey);
3232
+ let fieldIndex = this.formFields.findIndex((_) => {
3233
+ return field.key === _.key;
3234
+ });
3235
+ field = removeFormFieldMessage(field, message);
3236
+ this.formFields[fieldIndex] = field;
3237
+ }
3238
+ setObjectValue(field, path, value) { }
3239
+ patchFieldControlValue(key, value) {
3240
+ this.formGroup.patchValue({
3241
+ [key]: value
3242
+ }, { emitEvent: false });
3243
+ }
3244
+ patchFormGroup(formData) {
3245
+ if (isUndefined(this.formGroup) || isUndefined(formData)) {
3246
+ throw new Error(`formGroup or formData is 'undefined'.`);
3247
+ }
3248
+ else {
3249
+ this.formGroup.patchValue(formData, { emitEvent: false });
3250
+ }
3251
+ }
3252
+ isFieldValid(fieldKey) {
3253
+ return this.formGroup.controls[fieldKey].valid;
3254
+ }
3255
+ isFieldEnabled(fieldKey) {
3256
+ return this.formGroup.controls[fieldKey].enabled;
3257
+ }
3258
+ getFormGroupRawValues() {
3259
+ return this.formGroup.getRawValue();
3260
+ }
3261
+ takeActionOnFieldGroup(action, object) {
3262
+ return __awaiter(this, void 0, void 0, function* () {
3263
+ switch (action.key) {
3264
+ case EActionKey.FIELD_GROUP_HIDE:
3265
+ this.fieldGroupHide(action.props.groupKey);
3266
+ break;
3267
+ case EActionKey.FIELD_GROUP_SHOW:
3268
+ this.fieldGroupShow(action.props.groupKey);
3269
+ break;
3270
+ case EActionKey.FIELD_GROUP_ENABLE:
3271
+ this.fieldGroupEnable(action.props.groupKey);
3272
+ break;
3273
+ case EActionKey.FIELD_GROUP_DISABLE:
3274
+ this.fieldGroupDisable(action.props.groupKey);
3275
+ break;
3276
+ default:
3277
+ break;
3278
+ }
3279
+ });
3280
+ }
3281
+ takeAction(action, object) {
3282
+ return __awaiter(this, void 0, void 0, function* () {
3283
+ switch (action.key) {
3284
+ case EActionKey.FIELD_HIDE:
3285
+ this.fieldHide(action.props.fieldKey);
3286
+ break;
3287
+ case EActionKey.FIELD_SHOW:
3288
+ this.fieldShow(action.props.fieldKey);
3289
+ break;
3290
+ case EActionKey.FIELD_DISABLE:
3291
+ this.fieldDisable(action.props.fieldKey);
3292
+ break;
3293
+ case EActionKey.FIELD_ENABLE:
3294
+ this.fieldEnable(action.props.fieldKey);
3295
+ break;
3296
+ case EActionKey.FIELD_RESET:
3297
+ this.fieldReset(action.props.fieldKey);
3298
+ break;
3299
+ case EActionKey.FIELD_ERROR_SHOW:
3300
+ this.fieldErrorShow(action.props.fieldKey, action.props.message);
3301
+ break;
3302
+ case EActionKey.FIELD_ERROR_HIDE:
3303
+ this.fieldErrorHide(action.props.fieldKey, action.props.message);
3304
+ break;
3305
+ case EActionKey.FIELD_MESSAGE_SHOW:
3306
+ this.fieldMessageShow(action.props.fieldKey, action.props.message);
3307
+ break;
3308
+ case EActionKey.FIELD_MESSAGES_HIDE:
3309
+ this.fieldMessageHide(action.props.fieldKey, action.props.message);
3310
+ break;
3311
+ case EActionKey.SET_VALUE:
3312
+ const setValue_Source = new Source(object);
3313
+ const sourceValue = yield setValue_Source.getValueFromSource(action.props.value.source);
3314
+ setValue_Source.setValueToSource(action.props.value.destination, sourceValue);
3315
+ object.FIELD_CONFIG = setValue_Source.object.FIELD_CONFIG;
3316
+ this.formData = setValue_Source.object.FORM_DATA;
3317
+ this.patchFormGroup(this.formData);
3318
+ this.allFormsData = setValue_Source.object.ALL_FORMS_DATA;
3319
+ this.previousFormData = setValue_Source.object.PREVIOUS_FORM_DATA;
3320
+ break;
3321
+ case EActionKey.SET_FIELD_DEFAULT_VALUE:
3322
+ const setDefaultValue_Source = new Source(object);
3323
+ const sourceDefaultValue = yield setDefaultValue_Source.getValueFromSource(action.props.value.source);
3324
+ const destinationDefaultValue_FieldConfig_Config = {
3325
+ key: ESourceKey.OBJECT,
3326
+ props: {
3327
+ object: {
3328
+ key: "FIELD_CONFIG",
3329
+ path: "default.value.value"
3550
3330
  }
3551
- else if (field.autofill.type === "config") {
3552
- field["defaultValue"] = {
3553
- is_found: false,
3554
- value: "",
3555
- sources: [
3556
- {
3557
- source: "field_config",
3558
- field_config: {
3559
- path: `$.${field.key}`,
3560
- validation: {
3561
- rules: [
3562
- {
3563
- key: "1",
3564
- type: "is_not_empty",
3565
- is_not_empty: {
3566
- value: true
3567
- }
3568
- }
3569
- ],
3570
- actions: [
3571
- {
3572
- type: "set_default_value_found",
3573
- condition: "1",
3574
- set_default_value_found: {
3575
- value: true
3576
- }
3577
- },
3578
- {
3579
- type: "enable_field",
3580
- condition: "1 OR NOT(1)",
3581
- enable_field: { value: true }
3582
- }
3583
- ]
3584
- }
3585
- }
3586
- }
3587
- ]
3588
- };
3331
+ }
3332
+ };
3333
+ setDefaultValue_Source.setValueToSource(destinationDefaultValue_FieldConfig_Config, sourceDefaultValue);
3334
+ const destinationDefaultValue_FormData_Config__Props__Object__Path = String(`${action.props.fieldKey}`);
3335
+ const destinationDefaultValue_FormData_Config = {
3336
+ key: ESourceKey.OBJECT,
3337
+ props: {
3338
+ object: {
3339
+ key: "FORM_DATA",
3340
+ path: String(action.props.fieldKey)
3589
3341
  }
3590
3342
  }
3343
+ };
3344
+ setDefaultValue_Source.setValueToSource(destinationDefaultValue_FormData_Config, sourceDefaultValue);
3345
+ object.FIELD_CONFIG = setDefaultValue_Source.object.FIELD_CONFIG;
3346
+ this.formData = setDefaultValue_Source.object.FORM_DATA;
3347
+ this.patchFormGroup(this.formData);
3348
+ this.allFormsData = setDefaultValue_Source.object.ALL_FORMS_DATA;
3349
+ this.previousFormData =
3350
+ setDefaultValue_Source.object.PREVIOUS_FORM_DATA;
3351
+ break;
3352
+ case EActionKey.SET_DROPDOWN_OPTIONS:
3353
+ const setDropdownValue_Sources = new Source(object);
3354
+ let dropdownValue = yield setDropdownValue_Sources.getValueFromSource(action.props.value.source);
3355
+ if (checkObjectKeyExists(action.props, "options")) {
3356
+ if (checkObjectKeyExists(action.props.options, "appendToPath")) {
3357
+ let appendToPath = yield setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source);
3358
+ if (isNotEmptyValue(appendToPath)) {
3359
+ const appendToPathStr = replaceString(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
3360
+ const optionsPath = `${action.props.options.path}${appendToPathStr}`;
3361
+ dropdownValue = getObjectValueFromPath(dropdownValue, optionsPath);
3362
+ }
3363
+ }
3364
+ else {
3365
+ dropdownValue = getObjectValueFromPath(dropdownValue, action.props.options.path);
3366
+ }
3367
+ }
3368
+ setDropdownValue_Sources.setValueToSource(action.props.value.destination, dropdownValue);
3369
+ object.FIELD_CONFIG = setDropdownValue_Sources.object.FIELD_CONFIG;
3370
+ this.formData = setDropdownValue_Sources.object.FORM_DATA;
3371
+ this.allFormsData = setDropdownValue_Sources.object.ALL_FORMS_DATA;
3372
+ this.previousFormData =
3373
+ setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
3374
+ break;
3375
+ case EActionKey.HANDLE_CONNECTED_ELEMENTS:
3376
+ this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
3377
+ break;
3378
+ case EActionKey.CUSTOM:
3379
+ break;
3380
+ default:
3381
+ break;
3382
+ }
3383
+ });
3384
+ }
3385
+ }
3386
+ /** @nocollapse */ KwikIDFormViewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewComponent, deps: [{ token: TuiPushService }, { token: TuiAlertService }, { token: KwikIDFormViewService }], target: i0.ɵɵFactoryTarget.Component });
3387
+ /** @nocollapse */ KwikIDFormViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: { formConfig: "formConfig", formData: "formData", isMobileView: "isMobileView", allFormsData: "allFormsData" }, outputs: { onClickViewForms: "onClickViewForms", onClickSaveForm: "onClickSaveForm", onClickApiCall: "onClickApiCall" }, providers: [KwikIDFormViewService], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"kwikid-form-container\"\n *ngIf=\"!loading\"\n>\n <div\n id=\"uf-form-fields-header-container\"\n *ngIf=\"\n !formConfig.properties.header.title.hidden ||\n !formConfig.properties.header.steps.hidden\n \"\n >\n <div\n id=\"uf-form-fields-title\"\n *ngIf=\"!formConfig.properties.header.title.hidden\"\n >{{ formConfig.properties.header.title.label }}</div\n >\n <div\n id=\"uf-form-fields-steps\"\n *ngIf=\"!formConfig.properties.header.steps.hidden\"\n >Step {{ formConfig.sequenceNo }} of {{ formConfig.formsListLength }}</div\n >\n <hr\n *ngIf=\"\n !formConfig.properties.header.title.hidden &&\n !formConfig.properties.header.steps.hidden\n \"\n />\n </div>\n <form\n class=\"kwikid-form show\"\n [formGroup]=\"formGroup\"\n >\n <ng-container\n *ngFor=\"\n let field of formFields;\n let i = index;\n trackBy: getUniqueIdentifier\n \"\n >\n <ng-container [ngSwitch]=\"field.type\">\n <!-- HTML Content -->\n <ng-container *ngSwitchCase=\"'html'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div [innerHtml]=\"field.html | safeHtml\"></div>\n </div>\n </ng-container>\n <!-- Form Title -->\n <ng-container *ngSwitchCase=\"'title'\">\n <div\n class=\"title\"\n [class.hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div>\n {{ field.label }}\n </div>\n <kwikui-button\n *ngIf=\"field?.reset\"\n appearance=\"whiteblock\"\n size=\"s\"\n label=\"Reset\"\n (onClick)=\"handleOnClickResetFormFields($event, field)\"\n ></kwikui-button>\n </div>\n </ng-container>\n <!-- Input Text -->\n <ng-container *ngSwitchCase=\"'text'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input\n [case]=\"field?.properties?.case\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [placeholder]=\"field?.properties?.placeholder\"\n [type]=\"'text'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Checkbox -->\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-checkbox-block\n [contentAlign]=\"field?.properties?.contentAlign ?? 'left'\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.properties?.placeholder\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size ?? 'l'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-checkbox-block>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Number -->\n <ng-container *ngSwitchCase=\"'number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-number\n [decimal]=\"field?.properties?.decimal\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [postfix]=\"field?.properties?.postfix ?? ''\"\n [precision]=\"field?.properties?.precision\"\n [prefix]=\"field?.properties?.prefix ?? ''\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-number>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Date -->\n <ng-container *ngSwitchCase=\"'date'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-date\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-date>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Phone -->\n <ng-container *ngSwitchCase=\"'phone'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-phone\n [countryCode]=\"field?.properties?.countryCode\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [phoneMaskAfterCountryCode]=\"\n field?.properties?.phoneMaskAfterCountryCode\n \"\n [removeCountryCodeFromValue]=\"\n field?.properties?.removeCountryCodeFromValue\n \"\n [placeholder]=\"field?.properties?.placeholder\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-phone>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Radio -->\n <ng-container *ngSwitchCase=\"'radio'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <label\n [tuiLabel]=\"labelTemplate\"\n style=\"min-height: auto; padding: 0px 0.5rem\"\n >\n <kwikui-radio-list\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [items]=\"field?.options\"\n [label]=\"field?.label\"\n [orientation]=\"field?.properties?.orientation\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-radio-list>\n </label>\n <ng-template #labelTemplate>\n <p\n class=\"tui-space_bottom-2\"\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <b>\n {{ field.label }}\n <span *ngIf=\"field.validators?.required\"></span>\n </b>\n </p>\n </ng-template>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Dropdown -->\n <ng-container *ngSwitchCase=\"'dropdown-with-search'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-select-combobox\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [options]=\"field.options\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-select-combobox>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- API Call -->\n <ng-container *ngSwitchCase=\"'api-call'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-button-api-call\n [apiStatus]=\"field?.api?.status?.value\"\n [class]=\"field?.class\"\n [disabled]=\"field?.disabled\"\n [id]=\"field.key\"\n [label]=\"field?.api?.status?.labels[field?.api?.status?.value]\"\n [showLoader]=\"field?.disabled === 'loading'\"\n shape=\"null\"\n size=\"m\"\n styles=\"width: fit-content\"\n (onClick)=\"handleOnClickApiCall($event)\"\n ></kwikui-button-api-call>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Mobile OTP -->\n <ng-container *ngSwitchCase=\"'otp'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-otp\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [mask]=\"field?.properties?.mask\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-otp>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Aadhaar Number -->\n <ng-container *ngSwitchCase=\"'aadhaar-number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-aadhaar\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [placeholder]=\"field?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-aadhaar>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n </form>\n <div class=\"kwikid-form-buttons\">\n <kwikui-button\n *ngIf=\"\n !formConfig.properties.footer.viewFormsButton.hidden && isMobileView\n \"\n [disabled]=\"viewFormsButton.disabled\"\n id=\"\"\n label=\"{{ formConfig.properties.footer.viewFormsButton.label }}\"\n [showLoader]=\"viewFormsButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"secondary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"handleOnClickViewForms($event)\"\n ></kwikui-button>\n <kwikui-button\n *ngIf=\"!formConfig.properties.footer.saveButton.hidden\"\n [disabled]=\"saveFormButton.disabled\"\n id=\"\"\n label=\"{{ formConfig.properties.footer.saveButton.label }}\"\n [showLoader]=\"saveFormButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"primary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"handleOnClickSaveForm($event)\"\n ></kwikui-button>\n </div>\n</div>\n<div\n class=\"kwikid-form-container-loading\"\n *ngIf=\"loading\"\n>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"loading\"\n [class.tui-skeleton_rounded]=\"loading\"\n ></div>\n</div>\n<tui-push\n id=\"field-error-notification\"\n *tuiPush=\"showErrorNotification\"\n heading=\"Missing/Incorrect Fields!\"\n type=\"Error\"\n (close)=\"toggleErrorNotification(false)\"\n>\n <tui-svg\n src=\"tuiIconCancel\"\n style=\"color: #fff !important\"\n >\n </tui-svg>\n</tui-push>\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{border-radius:10px}::-webkit-scrollbar-thumb{background:lightgray;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:gray}.kwikid-form-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}.kwikid-form.show{width:100%;height:100%;padding:1rem;overflow-y:auto;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch;grid-row-gap:1rem;row-gap:1rem}.kwikid-form-buttons{width:100%;bottom:0px;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-column-gap:10px;column-gap:10px}.kwikid-form-buttons *{flex-grow:1}#uf-form-fields-header-container{display:flex;flex-direction:column;align-content:center;justify-content:center;align-items:flex-start;grid-row-gap:.5rem;row-gap:.5rem;padding:1rem}#uf-form-fields-header-container hr{width:100%}#uf-form-fields-title{color:#000;font-size:1.75em;font-weight:bold}#uf-form-fields-steps{color:var(--color-on-secondary-container);font-size:1em}.title{border-left:.25rem solid var(--tui-primary);padding:.75rem;font-size:1.4em;font-weight:bold;background-color:var(--tui-secondary);display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-gap:.5rem;gap:.5rem}.title:not(:first-child){margin-top:.5rem}.title.hidden{display:none}.large-wrapper{width:100%;height:60px}.large-wrapper:first-child{margin-bottom:auto}.large-wrapper:last-child{margin-top:auto}.kwikid-form-container-loading{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;grid-row-gap:1rem;row-gap:1rem;padding:1rem}#field-error-notification{background-color:var(--tui-error-fill);color:#fff!important}#field-error-notification .t-top{color:#fff!important}#field-error-notification .t-close{color:#fff!important}\n"], components: [{ type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }, { type: i2.KwikUIInputComponent, selector: "kwikui-input", inputs: ["label", "id", "type", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "validators", "case", "size", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIMessagesComponent, selector: "kwikui-messages", inputs: ["messages", "id"] }, { type: i2.KwikUICheckboxBlockComponent, selector: "kwikui-checkbox-block", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "contentAlign", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputNumberComponent, selector: "kwikui-input-number", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "prefix", "postfix", "precision", "decimal", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputDateComponent, selector: "kwikui-input-date", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputPhoneComponent, selector: "kwikui-input-phone", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "countryCode", "phoneMaskAfterCountryCode", "removeCountryCodeFromValue", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i3$1.TuiLabelComponent, selector: "label[tuiLabel]", inputs: ["tuiLabel", "context"] }, { type: i2.KwikUIRadioListComponent, selector: "kwikui-radio-list", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "orientation", "items", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUISelectComboboxComponent, selector: "kwikui-select-combobox", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "options", "size", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIButtonApiCallComponent, selector: "kwikui-button-api-call", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "shape", "size", "apiStatus"], outputs: ["onClick"] }, { type: i2.KwikUIInputOtpComponent, selector: "kwikui-input-otp", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputAadhaarComponent, selector: "kwikui-input-aadhaar", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i4$1.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3$1.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["disabled", "formControl", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i4$1.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4$1.TuiPushDirective, selector: "tui-push" }], pipes: { "safeHtml": SafeHtmlPipe$1 } });
3388
+ __decorate([
3389
+ logMethod
3390
+ ], KwikIDFormViewComponent.prototype, "ngOnInit", null);
3391
+ __decorate([
3392
+ logMethod
3393
+ ], KwikIDFormViewComponent.prototype, "ngAfterViewInit", null);
3394
+ __decorate([
3395
+ logMethod
3396
+ ], KwikIDFormViewComponent.prototype, "ngOnChanges", null);
3397
+ __decorate([
3398
+ logMethod
3399
+ ], KwikIDFormViewComponent.prototype, "initFormConfig", null);
3400
+ __decorate([
3401
+ logMethod
3402
+ ], KwikIDFormViewComponent.prototype, "setFormFieldsFromFormConfig", null);
3403
+ __decorate([
3404
+ logMethod
3405
+ ], KwikIDFormViewComponent.prototype, "setFormFieldGroupsFromFormConfig", null);
3406
+ __decorate([
3407
+ logMethod
3408
+ ], KwikIDFormViewComponent.prototype, "setFormDataFromAllFormsData", null);
3409
+ __decorate([
3410
+ logMethod
3411
+ ], KwikIDFormViewComponent.prototype, "handleConnectedElementFieldGroupActions", null);
3412
+ __decorate([
3413
+ logMethod
3414
+ ], KwikIDFormViewComponent.prototype, "handleConnectedElementFieldGroup", null);
3415
+ __decorate([
3416
+ logMethod
3417
+ ], KwikIDFormViewComponent.prototype, "handleConnectedElementFieldActions", null);
3418
+ __decorate([
3419
+ logMethod
3420
+ ], KwikIDFormViewComponent.prototype, "handleConnectedElementFields", null);
3421
+ __decorate([
3422
+ logMethod
3423
+ ], KwikIDFormViewComponent.prototype, "handleConnectedElements", null);
3424
+ __decorate([
3425
+ logMethod
3426
+ ], KwikIDFormViewComponent.prototype, "handleGetKeyValue", null);
3427
+ __decorate([
3428
+ logMethod
3429
+ ], KwikIDFormViewComponent.prototype, "handleOnClickResetFormFields", null);
3430
+ __decorate([
3431
+ logMethod
3432
+ ], KwikIDFormViewComponent.prototype, "handleOnClickApiCall", null);
3433
+ __decorate([
3434
+ logMethod
3435
+ ], KwikIDFormViewComponent.prototype, "handleOnClickViewForms", null);
3436
+ __decorate([
3437
+ logMethod
3438
+ ], KwikIDFormViewComponent.prototype, "handleOnClickSaveForm", null);
3439
+ __decorate([
3440
+ logMethod
3441
+ ], KwikIDFormViewComponent.prototype, "toggleErrorNotification", null);
3442
+ __decorate([
3443
+ logMethod
3444
+ ], KwikIDFormViewComponent.prototype, "fieldHide", null);
3445
+ __decorate([
3446
+ logMethod
3447
+ ], KwikIDFormViewComponent.prototype, "fieldGroupHide", null);
3448
+ __decorate([
3449
+ logMethod
3450
+ ], KwikIDFormViewComponent.prototype, "fieldShow", null);
3451
+ __decorate([
3452
+ logMethod
3453
+ ], KwikIDFormViewComponent.prototype, "fieldGroupShow", null);
3454
+ __decorate([
3455
+ logMethod
3456
+ ], KwikIDFormViewComponent.prototype, "fieldDisable", null);
3457
+ __decorate([
3458
+ logMethod
3459
+ ], KwikIDFormViewComponent.prototype, "fieldGroupDisable", null);
3460
+ __decorate([
3461
+ logMethod
3462
+ ], KwikIDFormViewComponent.prototype, "fieldEnable", null);
3463
+ __decorate([
3464
+ logMethod
3465
+ ], KwikIDFormViewComponent.prototype, "fieldGroupEnable", null);
3466
+ __decorate([
3467
+ logMethod
3468
+ ], KwikIDFormViewComponent.prototype, "fieldReset", null);
3469
+ __decorate([
3470
+ logMethod
3471
+ ], KwikIDFormViewComponent.prototype, "fieldErrorShow", null);
3472
+ __decorate([
3473
+ logMethod
3474
+ ], KwikIDFormViewComponent.prototype, "fieldErrorHide", null);
3475
+ __decorate([
3476
+ logMethod
3477
+ ], KwikIDFormViewComponent.prototype, "fieldMessageShow", null);
3478
+ __decorate([
3479
+ logMethod
3480
+ ], KwikIDFormViewComponent.prototype, "fieldMessageHide", null);
3481
+ __decorate([
3482
+ logMethod
3483
+ ], KwikIDFormViewComponent.prototype, "setObjectValue", null);
3484
+ __decorate([
3485
+ logMethod
3486
+ ], KwikIDFormViewComponent.prototype, "patchFieldControlValue", null);
3487
+ __decorate([
3488
+ logMethod
3489
+ ], KwikIDFormViewComponent.prototype, "patchFormGroup", null);
3490
+ __decorate([
3491
+ logMethod
3492
+ ], KwikIDFormViewComponent.prototype, "isFieldValid", null);
3493
+ __decorate([
3494
+ logMethod
3495
+ ], KwikIDFormViewComponent.prototype, "isFieldEnabled", null);
3496
+ __decorate([
3497
+ logMethod
3498
+ ], KwikIDFormViewComponent.prototype, "getFormGroupRawValues", null);
3499
+ __decorate([
3500
+ logMethod
3501
+ ], KwikIDFormViewComponent.prototype, "takeActionOnFieldGroup", null);
3502
+ __decorate([
3503
+ logMethod
3504
+ ], KwikIDFormViewComponent.prototype, "takeAction", null);
3505
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewComponent, decorators: [{
3506
+ type: Component,
3507
+ args: [{
3508
+ selector: "kwikid-form-view",
3509
+ templateUrl: "./form-view.component.html",
3510
+ styleUrls: ["./form-view.component.scss"],
3511
+ providers: [KwikIDFormViewService]
3512
+ }]
3513
+ }], ctorParameters: function () { return [{ type: i4$1.TuiPushService, decorators: [{
3514
+ type: Inject,
3515
+ args: [TuiPushService]
3516
+ }] }, { type: i3$1.TuiAlertService, decorators: [{
3517
+ type: Inject,
3518
+ args: [TuiAlertService]
3519
+ }] }, { type: KwikIDFormViewService }]; }, propDecorators: { formConfig: [{
3520
+ type: Input
3521
+ }], formData: [{
3522
+ type: Input
3523
+ }], isMobileView: [{
3524
+ type: Input
3525
+ }], allFormsData: [{
3526
+ type: Input
3527
+ }], onClickViewForms: [{
3528
+ type: Output
3529
+ }], onClickSaveForm: [{
3530
+ type: Output
3531
+ }], onClickApiCall: [{
3532
+ type: Output
3533
+ }], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleOnClickApiCall: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setObjectValue: [], patchFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], takeActionOnFieldGroup: [], takeAction: [] } });
3534
+
3535
+ /**
3536
+ * Generated class for the SafeHtmlPipe pipe.
3537
+ *
3538
+ * See https://angular.io/api/core/Pipe for more info on Angular Pipes.
3539
+ */
3540
+ class SafeHtmlPipe {
3541
+ constructor(sanitizer) {
3542
+ this.sanitizer = sanitizer;
3543
+ }
3544
+ transform(html) {
3545
+ return this.sanitizer.bypassSecurityTrustHtml(html);
3546
+ }
3547
+ }
3548
+ /** @nocollapse */ SafeHtmlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
3549
+ /** @nocollapse */ SafeHtmlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, name: "safeHtml" });
3550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, decorators: [{
3551
+ type: Pipe,
3552
+ args: [{
3553
+ name: "safeHtml"
3554
+ }]
3555
+ }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
3556
+
3557
+ class KwikIDFormsListComponent {
3558
+ constructor() {
3559
+ this.showFormFields = {};
3560
+ this.userConfig = {};
3561
+ this.activeFormConfig = {};
3562
+ this.formsList = [];
3563
+ this.formsListCompleted = [];
3564
+ this.isMobileView = false;
3565
+ this.onClickSetActiveForm = new EventEmitter();
3566
+ this.onClickHideFormsList = new EventEmitter();
3567
+ this.onClickSubmitForms = new EventEmitter();
3568
+ this.selectedForm = "";
3569
+ this.formsListLength = 0;
3570
+ this.isAllFormsCompleted = true;
3571
+ }
3572
+ ngOnInit() {
3573
+ this.formsList = this.filterHiddenForms(this.formsList);
3574
+ this.formsListLength = this.findFormsListLength(this.formsList);
3575
+ this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
3576
+ }
3577
+ ngOnChanges(changes) {
3578
+ const verifyChange = (key) => {
3579
+ return checkObjectKeyExists(changes, key) && !changes[key].firstChange;
3580
+ };
3581
+ if (verifyChange("showFormFields")) {
3582
+ this.showFormFields = changes.showFormFields.currentValue;
3583
+ }
3584
+ if (verifyChange("formsList")) {
3585
+ this.formsList = this.filterHiddenForms(this.formsList);
3586
+ this.formsListLength = this.findFormsListLength(this.formsList);
3587
+ this.isAllFormsCompleted = this.checkIsAllFormsCompleted(this.formsList);
3588
+ }
3589
+ if (verifyChange("isMobileView")) {
3590
+ this.isMobileView = changes.isMobileView.currentValue;
3591
+ }
3592
+ }
3593
+ filterHiddenForms(formsList) {
3594
+ return formsList.filter((form) => {
3595
+ if (checkObjectKeyExists(form, "hidden")) {
3596
+ if (!form.hidden) {
3597
+ return form;
3598
+ }
3599
+ }
3600
+ });
3601
+ }
3602
+ findFormsListLength(formsList) {
3603
+ const _formsList = formsList.filter((form) => {
3604
+ if (checkObjectKeyExists(form, "type")) {
3605
+ if (form.type === "form") {
3606
+ if (checkObjectKeyExists(form, "hidden")) {
3607
+ if (!form.hidden) {
3608
+ return form;
3609
+ }
3591
3610
  }
3592
- else {
3593
- field["defaultValue"] = {
3594
- is_found: false,
3595
- value: "",
3596
- sources: [
3597
- {
3598
- source: "form_data",
3599
- form_data: {
3600
- path: `$.${field.key}`,
3601
- validation: {
3602
- rules: [
3603
- {
3604
- key: "1",
3605
- type: "is_not_empty",
3606
- is_not_empty: {
3607
- value: true
3608
- }
3609
- }
3610
- ],
3611
- actions: [
3612
- {
3613
- type: "set_default_value_found",
3614
- condition: "1",
3615
- set_default_value_found: {
3616
- value: true
3617
- }
3618
- },
3619
- {
3620
- type: "enable_field",
3621
- condition: "1 OR NOT(1)",
3622
- enable_field: { value: true }
3623
- }
3624
- ]
3625
- }
3626
- }
3627
- }
3628
- ]
3629
- };
3630
- }
3631
3611
  }
3632
- delete field["defaultVal"];
3633
3612
  }
3634
- return field;
3635
- };
3636
- const updateFieldMessages = (field) => {
3637
- if (field.isFormElement) {
3638
- field = this.setMissingFieldKeyValue(field, "messages", []);
3639
- }
3640
- return field;
3641
- };
3642
- const updateFieldResetButton = (field) => {
3643
- if (field.isFormElement) {
3644
- if (checkObjectKeyExists(field, "action") &&
3645
- field.action === "reset" &&
3646
- checkObjectKeyExists(field, "fields")) {
3647
- field = this.setFieldKeyValue(field, "reset", {
3648
- fields: field.fields
3649
- });
3613
+ else if (checkObjectKeyExists(form, "hidden")) {
3614
+ if (!form.hidden) {
3615
+ return form;
3650
3616
  }
3651
3617
  }
3652
- return field;
3653
- };
3654
- const setFormFields = (formConfig, fields) => {
3655
- if (checkObjectKeyExists(formConfig, "multiForm")) {
3656
- formConfig.multiForm["fields"] = fields;
3657
- }
3658
- else {
3659
- formConfig["fields"] = fields;
3660
- }
3661
- return formConfig;
3662
- };
3663
- const setFormFieldGroups = (formConfig, groups) => {
3664
- formConfig["fieldGroups"] = groups;
3665
- return formConfig;
3666
- };
3667
- const updateFormFieldGroups = (fieldGroups, field) => {
3668
- if (checkObjectKeyExists(field, "groupKey")) {
3669
- if (checkObjectKeyExists(fieldGroups, field.groupKey)) {
3670
- fieldGroups[field.groupKey].push(field.key);
3671
- }
3672
- else {
3673
- fieldGroups[field.groupKey] = [field.key];
3618
+ });
3619
+ return _formsList.length;
3620
+ }
3621
+ checkIsAllFormsCompleted(formsList) {
3622
+ let isAllFormsCompleted = true;
3623
+ for (let form of formsList) {
3624
+ if (checkObjectKeyExists(form, "type")) {
3625
+ if (form.type === "form") {
3626
+ if (form.status !== "completed") {
3627
+ isAllFormsCompleted = false;
3628
+ break;
3629
+ }
3674
3630
  }
3675
3631
  }
3676
- return fieldGroups;
3677
- };
3678
- let connectedFieldMapping = {
3679
- parent: {},
3680
- child: {}
3681
- };
3682
- let fields = this.getFormFields(formConfig);
3683
- let fieldGroups = {};
3684
- for (let field of fields) {
3685
- field = updateOnFieldType(field);
3686
- field = formatFieldKeys(field);
3687
- // connectedFieldMapping = getConnectedElementFieldMapping(
3688
- // field,
3689
- // connectedFieldMapping
3690
- // );
3691
- // field = updateConnectedElementsKeyValue(field, connectedFieldMapping);
3692
- fieldGroups = updateFormFieldGroups(fieldGroups, field);
3693
- field = updateFieldDefaultValueConfig(field);
3694
- field = updateFieldValidatorConfig(field);
3695
- field = updateFieldResetButton(field);
3696
- field = updateFieldMessages(field);
3697
3632
  }
3698
- formConfig = setFormFieldGroups(formConfig, fieldGroups);
3699
- formConfig = setFormFields(formConfig, fields);
3700
- return formConfig;
3633
+ return isAllFormsCompleted;
3634
+ }
3635
+ handleOnClickSetActiveForm(selectedForm) {
3636
+ if (this.selectedForm !== selectedForm ||
3637
+ (this.isAllFormsCompleted && !this.showFormFields)) {
3638
+ this.selectedForm = selectedForm;
3639
+ this.onClickSetActiveForm.emit(selectedForm);
3640
+ }
3641
+ }
3642
+ handleOnSubmitForms(e) {
3643
+ this.onClickSubmitForms.emit(e);
3701
3644
  }
3702
3645
  }
3646
+ /** @nocollapse */ KwikIDFormsListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormsListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3647
+ /** @nocollapse */ KwikIDFormsListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: { showFormFields: "showFormFields", userConfig: "userConfig", activeFormConfig: "activeFormConfig", formsList: "formsList", formsListCompleted: "formsListCompleted", isMobileView: "isMobileView" }, outputs: { onClickSetActiveForm: "onClickSetActiveForm", onClickHideFormsList: "onClickHideFormsList", onClickSubmitForms: "onClickSubmitForms" }, usesOnChanges: true, ngImport: i0, template: "<div id=\"sidebar-container\">\n <div id=\"sidebar\">\n <div ngClass=\"kwikid-form-header\">\n <div id=\"uf-header\">\n <div id=\"uf-header-logo-container\">\n <img\n id=\"uf-header-logo\"\n src=\"{{ this.userConfig.theme.clientLogo }}\"\n [ngClass]=\"'large-icon'\"\n />\n </div>\n </div>\n <hr />\n </div>\n <div id=\"uf-progress\">\n <div id=\"uf-progress-steps\">\n {{ this.formsListCompleted.length }} / {{ this.formsListLength }} Steps\n Completed\n </div>\n <kwikui-progress-segmented\n [max]=\"this.formsListLength\"\n size=\"m\"\n [value]=\"this.formsListCompleted.length\"\n ></kwikui-progress-segmented>\n </div>\n <div id=\"uf-sections-container\">\n <ng-container *ngFor=\"let form of formsList; let i = index\">\n <ng-container [ngSwitch]=\"form.type\">\n <!-- HTML Content -->\n <ng-container *ngSwitchCase=\"'html'\">\n <div [innerHtml]=\"form.props.htmlContent | safeHtml\"></div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'form'\">\n <div\n [class]=\"'uf-section-item'\"\n [class.completed]=\"form.status === 'completed' && !form.disabled\"\n [class.edit]=\"form.status === 'editable' && !form.disabled\"\n [class.locked]=\"form.status === 'locked' && form.disabled\"\n [class.active]=\"\n activeFormConfig !== undefined &&\n form.key === activeFormConfig.key\n \"\n (click)=\"\n form.status === 'locked' && form.disabled\n ? undefined\n : handleOnClickSetActiveForm(form.key)\n \"\n >\n <div class=\"uf-form-section-card-title\">\n {{ form.props.title }}&nbsp;<span *ngIf=\"form?.required\"\n >*</span\n >\n </div>\n <div class=\"uf-form-section-card-status\">\n <div\n *ngIf=\"form.status === 'completed' && !form.disabled\"\n class=\"uf-form-section-card-status-img completed\"\n >\n <tui-svg src=\"tuiIconCheckLarge\"></tui-svg>\n </div>\n <div\n *ngIf=\"form.status !== 'completed' && !form.disabled\"\n class=\"uf-form-section-card-status-img edit\"\n >\n <tui-svg src=\"tuiIconEdit\"></tui-svg>\n </div>\n <div\n *ngIf=\"form.status !== 'completed' && form.disabled\"\n class=\"uf-form-section-card-status-img locked\"\n >\n <tui-svg src=\"tuiIconLock\"></tui-svg>\n </div>\n </div>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n </div>\n <div id=\"submit-sidebar-btn-container\">\n <kwikui-button\n [disabled]=\"false\"\n id=\"\"\n label=\"Submit\"\n [showLoader]=\"false\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"primary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"handleOnSubmitForms($event)\"\n ></kwikui-button>\n </div>\n </div>\n</div>\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{border-radius:10px}::-webkit-scrollbar-thumb{background:lightgray;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:gray}#sidebar-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}#sidebar{width:100%;height:100%;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch}.uf-section-item{width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;align-content:center;padding:1rem;grid-gap:1rem;gap:1rem;cursor:pointer;box-shadow:0 1px 3px -1px var(--tui-base-05);border-radius:.5rem;background-color:var(--tui-base-02);position:relative}.uf-section-item:hover{box-shadow:0 1px 3px -1px var(--tui-base-08)}#submit-sidebar-btn-container{width:100%;bottom:0px;z-index:1;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-gap:1rem;gap:1rem}#submit-sidebar-btn-container *{flex-grow:1}#uf-sections-container{display:flex;flex-direction:column;height:100%;grid-row-gap:20px;row-gap:20px;padding:1rem;overflow-y:auto}.uf-form-section-card{display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-column-gap:10px;column-gap:10px;border:none;border-radius:8px;background-color:#e9e9e9;height:-moz-fit-content;height:fit-content;min-height:60px;padding:10px 15px;width:100%;max-width:350px;margin:0 auto}.uf-section-item.locked{-webkit-user-select:none;user-select:none;cursor:not-allowed}.uf-form-section-card .uf-form-section-card-title{font-size:1.2em;text-align:left;line-height:1.25em}.uf-form-section-card .uf-form-section-card-status{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}.uf-form-section-card .uf-form-section-card-status .uf-form-section-card-status-img{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;border-radius:100%;color:#fff;font-weight:bold}.uf-form-section-card-status-img.completed{background-color:var(--tui-success-fill);padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-status-img.edit{background-color:var(--tui-error-fill);padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-status-img.locked{background-color:var(--tui-neutral-fill);padding:.25rem;border-radius:50%;color:#fff}#uf-progress{display:flex;padding:1rem;flex-direction:column;align-content:center;justify-content:center;align-items:stretch;grid-gap:.5rem;gap:.5rem}#uf-progress-steps{font-size:1em;text-align:right;color:#3d3d3d}.uf-form-section-card-title{font-size:1em;font-weight:bold;color:#000}@media screen and (max-width: 600px){#sidebar-container{max-width:unset}}.kwikid-form-header{height:70px;z-index:6}.kwikid-form-header hr{width:calc(100% - 1rem);margin-left:auto;margin-right:auto}#uf-header{display:flex;flex-direction:row;align-content:center;align-items:center;justify-content:flex-start;grid-column-gap:10px;column-gap:10px;padding:10px 20px;width:100%;max-width:calc(400px + 50vw + 2rem);margin:0 auto;height:70px;z-index:1}#uf-header #uf-header-goback-container{display:none}#uf-header #uf-header-goback-container:hover{border-radius:50%;background-color:#d3d3d3}#uf-header #uf-header-goback-container #uf-header-goback{width:100%;height:auto}#uf-header #uf-header-logo-container{display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}#uf-header #uf-header-logo-container #uf-header-logo.small-icon{width:100%;height:50px}#uf-header #uf-header-logo-container #uf-header-logo.large-icon{width:100%;height:50px}#uf-header #uf-header-title-container{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;grid-row-gap:4px;row-gap:4px}#uf-header #uf-header-title-container #uf-header-title{font-size:1.4em;color:#121212}#uf-header #uf-header-title-container #uf-header-subtitle{font-size:1.2em;color:#121212}\n"], components: [{ type: i2.KwikUIProgressSegmentedComponent, selector: "kwikui-progress-segmented", inputs: ["id", "value", "max", "size", "colors"] }, { type: i3$1.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }, { type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "safeHtml": SafeHtmlPipe } });
3703
3648
  __decorate([
3704
3649
  logMethod
3705
- ], Converter.prototype, "convertFormConfig", null);
3650
+ ], KwikIDFormsListComponent.prototype, "ngOnChanges", null);
3651
+ __decorate([
3652
+ logMethod
3653
+ ], KwikIDFormsListComponent.prototype, "filterHiddenForms", null);
3654
+ __decorate([
3655
+ logMethod
3656
+ ], KwikIDFormsListComponent.prototype, "findFormsListLength", null);
3657
+ __decorate([
3658
+ logMethod
3659
+ ], KwikIDFormsListComponent.prototype, "checkIsAllFormsCompleted", null);
3660
+ __decorate([
3661
+ logMethod
3662
+ ], KwikIDFormsListComponent.prototype, "handleOnClickSetActiveForm", null);
3663
+ __decorate([
3664
+ logMethod
3665
+ ], KwikIDFormsListComponent.prototype, "handleOnSubmitForms", null);
3666
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormsListComponent, decorators: [{
3667
+ type: Component,
3668
+ args: [{
3669
+ selector: "kwikid-forms-list",
3670
+ templateUrl: "./forms-list.component.html",
3671
+ styleUrls: ["./forms-list.component.scss"]
3672
+ }]
3673
+ }], ctorParameters: function () { return []; }, propDecorators: { showFormFields: [{
3674
+ type: Input
3675
+ }], userConfig: [{
3676
+ type: Input
3677
+ }], activeFormConfig: [{
3678
+ type: Input
3679
+ }], formsList: [{
3680
+ type: Input
3681
+ }], formsListCompleted: [{
3682
+ type: Input
3683
+ }], isMobileView: [{
3684
+ type: Input
3685
+ }], onClickSetActiveForm: [{
3686
+ type: Output
3687
+ }], onClickHideFormsList: [{
3688
+ type: Output
3689
+ }], onClickSubmitForms: [{
3690
+ type: Output
3691
+ }], ngOnChanges: [], filterHiddenForms: [], findFormsListLength: [], checkIsAllFormsCompleted: [], handleOnClickSetActiveForm: [], handleOnSubmitForms: [] } });
3692
+
3693
+ var EFormsListStatus;
3694
+ (function (EFormsListStatus) {
3695
+ EFormsListStatus["COMPLETED"] = "completed";
3696
+ EFormsListStatus["EDITABLE"] = "editable";
3697
+ EFormsListStatus["LOCKED"] = "locked";
3698
+ })(EFormsListStatus || (EFormsListStatus = {}));
3699
+
3700
+ var ERendererActionKey;
3701
+ (function (ERendererActionKey) {
3702
+ ERendererActionKey["SET_VALUE"] = "SET_VALUE";
3703
+ ERendererActionKey["FORM_HIDE"] = "FORM_HIDE";
3704
+ ERendererActionKey["FORM_SHOW"] = "FORM_SHOW";
3705
+ ERendererActionKey["FORM_DISABLE"] = "FORM_DISABLE";
3706
+ ERendererActionKey["FORM_ENABLE"] = "FORM_ENABLE";
3707
+ })(ERendererActionKey || (ERendererActionKey = {}));
3706
3708
 
3707
3709
  const getFormConfigByKey = (forms, key) => {
3708
3710
  const form = forms.find((form) => {
@@ -3776,7 +3778,7 @@ class KwikIDFormsRendererComponent {
3776
3778
  else {
3777
3779
  throw new Error(`userFormFields doesn't have a form defined with key: ${formStepKey}`);
3778
3780
  }
3779
- this.initializeForms();
3781
+ this.initializeForms("ON_INIT");
3780
3782
  this.loader = false;
3781
3783
  }
3782
3784
  ngOnChanges(changes) {
@@ -3789,7 +3791,7 @@ class KwikIDFormsRendererComponent {
3789
3791
  }
3790
3792
  if (verifyChange("formsData")) {
3791
3793
  this.formsData = changes.formsData.currentValue;
3792
- this.initializeForms();
3794
+ this.initializeForms("ON_CHANGE");
3793
3795
  }
3794
3796
  if (verifyChange("apiCallResponse")) {
3795
3797
  this.apiCallResponse = changes.apiCallResponse.currentValue;
@@ -3803,28 +3805,34 @@ class KwikIDFormsRendererComponent {
3803
3805
  return data;
3804
3806
  });
3805
3807
  }
3806
- initializeForms() {
3808
+ initializeForms(eventType) {
3807
3809
  return __awaiter(this, void 0, void 0, function* () {
3808
3810
  this.loader = true;
3809
3811
  this.allFormsData = this.formsData;
3810
3812
  yield this.updateFormsList();
3811
- this.handleResize(this.formsList);
3812
- if (isNotEmptyValue(this.activeFormConfig)) {
3813
- if (checkObjectKeyExists(this.activeFormConfig, "type")) {
3814
- if (this.activeFormConfig.type === "form") {
3813
+ if (eventType === "ON_CHANGE" &&
3814
+ this.findFormsListLength(this.formsList) === 1) {
3815
+ this.handleOnClickSubmitForms(null);
3816
+ }
3817
+ else {
3818
+ this.handleResize(this.formsList);
3819
+ if (isNotEmptyValue(this.activeFormConfig)) {
3820
+ if (checkObjectKeyExists(this.activeFormConfig, "type")) {
3821
+ if (this.activeFormConfig.type === "form") {
3822
+ yield this.handleOnClickSetActiveForm(this.activeFormConfig.key);
3823
+ }
3824
+ }
3825
+ else {
3815
3826
  yield this.handleOnClickSetActiveForm(this.activeFormConfig.key);
3816
3827
  }
3817
3828
  }
3818
3829
  else {
3819
- yield this.handleOnClickSetActiveForm(this.activeFormConfig.key);
3830
+ this.showForm = false;
3831
+ this.showFormFields = false;
3820
3832
  }
3833
+ this.loader = false;
3834
+ this.loading = false;
3821
3835
  }
3822
- else {
3823
- this.showForm = false;
3824
- this.showFormFields = false;
3825
- }
3826
- this.loader = false;
3827
- this.loading = false;
3828
3836
  });
3829
3837
  }
3830
3838
  convertFormListConfig(formsList) {
@@ -4041,6 +4049,25 @@ class KwikIDFormsRendererComponent {
4041
4049
  }
4042
4050
  });
4043
4051
  }
4052
+ findFormsListLength(formsList) {
4053
+ const _formsList = formsList.filter((form) => {
4054
+ if (checkObjectKeyExists(form, "type")) {
4055
+ if (form.type === "form") {
4056
+ if (checkObjectKeyExists(form, "hidden")) {
4057
+ if (!form.hidden) {
4058
+ return form;
4059
+ }
4060
+ }
4061
+ }
4062
+ }
4063
+ else if (checkObjectKeyExists(form, "hidden")) {
4064
+ if (!form.hidden) {
4065
+ return form;
4066
+ }
4067
+ }
4068
+ });
4069
+ return _formsList.length;
4070
+ }
4044
4071
  /**
4045
4072
  * Library Event Listeners
4046
4073
  */
@@ -4049,7 +4076,6 @@ class KwikIDFormsRendererComponent {
4049
4076
  * @param selectedForm string
4050
4077
  */
4051
4078
  handleOnClickSetActiveForm(selectedForm) {
4052
- var _a;
4053
4079
  return __awaiter(this, void 0, void 0, function* () {
4054
4080
  this.showForm = false;
4055
4081
  this.loader = true;
@@ -4061,7 +4087,8 @@ class KwikIDFormsRendererComponent {
4061
4087
  let formConfig = undefined;
4062
4088
  if (checkObjectKeyExists(activeFormConfig, "props")) {
4063
4089
  if (checkObjectKeyExists(activeFormConfig.props, "url")) {
4064
- formConfig = yield this.fetchFormConfig(activeFormConfig.props.url);
4090
+ const formConfigFromUrl = yield this.fetchFormConfig(activeFormConfig.props.url);
4091
+ formConfig = Object.assign(Object.assign({}, activeFormConfig), formConfigFromUrl);
4065
4092
  }
4066
4093
  else {
4067
4094
  if (checkObjectKeyExists(activeFormConfig, "fields")) {
@@ -4074,7 +4101,8 @@ class KwikIDFormsRendererComponent {
4074
4101
  }
4075
4102
  else {
4076
4103
  if (checkObjectKeyExists(activeFormConfig.formContent, "url")) {
4077
- formConfig = yield this.fetchFormConfig(activeFormConfig.formContent.url);
4104
+ const formConfigFromUrl = yield this.fetchFormConfig(activeFormConfig.formContent.url);
4105
+ formConfig = Object.assign(Object.assign({}, activeFormConfig), formConfigFromUrl);
4078
4106
  }
4079
4107
  else {
4080
4108
  if (checkObjectKeyExists(activeFormConfig, "fields")) {
@@ -4086,9 +4114,11 @@ class KwikIDFormsRendererComponent {
4086
4114
  }
4087
4115
  }
4088
4116
  console.log(JSON.parse(JSON.stringify(formConfig)));
4089
- formConfig = new Converter().convertFormConfig(formConfig);
4090
- const activeFormData = (_a = this.allFormsData[formConfig.key]) !== null && _a !== void 0 ? _a : {};
4117
+ formConfig = new Converter().updateFormConfigMiscellaneous(formConfig, {
4118
+ formsListLength: this.findFormsListLength(this.formsList)
4119
+ });
4091
4120
  this.activeFormConfig = Object.assign(Object.assign({}, activeFormConfig), formConfig);
4121
+ this.activeFormConfig;
4092
4122
  if (this.hostElement.nativeElement.offsetWidth < 600) {
4093
4123
  this.showFormSections = false;
4094
4124
  this.showFormFields = true;
@@ -4115,7 +4145,6 @@ class KwikIDFormsRendererComponent {
4115
4145
  */
4116
4146
  handleOnClickSaveForm(e) {
4117
4147
  this.loader = true;
4118
- this.activeFormData = {};
4119
4148
  this.getFormData.emit({
4120
4149
  [this.activeFormConfig.key]: e["data"]
4121
4150
  });
@@ -4176,7 +4205,7 @@ class KwikIDFormsRendererComponent {
4176
4205
  }
4177
4206
  }
4178
4207
  /** @nocollapse */ KwikIDFormsRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormsRendererComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
4179
- /** @nocollapse */ KwikIDFormsRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormsRendererComponent, selector: "kwikid-forms-renderer", inputs: { stepConfig: "stepConfig", userConfig: "userConfig", formsData: "formsData", apiCallResponse: "apiCallResponse" }, outputs: { onClickSubmit: "onClickSubmit", getFormData: "getFormData", onClickApiCall: "onClickApiCall" }, host: { listeners: { "window:resize": "windowResizeWatcher($event)" } }, usesOnChanges: true, ngImport: i0, template: "<div ngClass=\"kwikid-renderer\">\n <div\n ngClass=\"kwikid-layout-container\"\n *ngIf=\"!loading\"\n >\n <div\n ngClass=\"kwikid-sections-container\"\n *ngIf=\"showFormSections\"\n class=\"active\"\n [class.active]=\"showFormSections\"\n [class.mobile]=\"isMobileView\"\n >\n <kwikid-forms-list\n [showFormFields]=\"this.showFormFields\"\n [activeFormConfig]=\"this.activeFormConfig\"\n [userConfig]=\"this.userConfig\"\n [formsList]=\"this.formsList\"\n [formsListCompleted]=\"this.formsListCompleted\"\n [isMobileView]=\"this.isMobileView\"\n (onClickSetActiveForm)=\"this.handleOnClickSetActiveForm($event)\"\n (onClickSubmitForms)=\"this.handleOnClickSubmitForms($event)\"\n ></kwikid-forms-list>\n </div>\n <div\n ngClass=\"kwikid-forms-container\"\n *ngIf=\"\n this.showForm &&\n this.showFormFields &&\n this.activeFormConfig !== undefined\n \"\n [class.active]=\"showFormFields\"\n [class.mobile]=\"isMobileView\"\n [@panelInOut]\n >\n <kwikid-form-view\n [formConfig]=\"this.activeFormConfig\"\n [formData]=\"this.activeFormData\"\n [formsList]=\"this.formsList\"\n [allFormsData]=\"this.allFormsData\"\n [isMobileView]=\"this.isMobileView\"\n (onClickViewForms)=\"this.handleOnClickViewForms($event)\"\n (onClickSaveForm)=\"this.handleOnClickSaveForm($event)\"\n ></kwikid-form-view>\n </div>\n </div>\n</div>\n<div\n ngClass=\"kwikid-forms-renderer-loader\"\n *ngIf=\"loader\"\n>\n <span class=\"loader\"></span>\n</div>\n<tui-push\n id=\"error-notification\"\n *tuiPush=\"showErrorNotification\"\n heading=\"Please complete the required Forms!\"\n type=\"Error\"\n (close)=\"toggleErrorNotification(false)\"\n>\n <tui-svg\n src=\"tuiIconCancel\"\n style=\"color: #fff !important\"\n >\n </tui-svg>\n</tui-push>\n", styles: [":host{position:relative}.kwikid-root{width:100%;height:100%}.kwikid-renderer{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;width:100%;height:100%}.kwikid-layout-container{display:flex;flex-direction:row;padding:0 1rem;height:100%;justify-content:center;align-items:stretch;background:var(--tui-secondary-active);position:relative}.kwikid-sections-container{display:block;width:100%;max-width:400px;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);margin:auto 1rem auto 0;box-shadow:0 0 12px -8px var(--tui-secondary)}.kwikid-sections-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}.kwikid-forms-container{display:block;width:100%;max-width:50%;margin:auto 0;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);box-shadow:0 0 12px -8px var(--tui-primary)}.kwikid-forms-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}@media screen and (max-width: 600px){.kwikid-layout-container{padding:0;background:transparent}.kwikid-sections-container{position:absolute;max-width:100%;bottom:-10000px;left:-10000px;opacity:0;padding:0;visibility:hidden}.kwikid-sections-container.active{visibility:visible}.kwikid-sections-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container{display:none;max-width:100%;height:100%;padding:0;border-radius:0;box-shadow:none}.kwikid-forms-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container.active{display:block}}.kwikid-forms-renderer-loader{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.75);display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;z-index:100}.kwikid-forms-renderer-loader .loader{width:48px;height:48px;border-radius:50%;display:inline-block;position:relative;border:3px solid;border-color:#fff #fff transparent;box-sizing:border-box;animation:rotation 1s linear infinite}.kwikid-forms-renderer-loader .loader:after{content:\"\";box-sizing:border-box;position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;border:3px solid;border-color:transparent var(--tui-primary) var(--tui-primary);width:24px;height:24px;border-radius:50%;animation:rotationBack .5s linear infinite;transform-origin:center center}@keyframes rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes rotationBack{0%{transform:rotate(0)}to{transform:rotate(-360deg)}}.kwikid-forms-renderer-loader .t-loader{display:none!important}#error-notification{background-color:var(--tui-error-fill);color:#fff!important}#error-notification .t-top{color:#fff!important}#error-notification .t-close{color:#fff!important}\n"], components: [{ type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: ["showFormFields", "userConfig", "activeFormConfig", "formsList", "formsListCompleted", "isMobileView"], outputs: ["onClickSetActiveForm", "onClickHideFormsList", "onClickSubmitForms"] }, { type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: ["formConfig", "formData", "isMobileView", "allFormsData", "formsList"], outputs: ["onClickViewForms", "onClickSaveForm", "onClickApiCall"] }, { type: i4$1.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3$1.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4$1.TuiPushDirective, selector: "tui-push" }], animations: [
4208
+ /** @nocollapse */ KwikIDFormsRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormsRendererComponent, selector: "kwikid-forms-renderer", inputs: { stepConfig: "stepConfig", userConfig: "userConfig", formsData: "formsData", apiCallResponse: "apiCallResponse" }, outputs: { onClickSubmit: "onClickSubmit", getFormData: "getFormData", onClickApiCall: "onClickApiCall" }, host: { listeners: { "window:resize": "windowResizeWatcher($event)" } }, usesOnChanges: true, ngImport: i0, template: "<div ngClass=\"kwikid-renderer\">\n <div\n ngClass=\"kwikid-layout-container\"\n *ngIf=\"!loading\"\n >\n <div\n ngClass=\"kwikid-sections-container\"\n *ngIf=\"showFormSections\"\n class=\"active\"\n [class.active]=\"showFormSections\"\n [class.mobile]=\"isMobileView\"\n >\n <kwikid-forms-list\n [showFormFields]=\"this.showFormFields\"\n [activeFormConfig]=\"this.activeFormConfig\"\n [userConfig]=\"this.userConfig\"\n [formsList]=\"this.formsList\"\n [formsListCompleted]=\"this.formsListCompleted\"\n [isMobileView]=\"this.isMobileView\"\n (onClickSetActiveForm)=\"this.handleOnClickSetActiveForm($event)\"\n (onClickSubmitForms)=\"this.handleOnClickSubmitForms($event)\"\n ></kwikid-forms-list>\n </div>\n <div\n ngClass=\"kwikid-forms-container\"\n *ngIf=\"\n this.showForm &&\n this.showFormFields &&\n this.activeFormConfig !== undefined\n \"\n [class.active]=\"showFormFields\"\n [class.mobile]=\"isMobileView\"\n [@panelInOut]\n >\n <kwikid-form-view\n [formConfig]=\"this.activeFormConfig\"\n [allFormsData]=\"this.allFormsData\"\n [isMobileView]=\"this.isMobileView\"\n (onClickViewForms)=\"this.handleOnClickViewForms($event)\"\n (onClickSaveForm)=\"this.handleOnClickSaveForm($event)\"\n ></kwikid-form-view>\n </div>\n </div>\n</div>\n<div\n ngClass=\"kwikid-forms-renderer-loader\"\n *ngIf=\"loader\"\n>\n <span class=\"loader\"></span>\n</div>\n<tui-push\n id=\"error-notification\"\n *tuiPush=\"showErrorNotification\"\n heading=\"Please complete the required Forms!\"\n type=\"Error\"\n (close)=\"toggleErrorNotification(false)\"\n>\n <tui-svg\n src=\"tuiIconCancel\"\n style=\"color: #fff !important\"\n >\n </tui-svg>\n</tui-push>\n", styles: [":host{position:relative}.kwikid-root{width:100%;height:100%}.kwikid-renderer{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;width:100%;height:100%}.kwikid-layout-container{display:flex;flex-direction:row;padding:0 1rem;height:100%;justify-content:center;align-items:stretch;background:var(--tui-secondary-active);position:relative}.kwikid-sections-container{display:block;width:100%;max-width:400px;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);margin:auto 1rem auto 0;box-shadow:0 0 12px -8px var(--tui-secondary)}.kwikid-sections-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}.kwikid-forms-container{display:block;width:100%;max-width:50%;margin:auto 0;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);box-shadow:0 0 12px -8px var(--tui-primary)}.kwikid-forms-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}@media screen and (max-width: 600px){.kwikid-layout-container{padding:0;background:transparent}.kwikid-sections-container{position:absolute;max-width:100%;bottom:-10000px;left:-10000px;opacity:0;padding:0;visibility:hidden}.kwikid-sections-container.active{visibility:visible}.kwikid-sections-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container{display:none;max-width:100%;height:100%;padding:0;border-radius:0;box-shadow:none}.kwikid-forms-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container.active{display:block}}.kwikid-forms-renderer-loader{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.75);display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;z-index:100}.kwikid-forms-renderer-loader .loader{width:48px;height:48px;border-radius:50%;display:inline-block;position:relative;border:3px solid;border-color:#fff #fff transparent;box-sizing:border-box;animation:rotation 1s linear infinite}.kwikid-forms-renderer-loader .loader:after{content:\"\";box-sizing:border-box;position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;border:3px solid;border-color:transparent var(--tui-primary) var(--tui-primary);width:24px;height:24px;border-radius:50%;animation:rotationBack .5s linear infinite;transform-origin:center center}@keyframes rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes rotationBack{0%{transform:rotate(0)}to{transform:rotate(-360deg)}}.kwikid-forms-renderer-loader .t-loader{display:none!important}#error-notification{background-color:var(--tui-error-fill);color:#fff!important}#error-notification .t-top{color:#fff!important}#error-notification .t-close{color:#fff!important}\n"], components: [{ type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: ["showFormFields", "userConfig", "activeFormConfig", "formsList", "formsListCompleted", "isMobileView"], outputs: ["onClickSetActiveForm", "onClickHideFormsList", "onClickSubmitForms"] }, { type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: ["formConfig", "formData", "isMobileView", "allFormsData"], outputs: ["onClickViewForms", "onClickSaveForm", "onClickApiCall"] }, { type: i4$1.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3$1.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4$1.TuiPushDirective, selector: "tui-push" }], animations: [
4180
4209
  trigger("panelInOut", [
4181
4210
  transition(":enter", [
4182
4211
  style({ transform: "translateY(100%)" }),
@@ -4220,6 +4249,9 @@ __decorate([
4220
4249
  __decorate([
4221
4250
  logMethod
4222
4251
  ], KwikIDFormsRendererComponent.prototype, "formShow", null);
4252
+ __decorate([
4253
+ logMethod
4254
+ ], KwikIDFormsRendererComponent.prototype, "findFormsListLength", null);
4223
4255
  __decorate([
4224
4256
  logMethod
4225
4257
  ], KwikIDFormsRendererComponent.prototype, "handleOnClickSetActiveForm", null);
@@ -4261,7 +4293,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
4261
4293
  type: Output
4262
4294
  }], onClickApiCall: [{
4263
4295
  type: Output
4264
- }], convertFormListConfig: [], assignSequenceNoToForm: [], findCompletedFormsList: [], markFormInFormsListAsCompleted: [], markFormInFormsListAsDisabled: [], filterAllFormsData: [], checkIfFormsStatusCompleted: [], findActiveFormConfig: [], updateFormsList: [], formHide: [], formShow: [], handleOnClickSetActiveForm: [], handleOnClickSubmitForms: [] } });
4296
+ }], convertFormListConfig: [], assignSequenceNoToForm: [], findCompletedFormsList: [], markFormInFormsListAsCompleted: [], markFormInFormsListAsDisabled: [], filterAllFormsData: [], checkIfFormsStatusCompleted: [], findActiveFormConfig: [], updateFormsList: [], formHide: [], formShow: [], findFormsListLength: [], handleOnClickSetActiveForm: [], handleOnClickSubmitForms: [] } });
4265
4297
 
4266
4298
  class KwikIDFormBuilderModule {
4267
4299
  }