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