@3kles/kles-material-dynamicforms 1.1.19 → 14.0.1

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