monkey-front-components 0.0.180 → 0.0.181

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/esm2020/lib/components/base/base-component.mjs +297 -0
  2. package/esm2020/lib/components/base/base-dynamic-array.mjs +221 -0
  3. package/esm2020/lib/components/base/base-dynamic.mjs +99 -0
  4. package/{esm2015/lib/components/base/base-validators.js → esm2020/lib/components/base/base-validators.mjs} +1 -1
  5. package/{esm2015/lib/components/base/index.js → esm2020/lib/components/base/index.mjs} +0 -0
  6. package/esm2020/lib/components/dynamic/button/button.component.mjs +52 -0
  7. package/{esm2015/lib/components/dynamic/button/index.js → esm2020/lib/components/dynamic/button/index.mjs} +0 -0
  8. package/esm2020/lib/components/dynamic/dynamic-directive.mjs +95 -0
  9. package/{esm2015/lib/components/dynamic/dynamic.module.js → esm2020/lib/components/dynamic/dynamic.module.mjs} +5 -5
  10. package/esm2020/lib/components/dynamic/file-upload/file-upload.component.mjs +52 -0
  11. package/{esm2015/lib/components/dynamic/file-upload/index.js → esm2020/lib/components/dynamic/file-upload/index.mjs} +0 -0
  12. package/esm2020/lib/components/dynamic/form/dynamic-form-array.component.mjs +72 -0
  13. package/esm2020/lib/components/dynamic/form/dynamic-form.component.mjs +46 -0
  14. package/{esm2015/lib/components/dynamic/form/index.js → esm2020/lib/components/dynamic/form/index.mjs} +0 -0
  15. package/{esm2015/lib/components/dynamic/index.js → esm2020/lib/components/dynamic/index.mjs} +0 -0
  16. package/{esm2015/lib/components/dynamic/input/index.js → esm2020/lib/components/dynamic/input/index.mjs} +0 -0
  17. package/esm2020/lib/components/dynamic/input/input.component.mjs +65 -0
  18. package/{esm2015/lib/components/dynamic/input-phone/index.js → esm2020/lib/components/dynamic/input-phone/index.mjs} +0 -0
  19. package/esm2020/lib/components/dynamic/input-phone/input-phone.component.mjs +65 -0
  20. package/{esm2015/lib/components/dynamic/radio/index.js → esm2020/lib/components/dynamic/radio/index.mjs} +0 -0
  21. package/esm2020/lib/components/dynamic/radio/radio.component.mjs +33 -0
  22. package/{esm2015/lib/components/dynamic/select/index.js → esm2020/lib/components/dynamic/select/index.mjs} +0 -0
  23. package/esm2020/lib/components/dynamic/select/select.component.mjs +80 -0
  24. package/{esm2015/lib/components/dynamic/select-search/index.js → esm2020/lib/components/dynamic/select-search/index.mjs} +0 -0
  25. package/esm2020/lib/components/dynamic/select-search/select-search.component.mjs +80 -0
  26. package/{esm2015/lib/components/index.js → esm2020/lib/components/index.mjs} +0 -0
  27. package/{esm2015/lib/components/shared/index.js → esm2020/lib/components/shared/index.mjs} +2 -1
  28. package/{esm2015/lib/components/shared/password-strength/index.js → esm2020/lib/components/shared/password-strength/index.mjs} +0 -0
  29. package/esm2020/lib/components/shared/password-strength/password-strength.component.mjs +83 -0
  30. package/{esm2015/lib/components/shared/password-strength/password-strength.js → esm2020/lib/components/shared/password-strength/password-strength.mjs} +0 -0
  31. package/{esm2015/lib/components/shared/password-strength/password-strength.module.js → esm2020/lib/components/shared/password-strength/password-strength.module.mjs} +5 -5
  32. package/esm2020/lib/components/shared/progress-bar/index.mjs +4 -0
  33. package/esm2020/lib/components/shared/progress-bar/progress-bar.component.mjs +28 -0
  34. package/esm2020/lib/components/shared/progress-bar/progress-bar.module.mjs +18 -0
  35. package/esm2020/lib/components/shared/progress-bar/progress-bar.service.mjs +49 -0
  36. package/{esm2015/lib/interfaces/field-config.js → esm2020/lib/interfaces/field-config.mjs} +0 -0
  37. package/{esm2015/lib/interfaces/index.js → esm2020/lib/interfaces/index.mjs} +0 -0
  38. package/{esm2015/monkey-front-components.js → esm2020/monkey-front-components.mjs} +0 -0
  39. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  40. package/fesm2015/monkey-front-components.mjs +1493 -0
  41. package/fesm2015/monkey-front-components.mjs.map +1 -0
  42. package/fesm2020/monkey-front-components.mjs +1477 -0
  43. package/fesm2020/monkey-front-components.mjs.map +1 -0
  44. package/lib/components/base/base-component.d.ts +1 -1
  45. package/lib/components/base/base-dynamic-array.d.ts +1 -1
  46. package/lib/components/base/base-dynamic.d.ts +1 -1
  47. package/lib/components/base/base-validators.d.ts +1 -14
  48. package/lib/components/dynamic/button/button.component.d.ts +2 -2
  49. package/lib/components/dynamic/dynamic-directive.d.ts +2 -2
  50. package/lib/components/dynamic/input/input.component.d.ts +3 -3
  51. package/lib/components/dynamic/input-phone/input-phone.component.d.ts +3 -3
  52. package/lib/components/dynamic/radio/radio.component.d.ts +2 -2
  53. package/lib/components/dynamic/select/select.component.d.ts +2 -2
  54. package/lib/components/dynamic/select-search/select-search.component.d.ts +2 -2
  55. package/lib/components/shared/index.d.ts +1 -0
  56. package/lib/components/shared/password-strength/password-strength.component.d.ts +2 -2
  57. package/lib/components/shared/progress-bar/index.d.ts +3 -0
  58. package/lib/components/shared/progress-bar/progress-bar.component.d.ts +12 -0
  59. package/lib/components/shared/progress-bar/progress-bar.module.d.ts +8 -0
  60. package/lib/components/shared/progress-bar/progress-bar.service.d.ts +14 -0
  61. package/monkey-front-components-0.0.181.tgz +0 -0
  62. package/package.json +24 -10
  63. package/bundles/monkey-front-components.umd.js +0 -1866
  64. package/bundles/monkey-front-components.umd.js.map +0 -1
  65. package/esm2015/lib/components/base/base-component.js +0 -288
  66. package/esm2015/lib/components/base/base-dynamic-array.js +0 -215
  67. package/esm2015/lib/components/base/base-dynamic.js +0 -98
  68. package/esm2015/lib/components/dynamic/button/button.component.js +0 -57
  69. package/esm2015/lib/components/dynamic/dynamic-directive.js +0 -95
  70. package/esm2015/lib/components/dynamic/file-upload/file-upload.component.js +0 -57
  71. package/esm2015/lib/components/dynamic/form/dynamic-form-array.component.js +0 -77
  72. package/esm2015/lib/components/dynamic/form/dynamic-form.component.js +0 -51
  73. package/esm2015/lib/components/dynamic/input/input.component.js +0 -66
  74. package/esm2015/lib/components/dynamic/input-phone/input-phone.component.js +0 -66
  75. package/esm2015/lib/components/dynamic/radio/radio.component.js +0 -36
  76. package/esm2015/lib/components/dynamic/select/select.component.js +0 -81
  77. package/esm2015/lib/components/dynamic/select-search/select-search.component.js +0 -81
  78. package/esm2015/lib/components/shared/password-strength/password-strength.component.js +0 -89
  79. package/fesm2015/monkey-front-components.js +0 -1414
  80. package/fesm2015/monkey-front-components.js.map +0 -1
  81. package/monkey-front-components-0.0.180.tgz +0 -0
@@ -0,0 +1,1477 @@
1
+ import { Subject, BehaviorSubject } from 'rxjs';
2
+ import * as i0 from '@angular/core';
3
+ import { Directive, EventEmitter, Input, Output, Component, ViewEncapsulation, HostBinding, ViewChild, NgModule, Injectable } from '@angular/core';
4
+ import { takeUntil, filter } from 'rxjs/operators';
5
+ import * as i1$1 from 'monkey-style-guide';
6
+ import { MonkeyUtils, MonkeyInputModule, MonkeySelectModule, MonkeyRadioButtonModule, MonkeyOptionModule, MonkeyFileUploadModule, MonkeyButtonModule, MonkeyInputPhoneModule, MonkeyIconModule } from 'monkey-style-guide';
7
+ import * as i1$2 from 'monkey-front-core';
8
+ import { MonkeyEcxCommonsService, ValidateUtils, Validators as Validators$1, MonkeyEcxUtils, MonkeyEcxPipesModule, MonkeyEcxDirectivesModule } from 'monkey-front-core';
9
+ import * as i1 from '@angular/forms';
10
+ import { Validators, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
11
+ import * as i3 from '@angular/common';
12
+ import { CommonModule } from '@angular/common';
13
+ import * as i4 from '@ngx-translate/core';
14
+ import { TranslateModule } from '@ngx-translate/core';
15
+ import * as i1$3 from '@angular/router';
16
+ import { NavigationStart, NavigationEnd, NavigationError, NavigationCancel } from '@angular/router';
17
+
18
+ class BaseComponent {
19
+ constructor() {
20
+ this.__paginationOptions = null;
21
+ this.__isMobile = this.isMobile();
22
+ this.__locales = ['pt-BR', 'es-CL'];
23
+ this.__unsubscribeAll = new Subject();
24
+ }
25
+ isMobile() {
26
+ const isMobileWidth = (window.screen.width <= 640) ||
27
+ (window.matchMedia &&
28
+ window.matchMedia('only screen and (max-width: 640px)').matches);
29
+ return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|Mobile/i.test(navigator.userAgent)) || isMobileWidth;
30
+ }
31
+ handlePagination(create = true) {
32
+ const { __paginationOptions } = this;
33
+ if (__paginationOptions) {
34
+ const { mainElement, service } = __paginationOptions;
35
+ setTimeout(() => {
36
+ const element = document.getElementById(mainElement);
37
+ if (element) {
38
+ element.scroll = null;
39
+ element.onscroll = null;
40
+ if (create) {
41
+ this.paginationFunc = () => {
42
+ const { scrollTop, scrollHeight, offsetHeight } = element;
43
+ const contentHeight = scrollHeight - offsetHeight;
44
+ if (contentHeight <= scrollTop) {
45
+ service.__onDoPagination$.next(null);
46
+ }
47
+ };
48
+ element.addEventListener('scroll', this.paginationFunc);
49
+ }
50
+ else {
51
+ element.removeEventListener('scroll', this.paginationFunc);
52
+ }
53
+ }
54
+ }, 200);
55
+ }
56
+ }
57
+ handleSupport(supportControls) {
58
+ const { service, show } = supportControls;
59
+ const method = show ? 'show' : 'hide';
60
+ service[method.toLowerCase()]();
61
+ }
62
+ handleTranslate(translateOptions) {
63
+ const { service } = translateOptions;
64
+ service.__oni18nDataChanged$
65
+ .pipe(takeUntil(this.__unsubscribeAll))
66
+ .subscribe(() => {
67
+ const data = service.__i18n;
68
+ if (data) {
69
+ this.__i18n = data;
70
+ }
71
+ });
72
+ }
73
+ getErrorFirstMessageTranslated(formControl = null) {
74
+ if (formControl?.hasError('required'))
75
+ return 'FIELD-REQUIRED';
76
+ if (formControl?.hasError('invalid'))
77
+ return 'FIELD-INVALID';
78
+ if (formControl?.hasError('email'))
79
+ return 'INVALID-EMAIL';
80
+ if (formControl?.hasError('minlength'))
81
+ return 'MIN-LENGTH';
82
+ if (formControl?.hasError('maxlength'))
83
+ return 'MAX-LENGTH';
84
+ if (formControl?.hasError('max'))
85
+ return 'MAX';
86
+ if (formControl?.hasError('min'))
87
+ return 'MIN';
88
+ if (formControl?.hasError('passwordsNotMatching'))
89
+ return 'MATCH-PASSWORD';
90
+ if (formControl?.hasError('invalidDate'))
91
+ return 'INVALID-DATE';
92
+ if (formControl?.hasError('invalidTrue'))
93
+ return 'INVALID-TRUE';
94
+ if (formControl?.hasError('invalidCpfCnpj'))
95
+ return 'INVALID-DOCUMENT';
96
+ if (formControl?.hasError('invalidZipCode'))
97
+ return 'INVALID-ZIPCODE';
98
+ if (formControl?.hasError('invalidCombo'))
99
+ return 'INVALID-COMBO';
100
+ if (formControl?.hasError('invalidUrl'))
101
+ return 'INVALID-URL';
102
+ if (formControl?.hasError('invalidUnlockRegister')) {
103
+ return 'INVALID-UNLOCK-REGISTER';
104
+ }
105
+ if (formControl?.hasError('dateStartMustBeLessThanAnd')) {
106
+ return 'DATE-START-MUST-BE-LESS-THAN-AND';
107
+ }
108
+ if (formControl?.hasError('dateEndMustBeGreaterThanStart')) {
109
+ return 'DATE-END-MUST-BE-GREATER-THAN-SART';
110
+ }
111
+ if (formControl?.hasError('phone'))
112
+ return 'INVALID-PHONE';
113
+ return 'FIELD-INVALID';
114
+ }
115
+ getErrorLastMessageNotTranslated(formControl = null) {
116
+ if (formControl?.hasError('minlength')) {
117
+ return `${formControl?.getError('minlength').requiredLength} caracteres.`;
118
+ }
119
+ if (formControl?.hasError('maxlength')) {
120
+ return `${formControl?.getError('maxlength').requiredLength} caracteres.`;
121
+ }
122
+ if (formControl?.hasError('max')) {
123
+ return `${formControl?.getError('max').max}`;
124
+ }
125
+ if (formControl?.hasError('min')) {
126
+ return `${formControl?.getError('min').min}`;
127
+ }
128
+ return '';
129
+ }
130
+ validateFormWithTranslate(f, index) {
131
+ const formErrors = f.value;
132
+ if (f.status === 'VALID')
133
+ return true;
134
+ if (!formErrors)
135
+ return true;
136
+ Object.entries(formErrors).forEach(([key, value]) => {
137
+ const control = f.get(key);
138
+ formErrors[key] = '';
139
+ if (control && !control.valid) {
140
+ const msg = {
141
+ first: `ERRORS.${this.getErrorFirstMessageTranslated(f.get(key))}`,
142
+ last: this.getErrorLastMessageNotTranslated(f.get(key))
143
+ };
144
+ formErrors[key] = msg;
145
+ }
146
+ });
147
+ if (MonkeyUtils.persistNullEmptyUndefined(index)) {
148
+ this.__monkeyecxFormErrors[index || 0] = formErrors;
149
+ }
150
+ else {
151
+ this.__monkeyecxFormErrors = formErrors;
152
+ }
153
+ return false;
154
+ }
155
+ copyToClipboard(val) {
156
+ const selBox = document.createElement('textarea');
157
+ selBox.style.position = 'fixed';
158
+ selBox.style.left = '0';
159
+ selBox.style.top = '0';
160
+ selBox.style.opacity = '0';
161
+ selBox.value = val;
162
+ document.body.appendChild(selBox);
163
+ selBox.focus();
164
+ selBox.select();
165
+ document.execCommand('copy');
166
+ document.body.removeChild(selBox);
167
+ }
168
+ validateForm(f, index, alias) {
169
+ const formErrors = f.value;
170
+ if (f.status === 'VALID')
171
+ return true;
172
+ if (!formErrors)
173
+ return true;
174
+ Object.entries(formErrors).forEach(([key, value]) => {
175
+ const control = f.get(key);
176
+ formErrors[key] = '';
177
+ if (control && !control.valid) {
178
+ const msg = {
179
+ firstMessage: `ERRORS.${this.getErrorFirstMessageTranslated(f.get(key))}`,
180
+ lastMessage: this.getErrorLastMessageNotTranslated(f.get(key))
181
+ };
182
+ formErrors[key] = msg;
183
+ }
184
+ });
185
+ if (MonkeyUtils.persistNullEmptyUndefined(index)) {
186
+ this.__monkeyecxFormErrors[index || 0] = formErrors;
187
+ }
188
+ else {
189
+ let obj;
190
+ if (alias) {
191
+ obj = {
192
+ [alias]: {
193
+ ...formErrors
194
+ }
195
+ };
196
+ }
197
+ else {
198
+ obj = formErrors;
199
+ }
200
+ this.__monkeyecxFormErrors = {
201
+ ...this.__monkeyecxFormErrors,
202
+ ...obj
203
+ };
204
+ }
205
+ f.markAllAsTouched();
206
+ return false;
207
+ }
208
+ clearAllServiceData(clearData) {
209
+ const context = this;
210
+ Object.values(context).forEach((ctx) => {
211
+ if (ctx instanceof MonkeyEcxCommonsService) {
212
+ ctx.clear(clearData);
213
+ }
214
+ });
215
+ }
216
+ ngOnInit(args) {
217
+ if (args?.paginationOptions) {
218
+ this.__paginationOptions = args?.paginationOptions;
219
+ this.handlePagination();
220
+ }
221
+ if (args?.supportControls) {
222
+ this.handleSupport(args?.supportControls);
223
+ }
224
+ if (args?.translateOptions) {
225
+ this.handleTranslate(args?.translateOptions);
226
+ }
227
+ }
228
+ ngOnDestroy(clearData = true) {
229
+ this.__unsubscribeAll.next();
230
+ this.__unsubscribeAll.complete();
231
+ this.clearAllServiceData(clearData);
232
+ this.handlePagination(false);
233
+ }
234
+ handleErrorFromServices(error, f) {
235
+ this.__monkeyecxFormErrors = null;
236
+ if (error.type === 'Parameter_Error') {
237
+ Object.entries(f.value).forEach(([key, value]) => {
238
+ error.notifications.forEach((_) => {
239
+ const field = _.split(':')[0];
240
+ const description = _.split(':')[1];
241
+ if (field === key) {
242
+ const msg = {
243
+ firstMessage: '',
244
+ lastMessage: description
245
+ };
246
+ this.__monkeyecxFormErrors = {
247
+ ...this.__monkeyecxFormErrors,
248
+ [key]: msg
249
+ };
250
+ f.controls[key].setErrors({
251
+ incorrect: true
252
+ });
253
+ }
254
+ });
255
+ });
256
+ }
257
+ f.markAllAsTouched();
258
+ }
259
+ goBack() {
260
+ window.history.back();
261
+ }
262
+ goScroll(id) {
263
+ const element = document.getElementById(id);
264
+ if (element)
265
+ element.scrollIntoView();
266
+ }
267
+ getEmbeddedData(data, field) {
268
+ const { _embedded } = data;
269
+ return _embedded ? _embedded[field] : null;
270
+ }
271
+ openWindow(url) {
272
+ window.open(`${url}`, '_blank');
273
+ }
274
+ fillI18n(data) {
275
+ this.__i18n = data;
276
+ }
277
+ getCountryPrefix(country) {
278
+ return {
279
+ br: 55,
280
+ cl: 56
281
+ }[country];
282
+ }
283
+ getCountryCurrencyChartFormat(country) {
284
+ return {
285
+ br: 'R$ #,###,##0.00',
286
+ cl: 'CLP #,###,##0'
287
+ }[country];
288
+ }
289
+ getCountryValidators(country) {
290
+ return {
291
+ br: {
292
+ governmentId: ValidateUtils.DocumentValidator
293
+ },
294
+ cl: {
295
+ governmentId: ValidateUtils.DocumentRutValidator
296
+ }
297
+ }[country];
298
+ }
299
+ }
300
+ BaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
301
+ BaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: BaseComponent, selector: "[baseComponent]", ngImport: i0 });
302
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseComponent, decorators: [{
303
+ type: Directive,
304
+ args: [{
305
+ selector: '[baseComponent]'
306
+ }]
307
+ }], ctorParameters: function () { return []; } });
308
+
309
+ const validators = {
310
+ required: Validators.required,
311
+ email: Validators$1.email,
312
+ governmentId: Validators$1.documentBR,
313
+ governmentIdRut: Validators$1.documentCL,
314
+ documentBR: Validators$1.documentBR,
315
+ documentCL: Validators$1.documentCL,
316
+ date: Validators$1.date,
317
+ zipCode: Validators$1.zipCode,
318
+ minLength: (param) => {
319
+ return Validators.minLength(param);
320
+ },
321
+ maxLength: (param) => {
322
+ return Validators.maxLength(param);
323
+ }
324
+ };
325
+
326
+ class BaseDynamic extends BaseComponent {
327
+ constructor(fb) {
328
+ super();
329
+ this.fb = fb;
330
+ this.onHandleSubmit = new EventEmitter();
331
+ this.onHandleUpdateForm = new EventEmitter();
332
+ this.onHandleSubmitFormReady = new EventEmitter();
333
+ this.fields = [];
334
+ this.disabled = false;
335
+ this._form = null;
336
+ }
337
+ createControl() {
338
+ const { fields } = this;
339
+ if (!fields)
340
+ return null;
341
+ // eslint-disable-next-line object-curly-newline
342
+ const group = this.fb.group({});
343
+ fields.forEach((field) => {
344
+ const { fieldType, validations, name, disabled } = field;
345
+ let { value } = field;
346
+ if (fieldType === 'button')
347
+ return;
348
+ if (fieldType === 'radiobutton' || fieldType === 'checkbox' || fieldType === 'select') {
349
+ value = '';
350
+ }
351
+ const control = this.fb.control(value, this.bindValidations(validations || []));
352
+ if (disabled || this.disabled)
353
+ control.disable();
354
+ group.addControl(name, control);
355
+ });
356
+ return group;
357
+ }
358
+ bindValidations(validations) {
359
+ if (validations.length > 0) {
360
+ const validList = [];
361
+ validations.forEach((valid) => {
362
+ const validated = valid.param
363
+ ? validators[valid.name](valid.param)
364
+ : validators[valid.name];
365
+ validList.push(validated);
366
+ });
367
+ return Validators.compose(validList);
368
+ }
369
+ return null;
370
+ }
371
+ fillValues() {
372
+ const { data } = this;
373
+ if (!data || !this._form)
374
+ return;
375
+ Object.entries(data).forEach(([key, value]) => {
376
+ if (MonkeyUtils.persistNullEmptyUndefined(value) && this._form?.controls[key]) {
377
+ this._form?.controls[key]?.setValue(value);
378
+ }
379
+ });
380
+ }
381
+ ngOnInit() {
382
+ this._form = this.createControl();
383
+ this.fillValues();
384
+ this.onHandleUpdateForm.subscribe(() => {
385
+ this.fillValues();
386
+ });
387
+ }
388
+ ngOnChanges() {
389
+ if (!this._form) {
390
+ this._form = this.createControl();
391
+ }
392
+ this.fillValues();
393
+ }
394
+ }
395
+ BaseDynamic.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseDynamic, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Directive });
396
+ BaseDynamic.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: BaseDynamic, selector: "[baseDynamic]", inputs: { onHandleSubmit: "onHandleSubmit", onHandleUpdateForm: "onHandleUpdateForm", self: "self", fields: "fields", data: "data", disabled: "disabled" }, outputs: { onHandleSubmitFormReady: "onHandleSubmitFormReady" }, usesInheritance: true, usesOnChanges: true, ngImport: i0 });
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseDynamic, decorators: [{
398
+ type: Directive,
399
+ args: [{
400
+ selector: '[baseDynamic]'
401
+ }]
402
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { onHandleSubmit: [{
403
+ type: Input
404
+ }], onHandleUpdateForm: [{
405
+ type: Input
406
+ }], onHandleSubmitFormReady: [{
407
+ type: Output
408
+ }], self: [{
409
+ type: Input
410
+ }], fields: [{
411
+ type: Input
412
+ }], data: [{
413
+ type: Input
414
+ }], disabled: [{
415
+ type: Input
416
+ }] } });
417
+
418
+ class BaseDynamicArray extends BaseComponent {
419
+ constructor(fb) {
420
+ super();
421
+ this.fb = fb;
422
+ this.onHandleSubmit = new EventEmitter();
423
+ this.onHandleUpdateForm = new EventEmitter();
424
+ this.onHandleSubmitFormReady = new EventEmitter();
425
+ this.fields = [];
426
+ this.qtd = 1;
427
+ this.disabled = false;
428
+ this._form = null;
429
+ // eslint-disable-next-line object-curly-newline
430
+ this._plusValidations = [];
431
+ this.changesUnsubscribe = new Subject();
432
+ this.formBase = () => {
433
+ // return this.fb.group(this.createControl());
434
+ return this.createControl();
435
+ };
436
+ }
437
+ handleInternalPlusValidation(mainField, data) {
438
+ const { operator, field, value } = mainField;
439
+ const validators = {
440
+ e: (val1, val2) => { return val1 === val2; },
441
+ lt: (val1, val2) => { return val1 < val2; },
442
+ gt: (val1, val2) => { return val1 > val2; }
443
+ };
444
+ return validators[operator](data?.[field] || data, value);
445
+ }
446
+ makeInternalPlusValidation(data, sourceField, settings, rowIndex) {
447
+ const changeFields = (show) => {
448
+ const saved = [...this.fields];
449
+ saved.map((val) => {
450
+ const valSaved = {
451
+ ...val
452
+ };
453
+ if (val.name === sourceField) {
454
+ this._plusValidations[rowIndex] = {
455
+ [sourceField]: {
456
+ ...valSaved,
457
+ alwaysShow: show
458
+ }
459
+ };
460
+ this.createOneControl(val.name, this.formValues?.controls[rowIndex], show);
461
+ }
462
+ else {
463
+ this._plusValidations[rowIndex] = {
464
+ ...valSaved
465
+ };
466
+ }
467
+ return null;
468
+ });
469
+ };
470
+ const validated = this.handleInternalPlusValidation(settings, data);
471
+ changeFields(validated);
472
+ }
473
+ createOneControl(fieldName, ctrl, create = true) {
474
+ const { fields } = this;
475
+ if (!fields)
476
+ return;
477
+ fields.forEach((field) => {
478
+ const { fieldType, validations, name, disabled } = field;
479
+ if (name !== fieldName)
480
+ return;
481
+ let { value } = field;
482
+ if (fieldType === 'button')
483
+ return;
484
+ if (fieldType === 'radiobutton' || fieldType === 'checkbox' || fieldType === 'select') {
485
+ value = '';
486
+ }
487
+ if (create) {
488
+ const control = this.fb.control(value, this.bindValidations(validations || []));
489
+ if (disabled || this.disabled)
490
+ control.disable();
491
+ ctrl.addControl(name, control);
492
+ }
493
+ else {
494
+ ctrl.removeControl(name);
495
+ }
496
+ });
497
+ }
498
+ createControl(data) {
499
+ const { fields } = this;
500
+ if (!fields)
501
+ return null;
502
+ // eslint-disable-next-line object-curly-newline
503
+ const group = this.fb.group({});
504
+ fields.forEach((field) => {
505
+ const { fieldType, validations, name, disabled, alwaysShow } = field;
506
+ let { value } = field;
507
+ if (field.alwaysShowPlusValidation) {
508
+ if (!this.handleInternalPlusValidation(field.alwaysShowPlusValidation, data))
509
+ return;
510
+ }
511
+ else if (!alwaysShow)
512
+ return;
513
+ if (fieldType === 'button')
514
+ return;
515
+ if (fieldType === 'radiobutton' || fieldType === 'checkbox' || fieldType === 'select') {
516
+ value = '';
517
+ }
518
+ const control = this.fb.control(value, this.bindValidations(validations || []));
519
+ if (disabled || this.disabled)
520
+ control.disable();
521
+ group.addControl(name, control);
522
+ });
523
+ return group;
524
+ }
525
+ bindValidations(validations) {
526
+ if (validations.length > 0) {
527
+ const validList = [];
528
+ validations.forEach((valid) => {
529
+ const validated = valid.param
530
+ ? validators[valid.name](valid.param)
531
+ : validators[valid.name];
532
+ validList.push(validated);
533
+ });
534
+ return Validators.compose(validList);
535
+ }
536
+ return null;
537
+ }
538
+ buildForm() {
539
+ const form = this.fb.group({
540
+ fields: this.fb.array([])
541
+ });
542
+ form?.controls.fields?.valueChanges.subscribe((_) => {
543
+ this.watchForChanges();
544
+ });
545
+ return form;
546
+ }
547
+ watchForChanges() {
548
+ const { fields, changesUnsubscribe } = this;
549
+ changesUnsubscribe.next();
550
+ this.formValues?.controls?.map((control, index) => {
551
+ fields.forEach((fieldConfig) => {
552
+ const { name, alwaysShowPlusValidation } = fieldConfig;
553
+ if (!alwaysShowPlusValidation)
554
+ return;
555
+ const { field } = alwaysShowPlusValidation;
556
+ if (field) {
557
+ control.controls[field]?.valueChanges.pipe(takeUntil(changesUnsubscribe)).subscribe((_) => {
558
+ this.makeInternalPlusValidation(_, name, alwaysShowPlusValidation, index);
559
+ });
560
+ }
561
+ });
562
+ return null;
563
+ });
564
+ }
565
+ get formValues() {
566
+ return this._form ? this._form.get('fields') : null;
567
+ }
568
+ fillValues() {
569
+ const { data, qtd } = this;
570
+ if ((!this._form) && qtd)
571
+ return;
572
+ if (qtd > 0) {
573
+ Array(qtd)
574
+ .fill(null)
575
+ .map((_, index) => {
576
+ let form = this.createControl();
577
+ if (data && data[index]) {
578
+ form = this.createControl(data[index]);
579
+ const handledData = data[index];
580
+ Object.entries(handledData).forEach(([key, value]) => {
581
+ if (MonkeyUtils.persistNullEmptyUndefined(value) && form?.controls[key]) {
582
+ form?.controls[key].setValue(value);
583
+ }
584
+ });
585
+ }
586
+ this.formValues?.push(form);
587
+ return null;
588
+ });
589
+ }
590
+ }
591
+ ngOnInit() {
592
+ this._form = this.buildForm();
593
+ this.fillValues();
594
+ this.onHandleUpdateForm.subscribe(() => {
595
+ this.fillValues();
596
+ });
597
+ }
598
+ ngOnChanges() {
599
+ if (!this._form) {
600
+ this._form = this.buildForm();
601
+ }
602
+ this.fillValues();
603
+ }
604
+ }
605
+ BaseDynamicArray.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseDynamicArray, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Directive });
606
+ BaseDynamicArray.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: BaseDynamicArray, selector: "[baseDynamicArray]", inputs: { onHandleSubmit: "onHandleSubmit", onHandleUpdateForm: "onHandleUpdateForm", self: "self", fields: "fields", data: "data", qtd: "qtd", disabled: "disabled" }, outputs: { onHandleSubmitFormReady: "onHandleSubmitFormReady" }, usesInheritance: true, usesOnChanges: true, ngImport: i0 });
607
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseDynamicArray, decorators: [{
608
+ type: Directive,
609
+ args: [{
610
+ selector: '[baseDynamicArray]'
611
+ }]
612
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { onHandleSubmit: [{
613
+ type: Input
614
+ }], onHandleUpdateForm: [{
615
+ type: Input
616
+ }], onHandleSubmitFormReady: [{
617
+ type: Output
618
+ }], self: [{
619
+ type: Input
620
+ }], fields: [{
621
+ type: Input
622
+ }], data: [{
623
+ type: Input
624
+ }], qtd: [{
625
+ type: Input
626
+ }], disabled: [{
627
+ type: Input
628
+ }] } });
629
+
630
+ class MECXDynamicFileUploadComponent {
631
+ constructor(cdr) {
632
+ this.cdr = cdr;
633
+ // eslint-disable-next-line object-curly-newline
634
+ this._formErrors = {};
635
+ this._function = (file, callback) => {
636
+ if (this._form?.disabled)
637
+ return;
638
+ if (!this._field?.functions?.onHandleUpload) {
639
+ console.error('onHandleUpload not declared');
640
+ return;
641
+ }
642
+ const { func, type } = this._field?.functions?.onHandleUpload;
643
+ if (!func || !this.self[func]) {
644
+ console.error('onHandleUpload not declared');
645
+ return;
646
+ }
647
+ this.self[func](file, type, callback);
648
+ };
649
+ // not to do
650
+ }
651
+ get className() {
652
+ return this._field?.style?.class;
653
+ }
654
+ ngOnChanges() {
655
+ this.cdr.detectChanges();
656
+ }
657
+ }
658
+ MECXDynamicFileUploadComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicFileUploadComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
659
+ MECXDynamicFileUploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicFileUploadComponent, selector: "mecx-dynamic-file-upload", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors", self: "self" }, host: { properties: { "class": "this.className" } }, usesOnChanges: true, ngImport: i0, template: "<monkey-file-upload\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [icon]=\"_field?.icon\" [formControl]=\"_form.controls[_field?.name]\"\n [placeholder]=\"_field?.placeholder | translate\"\n [helperMessage]=\"_field?.helperMessage | translate\" [label]=\"_field?.label | translate\"\n [maxSize]=\"_field?.maxSize || 5242880\" [fileUpload]=\"_function\"\n [maxSizeErrorMessage]=\"'FIELD.FILE.MAX-FILE' | translate\"\n [allowedExtensionErrorMessage]=\"'FIELD.FILE.ALLOWED-EXTENSION' | translate\"\n [allowedExtensions]=\"_field?.allowedExtensions || []\" *ngIf=\"_field\">\n</monkey-file-upload>", components: [{ type: i1$1.MonkeyFileUploadComponent, selector: "monkey-file-upload", inputs: ["name", "label", "helperMessage", "placeholder", "icon", "infoMessage", "uploadOngoingMessage", "errorMessage", "listenFiles", "maxSize", "allowedExtensions", "maxSizeErrorMessage", "allowedExtensionErrorMessage", "fileUpload", "value"], outputs: ["onChange", "onHandleFilesReady"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
660
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicFileUploadComponent, decorators: [{
661
+ type: Component,
662
+ args: [{ selector: 'mecx-dynamic-file-upload', encapsulation: ViewEncapsulation.None, template: "<monkey-file-upload\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [icon]=\"_field?.icon\" [formControl]=\"_form.controls[_field?.name]\"\n [placeholder]=\"_field?.placeholder | translate\"\n [helperMessage]=\"_field?.helperMessage | translate\" [label]=\"_field?.label | translate\"\n [maxSize]=\"_field?.maxSize || 5242880\" [fileUpload]=\"_function\"\n [maxSizeErrorMessage]=\"'FIELD.FILE.MAX-FILE' | translate\"\n [allowedExtensionErrorMessage]=\"'FIELD.FILE.ALLOWED-EXTENSION' | translate\"\n [allowedExtensions]=\"_field?.allowedExtensions || []\" *ngIf=\"_field\">\n</monkey-file-upload>" }]
663
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { _field: [{
664
+ type: Input
665
+ }], _form: [{
666
+ type: Input
667
+ }], _formErrors: [{
668
+ type: Input
669
+ }], self: [{
670
+ type: Input
671
+ }], className: [{
672
+ type: HostBinding,
673
+ args: ['class']
674
+ }] } });
675
+
676
+ class MECXDynamicButtonComponent {
677
+ constructor(cdr) {
678
+ this.cdr = cdr;
679
+ this._field = null;
680
+ this._form = null;
681
+ // eslint-disable-next-line object-curly-newline
682
+ this._formErrors = {};
683
+ // not to do
684
+ }
685
+ get className() {
686
+ return this._field?.style?.class;
687
+ }
688
+ ngOnChanges() {
689
+ this.cdr.detectChanges();
690
+ }
691
+ onClick() {
692
+ const { _form, _field, self } = this;
693
+ if (_form?.disabled || !_field)
694
+ return;
695
+ const { name, value } = _field;
696
+ const func = _field?.functions?.onClick;
697
+ if (func) {
698
+ self[func]({
699
+ name,
700
+ value,
701
+ form: _form
702
+ });
703
+ }
704
+ }
705
+ }
706
+ MECXDynamicButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicButtonComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
707
+ MECXDynamicButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicButtonComponent, selector: "mecx-dynamic-button", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors", self: "self" }, host: { properties: { "class": "this.className" } }, usesOnChanges: true, ngImport: i0, template: "<monkey-button [icon]=\"_field?.icon\" [type]=\"_field?.type\" [color]=\"_field?.color\"\n (click)=\"onClick()\">\n {{ _field?.label | translate }}\n</monkey-button>", styles: ["mecx-dynamic-button monkey-button button{height:40px}\n"], components: [{ type: i1$1.MonkeyButtonComponent, selector: "monkey-button", inputs: ["label", "icon", "iconPosition", "type", "color", "disabled", "size"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
708
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicButtonComponent, decorators: [{
709
+ type: Component,
710
+ args: [{ selector: 'mecx-dynamic-button', encapsulation: ViewEncapsulation.None, template: "<monkey-button [icon]=\"_field?.icon\" [type]=\"_field?.type\" [color]=\"_field?.color\"\n (click)=\"onClick()\">\n {{ _field?.label | translate }}\n</monkey-button>", styles: ["mecx-dynamic-button monkey-button button{height:40px}\n"] }]
711
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { _field: [{
712
+ type: Input
713
+ }], _form: [{
714
+ type: Input
715
+ }], _formErrors: [{
716
+ type: Input
717
+ }], self: [{
718
+ type: Input
719
+ }], className: [{
720
+ type: HostBinding,
721
+ args: ['class']
722
+ }] } });
723
+
724
+ class MECXDynamicInputComponent {
725
+ constructor(cdr) {
726
+ this.cdr = cdr;
727
+ this._field = null;
728
+ this._form = null;
729
+ // eslint-disable-next-line object-curly-newline
730
+ this._formErrors = {};
731
+ this.inputElement = null;
732
+ // not to do
733
+ }
734
+ get className() {
735
+ return this._field?.style?.class;
736
+ }
737
+ ngOnInit() {
738
+ this.cdr.detectChanges();
739
+ }
740
+ ngOnChanges() {
741
+ this.cdr.detectChanges();
742
+ }
743
+ onChange(event) {
744
+ const { _form, _field, self } = this;
745
+ if (!_field || !_form)
746
+ return;
747
+ const { name } = _field;
748
+ const func = _field?.functions?.onChange;
749
+ const isValid = _form?.get(_field?.name)?.valid;
750
+ if (func) {
751
+ self[func]({
752
+ name,
753
+ isValid,
754
+ event,
755
+ ctrl: _form.get(this._field?.name),
756
+ form: _form
757
+ });
758
+ }
759
+ }
760
+ }
761
+ MECXDynamicInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicInputComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
762
+ MECXDynamicInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicInputComponent, selector: "mecx-dynamic-input", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors", self: "self" }, host: { properties: { "class": "this.className" } }, viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<monkey-input\r\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\r\n [mask]=\"_field?.mask\" [prefix]=\"_field?.prefix\" [name]=\"_field?.name\"\r\n [formControl]=\"_form.controls[_field?.name]\" [placeholder]=\"_field?.placeholder | translate\"\r\n [helperMessage]=\"_field?.helperMessage | translate\" [label]=\"_field?.label | translate\"\r\n [type]=\"_field?.type\" #inputElement (onChange)=\"onChange($event)\"\r\n [onlyNumber]=\"_field?.onlyNumber\" [currency]=\"_field?.currency\" [maxLength]=\"_field?.maxLength\"\r\n [maxDateToday]=\"_field?.maxDateToday\">\r\n</monkey-input>", components: [{ type: i1$1.MonkeyInputComponent, selector: "monkey-input", inputs: ["name", "label", "helperMessage", "placeholder", "icon", "type", "infoMessage", "errorMessage", "mask", "prefix", "maxLength", "onlyNumber", "onlyAlphaNumeric", "upperCase", "lowerCase", "capitalize", "currency", "percent", "maxDateToday", "value"], outputs: ["onChange"] }], directives: [{ type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicInputComponent, decorators: [{
764
+ type: Component,
765
+ args: [{ selector: 'mecx-dynamic-input', encapsulation: ViewEncapsulation.None, template: "<monkey-input\r\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\r\n [mask]=\"_field?.mask\" [prefix]=\"_field?.prefix\" [name]=\"_field?.name\"\r\n [formControl]=\"_form.controls[_field?.name]\" [placeholder]=\"_field?.placeholder | translate\"\r\n [helperMessage]=\"_field?.helperMessage | translate\" [label]=\"_field?.label | translate\"\r\n [type]=\"_field?.type\" #inputElement (onChange)=\"onChange($event)\"\r\n [onlyNumber]=\"_field?.onlyNumber\" [currency]=\"_field?.currency\" [maxLength]=\"_field?.maxLength\"\r\n [maxDateToday]=\"_field?.maxDateToday\">\r\n</monkey-input>" }]
766
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { _field: [{
767
+ type: Input
768
+ }], _form: [{
769
+ type: Input
770
+ }], _formErrors: [{
771
+ type: Input
772
+ }], self: [{
773
+ type: Input
774
+ }], inputElement: [{
775
+ type: ViewChild,
776
+ args: ['inputElement', {
777
+ static: true
778
+ }]
779
+ }], className: [{
780
+ type: HostBinding,
781
+ args: ['class']
782
+ }] } });
783
+
784
+ class MECXDynamicInputPhoneComponent {
785
+ constructor(cdr) {
786
+ this.cdr = cdr;
787
+ this._field = null;
788
+ this._form = null;
789
+ // eslint-disable-next-line object-curly-newline
790
+ this._formErrors = {};
791
+ this.inputElement = null;
792
+ // not to do
793
+ }
794
+ get className() {
795
+ return this._field?.style?.class;
796
+ }
797
+ ngOnInit() {
798
+ this.cdr.detectChanges();
799
+ }
800
+ ngOnChanges() {
801
+ this.cdr.detectChanges();
802
+ }
803
+ onChange(event) {
804
+ const { _form, _field, self } = this;
805
+ if (!_field || !_form)
806
+ return;
807
+ const { name } = _field;
808
+ const func = _field?.functions?.onChange;
809
+ const isValid = _form?.get(_field?.name)?.valid;
810
+ if (func) {
811
+ self[func]({
812
+ name,
813
+ isValid,
814
+ event,
815
+ ctrl: _form.get(this._field?.name),
816
+ form: _form
817
+ });
818
+ }
819
+ }
820
+ }
821
+ MECXDynamicInputPhoneComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicInputPhoneComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
822
+ MECXDynamicInputPhoneComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicInputPhoneComponent, selector: "mecx-dynamic-input-phone", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors", self: "self" }, host: { properties: { "class": "this.className" } }, viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<monkey-input-phone [name]=\"_field?.name\" [label]=\"_field?.label | translate\"\r\n [helperMessage]=\"_field?.helperMessage | translate\"\r\n [placeholder]=\"_field?.placeholder | translate\" [icon]=\"_field?.icon\"\r\n (onChange)=\"onChange($event)\" [internationalNumber]=\"_field?.internationalNumber\"\r\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\r\n [maxLength]=\"_field?.maxLength\" [formControl]=\"_form.controls[_field?.name]\" #inputElement>\r\n</monkey-input-phone>", components: [{ type: i1$1.MonkeyInputPhoneComponent, selector: "monkey-input-phone", inputs: ["name", "label", "helperMessage", "placeholder", "icon", "infoMessage", "errorMessage", "maxLength", "internationalNumber", "value"], outputs: ["onChange"] }], directives: [{ type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
823
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicInputPhoneComponent, decorators: [{
824
+ type: Component,
825
+ args: [{ selector: 'mecx-dynamic-input-phone', encapsulation: ViewEncapsulation.None, template: "<monkey-input-phone [name]=\"_field?.name\" [label]=\"_field?.label | translate\"\r\n [helperMessage]=\"_field?.helperMessage | translate\"\r\n [placeholder]=\"_field?.placeholder | translate\" [icon]=\"_field?.icon\"\r\n (onChange)=\"onChange($event)\" [internationalNumber]=\"_field?.internationalNumber\"\r\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\r\n [maxLength]=\"_field?.maxLength\" [formControl]=\"_form.controls[_field?.name]\" #inputElement>\r\n</monkey-input-phone>" }]
826
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { _field: [{
827
+ type: Input
828
+ }], _form: [{
829
+ type: Input
830
+ }], _formErrors: [{
831
+ type: Input
832
+ }], self: [{
833
+ type: Input
834
+ }], inputElement: [{
835
+ type: ViewChild,
836
+ args: ['inputElement', {
837
+ static: true
838
+ }]
839
+ }], className: [{
840
+ type: HostBinding,
841
+ args: ['class']
842
+ }] } });
843
+
844
+ class MECXDynamicRadioComponent {
845
+ constructor() {
846
+ this._field = null;
847
+ this._form = null;
848
+ // eslint-disable-next-line object-curly-newline
849
+ this._formErrors = {};
850
+ }
851
+ get className() {
852
+ return this._field?.style?.class;
853
+ }
854
+ }
855
+ MECXDynamicRadioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicRadioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
856
+ MECXDynamicRadioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicRadioComponent, selector: "mecx-dynamic-radio", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors" }, host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<monkey-radiobutton\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [formControl]=\"_form.controls[_field?.name]\" [helperMessage]=\"_field?.helperMessage | translate\"\n [label]=\"_field?.label | translate\">\n <monkey-option *ngFor=\"let value of _field?.value\" [label]=\"value.description | translate\"\n [value]=\"value.value\">\n </monkey-option>\n</monkey-radiobutton>", components: [{ type: i1$1.MonkeyRadioButtonComponent, selector: "monkey-radiobutton", inputs: ["label", "helperMessage", "placeholder", "icon", "infoMessage", "errorMessage", "value"], outputs: ["onChange"] }, { type: i1$1.MonkeyOptionComponent, selector: "monkey-option", inputs: ["type", "label", "value", "selectAll", "selected", "enableClick"], outputs: ["onSelectOption"] }], directives: [{ type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
857
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicRadioComponent, decorators: [{
858
+ type: Component,
859
+ args: [{ selector: 'mecx-dynamic-radio', encapsulation: ViewEncapsulation.None, template: "<monkey-radiobutton\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [formControl]=\"_form.controls[_field?.name]\" [helperMessage]=\"_field?.helperMessage | translate\"\n [label]=\"_field?.label | translate\">\n <monkey-option *ngFor=\"let value of _field?.value\" [label]=\"value.description | translate\"\n [value]=\"value.value\">\n </monkey-option>\n</monkey-radiobutton>" }]
860
+ }], propDecorators: { _field: [{
861
+ type: Input
862
+ }], _form: [{
863
+ type: Input
864
+ }], _formErrors: [{
865
+ type: Input
866
+ }], className: [{
867
+ type: HostBinding,
868
+ args: ['class']
869
+ }] } });
870
+
871
+ class MECXDynamicSelectComponent {
872
+ constructor() {
873
+ this._field = null;
874
+ this._form = null;
875
+ // eslint-disable-next-line object-curly-newline
876
+ this._formErrors = {};
877
+ this._onHandleOptions = new EventEmitter();
878
+ }
879
+ get className() {
880
+ return this._field?.style?.class;
881
+ }
882
+ onHandleGenericLoad() {
883
+ const { _form, _field, self } = this;
884
+ if (_form?.disabled || !_field || !_field?.functions?.onHandleGenericLoad)
885
+ return;
886
+ const { name } = _field;
887
+ if (_field?.value?.length)
888
+ return;
889
+ const { func, url } = _field?.functions?.onHandleGenericLoad;
890
+ if (!func || !self[func]) {
891
+ console.error('onHandleGenericLoad not declared');
892
+ return;
893
+ }
894
+ _form?.disable();
895
+ self[func]({
896
+ name,
897
+ url,
898
+ form: _form,
899
+ callback: (data) => {
900
+ if (this._field) {
901
+ this._field.value = data;
902
+ }
903
+ this._form?.enable();
904
+ this._onHandleOptions.next(null);
905
+ }
906
+ });
907
+ }
908
+ onChange(event) {
909
+ const { _form, _field, self } = this;
910
+ if (!_field || !_form)
911
+ return;
912
+ const { name } = _field;
913
+ const func = _field?.functions?.onChange;
914
+ const isValid = _form?.get(_field.name)?.valid;
915
+ if (func) {
916
+ self[func]({
917
+ name,
918
+ isValid,
919
+ event,
920
+ ctrl: _form?.get(this._field?.name),
921
+ form: _form,
922
+ value: _field.value
923
+ });
924
+ }
925
+ }
926
+ }
927
+ MECXDynamicSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
928
+ MECXDynamicSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicSelectComponent, selector: "mecx-dynamic-select", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors", self: "self" }, host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<monkey-select\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [formControl]=\"_form.controls[_field?.name]\" [helperMessage]=\"_field?.helperMessage | translate\"\n [label]=\"_field?.label | translate\" (click)=\"onHandleGenericLoad()\"\n [onHandleOptions]=\"_onHandleOptions\" (onChange)=\"onChange($event)\"\n [labelSelect]=\"_form.get(_field?.name).value || ('FIELD.SELECT' | translate)\"\n [placeholder]=\"_field?.placeholder | translate\">\n <monkey-option [label]=\"'FIELD.LOADING' | translate\" *ngIf=\"!_field?.value?.length\"\n enableClick=\"false\">\n </monkey-option>\n <monkey-option *ngFor=\"let value of _field?.value\" [label]=\"value.description | translate\"\n [value]=\"value.value\">\n </monkey-option>\n</monkey-select>", components: [{ type: i1$1.MonkeySelectComponent, selector: "monkey-select", inputs: ["label", "helperMessage", "placeholder", "icon", "infoMessage", "errorMessage", "labelSelect", "onHandleOptions", "value"], outputs: ["onChange"] }, { type: i1$1.MonkeyOptionComponent, selector: "monkey-option", inputs: ["type", "label", "value", "selectAll", "selected", "enableClick"], outputs: ["onSelectOption"] }], directives: [{ type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
929
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicSelectComponent, decorators: [{
930
+ type: Component,
931
+ args: [{ selector: 'mecx-dynamic-select', encapsulation: ViewEncapsulation.None, template: "<monkey-select\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [formControl]=\"_form.controls[_field?.name]\" [helperMessage]=\"_field?.helperMessage | translate\"\n [label]=\"_field?.label | translate\" (click)=\"onHandleGenericLoad()\"\n [onHandleOptions]=\"_onHandleOptions\" (onChange)=\"onChange($event)\"\n [labelSelect]=\"_form.get(_field?.name).value || ('FIELD.SELECT' | translate)\"\n [placeholder]=\"_field?.placeholder | translate\">\n <monkey-option [label]=\"'FIELD.LOADING' | translate\" *ngIf=\"!_field?.value?.length\"\n enableClick=\"false\">\n </monkey-option>\n <monkey-option *ngFor=\"let value of _field?.value\" [label]=\"value.description | translate\"\n [value]=\"value.value\">\n </monkey-option>\n</monkey-select>" }]
932
+ }], propDecorators: { _field: [{
933
+ type: Input
934
+ }], _form: [{
935
+ type: Input
936
+ }], _formErrors: [{
937
+ type: Input
938
+ }], self: [{
939
+ type: Input
940
+ }], className: [{
941
+ type: HostBinding,
942
+ args: ['class']
943
+ }] } });
944
+
945
+ class MECXDynamicSelectSearchComponent {
946
+ constructor() {
947
+ this._field = null;
948
+ this._form = null;
949
+ // eslint-disable-next-line object-curly-newline
950
+ this._formErrors = {};
951
+ this._onHandleOptions = new EventEmitter();
952
+ }
953
+ get className() {
954
+ return this._field?.style?.class;
955
+ }
956
+ onHandleGenericLoad() {
957
+ const { _form, _field, self } = this;
958
+ if (_form?.disabled || !_field || !_field?.functions?.onHandleGenericLoad)
959
+ return;
960
+ const { name } = _field;
961
+ if (_field?.value?.length)
962
+ return;
963
+ const { func, url } = _field?.functions?.onHandleGenericLoad;
964
+ if (!func || !self[func]) {
965
+ console.error('onHandleGenericLoad not declared');
966
+ return;
967
+ }
968
+ _form?.disable();
969
+ self[func]({
970
+ name,
971
+ url,
972
+ form: _form,
973
+ callback: (data) => {
974
+ if (this._field) {
975
+ this._field.value = data;
976
+ }
977
+ this._form?.enable();
978
+ this._onHandleOptions.next(null);
979
+ }
980
+ });
981
+ }
982
+ onChange(event) {
983
+ const { _form, _field, self } = this;
984
+ if (!_field || !_form)
985
+ return;
986
+ const { name } = _field;
987
+ const func = _field?.functions?.onChange;
988
+ const isValid = _form?.get(_field?.name)?.valid;
989
+ if (func) {
990
+ self[func]({
991
+ name,
992
+ isValid,
993
+ event,
994
+ ctrl: _form.get(this._field?.name),
995
+ form: _form,
996
+ value: _field.value
997
+ });
998
+ }
999
+ }
1000
+ }
1001
+ MECXDynamicSelectSearchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicSelectSearchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1002
+ MECXDynamicSelectSearchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicSelectSearchComponent, selector: "mecx-dynamic-select-search", inputs: { _field: "_field", _form: "_form", _formErrors: "_formErrors", self: "self" }, host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<monkey-select-search\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [formControl]=\"_form.controls[_field?.name]\" [helperMessage]=\"_field?.helperMessage | translate\"\n [label]=\"_field?.label | translate\" (click)=\"onHandleGenericLoad()\"\n [onHandleOptions]=\"_onHandleOptions\" (onChange)=\"onChange($event)\"\n [fieldToCompare]=\"_field?.fieldToCompare\"\n [labelSelect]=\"_form.get(_field?.name).value || ('FIELD.SELECT' | translate)\"\n [placeholder]=\"_field?.placeholder | translate\">\n <monkey-option [label]=\"'FIELD.LOADING' | translate\" *ngIf=\"!_field?.value?.length\"\n enableClick=\"false\">\n </monkey-option>\n <monkey-option *ngFor=\"let value of _field?.value\" [label]=\"value.description | translate\"\n [value]=\"value.value\">\n </monkey-option>\n</monkey-select-search>", components: [{ type: i1$1.MonkeySelectSearchComponent, selector: "monkey-select-search", inputs: ["label", "helperMessage", "placeholder", "icon", "infoMessage", "errorMessage", "labelSelect", "fieldToCompare", "onHandleOptions", "value"], outputs: ["onChange", "onSearch"] }, { type: i1$1.MonkeyOptionComponent, selector: "monkey-option", inputs: ["type", "label", "value", "selectAll", "selected", "enableClick"], outputs: ["onSelectOption"] }], directives: [{ type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
1003
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicSelectSearchComponent, decorators: [{
1004
+ type: Component,
1005
+ args: [{ selector: 'mecx-dynamic-select-search', encapsulation: ViewEncapsulation.None, template: "<monkey-select-search\n errorMessage=\"{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}\"\n [formControl]=\"_form.controls[_field?.name]\" [helperMessage]=\"_field?.helperMessage | translate\"\n [label]=\"_field?.label | translate\" (click)=\"onHandleGenericLoad()\"\n [onHandleOptions]=\"_onHandleOptions\" (onChange)=\"onChange($event)\"\n [fieldToCompare]=\"_field?.fieldToCompare\"\n [labelSelect]=\"_form.get(_field?.name).value || ('FIELD.SELECT' | translate)\"\n [placeholder]=\"_field?.placeholder | translate\">\n <monkey-option [label]=\"'FIELD.LOADING' | translate\" *ngIf=\"!_field?.value?.length\"\n enableClick=\"false\">\n </monkey-option>\n <monkey-option *ngFor=\"let value of _field?.value\" [label]=\"value.description | translate\"\n [value]=\"value.value\">\n </monkey-option>\n</monkey-select-search>" }]
1006
+ }], propDecorators: { _field: [{
1007
+ type: Input
1008
+ }], _form: [{
1009
+ type: Input
1010
+ }], _formErrors: [{
1011
+ type: Input
1012
+ }], self: [{
1013
+ type: Input
1014
+ }], className: [{
1015
+ type: HostBinding,
1016
+ args: ['class']
1017
+ }] } });
1018
+
1019
+ const componentMapper = {
1020
+ input: MECXDynamicInputComponent,
1021
+ 'input-phone': MECXDynamicInputPhoneComponent,
1022
+ radiobutton: MECXDynamicRadioComponent,
1023
+ select: MECXDynamicSelectComponent,
1024
+ 'select-search': MECXDynamicSelectSearchComponent,
1025
+ 'file-upload': MECXDynamicFileUploadComponent,
1026
+ button: MECXDynamicButtonComponent
1027
+ };
1028
+ class MECXDynamicDirective {
1029
+ constructor(resolver, container, cdr) {
1030
+ this.resolver = resolver;
1031
+ this.container = container;
1032
+ this.cdr = cdr;
1033
+ this.field = null;
1034
+ this.form = null;
1035
+ // not to do
1036
+ }
1037
+ handleInternalPlusValidation() {
1038
+ if (!this.field?.alwaysShowPlusValidation)
1039
+ return false;
1040
+ const { operator, value, field } = this.field?.alwaysShowPlusValidation;
1041
+ const validators = {
1042
+ e: (val1, val2) => { return val1 === val2; },
1043
+ lt: (val1, val2) => { return val1 < val2; },
1044
+ gt: (val1, val2) => { return val1 > val2; }
1045
+ };
1046
+ const data = this.form?.controls[field]?.value;
1047
+ return validators[operator](data, value);
1048
+ }
1049
+ buildComponent() {
1050
+ if (this.componentRef?.instance)
1051
+ return;
1052
+ const factory = this.resolver.resolveComponentFactory(componentMapper[this.field?.fieldType]);
1053
+ this.componentRef = this.container.createComponent(factory);
1054
+ this.componentRef.instance._field = this.field;
1055
+ this.componentRef.instance._form = this.form;
1056
+ // eslint-disable-next-line object-curly-newline
1057
+ this.componentRef.instance._formErrors = this.formErrors || {};
1058
+ this.componentRef.instance.self = this.self;
1059
+ }
1060
+ ngOnInit() {
1061
+ if (!this.field?.alwaysShow && !this.handleInternalPlusValidation())
1062
+ return;
1063
+ this.buildComponent();
1064
+ }
1065
+ ngOnChanges() {
1066
+ if (this.plusValidations && this.plusValidations[this.field?.name]) {
1067
+ if (!this.field?.alwaysShow && this.plusValidations[this.field?.name].alwaysShow) {
1068
+ setTimeout(() => {
1069
+ this.buildComponent();
1070
+ this.cdr.detectChanges();
1071
+ }, 1);
1072
+ }
1073
+ if (this.componentRef?.instance &&
1074
+ !this.plusValidations[this.field?.name].alwaysShow) {
1075
+ this.componentRef.destroy();
1076
+ this.componentRef = null;
1077
+ this.form?.controls[this.field?.name]?.setValue(null);
1078
+ this.form?.controls[this.field?.name]?.clearValidators();
1079
+ }
1080
+ }
1081
+ if (!this.componentRef?.instance)
1082
+ return;
1083
+ this.componentRef.instance._formErrors = this.formErrors || {};
1084
+ }
1085
+ }
1086
+ MECXDynamicDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicDirective, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1087
+ MECXDynamicDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicDirective, selector: "[MECXDynamic]", inputs: { field: "field", form: "form", formErrors: "formErrors", self: "self", plusValidations: "plusValidations" }, usesOnChanges: true, ngImport: i0 });
1088
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicDirective, decorators: [{
1089
+ type: Directive,
1090
+ args: [{
1091
+ selector: '[MECXDynamic]'
1092
+ }]
1093
+ }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { field: [{
1094
+ type: Input
1095
+ }], form: [{
1096
+ type: Input
1097
+ }], formErrors: [{
1098
+ type: Input
1099
+ }], self: [{
1100
+ type: Input
1101
+ }], plusValidations: [{
1102
+ type: Input
1103
+ }] } });
1104
+
1105
+ class MECXDynamicFormComponent extends BaseDynamic {
1106
+ constructor(fb, cdr) {
1107
+ super(fb);
1108
+ this.cdr = cdr;
1109
+ this.unsubscribeAll = new Subject();
1110
+ }
1111
+ ngOnInit() {
1112
+ super.ngOnInit();
1113
+ this.onHandleSubmit.pipe(takeUntil(this.unsubscribeAll)).subscribe((func) => {
1114
+ this.onSubmit(func);
1115
+ });
1116
+ }
1117
+ ngOnDestroy() {
1118
+ this.unsubscribeAll.next();
1119
+ this.unsubscribeAll.complete();
1120
+ }
1121
+ onSubmit(callback) {
1122
+ const { _form } = this;
1123
+ // eslint-disable-next-line object-curly-newline
1124
+ this.__monkeyecxFormErrors = {};
1125
+ const isValid = this.validateForm(_form);
1126
+ this.cdr.detectChanges();
1127
+ this.onHandleSubmitFormReady.next({
1128
+ validate: {
1129
+ isValid
1130
+ },
1131
+ callback,
1132
+ form: _form
1133
+ });
1134
+ }
1135
+ }
1136
+ MECXDynamicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicFormComponent, deps: [{ token: i1.FormBuilder }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1137
+ MECXDynamicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicFormComponent, selector: "mecx-dynamic-form", usesInheritance: true, ngImport: i0, template: "<form name=\"form\" [formGroup]=\"_form\" *ngIf=\"_form\">\n <div class=\"row\">\n <div *ngFor=\"let field of fields;\" MECXDynamic [field]=\"field\" [form]=\"_form\" [self]=\"self\"\n [formErrors]=\"__monkeyecxFormErrors\" [style.display]=\"'none'\">\n </div>\n </div>\n</form>", 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: MECXDynamicDirective, selector: "[MECXDynamic]", inputs: ["field", "form", "formErrors", "self", "plusValidations"] }], encapsulation: i0.ViewEncapsulation.None });
1138
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicFormComponent, decorators: [{
1139
+ type: Component,
1140
+ args: [{ selector: 'mecx-dynamic-form', styles: [], encapsulation: ViewEncapsulation.None, template: "<form name=\"form\" [formGroup]=\"_form\" *ngIf=\"_form\">\n <div class=\"row\">\n <div *ngFor=\"let field of fields;\" MECXDynamic [field]=\"field\" [form]=\"_form\" [self]=\"self\"\n [formErrors]=\"__monkeyecxFormErrors\" [style.display]=\"'none'\">\n </div>\n </div>\n</form>" }]
1141
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i0.ChangeDetectorRef }]; } });
1142
+
1143
+ class MECXDynamicFormArrayComponent extends BaseDynamicArray {
1144
+ constructor(fb, cdr) {
1145
+ super(fb);
1146
+ this.cdr = cdr;
1147
+ this.unsubscribeAll = new Subject();
1148
+ this.__monkeyecxFormErrors = [];
1149
+ }
1150
+ ngOnInit() {
1151
+ super.ngOnInit();
1152
+ this.onHandleSubmit.pipe(takeUntil(this.unsubscribeAll)).subscribe((func) => {
1153
+ this.onSubmit(func);
1154
+ });
1155
+ }
1156
+ ngOnDestroy() {
1157
+ this.unsubscribeAll.next();
1158
+ this.unsubscribeAll.complete();
1159
+ }
1160
+ onSubmit(callback) {
1161
+ const { _form } = this;
1162
+ // eslint-disable-next-line object-curly-newline
1163
+ this.__monkeyecxFormErrors = [];
1164
+ let validate = {
1165
+ isValid: false
1166
+ };
1167
+ let hasErrors = false;
1168
+ if (this.formValues) {
1169
+ this.__monkeyecxFormErrors = [this.formValues.length];
1170
+ this.formValues.controls.forEach((item, index) => {
1171
+ if (item instanceof FormGroup) {
1172
+ if (!this.validateForm(item, index)) {
1173
+ hasErrors = true;
1174
+ }
1175
+ }
1176
+ });
1177
+ }
1178
+ validate = {
1179
+ isValid: !hasErrors
1180
+ };
1181
+ this.cdr.detectChanges();
1182
+ this.onHandleSubmitFormReady.next({
1183
+ validate,
1184
+ callback,
1185
+ form: _form
1186
+ });
1187
+ }
1188
+ onHandleAdd() {
1189
+ this.formValues?.push(this.formBase());
1190
+ this.cdr.detectChanges();
1191
+ }
1192
+ onHandleRemove(index) {
1193
+ this.formValues?.removeAt(index);
1194
+ this._plusValidations.splice(index, 1);
1195
+ }
1196
+ }
1197
+ MECXDynamicFormArrayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicFormArrayComponent, deps: [{ token: i1.FormBuilder }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1198
+ MECXDynamicFormArrayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXDynamicFormArrayComponent, selector: "mecx-dynamic-form-array", usesInheritance: true, ngImport: i0, template: "<form name=\"form\" [formGroup]=\"_form\" *ngIf=\"_form\">\n <div formArrayName=\"fields\">\n <div *ngFor=\"let item of formValues.controls; let indForm=index\" [formGroupName]=\"indForm\">\n <monkey-button type=\"secondary\" color=\"error\" icon=\"close-20\" iconPosition=\"right\"\n [label]=\"'BUTTONS.REMOVE' | translate\" (click)=\"onHandleRemove(indForm)\"\n *ngIf=\"formValues.controls.length > 1 && !disabled\">\n </monkey-button>\n <div class=\"row mt-3\">\n <div *ngFor=\"let field of fields;\" MECXDynamic [field]=\"field\" [form]=\"item\" [self]=\"self\"\n [formErrors]=\"__monkeyecxFormErrors[indForm]\"\n [plusValidations]=\"_plusValidations[indForm]\" [style.display]=\"'none'\">\n </div>\n </div>\n </div>\n </div>\n</form>\n<monkey-button type=\"secondary\" color=\"theme\" icon=\"more-20\" iconPosition=\"right\"\n [label]=\"'BUTTONS.ADD' | translate\" (click)=\"onHandleAdd()\" *ngIf=\"!disabled\">\n</monkey-button>", styles: ["mecx-dynamic-form-array monkey-button{width:100%}mecx-dynamic-form-array monkey-button button{width:100%;height:40px}\n"], components: [{ type: i1$1.MonkeyButtonComponent, selector: "monkey-button", inputs: ["label", "icon", "iconPosition", "type", "color", "disabled", "size"] }], 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: i1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { type: MECXDynamicDirective, selector: "[MECXDynamic]", inputs: ["field", "form", "formErrors", "self", "plusValidations"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
1199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicFormArrayComponent, decorators: [{
1200
+ type: Component,
1201
+ args: [{ selector: 'mecx-dynamic-form-array', encapsulation: ViewEncapsulation.None, template: "<form name=\"form\" [formGroup]=\"_form\" *ngIf=\"_form\">\n <div formArrayName=\"fields\">\n <div *ngFor=\"let item of formValues.controls; let indForm=index\" [formGroupName]=\"indForm\">\n <monkey-button type=\"secondary\" color=\"error\" icon=\"close-20\" iconPosition=\"right\"\n [label]=\"'BUTTONS.REMOVE' | translate\" (click)=\"onHandleRemove(indForm)\"\n *ngIf=\"formValues.controls.length > 1 && !disabled\">\n </monkey-button>\n <div class=\"row mt-3\">\n <div *ngFor=\"let field of fields;\" MECXDynamic [field]=\"field\" [form]=\"item\" [self]=\"self\"\n [formErrors]=\"__monkeyecxFormErrors[indForm]\"\n [plusValidations]=\"_plusValidations[indForm]\" [style.display]=\"'none'\">\n </div>\n </div>\n </div>\n </div>\n</form>\n<monkey-button type=\"secondary\" color=\"theme\" icon=\"more-20\" iconPosition=\"right\"\n [label]=\"'BUTTONS.ADD' | translate\" (click)=\"onHandleAdd()\" *ngIf=\"!disabled\">\n</monkey-button>", styles: ["mecx-dynamic-form-array monkey-button{width:100%}mecx-dynamic-form-array monkey-button button{width:100%;height:40px}\n"] }]
1202
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i0.ChangeDetectorRef }]; } });
1203
+
1204
+ class MECXDynamicModule {
1205
+ }
1206
+ MECXDynamicModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1207
+ MECXDynamicModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicModule, declarations: [MECXDynamicButtonComponent,
1208
+ MECXDynamicFileUploadComponent,
1209
+ MECXDynamicFormComponent,
1210
+ MECXDynamicFormArrayComponent,
1211
+ MECXDynamicInputComponent,
1212
+ MECXDynamicInputPhoneComponent,
1213
+ MECXDynamicRadioComponent,
1214
+ MECXDynamicSelectComponent,
1215
+ MECXDynamicSelectSearchComponent,
1216
+ MECXDynamicDirective], imports: [CommonModule,
1217
+ FormsModule,
1218
+ ReactiveFormsModule,
1219
+ MonkeyInputModule,
1220
+ MonkeySelectModule,
1221
+ MonkeyRadioButtonModule,
1222
+ MonkeyOptionModule,
1223
+ MonkeyFileUploadModule,
1224
+ MonkeyButtonModule,
1225
+ MonkeyInputPhoneModule, i4.TranslateModule], exports: [MECXDynamicDirective, MECXDynamicFormComponent, MECXDynamicFormArrayComponent] });
1226
+ MECXDynamicModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicModule, imports: [[
1227
+ CommonModule,
1228
+ FormsModule,
1229
+ ReactiveFormsModule,
1230
+ MonkeyInputModule,
1231
+ MonkeySelectModule,
1232
+ MonkeyRadioButtonModule,
1233
+ MonkeyOptionModule,
1234
+ MonkeyFileUploadModule,
1235
+ MonkeyButtonModule,
1236
+ MonkeyInputPhoneModule,
1237
+ TranslateModule.forChild()
1238
+ ]] });
1239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXDynamicModule, decorators: [{
1240
+ type: NgModule,
1241
+ args: [{
1242
+ declarations: [
1243
+ MECXDynamicButtonComponent,
1244
+ MECXDynamicFileUploadComponent,
1245
+ MECXDynamicFormComponent,
1246
+ MECXDynamicFormArrayComponent,
1247
+ MECXDynamicInputComponent,
1248
+ MECXDynamicInputPhoneComponent,
1249
+ MECXDynamicRadioComponent,
1250
+ MECXDynamicSelectComponent,
1251
+ MECXDynamicSelectSearchComponent,
1252
+ MECXDynamicDirective
1253
+ ],
1254
+ imports: [
1255
+ CommonModule,
1256
+ FormsModule,
1257
+ ReactiveFormsModule,
1258
+ MonkeyInputModule,
1259
+ MonkeySelectModule,
1260
+ MonkeyRadioButtonModule,
1261
+ MonkeyOptionModule,
1262
+ MonkeyFileUploadModule,
1263
+ MonkeyButtonModule,
1264
+ MonkeyInputPhoneModule,
1265
+ TranslateModule.forChild()
1266
+ ],
1267
+ exports: [MECXDynamicDirective, MECXDynamicFormComponent, MECXDynamicFormArrayComponent],
1268
+ entryComponents: [MECXDynamicInputComponent]
1269
+ }]
1270
+ }] });
1271
+
1272
+ class MECXPasswordStrengthComponent {
1273
+ constructor(configService) {
1274
+ this.configService = configService;
1275
+ this.passwordToCheck = null;
1276
+ this.onHandleSubmitReady = new EventEmitter();
1277
+ this._validatorsPasswordPass = [];
1278
+ this._stepPassword = 0;
1279
+ this.validatorsPassword = new Map();
1280
+ // not do
1281
+ }
1282
+ handleColor(score) {
1283
+ let idx = 0;
1284
+ if (score > 50)
1285
+ idx = 1;
1286
+ if (score === 100)
1287
+ idx = 2;
1288
+ this._stepPassword = idx;
1289
+ }
1290
+ passwordStrengthValidator(pass) {
1291
+ this._validatorsPasswordPass = [];
1292
+ let score = 0;
1293
+ this.validatorsPassword.forEach((key, value) => {
1294
+ this._validatorsPasswordPass.push({
1295
+ regex: `${value}`,
1296
+ validate: `${key.VALIDATE}` === String(RegExp(`${key.REGEX}`).test(pass)),
1297
+ percent: 100 / this.validatorsPassword.size
1298
+ });
1299
+ });
1300
+ this._validatorsPasswordPass.forEach((check) => {
1301
+ if (check.validate) {
1302
+ score += check.percent;
1303
+ }
1304
+ });
1305
+ return Math.trunc(score);
1306
+ }
1307
+ onHandleReady() {
1308
+ const validate = this._validatorsPasswordPass?.find(({ validate }) => { return !validate; });
1309
+ this.onHandleSubmitReady.next(!validate);
1310
+ }
1311
+ onHandleChages() {
1312
+ const password = this.passwordToCheck;
1313
+ this.handleColor(this.passwordStrengthValidator(password));
1314
+ this.onHandleReady();
1315
+ }
1316
+ onHandlePasswordStrengthKeys(params) {
1317
+ const ps = params?.program?.screens?.login?.passwordStrength;
1318
+ if (ps) {
1319
+ Object.entries(ps)
1320
+ .forEach(([key, value]) => {
1321
+ if (MonkeyEcxUtils.persistNullEmptyUndefined(value)) {
1322
+ this.validatorsPassword.set(key, value);
1323
+ }
1324
+ });
1325
+ this.onHandleChages();
1326
+ }
1327
+ }
1328
+ ngOnInit() {
1329
+ this.configService.config().subscribe((_) => {
1330
+ this.onHandlePasswordStrengthKeys(_);
1331
+ });
1332
+ }
1333
+ ngOnChanges() {
1334
+ this.onHandleChages();
1335
+ }
1336
+ }
1337
+ MECXPasswordStrengthComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXPasswordStrengthComponent, deps: [{ token: i1$2.MonkeyEcxConfigService }], target: i0.ɵɵFactoryTarget.Component });
1338
+ MECXPasswordStrengthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXPasswordStrengthComponent, selector: "mecx-password-strength", inputs: { passwordToCheck: "passwordToCheck" }, outputs: { onHandleSubmitReady: "onHandleSubmitReady" }, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"_validatorsPasswordPass?.length\">\n <div id=\"strength\" class=\"d-flex full-width flex-column justify-content-center align-items-center\"\n #strength>\n <div id=\"strengthBar\" class=\"strength-bar d-flex full-width flex-row\">\n <div class=\"d-flex full-width align-items-center\">\n <div class=\"bar-label\">\n <small>{{ 'SCREENS.LOGIN.REGISTER.PASSWORD-STRENGTH.TITLE' | translate }}</small>\n </div>\n </div>\n <div class=\"d-flex full-width align-items-center flex-column\">\n <div class=\"point\" [class.error]=\"_stepPassword === 0\" [class.warning]=\"_stepPassword === 1\"\n [class.success]=\"_stepPassword === 2\">\n </div>\n <ng-container *ngIf=\"_stepPassword === 0\">\n <ng-container *ngTemplateOutlet=\"stepPasswordLabel\"></ng-container>\n </ng-container>\n </div>\n <div class=\"d-flex full-width align-items-center flex-column\">\n <div class=\"point\" [class.warning]=\"_stepPassword === 1\"\n [class.success]=\"_stepPassword === 2\"></div>\n <ng-container *ngIf=\"_stepPassword === 1\">\n <ng-container *ngTemplateOutlet=\"stepPasswordLabel\"></ng-container>\n </ng-container>\n </div>\n <div class=\"d-flex full-width align-items-center flex-column\">\n <div class=\"point\" [class.success]=\"_stepPassword === 2\"></div>\n <ng-container *ngIf=\"_stepPassword === 2\">\n <ng-container *ngTemplateOutlet=\"stepPasswordLabel\"></ng-container>\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"callbacks mt-2 row\">\n <div class=\"col-sm-6 mt-2 d-flex justify-content-start\"\n *ngFor=\"let validators of _validatorsPasswordPass\">\n <monkey-icon *ngIf=\"validators.validate\" icon=\"check-circle-20\"></monkey-icon>\n <monkey-icon *ngIf=\"!validators.validate\" icon=\"error-20\"></monkey-icon>\n <span class=\"ml-2\">\n {{ 'SCREENS.LOGIN.REGISTER.PASSWORD-STRENGTH.TYPES.' + validators.regex | translate }}\n </span>\n </div>\n </div>\n</ng-container>\n<ng-template #stepPasswordLabel>\n <div class=\"name-point mt-1\" [class.error]=\"_stepPassword === 0\"\n [class.warning]=\"_stepPassword === 1\" [class.success]=\"_stepPassword === 2\">\n {{ 'SCREENS.LOGIN.REGISTER.PASSWORD-STRENGTH.LABELS.' + _stepPassword | translate }}\n </div>\n</ng-template>", styles: ["mecx-password-strength{margin-bottom:8px}mecx-password-strength .strength-bar{display:inline;list-style:none;padding:0;vertical-align:2px;grid-gap:.5rem;gap:.5rem}mecx-password-strength .strength-bar .bar-label{font-style:normal;font-weight:400;font-size:14px;line-height:16px;color:#4b4a53}mecx-password-strength .strength-bar .point:last-child{margin:0}mecx-password-strength .callbacks{font-style:normal;font-weight:400;font-size:14px;line-height:16px;color:#72717e}mecx-password-strength .point{background:#ebebeb;border-radius:8px;display:inline-block;height:8px;margin-right:4px;width:100%}mecx-password-strength .point.success{background:var(--mecx-color-success-main)}mecx-password-strength .point.warning{background:var(--mecx-color-warning-main)}mecx-password-strength .point.error{background:var(--mecx-color-error-main)}mecx-password-strength .name-point.success{color:var(--mecx-color-success-main)}mecx-password-strength .name-point.warning{color:var(--mecx-color-warning-main)}mecx-password-strength .name-point.error{color:var(--mecx-color-error-main)}\n"], components: [{ type: i1$1.MonkeyIconComponent, selector: "monkey-icon", inputs: ["icon", "color", "contrast", "disabled"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i4.TranslatePipe }, encapsulation: i0.ViewEncapsulation.None });
1339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXPasswordStrengthComponent, decorators: [{
1340
+ type: Component,
1341
+ args: [{ selector: 'mecx-password-strength', encapsulation: ViewEncapsulation.None, template: "<ng-container *ngIf=\"_validatorsPasswordPass?.length\">\n <div id=\"strength\" class=\"d-flex full-width flex-column justify-content-center align-items-center\"\n #strength>\n <div id=\"strengthBar\" class=\"strength-bar d-flex full-width flex-row\">\n <div class=\"d-flex full-width align-items-center\">\n <div class=\"bar-label\">\n <small>{{ 'SCREENS.LOGIN.REGISTER.PASSWORD-STRENGTH.TITLE' | translate }}</small>\n </div>\n </div>\n <div class=\"d-flex full-width align-items-center flex-column\">\n <div class=\"point\" [class.error]=\"_stepPassword === 0\" [class.warning]=\"_stepPassword === 1\"\n [class.success]=\"_stepPassword === 2\">\n </div>\n <ng-container *ngIf=\"_stepPassword === 0\">\n <ng-container *ngTemplateOutlet=\"stepPasswordLabel\"></ng-container>\n </ng-container>\n </div>\n <div class=\"d-flex full-width align-items-center flex-column\">\n <div class=\"point\" [class.warning]=\"_stepPassword === 1\"\n [class.success]=\"_stepPassword === 2\"></div>\n <ng-container *ngIf=\"_stepPassword === 1\">\n <ng-container *ngTemplateOutlet=\"stepPasswordLabel\"></ng-container>\n </ng-container>\n </div>\n <div class=\"d-flex full-width align-items-center flex-column\">\n <div class=\"point\" [class.success]=\"_stepPassword === 2\"></div>\n <ng-container *ngIf=\"_stepPassword === 2\">\n <ng-container *ngTemplateOutlet=\"stepPasswordLabel\"></ng-container>\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"callbacks mt-2 row\">\n <div class=\"col-sm-6 mt-2 d-flex justify-content-start\"\n *ngFor=\"let validators of _validatorsPasswordPass\">\n <monkey-icon *ngIf=\"validators.validate\" icon=\"check-circle-20\"></monkey-icon>\n <monkey-icon *ngIf=\"!validators.validate\" icon=\"error-20\"></monkey-icon>\n <span class=\"ml-2\">\n {{ 'SCREENS.LOGIN.REGISTER.PASSWORD-STRENGTH.TYPES.' + validators.regex | translate }}\n </span>\n </div>\n </div>\n</ng-container>\n<ng-template #stepPasswordLabel>\n <div class=\"name-point mt-1\" [class.error]=\"_stepPassword === 0\"\n [class.warning]=\"_stepPassword === 1\" [class.success]=\"_stepPassword === 2\">\n {{ 'SCREENS.LOGIN.REGISTER.PASSWORD-STRENGTH.LABELS.' + _stepPassword | translate }}\n </div>\n</ng-template>", styles: ["mecx-password-strength{margin-bottom:8px}mecx-password-strength .strength-bar{display:inline;list-style:none;padding:0;vertical-align:2px;grid-gap:.5rem;gap:.5rem}mecx-password-strength .strength-bar .bar-label{font-style:normal;font-weight:400;font-size:14px;line-height:16px;color:#4b4a53}mecx-password-strength .strength-bar .point:last-child{margin:0}mecx-password-strength .callbacks{font-style:normal;font-weight:400;font-size:14px;line-height:16px;color:#72717e}mecx-password-strength .point{background:#ebebeb;border-radius:8px;display:inline-block;height:8px;margin-right:4px;width:100%}mecx-password-strength .point.success{background:var(--mecx-color-success-main)}mecx-password-strength .point.warning{background:var(--mecx-color-warning-main)}mecx-password-strength .point.error{background:var(--mecx-color-error-main)}mecx-password-strength .name-point.success{color:var(--mecx-color-success-main)}mecx-password-strength .name-point.warning{color:var(--mecx-color-warning-main)}mecx-password-strength .name-point.error{color:var(--mecx-color-error-main)}\n"] }]
1342
+ }], ctorParameters: function () { return [{ type: i1$2.MonkeyEcxConfigService }]; }, propDecorators: { passwordToCheck: [{
1343
+ type: Input
1344
+ }], onHandleSubmitReady: [{
1345
+ type: Output
1346
+ }] } });
1347
+
1348
+ class MECXPasswordStrengthModule {
1349
+ }
1350
+ MECXPasswordStrengthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXPasswordStrengthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1351
+ MECXPasswordStrengthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXPasswordStrengthModule, declarations: [MECXPasswordStrengthComponent], imports: [CommonModule,
1352
+ FormsModule,
1353
+ ReactiveFormsModule,
1354
+ MonkeyEcxPipesModule,
1355
+ MonkeyEcxDirectivesModule,
1356
+ MonkeyButtonModule,
1357
+ MonkeyInputModule,
1358
+ MonkeyIconModule, i4.TranslateModule], exports: [MECXPasswordStrengthComponent] });
1359
+ MECXPasswordStrengthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXPasswordStrengthModule, imports: [[
1360
+ CommonModule,
1361
+ FormsModule,
1362
+ ReactiveFormsModule,
1363
+ MonkeyEcxPipesModule,
1364
+ MonkeyEcxDirectivesModule,
1365
+ MonkeyButtonModule,
1366
+ MonkeyInputModule,
1367
+ MonkeyIconModule,
1368
+ TranslateModule.forChild()
1369
+ ]] });
1370
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXPasswordStrengthModule, decorators: [{
1371
+ type: NgModule,
1372
+ args: [{
1373
+ declarations: [MECXPasswordStrengthComponent],
1374
+ imports: [
1375
+ CommonModule,
1376
+ FormsModule,
1377
+ ReactiveFormsModule,
1378
+ MonkeyEcxPipesModule,
1379
+ MonkeyEcxDirectivesModule,
1380
+ MonkeyButtonModule,
1381
+ MonkeyInputModule,
1382
+ MonkeyIconModule,
1383
+ TranslateModule.forChild()
1384
+ ],
1385
+ exports: [MECXPasswordStrengthComponent]
1386
+ }]
1387
+ }] });
1388
+
1389
+ class MECXProgressBarService {
1390
+ constructor(router) {
1391
+ this.router = router;
1392
+ this.visible = new BehaviorSubject(false);
1393
+ this.init();
1394
+ }
1395
+ init() {
1396
+ this.router.events
1397
+ .pipe(filter((event) => {
1398
+ return event instanceof NavigationStart;
1399
+ }))
1400
+ .subscribe(() => {
1401
+ this.show();
1402
+ });
1403
+ this.router.events
1404
+ .pipe(filter((event) => {
1405
+ return (event instanceof NavigationEnd ||
1406
+ event instanceof NavigationError ||
1407
+ event instanceof NavigationCancel);
1408
+ }))
1409
+ .subscribe(() => {
1410
+ this.hide();
1411
+ });
1412
+ }
1413
+ show() {
1414
+ this.visible.next(true);
1415
+ }
1416
+ hide() {
1417
+ this.visible.next(false);
1418
+ }
1419
+ visibleConfig() {
1420
+ return this.visible.asObservable();
1421
+ }
1422
+ }
1423
+ MECXProgressBarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarService, deps: [{ token: i1$3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
1424
+ MECXProgressBarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarService, providedIn: 'root' });
1425
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarService, decorators: [{
1426
+ type: Injectable,
1427
+ args: [{
1428
+ providedIn: 'root'
1429
+ }]
1430
+ }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
1431
+
1432
+ class MECXProgressBarComponent extends BaseComponent {
1433
+ constructor(progressBarService) {
1434
+ super();
1435
+ this.progressBarService = progressBarService;
1436
+ this.visible = false;
1437
+ }
1438
+ ngOnInit() {
1439
+ this.progressBarService
1440
+ .visibleConfig()
1441
+ .pipe(takeUntil(this.__unsubscribeAll))
1442
+ .subscribe((visible) => {
1443
+ this.visible = visible;
1444
+ });
1445
+ }
1446
+ }
1447
+ MECXProgressBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarComponent, deps: [{ token: MECXProgressBarService }], target: i0.ɵɵFactoryTarget.Component });
1448
+ MECXProgressBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXProgressBarComponent, selector: "mecx-progress-bar", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"visible\">\n <progress class=\"monkey-progress monkey-progress__theme\"></progress>\n</ng-container>", styles: ["app-progress-bar{position:absolute;width:100%;margin-top:-9.5px;z-index:99998}\n"], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], encapsulation: i0.ViewEncapsulation.None });
1449
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarComponent, decorators: [{
1450
+ type: Component,
1451
+ args: [{ selector: 'mecx-progress-bar', encapsulation: ViewEncapsulation.None, template: "<ng-container *ngIf=\"visible\">\n <progress class=\"monkey-progress monkey-progress__theme\"></progress>\n</ng-container>", styles: ["app-progress-bar{position:absolute;width:100%;margin-top:-9.5px;z-index:99998}\n"] }]
1452
+ }], ctorParameters: function () { return [{ type: MECXProgressBarService }]; } });
1453
+
1454
+ class MECXProgressBarModule {
1455
+ }
1456
+ MECXProgressBarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1457
+ MECXProgressBarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarModule, declarations: [MECXProgressBarComponent], imports: [CommonModule], exports: [MECXProgressBarComponent] });
1458
+ MECXProgressBarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarModule, imports: [[CommonModule]] });
1459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProgressBarModule, decorators: [{
1460
+ type: NgModule,
1461
+ args: [{
1462
+ declarations: [MECXProgressBarComponent],
1463
+ imports: [CommonModule],
1464
+ exports: [MECXProgressBarComponent]
1465
+ }]
1466
+ }] });
1467
+
1468
+ /*
1469
+ * Public API Surface of monkey-front-components
1470
+ */
1471
+
1472
+ /**
1473
+ * Generated bundle index. Do not edit.
1474
+ */
1475
+
1476
+ export { BaseComponent, BaseDynamic, BaseDynamicArray, MECXDynamicDirective, MECXDynamicFileUploadComponent, MECXDynamicFormArrayComponent, MECXDynamicFormComponent, MECXDynamicInputComponent, MECXDynamicInputPhoneComponent, MECXDynamicModule, MECXDynamicRadioComponent, MECXDynamicSelectComponent, MECXPasswordStrengthComponent, MECXPasswordStrengthModule, MECXProgressBarComponent, MECXProgressBarModule, MECXProgressBarService, validators };
1477
+ //# sourceMappingURL=monkey-front-components.mjs.map