@3kles/kles-material-dynamicforms 1.1.0 → 1.1.4

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 (142) hide show
  1. package/3kles-kles-material-dynamicforms.d.ts +5 -5
  2. package/3kles-kles-material-dynamicforms.metadata.json +1 -1
  3. package/bundles/3kles-kles-material-dynamicforms.umd.js +1478 -1457
  4. package/bundles/3kles-kles-material-dynamicforms.umd.js.map +1 -1
  5. package/bundles/3kles-kles-material-dynamicforms.umd.min.js +2 -2
  6. package/bundles/3kles-kles-material-dynamicforms.umd.min.js.map +1 -1
  7. package/esm2015/3kles-kles-material-dynamicforms.js +5 -5
  8. package/esm2015/lib/directive/dynamic-component.directive.js +50 -46
  9. package/esm2015/lib/directive/dynamic-field.directive.js +94 -94
  10. package/esm2015/lib/dynamic-form.component.js +238 -234
  11. package/esm2015/lib/fields/badge.component.js +20 -20
  12. package/esm2015/lib/fields/button-form.component.js +28 -28
  13. package/esm2015/lib/fields/button-submit.component.js +20 -20
  14. package/esm2015/lib/fields/button-toogle-group.component.js +37 -37
  15. package/esm2015/lib/fields/buttonchecker-form.component.js +28 -28
  16. package/esm2015/lib/fields/buttonfile-form.component.js +27 -27
  17. package/esm2015/lib/fields/checkbox.component.js +24 -24
  18. package/esm2015/lib/fields/chip.component.js +23 -23
  19. package/esm2015/lib/fields/color.component.js +58 -58
  20. package/esm2015/lib/fields/date.component.js +28 -28
  21. package/esm2015/lib/fields/field.abstract.js +40 -40
  22. package/esm2015/lib/fields/group.component.js +27 -27
  23. package/esm2015/lib/fields/icon.component.js +18 -18
  24. package/esm2015/lib/fields/input.clearable.component.js +56 -56
  25. package/esm2015/lib/fields/input.component.js +101 -101
  26. package/esm2015/lib/fields/label.component.js +23 -23
  27. package/esm2015/lib/fields/line-break.component.js +19 -19
  28. package/esm2015/lib/fields/link.component.js +20 -20
  29. package/esm2015/lib/fields/list-field.component.js +83 -83
  30. package/esm2015/lib/fields/radio.component.js +27 -27
  31. package/esm2015/lib/fields/select.component.js +120 -114
  32. package/esm2015/lib/fields/select.search.component.js +205 -199
  33. package/esm2015/lib/fields/selection-list.component.js +40 -41
  34. package/esm2015/lib/fields/slide-toggle.component.js +24 -24
  35. package/esm2015/lib/fields/text.component.js +20 -20
  36. package/esm2015/lib/fields/textarea.component.js +32 -32
  37. package/esm2015/lib/forms/button-control.component.js +102 -102
  38. package/esm2015/lib/forms/buttonchecker-control.component.js +53 -53
  39. package/esm2015/lib/forms/buttonfile-control.component.js +107 -107
  40. package/esm2015/lib/interfaces/component.interface.js +1 -1
  41. package/esm2015/lib/interfaces/field.config.interface.js +1 -1
  42. package/esm2015/lib/interfaces/field.interface.js +1 -1
  43. package/esm2015/lib/interfaces/validator.interface.js +1 -1
  44. package/esm2015/lib/kles-material-dynamicforms.module.js +114 -114
  45. package/esm2015/lib/matcher/form-error.matcher.js +9 -9
  46. package/esm2015/lib/modules/material.module.js +129 -129
  47. package/esm2015/lib/pipe/array.pipe.js +20 -20
  48. package/esm2015/lib/pipe/transform.pipe.js +25 -25
  49. package/esm2015/lib/validators/autocomplete.validator.js +23 -23
  50. package/esm2015/public-api.js +48 -48
  51. package/esm5/3kles-kles-material-dynamicforms.js +5 -5
  52. package/esm5/lib/directive/dynamic-component.directive.js +51 -47
  53. package/esm5/lib/directive/dynamic-field.directive.js +95 -95
  54. package/esm5/lib/dynamic-form.component.js +240 -236
  55. package/esm5/lib/fields/badge.component.js +21 -21
  56. package/esm5/lib/fields/button-form.component.js +21 -21
  57. package/esm5/lib/fields/button-submit.component.js +21 -21
  58. package/esm5/lib/fields/button-toogle-group.component.js +33 -33
  59. package/esm5/lib/fields/buttonchecker-form.component.js +21 -21
  60. package/esm5/lib/fields/buttonfile-form.component.js +21 -21
  61. package/esm5/lib/fields/checkbox.component.js +19 -19
  62. package/esm5/lib/fields/chip.component.js +19 -19
  63. package/esm5/lib/fields/color.component.js +46 -46
  64. package/esm5/lib/fields/date.component.js +19 -19
  65. package/esm5/lib/fields/field.abstract.js +45 -45
  66. package/esm5/lib/fields/group.component.js +25 -25
  67. package/esm5/lib/fields/icon.component.js +19 -19
  68. package/esm5/lib/fields/input.clearable.component.js +19 -19
  69. package/esm5/lib/fields/input.component.js +70 -70
  70. package/esm5/lib/fields/label.component.js +22 -22
  71. package/esm5/lib/fields/line-break.component.js +20 -20
  72. package/esm5/lib/fields/link.component.js +21 -21
  73. package/esm5/lib/fields/list-field.component.js +63 -63
  74. package/esm5/lib/fields/radio.component.js +19 -19
  75. package/esm5/lib/fields/select.component.js +52 -45
  76. package/esm5/lib/fields/select.search.component.js +119 -113
  77. package/esm5/lib/fields/selection-list.component.js +29 -29
  78. package/esm5/lib/fields/slide-toggle.component.js +19 -19
  79. package/esm5/lib/fields/text.component.js +21 -21
  80. package/esm5/lib/fields/textarea.component.js +22 -22
  81. package/esm5/lib/forms/button-control.component.js +95 -95
  82. package/esm5/lib/forms/buttonchecker-control.component.js +37 -37
  83. package/esm5/lib/forms/buttonfile-control.component.js +123 -123
  84. package/esm5/lib/interfaces/component.interface.js +1 -1
  85. package/esm5/lib/interfaces/field.config.interface.js +1 -1
  86. package/esm5/lib/interfaces/field.interface.js +1 -1
  87. package/esm5/lib/interfaces/validator.interface.js +1 -1
  88. package/esm5/lib/kles-material-dynamicforms.module.js +117 -117
  89. package/esm5/lib/matcher/form-error.matcher.js +11 -11
  90. package/esm5/lib/modules/material.module.js +132 -132
  91. package/esm5/lib/pipe/array.pipe.js +23 -23
  92. package/esm5/lib/pipe/transform.pipe.js +28 -28
  93. package/esm5/lib/validators/autocomplete.validator.js +23 -23
  94. package/esm5/public-api.js +48 -48
  95. package/fesm2015/3kles-kles-material-dynamicforms.js +1795 -1776
  96. package/fesm2015/3kles-kles-material-dynamicforms.js.map +1 -1
  97. package/fesm5/3kles-kles-material-dynamicforms.js +1482 -1461
  98. package/fesm5/3kles-kles-material-dynamicforms.js.map +1 -1
  99. package/lib/directive/dynamic-component.directive.d.ts +14 -12
  100. package/lib/directive/dynamic-field.directive.d.ts +16 -16
  101. package/lib/dynamic-form.component.d.ts +28 -28
  102. package/lib/fields/badge.component.d.ts +5 -5
  103. package/lib/fields/button-form.component.d.ts +5 -5
  104. package/lib/fields/button-submit.component.d.ts +5 -5
  105. package/lib/fields/button-toogle-group.component.d.ts +7 -7
  106. package/lib/fields/buttonchecker-form.component.d.ts +5 -5
  107. package/lib/fields/buttonfile-form.component.d.ts +5 -5
  108. package/lib/fields/checkbox.component.d.ts +5 -5
  109. package/lib/fields/chip.component.d.ts +5 -5
  110. package/lib/fields/color.component.d.ts +6 -6
  111. package/lib/fields/date.component.d.ts +5 -5
  112. package/lib/fields/field.abstract.d.ts +12 -12
  113. package/lib/fields/group.component.d.ts +7 -7
  114. package/lib/fields/icon.component.d.ts +5 -5
  115. package/lib/fields/input.clearable.component.d.ts +4 -4
  116. package/lib/fields/input.component.d.ts +11 -11
  117. package/lib/fields/label.component.d.ts +5 -5
  118. package/lib/fields/line-break.component.d.ts +5 -5
  119. package/lib/fields/link.component.d.ts +5 -5
  120. package/lib/fields/list-field.component.d.ts +14 -14
  121. package/lib/fields/radio.component.d.ts +5 -5
  122. package/lib/fields/select.component.d.ts +14 -13
  123. package/lib/fields/select.search.component.d.ts +20 -19
  124. package/lib/fields/selection-list.component.d.ts +7 -7
  125. package/lib/fields/slide-toggle.component.d.ts +5 -5
  126. package/lib/fields/text.component.d.ts +5 -5
  127. package/lib/fields/textarea.component.d.ts +5 -5
  128. package/lib/forms/button-control.component.d.ts +33 -33
  129. package/lib/forms/buttonchecker-control.component.d.ts +11 -11
  130. package/lib/forms/buttonfile-control.component.d.ts +17 -17
  131. package/lib/interfaces/component.interface.d.ts +5 -5
  132. package/lib/interfaces/field.config.interface.d.ts +52 -51
  133. package/lib/interfaces/field.interface.d.ts +7 -7
  134. package/lib/interfaces/validator.interface.d.ts +5 -5
  135. package/lib/kles-material-dynamicforms.module.d.ts +2 -2
  136. package/lib/matcher/form-error.matcher.d.ts +6 -6
  137. package/lib/modules/material.module.d.ts +2 -2
  138. package/lib/pipe/array.pipe.d.ts +4 -4
  139. package/lib/pipe/transform.pipe.d.ts +7 -7
  140. package/lib/validators/autocomplete.validator.d.ts +3 -3
  141. package/package.json +1 -1
  142. package/public-api.d.ts +48 -48
@@ -43,1545 +43,1566 @@ import { FlexLayoutModule } from '@angular/flex-layout';
43
43
  import { TranslateModule } from '@ngx-translate/core';
44
44
  import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
45
45
 
46
- var KlesDynamicFormComponent = /** @class */ (function () {
47
- function KlesDynamicFormComponent(fb) {
48
- this.fb = fb;
49
- this.fields = [];
50
- this.validators = [];
51
- this.asyncValidators = [];
52
- // tslint:disable-next-line: no-output-native
53
- this.submit = new EventEmitter();
54
- this._onLoaded = new EventEmitter();
55
- this.direction = 'column';
56
- this.orientationClass = 'dynamic-form-column';
57
- this.orientationItemClass = 'dynamic-form-column-item';
58
- }
59
- Object.defineProperty(KlesDynamicFormComponent.prototype, "value", {
60
- get: function () {
61
- return this.form.value;
62
- },
63
- enumerable: true,
64
- configurable: true
65
- });
66
- KlesDynamicFormComponent.prototype.ngOnInit = function () {
67
- this.form = this.createForm();
68
- this.orientationClass = this.direction === 'row' ? 'dynamic-form-row' : 'dynamic-form-column';
69
- this.orientationItemClass = this.direction === 'row' ? 'dynamic-form-row-item' : 'dynamic-form-column-item';
70
- this._onLoaded.emit();
71
- };
72
- KlesDynamicFormComponent.prototype.ngOnChanges = function (changes) {
73
- var _a, _b, _c, _d;
74
- if (!((_a = changes.fields) === null || _a === void 0 ? void 0 : _a.firstChange)) {
75
- this.updateForm();
76
- // this.form = this.createControl();
77
- // this.form.controls = {};
78
- this._onLoaded.emit();
79
- }
80
- if (!((_b = changes.validators) === null || _b === void 0 ? void 0 : _b.firstChange) && this.form) {
81
- this.form.setValidators(this.validators.map(function (v) { return v.validator; }));
82
- }
83
- if (!((_c = changes.asyncValidators) === null || _c === void 0 ? void 0 : _c.firstChange) && this.form) {
84
- this.form.setAsyncValidators(this.asyncValidators.map(function (v) { return v.validator; }));
85
- }
86
- if (!((_d = changes.direction) === null || _d === void 0 ? void 0 : _d.firstChange)) {
87
- this.orientationClass = this.direction === 'row' ? 'dynamic-form-row' : 'dynamic-form-column';
88
- this.orientationItemClass = this.direction === 'row' ? 'dynamic-form-row-item' : 'dynamic-form-column-item';
89
- }
90
- };
91
- KlesDynamicFormComponent.prototype.onSubmit = function (event) {
92
- event.preventDefault();
93
- event.stopPropagation();
94
- if (this.form.valid) {
95
- this.submit.emit(this.form.value);
96
- }
97
- else {
98
- this.validateAllFormFields(this.form);
99
- }
100
- };
101
- KlesDynamicFormComponent.prototype.reset = function () {
102
- this.form.reset();
103
- };
104
- KlesDynamicFormComponent.prototype.updateForm = function () {
105
- var _this = this;
106
- Object.keys(this.form.controls).filter(function (key) {
107
- return !_this.fields.map(function (field) { return field.name; }).includes(key);
108
- }).forEach(function (key) {
109
- _this.form.removeControl(key);
110
- });
111
- this.fields
112
- .filter(function (field) { return !_this.form.controls[field.name]; })
113
- .forEach(function (field) {
114
- if (field.type === 'lineBreak') {
115
- return;
116
- }
117
- var control = _this.createControl(field);
118
- _this.form.addControl(field.name, control);
119
- });
120
- };
121
- KlesDynamicFormComponent.prototype.createControl = function (field) {
122
- var _this = this;
123
- if (field.type === 'listField') {
124
- var array_1 = this.fb.array([]);
125
- field.value.forEach(function (data) {
126
- var subGroup = _this.fb.group({});
127
- field.collections.forEach(function (subfield) {
128
- var control = _this.createControl(subfield);
129
- subGroup.addControl(subfield.name, control);
130
- });
131
- array_1.push(subGroup);
132
- });
133
- return array_1;
134
- }
135
- else if (field.type === 'group') {
136
- var subGroup_1 = this.fb.group({});
137
- if (field.collections && Array.isArray(field.collections)) {
138
- field.collections.forEach(function (subfield) {
139
- var control = _this.createControl(subfield);
140
- subGroup_1.addControl(subfield.name, control);
141
- });
142
- }
143
- return subGroup_1;
144
- }
145
- else {
146
- var control = this.fb.control(field.value, this.bindValidations(field.validations || []), this.bindAsyncValidations(field.asyncValidations || []));
147
- if (field.disabled) {
148
- control.disable();
149
- }
150
- return control;
151
- }
152
- };
153
- // private createControl(field: IKlesFieldConfig): AbstractControl {
154
- // if (field.type === 'listField') {
155
- // const array = this.fb.array([]);
156
- // field.value.forEach((data: any) => {
157
- // const subGroup = this.fb.group({});
158
- // field.collections.forEach(subfield => {
159
- // const control = this.fb.control(
160
- // data[subfield.name] ? data[subfield.name] : null,
161
- // this.bindValidations(subfield.validations || []),
162
- // this.bindAsyncValidations(subfield.asyncValidations || [])
163
- // );
164
- // subGroup.addControl(subfield.name, control);
165
- // });
166
- // array.push(subGroup);
167
- // });
168
- // return array;
169
- // } else if (field.type === 'group') {
170
- // const subGroup = this.fb.group({});
171
- // if (field.collections && Array.isArray(field.collections)) {
172
- // field.collections.forEach(subfield => {
173
- // const control = this.fb.control(
174
- // subfield.value,
175
- // this.bindValidations(subfield.validations || []),
176
- // this.bindAsyncValidations(subfield.asyncValidations || [])
177
- // );
178
- // if (subfield.disabled) {
179
- // control.disable();
180
- // }
181
- // subGroup.addControl(subfield.name, control);
182
- // });
183
- // }
184
- // return subGroup;
185
- // } else {
186
- // const control = this.fb.control(
187
- // field.value,
188
- // this.bindValidations(field.validations || []),
189
- // this.bindAsyncValidations(field.asyncValidations || [])
190
- // );
191
- // if (field.disabled) {
192
- // control.disable();
193
- // }
194
- // return control;
195
- // }
196
- // }
197
- KlesDynamicFormComponent.prototype.createForm = function () {
198
- var _this = this;
199
- var group = this.fb.group({});
200
- this.fields.forEach(function (field) {
201
- if (field.type === 'lineBreak') {
202
- return;
203
- }
204
- var control = _this.createControl(field);
205
- group.addControl(field.name, control);
206
- });
207
- group.setValidators(this.validators.map(function (v) { return v.validator; }));
208
- group.setAsyncValidators(this.asyncValidators.map(function (v) { return v.validator; }));
209
- return group;
210
- };
211
- KlesDynamicFormComponent.prototype.bindValidations = function (validations) {
212
- if (validations.length > 0) {
213
- var validList_1 = [];
214
- validations.forEach(function (valid) {
215
- validList_1.push(valid.validator);
216
- });
217
- return Validators.compose(validList_1);
218
- }
219
- return null;
220
- };
221
- KlesDynamicFormComponent.prototype.bindAsyncValidations = function (validations) {
222
- if (validations.length > 0) {
223
- var validList_2 = [];
224
- validations.forEach(function (valid) {
225
- validList_2.push(valid.validator);
226
- });
227
- return Validators.composeAsync(validList_2);
228
- }
229
- return null;
230
- };
231
- KlesDynamicFormComponent.prototype.validateAllFormFields = function (formGroup) {
232
- Object.keys(formGroup.controls).forEach(function (field) {
233
- var control = formGroup.get(field);
234
- control.markAsTouched({ onlySelf: true });
235
- });
236
- };
237
- KlesDynamicFormComponent.ctorParameters = function () { return [
238
- { type: FormBuilder }
239
- ]; };
240
- __decorate([
241
- Input()
242
- ], KlesDynamicFormComponent.prototype, "fields", void 0);
243
- __decorate([
244
- Input()
245
- ], KlesDynamicFormComponent.prototype, "validators", void 0);
246
- __decorate([
247
- Input()
248
- ], KlesDynamicFormComponent.prototype, "asyncValidators", void 0);
249
- __decorate([
250
- Output()
251
- ], KlesDynamicFormComponent.prototype, "submit", void 0);
252
- __decorate([
253
- Output()
254
- ], KlesDynamicFormComponent.prototype, "_onLoaded", void 0);
255
- __decorate([
256
- Input()
257
- ], KlesDynamicFormComponent.prototype, "direction", void 0);
258
- KlesDynamicFormComponent = __decorate([
259
- Component({
260
- exportAs: 'klesDynamicForm',
261
- selector: 'app-kles-dynamic-form',
262
- template: "\n <form class=\"{{orientationClass}}\" [formGroup]=\"form\" (submit)=\"onSubmit($event)\">\n <ng-container *ngFor=\"let field of fields;\" class=\"{{orientationItemClass}}\" klesDynamicField [field]=\"field\" [group]=\"form\" [siblingFields]=\"fields\">\n </ng-container>\n <!--<button (click)=\"reset()\" mat-raised-button color=\"primary\">RESET</button>-->\n </form>\n ",
263
- styles: [
264
- // '.dynamic-form {display: flex; flex-direction: column;}',
265
- //'.dynamic-form {display: flex;}',
266
- //'.dynamic-form { width: 100%; }',
267
- '.dynamic-form-column { display: flex;flex-direction: column; }',
268
- '.dynamic-form-column > * { width: 100%; }',
269
- '.dynamic-form-row { display: inline-flex;flex-wrap:wrap;gap:10px }',
270
- '.dynamic-form-row > * { width: 100%; }',
271
- '.dynamic-form-row-item { margin-right: 10px; }',
272
- '.dynamic-form-column-item { margin-bottom: 10px; }']
273
- })
274
- ], KlesDynamicFormComponent);
275
- return KlesDynamicFormComponent;
46
+ var KlesDynamicFormComponent = /** @class */ (function () {
47
+ function KlesDynamicFormComponent(fb) {
48
+ this.fb = fb;
49
+ this.fields = [];
50
+ this.validators = [];
51
+ this.asyncValidators = [];
52
+ // tslint:disable-next-line: no-output-native
53
+ this.submit = new EventEmitter();
54
+ this._onLoaded = new EventEmitter();
55
+ this.direction = 'column';
56
+ this.orientationClass = 'dynamic-form-column';
57
+ this.orientationItemClass = 'dynamic-form-column-item';
58
+ }
59
+ Object.defineProperty(KlesDynamicFormComponent.prototype, "value", {
60
+ get: function () {
61
+ return this.form.value;
62
+ },
63
+ enumerable: true,
64
+ configurable: true
65
+ });
66
+ KlesDynamicFormComponent.prototype.ngOnInit = function () {
67
+ this.form = this.createForm();
68
+ this.orientationClass = this.direction === 'row' ? 'dynamic-form-row' : 'dynamic-form-column';
69
+ this.orientationItemClass = this.direction === 'row' ? 'dynamic-form-row-item' : 'dynamic-form-column-item';
70
+ this._onLoaded.emit();
71
+ };
72
+ KlesDynamicFormComponent.prototype.ngOnChanges = function (changes) {
73
+ var _a, _b, _c, _d;
74
+ if (!((_a = changes.fields) === null || _a === void 0 ? void 0 : _a.firstChange)) {
75
+ this.updateForm();
76
+ // this.form = this.createControl();
77
+ // this.form.controls = {};
78
+ this._onLoaded.emit();
79
+ }
80
+ if (!((_b = changes.validators) === null || _b === void 0 ? void 0 : _b.firstChange) && this.form) {
81
+ this.form.setValidators(this.validators.map(function (v) { return v.validator; }));
82
+ }
83
+ if (!((_c = changes.asyncValidators) === null || _c === void 0 ? void 0 : _c.firstChange) && this.form) {
84
+ this.form.setAsyncValidators(this.asyncValidators.map(function (v) { return v.validator; }));
85
+ }
86
+ if (!((_d = changes.direction) === null || _d === void 0 ? void 0 : _d.firstChange)) {
87
+ this.orientationClass = this.direction === 'row' ? 'dynamic-form-row' : 'dynamic-form-column';
88
+ this.orientationItemClass = this.direction === 'row' ? 'dynamic-form-row-item' : 'dynamic-form-column-item';
89
+ }
90
+ };
91
+ KlesDynamicFormComponent.prototype.onSubmit = function (event) {
92
+ event.preventDefault();
93
+ event.stopPropagation();
94
+ if (this.form.valid) {
95
+ this.submit.emit(this.form.value);
96
+ }
97
+ else {
98
+ this.validateAllFormFields(this.form);
99
+ }
100
+ };
101
+ KlesDynamicFormComponent.prototype.reset = function () {
102
+ this.form.reset();
103
+ };
104
+ KlesDynamicFormComponent.prototype.updateForm = function () {
105
+ var _this = this;
106
+ Object.keys(this.form.controls).filter(function (key) {
107
+ return !_this.fields.map(function (field) { return field.name; }).includes(key);
108
+ }).forEach(function (key) {
109
+ _this.form.removeControl(key);
110
+ });
111
+ this.fields
112
+ .filter(function (field) { return !_this.form.controls[field.name]; })
113
+ .forEach(function (field) {
114
+ if (field.type === 'lineBreak') {
115
+ return;
116
+ }
117
+ var control = _this.createControl(field);
118
+ _this.form.addControl(field.name, control);
119
+ });
120
+ };
121
+ KlesDynamicFormComponent.prototype.createControl = function (field) {
122
+ var _this = this;
123
+ if (field.type === 'listField') {
124
+ var array_1 = this.fb.array([]);
125
+ field.value.forEach(function (data) {
126
+ var subGroup = _this.fb.group({});
127
+ field.collections.forEach(function (subfield) {
128
+ var control = _this.createControl(subfield);
129
+ subGroup.addControl(subfield.name, control);
130
+ });
131
+ array_1.push(subGroup);
132
+ });
133
+ return array_1;
134
+ }
135
+ else if (field.type === 'group') {
136
+ var subGroup_1 = this.fb.group({});
137
+ if (field.collections && Array.isArray(field.collections)) {
138
+ field.collections.forEach(function (subfield) {
139
+ var control = _this.createControl(subfield);
140
+ subGroup_1.addControl(subfield.name, control);
141
+ });
142
+ }
143
+ return subGroup_1;
144
+ }
145
+ else {
146
+ var control = this.fb.control(field.value, {
147
+ validators: this.bindValidations(field.validations || []),
148
+ asyncValidators: this.bindAsyncValidations(field.asyncValidations || []),
149
+ updateOn: field.updateOn || 'change'
150
+ });
151
+ if (field.disabled) {
152
+ control.disable();
153
+ }
154
+ return control;
155
+ }
156
+ };
157
+ // private createControl(field: IKlesFieldConfig): AbstractControl {
158
+ // if (field.type === 'listField') {
159
+ // const array = this.fb.array([]);
160
+ // field.value.forEach((data: any) => {
161
+ // const subGroup = this.fb.group({});
162
+ // field.collections.forEach(subfield => {
163
+ // const control = this.fb.control(
164
+ // data[subfield.name] ? data[subfield.name] : null,
165
+ // this.bindValidations(subfield.validations || []),
166
+ // this.bindAsyncValidations(subfield.asyncValidations || [])
167
+ // );
168
+ // subGroup.addControl(subfield.name, control);
169
+ // });
170
+ // array.push(subGroup);
171
+ // });
172
+ // return array;
173
+ // } else if (field.type === 'group') {
174
+ // const subGroup = this.fb.group({});
175
+ // if (field.collections && Array.isArray(field.collections)) {
176
+ // field.collections.forEach(subfield => {
177
+ // const control = this.fb.control(
178
+ // subfield.value,
179
+ // this.bindValidations(subfield.validations || []),
180
+ // this.bindAsyncValidations(subfield.asyncValidations || [])
181
+ // );
182
+ // if (subfield.disabled) {
183
+ // control.disable();
184
+ // }
185
+ // subGroup.addControl(subfield.name, control);
186
+ // });
187
+ // }
188
+ // return subGroup;
189
+ // } else {
190
+ // const control = this.fb.control(
191
+ // field.value,
192
+ // this.bindValidations(field.validations || []),
193
+ // this.bindAsyncValidations(field.asyncValidations || [])
194
+ // );
195
+ // if (field.disabled) {
196
+ // control.disable();
197
+ // }
198
+ // return control;
199
+ // }
200
+ // }
201
+ KlesDynamicFormComponent.prototype.createForm = function () {
202
+ var _this = this;
203
+ var group = this.fb.group({});
204
+ this.fields.forEach(function (field) {
205
+ if (field.type === 'lineBreak') {
206
+ return;
207
+ }
208
+ var control = _this.createControl(field);
209
+ group.addControl(field.name, control);
210
+ });
211
+ group.setValidators(this.validators.map(function (v) { return v.validator; }));
212
+ group.setAsyncValidators(this.asyncValidators.map(function (v) { return v.validator; }));
213
+ return group;
214
+ };
215
+ KlesDynamicFormComponent.prototype.bindValidations = function (validations) {
216
+ if (validations.length > 0) {
217
+ var validList_1 = [];
218
+ validations.forEach(function (valid) {
219
+ validList_1.push(valid.validator);
220
+ });
221
+ return Validators.compose(validList_1);
222
+ }
223
+ return null;
224
+ };
225
+ KlesDynamicFormComponent.prototype.bindAsyncValidations = function (validations) {
226
+ if (validations.length > 0) {
227
+ var validList_2 = [];
228
+ validations.forEach(function (valid) {
229
+ validList_2.push(valid.validator);
230
+ });
231
+ return Validators.composeAsync(validList_2);
232
+ }
233
+ return null;
234
+ };
235
+ KlesDynamicFormComponent.prototype.validateAllFormFields = function (formGroup) {
236
+ Object.keys(formGroup.controls).forEach(function (field) {
237
+ var control = formGroup.get(field);
238
+ control.markAsTouched({ onlySelf: true });
239
+ });
240
+ };
241
+ KlesDynamicFormComponent.ctorParameters = function () { return [
242
+ { type: FormBuilder }
243
+ ]; };
244
+ __decorate([
245
+ Input()
246
+ ], KlesDynamicFormComponent.prototype, "fields", void 0);
247
+ __decorate([
248
+ Input()
249
+ ], KlesDynamicFormComponent.prototype, "validators", void 0);
250
+ __decorate([
251
+ Input()
252
+ ], KlesDynamicFormComponent.prototype, "asyncValidators", void 0);
253
+ __decorate([
254
+ Output()
255
+ ], KlesDynamicFormComponent.prototype, "submit", void 0);
256
+ __decorate([
257
+ Output()
258
+ ], KlesDynamicFormComponent.prototype, "_onLoaded", void 0);
259
+ __decorate([
260
+ Input()
261
+ ], KlesDynamicFormComponent.prototype, "direction", void 0);
262
+ KlesDynamicFormComponent = __decorate([
263
+ Component({
264
+ exportAs: 'klesDynamicForm',
265
+ selector: 'app-kles-dynamic-form',
266
+ template: "\n <form class=\"{{orientationClass}}\" [formGroup]=\"form\" (submit)=\"onSubmit($event)\">\n <ng-container *ngFor=\"let field of fields;\" class=\"{{orientationItemClass}}\" klesDynamicField [field]=\"field\" [group]=\"form\" [siblingFields]=\"fields\">\n </ng-container>\n <!--<button (click)=\"reset()\" mat-raised-button color=\"primary\">RESET</button>-->\n </form>\n ",
267
+ styles: [
268
+ // '.dynamic-form {display: flex; flex-direction: column;}',
269
+ //'.dynamic-form {display: flex;}',
270
+ //'.dynamic-form { width: 100%; }',
271
+ '.dynamic-form-column { display: flex;flex-direction: column; }',
272
+ '.dynamic-form-column > * { width: 100%; }',
273
+ '.dynamic-form-row { display: inline-flex;flex-wrap:wrap;gap:10px }',
274
+ '.dynamic-form-row > * { width: 100%; }',
275
+ '.dynamic-form-row-item { margin-right: 10px; }',
276
+ '.dynamic-form-column-item { margin-bottom: 10px; }']
277
+ })
278
+ ], KlesDynamicFormComponent);
279
+ return KlesDynamicFormComponent;
276
280
  }());
277
281
 
278
- var KlesComponentDirective = /** @class */ (function () {
279
- function KlesComponentDirective(resolver, container) {
280
- this.resolver = resolver;
281
- this.container = container;
282
- }
283
- KlesComponentDirective.prototype.ngOnInit = function () {
284
- this.buildComponent();
285
- };
286
- KlesComponentDirective.prototype.ngOnChanges = function (changes) {
287
- if (changes.component && !changes.component.isFirstChange()) {
288
- this.component = changes.component.currentValue;
289
- this.buildComponent();
290
- }
291
- if (changes.value && !changes.value.isFirstChange()) {
292
- this.value = changes.value.currentValue;
293
- this.componentRef.instance.value = this.value;
294
- }
295
- };
296
- KlesComponentDirective.prototype.buildComponent = function () {
297
- var factory = this.resolver.resolveComponentFactory(this.component);
298
- if (this.componentRef)
299
- this.componentRef.destroy();
300
- this.componentRef = this.container.createComponent(factory);
301
- this.componentRef.instance.component = this.component;
302
- this.componentRef.instance.value = this.value;
303
- };
304
- KlesComponentDirective.ctorParameters = function () { return [
305
- { type: ComponentFactoryResolver },
306
- { type: ViewContainerRef }
307
- ]; };
308
- __decorate([
309
- Input()
310
- ], KlesComponentDirective.prototype, "component", void 0);
311
- __decorate([
312
- Input()
313
- ], KlesComponentDirective.prototype, "value", void 0);
314
- KlesComponentDirective = __decorate([
315
- Directive({
316
- selector: '[klesComponent]'
317
- })
318
- ], KlesComponentDirective);
319
- return KlesComponentDirective;
282
+ var KlesComponentDirective = /** @class */ (function () {
283
+ function KlesComponentDirective(resolver, container) {
284
+ this.resolver = resolver;
285
+ this.container = container;
286
+ }
287
+ KlesComponentDirective.prototype.ngOnInit = function () {
288
+ this.buildComponent();
289
+ };
290
+ KlesComponentDirective.prototype.ngOnChanges = function (changes) {
291
+ if (changes.component && !changes.component.isFirstChange()) {
292
+ this.component = changes.component.currentValue;
293
+ this.buildComponent();
294
+ }
295
+ if (changes.value && !changes.value.isFirstChange()) {
296
+ this.value = changes.value.currentValue;
297
+ this.componentRef.instance.value = this.value;
298
+ }
299
+ };
300
+ KlesComponentDirective.prototype.buildComponent = function () {
301
+ var factory = this.resolver.resolveComponentFactory(this.component);
302
+ if (this.componentRef)
303
+ this.componentRef.destroy();
304
+ this.componentRef = this.container.createComponent(factory);
305
+ this.componentRef.instance.component = this.component;
306
+ this.componentRef.instance.value = this.value;
307
+ this.componentRef.instance.field = this.field;
308
+ };
309
+ KlesComponentDirective.ctorParameters = function () { return [
310
+ { type: ComponentFactoryResolver },
311
+ { type: ViewContainerRef }
312
+ ]; };
313
+ __decorate([
314
+ Input()
315
+ ], KlesComponentDirective.prototype, "component", void 0);
316
+ __decorate([
317
+ Input()
318
+ ], KlesComponentDirective.prototype, "value", void 0);
319
+ __decorate([
320
+ Input()
321
+ ], KlesComponentDirective.prototype, "field", void 0);
322
+ KlesComponentDirective = __decorate([
323
+ Directive({
324
+ selector: '[klesComponent]'
325
+ })
326
+ ], KlesComponentDirective);
327
+ return KlesComponentDirective;
320
328
  }());
321
329
 
322
- var KlesFieldAbstract = /** @class */ (function () {
323
- function KlesFieldAbstract() {
324
- }
325
- KlesFieldAbstract.prototype.ngOnInit = function () {
326
- var _this = this;
327
- var _a;
328
- // this.applyPipeTransform();
329
- if (this.field.valueChanges) {
330
- this.field.valueChanges(this.field, this.group, this.siblingFields);
331
- }
332
- (_a = this.group.controls[this.field.name]) === null || _a === void 0 ? void 0 : _a.valueChanges.pipe().subscribe(function (val) {
333
- if (_this.field.valueChanges) {
334
- _this.field.valueChanges(_this.field, _this.group, _this.siblingFields, val);
335
- }
336
- // this.applyPipeTransform();
337
- });
338
- };
339
- KlesFieldAbstract.prototype.ngAfterViewInit = function () {
340
- };
341
- KlesFieldAbstract.prototype.applyPipeTransform = function () {
342
- if (this.group && this.field) {
343
- var control_1 = this.group.controls[this.field.name];
344
- if (control_1) {
345
- var val_1 = this.group.controls[this.field.name].value;
346
- if (this.field.pipeTransform) {
347
- this.field.pipeTransform.forEach(function (p) {
348
- var pipeVal = control_1.value;
349
- if (p.options) {
350
- p.options.forEach(function (opt) {
351
- pipeVal = p.pipe.transform(val_1, opt);
352
- });
353
- }
354
- else {
355
- pipeVal = p.pipe.transform(val_1);
356
- }
357
- control_1.patchValue(pipeVal, { onlySelf: true, emitEvent: false });
358
- });
359
- }
360
- }
361
- }
362
- };
363
- return KlesFieldAbstract;
330
+ var KlesFieldAbstract = /** @class */ (function () {
331
+ function KlesFieldAbstract() {
332
+ }
333
+ KlesFieldAbstract.prototype.ngOnInit = function () {
334
+ var _this = this;
335
+ var _a;
336
+ // this.applyPipeTransform();
337
+ if (this.field.valueChanges) {
338
+ this.field.valueChanges(this.field, this.group, this.siblingFields);
339
+ }
340
+ (_a = this.group.controls[this.field.name]) === null || _a === void 0 ? void 0 : _a.valueChanges.pipe().subscribe(function (val) {
341
+ if (_this.field.valueChanges) {
342
+ _this.field.valueChanges(_this.field, _this.group, _this.siblingFields, val);
343
+ }
344
+ // this.applyPipeTransform();
345
+ });
346
+ };
347
+ KlesFieldAbstract.prototype.ngAfterViewInit = function () {
348
+ };
349
+ KlesFieldAbstract.prototype.applyPipeTransform = function () {
350
+ if (this.group && this.field) {
351
+ var control_1 = this.group.controls[this.field.name];
352
+ if (control_1) {
353
+ var val_1 = this.group.controls[this.field.name].value;
354
+ if (this.field.pipeTransform) {
355
+ this.field.pipeTransform.forEach(function (p) {
356
+ var pipeVal = control_1.value;
357
+ if (p.options) {
358
+ p.options.forEach(function (opt) {
359
+ pipeVal = p.pipe.transform(val_1, opt);
360
+ });
361
+ }
362
+ else {
363
+ pipeVal = p.pipe.transform(val_1);
364
+ }
365
+ control_1.patchValue(pipeVal, { onlySelf: true, emitEvent: false });
366
+ });
367
+ }
368
+ }
369
+ }
370
+ };
371
+ return KlesFieldAbstract;
364
372
  }());
365
373
 
366
- var KlesFormLabelComponent = /** @class */ (function (_super) {
367
- __extends(KlesFormLabelComponent, _super);
368
- function KlesFormLabelComponent() {
369
- return _super !== null && _super.apply(this, arguments) || this;
370
- }
371
- KlesFormLabelComponent.prototype.ngOnInit = function () {
372
- this.group.controls[this.field.name].disable();
373
- _super.prototype.ngOnInit.call(this);
374
- };
375
- KlesFormLabelComponent = __decorate([
376
- Component({
377
- selector: "kles-form-label",
378
- template: "\n <div [formGroup]=\"group\" >\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" \n [ngClass]=\"field.ngClass\" \n [ngStyle]=\"{'color':'inherit'}\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\">\n </div>\n"
379
- })
380
- ], KlesFormLabelComponent);
381
- return KlesFormLabelComponent;
374
+ var KlesFormLabelComponent = /** @class */ (function (_super) {
375
+ __extends(KlesFormLabelComponent, _super);
376
+ function KlesFormLabelComponent() {
377
+ return _super !== null && _super.apply(this, arguments) || this;
378
+ }
379
+ KlesFormLabelComponent.prototype.ngOnInit = function () {
380
+ this.group.controls[this.field.name].disable();
381
+ _super.prototype.ngOnInit.call(this);
382
+ };
383
+ KlesFormLabelComponent = __decorate([
384
+ Component({
385
+ selector: "kles-form-label",
386
+ template: "\n <div [formGroup]=\"group\" >\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" \n [ngClass]=\"field.ngClass\" \n [ngStyle]=\"{'color':'inherit'}\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\">\n </div>\n"
387
+ })
388
+ ], KlesFormLabelComponent);
389
+ return KlesFormLabelComponent;
382
390
  }(KlesFieldAbstract));
383
391
 
384
- var KlesFormInputComponent = /** @class */ (function (_super) {
385
- __extends(KlesFormInputComponent, _super);
386
- function KlesFormInputComponent() {
387
- return _super !== null && _super.apply(this, arguments) || this;
388
- }
389
- KlesFormInputComponent.prototype.ngOnInit = function () {
390
- var _this = this;
391
- if (this.field.options instanceof Observable) {
392
- this.options$ = this.field.options;
393
- }
394
- else {
395
- this.options$ = of(this.field.options);
396
- }
397
- this.filteredOption = this.group.get(this.field.name).valueChanges
398
- .pipe(startWith(''),
399
- // map(data => data ? this.filterData(data) : this.field.options.slice())
400
- switchMap(function (data) { return data ? _this.filterData(data) : _this.options$; }));
401
- if (!this.field.maxLength) {
402
- this.field.maxLength = 524288; // Max default input W3C
403
- }
404
- _super.prototype.ngOnInit.call(this);
405
- };
406
- KlesFormInputComponent.prototype.isPending = function () {
407
- return (this.group.controls[this.field.name].pending || this.field.pending);
408
- };
409
- KlesFormInputComponent.prototype.filterData = function (value) {
410
- var _this = this;
411
- var filterValue;
412
- if (typeof value === 'string' && Object.prototype.toString.call(value) === '[object String]') {
413
- filterValue = value.toLowerCase();
414
- }
415
- else {
416
- filterValue = value[this.field.property].toLowerCase();
417
- }
418
- if (this.field.property) {
419
- return this.options$
420
- .pipe(map(function (options) { return options.filter(function (option) { return option[_this.field.property].toLowerCase().indexOf(filterValue) === 0; }); }));
421
- // return this.field.options
422
- // .filter(data => data[this.field.property].toLowerCase().indexOf(filterValue) === 0);
423
- }
424
- // return this.field.options.filter(data => data.toLowerCase().indexOf(filterValue) === 0);
425
- return this.options$.pipe(map(function (options) { return options.filter(function (option) { return option.toLowerCase().indexOf(filterValue) === 0; }); }));
426
- };
427
- KlesFormInputComponent.prototype.displayFn = function (value) {
428
- if (this.field.displayWith) {
429
- return this.field.displayWith(value);
430
- }
431
- else {
432
- if (value && this.field && this.field.property) {
433
- return value[this.field.property] ? value[this.field.property] : '';
434
- }
435
- return value ? value : '';
436
- }
437
- };
438
- KlesFormInputComponent = __decorate([
439
- Component({
440
- selector: 'kles-form-input',
441
- template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n\n <ng-container *ngIf=\"field.autocomplete; else notAutoComplete\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\" \n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\"\n [matAutocomplete]=\"auto\">\n\n <mat-autocomplete #auto=\"matAutocomplete\" [displayWith]=\"displayFn.bind(this)\" [panelWidth]=\"this.field.panelWidth\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n {{field.property ? option[field.property] : option}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"option\">\n </ng-container>\n </mat-option>\n </ng-container>\n </mat-autocomplete>\n </ng-container>\n\n <ng-template #notAutoComplete>\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\"\n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\">\n </ng-template>\n\n <mat-spinner matSuffix mode=\"indeterminate\" *ngIf=\"isPending()\" diameter=\"17\"></mat-spinner>\n\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
442
- styles: ['mat-form-field {width: calc(100%)}']
443
- })
444
- ], KlesFormInputComponent);
445
- return KlesFormInputComponent;
392
+ var KlesFormInputComponent = /** @class */ (function (_super) {
393
+ __extends(KlesFormInputComponent, _super);
394
+ function KlesFormInputComponent() {
395
+ return _super !== null && _super.apply(this, arguments) || this;
396
+ }
397
+ KlesFormInputComponent.prototype.ngOnInit = function () {
398
+ var _this = this;
399
+ if (this.field.options instanceof Observable) {
400
+ this.options$ = this.field.options;
401
+ }
402
+ else {
403
+ this.options$ = of(this.field.options);
404
+ }
405
+ this.filteredOption = this.group.get(this.field.name).valueChanges
406
+ .pipe(startWith(''),
407
+ // map(data => data ? this.filterData(data) : this.field.options.slice())
408
+ switchMap(function (data) { return data ? _this.filterData(data) : _this.options$; }));
409
+ if (!this.field.maxLength) {
410
+ this.field.maxLength = 524288; // Max default input W3C
411
+ }
412
+ _super.prototype.ngOnInit.call(this);
413
+ };
414
+ KlesFormInputComponent.prototype.isPending = function () {
415
+ return (this.group.controls[this.field.name].pending || this.field.pending);
416
+ };
417
+ KlesFormInputComponent.prototype.filterData = function (value) {
418
+ var _this = this;
419
+ var filterValue;
420
+ if (typeof value === 'string' && Object.prototype.toString.call(value) === '[object String]') {
421
+ filterValue = value.toLowerCase();
422
+ }
423
+ else {
424
+ filterValue = value[this.field.property].toLowerCase();
425
+ }
426
+ if (this.field.property) {
427
+ return this.options$
428
+ .pipe(map(function (options) { return options.filter(function (option) { return option[_this.field.property].toLowerCase().indexOf(filterValue) === 0; }); }));
429
+ // return this.field.options
430
+ // .filter(data => data[this.field.property].toLowerCase().indexOf(filterValue) === 0);
431
+ }
432
+ // return this.field.options.filter(data => data.toLowerCase().indexOf(filterValue) === 0);
433
+ return this.options$.pipe(map(function (options) { return options.filter(function (option) { return option.toLowerCase().indexOf(filterValue) === 0; }); }));
434
+ };
435
+ KlesFormInputComponent.prototype.displayFn = function (value) {
436
+ if (this.field.displayWith) {
437
+ return this.field.displayWith(value);
438
+ }
439
+ else {
440
+ if (value && this.field && this.field.property) {
441
+ return value[this.field.property] ? value[this.field.property] : '';
442
+ }
443
+ return value ? value : '';
444
+ }
445
+ };
446
+ KlesFormInputComponent = __decorate([
447
+ Component({
448
+ selector: 'kles-form-input',
449
+ template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n\n <ng-container *ngIf=\"field.autocomplete; else notAutoComplete\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\" \n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\"\n [matAutocomplete]=\"auto\">\n\n <mat-autocomplete #auto=\"matAutocomplete\" [displayWith]=\"displayFn.bind(this)\" [panelWidth]=\"this.field.panelWidth\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n {{field.property ? option[field.property] : option}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"option\" [field]=\"field\">\n </ng-container>\n </mat-option>\n </ng-container>\n </mat-autocomplete>\n </ng-container>\n\n <ng-template #notAutoComplete>\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\"\n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\">\n </ng-template>\n\n <mat-spinner matSuffix mode=\"indeterminate\" *ngIf=\"isPending()\" diameter=\"17\"></mat-spinner>\n\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
450
+ styles: ['mat-form-field {width: calc(100%)}']
451
+ })
452
+ ], KlesFormInputComponent);
453
+ return KlesFormInputComponent;
446
454
  }(KlesFieldAbstract));
447
455
 
448
- var KlesFormSubmitButtonComponent = /** @class */ (function (_super) {
449
- __extends(KlesFormSubmitButtonComponent, _super);
450
- function KlesFormSubmitButtonComponent() {
451
- return _super !== null && _super.apply(this, arguments) || this;
452
- }
453
- KlesFormSubmitButtonComponent.prototype.ngOnInit = function () {
454
- _super.prototype.ngOnInit.call(this);
455
- };
456
- KlesFormSubmitButtonComponent = __decorate([
457
- Component({
458
- selector: 'kles-submit-button',
459
- template: "\n <div [formGroup]=\"group\">\n <button matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" type=\"submit\" [disabled]=\"field.disabled\" mat-raised-button color=\"primary\">{{field.label}}</button>\n </div>\n "
460
- })
461
- ], KlesFormSubmitButtonComponent);
462
- return KlesFormSubmitButtonComponent;
456
+ var KlesFormSubmitButtonComponent = /** @class */ (function (_super) {
457
+ __extends(KlesFormSubmitButtonComponent, _super);
458
+ function KlesFormSubmitButtonComponent() {
459
+ return _super !== null && _super.apply(this, arguments) || this;
460
+ }
461
+ KlesFormSubmitButtonComponent.prototype.ngOnInit = function () {
462
+ _super.prototype.ngOnInit.call(this);
463
+ };
464
+ KlesFormSubmitButtonComponent = __decorate([
465
+ Component({
466
+ selector: 'kles-submit-button',
467
+ template: "\n <div [formGroup]=\"group\">\n <button matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" type=\"submit\" [disabled]=\"field.disabled\" mat-raised-button color=\"primary\">{{field.label}}</button>\n </div>\n "
468
+ })
469
+ ], KlesFormSubmitButtonComponent);
470
+ return KlesFormSubmitButtonComponent;
463
471
  }(KlesFieldAbstract));
464
472
 
465
- var KlesFormSelectComponent = /** @class */ (function (_super) {
466
- __extends(KlesFormSelectComponent, _super);
467
- function KlesFormSelectComponent() {
468
- return _super.call(this) || this;
469
- }
470
- KlesFormSelectComponent.prototype.ngOnInit = function () {
471
- _super.prototype.ngOnInit.call(this);
472
- if (!(this.field.options instanceof Observable)) {
473
- this.options$ = of(this.field.options);
474
- }
475
- else {
476
- this.options$ = this.field.options;
477
- }
478
- };
479
- KlesFormSelectComponent.prototype.openChange = function ($event) {
480
- if (this.field.virtualScroll) {
481
- if ($event) {
482
- this.cdkVirtualScrollViewport.scrollToIndex(0);
483
- this.cdkVirtualScrollViewport.checkViewportSize();
484
- }
485
- }
486
- };
487
- __decorate([
488
- ViewChild(CdkVirtualScrollViewport)
489
- ], KlesFormSelectComponent.prototype, "cdkVirtualScrollViewport", void 0);
490
- __decorate([
491
- ViewChildren(MatOption)
492
- ], KlesFormSelectComponent.prototype, "options", void 0);
493
- KlesFormSelectComponent = __decorate([
494
- Component({
495
- selector: 'kles-form-select',
496
- template: "\n <mat-form-field class=\"margin-top\" [formGroup]=\"group\">\n <mat-select matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\"\n (openedChange)=\"openChange($event)\"\n [ngClass]=\"field.ngClass\" [placeholder]=\"field.placeholder | translate\" [formControlName]=\"field.name\" [multiple]=\"field.multiple\">\n <mat-select-trigger *ngIf=\"field.triggerComponent\">\n <ng-container klesComponent [component]=\"field.triggerComponent\" [value]=\"group.controls[field.name].value\"></ng-container>\n </mat-select-trigger>\n\n\n <ng-container *ngIf=\"!field.virtualScroll\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of options$ | async\" [value]=\"item\">{{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}</mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of options$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"field.virtualScroll\">\n <cdk-virtual-scroll-viewport [itemSize]=\"field.itemSize || 50\" [style.height.px]=5*48>\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *cdkVirtualFor=\"let item of options$ | async\" [value]=\"item\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n\n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *cdkVirtualFor=\"let item of options$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n </ng-container>\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n\n </ng-container>\n\n </mat-select>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n",
497
- styles: ['mat-form-field {width: calc(100%)}']
498
- })
499
- ], KlesFormSelectComponent);
500
- return KlesFormSelectComponent;
473
+ var KlesFormSelectComponent = /** @class */ (function (_super) {
474
+ __extends(KlesFormSelectComponent, _super);
475
+ function KlesFormSelectComponent() {
476
+ var _this = _super.call(this) || this;
477
+ _this.compareFn = function (o1, o2) {
478
+ if (_this.field.property && o1 && o2) {
479
+ return o1[_this.field.property] === o2[_this.field.property];
480
+ }
481
+ return o1 === o2;
482
+ };
483
+ return _this;
484
+ }
485
+ KlesFormSelectComponent.prototype.ngOnInit = function () {
486
+ _super.prototype.ngOnInit.call(this);
487
+ if (!(this.field.options instanceof Observable)) {
488
+ this.options$ = of(this.field.options);
489
+ }
490
+ else {
491
+ this.options$ = this.field.options;
492
+ }
493
+ };
494
+ KlesFormSelectComponent.prototype.openChange = function ($event) {
495
+ if (this.field.virtualScroll) {
496
+ if ($event) {
497
+ this.cdkVirtualScrollViewport.scrollToIndex(0);
498
+ this.cdkVirtualScrollViewport.checkViewportSize();
499
+ }
500
+ }
501
+ };
502
+ __decorate([
503
+ ViewChild(CdkVirtualScrollViewport)
504
+ ], KlesFormSelectComponent.prototype, "cdkVirtualScrollViewport", void 0);
505
+ __decorate([
506
+ ViewChildren(MatOption)
507
+ ], KlesFormSelectComponent.prototype, "options", void 0);
508
+ KlesFormSelectComponent = __decorate([
509
+ Component({
510
+ selector: 'kles-form-select',
511
+ template: "\n <mat-form-field class=\"margin-top\" [formGroup]=\"group\">\n <mat-select matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\"\n (openedChange)=\"openChange($event)\" [compareWith]=\"compareFn\"\n [ngClass]=\"field.ngClass\" [placeholder]=\"field.placeholder | translate\" [formControlName]=\"field.name\" [multiple]=\"field.multiple\">\n <mat-select-trigger *ngIf=\"field.triggerComponent\">\n <ng-container klesComponent [component]=\"field.triggerComponent\" [value]=\"group.controls[field.name].value\" [field]=\"field\"></ng-container>\n </mat-select-trigger>\n\n\n <ng-container *ngIf=\"!field.virtualScroll\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of options$ | async\" [value]=\"item\">{{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}</mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of options$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"field.virtualScroll\">\n <cdk-virtual-scroll-viewport [itemSize]=\"field.itemSize || 50\" [style.height.px]=5*48>\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *cdkVirtualFor=\"let item of options$ | async\" [value]=\"item\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n\n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *cdkVirtualFor=\"let item of options$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n </ng-container>\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n\n </ng-container>\n\n </mat-select>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n",
512
+ styles: ['mat-form-field {width: calc(100%)}']
513
+ })
514
+ ], KlesFormSelectComponent);
515
+ return KlesFormSelectComponent;
501
516
  }(KlesFieldAbstract));
502
517
 
503
- var KlesFormDateComponent = /** @class */ (function (_super) {
504
- __extends(KlesFormDateComponent, _super);
505
- function KlesFormDateComponent() {
506
- return _super !== null && _super.apply(this, arguments) || this;
507
- }
508
- KlesFormDateComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
509
- KlesFormDateComponent = __decorate([
510
- Component({
511
- selector: "kles-form-datepicker",
512
- template: "\n <mat-form-field class=\"demo-full-width margin-top\" [formGroup]=\"group\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [matDatepicker]=\"picker\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-hint></mat-hint>\n \n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n "
513
- })
514
- ], KlesFormDateComponent);
515
- return KlesFormDateComponent;
518
+ var KlesFormDateComponent = /** @class */ (function (_super) {
519
+ __extends(KlesFormDateComponent, _super);
520
+ function KlesFormDateComponent() {
521
+ return _super !== null && _super.apply(this, arguments) || this;
522
+ }
523
+ KlesFormDateComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
524
+ KlesFormDateComponent = __decorate([
525
+ Component({
526
+ selector: "kles-form-datepicker",
527
+ template: "\n <mat-form-field class=\"demo-full-width margin-top\" [formGroup]=\"group\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [matDatepicker]=\"picker\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n <mat-hint></mat-hint>\n \n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n "
528
+ })
529
+ ], KlesFormDateComponent);
530
+ return KlesFormDateComponent;
516
531
  }(KlesFieldAbstract));
517
532
 
518
- var KlesFormRadioComponent = /** @class */ (function (_super) {
519
- __extends(KlesFormRadioComponent, _super);
520
- function KlesFormRadioComponent() {
521
- return _super !== null && _super.apply(this, arguments) || this;
522
- }
523
- KlesFormRadioComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
524
- KlesFormRadioComponent = __decorate([
525
- Component({
526
- selector: "kles-form-radiobutton",
527
- template: "\n <div [formGroup]=\"group\">\n <label class=\"radio-label-padding\">{{field.label}}</label>\n <mat-radio-group matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\">\n <mat-radio-button *ngFor=\"let item of field.options\" [value]=\"item\">{{item}}</mat-radio-button>\n </mat-radio-group>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </div>\n"
528
- })
529
- ], KlesFormRadioComponent);
530
- return KlesFormRadioComponent;
533
+ var KlesFormRadioComponent = /** @class */ (function (_super) {
534
+ __extends(KlesFormRadioComponent, _super);
535
+ function KlesFormRadioComponent() {
536
+ return _super !== null && _super.apply(this, arguments) || this;
537
+ }
538
+ KlesFormRadioComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
539
+ KlesFormRadioComponent = __decorate([
540
+ Component({
541
+ selector: "kles-form-radiobutton",
542
+ template: "\n <div [formGroup]=\"group\">\n <label class=\"radio-label-padding\">{{field.label}}</label>\n <mat-radio-group matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\">\n <mat-radio-button *ngFor=\"let item of field.options\" [value]=\"item\">{{item}}</mat-radio-button>\n </mat-radio-group>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </div>\n"
543
+ })
544
+ ], KlesFormRadioComponent);
545
+ return KlesFormRadioComponent;
531
546
  }(KlesFieldAbstract));
532
547
 
533
- var KlesFormCheckboxComponent = /** @class */ (function (_super) {
534
- __extends(KlesFormCheckboxComponent, _super);
535
- function KlesFormCheckboxComponent() {
536
- return _super !== null && _super.apply(this, arguments) || this;
537
- }
538
- KlesFormCheckboxComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
539
- KlesFormCheckboxComponent = __decorate([
540
- Component({
541
- selector: "kles-form-checkbox",
542
- template: "\n <div [formGroup]=\"group\" > \n <mat-checkbox matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [indeterminate]=\"field.indeterminate\" [formControlName]=\"field.name\">{{field.label | translate}}</mat-checkbox>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n </div>\n"
543
- })
544
- ], KlesFormCheckboxComponent);
545
- return KlesFormCheckboxComponent;
548
+ var KlesFormCheckboxComponent = /** @class */ (function (_super) {
549
+ __extends(KlesFormCheckboxComponent, _super);
550
+ function KlesFormCheckboxComponent() {
551
+ return _super !== null && _super.apply(this, arguments) || this;
552
+ }
553
+ KlesFormCheckboxComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
554
+ KlesFormCheckboxComponent = __decorate([
555
+ Component({
556
+ selector: "kles-form-checkbox",
557
+ template: "\n <div [formGroup]=\"group\" > \n <mat-checkbox matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [indeterminate]=\"field.indeterminate\" [formControlName]=\"field.name\">{{field.label | translate}}</mat-checkbox>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n </div>\n"
558
+ })
559
+ ], KlesFormCheckboxComponent);
560
+ return KlesFormCheckboxComponent;
546
561
  }(KlesFieldAbstract));
547
562
 
548
- var KlesFormListFieldComponent = /** @class */ (function (_super) {
549
- __extends(KlesFormListFieldComponent, _super);
550
- function KlesFormListFieldComponent(fb) {
551
- var _this = _super.call(this) || this;
552
- _this.fb = fb;
553
- return _this;
554
- }
555
- KlesFormListFieldComponent.prototype.ngOnInit = function () {
556
- this.formArray = this.group.controls[this.field.name];
557
- _super.prototype.ngOnInit.call(this);
558
- };
559
- KlesFormListFieldComponent.prototype.createFormGroup = function () {
560
- var _this = this;
561
- var group = this.fb.group({});
562
- this.field.collections.forEach(function (item) {
563
- var control = _this.fb.control(null, _this.bindValidations(item.validations || []), _this.bindAsyncValidations(item.asyncValidations || []));
564
- group.addControl(item.name, control);
565
- });
566
- return group;
567
- };
568
- KlesFormListFieldComponent.prototype.deleteField = function (index) {
569
- this.formArray.removeAt(index);
570
- };
571
- KlesFormListFieldComponent.prototype.addField = function () {
572
- this.formArray.push(this.createFormGroup());
573
- };
574
- KlesFormListFieldComponent.prototype.bindValidations = function (validations) {
575
- if (validations.length > 0) {
576
- var validList_1 = [];
577
- validations.forEach(function (valid) {
578
- validList_1.push(valid.validator);
579
- });
580
- return Validators.compose(validList_1);
581
- }
582
- return null;
583
- };
584
- KlesFormListFieldComponent.prototype.bindAsyncValidations = function (validations) {
585
- if (validations.length > 0) {
586
- var validList_2 = [];
587
- validations.forEach(function (valid) {
588
- validList_2.push(valid.validator);
589
- });
590
- return Validators.composeAsync(validList_2);
591
- }
592
- return null;
593
- };
594
- KlesFormListFieldComponent.ctorParameters = function () { return [
595
- { type: FormBuilder }
596
- ]; };
597
- KlesFormListFieldComponent = __decorate([
598
- Component({
599
- selector: 'kles-form-listfield',
600
- template: "\n <div [formGroup]=\"group\" class=\"form-element\">\n {{field.label | translate}}\n <button mat-icon-button color=\"primary\" (click)=\"addField()\">\n <mat-icon>add</mat-icon>\n </button>\n\n <div class=\"dynamic-form\" [formGroupName]=\"field.name\">\n <div *ngFor=\"let subGroup of formArray.controls let index = index;\" fxLayout=\"row\" fxLayoutGap=\"5px\">\n <ng-container *ngFor=\"let subfield of field.collections;\"\n dynamicField [field]=\"subfield\" [group]=\"subGroup\">\n </ng-container>\n <button mat-icon-button (click)=\"deleteField(index)\" color=\"primary\">\n <mat-icon>delete_outlined</mat-icon>\n </button>\n </div>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </div>\n </div>\n "
601
- })
602
- ], KlesFormListFieldComponent);
603
- return KlesFormListFieldComponent;
563
+ var KlesFormListFieldComponent = /** @class */ (function (_super) {
564
+ __extends(KlesFormListFieldComponent, _super);
565
+ function KlesFormListFieldComponent(fb) {
566
+ var _this = _super.call(this) || this;
567
+ _this.fb = fb;
568
+ return _this;
569
+ }
570
+ KlesFormListFieldComponent.prototype.ngOnInit = function () {
571
+ this.formArray = this.group.controls[this.field.name];
572
+ _super.prototype.ngOnInit.call(this);
573
+ };
574
+ KlesFormListFieldComponent.prototype.createFormGroup = function () {
575
+ var _this = this;
576
+ var group = this.fb.group({});
577
+ this.field.collections.forEach(function (item) {
578
+ var control = _this.fb.control(null, _this.bindValidations(item.validations || []), _this.bindAsyncValidations(item.asyncValidations || []));
579
+ group.addControl(item.name, control);
580
+ });
581
+ return group;
582
+ };
583
+ KlesFormListFieldComponent.prototype.deleteField = function (index) {
584
+ this.formArray.removeAt(index);
585
+ };
586
+ KlesFormListFieldComponent.prototype.addField = function () {
587
+ this.formArray.push(this.createFormGroup());
588
+ };
589
+ KlesFormListFieldComponent.prototype.bindValidations = function (validations) {
590
+ if (validations.length > 0) {
591
+ var validList_1 = [];
592
+ validations.forEach(function (valid) {
593
+ validList_1.push(valid.validator);
594
+ });
595
+ return Validators.compose(validList_1);
596
+ }
597
+ return null;
598
+ };
599
+ KlesFormListFieldComponent.prototype.bindAsyncValidations = function (validations) {
600
+ if (validations.length > 0) {
601
+ var validList_2 = [];
602
+ validations.forEach(function (valid) {
603
+ validList_2.push(valid.validator);
604
+ });
605
+ return Validators.composeAsync(validList_2);
606
+ }
607
+ return null;
608
+ };
609
+ KlesFormListFieldComponent.ctorParameters = function () { return [
610
+ { type: FormBuilder }
611
+ ]; };
612
+ KlesFormListFieldComponent = __decorate([
613
+ Component({
614
+ selector: 'kles-form-listfield',
615
+ template: "\n <div [formGroup]=\"group\" class=\"form-element\">\n {{field.label | translate}}\n <button mat-icon-button color=\"primary\" (click)=\"addField()\">\n <mat-icon>add</mat-icon>\n </button>\n\n <div class=\"dynamic-form\" [formGroupName]=\"field.name\">\n <div *ngFor=\"let subGroup of formArray.controls let index = index;\" fxLayout=\"row\" fxLayoutGap=\"5px\">\n <ng-container *ngFor=\"let subfield of field.collections;\"\n dynamicField [field]=\"subfield\" [group]=\"subGroup\">\n </ng-container>\n <button mat-icon-button (click)=\"deleteField(index)\" color=\"primary\">\n <mat-icon>delete_outlined</mat-icon>\n </button>\n </div>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </div>\n </div>\n "
616
+ })
617
+ ], KlesFormListFieldComponent);
618
+ return KlesFormListFieldComponent;
604
619
  }(KlesFieldAbstract));
605
620
 
606
- var KlesFormColorComponent = /** @class */ (function (_super) {
607
- __extends(KlesFormColorComponent, _super);
608
- function KlesFormColorComponent() {
609
- return _super !== null && _super.apply(this, arguments) || this;
610
- }
611
- KlesFormColorComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
612
- KlesFormColorComponent.prototype.invertColor = function (hex, bw) {
613
- if (hex.indexOf('#') === 0) {
614
- hex = hex.slice(1);
615
- }
616
- // convert 3-digit hex to 6-digits.
617
- if (hex.length === 3) {
618
- hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
619
- }
620
- if (hex.length !== 6) {
621
- return '#000000';
622
- }
623
- var r = parseInt(hex.slice(0, 2), 16);
624
- var g = parseInt(hex.slice(2, 4), 16);
625
- var b = parseInt(hex.slice(4, 6), 16);
626
- if (bw) {
627
- return (r * 0.299 + g * 0.587 + b * 0.114) > 186
628
- ? '#000000'
629
- : '#FFFFFF';
630
- }
631
- // invert color components
632
- var r1 = (255 - r).toString(16);
633
- var g1 = (255 - g).toString(16);
634
- var b1 = (255 - b).toString(16);
635
- // pad each with zeros and return
636
- return "#" + r1 + g1 + b1;
637
- };
638
- KlesFormColorComponent = __decorate([
639
- Component({
640
- selector: 'kles-form-color',
641
- template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [placeholder]=\"field.placeholder | translate\"\n [colorPicker]=\"group.get(field.name).value\"\n [value]=\"group.get(field.name).value\"\n (colorPickerChange)=\"group.get(field.name).setValue($event)\"\n class=\"colorPicker\"\n [style.background]=\"group.get(field.name).value\"\n [style.color]=\"invertColor(group.get(field.name).value,true)\"\n [formControlName]=\"field.name\">\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
642
- styles: ['mat-form-field {width: calc(100%)}']
643
- })
644
- ], KlesFormColorComponent);
645
- return KlesFormColorComponent;
621
+ var KlesFormColorComponent = /** @class */ (function (_super) {
622
+ __extends(KlesFormColorComponent, _super);
623
+ function KlesFormColorComponent() {
624
+ return _super !== null && _super.apply(this, arguments) || this;
625
+ }
626
+ KlesFormColorComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
627
+ KlesFormColorComponent.prototype.invertColor = function (hex, bw) {
628
+ if (hex.indexOf('#') === 0) {
629
+ hex = hex.slice(1);
630
+ }
631
+ // convert 3-digit hex to 6-digits.
632
+ if (hex.length === 3) {
633
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
634
+ }
635
+ if (hex.length !== 6) {
636
+ return '#000000';
637
+ }
638
+ var r = parseInt(hex.slice(0, 2), 16);
639
+ var g = parseInt(hex.slice(2, 4), 16);
640
+ var b = parseInt(hex.slice(4, 6), 16);
641
+ if (bw) {
642
+ return (r * 0.299 + g * 0.587 + b * 0.114) > 186
643
+ ? '#000000'
644
+ : '#FFFFFF';
645
+ }
646
+ // invert color components
647
+ var r1 = (255 - r).toString(16);
648
+ var g1 = (255 - g).toString(16);
649
+ var b1 = (255 - b).toString(16);
650
+ // pad each with zeros and return
651
+ return "#" + r1 + g1 + b1;
652
+ };
653
+ KlesFormColorComponent = __decorate([
654
+ Component({
655
+ selector: 'kles-form-color',
656
+ template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [placeholder]=\"field.placeholder | translate\"\n [colorPicker]=\"group.get(field.name).value\"\n [value]=\"group.get(field.name).value\"\n (colorPickerChange)=\"group.get(field.name).setValue($event)\"\n class=\"colorPicker\"\n [style.background]=\"group.get(field.name).value\"\n [style.color]=\"invertColor(group.get(field.name).value,true)\"\n [formControlName]=\"field.name\">\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
657
+ styles: ['mat-form-field {width: calc(100%)}']
658
+ })
659
+ ], KlesFormColorComponent);
660
+ return KlesFormColorComponent;
646
661
  }(KlesFieldAbstract));
647
662
 
648
- var KlesFormChipComponent = /** @class */ (function (_super) {
649
- __extends(KlesFormChipComponent, _super);
650
- function KlesFormChipComponent() {
651
- return _super !== null && _super.apply(this, arguments) || this;
652
- }
653
- KlesFormChipComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
654
- KlesFormChipComponent = __decorate([
655
- Component({
656
- selector: "kles-form-chip",
657
- template: "\n <div [formGroup]=\"group\"> \n <mat-chip-list>\n <mat-chip [color]=\"field.color\" matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" selected [ngClass]=\"field.ngClass\" [ngStyle]=\"field.ngStyle\">\n <mat-icon *ngIf=\"field.icon\">{{field.icon}}</mat-icon>\n {{group.controls[field.name].value | klesTransform:field.pipeTransform}}\n </mat-chip>\n </mat-chip-list>\n </div>\n"
658
- })
659
- ], KlesFormChipComponent);
660
- return KlesFormChipComponent;
663
+ var KlesFormChipComponent = /** @class */ (function (_super) {
664
+ __extends(KlesFormChipComponent, _super);
665
+ function KlesFormChipComponent() {
666
+ return _super !== null && _super.apply(this, arguments) || this;
667
+ }
668
+ KlesFormChipComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
669
+ KlesFormChipComponent = __decorate([
670
+ Component({
671
+ selector: "kles-form-chip",
672
+ template: "\n <div [formGroup]=\"group\"> \n <mat-chip-list>\n <mat-chip [color]=\"field.color\" matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" selected [ngClass]=\"field.ngClass\" [ngStyle]=\"field.ngStyle\">\n <mat-icon *ngIf=\"field.icon\">{{field.icon}}</mat-icon>\n {{group.controls[field.name].value | klesTransform:field.pipeTransform}}\n </mat-chip>\n </mat-chip-list>\n </div>\n"
673
+ })
674
+ ], KlesFormChipComponent);
675
+ return KlesFormChipComponent;
661
676
  }(KlesFieldAbstract));
662
677
 
663
- var KlesFormGroupComponent = /** @class */ (function (_super) {
664
- __extends(KlesFormGroupComponent, _super);
665
- function KlesFormGroupComponent() {
666
- return _super !== null && _super.apply(this, arguments) || this;
667
- }
668
- KlesFormGroupComponent.prototype.ngOnInit = function () {
669
- this.subGroup = this.group.controls[this.field.name];
670
- _super.prototype.ngOnInit.call(this);
671
- };
672
- KlesFormGroupComponent = __decorate([
673
- Component({
674
- selector: 'kles-group',
675
- template: "\n <div [formGroup]=\"group\" class=\"group-container\">\n <div [formGroupName]=\"field.name\" class=\"group-container\" [style.flex-direction]=\"field.direction || 'inherit'\" [ngClass]=\"field.ngClass\" >\n <ng-container *ngFor=\"let subfield of field.collections;\" klesDynamicField [field]=\"subfield\" [group]=\"subGroup\">\n </ng-container>\n </div>\n </div>\n",
676
- styles: ['mat-form-field {width: calc(100%)}',
677
- ':host { display:flex; flex-direction: inherit}',
678
- '.group-container {display:flex; flex-direction: inherit}']
679
- })
680
- ], KlesFormGroupComponent);
681
- return KlesFormGroupComponent;
678
+ var KlesFormGroupComponent = /** @class */ (function (_super) {
679
+ __extends(KlesFormGroupComponent, _super);
680
+ function KlesFormGroupComponent() {
681
+ return _super !== null && _super.apply(this, arguments) || this;
682
+ }
683
+ KlesFormGroupComponent.prototype.ngOnInit = function () {
684
+ this.subGroup = this.group.controls[this.field.name];
685
+ _super.prototype.ngOnInit.call(this);
686
+ };
687
+ KlesFormGroupComponent = __decorate([
688
+ Component({
689
+ selector: 'kles-group',
690
+ template: "\n <div [formGroup]=\"group\" class=\"group-container\">\n <div [formGroupName]=\"field.name\" class=\"group-container\" [style.flex-direction]=\"field.direction || 'inherit'\" [ngClass]=\"field.ngClass\" >\n <ng-container *ngFor=\"let subfield of field.collections;\" klesDynamicField [field]=\"subfield\" [group]=\"subGroup\">\n </ng-container>\n </div>\n </div>\n",
691
+ styles: ['mat-form-field {width: calc(100%)}',
692
+ ':host { display:flex; flex-direction: inherit}',
693
+ '.group-container {display:flex; flex-direction: inherit}']
694
+ })
695
+ ], KlesFormGroupComponent);
696
+ return KlesFormGroupComponent;
682
697
  }(KlesFieldAbstract));
683
698
 
684
- var KlesFormIconComponent = /** @class */ (function (_super) {
685
- __extends(KlesFormIconComponent, _super);
686
- function KlesFormIconComponent() {
687
- return _super !== null && _super.apply(this, arguments) || this;
688
- }
689
- KlesFormIconComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
690
- KlesFormIconComponent = __decorate([
691
- Component({
692
- selector: "kles-form-icon",
693
- template: "\n <mat-icon [color]=\"field.color\" matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [ngStyle]=\"field.ngStyle\">\n {{group.controls[field.name].value}}\n </mat-icon>\n"
694
- })
695
- ], KlesFormIconComponent);
696
- return KlesFormIconComponent;
699
+ var KlesFormIconComponent = /** @class */ (function (_super) {
700
+ __extends(KlesFormIconComponent, _super);
701
+ function KlesFormIconComponent() {
702
+ return _super !== null && _super.apply(this, arguments) || this;
703
+ }
704
+ KlesFormIconComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
705
+ KlesFormIconComponent = __decorate([
706
+ Component({
707
+ selector: "kles-form-icon",
708
+ template: "\n <mat-icon [color]=\"field.color\" matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [ngStyle]=\"field.ngStyle\">\n {{group.controls[field.name].value}}\n </mat-icon>\n"
709
+ })
710
+ ], KlesFormIconComponent);
711
+ return KlesFormIconComponent;
697
712
  }(KlesFieldAbstract));
698
713
 
699
- var KlesFormSelectSearchComponent = /** @class */ (function (_super) {
700
- __extends(KlesFormSelectSearchComponent, _super);
701
- function KlesFormSelectSearchComponent() {
702
- var _this = _super !== null && _super.apply(this, arguments) || this;
703
- _this.searchControl = new FormControl();
704
- _this.selectAllControl = new FormControl(false);
705
- _this.optionsFiltered$ = new ReplaySubject(1);
706
- _this._onDestroy = new Subject();
707
- return _this;
708
- }
709
- KlesFormSelectSearchComponent.prototype.ngOnInit = function () {
710
- var _this = this;
711
- _super.prototype.ngOnInit.call(this);
712
- if (!(this.field.options instanceof Observable)) {
713
- this.options$ = of(this.field.options);
714
- }
715
- else {
716
- this.options$ = this.field.options;
717
- }
718
- this.searchControl.valueChanges.pipe(startWith(this.searchControl.value), takeUntil(this._onDestroy), switchMap(function (value) {
719
- if (value) {
720
- var search_1 = value.toLowerCase();
721
- return _this.options$.pipe(map(function (options) {
722
- return options
723
- .filter(function (option) {
724
- if (_this.field.searchKeys && _this.field.searchKeys.length) {
725
- return _this.field.searchKeys.some(function (searchKey) {
726
- if (option[searchKey]) {
727
- return option[searchKey].toString().toLowerCase().indexOf(search_1) > -1;
728
- }
729
- return false;
730
- }) || (_this.field.property ?
731
- option[_this.field.property].toString().toLowerCase().indexOf(search_1) > -1 : false);
732
- }
733
- else {
734
- if (_this.field.property) {
735
- return option[_this.field.property].toString().toLowerCase().indexOf(search_1) > -1;
736
- }
737
- }
738
- return option.toString().toLowerCase().indexOf(search_1) > -1;
739
- });
740
- }));
741
- }
742
- else {
743
- return _this.options$;
744
- }
745
- })).subscribe(this.optionsFiltered$);
746
- this.group.controls[this.field.name]
747
- .valueChanges.pipe(takeUntil(this._onDestroy), startWith(this.group.controls[this.field.name].value), switchMap(function (selected) {
748
- return _this.optionsFiltered$.pipe(map(function (options) {
749
- if (!selected) {
750
- return false;
751
- }
752
- if (options.length < selected.length) {
753
- return options.length > 0 && options.every(function (o) { return selected.includes(o); });
754
- }
755
- else {
756
- return options.length > 0 && options.length === selected.length && selected.every(function (s) { return options.includes(s); });
757
- }
758
- }));
759
- })).subscribe(function (isChecked) {
760
- _this.selectAllControl.setValue(isChecked);
761
- });
762
- };
763
- KlesFormSelectSearchComponent.prototype.ngOnDestroy = function () {
764
- this._onDestroy.next();
765
- };
766
- KlesFormSelectSearchComponent.prototype.toggleAllSelection = function (state) {
767
- var _this = this;
768
- if (state.checked) {
769
- this.optionsFiltered$.pipe(take(1)).subscribe(function (options) {
770
- if (options.length > 0) {
771
- _this.group.controls[_this.field.name].patchValue(options.slice());
772
- }
773
- });
774
- }
775
- else {
776
- this.group.controls[this.field.name].patchValue([]);
777
- }
778
- };
779
- KlesFormSelectSearchComponent.prototype.openChange = function ($event) {
780
- if (this.field.virtualScroll) {
781
- if ($event) {
782
- this.cdkVirtualScrollViewport.scrollToIndex(0);
783
- this.cdkVirtualScrollViewport.checkViewportSize();
784
- }
785
- }
786
- };
787
- __decorate([
788
- ViewChild(CdkVirtualScrollViewport)
789
- ], KlesFormSelectSearchComponent.prototype, "cdkVirtualScrollViewport", void 0);
790
- __decorate([
791
- ViewChildren(MatOption)
792
- ], KlesFormSelectSearchComponent.prototype, "options", void 0);
793
- KlesFormSelectSearchComponent = __decorate([
794
- Component({
795
- selector: 'kles-form-select-search',
796
- template: "\n <mat-form-field class=\"margin-top\" [formGroup]=\"group\">\n <mat-select matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\"\n (openedChange)=\"openChange($event)\" \n [placeholder]=\"field.placeholder | translate\" [formControlName]=\"field.name\" [multiple]=\"field.multiple\">\n <mat-select-trigger *ngIf=\"field.triggerComponent\">\n <ng-container klesComponent [component]=\"field.triggerComponent\" [value]=\"group.controls[field.name].value\"></ng-container>\n </mat-select-trigger>\n\n <ng-container *ngIf=\"field.virtualScroll\">\n <mat-option>\n <ngx-mat-select-search [formControl]=\"searchControl\"\n placeholderLabel=\"\" noEntriesFoundLabel =\"\"></ngx-mat-select-search>\n </mat-option>\n \n <cdk-virtual-scroll-viewport [itemSize]=\"field.itemSize || 50\" [style.height.px]=4*48>\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-checkbox *ngIf=\"field.multiple\" class=\"selectAll\" [formControl]=\"selectAllControl\"\n (change)=\"toggleAllSelection($event)\">\n {{'selectAll' | translate}}\n </mat-checkbox>\n <mat-option *cdkVirtualFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">{{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}</mat-option>\n \n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *cdkVirtualFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n\n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n\n </ng-container>\n\n <ng-container *ngIf=\"!field.virtualScroll\">\n \n <mat-option>\n <ngx-mat-select-search [formControl]=\"searchControl\"\n placeholderLabel=\"\" noEntriesFoundLabel =\"\"></ngx-mat-select-search>\n </mat-option>\n \n <mat-checkbox *ngIf=\"field.multiple\" class=\"selectAll\" [formControl]=\"selectAllControl\"\n (change)=\"toggleAllSelection($event)\">\n {{'selectAll' | translate}}\n </mat-checkbox>\n\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">{{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}</mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n\n\n </mat-select>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n",
797
- styles: ['mat-form-field {width: calc(100%)}', '.selectAll {padding: 10px 16px;}']
798
- })
799
- ], KlesFormSelectSearchComponent);
800
- return KlesFormSelectSearchComponent;
714
+ var KlesFormSelectSearchComponent = /** @class */ (function (_super) {
715
+ __extends(KlesFormSelectSearchComponent, _super);
716
+ function KlesFormSelectSearchComponent() {
717
+ var _this = _super !== null && _super.apply(this, arguments) || this;
718
+ _this.searchControl = new FormControl();
719
+ _this.selectAllControl = new FormControl(false);
720
+ _this.optionsFiltered$ = new ReplaySubject(1);
721
+ _this._onDestroy = new Subject();
722
+ _this.compareFn = function (o1, o2) {
723
+ if (_this.field.property && o1 && o2) {
724
+ return o1[_this.field.property] === o2[_this.field.property];
725
+ }
726
+ return o1 === o2;
727
+ };
728
+ return _this;
729
+ }
730
+ KlesFormSelectSearchComponent.prototype.ngOnInit = function () {
731
+ var _this = this;
732
+ _super.prototype.ngOnInit.call(this);
733
+ if (!(this.field.options instanceof Observable)) {
734
+ this.options$ = of(this.field.options);
735
+ }
736
+ else {
737
+ this.options$ = this.field.options;
738
+ }
739
+ this.searchControl.valueChanges.pipe(startWith(this.searchControl.value), takeUntil(this._onDestroy), switchMap(function (value) {
740
+ if (value) {
741
+ var search_1 = value.toLowerCase();
742
+ return _this.options$.pipe(map(function (options) {
743
+ return options
744
+ .filter(function (option) {
745
+ if (_this.field.searchKeys && _this.field.searchKeys.length) {
746
+ return _this.field.searchKeys.some(function (searchKey) {
747
+ if (option[searchKey]) {
748
+ return option[searchKey].toString().toLowerCase().indexOf(search_1) > -1;
749
+ }
750
+ return false;
751
+ }) || (_this.field.property ?
752
+ option[_this.field.property].toString().toLowerCase().indexOf(search_1) > -1 : false);
753
+ }
754
+ else {
755
+ if (_this.field.property) {
756
+ return option[_this.field.property].toString().toLowerCase().indexOf(search_1) > -1;
757
+ }
758
+ }
759
+ return option.toString().toLowerCase().indexOf(search_1) > -1;
760
+ });
761
+ }));
762
+ }
763
+ else {
764
+ return _this.options$;
765
+ }
766
+ })).subscribe(this.optionsFiltered$);
767
+ this.group.controls[this.field.name]
768
+ .valueChanges.pipe(takeUntil(this._onDestroy), startWith(this.group.controls[this.field.name].value), switchMap(function (selected) {
769
+ return _this.optionsFiltered$.pipe(map(function (options) {
770
+ if (!selected) {
771
+ return false;
772
+ }
773
+ if (options.length < selected.length) {
774
+ return options.length > 0 && options.every(function (o) { return selected.includes(o); });
775
+ }
776
+ else {
777
+ return options.length > 0 && options.length === selected.length && selected.every(function (s) { return options.includes(s); });
778
+ }
779
+ }));
780
+ })).subscribe(function (isChecked) {
781
+ _this.selectAllControl.setValue(isChecked);
782
+ });
783
+ };
784
+ KlesFormSelectSearchComponent.prototype.ngOnDestroy = function () {
785
+ this._onDestroy.next();
786
+ };
787
+ KlesFormSelectSearchComponent.prototype.toggleAllSelection = function (state) {
788
+ var _this = this;
789
+ if (state.checked) {
790
+ this.optionsFiltered$.pipe(take(1)).subscribe(function (options) {
791
+ if (options.length > 0) {
792
+ _this.group.controls[_this.field.name].patchValue(options.slice());
793
+ }
794
+ });
795
+ }
796
+ else {
797
+ this.group.controls[this.field.name].patchValue([]);
798
+ }
799
+ };
800
+ KlesFormSelectSearchComponent.prototype.openChange = function ($event) {
801
+ if (this.field.virtualScroll) {
802
+ if ($event) {
803
+ this.cdkVirtualScrollViewport.scrollToIndex(0);
804
+ this.cdkVirtualScrollViewport.checkViewportSize();
805
+ }
806
+ }
807
+ };
808
+ __decorate([
809
+ ViewChild(CdkVirtualScrollViewport)
810
+ ], KlesFormSelectSearchComponent.prototype, "cdkVirtualScrollViewport", void 0);
811
+ __decorate([
812
+ ViewChildren(MatOption)
813
+ ], KlesFormSelectSearchComponent.prototype, "options", void 0);
814
+ KlesFormSelectSearchComponent = __decorate([
815
+ Component({
816
+ selector: 'kles-form-select-search',
817
+ template: "\n <mat-form-field class=\"margin-top\" [formGroup]=\"group\">\n <mat-select matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\"\n (openedChange)=\"openChange($event)\" [compareWith]=\"compareFn\"\n [placeholder]=\"field.placeholder | translate\" [formControlName]=\"field.name\" [multiple]=\"field.multiple\">\n <mat-select-trigger *ngIf=\"field.triggerComponent\">\n <ng-container klesComponent [component]=\"field.triggerComponent\" [value]=\"group.controls[field.name].value\" [field]=\"field\"></ng-container>\n </mat-select-trigger>\n\n <ng-container *ngIf=\"field.virtualScroll\">\n <mat-option>\n <ngx-mat-select-search [formControl]=\"searchControl\"\n placeholderLabel=\"\" noEntriesFoundLabel =\"\"></ngx-mat-select-search>\n </mat-option>\n \n <cdk-virtual-scroll-viewport [itemSize]=\"field.itemSize || 50\" [style.height.px]=4*48>\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-checkbox *ngIf=\"field.multiple\" class=\"selectAll\" [formControl]=\"selectAllControl\"\n (change)=\"toggleAllSelection($event)\">\n {{'selectAll' | translate}}\n </mat-checkbox>\n <mat-option *cdkVirtualFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">{{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}</mat-option>\n \n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-option>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *cdkVirtualFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n\n <ng-container *ngIf=\"field.multiple\">\n <mat-option *ngFor=\"let item of group.controls[field.name].value | slice:0:30\" [value]=\"item\"\n style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"!field.multiple && group.controls[field.name].value\">\n <mat-option *ngFor=\"let item of [group?.controls[field.name]?.value]\" [value]=\"item\" style=\"display:none\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n\n </ng-container>\n\n <ng-container *ngIf=\"!field.virtualScroll\">\n \n <mat-option>\n <ngx-mat-select-search [formControl]=\"searchControl\"\n placeholderLabel=\"\" noEntriesFoundLabel =\"\"></ngx-mat-select-search>\n </mat-option>\n \n <mat-checkbox *ngIf=\"field.multiple\" class=\"selectAll\" [formControl]=\"selectAllControl\"\n (change)=\"toggleAllSelection($event)\">\n {{'selectAll' | translate}}\n </mat-checkbox>\n\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">{{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}</mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let item of optionsFiltered$ | async\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-option>\n </ng-container>\n </ng-container>\n\n\n </mat-select>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n",
818
+ styles: ['mat-form-field {width: calc(100%)}', '.selectAll {padding: 10px 16px;}']
819
+ })
820
+ ], KlesFormSelectSearchComponent);
821
+ return KlesFormSelectSearchComponent;
801
822
  }(KlesFieldAbstract));
802
823
 
803
- var KlesFormLineBreakComponent = /** @class */ (function (_super) {
804
- __extends(KlesFormLineBreakComponent, _super);
805
- function KlesFormLineBreakComponent() {
806
- return _super !== null && _super.apply(this, arguments) || this;
807
- }
808
- KlesFormLineBreakComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
809
- KlesFormLineBreakComponent = __decorate([
810
- Component({
811
- selector: "kles-form-line-break",
812
- template: "",
813
- styles: [":host{\n flex-basis: 100%;\n display: flex;\n height:0;\n }"]
814
- })
815
- ], KlesFormLineBreakComponent);
816
- return KlesFormLineBreakComponent;
824
+ var KlesFormLineBreakComponent = /** @class */ (function (_super) {
825
+ __extends(KlesFormLineBreakComponent, _super);
826
+ function KlesFormLineBreakComponent() {
827
+ return _super !== null && _super.apply(this, arguments) || this;
828
+ }
829
+ KlesFormLineBreakComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
830
+ KlesFormLineBreakComponent = __decorate([
831
+ Component({
832
+ selector: "kles-form-line-break",
833
+ template: "",
834
+ styles: [":host{\n flex-basis: 100%;\n display: flex;\n height:0;\n }"]
835
+ })
836
+ ], KlesFormLineBreakComponent);
837
+ return KlesFormLineBreakComponent;
817
838
  }(KlesFieldAbstract));
818
839
 
819
- var KlesFormLinkComponent = /** @class */ (function (_super) {
820
- __extends(KlesFormLinkComponent, _super);
821
- function KlesFormLinkComponent() {
822
- return _super !== null && _super.apply(this, arguments) || this;
823
- }
824
- KlesFormLinkComponent.prototype.ngOnInit = function () {
825
- _super.prototype.ngOnInit.call(this);
826
- };
827
- KlesFormLinkComponent = __decorate([
828
- Component({
829
- selector: 'kles-form-link',
830
- template: "\n <a [href]=\"group.controls[field.name].value\" matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\">\n {{field.label}}\n </a>\n"
831
- })
832
- ], KlesFormLinkComponent);
833
- return KlesFormLinkComponent;
840
+ var KlesFormLinkComponent = /** @class */ (function (_super) {
841
+ __extends(KlesFormLinkComponent, _super);
842
+ function KlesFormLinkComponent() {
843
+ return _super !== null && _super.apply(this, arguments) || this;
844
+ }
845
+ KlesFormLinkComponent.prototype.ngOnInit = function () {
846
+ _super.prototype.ngOnInit.call(this);
847
+ };
848
+ KlesFormLinkComponent = __decorate([
849
+ Component({
850
+ selector: 'kles-form-link',
851
+ template: "\n <a [href]=\"group.controls[field.name].value\" matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\">\n {{field.label}}\n </a>\n"
852
+ })
853
+ ], KlesFormLinkComponent);
854
+ return KlesFormLinkComponent;
834
855
  }(KlesFieldAbstract));
835
856
 
836
- var KlesFormSelectionListComponent = /** @class */ (function (_super) {
837
- __extends(KlesFormSelectionListComponent, _super);
838
- function KlesFormSelectionListComponent() {
839
- return _super !== null && _super.apply(this, arguments) || this;
840
- }
841
- KlesFormSelectionListComponent.prototype.ngOnInit = function () {
842
- _super.prototype.ngOnInit.call(this);
843
- if (!(this.field.options instanceof Observable)) {
844
- this.options$ = of(this.field.options);
845
- }
846
- else {
847
- this.options$ = this.field.options;
848
- }
849
- };
850
- KlesFormSelectionListComponent = __decorate([
851
- Component({
852
- selector: 'kles-form-selection-list',
853
- template: "\n <div class=\"margin-top\" [formGroup]=\"group\">\n <mat-selection-list [formControlName]=\"field.name\" [attr.id]=\"field.id\" [multiple]=\"field.multiple\" [ngClass]=\"field.ngClass\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-list-option [value]=\"item\" *ngFor=\"let item of options$ | async;\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-list-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-list-option *ngFor=\"let item of options$ | async;\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\"></ng-container>\n </mat-list-option>\n </ng-container>\n </mat-selection-list>\n\n </div>\n",
854
- styles: ['mat-selection-list {width: calc(100%);height: 250px; overflow:auto}']
855
- })
856
- ], KlesFormSelectionListComponent);
857
- return KlesFormSelectionListComponent;
857
+ var KlesFormSelectionListComponent = /** @class */ (function (_super) {
858
+ __extends(KlesFormSelectionListComponent, _super);
859
+ function KlesFormSelectionListComponent() {
860
+ return _super !== null && _super.apply(this, arguments) || this;
861
+ }
862
+ KlesFormSelectionListComponent.prototype.ngOnInit = function () {
863
+ _super.prototype.ngOnInit.call(this);
864
+ if (!(this.field.options instanceof Observable)) {
865
+ this.options$ = of(this.field.options);
866
+ }
867
+ else {
868
+ this.options$ = this.field.options;
869
+ }
870
+ };
871
+ KlesFormSelectionListComponent = __decorate([
872
+ Component({
873
+ selector: 'kles-form-selection-list',
874
+ template: "\n <div class=\"margin-top\" [formGroup]=\"group\">\n <mat-selection-list [formControlName]=\"field.name\" [attr.id]=\"field.id\" [multiple]=\"field.multiple\" [ngClass]=\"field.ngClass\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-list-option [value]=\"item\" *ngFor=\"let item of options$ | async;\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-list-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-list-option *ngFor=\"let item of options$ | async;\" [value]=\"item\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"item\" [field]=\"field\"></ng-container>\n </mat-list-option>\n </ng-container>\n </mat-selection-list>\n </div>\n",
875
+ styles: ['mat-selection-list {width: calc(100%);height: 250px; overflow:auto}']
876
+ })
877
+ ], KlesFormSelectionListComponent);
878
+ return KlesFormSelectionListComponent;
858
879
  }(KlesFieldAbstract));
859
880
 
860
- var KlesFormButtonToogleGroupComponent = /** @class */ (function (_super) {
861
- __extends(KlesFormButtonToogleGroupComponent, _super);
862
- function KlesFormButtonToogleGroupComponent() {
863
- return _super !== null && _super.apply(this, arguments) || this;
864
- }
865
- KlesFormButtonToogleGroupComponent.prototype.ngOnInit = function () {
866
- _super.prototype.ngOnInit.call(this);
867
- if (!(this.field.options instanceof Observable)) {
868
- this.options$ = of(this.field.options);
869
- }
870
- else {
871
- this.options$ = this.field.options;
872
- }
873
- };
874
- KlesFormButtonToogleGroupComponent = __decorate([
875
- Component({
876
- selector: 'kles-form-button-toogle-group',
877
- template: "\n <div [formGroup]=\"group\" class=\"form-element\">\n <mat-button-toggle-group [formControlName]=\"field.name\" [multiple]=\"field.multiple\"\n [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\">\n <mat-button-toggle *ngFor=\"let item of options$ | async\" [value]=\"item\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-button-toggle>\n </mat-button-toggle-group>\n </div>\n"
878
- })
879
- ], KlesFormButtonToogleGroupComponent);
880
- return KlesFormButtonToogleGroupComponent;
881
- }(KlesFieldAbstract));
882
- // <mat-button-toggle-group [formControlName]="field.name">
883
- // <mat-button-toggle value="bold">Bold</mat-button-toggle>
884
- // <mat-button-toggle value="italic">Italic</mat-button-toggle>
885
- // <mat-button-toggle value="underline">Underline</mat-button-toggle>
881
+ var KlesFormButtonToogleGroupComponent = /** @class */ (function (_super) {
882
+ __extends(KlesFormButtonToogleGroupComponent, _super);
883
+ function KlesFormButtonToogleGroupComponent() {
884
+ return _super !== null && _super.apply(this, arguments) || this;
885
+ }
886
+ KlesFormButtonToogleGroupComponent.prototype.ngOnInit = function () {
887
+ _super.prototype.ngOnInit.call(this);
888
+ if (!(this.field.options instanceof Observable)) {
889
+ this.options$ = of(this.field.options);
890
+ }
891
+ else {
892
+ this.options$ = this.field.options;
893
+ }
894
+ };
895
+ KlesFormButtonToogleGroupComponent = __decorate([
896
+ Component({
897
+ selector: 'kles-form-button-toogle-group',
898
+ template: "\n <div [formGroup]=\"group\" class=\"form-element\">\n <mat-button-toggle-group [formControlName]=\"field.name\" [multiple]=\"field.multiple\"\n [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\">\n <mat-button-toggle *ngFor=\"let item of options$ | async\" [value]=\"item\">\n {{(field.property ? item[field.property] : item) | klesTransform:field.pipeTransform}}\n </mat-button-toggle>\n </mat-button-toggle-group>\n </div>\n"
899
+ })
900
+ ], KlesFormButtonToogleGroupComponent);
901
+ return KlesFormButtonToogleGroupComponent;
902
+ }(KlesFieldAbstract));
903
+ // <mat-button-toggle-group [formControlName]="field.name">
904
+ // <mat-button-toggle value="bold">Bold</mat-button-toggle>
905
+ // <mat-button-toggle value="italic">Italic</mat-button-toggle>
906
+ // <mat-button-toggle value="underline">Underline</mat-button-toggle>
886
907
  // </mat-button-toggle-group>
887
908
 
888
- var componentMapper = {
889
- label: KlesFormLabelComponent,
890
- input: KlesFormInputComponent,
891
- button: KlesFormSubmitButtonComponent,
892
- select: KlesFormSelectComponent,
893
- date: KlesFormDateComponent,
894
- radio: KlesFormRadioComponent,
895
- checkbox: KlesFormCheckboxComponent,
896
- listField: KlesFormListFieldComponent,
897
- color: KlesFormColorComponent,
898
- chip: KlesFormChipComponent,
899
- group: KlesFormGroupComponent,
900
- icon: KlesFormIconComponent,
901
- selectSearch: KlesFormSelectSearchComponent,
902
- lineBreak: KlesFormLineBreakComponent,
903
- link: KlesFormLinkComponent,
904
- selectionList: KlesFormSelectionListComponent,
905
- buttonToogleGroup: KlesFormButtonToogleGroupComponent
906
- };
907
- var KlesDynamicFieldDirective = /** @class */ (function () {
908
- function KlesDynamicFieldDirective(resolver, container) {
909
- this.resolver = resolver;
910
- this.container = container;
911
- }
912
- KlesDynamicFieldDirective.prototype.ngOnDestroy = function () {
913
- if (this.componentRef)
914
- this.componentRef.destroy();
915
- };
916
- KlesDynamicFieldDirective.prototype.ngOnInit = function () {
917
- this.buildComponent();
918
- };
919
- KlesDynamicFieldDirective.prototype.ngOnChanges = function (changes) {
920
- if (changes.group) {
921
- this.group = changes.group.currentValue;
922
- }
923
- if (changes.field) {
924
- if (changes.field.previousValue && changes.field.currentValue.component !== changes.field.previousValue.component) {
925
- this.field = changes.field.currentValue;
926
- this.buildComponent();
927
- }
928
- else {
929
- this.field = changes.field.currentValue;
930
- }
931
- }
932
- };
933
- KlesDynamicFieldDirective.prototype.buildComponent = function () {
934
- var factory = this.resolver.resolveComponentFactory(this.field.component || componentMapper[this.field.type]);
935
- if (this.componentRef)
936
- this.componentRef.destroy();
937
- this.componentRef = this.container.createComponent(factory);
938
- this.componentRef.instance.field = this.field;
939
- this.componentRef.instance.group = this.group;
940
- this.componentRef.instance.siblingFields = this.siblingFields;
941
- };
942
- KlesDynamicFieldDirective.ctorParameters = function () { return [
943
- { type: ComponentFactoryResolver },
944
- { type: ViewContainerRef }
945
- ]; };
946
- __decorate([
947
- Input()
948
- ], KlesDynamicFieldDirective.prototype, "field", void 0);
949
- __decorate([
950
- Input()
951
- ], KlesDynamicFieldDirective.prototype, "group", void 0);
952
- __decorate([
953
- Input()
954
- ], KlesDynamicFieldDirective.prototype, "siblingFields", void 0);
955
- KlesDynamicFieldDirective = __decorate([
956
- Directive({
957
- selector: '[klesDynamicField]'
958
- })
959
- ], KlesDynamicFieldDirective);
960
- return KlesDynamicFieldDirective;
909
+ var componentMapper = {
910
+ label: KlesFormLabelComponent,
911
+ input: KlesFormInputComponent,
912
+ button: KlesFormSubmitButtonComponent,
913
+ select: KlesFormSelectComponent,
914
+ date: KlesFormDateComponent,
915
+ radio: KlesFormRadioComponent,
916
+ checkbox: KlesFormCheckboxComponent,
917
+ listField: KlesFormListFieldComponent,
918
+ color: KlesFormColorComponent,
919
+ chip: KlesFormChipComponent,
920
+ group: KlesFormGroupComponent,
921
+ icon: KlesFormIconComponent,
922
+ selectSearch: KlesFormSelectSearchComponent,
923
+ lineBreak: KlesFormLineBreakComponent,
924
+ link: KlesFormLinkComponent,
925
+ selectionList: KlesFormSelectionListComponent,
926
+ buttonToogleGroup: KlesFormButtonToogleGroupComponent
927
+ };
928
+ var KlesDynamicFieldDirective = /** @class */ (function () {
929
+ function KlesDynamicFieldDirective(resolver, container) {
930
+ this.resolver = resolver;
931
+ this.container = container;
932
+ }
933
+ KlesDynamicFieldDirective.prototype.ngOnDestroy = function () {
934
+ if (this.componentRef)
935
+ this.componentRef.destroy();
936
+ };
937
+ KlesDynamicFieldDirective.prototype.ngOnInit = function () {
938
+ this.buildComponent();
939
+ };
940
+ KlesDynamicFieldDirective.prototype.ngOnChanges = function (changes) {
941
+ if (changes.group) {
942
+ this.group = changes.group.currentValue;
943
+ }
944
+ if (changes.field) {
945
+ if (changes.field.previousValue && changes.field.currentValue.component !== changes.field.previousValue.component) {
946
+ this.field = changes.field.currentValue;
947
+ this.buildComponent();
948
+ }
949
+ else {
950
+ this.field = changes.field.currentValue;
951
+ }
952
+ }
953
+ };
954
+ KlesDynamicFieldDirective.prototype.buildComponent = function () {
955
+ var factory = this.resolver.resolveComponentFactory(this.field.component || componentMapper[this.field.type]);
956
+ if (this.componentRef)
957
+ this.componentRef.destroy();
958
+ this.componentRef = this.container.createComponent(factory);
959
+ this.componentRef.instance.field = this.field;
960
+ this.componentRef.instance.group = this.group;
961
+ this.componentRef.instance.siblingFields = this.siblingFields;
962
+ };
963
+ KlesDynamicFieldDirective.ctorParameters = function () { return [
964
+ { type: ComponentFactoryResolver },
965
+ { type: ViewContainerRef }
966
+ ]; };
967
+ __decorate([
968
+ Input()
969
+ ], KlesDynamicFieldDirective.prototype, "field", void 0);
970
+ __decorate([
971
+ Input()
972
+ ], KlesDynamicFieldDirective.prototype, "group", void 0);
973
+ __decorate([
974
+ Input()
975
+ ], KlesDynamicFieldDirective.prototype, "siblingFields", void 0);
976
+ KlesDynamicFieldDirective = __decorate([
977
+ Directive({
978
+ selector: '[klesDynamicField]'
979
+ })
980
+ ], KlesDynamicFieldDirective);
981
+ return KlesDynamicFieldDirective;
961
982
  }());
962
983
 
963
- var KlesFormErrorStateMatcher = /** @class */ (function () {
964
- function KlesFormErrorStateMatcher() {
965
- }
966
- KlesFormErrorStateMatcher.prototype.isErrorState = function (control, form) {
967
- var isSubmitted = form && form.submitted;
968
- return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
969
- };
970
- return KlesFormErrorStateMatcher;
984
+ var KlesFormErrorStateMatcher = /** @class */ (function () {
985
+ function KlesFormErrorStateMatcher() {
986
+ }
987
+ KlesFormErrorStateMatcher.prototype.isErrorState = function (control, form) {
988
+ var isSubmitted = form && form.submitted;
989
+ return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
990
+ };
991
+ return KlesFormErrorStateMatcher;
971
992
  }());
972
993
 
973
- var MaterialModule = /** @class */ (function () {
974
- function MaterialModule() {
975
- }
976
- MaterialModule = __decorate([
977
- NgModule({
978
- imports: [
979
- CommonModule,
980
- MatSliderModule,
981
- MatButtonModule,
982
- MatToolbarModule,
983
- MatIconModule,
984
- MatSidenavModule,
985
- MatBadgeModule,
986
- MatListModule,
987
- MatGridListModule,
988
- MatFormFieldModule,
989
- MatInputModule,
990
- MatSelectModule,
991
- MatRadioModule,
992
- MatDatepickerModule,
993
- MatChipsModule,
994
- MatTooltipModule,
995
- MatTableModule,
996
- MatPaginatorModule,
997
- MatCardModule,
998
- MatMenuModule,
999
- MatTabsModule,
1000
- CdkTableModule,
1001
- MatProgressSpinnerModule,
1002
- MatCheckboxModule,
1003
- MatDialogModule,
1004
- MatAutocompleteModule,
1005
- MatProgressBarModule,
1006
- MatSortModule,
1007
- MatExpansionModule,
1008
- MatNativeDateModule,
1009
- MatSnackBarModule,
1010
- MatTreeModule,
1011
- MatSliderModule,
1012
- MatButtonModule,
1013
- MatSlideToggleModule,
1014
- ColorPickerModule,
1015
- MatButtonToggleModule
1016
- ],
1017
- exports: [
1018
- MatButtonModule,
1019
- MatToolbarModule,
1020
- MatIconModule,
1021
- MatSidenavModule,
1022
- MatBadgeModule,
1023
- MatListModule,
1024
- MatGridListModule,
1025
- MatInputModule,
1026
- MatFormFieldModule,
1027
- MatSelectModule,
1028
- MatRadioModule,
1029
- MatDatepickerModule,
1030
- MatChipsModule,
1031
- MatTooltipModule,
1032
- MatTableModule,
1033
- MatPaginatorModule,
1034
- MatCardModule,
1035
- MatMenuModule,
1036
- MatTabsModule,
1037
- CdkTableModule,
1038
- MatProgressSpinnerModule,
1039
- MatCheckboxModule,
1040
- MatDialogModule,
1041
- MatAutocompleteModule,
1042
- MatProgressBarModule,
1043
- MatSortModule,
1044
- MatExpansionModule,
1045
- MatNativeDateModule,
1046
- MatSnackBarModule,
1047
- MatTreeModule,
1048
- MatSliderModule,
1049
- MatButtonModule,
1050
- MatSlideToggleModule,
1051
- ColorPickerModule,
1052
- ScrollingModule,
1053
- CdkScrollable,
1054
- MatButtonToggleModule
1055
- ],
1056
- providers: [
1057
- MatDatepickerModule,
1058
- MatDialogModule
1059
- ]
1060
- })
1061
- ], MaterialModule);
1062
- return MaterialModule;
994
+ var MaterialModule = /** @class */ (function () {
995
+ function MaterialModule() {
996
+ }
997
+ MaterialModule = __decorate([
998
+ NgModule({
999
+ imports: [
1000
+ CommonModule,
1001
+ MatSliderModule,
1002
+ MatButtonModule,
1003
+ MatToolbarModule,
1004
+ MatIconModule,
1005
+ MatSidenavModule,
1006
+ MatBadgeModule,
1007
+ MatListModule,
1008
+ MatGridListModule,
1009
+ MatFormFieldModule,
1010
+ MatInputModule,
1011
+ MatSelectModule,
1012
+ MatRadioModule,
1013
+ MatDatepickerModule,
1014
+ MatChipsModule,
1015
+ MatTooltipModule,
1016
+ MatTableModule,
1017
+ MatPaginatorModule,
1018
+ MatCardModule,
1019
+ MatMenuModule,
1020
+ MatTabsModule,
1021
+ CdkTableModule,
1022
+ MatProgressSpinnerModule,
1023
+ MatCheckboxModule,
1024
+ MatDialogModule,
1025
+ MatAutocompleteModule,
1026
+ MatProgressBarModule,
1027
+ MatSortModule,
1028
+ MatExpansionModule,
1029
+ MatNativeDateModule,
1030
+ MatSnackBarModule,
1031
+ MatTreeModule,
1032
+ MatSliderModule,
1033
+ MatButtonModule,
1034
+ MatSlideToggleModule,
1035
+ ColorPickerModule,
1036
+ MatButtonToggleModule
1037
+ ],
1038
+ exports: [
1039
+ MatButtonModule,
1040
+ MatToolbarModule,
1041
+ MatIconModule,
1042
+ MatSidenavModule,
1043
+ MatBadgeModule,
1044
+ MatListModule,
1045
+ MatGridListModule,
1046
+ MatInputModule,
1047
+ MatFormFieldModule,
1048
+ MatSelectModule,
1049
+ MatRadioModule,
1050
+ MatDatepickerModule,
1051
+ MatChipsModule,
1052
+ MatTooltipModule,
1053
+ MatTableModule,
1054
+ MatPaginatorModule,
1055
+ MatCardModule,
1056
+ MatMenuModule,
1057
+ MatTabsModule,
1058
+ CdkTableModule,
1059
+ MatProgressSpinnerModule,
1060
+ MatCheckboxModule,
1061
+ MatDialogModule,
1062
+ MatAutocompleteModule,
1063
+ MatProgressBarModule,
1064
+ MatSortModule,
1065
+ MatExpansionModule,
1066
+ MatNativeDateModule,
1067
+ MatSnackBarModule,
1068
+ MatTreeModule,
1069
+ MatSliderModule,
1070
+ MatButtonModule,
1071
+ MatSlideToggleModule,
1072
+ ColorPickerModule,
1073
+ ScrollingModule,
1074
+ CdkScrollable,
1075
+ MatButtonToggleModule
1076
+ ],
1077
+ providers: [
1078
+ MatDatepickerModule,
1079
+ MatDialogModule
1080
+ ]
1081
+ })
1082
+ ], MaterialModule);
1083
+ return MaterialModule;
1063
1084
  }());
1064
1085
 
1065
- var KlesButtonComponent = /** @class */ (function () {
1066
- function KlesButtonComponent() {
1067
- this.name = '';
1068
- this.label = '';
1069
- this.color = 'accent';
1070
- this.icon = '';
1071
- this.iconSvg = '';
1072
- this.disabled = false;
1073
- this.classButton = '';
1074
- this.value = {};
1075
- this.onChange = function () { };
1076
- this.onTouched = function () { };
1077
- }
1078
- KlesButtonComponent_1 = KlesButtonComponent;
1079
- KlesButtonComponent.prototype.ngOnInit = function () {
1080
- };
1081
- KlesButtonComponent.prototype.click = function (event) {
1082
- this.value.event = this.name;
1083
- this.onChange(this.value);
1084
- };
1085
- KlesButtonComponent.prototype.writeValue = function (value) {
1086
- if (!value) {
1087
- value = { event: this.name };
1088
- }
1089
- if (!value.event) {
1090
- value.event = this.name;
1091
- }
1092
- if (value.uiButton) {
1093
- var uiButton = value.uiButton;
1094
- this.label = (uiButton.label) ? uiButton.label : this.label;
1095
- this.color = (uiButton.color) ? uiButton.color : this.color;
1096
- this.icon = (uiButton.icon) ? uiButton.icon : this.icon;
1097
- this.iconSvg = (uiButton.iconSvg) ? uiButton.iconSvg : this.iconSvg;
1098
- this.disabled = (uiButton.disabled) ? uiButton.disabled : this.disabled;
1099
- this.classButton = (uiButton.class) ? uiButton.class : this.classButton;
1100
- }
1101
- this.value = value;
1102
- };
1103
- KlesButtonComponent.prototype.registerOnChange = function (fn) {
1104
- this.onChange = fn;
1105
- };
1106
- KlesButtonComponent.prototype.registerOnTouched = function (fn) {
1107
- this.onTouched = fn;
1108
- };
1109
- KlesButtonComponent.prototype.setDisabledState = function (isDisabled) {
1110
- this.disabled = isDisabled;
1111
- };
1112
- var KlesButtonComponent_1;
1113
- __decorate([
1114
- Input()
1115
- ], KlesButtonComponent.prototype, "name", void 0);
1116
- __decorate([
1117
- Input()
1118
- ], KlesButtonComponent.prototype, "label", void 0);
1119
- __decorate([
1120
- Input()
1121
- ], KlesButtonComponent.prototype, "color", void 0);
1122
- __decorate([
1123
- Input()
1124
- ], KlesButtonComponent.prototype, "icon", void 0);
1125
- __decorate([
1126
- Input()
1127
- ], KlesButtonComponent.prototype, "iconSvg", void 0);
1128
- __decorate([
1129
- Input()
1130
- ], KlesButtonComponent.prototype, "disabled", void 0);
1131
- __decorate([
1132
- Input()
1133
- ], KlesButtonComponent.prototype, "classButton", void 0);
1134
- __decorate([
1135
- Input()
1136
- ], KlesButtonComponent.prototype, "value", void 0);
1137
- __decorate([
1138
- Input()
1139
- ], KlesButtonComponent.prototype, "tooltip", void 0);
1140
- KlesButtonComponent = KlesButtonComponent_1 = __decorate([
1141
- Component({
1142
- selector: 'kles-button',
1143
- template: "\n <span>\n <button mat-button [ngClass]=\"classButton\" [color]=\"(color)?color:'primary'\" [disabled]=\"disabled\"\n (click)=\"click($event)\" [matTooltip]=\"tooltip\">\n {{label | translate}}\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n <mat-icon svgIcon=\"{{iconSvg}}\" *ngIf=\"iconSvg\"></mat-icon>\n </button>\n </span>\n ",
1144
- providers: [
1145
- {
1146
- provide: NG_VALUE_ACCESSOR,
1147
- useExisting: forwardRef(function () { return KlesButtonComponent_1; }),
1148
- multi: true
1149
- }
1150
- ]
1151
- })
1152
- ], KlesButtonComponent);
1153
- return KlesButtonComponent;
1086
+ var KlesButtonComponent = /** @class */ (function () {
1087
+ function KlesButtonComponent() {
1088
+ this.name = '';
1089
+ this.label = '';
1090
+ this.color = 'accent';
1091
+ this.icon = '';
1092
+ this.iconSvg = '';
1093
+ this.disabled = false;
1094
+ this.classButton = '';
1095
+ this.value = {};
1096
+ this.onChange = function () { };
1097
+ this.onTouched = function () { };
1098
+ }
1099
+ KlesButtonComponent_1 = KlesButtonComponent;
1100
+ KlesButtonComponent.prototype.ngOnInit = function () {
1101
+ };
1102
+ KlesButtonComponent.prototype.click = function (event) {
1103
+ this.value.event = this.name;
1104
+ this.onChange(this.value);
1105
+ };
1106
+ KlesButtonComponent.prototype.writeValue = function (value) {
1107
+ if (!value) {
1108
+ value = { event: this.name };
1109
+ }
1110
+ if (!value.event) {
1111
+ value.event = this.name;
1112
+ }
1113
+ if (value.uiButton) {
1114
+ var uiButton = value.uiButton;
1115
+ this.label = (uiButton.label) ? uiButton.label : this.label;
1116
+ this.color = (uiButton.color) ? uiButton.color : this.color;
1117
+ this.icon = (uiButton.icon) ? uiButton.icon : this.icon;
1118
+ this.iconSvg = (uiButton.iconSvg) ? uiButton.iconSvg : this.iconSvg;
1119
+ this.disabled = (uiButton.disabled) ? uiButton.disabled : this.disabled;
1120
+ this.classButton = (uiButton.class) ? uiButton.class : this.classButton;
1121
+ }
1122
+ this.value = value;
1123
+ };
1124
+ KlesButtonComponent.prototype.registerOnChange = function (fn) {
1125
+ this.onChange = fn;
1126
+ };
1127
+ KlesButtonComponent.prototype.registerOnTouched = function (fn) {
1128
+ this.onTouched = fn;
1129
+ };
1130
+ KlesButtonComponent.prototype.setDisabledState = function (isDisabled) {
1131
+ this.disabled = isDisabled;
1132
+ };
1133
+ var KlesButtonComponent_1;
1134
+ __decorate([
1135
+ Input()
1136
+ ], KlesButtonComponent.prototype, "name", void 0);
1137
+ __decorate([
1138
+ Input()
1139
+ ], KlesButtonComponent.prototype, "label", void 0);
1140
+ __decorate([
1141
+ Input()
1142
+ ], KlesButtonComponent.prototype, "color", void 0);
1143
+ __decorate([
1144
+ Input()
1145
+ ], KlesButtonComponent.prototype, "icon", void 0);
1146
+ __decorate([
1147
+ Input()
1148
+ ], KlesButtonComponent.prototype, "iconSvg", void 0);
1149
+ __decorate([
1150
+ Input()
1151
+ ], KlesButtonComponent.prototype, "disabled", void 0);
1152
+ __decorate([
1153
+ Input()
1154
+ ], KlesButtonComponent.prototype, "classButton", void 0);
1155
+ __decorate([
1156
+ Input()
1157
+ ], KlesButtonComponent.prototype, "value", void 0);
1158
+ __decorate([
1159
+ Input()
1160
+ ], KlesButtonComponent.prototype, "tooltip", void 0);
1161
+ KlesButtonComponent = KlesButtonComponent_1 = __decorate([
1162
+ Component({
1163
+ selector: 'kles-button',
1164
+ template: "\n <span>\n <button mat-button [ngClass]=\"classButton\" [color]=\"(color)?color:'primary'\" [disabled]=\"disabled\"\n (click)=\"click($event)\" [matTooltip]=\"tooltip\">\n {{label | translate}}\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n <mat-icon svgIcon=\"{{iconSvg}}\" *ngIf=\"iconSvg\"></mat-icon>\n </button>\n </span>\n ",
1165
+ providers: [
1166
+ {
1167
+ provide: NG_VALUE_ACCESSOR,
1168
+ useExisting: forwardRef(function () { return KlesButtonComponent_1; }),
1169
+ multi: true
1170
+ }
1171
+ ]
1172
+ })
1173
+ ], KlesButtonComponent);
1174
+ return KlesButtonComponent;
1154
1175
  }());
1155
1176
 
1156
- var KlesFormButtonComponent = /** @class */ (function (_super) {
1157
- __extends(KlesFormButtonComponent, _super);
1158
- function KlesFormButtonComponent() {
1159
- return _super !== null && _super.apply(this, arguments) || this;
1160
- }
1161
- KlesFormButtonComponent.prototype.ngOnInit = function () {
1162
- _super.prototype.ngOnInit.call(this);
1163
- };
1164
- KlesFormButtonComponent = __decorate([
1165
- Component({
1166
- selector: 'kles-form-button',
1167
- template: "\n <div [formGroup]=\"group\">\n <kles-button \n [attr.id]=\"field.id\" [classButton]=\"field.ngClass\" \n [name]=\"field.name\" [label]=\"field.label\" [color]=\"field.color\" \n [icon]=\"field.icon\"\n [iconSvg]=\"field.iconSvg\"\n [value]=\"field.value\"\n [formControlName]=\"field.name\"\n [tooltip]=\"field.tooltip\">\n </kles-button>\n </div>\n "
1168
- })
1169
- ], KlesFormButtonComponent);
1170
- return KlesFormButtonComponent;
1177
+ var KlesFormButtonComponent = /** @class */ (function (_super) {
1178
+ __extends(KlesFormButtonComponent, _super);
1179
+ function KlesFormButtonComponent() {
1180
+ return _super !== null && _super.apply(this, arguments) || this;
1181
+ }
1182
+ KlesFormButtonComponent.prototype.ngOnInit = function () {
1183
+ _super.prototype.ngOnInit.call(this);
1184
+ };
1185
+ KlesFormButtonComponent = __decorate([
1186
+ Component({
1187
+ selector: 'kles-form-button',
1188
+ template: "\n <div [formGroup]=\"group\">\n <kles-button \n [attr.id]=\"field.id\" [classButton]=\"field.ngClass\" \n [name]=\"field.name\" [label]=\"field.label\" [color]=\"field.color\" \n [icon]=\"field.icon\"\n [iconSvg]=\"field.iconSvg\"\n [value]=\"field.value\"\n [formControlName]=\"field.name\"\n [tooltip]=\"field.tooltip\">\n </kles-button>\n </div>\n "
1189
+ })
1190
+ ], KlesFormButtonComponent);
1191
+ return KlesFormButtonComponent;
1171
1192
  }(KlesFieldAbstract));
1172
1193
 
1173
- var KlesButtonCheckerComponent = /** @class */ (function (_super) {
1174
- __extends(KlesButtonCheckerComponent, _super);
1175
- function KlesButtonCheckerComponent() {
1176
- var _this = _super !== null && _super.apply(this, arguments) || this;
1177
- _this.value = {
1178
- busy: false,
1179
- error: [],
1180
- event: false
1181
- };
1182
- return _this;
1183
- }
1184
- KlesButtonCheckerComponent_1 = KlesButtonCheckerComponent;
1185
- KlesButtonCheckerComponent.prototype.countError = function () {
1186
- return (this.value.error) ? this.value.error.length : 0;
1187
- };
1188
- var KlesButtonCheckerComponent_1;
1189
- KlesButtonCheckerComponent = KlesButtonCheckerComponent_1 = __decorate([
1190
- Component({
1191
- selector: 'kles-button-checker',
1192
- template: "\n <span *ngIf=\"value.error && !value.busy\">\n <kles-button \n [classButton]=\"classButton\" \n [name]=\"name\" [label]=\"label\" [color]=\"color\" \n [icon]=\"icon\" [iconSvg]=\"iconSvg\"\n [value]=\"value\" \n [tooltip]=\"tooltip\"\n [disabled]=\"disabled\"\n matBadge=\"{{countError()}}\" (click)=\"click($event)\">\n </kles-button>\n </span>\n <span style=\"text-align: center;\">\n <span style=\"text-align: center;margin-right: 10px\" *ngIf=\"value.busy||false\">\n <mat-spinner [diameter]=\"25\"></mat-spinner>\n </span>\n <span *ngIf=\"value.message\" style=\"margin-right: 10px\">\n {{value.message|translate}}\n </span>\n </span>\n ",
1193
- providers: [
1194
- {
1195
- provide: NG_VALUE_ACCESSOR,
1196
- useExisting: forwardRef(function () { return KlesButtonCheckerComponent_1; }),
1197
- multi: true
1198
- }
1199
- ]
1200
- })
1201
- ], KlesButtonCheckerComponent);
1202
- return KlesButtonCheckerComponent;
1194
+ var KlesButtonCheckerComponent = /** @class */ (function (_super) {
1195
+ __extends(KlesButtonCheckerComponent, _super);
1196
+ function KlesButtonCheckerComponent() {
1197
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1198
+ _this.value = {
1199
+ busy: false,
1200
+ error: [],
1201
+ event: false
1202
+ };
1203
+ return _this;
1204
+ }
1205
+ KlesButtonCheckerComponent_1 = KlesButtonCheckerComponent;
1206
+ KlesButtonCheckerComponent.prototype.countError = function () {
1207
+ return (this.value.error) ? this.value.error.length : 0;
1208
+ };
1209
+ var KlesButtonCheckerComponent_1;
1210
+ KlesButtonCheckerComponent = KlesButtonCheckerComponent_1 = __decorate([
1211
+ Component({
1212
+ selector: 'kles-button-checker',
1213
+ template: "\n <span *ngIf=\"value.error && !value.busy\">\n <kles-button \n [classButton]=\"classButton\" \n [name]=\"name\" [label]=\"label\" [color]=\"color\" \n [icon]=\"icon\" [iconSvg]=\"iconSvg\"\n [value]=\"value\" \n [tooltip]=\"tooltip\"\n [disabled]=\"disabled\"\n matBadge=\"{{countError()}}\" (click)=\"click($event)\">\n </kles-button>\n </span>\n <span style=\"text-align: center;\">\n <span style=\"text-align: center;margin-right: 10px\" *ngIf=\"value.busy||false\">\n <mat-spinner [diameter]=\"25\"></mat-spinner>\n </span>\n <span *ngIf=\"value.message\" style=\"margin-right: 10px\">\n {{value.message|translate}}\n </span>\n </span>\n ",
1214
+ providers: [
1215
+ {
1216
+ provide: NG_VALUE_ACCESSOR,
1217
+ useExisting: forwardRef(function () { return KlesButtonCheckerComponent_1; }),
1218
+ multi: true
1219
+ }
1220
+ ]
1221
+ })
1222
+ ], KlesButtonCheckerComponent);
1223
+ return KlesButtonCheckerComponent;
1203
1224
  }(KlesButtonComponent));
1204
1225
 
1205
- var KlesFormButtonCheckerComponent = /** @class */ (function (_super) {
1206
- __extends(KlesFormButtonCheckerComponent, _super);
1207
- function KlesFormButtonCheckerComponent() {
1208
- return _super !== null && _super.apply(this, arguments) || this;
1209
- }
1210
- KlesFormButtonCheckerComponent.prototype.ngOnInit = function () {
1211
- _super.prototype.ngOnInit.call(this);
1212
- };
1213
- KlesFormButtonCheckerComponent = __decorate([
1214
- Component({
1215
- selector: 'kles-form-button-checker',
1216
- template: "\n <div [formGroup]=\"group\">\n <kles-button-checker\n [attr.id]=\"field.id\" [classButton]=\"field.ngClass\" \n [name]=\"field.name\" [label]=\"field.label\" [color]=\"field.color\" \n [icon]=\"field.icon\"\n [iconSvg]=\"field.iconSvg\"\n [value]=\"field.value\"\n [formControlName]=\"field.name\"\n [tooltip]=\"field.tooltip\">\n </kles-button-checker>\n </div>\n "
1217
- })
1218
- ], KlesFormButtonCheckerComponent);
1219
- return KlesFormButtonCheckerComponent;
1226
+ var KlesFormButtonCheckerComponent = /** @class */ (function (_super) {
1227
+ __extends(KlesFormButtonCheckerComponent, _super);
1228
+ function KlesFormButtonCheckerComponent() {
1229
+ return _super !== null && _super.apply(this, arguments) || this;
1230
+ }
1231
+ KlesFormButtonCheckerComponent.prototype.ngOnInit = function () {
1232
+ _super.prototype.ngOnInit.call(this);
1233
+ };
1234
+ KlesFormButtonCheckerComponent = __decorate([
1235
+ Component({
1236
+ selector: 'kles-form-button-checker',
1237
+ template: "\n <div [formGroup]=\"group\">\n <kles-button-checker\n [attr.id]=\"field.id\" [classButton]=\"field.ngClass\" \n [name]=\"field.name\" [label]=\"field.label\" [color]=\"field.color\" \n [icon]=\"field.icon\"\n [iconSvg]=\"field.iconSvg\"\n [value]=\"field.value\"\n [formControlName]=\"field.name\"\n [tooltip]=\"field.tooltip\">\n </kles-button-checker>\n </div>\n "
1238
+ })
1239
+ ], KlesFormButtonCheckerComponent);
1240
+ return KlesFormButtonCheckerComponent;
1220
1241
  }(KlesFieldAbstract));
1221
1242
 
1222
- var KlesButtonFileComponent = /** @class */ (function (_super) {
1223
- __extends(KlesButtonFileComponent, _super);
1224
- function KlesButtonFileComponent() {
1225
- var _this = _super !== null && _super.apply(this, arguments) || this;
1226
- _this.accept = '*.*';
1227
- _this.fileReader = new FileReader();
1228
- _this.value = {};
1229
- return _this;
1230
- }
1231
- KlesButtonFileComponent_1 = KlesButtonFileComponent;
1232
- KlesButtonFileComponent.prototype.click = function (event) {
1233
- this.file.nativeElement.click();
1234
- };
1235
- KlesButtonFileComponent.prototype.writeValue = function (value) {
1236
- if (!value) {
1237
- value = { event: this.name };
1238
- }
1239
- if (!value.event) {
1240
- value.event = this.name;
1241
- }
1242
- if (value.uiButton) {
1243
- var uiButton = value.uiButton;
1244
- this.label = (uiButton.label) ? uiButton.label : this.label;
1245
- this.color = (uiButton.color) ? uiButton.color : this.color;
1246
- this.icon = (uiButton.icon) ? uiButton.icon : this.icon;
1247
- this.iconSvg = (uiButton.iconSvg) ? uiButton.iconSvg : this.iconSvg;
1248
- this.disabled = (uiButton.disabled) ? uiButton.disabled : this.disabled;
1249
- this.classButton = (uiButton.class) ? uiButton.class : this.classButton;
1250
- }
1251
- this.value = value;
1252
- };
1253
- KlesButtonFileComponent.prototype.onFileLoad = function (fileLoadedEvent) {
1254
- var textFromFileLoaded = fileLoadedEvent.target.result;
1255
- this.fileContent = textFromFileLoaded;
1256
- };
1257
- KlesButtonFileComponent.prototype.onFileSelect = function (input) {
1258
- return __awaiter(this, void 0, void 0, function () {
1259
- var files, fileContent, i, _a, _b, e_1;
1260
- return __generator(this, function (_c) {
1261
- switch (_c.label) {
1262
- case 0:
1263
- if (!(input.files.length > 0)) return [3 /*break*/, 8];
1264
- files = input.files;
1265
- fileContent = [];
1266
- if (!(files && files.length)) return [3 /*break*/, 7];
1267
- console.log('Filename: ' + files[0].name);
1268
- console.log('Type: ' + files[0].type);
1269
- console.log('Size: ' + files[0].size + ' bytes');
1270
- console.log('Files=', files.length);
1271
- i = 0;
1272
- _c.label = 1;
1273
- case 1:
1274
- if (!(i < files.length)) return [3 /*break*/, 6];
1275
- _c.label = 2;
1276
- case 2:
1277
- _c.trys.push([2, 4, , 5]);
1278
- _a = fileContent;
1279
- _b = i;
1280
- return [4 /*yield*/, this.readUploadedFile(files[i])];
1281
- case 3:
1282
- _a[_b] = _c.sent();
1283
- return [3 /*break*/, 5];
1284
- case 4:
1285
- e_1 = _c.sent();
1286
- return [3 /*break*/, 5];
1287
- case 5:
1288
- i++;
1289
- return [3 /*break*/, 1];
1290
- case 6:
1291
- if (fileContent.length === 1) {
1292
- fileContent = fileContent[0];
1293
- }
1294
- _c.label = 7;
1295
- case 7:
1296
- this.value.event = this.name;
1297
- this.value.fileContent = fileContent;
1298
- this.onChange(this.value);
1299
- input.value = '';
1300
- _c.label = 8;
1301
- case 8: return [2 /*return*/];
1302
- }
1303
- });
1304
- });
1305
- };
1306
- KlesButtonFileComponent.prototype.readUploadedFile = function (inputFile) {
1307
- var temporaryFileReader = new FileReader();
1308
- return new Promise(function (resolve, reject) {
1309
- temporaryFileReader.onerror = function () {
1310
- temporaryFileReader.abort();
1311
- var error = new DOMException('Problem parsing input file.');
1312
- reject(error);
1313
- };
1314
- temporaryFileReader.onload = function () {
1315
- resolve(temporaryFileReader.result);
1316
- };
1317
- temporaryFileReader.readAsArrayBuffer(inputFile);
1318
- });
1319
- };
1320
- var KlesButtonFileComponent_1;
1321
- __decorate([
1322
- ViewChild('file')
1323
- ], KlesButtonFileComponent.prototype, "file", void 0);
1324
- KlesButtonFileComponent = KlesButtonFileComponent_1 = __decorate([
1325
- Component({
1326
- selector: 'kles-button-file',
1327
- template: "\n <input type=\"file\" #file style=\"display: none\" accept=\"{{accept}}\" (change)=\"onFileSelect($event.target)\" multiple />\n <kles-button \n [classButton]=\"classButton\" \n [name]=\"name\" [label]=\"label\" [color]=\"color\" \n [icon]=\"icon\" [iconSvg]=\"iconSvg\"\n [disabled]=\"disabled\"\n [value]=\"value\" (click)=\"click($event)\">\n </kles-button>\n ",
1328
- providers: [
1329
- {
1330
- provide: NG_VALUE_ACCESSOR,
1331
- useExisting: forwardRef(function () { return KlesButtonFileComponent_1; }),
1332
- multi: true
1333
- }
1334
- ]
1335
- })
1336
- ], KlesButtonFileComponent);
1337
- return KlesButtonFileComponent;
1243
+ var KlesButtonFileComponent = /** @class */ (function (_super) {
1244
+ __extends(KlesButtonFileComponent, _super);
1245
+ function KlesButtonFileComponent() {
1246
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1247
+ _this.accept = '*.*';
1248
+ _this.fileReader = new FileReader();
1249
+ _this.value = {};
1250
+ return _this;
1251
+ }
1252
+ KlesButtonFileComponent_1 = KlesButtonFileComponent;
1253
+ KlesButtonFileComponent.prototype.click = function (event) {
1254
+ this.file.nativeElement.click();
1255
+ };
1256
+ KlesButtonFileComponent.prototype.writeValue = function (value) {
1257
+ if (!value) {
1258
+ value = { event: this.name };
1259
+ }
1260
+ if (!value.event) {
1261
+ value.event = this.name;
1262
+ }
1263
+ if (value.uiButton) {
1264
+ var uiButton = value.uiButton;
1265
+ this.label = (uiButton.label) ? uiButton.label : this.label;
1266
+ this.color = (uiButton.color) ? uiButton.color : this.color;
1267
+ this.icon = (uiButton.icon) ? uiButton.icon : this.icon;
1268
+ this.iconSvg = (uiButton.iconSvg) ? uiButton.iconSvg : this.iconSvg;
1269
+ this.disabled = (uiButton.disabled) ? uiButton.disabled : this.disabled;
1270
+ this.classButton = (uiButton.class) ? uiButton.class : this.classButton;
1271
+ }
1272
+ this.value = value;
1273
+ };
1274
+ KlesButtonFileComponent.prototype.onFileLoad = function (fileLoadedEvent) {
1275
+ var textFromFileLoaded = fileLoadedEvent.target.result;
1276
+ this.fileContent = textFromFileLoaded;
1277
+ };
1278
+ KlesButtonFileComponent.prototype.onFileSelect = function (input) {
1279
+ return __awaiter(this, void 0, void 0, function () {
1280
+ var files, fileContent, i, _a, _b, e_1;
1281
+ return __generator(this, function (_c) {
1282
+ switch (_c.label) {
1283
+ case 0:
1284
+ if (!(input.files.length > 0)) return [3 /*break*/, 8];
1285
+ files = input.files;
1286
+ fileContent = [];
1287
+ if (!(files && files.length)) return [3 /*break*/, 7];
1288
+ console.log('Filename: ' + files[0].name);
1289
+ console.log('Type: ' + files[0].type);
1290
+ console.log('Size: ' + files[0].size + ' bytes');
1291
+ console.log('Files=', files.length);
1292
+ i = 0;
1293
+ _c.label = 1;
1294
+ case 1:
1295
+ if (!(i < files.length)) return [3 /*break*/, 6];
1296
+ _c.label = 2;
1297
+ case 2:
1298
+ _c.trys.push([2, 4, , 5]);
1299
+ _a = fileContent;
1300
+ _b = i;
1301
+ return [4 /*yield*/, this.readUploadedFile(files[i])];
1302
+ case 3:
1303
+ _a[_b] = _c.sent();
1304
+ return [3 /*break*/, 5];
1305
+ case 4:
1306
+ e_1 = _c.sent();
1307
+ return [3 /*break*/, 5];
1308
+ case 5:
1309
+ i++;
1310
+ return [3 /*break*/, 1];
1311
+ case 6:
1312
+ if (fileContent.length === 1) {
1313
+ fileContent = fileContent[0];
1314
+ }
1315
+ _c.label = 7;
1316
+ case 7:
1317
+ this.value.event = this.name;
1318
+ this.value.fileContent = fileContent;
1319
+ this.onChange(this.value);
1320
+ input.value = '';
1321
+ _c.label = 8;
1322
+ case 8: return [2 /*return*/];
1323
+ }
1324
+ });
1325
+ });
1326
+ };
1327
+ KlesButtonFileComponent.prototype.readUploadedFile = function (inputFile) {
1328
+ var temporaryFileReader = new FileReader();
1329
+ return new Promise(function (resolve, reject) {
1330
+ temporaryFileReader.onerror = function () {
1331
+ temporaryFileReader.abort();
1332
+ var error = new DOMException('Problem parsing input file.');
1333
+ reject(error);
1334
+ };
1335
+ temporaryFileReader.onload = function () {
1336
+ resolve(temporaryFileReader.result);
1337
+ };
1338
+ temporaryFileReader.readAsArrayBuffer(inputFile);
1339
+ });
1340
+ };
1341
+ var KlesButtonFileComponent_1;
1342
+ __decorate([
1343
+ ViewChild('file')
1344
+ ], KlesButtonFileComponent.prototype, "file", void 0);
1345
+ KlesButtonFileComponent = KlesButtonFileComponent_1 = __decorate([
1346
+ Component({
1347
+ selector: 'kles-button-file',
1348
+ template: "\n <input type=\"file\" #file style=\"display: none\" accept=\"{{accept}}\" (change)=\"onFileSelect($event.target)\" multiple />\n <kles-button \n [classButton]=\"classButton\" \n [name]=\"name\" [label]=\"label\" [color]=\"color\" \n [icon]=\"icon\" [iconSvg]=\"iconSvg\"\n [disabled]=\"disabled\"\n [value]=\"value\" (click)=\"click($event)\">\n </kles-button>\n ",
1349
+ providers: [
1350
+ {
1351
+ provide: NG_VALUE_ACCESSOR,
1352
+ useExisting: forwardRef(function () { return KlesButtonFileComponent_1; }),
1353
+ multi: true
1354
+ }
1355
+ ]
1356
+ })
1357
+ ], KlesButtonFileComponent);
1358
+ return KlesButtonFileComponent;
1338
1359
  }(KlesButtonComponent));
1339
1360
 
1340
- var KlesFormButtonFileComponent = /** @class */ (function (_super) {
1341
- __extends(KlesFormButtonFileComponent, _super);
1342
- function KlesFormButtonFileComponent() {
1343
- return _super !== null && _super.apply(this, arguments) || this;
1344
- }
1345
- KlesFormButtonFileComponent.prototype.ngOnInit = function () {
1346
- _super.prototype.ngOnInit.call(this);
1347
- };
1348
- KlesFormButtonFileComponent = __decorate([
1349
- Component({
1350
- selector: 'kles-form-button-file',
1351
- template: "\n <div [formGroup]=\"group\">\n <kles-button-file\n [attr.id]=\"field.id\" [classButton]=\"field.ngClass\" \n [name]=\"field.name\" [label]=\"field.label\" [color]=\"field.color\" \n [icon]=\"field.icon\"\n [iconSvg]=\"field.iconSvg\"\n [value]=\"field.value\"\n [formControlName]=\"field.name\">\n </kles-button-file>\n </div>\n "
1352
- })
1353
- ], KlesFormButtonFileComponent);
1354
- return KlesFormButtonFileComponent;
1361
+ var KlesFormButtonFileComponent = /** @class */ (function (_super) {
1362
+ __extends(KlesFormButtonFileComponent, _super);
1363
+ function KlesFormButtonFileComponent() {
1364
+ return _super !== null && _super.apply(this, arguments) || this;
1365
+ }
1366
+ KlesFormButtonFileComponent.prototype.ngOnInit = function () {
1367
+ _super.prototype.ngOnInit.call(this);
1368
+ };
1369
+ KlesFormButtonFileComponent = __decorate([
1370
+ Component({
1371
+ selector: 'kles-form-button-file',
1372
+ template: "\n <div [formGroup]=\"group\">\n <kles-button-file\n [attr.id]=\"field.id\" [classButton]=\"field.ngClass\" \n [name]=\"field.name\" [label]=\"field.label\" [color]=\"field.color\" \n [icon]=\"field.icon\"\n [iconSvg]=\"field.iconSvg\"\n [value]=\"field.value\"\n [formControlName]=\"field.name\">\n </kles-button-file>\n </div>\n "
1373
+ })
1374
+ ], KlesFormButtonFileComponent);
1375
+ return KlesFormButtonFileComponent;
1355
1376
  }(KlesFieldAbstract));
1356
1377
 
1357
- var KlesFormTextareaComponent = /** @class */ (function (_super) {
1358
- __extends(KlesFormTextareaComponent, _super);
1359
- function KlesFormTextareaComponent() {
1360
- return _super !== null && _super.apply(this, arguments) || this;
1361
- }
1362
- KlesFormTextareaComponent.prototype.ngOnInit = function () {
1363
- _super.prototype.ngOnInit.call(this);
1364
- };
1365
- KlesFormTextareaComponent = __decorate([
1366
- Component({
1367
- selector: 'kles-form-textarea',
1368
- template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n <textarea matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" \n [formControlName]=\"field.name\" cdkTextareaAutosize [placeholder]=\"field.placeholder | translate\"\n [cdkAutosizeMinRows]=\"field.textareaAutoSize?.minRows\" [cdkAutosizeMaxRows]=\"field.textareaAutoSize?.maxRows\">\n </textarea>\n\n\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
1369
- styles: ['mat-form-field {width: calc(100%)}']
1370
- })
1371
- ], KlesFormTextareaComponent);
1372
- return KlesFormTextareaComponent;
1378
+ var KlesFormTextareaComponent = /** @class */ (function (_super) {
1379
+ __extends(KlesFormTextareaComponent, _super);
1380
+ function KlesFormTextareaComponent() {
1381
+ return _super !== null && _super.apply(this, arguments) || this;
1382
+ }
1383
+ KlesFormTextareaComponent.prototype.ngOnInit = function () {
1384
+ _super.prototype.ngOnInit.call(this);
1385
+ };
1386
+ KlesFormTextareaComponent = __decorate([
1387
+ Component({
1388
+ selector: 'kles-form-textarea',
1389
+ template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n <textarea matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" \n [formControlName]=\"field.name\" cdkTextareaAutosize [placeholder]=\"field.placeholder | translate\"\n [cdkAutosizeMinRows]=\"field.textareaAutoSize?.minRows\" [cdkAutosizeMaxRows]=\"field.textareaAutoSize?.maxRows\" [maxlength]=\"field.maxLength\">\n </textarea>\n\n\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
1390
+ styles: ['mat-form-field {width: calc(100%)}']
1391
+ })
1392
+ ], KlesFormTextareaComponent);
1393
+ return KlesFormTextareaComponent;
1373
1394
  }(KlesFieldAbstract));
1374
1395
 
1375
- var KlesFormTextComponent = /** @class */ (function (_super) {
1376
- __extends(KlesFormTextComponent, _super);
1377
- function KlesFormTextComponent() {
1378
- return _super !== null && _super.apply(this, arguments) || this;
1379
- }
1380
- KlesFormTextComponent.prototype.ngOnInit = function () {
1381
- _super.prototype.ngOnInit.call(this);
1382
- };
1383
- KlesFormTextComponent = __decorate([
1384
- Component({
1385
- selector: 'kles-form-text',
1386
- template: "\n <span matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\">\n {{(field.property ? group.controls[field.name].value[field.property] : group.controls[field.name].value) | klesTransform:field.pipeTransform}}\n </span> \n"
1387
- })
1388
- ], KlesFormTextComponent);
1389
- return KlesFormTextComponent;
1396
+ var KlesFormTextComponent = /** @class */ (function (_super) {
1397
+ __extends(KlesFormTextComponent, _super);
1398
+ function KlesFormTextComponent() {
1399
+ return _super !== null && _super.apply(this, arguments) || this;
1400
+ }
1401
+ KlesFormTextComponent.prototype.ngOnInit = function () {
1402
+ _super.prototype.ngOnInit.call(this);
1403
+ };
1404
+ KlesFormTextComponent = __decorate([
1405
+ Component({
1406
+ selector: 'kles-form-text',
1407
+ template: "\n <span matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\">\n {{(field.property ? group.controls[field.name].value[field.property] : group.controls[field.name].value) | klesTransform:field.pipeTransform}}\n </span> \n"
1408
+ })
1409
+ ], KlesFormTextComponent);
1410
+ return KlesFormTextComponent;
1390
1411
  }(KlesFieldAbstract));
1391
1412
 
1392
- var KlesFormInputClearableComponent = /** @class */ (function (_super) {
1393
- __extends(KlesFormInputClearableComponent, _super);
1394
- function KlesFormInputClearableComponent() {
1395
- return _super !== null && _super.apply(this, arguments) || this;
1396
- }
1397
- KlesFormInputClearableComponent = __decorate([
1398
- Component({
1399
- selector: 'kles-form-input-clearable',
1400
- template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n\n <ng-container *ngIf=\"field.autocomplete; else notAutoComplete\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\"\n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\"\n [matAutocomplete]=\"auto\">\n\n <mat-autocomplete #auto=\"matAutocomplete\" [displayWith]=\"displayFn.bind(this)\" [panelWidth]=\"this.field.panelWidth\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n {{field.property ? option[field.property] : option}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"option\">\n </ng-container>\n </mat-option>\n </ng-container>\n </mat-autocomplete>\n </ng-container>\n\n <ng-template #notAutoComplete>\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\"\n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\">\n </ng-template>\n <button mat-button matSuffix mat-icon-button aria-label=\"Clear\" type=\"button\"\n (click)=\"group.controls[field.name].reset();\">\n <mat-icon>close</mat-icon>\n </button>\n\n <mat-spinner matSuffix mode=\"indeterminate\" *ngIf=\"isPending()\" diameter=\"17\"></mat-spinner>\n\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
1401
- styles: ['mat-form-field {width: calc(100%)}']
1402
- })
1403
- ], KlesFormInputClearableComponent);
1404
- return KlesFormInputClearableComponent;
1413
+ var KlesFormInputClearableComponent = /** @class */ (function (_super) {
1414
+ __extends(KlesFormInputClearableComponent, _super);
1415
+ function KlesFormInputClearableComponent() {
1416
+ return _super !== null && _super.apply(this, arguments) || this;
1417
+ }
1418
+ KlesFormInputClearableComponent = __decorate([
1419
+ Component({
1420
+ selector: 'kles-form-input-clearable',
1421
+ template: "\n <mat-form-field [formGroup]=\"group\" class=\"form-element\">\n\n <ng-container *ngIf=\"field.autocomplete; else notAutoComplete\">\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\"\n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\"\n [matAutocomplete]=\"auto\">\n\n <mat-autocomplete #auto=\"matAutocomplete\" [displayWith]=\"displayFn.bind(this)\" [panelWidth]=\"this.field.panelWidth\">\n <ng-container *ngIf=\"!field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n {{field.property ? option[field.property] : option}}\n </mat-option>\n </ng-container>\n\n <ng-container *ngIf=\"field.autocompleteComponent\">\n <mat-option *ngFor=\"let option of filteredOption | async\" [value]=\"option\">\n <ng-container klesComponent [component]=\"field.autocompleteComponent\" [value]=\"option\" [field]=\"field\">\n </ng-container>\n </mat-option>\n </ng-container>\n </mat-autocomplete>\n </ng-container>\n\n <ng-template #notAutoComplete>\n <input matInput matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [formControlName]=\"field.name\" [placeholder]=\"field.placeholder | translate\" [type]=\"field.inputType\"\n [maxLength]=\"field.maxLength\" [min]=\"field.min\" [max]=\"field.max\" [step]=\"field.step\">\n </ng-template>\n <button mat-button matSuffix mat-icon-button aria-label=\"Clear\" type=\"button\"\n (click)=\"group.controls[field.name].reset();\">\n <mat-icon>close</mat-icon>\n </button>\n\n <mat-spinner matSuffix mode=\"indeterminate\" *ngIf=\"isPending()\" diameter=\"17\"></mat-spinner>\n\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message | translate}}</mat-error>\n </ng-container>\n </mat-form-field>\n ",
1422
+ styles: ['mat-form-field {width: calc(100%)}']
1423
+ })
1424
+ ], KlesFormInputClearableComponent);
1425
+ return KlesFormInputClearableComponent;
1405
1426
  }(KlesFormInputComponent));
1406
1427
 
1407
- var KlesTransformPipe = /** @class */ (function () {
1408
- function KlesTransformPipe() {
1409
- }
1410
- KlesTransformPipe.prototype.transform = function (value, pipes) {
1411
- if (pipes && pipes.length > 0) {
1412
- return pipes.reduce(function (acc, p) {
1413
- if (p.options) {
1414
- p.options.forEach(function (opt) {
1415
- acc = p.pipe.transform(acc, opt);
1416
- });
1417
- }
1418
- else {
1419
- acc = p.pipe.transform(acc);
1420
- }
1421
- return acc;
1422
- }, value);
1423
- }
1424
- return value;
1425
- };
1426
- KlesTransformPipe = __decorate([
1427
- Pipe({ name: 'klesTransform' })
1428
- ], KlesTransformPipe);
1429
- return KlesTransformPipe;
1428
+ var KlesTransformPipe = /** @class */ (function () {
1429
+ function KlesTransformPipe() {
1430
+ }
1431
+ KlesTransformPipe.prototype.transform = function (value, pipes) {
1432
+ if (pipes && pipes.length > 0) {
1433
+ return pipes.reduce(function (acc, p) {
1434
+ if (p.options) {
1435
+ p.options.forEach(function (opt) {
1436
+ acc = p.pipe.transform(acc, opt);
1437
+ });
1438
+ }
1439
+ else {
1440
+ acc = p.pipe.transform(acc);
1441
+ }
1442
+ return acc;
1443
+ }, value);
1444
+ }
1445
+ return value;
1446
+ };
1447
+ KlesTransformPipe = __decorate([
1448
+ Pipe({ name: 'klesTransform' })
1449
+ ], KlesTransformPipe);
1450
+ return KlesTransformPipe;
1430
1451
  }());
1431
1452
 
1432
- var ArrayFormatPipe = /** @class */ (function () {
1433
- function ArrayFormatPipe() {
1434
- }
1435
- ArrayFormatPipe.prototype.transform = function (values, property) {
1436
- if (values && Array.isArray(values)) {
1437
- if (property) {
1438
- return values.map(function (value) { return value[property]; }).filter(Boolean).join(', ');
1439
- }
1440
- else {
1441
- return values.join(', ');
1442
- }
1443
- }
1444
- return '';
1445
- };
1446
- ArrayFormatPipe = __decorate([
1447
- Pipe({ name: 'arrayFormat' })
1448
- ], ArrayFormatPipe);
1449
- return ArrayFormatPipe;
1453
+ var ArrayFormatPipe = /** @class */ (function () {
1454
+ function ArrayFormatPipe() {
1455
+ }
1456
+ ArrayFormatPipe.prototype.transform = function (values, property) {
1457
+ if (values && Array.isArray(values)) {
1458
+ if (property) {
1459
+ return values.map(function (value) { return value[property]; }).filter(Boolean).join(', ');
1460
+ }
1461
+ else {
1462
+ return values.join(', ');
1463
+ }
1464
+ }
1465
+ return '';
1466
+ };
1467
+ ArrayFormatPipe = __decorate([
1468
+ Pipe({ name: 'arrayFormat' })
1469
+ ], ArrayFormatPipe);
1470
+ return ArrayFormatPipe;
1450
1471
  }());
1451
1472
 
1452
- var KlesFormSlideToggleComponent = /** @class */ (function (_super) {
1453
- __extends(KlesFormSlideToggleComponent, _super);
1454
- function KlesFormSlideToggleComponent() {
1455
- return _super !== null && _super.apply(this, arguments) || this;
1456
- }
1457
- KlesFormSlideToggleComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
1458
- KlesFormSlideToggleComponent = __decorate([
1459
- Component({
1460
- selector: "kles-form-slide-toggle",
1461
- template: "\n <div [formGroup]=\"group\" > \n <mat-slide-toggle matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [color]=\"field.color\" [formControlName]=\"field.name\">{{field.label | translate}}</mat-slide-toggle>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n </div>\n"
1462
- })
1463
- ], KlesFormSlideToggleComponent);
1464
- return KlesFormSlideToggleComponent;
1473
+ var KlesFormSlideToggleComponent = /** @class */ (function (_super) {
1474
+ __extends(KlesFormSlideToggleComponent, _super);
1475
+ function KlesFormSlideToggleComponent() {
1476
+ return _super !== null && _super.apply(this, arguments) || this;
1477
+ }
1478
+ KlesFormSlideToggleComponent.prototype.ngOnInit = function () { _super.prototype.ngOnInit.call(this); };
1479
+ KlesFormSlideToggleComponent = __decorate([
1480
+ Component({
1481
+ selector: "kles-form-slide-toggle",
1482
+ template: "\n <div [formGroup]=\"group\" > \n <mat-slide-toggle matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" [color]=\"field.color\" [formControlName]=\"field.name\">{{field.label | translate}}</mat-slide-toggle>\n <ng-container *ngFor=\"let validation of field.validations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n <ng-container *ngFor=\"let validation of field.asyncValidations;\" ngProjectAs=\"mat-error\">\n <mat-error *ngIf=\"group.get(field.name).hasError(validation.name)\">{{validation.message}}</mat-error>\n </ng-container>\n </div>\n"
1483
+ })
1484
+ ], KlesFormSlideToggleComponent);
1485
+ return KlesFormSlideToggleComponent;
1465
1486
  }(KlesFieldAbstract));
1466
1487
 
1467
- var KlesFormBadgeComponent = /** @class */ (function (_super) {
1468
- __extends(KlesFormBadgeComponent, _super);
1469
- function KlesFormBadgeComponent() {
1470
- return _super !== null && _super.apply(this, arguments) || this;
1471
- }
1472
- KlesFormBadgeComponent.prototype.ngOnInit = function () {
1473
- _super.prototype.ngOnInit.call(this);
1474
- };
1475
- KlesFormBadgeComponent = __decorate([
1476
- Component({
1477
- selector: 'kles-form-badge',
1478
- template: "\n <span matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" \n matBadge=\"{{group.controls[field.name].value}}\" matBadgeOverlap=\"false\" matBadgeColor=\"{{field.color}}\">\n </span> \n"
1479
- })
1480
- ], KlesFormBadgeComponent);
1481
- return KlesFormBadgeComponent;
1488
+ var KlesFormBadgeComponent = /** @class */ (function (_super) {
1489
+ __extends(KlesFormBadgeComponent, _super);
1490
+ function KlesFormBadgeComponent() {
1491
+ return _super !== null && _super.apply(this, arguments) || this;
1492
+ }
1493
+ KlesFormBadgeComponent.prototype.ngOnInit = function () {
1494
+ _super.prototype.ngOnInit.call(this);
1495
+ };
1496
+ KlesFormBadgeComponent = __decorate([
1497
+ Component({
1498
+ selector: 'kles-form-badge',
1499
+ template: "\n <span matTooltip=\"{{field.tooltip}}\" [attr.id]=\"field.id\" [ngClass]=\"field.ngClass\" \n matBadge=\"{{group.controls[field.name].value}}\" matBadgeOverlap=\"false\" matBadgeColor=\"{{field.color}}\">\n </span> \n"
1500
+ })
1501
+ ], KlesFormBadgeComponent);
1502
+ return KlesFormBadgeComponent;
1482
1503
  }(KlesFieldAbstract));
1483
1504
 
1484
- var components = [
1485
- KlesDynamicFormComponent,
1486
- KlesFormLabelComponent,
1487
- KlesFormInputComponent,
1488
- KlesFormInputClearableComponent,
1489
- KlesFormSubmitButtonComponent,
1490
- KlesFormBadgeComponent,
1491
- KlesButtonComponent,
1492
- KlesFormButtonComponent,
1493
- KlesButtonCheckerComponent,
1494
- KlesFormButtonCheckerComponent,
1495
- KlesButtonFileComponent,
1496
- KlesFormButtonFileComponent,
1497
- KlesFormSelectComponent,
1498
- KlesFormDateComponent,
1499
- KlesFormRadioComponent,
1500
- KlesFormCheckboxComponent,
1501
- KlesFormListFieldComponent,
1502
- KlesFormColorComponent,
1503
- KlesFormTextareaComponent,
1504
- KlesFormTextComponent,
1505
- KlesFormChipComponent,
1506
- KlesFormGroupComponent,
1507
- KlesFormIconComponent,
1508
- KlesFormSelectSearchComponent,
1509
- KlesFormLineBreakComponent,
1510
- KlesFormLinkComponent,
1511
- KlesFormSlideToggleComponent,
1512
- KlesFormSelectionListComponent,
1513
- KlesFormButtonToogleGroupComponent
1514
- ];
1515
- var directives = [KlesDynamicFieldDirective, KlesComponentDirective];
1516
- var pipes = [KlesTransformPipe, ArrayFormatPipe];
1517
- var KlesMaterialDynamicformsModule = /** @class */ (function () {
1518
- function KlesMaterialDynamicformsModule() {
1519
- }
1520
- KlesMaterialDynamicformsModule = __decorate([
1521
- NgModule({
1522
- declarations: [
1523
- components,
1524
- directives,
1525
- pipes
1526
- ],
1527
- imports: [
1528
- CommonModule,
1529
- ReactiveFormsModule,
1530
- TranslateModule,
1531
- FlexLayoutModule,
1532
- FormsModule,
1533
- MaterialModule,
1534
- ColorPickerModule,
1535
- NgxMatSelectSearchModule
1536
- ],
1537
- providers: [
1538
- { provide: ErrorStateMatcher, useClass: KlesFormErrorStateMatcher },
1539
- pipes
1540
- ],
1541
- entryComponents: [
1542
- components
1543
- ],
1544
- exports: [
1545
- components,
1546
- pipes,
1547
- directives,
1548
- ColorPickerModule
1549
- ],
1550
- schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
1551
- })
1552
- ], KlesMaterialDynamicformsModule);
1553
- return KlesMaterialDynamicformsModule;
1505
+ var components = [
1506
+ KlesDynamicFormComponent,
1507
+ KlesFormLabelComponent,
1508
+ KlesFormInputComponent,
1509
+ KlesFormInputClearableComponent,
1510
+ KlesFormSubmitButtonComponent,
1511
+ KlesFormBadgeComponent,
1512
+ KlesButtonComponent,
1513
+ KlesFormButtonComponent,
1514
+ KlesButtonCheckerComponent,
1515
+ KlesFormButtonCheckerComponent,
1516
+ KlesButtonFileComponent,
1517
+ KlesFormButtonFileComponent,
1518
+ KlesFormSelectComponent,
1519
+ KlesFormDateComponent,
1520
+ KlesFormRadioComponent,
1521
+ KlesFormCheckboxComponent,
1522
+ KlesFormListFieldComponent,
1523
+ KlesFormColorComponent,
1524
+ KlesFormTextareaComponent,
1525
+ KlesFormTextComponent,
1526
+ KlesFormChipComponent,
1527
+ KlesFormGroupComponent,
1528
+ KlesFormIconComponent,
1529
+ KlesFormSelectSearchComponent,
1530
+ KlesFormLineBreakComponent,
1531
+ KlesFormLinkComponent,
1532
+ KlesFormSlideToggleComponent,
1533
+ KlesFormSelectionListComponent,
1534
+ KlesFormButtonToogleGroupComponent
1535
+ ];
1536
+ var directives = [KlesDynamicFieldDirective, KlesComponentDirective];
1537
+ var pipes = [KlesTransformPipe, ArrayFormatPipe];
1538
+ var KlesMaterialDynamicformsModule = /** @class */ (function () {
1539
+ function KlesMaterialDynamicformsModule() {
1540
+ }
1541
+ KlesMaterialDynamicformsModule = __decorate([
1542
+ NgModule({
1543
+ declarations: [
1544
+ components,
1545
+ directives,
1546
+ pipes
1547
+ ],
1548
+ imports: [
1549
+ CommonModule,
1550
+ ReactiveFormsModule,
1551
+ TranslateModule,
1552
+ FlexLayoutModule,
1553
+ FormsModule,
1554
+ MaterialModule,
1555
+ ColorPickerModule,
1556
+ NgxMatSelectSearchModule
1557
+ ],
1558
+ providers: [
1559
+ { provide: ErrorStateMatcher, useClass: KlesFormErrorStateMatcher },
1560
+ pipes
1561
+ ],
1562
+ entryComponents: [
1563
+ components
1564
+ ],
1565
+ exports: [
1566
+ components,
1567
+ pipes,
1568
+ directives,
1569
+ ColorPickerModule
1570
+ ],
1571
+ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
1572
+ })
1573
+ ], KlesMaterialDynamicformsModule);
1574
+ return KlesMaterialDynamicformsModule;
1554
1575
  }());
1555
1576
 
1556
- function autocompleteObjectValidator(optional) {
1557
- return function (control) {
1558
- if ((control.value === null || control.value === undefined) && !optional)
1559
- return { 'invalidAutocompleteObject': { value: control.value } };
1560
- if (typeof control.value === 'string') {
1561
- if (control.value === '' && optional)
1562
- return null;
1563
- return { 'invalidAutocompleteObject': { value: control.value } };
1564
- }
1565
- return null; /* valid option selected */
1566
- };
1567
- }
1568
- function autocompleteStringValidator(validOptions, optional) {
1569
- return function (control) {
1570
- if ((control.value === '' || control.value === null) && optional)
1571
- return null;
1572
- if (validOptions.indexOf(control.value) !== -1) {
1573
- return null; /* valid option selected */
1574
- }
1575
- return { 'invalidAutocompleteString': { value: control.value } };
1576
- };
1577
+ function autocompleteObjectValidator(optional) {
1578
+ return function (control) {
1579
+ if ((control.value === null || control.value === undefined) && !optional)
1580
+ return { 'invalidAutocompleteObject': { value: control.value } };
1581
+ if (typeof control.value === 'string') {
1582
+ if (control.value === '' && optional)
1583
+ return null;
1584
+ return { 'invalidAutocompleteObject': { value: control.value } };
1585
+ }
1586
+ return null; /* valid option selected */
1587
+ };
1588
+ }
1589
+ function autocompleteStringValidator(validOptions, optional) {
1590
+ return function (control) {
1591
+ if ((control.value === '' || control.value === null) && optional)
1592
+ return null;
1593
+ if (validOptions.indexOf(control.value) !== -1) {
1594
+ return null; /* valid option selected */
1595
+ }
1596
+ return { 'invalidAutocompleteString': { value: control.value } };
1597
+ };
1577
1598
  }
1578
1599
 
1579
- /*
1580
- * Public API Surface of kles-material-dynamicforms
1600
+ /*
1601
+ * Public API Surface of kles-material-dynamicforms
1581
1602
  */
1582
1603
 
1583
- /**
1584
- * Generated bundle index. Do not edit.
1604
+ /**
1605
+ * Generated bundle index. Do not edit.
1585
1606
  */
1586
1607
 
1587
1608
  export { ArrayFormatPipe, KlesButtonCheckerComponent, KlesButtonComponent, KlesButtonFileComponent, KlesComponentDirective, KlesDynamicFieldDirective, KlesDynamicFormComponent, KlesFieldAbstract, KlesFormBadgeComponent, KlesFormButtonCheckerComponent, KlesFormButtonComponent, KlesFormButtonFileComponent, KlesFormButtonToogleGroupComponent, KlesFormCheckboxComponent, KlesFormChipComponent, KlesFormColorComponent, KlesFormDateComponent, KlesFormErrorStateMatcher, KlesFormGroupComponent, KlesFormIconComponent, KlesFormInputClearableComponent, KlesFormInputComponent, KlesFormLabelComponent, KlesFormLineBreakComponent, KlesFormLinkComponent, KlesFormListFieldComponent, KlesFormRadioComponent, KlesFormSelectComponent, KlesFormSelectSearchComponent, KlesFormSelectionListComponent, KlesFormSlideToggleComponent, KlesFormSubmitButtonComponent, KlesFormTextComponent, KlesFormTextareaComponent, KlesMaterialDynamicformsModule, KlesTransformPipe, autocompleteObjectValidator, autocompleteStringValidator, MaterialModule as ɵa };