ngx-smz-ui 3.5.3 → 3.5.5

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.
@@ -1062,7 +1062,31 @@
1062
1062
  },
1063
1063
  },
1064
1064
  _j[exports.SmzControlType.CONTENT_MASK] = {
1065
- initialize: function (input, config) { },
1065
+ initialize: function (input, config) {
1066
+ // Expressão para localizar as tags originais
1067
+ var expression = new RegExp(/(<[^\/].*?>)(.*?)(<[\/].*?>)/gm);
1068
+ var variables = [];
1069
+ // Loop para encontrar todas as variáveis
1070
+ var value = expression.exec(input.defaultValue);
1071
+ while (value != null) {
1072
+ // Inserir variável encontrada
1073
+ // Cada variável será armazenada em um array de 4 elementos, sendo total [0], tag de abertura [1], valor [2] e tag de fechamento [3].
1074
+ variables.push(value);
1075
+ // Localizar próximo match
1076
+ value = expression.exec(input.defaultValue);
1077
+ }
1078
+ // Substituir as tags originais pelo padrão do content mask: {{value}}
1079
+ input.defaultValue = input.defaultValue.replace(expression, function (a) {
1080
+ // Resultado da busca será um array de 2 elementos, sendo total [0] e valor [1]
1081
+ var variable = new RegExp(/<[^\/].*?>(.*)<[\/].*?>/gm).exec(a);
1082
+ if (variable.length != 2)
1083
+ throw new Error("Some wrong when trying to extract variable value of " + variable);
1084
+ // Retornando formato {{value}}
1085
+ return "" + input.variableBegin + variable[1] + input.variableEnd;
1086
+ });
1087
+ // Armazenar variaveis originais para usar do mapping de getValue (response)
1088
+ input._originalVariables = variables;
1089
+ },
1066
1090
  clear: function (control) { control.patchValue(''); },
1067
1091
  updateValue: function (control, input) {
1068
1092
  var mapped = mapInputContentMaskText(input);
@@ -1070,8 +1094,24 @@
1070
1094
  },
1071
1095
  getValue: function (form, input, flattenResponse) {
1072
1096
  var value = form.get(input.propertyName).value;
1097
+ // Capturar valores do texto sem as tags de estilos do content mask
1073
1098
  var unmapped = unmapInputContentMaskText(value, input.variableId, input.tagClass, input.variableBegin, input.variableEnd, input.exportHtmlNewLine);
1074
- return mapResponseValue(input, unmapped, false);
1099
+ // Expressão para localizar as tags {{value}}
1100
+ var expression = new RegExp(input.variableBegin + ".*?" + input.variableEnd, 'gm');
1101
+ // Loop para substituir as tags {{value}} pela sua respectiva variável original
1102
+ var originalFormat = unmapped;
1103
+ var originalValue = expression.exec(unmapped);
1104
+ var index = 0;
1105
+ while (originalValue != null) {
1106
+ // Substituir bloco por variavel original
1107
+ // Esse regex não pode ser global para que substitua apenas um bloco por vez,
1108
+ // assim a ordem do original baterá perfeitamente com a sequencia da busca
1109
+ originalFormat = originalFormat.replace(new RegExp(input.variableBegin + ".*?" + input.variableEnd, ''), input._originalVariables[index][0]);
1110
+ // Localizar próximo match
1111
+ originalValue = expression.exec(unmapped);
1112
+ index++;
1113
+ }
1114
+ return mapResponseValue(input, originalFormat, false);
1075
1115
  },
1076
1116
  },
1077
1117
  _j[exports.SmzControlType.TAG_AREA] = {
@@ -3577,8 +3617,8 @@
3577
3617
  var _this = this;
3578
3618
  this.isInitialized = true;
3579
3619
  setTimeout(function () {
3580
- var e_1, _f, e_2, _g;
3581
- var _a, _b, _c, _d, _e;
3620
+ var e_1, _j, e_2, _k;
3621
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3582
3622
  if (_this.config.formId == null)
3583
3623
  _this.config.formId = uuidv4();
3584
3624
  // console.log(this.config);
@@ -3590,8 +3630,8 @@
3590
3630
  _this.config.template = _this.manager.setupTemplate(_this.config.template, _this.configService.forms.formTemplates);
3591
3631
  _this.config.behaviors = Object.assign(Object.assign({}, _this.configService.forms.behaviors), _this.config.behaviors);
3592
3632
  try {
3593
- for (var _h = __values(_this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
3594
- var group = _j.value;
3633
+ for (var _l = __values(_this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
3634
+ var group = _m.value;
3595
3635
  // SETUP GROUP TEMPLATES
3596
3636
  group.template = _this.manager.setupTemplate(group.template, _this.configService.forms.groupTemplates);
3597
3637
  // SETUP INPUT PRESETS
@@ -3639,15 +3679,15 @@
3639
3679
  _this.manager.setupVisibilityServices(input, _this.config);
3640
3680
  };
3641
3681
  try {
3642
- for (var _k = (e_2 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
3643
- var input = _l.value;
3682
+ for (var _o = (e_2 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
3683
+ var input = _p.value;
3644
3684
  _loop_1(input);
3645
3685
  }
3646
3686
  }
3647
3687
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
3648
3688
  finally {
3649
3689
  try {
3650
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
3690
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
3651
3691
  }
3652
3692
  finally { if (e_2) throw e_2.error; }
3653
3693
  }
@@ -3657,12 +3697,13 @@
3657
3697
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
3658
3698
  finally {
3659
3699
  try {
3660
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
3700
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
3661
3701
  }
3662
3702
  finally { if (e_1) throw e_1.error; }
3663
3703
  }
3664
3704
  ;
3665
- _this.form = _this.fb.group(controlsConfig);
3705
+ var options = { updateOn: (_h = (_g = (_f = _this.config) === null || _f === void 0 ? void 0 : _f.behaviors) === null || _g === void 0 ? void 0 : _g.updateOn) !== null && _h !== void 0 ? _h : 'change' };
3706
+ _this.form = _this.fb.group(controlsConfig, options);
3666
3707
  if (_this.config._context == null) {
3667
3708
  _this.config._context = {
3668
3709
  applyGlobalStyles: null,
@@ -3674,7 +3715,7 @@
3674
3715
  }
3675
3716
  _this.linkInputControls();
3676
3717
  setTimeout(function () {
3677
- var _a, _b;
3718
+ var _a, _b, _c;
3678
3719
  _this.updateFormValues();
3679
3720
  // this.isValid = this.form.valid;
3680
3721
  var runCustomFunctionsOnLoad = (_b = (_a = _this.config.behaviors) === null || _a === void 0 ? void 0 : _a.runCustomFunctionsOnLoad) !== null && _b !== void 0 ? _b : false;
@@ -3684,7 +3725,9 @@
3684
3725
  _this.checkCustomFunctions();
3685
3726
  }
3686
3727
  else {
3687
- _this.statusChanges.emit(_this.getData());
3728
+ if (!((_c = _this.config.behaviors) === null || _c === void 0 ? void 0 : _c.skipEmitChangesOnLoad)) {
3729
+ _this.statusChanges.emit(_this.getData());
3730
+ }
3688
3731
  }
3689
3732
  // Esse timeout garante um adiamento no subscribe de status change do form para não ser executado na primeira inicialização
3690
3733
  setTimeout(function () {
@@ -3739,20 +3782,20 @@
3739
3782
  }, 0);
3740
3783
  };
3741
3784
  FormGroupComponent.prototype.linkInputControls = function () {
3742
- var e_3, _f, e_4, _g;
3785
+ var e_3, _j, e_4, _k;
3743
3786
  try {
3744
- for (var _h = __values(this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
3745
- var group = _j.value;
3787
+ for (var _l = __values(this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
3788
+ var group = _m.value;
3746
3789
  try {
3747
- for (var _k = (e_4 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
3748
- var input = _l.value;
3790
+ for (var _o = (e_4 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
3791
+ var input = _p.value;
3749
3792
  input._inputFormControl = this.form.controls[input.propertyName];
3750
3793
  }
3751
3794
  }
3752
3795
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
3753
3796
  finally {
3754
3797
  try {
3755
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
3798
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
3756
3799
  }
3757
3800
  finally { if (e_4) throw e_4.error; }
3758
3801
  }
@@ -3762,7 +3805,7 @@
3762
3805
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
3763
3806
  finally {
3764
3807
  try {
3765
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
3808
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
3766
3809
  }
3767
3810
  finally { if (e_3) throw e_3.error; }
3768
3811
  }
@@ -3787,22 +3830,22 @@
3787
3830
  }
3788
3831
  };
3789
3832
  FormGroupComponent.prototype.hasDuplicateNames = function () {
3790
- var e_5, _f, e_6, _g;
3833
+ var e_5, _j, e_6, _k;
3791
3834
  try {
3792
3835
  var inputs = [];
3793
3836
  try {
3794
- for (var _h = __values(this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
3795
- var group = _j.value;
3837
+ for (var _l = __values(this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
3838
+ var group = _m.value;
3796
3839
  try {
3797
- for (var _k = (e_6 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
3798
- var input = _l.value;
3840
+ for (var _o = (e_6 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
3841
+ var input = _p.value;
3799
3842
  inputs.push(input);
3800
3843
  }
3801
3844
  }
3802
3845
  catch (e_6_1) { e_6 = { error: e_6_1 }; }
3803
3846
  finally {
3804
3847
  try {
3805
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
3848
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
3806
3849
  }
3807
3850
  finally { if (e_6) throw e_6.error; }
3808
3851
  }
@@ -3812,7 +3855,7 @@
3812
3855
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
3813
3856
  finally {
3814
3857
  try {
3815
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
3858
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
3816
3859
  }
3817
3860
  finally { if (e_5) throw e_5.error; }
3818
3861
  }
@@ -3829,13 +3872,13 @@
3829
3872
  };
3830
3873
  /** Limpa todos os valores default */
3831
3874
  FormGroupComponent.prototype.clearFormValues = function () {
3832
- var e_7, _f, e_8, _g;
3875
+ var e_7, _j, e_8, _k;
3833
3876
  try {
3834
- for (var _h = __values(this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
3835
- var group = _j.value;
3877
+ for (var _l = __values(this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
3878
+ var group = _m.value;
3836
3879
  try {
3837
- for (var _k = (e_8 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
3838
- var input = _l.value;
3880
+ for (var _o = (e_8 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
3881
+ var input = _p.value;
3839
3882
  if (input.type === exports.SmzControlType.FILE) {
3840
3883
  var fileInput = input;
3841
3884
  CONTROL_FUNCTIONS[input.type].clear(this.form.controls[input.propertyName], fileInput._clearMethod);
@@ -3848,7 +3891,7 @@
3848
3891
  catch (e_8_1) { e_8 = { error: e_8_1 }; }
3849
3892
  finally {
3850
3893
  try {
3851
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
3894
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
3852
3895
  }
3853
3896
  finally { if (e_8) throw e_8.error; }
3854
3897
  }
@@ -3858,7 +3901,7 @@
3858
3901
  catch (e_7_1) { e_7 = { error: e_7_1 }; }
3859
3902
  finally {
3860
3903
  try {
3861
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
3904
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
3862
3905
  }
3863
3906
  finally { if (e_7) throw e_7.error; }
3864
3907
  }
@@ -3886,13 +3929,13 @@
3886
3929
  };
3887
3930
  /** Atualiza os valores dos inputs com seus dados default */
3888
3931
  FormGroupComponent.prototype.updateFormValues = function () {
3889
- var e_9, _f, e_10, _g;
3932
+ var e_9, _j, e_10, _k;
3890
3933
  try {
3891
- for (var _h = __values(this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
3892
- var group = _j.value;
3934
+ for (var _l = __values(this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
3935
+ var group = _m.value;
3893
3936
  try {
3894
- for (var _k = (e_10 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
3895
- var input = _l.value;
3937
+ for (var _o = (e_10 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
3938
+ var input = _p.value;
3896
3939
  var control = this.form.controls[input.propertyName];
3897
3940
  if (input.isDisabled) {
3898
3941
  control.disable();
@@ -3906,7 +3949,7 @@
3906
3949
  catch (e_10_1) { e_10 = { error: e_10_1 }; }
3907
3950
  finally {
3908
3951
  try {
3909
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
3952
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
3910
3953
  }
3911
3954
  finally { if (e_10) throw e_10.error; }
3912
3955
  }
@@ -3916,7 +3959,7 @@
3916
3959
  catch (e_9_1) { e_9 = { error: e_9_1 }; }
3917
3960
  finally {
3918
3961
  try {
3919
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
3962
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
3920
3963
  }
3921
3964
  finally { if (e_9) throw e_9.error; }
3922
3965
  }
@@ -3956,14 +3999,14 @@
3956
3999
  }, 0);
3957
4000
  };
3958
4001
  FormGroupComponent.prototype.fixRadioBug = function () {
3959
- var e_11, _f, e_12, _g;
4002
+ var e_11, _j, e_12, _k;
3960
4003
  var _this = this;
3961
4004
  try {
3962
4005
  // https://github.com/primefaces/primeng/pull/9265
3963
4006
  // https://stackblitz.com/edit/primengdemo-rh51xa?file=src%2Fapp%2Fapp.component.ts
3964
4007
  // https://stackoverflow.com/questions/64827771/primeng-radio-button-selecting-multiple-items
3965
- for (var _h = __values(this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
3966
- var group = _j.value;
4008
+ for (var _l = __values(this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
4009
+ var group = _m.value;
3967
4010
  var _loop_2 = function (input) {
3968
4011
  if (input.type === exports.SmzControlType.RADIO) {
3969
4012
  this_1.form.get(input.propertyName).valueChanges.subscribe(function (val) {
@@ -3974,15 +4017,15 @@
3974
4017
  };
3975
4018
  var this_1 = this;
3976
4019
  try {
3977
- for (var _k = (e_12 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
3978
- var input = _l.value;
4020
+ for (var _o = (e_12 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
4021
+ var input = _p.value;
3979
4022
  _loop_2(input);
3980
4023
  }
3981
4024
  }
3982
4025
  catch (e_12_1) { e_12 = { error: e_12_1 }; }
3983
4026
  finally {
3984
4027
  try {
3985
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
4028
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
3986
4029
  }
3987
4030
  finally { if (e_12) throw e_12.error; }
3988
4031
  }
@@ -3992,7 +4035,7 @@
3992
4035
  catch (e_11_1) { e_11 = { error: e_11_1 }; }
3993
4036
  finally {
3994
4037
  try {
3995
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
4038
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
3996
4039
  }
3997
4040
  finally { if (e_11) throw e_11.error; }
3998
4041
  }
@@ -4000,7 +4043,7 @@
4000
4043
  };
4001
4044
  /** Retorna o objeto com os valores dos inputs; Esse objeto seguirá a nomemclatura do campo name de cada inputConfig */
4002
4045
  FormGroupComponent.prototype.getData = function () {
4003
- var e_13, _f, e_14, _g;
4046
+ var e_13, _j, e_14, _k;
4004
4047
  var _a, _b;
4005
4048
  // console.log('--------------------------');
4006
4049
  // console.log('--------------------------');
@@ -4009,11 +4052,11 @@
4009
4052
  var response = { data: data, isValid: true };
4010
4053
  var formFlattenResponse = (_b = (_a = this.config.behaviors) === null || _a === void 0 ? void 0 : _a.flattenResponse) !== null && _b !== void 0 ? _b : false;
4011
4054
  try {
4012
- for (var _h = __values(this.config.groups), _j = _h.next(); !_j.done; _j = _h.next()) {
4013
- var group = _j.value;
4055
+ for (var _l = __values(this.config.groups), _m = _l.next(); !_m.done; _m = _l.next()) {
4056
+ var group = _m.value;
4014
4057
  try {
4015
- for (var _k = (e_14 = void 0, __values(group.children)), _l = _k.next(); !_l.done; _l = _k.next()) {
4016
- var input = _l.value;
4058
+ for (var _o = (e_14 = void 0, __values(group.children)), _p = _o.next(); !_p.done; _p = _o.next()) {
4059
+ var input = _p.value;
4017
4060
  if (input.advancedSettings == null || !input.advancedSettings.excludeFromResponse) {
4018
4061
  var value = CONTROL_FUNCTIONS[input.type].getValue(this.form, input, formFlattenResponse);
4019
4062
  if (input.visibilityDependsOn == null || input.isVisible) {
@@ -4034,7 +4077,7 @@
4034
4077
  catch (e_14_1) { e_14 = { error: e_14_1 }; }
4035
4078
  finally {
4036
4079
  try {
4037
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
4080
+ if (_p && !_p.done && (_k = _o.return)) _k.call(_o);
4038
4081
  }
4039
4082
  finally { if (e_14) throw e_14.error; }
4040
4083
  }
@@ -4044,7 +4087,7 @@
4044
4087
  catch (e_13_1) { e_13 = { error: e_13_1 }; }
4045
4088
  finally {
4046
4089
  try {
4047
- if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
4090
+ if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
4048
4091
  }
4049
4092
  finally { if (e_13) throw e_13.error; }
4050
4093
  }
@@ -12122,7 +12165,7 @@
12122
12165
  formId: angular2Uuid.UUID.UUID(),
12123
12166
  groups: [],
12124
12167
  template: Object.assign({ extraSmall: { horizontalAlignment: 'justify-content-between', verticalAlignment: 'align-items-start' }, small: { horizontalAlignment: 'justify-content-between', verticalAlignment: 'align-items-start' } }, (_b = (_a = this.defaultConfig) === null || _a === void 0 ? void 0 : _a.forms) === null || _b === void 0 ? void 0 : _b.formTemplates),
12125
- behaviors: Object.assign({ avoidFocusOnLoad: false, debounceTime: 400, flattenResponse: true, runCustomFunctionsOnLoad: false, skipFunctionAfterNextEmit: false, showErrorsMethod: 'touched' }, (_d = (_c = this.defaultConfig) === null || _c === void 0 ? void 0 : _c.forms) === null || _d === void 0 ? void 0 : _d.behaviors),
12168
+ behaviors: Object.assign({ avoidFocusOnLoad: false, debounceTime: 400, flattenResponse: true, runCustomFunctionsOnLoad: false, skipFunctionAfterNextEmit: false, skipEmitChangesOnLoad: false, showErrorsMethod: 'touched' }, (_d = (_c = this.defaultConfig) === null || _c === void 0 ? void 0 : _c.forms) === null || _d === void 0 ? void 0 : _d.behaviors),
12126
12169
  };
12127
12170
  this.createdByUiDefinitions = false;
12128
12171
  if (state != null) {
@@ -12149,6 +12192,16 @@
12149
12192
  this._state.behaviors.debounceTime = debouceTime;
12150
12193
  return this;
12151
12194
  };
12195
+ SmzFormBuilder.prototype.setEmitChangesBehavior = function (updateOn) {
12196
+ this._state.behaviors.updateOn = updateOn;
12197
+ if (updateOn !== 'change')
12198
+ this._state.behaviors.skipEmitChangesOnLoad = true;
12199
+ return this;
12200
+ };
12201
+ SmzFormBuilder.prototype.avoidEmitChangesOnLoad = function () {
12202
+ this._state.behaviors.skipEmitChangesOnLoad = true;
12203
+ return this;
12204
+ };
12152
12205
  Object.defineProperty(SmzFormBuilder.prototype, "dialog", {
12153
12206
  get: function () {
12154
12207
  return this._dialogBuilder;