@covalent/dynamic-forms 3.1.2-beta.6 → 4.0.0-beta.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 (62) hide show
  1. package/covalent-dynamic-forms.d.ts +1 -0
  2. package/dynamic-element.component.d.ts +7 -0
  3. package/dynamic-elements/dynamic-checkbox/dynamic-checkbox.component.d.ts +3 -0
  4. package/dynamic-elements/dynamic-datepicker/dynamic-datepicker.component.d.ts +3 -0
  5. package/dynamic-elements/dynamic-datepicker/dynamic-datepicker.component.scss +1 -0
  6. package/dynamic-elements/dynamic-file-input/dynamic-file-input.component.d.ts +3 -0
  7. package/dynamic-elements/dynamic-file-input/dynamic-file-input.component.scss +2 -0
  8. package/dynamic-elements/dynamic-input/dynamic-input.component.d.ts +3 -0
  9. package/dynamic-elements/dynamic-input/dynamic-input.component.scss +1 -0
  10. package/dynamic-elements/dynamic-select/dynamic-select.component.d.ts +3 -0
  11. package/dynamic-elements/dynamic-select/dynamic-select.component.scss +1 -0
  12. package/dynamic-elements/dynamic-slide-toggle/dynamic-slide-toggle.component.d.ts +3 -0
  13. package/dynamic-elements/dynamic-slider/dynamic-slider.component.d.ts +3 -0
  14. package/dynamic-elements/dynamic-slider/dynamic-slider.component.scss +2 -0
  15. package/dynamic-elements/dynamic-textarea/dynamic-textarea.component.d.ts +3 -0
  16. package/dynamic-elements/dynamic-textarea/dynamic-textarea.component.scss +1 -0
  17. package/dynamic-forms.component.d.ts +3 -0
  18. package/dynamic-forms.component.scss +10 -12
  19. package/dynamic-forms.module.d.ts +27 -0
  20. package/esm2020/covalent-dynamic-forms.mjs +5 -0
  21. package/esm2020/dynamic-element.component.mjs +220 -0
  22. package/esm2020/dynamic-elements/dynamic-checkbox/dynamic-checkbox.component.mjs +35 -0
  23. package/esm2020/dynamic-elements/dynamic-datepicker/dynamic-datepicker.component.mjs +58 -0
  24. package/esm2020/dynamic-elements/dynamic-file-input/dynamic-file-input.component.mjs +84 -0
  25. package/esm2020/dynamic-elements/dynamic-input/dynamic-input.component.mjs +55 -0
  26. package/esm2020/dynamic-elements/dynamic-select/dynamic-select.component.mjs +67 -0
  27. package/esm2020/dynamic-elements/dynamic-slide-toggle/dynamic-slide-toggle.component.mjs +36 -0
  28. package/esm2020/dynamic-elements/dynamic-slider/dynamic-slider.component.mjs +62 -0
  29. package/esm2020/dynamic-elements/dynamic-textarea/dynamic-textarea.component.mjs +50 -0
  30. package/esm2020/dynamic-forms.component.mjs +220 -0
  31. package/esm2020/dynamic-forms.module.mjs +118 -0
  32. package/esm2020/index.mjs +2 -0
  33. package/esm2020/public_api.mjs +13 -0
  34. package/esm2020/services/dynamic-forms.service.mjs +125 -0
  35. package/fesm2015/covalent-dynamic-forms.mjs +1143 -0
  36. package/fesm2015/covalent-dynamic-forms.mjs.map +1 -0
  37. package/fesm2020/covalent-dynamic-forms.mjs +1063 -0
  38. package/fesm2020/covalent-dynamic-forms.mjs.map +1 -0
  39. package/package.json +29 -12
  40. package/services/dynamic-forms.service.d.ts +3 -0
  41. package/bundles/covalent-dynamic-forms.umd.js +0 -1654
  42. package/bundles/covalent-dynamic-forms.umd.js.map +0 -1
  43. package/bundles/covalent-dynamic-forms.umd.min.js +0 -16
  44. package/bundles/covalent-dynamic-forms.umd.min.js.map +0 -1
  45. package/covalent-dynamic-forms.metadata.json +0 -1
  46. package/esm2015/covalent-dynamic-forms.js +0 -10
  47. package/esm2015/dynamic-element.component.js +0 -340
  48. package/esm2015/dynamic-elements/dynamic-checkbox/dynamic-checkbox.component.js +0 -34
  49. package/esm2015/dynamic-elements/dynamic-datepicker/dynamic-datepicker.component.js +0 -49
  50. package/esm2015/dynamic-elements/dynamic-file-input/dynamic-file-input.component.js +0 -47
  51. package/esm2015/dynamic-elements/dynamic-input/dynamic-input.component.js +0 -55
  52. package/esm2015/dynamic-elements/dynamic-select/dynamic-select.component.js +0 -46
  53. package/esm2015/dynamic-elements/dynamic-slide-toggle/dynamic-slide-toggle.component.js +0 -34
  54. package/esm2015/dynamic-elements/dynamic-slider/dynamic-slider.component.js +0 -64
  55. package/esm2015/dynamic-elements/dynamic-textarea/dynamic-textarea.component.js +0 -40
  56. package/esm2015/dynamic-forms.component.js +0 -306
  57. package/esm2015/dynamic-forms.module.js +0 -73
  58. package/esm2015/index.js +0 -7
  59. package/esm2015/public_api.js +0 -18
  60. package/esm2015/services/dynamic-forms.service.js +0 -201
  61. package/fesm2015/covalent-dynamic-forms.js +0 -1269
  62. package/fesm2015/covalent-dynamic-forms.js.map +0 -1
@@ -0,0 +1,1143 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, Injectable, Optional, SkipSelf, Directive, Input, Type, forwardRef, ViewChild, HostBinding, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
+ import * as i4 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i3 from '@angular/forms';
6
+ import { FormControl, Validators, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
7
+ import * as i1 from '@angular/material/form-field';
8
+ import { MatFormFieldModule } from '@angular/material/form-field';
9
+ import * as i2 from '@angular/material/input';
10
+ import { MatInputModule } from '@angular/material/input';
11
+ import * as i2$3 from '@angular/material/select';
12
+ import { MatSelectModule } from '@angular/material/select';
13
+ import * as i1$2 from '@angular/material/checkbox';
14
+ import { MatCheckboxModule } from '@angular/material/checkbox';
15
+ import * as i2$2 from '@angular/material/slider';
16
+ import { MatSliderModule } from '@angular/material/slider';
17
+ import * as i1$1 from '@angular/material/slide-toggle';
18
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
19
+ import * as i6 from '@angular/material/icon';
20
+ import { MatIconModule } from '@angular/material/icon';
21
+ import * as i5 from '@angular/material/button';
22
+ import { MatButtonModule } from '@angular/material/button';
23
+ import * as i3$1 from '@angular/material/datepicker';
24
+ import { MatDatepickerModule } from '@angular/material/datepicker';
25
+ import { mixinControlValueAccessor, CovalentCommonModule } from '@covalent/core/common';
26
+ import * as i2$1 from '@covalent/core/file';
27
+ import { CovalentFileModule } from '@covalent/core/file';
28
+ import { TemplatePortalDirective } from '@angular/cdk/portal';
29
+ import * as i5$1 from '@angular/material/core';
30
+ import { Subject, timer } from 'rxjs';
31
+ import { filter, takeUntil } from 'rxjs/operators';
32
+
33
+ function TdDynamicInputComponent_ng_template_9_Template(rf, ctx) { }
34
+ const _c0$5 = function (a0, a1) { return { control: a0, errors: a1 }; };
35
+ class TdDynamicInputComponent {
36
+ constructor() {
37
+ this.label = '';
38
+ this.hint = '';
39
+ this.type = undefined;
40
+ this.required = undefined;
41
+ this.name = '';
42
+ this.min = undefined;
43
+ this.max = undefined;
44
+ this.minLength = undefined;
45
+ this.maxLength = undefined;
46
+ this.errorMessageTemplate = undefined;
47
+ this.placeholder = '';
48
+ }
49
+ }
50
+ /** @nocollapse */ /** @nocollapse */ TdDynamicInputComponent.ɵfac = function TdDynamicInputComponent_Factory(t) { return new (t || TdDynamicInputComponent)(); };
51
+ /** @nocollapse */ /** @nocollapse */ TdDynamicInputComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicInputComponent, selectors: [["td-dynamic-input"]], decls: 10, vars: 16, consts: [[1, "td-dynamic-input-wrapper"], [1, "td-dynamic-input-field"], ["matInput", "", 3, "formControl", "placeholder", "type", "required"], ["elementInput", ""], [3, "ngTemplateOutlet", "ngTemplateOutletContext"]], template: function TdDynamicInputComponent_Template(rf, ctx) {
52
+ if (rf & 1) {
53
+ i0.ɵɵelementStart(0, "div", 0);
54
+ i0.ɵɵelementStart(1, "mat-form-field", 1);
55
+ i0.ɵɵelementStart(2, "mat-label");
56
+ i0.ɵɵtext(3);
57
+ i0.ɵɵelementEnd();
58
+ i0.ɵɵelement(4, "input", 2, 3);
59
+ i0.ɵɵelementStart(6, "mat-hint");
60
+ i0.ɵɵtext(7);
61
+ i0.ɵɵelementEnd();
62
+ i0.ɵɵelementStart(8, "mat-error");
63
+ i0.ɵɵtemplate(9, TdDynamicInputComponent_ng_template_9_Template, 0, 0, "ng-template", 4);
64
+ i0.ɵɵelementEnd();
65
+ i0.ɵɵelementEnd();
66
+ i0.ɵɵelementEnd();
67
+ }
68
+ if (rf & 2) {
69
+ i0.ɵɵadvance(3);
70
+ i0.ɵɵtextInterpolate(ctx.label);
71
+ i0.ɵɵadvance(1);
72
+ i0.ɵɵproperty("formControl", ctx.control)("placeholder", ctx.placeholder)("type", ctx.type)("required", ctx.required);
73
+ i0.ɵɵattribute("name", ctx.name)("min", ctx.min)("max", ctx.max)("minLength", ctx.minLength)("maxLength", ctx.maxLength);
74
+ i0.ɵɵadvance(3);
75
+ i0.ɵɵtextInterpolate(ctx.hint);
76
+ i0.ɵɵadvance(2);
77
+ i0.ɵɵproperty("ngTemplateOutlet", ctx.errorMessageTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(13, _c0$5, ctx.control, ctx.control == null ? null : ctx.control.errors));
78
+ }
79
+ }, directives: [i1.MatFormField, i1.MatLabel, i2.MatInput, i3.DefaultValueAccessor, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator, i1.MatHint, i1.MatError, i4.NgTemplateOutlet], styles: [".td-dynamic-input-wrapper[_ngcontent-%COMP%]{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-input-wrapper[_ngcontent-%COMP%] .td-dynamic-input-field[_ngcontent-%COMP%]{-ms-flex:1;flex:1;box-sizing:border-box}"] });
80
+ (function () {
81
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicInputComponent, [{
82
+ type: Component,
83
+ args: [{ selector: 'td-dynamic-input', template: "<div class=\"td-dynamic-input-wrapper\">\n <mat-form-field class=\"td-dynamic-input-field\">\n <mat-label>{{ label }}</mat-label>\n <input\n #elementInput\n matInput\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [type]=\"type\"\n [required]=\"required\"\n [attr.name]=\"name\"\n [attr.min]=\"min\"\n [attr.max]=\"max\"\n [attr.minLength]=\"minLength\"\n [attr.maxLength]=\"maxLength\"\n />\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{ control: control, errors: control?.errors }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-input-wrapper{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-input-wrapper .td-dynamic-input-field{-ms-flex:1;flex:1;box-sizing:border-box}\n"] }]
84
+ }], null, null);
85
+ })();
86
+
87
+ function TdDynamicFileInputComponent_ng_template_8_Template(rf, ctx) { }
88
+ function TdDynamicFileInputComponent_button_9_Template(rf, ctx) {
89
+ if (rf & 1) {
90
+ const _r4 = i0.ɵɵgetCurrentView();
91
+ i0.ɵɵelementStart(0, "button", 7);
92
+ i0.ɵɵlistener("click", function TdDynamicFileInputComponent_button_9_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r4); i0.ɵɵnextContext(); const _r2 = i0.ɵɵreference(11); return _r2.clear(); })("keyup.enter", function TdDynamicFileInputComponent_button_9_Template_button_keyup_enter_0_listener() { i0.ɵɵrestoreView(_r4); i0.ɵɵnextContext(); const _r2 = i0.ɵɵreference(11); return _r2.clear(); });
93
+ i0.ɵɵelementStart(1, "mat-icon");
94
+ i0.ɵɵtext(2, "cancel");
95
+ i0.ɵɵelementEnd();
96
+ i0.ɵɵelementEnd();
97
+ }
98
+ }
99
+ const _c0$4 = function (a0, a1) { return { control: a0, errors: a1 }; };
100
+ class TdDynamicFileInputComponent {
101
+ constructor() {
102
+ this.required = undefined;
103
+ this.label = '';
104
+ this.name = '';
105
+ this.hint = '';
106
+ this.errorMessageTemplate = undefined;
107
+ this.placeholder = '';
108
+ }
109
+ _handlefileDrop(value) {
110
+ this.control.setValue(value);
111
+ }
112
+ }
113
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFileInputComponent.ɵfac = function TdDynamicFileInputComponent_Factory(t) { return new (t || TdDynamicFileInputComponent)(); };
114
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFileInputComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicFileInputComponent, selectors: [["td-dynamic-file-input"]], decls: 16, vars: 15, consts: [[1, "td-dynamic-file-input-wrapper"], ["tdFileDrop", "", "floatLabel", "never", 1, "td-dynamic-file-input-field", 3, "disabled", "fileDrop", "click", "keyup.enter", "keyup.delete", "keyup.backspace"], ["matInput", "", "readonly", "", 3, "value", "placeholder", "disabled"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], ["mat-icon-button", "", 3, "click", "keyup.enter", 4, "ngIf"], [1, "td-file-input", 3, "formControl"], ["fileInput", ""], ["mat-icon-button", "", 3, "click", "keyup.enter"]], template: function TdDynamicFileInputComponent_Template(rf, ctx) {
115
+ if (rf & 1) {
116
+ const _r6 = i0.ɵɵgetCurrentView();
117
+ i0.ɵɵelementStart(0, "div", 0);
118
+ i0.ɵɵelementStart(1, "mat-form-field", 1);
119
+ i0.ɵɵlistener("fileDrop", function TdDynamicFileInputComponent_Template_mat_form_field_fileDrop_1_listener($event) { return ctx._handlefileDrop($event); })("click", function TdDynamicFileInputComponent_Template_mat_form_field_click_1_listener() { i0.ɵɵrestoreView(_r6); const _r2 = i0.ɵɵreference(11); return !(ctx.control == null ? null : ctx.control.disabled) && _r2.inputElement.click(); })("keyup.enter", function TdDynamicFileInputComponent_Template_mat_form_field_keyup_enter_1_listener() { i0.ɵɵrestoreView(_r6); const _r2 = i0.ɵɵreference(11); return !(ctx.control == null ? null : ctx.control.disabled) && _r2.inputElement.click(); })("keyup.delete", function TdDynamicFileInputComponent_Template_mat_form_field_keyup_delete_1_listener() { i0.ɵɵrestoreView(_r6); const _r2 = i0.ɵɵreference(11); return _r2.clear(); })("keyup.backspace", function TdDynamicFileInputComponent_Template_mat_form_field_keyup_backspace_1_listener() { i0.ɵɵrestoreView(_r6); const _r2 = i0.ɵɵreference(11); return _r2.clear(); });
120
+ i0.ɵɵelementStart(2, "mat-label");
121
+ i0.ɵɵtext(3);
122
+ i0.ɵɵelementEnd();
123
+ i0.ɵɵelement(4, "input", 2);
124
+ i0.ɵɵelementStart(5, "mat-hint");
125
+ i0.ɵɵtext(6);
126
+ i0.ɵɵelementEnd();
127
+ i0.ɵɵelementStart(7, "mat-error");
128
+ i0.ɵɵtemplate(8, TdDynamicFileInputComponent_ng_template_8_Template, 0, 0, "ng-template", 3);
129
+ i0.ɵɵelementEnd();
130
+ i0.ɵɵelementEnd();
131
+ i0.ɵɵtemplate(9, TdDynamicFileInputComponent_button_9_Template, 3, 0, "button", 4);
132
+ i0.ɵɵelementStart(10, "td-file-input", 5, 6);
133
+ i0.ɵɵelementStart(12, "mat-icon");
134
+ i0.ɵɵtext(13, "folder");
135
+ i0.ɵɵelementEnd();
136
+ i0.ɵɵelementStart(14, "span");
137
+ i0.ɵɵtext(15);
138
+ i0.ɵɵelementEnd();
139
+ i0.ɵɵelementEnd();
140
+ i0.ɵɵelementEnd();
141
+ }
142
+ if (rf & 2) {
143
+ i0.ɵɵadvance(1);
144
+ i0.ɵɵproperty("disabled", ctx.control == null ? null : ctx.control.disabled);
145
+ i0.ɵɵadvance(2);
146
+ i0.ɵɵtextInterpolate(ctx.label);
147
+ i0.ɵɵadvance(1);
148
+ i0.ɵɵproperty("value", ctx.control == null ? null : ctx.control.value == null ? null : ctx.control.value.name)("placeholder", ctx.placeholder)("disabled", ctx.control == null ? null : ctx.control.disabled);
149
+ i0.ɵɵattribute("name", ctx.name);
150
+ i0.ɵɵadvance(2);
151
+ i0.ɵɵtextInterpolate(ctx.hint);
152
+ i0.ɵɵadvance(2);
153
+ i0.ɵɵproperty("ngTemplateOutlet", ctx.errorMessageTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(12, _c0$4, ctx.control, ctx.control == null ? null : ctx.control.errors));
154
+ i0.ɵɵadvance(1);
155
+ i0.ɵɵproperty("ngIf", ctx.control.value);
156
+ i0.ɵɵadvance(1);
157
+ i0.ɵɵproperty("formControl", ctx.control);
158
+ i0.ɵɵadvance(5);
159
+ i0.ɵɵtextInterpolate(ctx.label);
160
+ }
161
+ }, directives: [i1.MatFormField, i2$1.TdFileDropDirective, i1.MatLabel, i2.MatInput, i1.MatHint, i1.MatError, i4.NgTemplateOutlet, i4.NgIf, i5.MatButton, i6.MatIcon, i2$1.TdFileInputComponent, i3.NgControlStatus, i3.FormControlDirective], styles: [".td-dynamic-file-input-wrapper[_ngcontent-%COMP%]{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-file-input-wrapper[_ngcontent-%COMP%] .td-dynamic-file-input-field[_ngcontent-%COMP%]{-ms-flex:1;flex:1;box-sizing:border-box}.td-file-input[_ngcontent-%COMP%]{margin-left:10px}"] });
162
+ (function () {
163
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicFileInputComponent, [{
164
+ type: Component,
165
+ args: [{ selector: 'td-dynamic-file-input', template: "<div class=\"td-dynamic-file-input-wrapper\">\n <mat-form-field\n tdFileDrop\n class=\"td-dynamic-file-input-field\"\n floatLabel=\"never\"\n [disabled]=\"control?.disabled\"\n (fileDrop)=\"_handlefileDrop($event)\"\n (click)=\"!control?.disabled && fileInput.inputElement.click()\"\n (keyup.enter)=\"!control?.disabled && fileInput.inputElement.click()\"\n (keyup.delete)=\"fileInput.clear()\"\n (keyup.backspace)=\"fileInput.clear()\"\n >\n <mat-label>{{ label }}</mat-label>\n <input\n matInput\n [value]=\"control?.value?.name\"\n [placeholder]=\"placeholder\"\n [attr.name]=\"name\"\n [disabled]=\"control?.disabled\"\n readonly\n />\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{ control: control, errors: control?.errors }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n <button mat-icon-button *ngIf=\"control.value\" (click)=\"fileInput.clear()\" (keyup.enter)=\"fileInput.clear()\">\n <mat-icon>cancel</mat-icon>\n </button>\n <td-file-input class=\"td-file-input\" #fileInput [formControl]=\"control\">\n <mat-icon>folder</mat-icon>\n <span>{{ label }}</span>\n </td-file-input>\n</div>\n", styles: [".td-dynamic-file-input-wrapper{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-file-input-wrapper .td-dynamic-file-input-field{-ms-flex:1;flex:1;box-sizing:border-box}.td-file-input{margin-left:10px}\n"] }]
166
+ }], null, null);
167
+ })();
168
+
169
+ function TdDynamicTextareaComponent_ng_template_9_Template(rf, ctx) { }
170
+ const _c0$3 = function (a0, a1) { return { control: a0, errors: a1 }; };
171
+ class TdDynamicTextareaComponent {
172
+ constructor() {
173
+ this.label = '';
174
+ this.hint = '';
175
+ this.name = '';
176
+ this.required = undefined;
177
+ this.errorMessageTemplate = undefined;
178
+ this.placeholder = '';
179
+ }
180
+ }
181
+ /** @nocollapse */ /** @nocollapse */ TdDynamicTextareaComponent.ɵfac = function TdDynamicTextareaComponent_Factory(t) { return new (t || TdDynamicTextareaComponent)(); };
182
+ /** @nocollapse */ /** @nocollapse */ TdDynamicTextareaComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicTextareaComponent, selectors: [["td-dynamic-textarea"]], decls: 10, vars: 11, consts: [[1, "td-dynamic-textarea-wrapper"], [1, "td-dynamic-textarea-field"], ["matInput", "", "rows", "4", 3, "formControl", "placeholder", "required"], ["elementInput", ""], [3, "ngTemplateOutlet", "ngTemplateOutletContext"]], template: function TdDynamicTextareaComponent_Template(rf, ctx) {
183
+ if (rf & 1) {
184
+ i0.ɵɵelementStart(0, "div", 0);
185
+ i0.ɵɵelementStart(1, "mat-form-field", 1);
186
+ i0.ɵɵelementStart(2, "mat-label");
187
+ i0.ɵɵtext(3);
188
+ i0.ɵɵelementEnd();
189
+ i0.ɵɵelement(4, "textarea", 2, 3);
190
+ i0.ɵɵelementStart(6, "mat-hint");
191
+ i0.ɵɵtext(7);
192
+ i0.ɵɵelementEnd();
193
+ i0.ɵɵelementStart(8, "mat-error");
194
+ i0.ɵɵtemplate(9, TdDynamicTextareaComponent_ng_template_9_Template, 0, 0, "ng-template", 4);
195
+ i0.ɵɵelementEnd();
196
+ i0.ɵɵelementEnd();
197
+ i0.ɵɵelementEnd();
198
+ }
199
+ if (rf & 2) {
200
+ i0.ɵɵadvance(3);
201
+ i0.ɵɵtextInterpolate(ctx.label);
202
+ i0.ɵɵadvance(1);
203
+ i0.ɵɵproperty("formControl", ctx.control)("placeholder", ctx.placeholder)("required", ctx.required);
204
+ i0.ɵɵattribute("name", ctx.name);
205
+ i0.ɵɵadvance(3);
206
+ i0.ɵɵtextInterpolate(ctx.hint);
207
+ i0.ɵɵadvance(2);
208
+ i0.ɵɵproperty("ngTemplateOutlet", ctx.errorMessageTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(8, _c0$3, ctx.control, ctx.control == null ? null : ctx.control.errors));
209
+ }
210
+ }, directives: [i1.MatFormField, i1.MatLabel, i2.MatInput, i3.DefaultValueAccessor, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator, i1.MatHint, i1.MatError, i4.NgTemplateOutlet], styles: [".td-dynamic-textarea-wrapper[_ngcontent-%COMP%]{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-textarea-wrapper[_ngcontent-%COMP%] .td-dynamic-textarea-field[_ngcontent-%COMP%]{-ms-flex:1;flex:1;box-sizing:border-box}"] });
211
+ (function () {
212
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicTextareaComponent, [{
213
+ type: Component,
214
+ args: [{ selector: 'td-dynamic-textarea', template: "<div class=\"td-dynamic-textarea-wrapper\">\n <mat-form-field class=\"td-dynamic-textarea-field\">\n <mat-label>{{ label }}</mat-label>\n <textarea\n #elementInput\n matInput\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [required]=\"required\"\n [attr.name]=\"name\"\n rows=\"4\"\n ></textarea>\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{ control: control, errors: control?.errors }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-textarea-wrapper{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-textarea-wrapper .td-dynamic-textarea-field{-ms-flex:1;flex:1;box-sizing:border-box}\n"] }]
215
+ }], null, null);
216
+ })();
217
+
218
+ class TdDynamicSlideToggleComponent {
219
+ constructor() {
220
+ this.label = '';
221
+ this.name = '';
222
+ this.hint = '';
223
+ this.required = false;
224
+ }
225
+ }
226
+ /** @nocollapse */ /** @nocollapse */ TdDynamicSlideToggleComponent.ɵfac = function TdDynamicSlideToggleComponent_Factory(t) { return new (t || TdDynamicSlideToggleComponent)(); };
227
+ /** @nocollapse */ /** @nocollapse */ TdDynamicSlideToggleComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicSlideToggleComponent, selectors: [["td-dynamic-slide-toggle"]], decls: 5, vars: 5, consts: [[1, "td-dynamic-slide-toggle-wrapper"], [3, "formControl", "required"], [1, "mat-hint", "td-dynamic-element-hint"]], template: function TdDynamicSlideToggleComponent_Template(rf, ctx) {
228
+ if (rf & 1) {
229
+ i0.ɵɵelementStart(0, "div", 0);
230
+ i0.ɵɵelementStart(1, "mat-slide-toggle", 1);
231
+ i0.ɵɵtext(2);
232
+ i0.ɵɵelementEnd();
233
+ i0.ɵɵelementStart(3, "span", 2);
234
+ i0.ɵɵtext(4);
235
+ i0.ɵɵelementEnd();
236
+ i0.ɵɵelementEnd();
237
+ }
238
+ if (rf & 2) {
239
+ i0.ɵɵadvance(1);
240
+ i0.ɵɵproperty("formControl", ctx.control)("required", ctx.required);
241
+ i0.ɵɵattribute("name", ctx.name);
242
+ i0.ɵɵadvance(1);
243
+ i0.ɵɵtextInterpolate1(" ", ctx.label, " ");
244
+ i0.ɵɵadvance(2);
245
+ i0.ɵɵtextInterpolate(ctx.hint);
246
+ }
247
+ }, directives: [i1$1.MatSlideToggle, i1$1.MatSlideToggleRequiredValidator, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator], styles: [""] });
248
+ (function () {
249
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicSlideToggleComponent, [{
250
+ type: Component,
251
+ args: [{ selector: 'td-dynamic-slide-toggle', template: "<div class=\"td-dynamic-slide-toggle-wrapper\">\n <mat-slide-toggle [formControl]=\"control\" [attr.name]=\"name\" [required]=\"required\">\n {{ label }}\n </mat-slide-toggle>\n <span class=\"mat-hint td-dynamic-element-hint\">{{ hint }}</span>\n</div>\n", styles: [""] }]
252
+ }], null, null);
253
+ })();
254
+
255
+ class TdDynamicCheckboxComponent {
256
+ constructor() {
257
+ this.label = '';
258
+ this.name = '';
259
+ this.hint = '';
260
+ this.required = false;
261
+ }
262
+ }
263
+ /** @nocollapse */ /** @nocollapse */ TdDynamicCheckboxComponent.ɵfac = function TdDynamicCheckboxComponent_Factory(t) { return new (t || TdDynamicCheckboxComponent)(); };
264
+ /** @nocollapse */ /** @nocollapse */ TdDynamicCheckboxComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicCheckboxComponent, selectors: [["td-dynamic-checkbox"]], decls: 5, vars: 5, consts: [[1, "td-dynamic-checkbox-wrapper"], [3, "formControl", "name", "required"], [1, "mat-hint", "td-dynamic-element-hint"]], template: function TdDynamicCheckboxComponent_Template(rf, ctx) {
265
+ if (rf & 1) {
266
+ i0.ɵɵelementStart(0, "div", 0);
267
+ i0.ɵɵelementStart(1, "mat-checkbox", 1);
268
+ i0.ɵɵtext(2);
269
+ i0.ɵɵelementEnd();
270
+ i0.ɵɵelementStart(3, "span", 2);
271
+ i0.ɵɵtext(4);
272
+ i0.ɵɵelementEnd();
273
+ i0.ɵɵelementEnd();
274
+ }
275
+ if (rf & 2) {
276
+ i0.ɵɵadvance(1);
277
+ i0.ɵɵproperty("formControl", ctx.control)("name", ctx.name)("required", ctx.required);
278
+ i0.ɵɵadvance(1);
279
+ i0.ɵɵtextInterpolate1(" ", ctx.label, " ");
280
+ i0.ɵɵadvance(2);
281
+ i0.ɵɵtextInterpolate(ctx.hint);
282
+ }
283
+ }, directives: [i1$2.MatCheckbox, i1$2.MatCheckboxRequiredValidator, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator], styles: [""] });
284
+ (function () {
285
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicCheckboxComponent, [{
286
+ type: Component,
287
+ args: [{ selector: 'td-dynamic-checkbox', template: "<div class=\"td-dynamic-checkbox-wrapper\">\n <mat-checkbox [formControl]=\"control\" [name]=\"name\" [required]=\"required\">\n {{ label }}\n </mat-checkbox>\n <span class=\"mat-hint td-dynamic-element-hint\">{{ hint }}</span>\n</div>\n", styles: [""] }]
288
+ }], null, null);
289
+ })();
290
+
291
+ function TdDynamicSliderComponent_span_4_Template(rf, ctx) {
292
+ if (rf & 1) {
293
+ i0.ɵɵelementStart(0, "span", 8);
294
+ i0.ɵɵtext(1, "*");
295
+ i0.ɵɵelementEnd();
296
+ }
297
+ }
298
+ class TdDynamicSliderComponent {
299
+ constructor(_changeDetectorRef) {
300
+ this._changeDetectorRef = _changeDetectorRef;
301
+ this.label = '';
302
+ this.required = undefined;
303
+ this.name = '';
304
+ this.hint = '';
305
+ this.min = undefined;
306
+ this.max = undefined;
307
+ }
308
+ _handleBlur() {
309
+ setTimeout(() => {
310
+ this._changeDetectorRef.markForCheck();
311
+ });
312
+ }
313
+ }
314
+ /** @nocollapse */ /** @nocollapse */ TdDynamicSliderComponent.ɵfac = function TdDynamicSliderComponent_Factory(t) { return new (t || TdDynamicSliderComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
315
+ /** @nocollapse */ /** @nocollapse */ TdDynamicSliderComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicSliderComponent, selectors: [["td-dynamic-slider"]], decls: 10, vars: 10, consts: [[1, "td-dynamic-slider-wrapper", "mat-form-field", "mat-form-field-can-float", "mat-form-field-should-float"], [1, "mat-form-field-label-wrapper"], [1, "mat-form-field-label", "mat-primary", "td-slider-label"], ["class", "mat-form-field-required-marker", 4, "ngIf"], [1, "td-dynamic-slider-field"], ["thumbLabel", "", "tickInterval", "auto", 1, "td-dynamic-slider", 3, "formControl", "min", "max", "required", "blur"], ["slider", ""], [1, "mat-hint", "td-dynamic-element-hint"], [1, "mat-form-field-required-marker"]], template: function TdDynamicSliderComponent_Template(rf, ctx) {
316
+ if (rf & 1) {
317
+ i0.ɵɵelementStart(0, "div", 0);
318
+ i0.ɵɵelementStart(1, "span", 1);
319
+ i0.ɵɵelementStart(2, "label", 2);
320
+ i0.ɵɵtext(3);
321
+ i0.ɵɵtemplate(4, TdDynamicSliderComponent_span_4_Template, 2, 0, "span", 3);
322
+ i0.ɵɵelementEnd();
323
+ i0.ɵɵelementEnd();
324
+ i0.ɵɵelementStart(5, "div", 4);
325
+ i0.ɵɵelementStart(6, "mat-slider", 5, 6);
326
+ i0.ɵɵlistener("blur", function TdDynamicSliderComponent_Template_mat_slider_blur_6_listener() { return ctx._handleBlur(); });
327
+ i0.ɵɵelementEnd();
328
+ i0.ɵɵelementEnd();
329
+ i0.ɵɵelementStart(8, "span", 7);
330
+ i0.ɵɵtext(9);
331
+ i0.ɵɵelementEnd();
332
+ i0.ɵɵelementEnd();
333
+ }
334
+ if (rf & 2) {
335
+ const _r1 = i0.ɵɵreference(7);
336
+ i0.ɵɵclassProp("mat-focused", _r1._isActive);
337
+ i0.ɵɵadvance(3);
338
+ i0.ɵɵtextInterpolate1(" ", ctx.label, " ");
339
+ i0.ɵɵadvance(1);
340
+ i0.ɵɵproperty("ngIf", ctx.required && !(ctx.control == null ? null : ctx.control.disabled));
341
+ i0.ɵɵadvance(2);
342
+ i0.ɵɵproperty("formControl", ctx.control)("min", ctx.min)("max", ctx.max)("required", ctx.required);
343
+ i0.ɵɵattribute("name", ctx.name);
344
+ i0.ɵɵadvance(3);
345
+ i0.ɵɵtextInterpolate(ctx.hint);
346
+ }
347
+ }, directives: [i4.NgIf, i2$2.MatSlider, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator], styles: ["[_nghost-%COMP%] .td-dynamic-slider-wrapper[_ngcontent-%COMP%]{display:block}.td-dynamic-slider-field[_ngcontent-%COMP%]{position:relative;-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-slider-field[_ngcontent-%COMP%] .td-dynamic-slider[_ngcontent-%COMP%]{-ms-flex:1;flex:1}"] });
348
+ (function () {
349
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicSliderComponent, [{
350
+ type: Component,
351
+ args: [{ selector: 'td-dynamic-slider', template: "<div\n class=\"td-dynamic-slider-wrapper mat-form-field mat-form-field-can-float mat-form-field-should-float\"\n [class.mat-focused]=\"slider._isActive\"\n>\n <span class=\"mat-form-field-label-wrapper\">\n <label class=\"mat-form-field-label mat-primary td-slider-label\">\n {{ label }}\n <span *ngIf=\"required && !control?.disabled\" class=\"mat-form-field-required-marker\">*</span>\n </label>\n </span>\n <div class=\"td-dynamic-slider-field\">\n <mat-slider\n #slider\n class=\"td-dynamic-slider\"\n [formControl]=\"control\"\n [attr.name]=\"name\"\n [min]=\"min\"\n [max]=\"max\"\n thumbLabel\n tickInterval=\"auto\"\n [required]=\"required\"\n (blur)=\"_handleBlur()\"\n ></mat-slider>\n </div>\n <span class=\"mat-hint td-dynamic-element-hint\">{{ hint }}</span>\n</div>\n", styles: [":host .td-dynamic-slider-wrapper{display:block}.td-dynamic-slider-field{position:relative;-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-slider-field .td-dynamic-slider{-ms-flex:1;flex:1}\n"] }]
352
+ }], function () { return [{ type: i0.ChangeDetectorRef }]; }, null);
353
+ })();
354
+
355
+ function TdDynamicSelectComponent_mat_option_5_Template(rf, ctx) {
356
+ if (rf & 1) {
357
+ i0.ɵɵelementStart(0, "mat-option", 5);
358
+ i0.ɵɵtext(1);
359
+ i0.ɵɵelementEnd();
360
+ }
361
+ if (rf & 2) {
362
+ const selection_r2 = ctx.$implicit;
363
+ i0.ɵɵproperty("value", selection_r2.value || selection_r2);
364
+ i0.ɵɵadvance(1);
365
+ i0.ɵɵtextInterpolate1(" ", selection_r2.label || selection_r2, " ");
366
+ }
367
+ }
368
+ function TdDynamicSelectComponent_ng_template_9_Template(rf, ctx) { }
369
+ const _c0$2 = function (a0, a1) { return { control: a0, errors: a1 }; };
370
+ class TdDynamicSelectComponent {
371
+ constructor() {
372
+ this.label = '';
373
+ this.hint = '';
374
+ this.name = '';
375
+ this.required = undefined;
376
+ this.selections = undefined;
377
+ this.multiple = undefined;
378
+ this.errorMessageTemplate = undefined;
379
+ this.placeholder = '';
380
+ }
381
+ }
382
+ /** @nocollapse */ /** @nocollapse */ TdDynamicSelectComponent.ɵfac = function TdDynamicSelectComponent_Factory(t) { return new (t || TdDynamicSelectComponent)(); };
383
+ /** @nocollapse */ /** @nocollapse */ TdDynamicSelectComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicSelectComponent, selectors: [["td-dynamic-select"]], decls: 10, vars: 13, consts: [[1, "td-dynamic-select-wrapper"], [1, "td-dynamic-select-field"], [3, "formControl", "placeholder", "required", "multiple"], [3, "value", 4, "ngFor", "ngForOf"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], [3, "value"]], template: function TdDynamicSelectComponent_Template(rf, ctx) {
384
+ if (rf & 1) {
385
+ i0.ɵɵelementStart(0, "div", 0);
386
+ i0.ɵɵelementStart(1, "mat-form-field", 1);
387
+ i0.ɵɵelementStart(2, "mat-label");
388
+ i0.ɵɵtext(3);
389
+ i0.ɵɵelementEnd();
390
+ i0.ɵɵelementStart(4, "mat-select", 2);
391
+ i0.ɵɵtemplate(5, TdDynamicSelectComponent_mat_option_5_Template, 2, 2, "mat-option", 3);
392
+ i0.ɵɵelementEnd();
393
+ i0.ɵɵelementStart(6, "mat-hint");
394
+ i0.ɵɵtext(7);
395
+ i0.ɵɵelementEnd();
396
+ i0.ɵɵelementStart(8, "mat-error");
397
+ i0.ɵɵtemplate(9, TdDynamicSelectComponent_ng_template_9_Template, 0, 0, "ng-template", 4);
398
+ i0.ɵɵelementEnd();
399
+ i0.ɵɵelementEnd();
400
+ i0.ɵɵelementEnd();
401
+ }
402
+ if (rf & 2) {
403
+ i0.ɵɵadvance(3);
404
+ i0.ɵɵtextInterpolate(ctx.label);
405
+ i0.ɵɵadvance(1);
406
+ i0.ɵɵproperty("formControl", ctx.control)("placeholder", ctx.placeholder)("required", ctx.required)("multiple", ctx.multiple);
407
+ i0.ɵɵattribute("name", ctx.name);
408
+ i0.ɵɵadvance(1);
409
+ i0.ɵɵproperty("ngForOf", ctx.selections);
410
+ i0.ɵɵadvance(2);
411
+ i0.ɵɵtextInterpolate(ctx.hint);
412
+ i0.ɵɵadvance(2);
413
+ i0.ɵɵproperty("ngTemplateOutlet", ctx.errorMessageTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(10, _c0$2, ctx.control, ctx.control == null ? null : ctx.control.errors));
414
+ }
415
+ }, directives: [i1.MatFormField, i1.MatLabel, i2$3.MatSelect, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator, i4.NgForOf, i5$1.MatOption, i1.MatHint, i1.MatError, i4.NgTemplateOutlet], styles: [".td-dynamic-select-wrapper[_ngcontent-%COMP%]{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-select-wrapper[_ngcontent-%COMP%] .td-dynamic-select-field[_ngcontent-%COMP%]{-ms-flex:1;flex:1;box-sizing:border-box}"] });
416
+ (function () {
417
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicSelectComponent, [{
418
+ type: Component,
419
+ args: [{ selector: 'td-dynamic-select', template: "<div class=\"td-dynamic-select-wrapper\">\n <mat-form-field class=\"td-dynamic-select-field\">\n <mat-label>{{ label }}</mat-label>\n <mat-select\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [required]=\"required\"\n [attr.name]=\"name\"\n [multiple]=\"multiple\"\n >\n <mat-option *ngFor=\"let selection of selections\" [value]=\"selection.value || selection\">\n {{ selection.label || selection }}\n </mat-option>\n </mat-select>\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{ control: control, errors: control?.errors }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-select-wrapper{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-select-wrapper .td-dynamic-select-field{-ms-flex:1;flex:1;box-sizing:border-box}\n"] }]
420
+ }], null, null);
421
+ })();
422
+
423
+ function TdDynamicDatepickerComponent_ng_template_9_Template(rf, ctx) { }
424
+ const _c0$1 = function (a0, a1) { return { control: a0, errors: a1 }; };
425
+ class TdDynamicDatepickerComponent {
426
+ constructor() {
427
+ this.label = '';
428
+ this.hint = '';
429
+ this.name = '';
430
+ this.type = undefined;
431
+ this.required = undefined;
432
+ this.min = undefined;
433
+ this.max = undefined;
434
+ this.errorMessageTemplate = undefined;
435
+ this.placeholder = '';
436
+ }
437
+ }
438
+ /** @nocollapse */ /** @nocollapse */ TdDynamicDatepickerComponent.ɵfac = function TdDynamicDatepickerComponent_Factory(t) { return new (t || TdDynamicDatepickerComponent)(); };
439
+ /** @nocollapse */ /** @nocollapse */ TdDynamicDatepickerComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicDatepickerComponent, selectors: [["td-dynamic-datepicker"]], decls: 13, vars: 15, consts: [[1, "td-dynamic-datepicker-wrapper"], [1, "td-dynamic-datepicker-field"], ["matInput", "", 3, "matDatepicker", "formControl", "placeholder", "required", "name", "min", "max"], ["elementInput", ""], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], ["matSuffix", "", 3, "for"], ["dynamicDatePicker", ""]], template: function TdDynamicDatepickerComponent_Template(rf, ctx) {
440
+ if (rf & 1) {
441
+ i0.ɵɵelementStart(0, "div", 0);
442
+ i0.ɵɵelementStart(1, "mat-form-field", 1);
443
+ i0.ɵɵelementStart(2, "mat-label");
444
+ i0.ɵɵtext(3);
445
+ i0.ɵɵelementEnd();
446
+ i0.ɵɵelement(4, "input", 2, 3);
447
+ i0.ɵɵelementStart(6, "mat-hint");
448
+ i0.ɵɵtext(7);
449
+ i0.ɵɵelementEnd();
450
+ i0.ɵɵelementStart(8, "mat-error");
451
+ i0.ɵɵtemplate(9, TdDynamicDatepickerComponent_ng_template_9_Template, 0, 0, "ng-template", 4);
452
+ i0.ɵɵelementEnd();
453
+ i0.ɵɵelement(10, "mat-datepicker-toggle", 5);
454
+ i0.ɵɵelement(11, "mat-datepicker", null, 6);
455
+ i0.ɵɵelementEnd();
456
+ i0.ɵɵelementEnd();
457
+ }
458
+ if (rf & 2) {
459
+ const _r2 = i0.ɵɵreference(12);
460
+ i0.ɵɵadvance(3);
461
+ i0.ɵɵtextInterpolate(ctx.label);
462
+ i0.ɵɵadvance(1);
463
+ i0.ɵɵproperty("matDatepicker", _r2)("formControl", ctx.control)("placeholder", ctx.placeholder)("required", ctx.required)("name", ctx.name)("min", ctx.min)("max", ctx.max);
464
+ i0.ɵɵadvance(3);
465
+ i0.ɵɵtextInterpolate(ctx.hint);
466
+ i0.ɵɵadvance(2);
467
+ i0.ɵɵproperty("ngTemplateOutlet", ctx.errorMessageTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(12, _c0$1, ctx.control, ctx.control == null ? null : ctx.control.errors));
468
+ i0.ɵɵadvance(1);
469
+ i0.ɵɵproperty("for", _r2);
470
+ }
471
+ }, directives: [i1.MatFormField, i1.MatLabel, i2.MatInput, i3$1.MatDatepickerInput, i3.DefaultValueAccessor, i3.NgControlStatus, i3.FormControlDirective, i3.RequiredValidator, i1.MatHint, i1.MatError, i4.NgTemplateOutlet, i3$1.MatDatepickerToggle, i1.MatSuffix, i3$1.MatDatepicker], styles: [".td-dynamic-datepicker-wrapper[_ngcontent-%COMP%]{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-datepicker-wrapper[_ngcontent-%COMP%] .td-dynamic-datepicker-field[_ngcontent-%COMP%]{-ms-flex:1;flex:1;box-sizing:border-box}"] });
472
+ (function () {
473
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicDatepickerComponent, [{
474
+ type: Component,
475
+ args: [{ selector: 'td-dynamic-datepicker', template: "<div class=\"td-dynamic-datepicker-wrapper\">\n <mat-form-field class=\"td-dynamic-datepicker-field\">\n <mat-label>{{ label }}</mat-label>\n <input\n #elementInput\n matInput\n [matDatepicker]=\"dynamicDatePicker\"\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [required]=\"required\"\n [name]=\"name\"\n [min]=\"min\"\n [max]=\"max\"\n />\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{ control: control, errors: control?.errors }\"\n ></ng-template>\n </mat-error>\n <mat-datepicker-toggle matSuffix [for]=\"dynamicDatePicker\"></mat-datepicker-toggle>\n <mat-datepicker #dynamicDatePicker></mat-datepicker>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-datepicker-wrapper{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;box-sizing:border-box}.td-dynamic-datepicker-wrapper .td-dynamic-datepicker-field{-ms-flex:1;flex:1;box-sizing:border-box}\n"] }]
476
+ }], null, null);
477
+ })();
478
+
479
+ var TdDynamicType;
480
+ (function (TdDynamicType) {
481
+ TdDynamicType["Text"] = "text";
482
+ TdDynamicType["Boolean"] = "boolean";
483
+ TdDynamicType["Number"] = "number";
484
+ TdDynamicType["Array"] = "array";
485
+ TdDynamicType["Date"] = "date";
486
+ })(TdDynamicType || (TdDynamicType = {}));
487
+ var TdDynamicElement;
488
+ (function (TdDynamicElement) {
489
+ TdDynamicElement["Input"] = "input";
490
+ TdDynamicElement["Datepicker"] = "datepicker";
491
+ TdDynamicElement["Password"] = "password";
492
+ TdDynamicElement["Textarea"] = "textarea";
493
+ TdDynamicElement["Slider"] = "slider";
494
+ TdDynamicElement["SlideToggle"] = "slide-toggle";
495
+ TdDynamicElement["Checkbox"] = "checkbox";
496
+ TdDynamicElement["Select"] = "select";
497
+ TdDynamicElement["FileInput"] = "file-input";
498
+ })(TdDynamicElement || (TdDynamicElement = {}));
499
+ const DYNAMIC_ELEMENT_NAME_REGEX = /^[^0-9][^\@]*$/;
500
+ class TdDynamicFormsService {
501
+ /**
502
+ * Method to validate if the [name] is a proper element name.
503
+ * Throws error if name is not valid.
504
+ */
505
+ validateDynamicElementName(name) {
506
+ if (!DYNAMIC_ELEMENT_NAME_REGEX.test(name)) {
507
+ throw new Error('Dynamic element name: "${name}" is not valid.');
508
+ }
509
+ }
510
+ /**
511
+ * Gets component to be rendered depending on [TdDynamicElement | TdDynamicType]
512
+ * Throws error if it does not exists or not supported.
513
+ */
514
+ getDynamicElement(element) {
515
+ switch (element) {
516
+ case TdDynamicType.Text:
517
+ case TdDynamicType.Number:
518
+ case TdDynamicElement.Input:
519
+ case TdDynamicElement.Password:
520
+ return TdDynamicInputComponent;
521
+ case TdDynamicElement.Textarea:
522
+ return TdDynamicTextareaComponent;
523
+ case TdDynamicType.Boolean:
524
+ case TdDynamicElement.SlideToggle:
525
+ return TdDynamicSlideToggleComponent;
526
+ case TdDynamicElement.Checkbox:
527
+ return TdDynamicCheckboxComponent;
528
+ case TdDynamicElement.Slider:
529
+ return TdDynamicSliderComponent;
530
+ case TdDynamicType.Array:
531
+ case TdDynamicElement.Select:
532
+ return TdDynamicSelectComponent;
533
+ case TdDynamicElement.FileInput:
534
+ return TdDynamicFileInputComponent;
535
+ case TdDynamicElement.Datepicker:
536
+ case TdDynamicType.Date:
537
+ return TdDynamicDatepickerComponent;
538
+ default:
539
+ throw new Error(`Error: type ${element} does not exist or not supported.`);
540
+ }
541
+ }
542
+ /**
543
+ * Creates form control for element depending [ITdDynamicElementConfig] properties.
544
+ */
545
+ createFormControl(config) {
546
+ const validator = this.createValidators(config);
547
+ return new FormControl({ value: config.default, disabled: config.disabled }, validator);
548
+ }
549
+ /**
550
+ * Creates form validationdepending [ITdDynamicElementConfig] properties.
551
+ */
552
+ createValidators(config) {
553
+ let validator;
554
+ if (config.required) {
555
+ validator = Validators.required;
556
+ }
557
+ if (config.max || config.max === 0) {
558
+ validator = Validators.compose([validator, Validators.max(parseFloat(config.max))]);
559
+ }
560
+ if (config.min || config.min === 0) {
561
+ validator = Validators.compose([validator, Validators.min(parseFloat(config.min))]);
562
+ }
563
+ if (config.maxLength || config.maxLength === 0) {
564
+ validator = Validators.compose([validator, Validators.maxLength(parseFloat(config.maxLength))]);
565
+ }
566
+ if (config.minLength || config.minLength === 0) {
567
+ validator = Validators.compose([validator, Validators.minLength(parseFloat(config.minLength))]);
568
+ }
569
+ // Add provided custom validators to the validator function
570
+ if (config.validators) {
571
+ config.validators.forEach((validatorConfig) => {
572
+ validator = Validators.compose([validator, validatorConfig.validator]);
573
+ });
574
+ }
575
+ return validator;
576
+ }
577
+ }
578
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFormsService.ɵfac = function TdDynamicFormsService_Factory(t) { return new (t || TdDynamicFormsService)(); };
579
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFormsService.ɵprov = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjectable({ token: TdDynamicFormsService, factory: TdDynamicFormsService.ɵfac });
580
+ (function () {
581
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicFormsService, [{
582
+ type: Injectable
583
+ }], null, null);
584
+ })();
585
+ function DYNAMIC_FORMS_PROVIDER_FACTORY(parent) {
586
+ return parent || new TdDynamicFormsService();
587
+ }
588
+ const DYNAMIC_FORMS_PROVIDER = {
589
+ // If there is already a service available, use that. Otherwise, provide a new one.
590
+ provide: TdDynamicFormsService,
591
+ deps: [[new Optional(), new SkipSelf(), TdDynamicFormsService]],
592
+ useFactory: DYNAMIC_FORMS_PROVIDER_FACTORY,
593
+ };
594
+
595
+ class TdDynamicElementBase {
596
+ constructor(_changeDetectorRef) {
597
+ this._changeDetectorRef = _changeDetectorRef;
598
+ }
599
+ }
600
+ /* tslint:disable-next-line */
601
+ const _TdDynamicElementMixinBase = mixinControlValueAccessor(TdDynamicElementBase);
602
+ class TdDynamicFormsErrorTemplateDirective extends TemplatePortalDirective {
603
+ constructor(templateRef, viewContainerRef) {
604
+ super(templateRef, viewContainerRef);
605
+ this.templateRef = templateRef;
606
+ }
607
+ }
608
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFormsErrorTemplateDirective.ɵfac = function TdDynamicFormsErrorTemplateDirective_Factory(t) { return new (t || TdDynamicFormsErrorTemplateDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
609
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFormsErrorTemplateDirective.ɵdir = /** @pureOrBreakMyCode */ i0.ɵɵdefineDirective({ type: TdDynamicFormsErrorTemplateDirective, selectors: [["ng-template", "tdDynamicFormsError", ""]], inputs: { tdDynamicFormsError: "tdDynamicFormsError" }, features: [i0.ɵɵInheritDefinitionFeature] });
610
+ (function () {
611
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicFormsErrorTemplateDirective, [{
612
+ type: Directive,
613
+ args: [{ selector: '[tdDynamicFormsError]ng-template' }]
614
+ }], function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, { tdDynamicFormsError: [{
615
+ type: Input
616
+ }] });
617
+ })();
618
+ class TdDynamicElementDirective {
619
+ constructor(viewContainer) {
620
+ this.viewContainer = viewContainer;
621
+ }
622
+ }
623
+ /** @nocollapse */ /** @nocollapse */ TdDynamicElementDirective.ɵfac = function TdDynamicElementDirective_Factory(t) { return new (t || TdDynamicElementDirective)(i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
624
+ /** @nocollapse */ /** @nocollapse */ TdDynamicElementDirective.ɵdir = /** @pureOrBreakMyCode */ i0.ɵɵdefineDirective({ type: TdDynamicElementDirective, selectors: [["", "tdDynamicContainer", ""]] });
625
+ (function () {
626
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicElementDirective, [{
627
+ type: Directive,
628
+ args: [{
629
+ selector: '[tdDynamicContainer]',
630
+ }]
631
+ }], function () { return [{ type: i0.ViewContainerRef }]; }, null);
632
+ })();
633
+ class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
634
+ constructor(_componentFactoryResolver, _dynamicFormsService, _changeDetectorRef) {
635
+ super(_changeDetectorRef);
636
+ this._componentFactoryResolver = _componentFactoryResolver;
637
+ this._dynamicFormsService = _dynamicFormsService;
638
+ /**
639
+ * Sets label to be displayed.
640
+ */
641
+ this.label = '';
642
+ /**
643
+ * Sets hint to be displayed.
644
+ */
645
+ this.hint = '';
646
+ /**
647
+ * Sets name to be displayed as attribute.
648
+ */
649
+ this.name = '';
650
+ /**
651
+ * Sets type or element of element to be rendered.
652
+ * Throws error if does not exist or no supported.
653
+ */
654
+ this.type = undefined;
655
+ /**
656
+ * Sets required validation checkup (if supported by element).
657
+ */
658
+ this.required = undefined;
659
+ /**
660
+ * Sets min validation checkup (if supported by element).
661
+ */
662
+ this.min = undefined;
663
+ /**
664
+ * Sets max validation checkup (if supported by element).
665
+ */
666
+ this.max = undefined;
667
+ /**
668
+ * Sets minLength validation checkup (if supported by element).
669
+ */
670
+ this.minLength = undefined;
671
+ /**
672
+ * Sets maxLength validation checkup (if supported by element).
673
+ */
674
+ this.maxLength = undefined;
675
+ /**
676
+ * Sets selections for array elements (if supported by element).
677
+ */
678
+ this.selections = undefined;
679
+ /**
680
+ * Sets multiple property for array elements (if supported by element).
681
+ */
682
+ this.multiple = undefined;
683
+ /**
684
+ * Sets error message template so it can be injected into dynamic components.
685
+ */
686
+ this.errorMessageTemplate = undefined;
687
+ /**
688
+ * Sets the placeholder message
689
+ */
690
+ this.placeholder = '';
691
+ }
692
+ get maxAttr() {
693
+ return this.max;
694
+ }
695
+ get minAttr() {
696
+ return this.min;
697
+ }
698
+ ngOnInit() {
699
+ const component = this.type instanceof Type ? this.type : this._dynamicFormsService.getDynamicElement(this.type);
700
+ const ref = this._componentFactoryResolver
701
+ .resolveComponentFactory(component)
702
+ .create(this.childElement.viewContainer.injector);
703
+ this.childElement.viewContainer.insert(ref.hostView);
704
+ this._instance = ref.instance;
705
+ this._instance.control = this.dynamicControl;
706
+ this._instance.label = this.label;
707
+ this._instance.hint = this.hint;
708
+ this._instance.name = this.name;
709
+ this._instance.type = this.type;
710
+ this._instance.value = this.value;
711
+ this._instance.required = this.required;
712
+ this._instance.min = this.min;
713
+ this._instance.max = this.max;
714
+ this._instance.minLength = this.minLength;
715
+ this._instance.maxLength = this.maxLength;
716
+ this._instance.selections = this.selections;
717
+ this._instance.multiple = this.multiple;
718
+ this._instance.errorMessageTemplate = this.errorMessageTemplate;
719
+ this._instance.placeholder = this.placeholder;
720
+ if (this.customConfig) {
721
+ Object.getOwnPropertyNames(this.customConfig).forEach((name) => {
722
+ this._instance[name] = this.customConfig[name];
723
+ });
724
+ }
725
+ }
726
+ /**
727
+ * Reassign any inputs that have changed
728
+ */
729
+ ngOnChanges(changes) {
730
+ if (this._instance) {
731
+ for (const prop of Object.keys(changes)) {
732
+ this._instance[prop] = changes[prop].currentValue;
733
+ }
734
+ }
735
+ }
736
+ }
737
+ /** @nocollapse */ /** @nocollapse */ TdDynamicElementComponent.ɵfac = function TdDynamicElementComponent_Factory(t) { return new (t || TdDynamicElementComponent)(i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver), i0.ɵɵdirectiveInject(TdDynamicFormsService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
738
+ /** @nocollapse */ /** @nocollapse */ TdDynamicElementComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicElementComponent, selectors: [["td-dynamic-element"]], viewQuery: function TdDynamicElementComponent_Query(rf, ctx) {
739
+ if (rf & 1) {
740
+ i0.ɵɵviewQuery(TdDynamicElementDirective, 7);
741
+ }
742
+ if (rf & 2) {
743
+ let _t;
744
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childElement = _t.first);
745
+ }
746
+ }, hostVars: 2, hostBindings: function TdDynamicElementComponent_HostBindings(rf, ctx) {
747
+ if (rf & 2) {
748
+ i0.ɵɵattribute("max", ctx.maxAttr)("min", ctx.minAttr);
749
+ }
750
+ }, inputs: { dynamicControl: "dynamicControl", label: "label", hint: "hint", name: "name", type: "type", required: "required", min: "min", max: "max", minLength: "minLength", maxLength: "maxLength", selections: "selections", multiple: "multiple", customConfig: "customConfig", errorMessageTemplate: "errorMessageTemplate", placeholder: "placeholder" }, features: [i0.ɵɵProvidersFeature([
751
+ TdDynamicFormsService,
752
+ {
753
+ provide: NG_VALUE_ACCESSOR,
754
+ useExisting: forwardRef((() => TdDynamicElementComponent)),
755
+ multi: true,
756
+ },
757
+ ]), i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 1, vars: 0, consts: [["tdDynamicContainer", ""]], template: function TdDynamicElementComponent_Template(rf, ctx) {
758
+ if (rf & 1) {
759
+ i0.ɵɵelement(0, "div", 0);
760
+ }
761
+ }, directives: [TdDynamicElementDirective], encapsulation: 2 });
762
+ (function () {
763
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicElementComponent, [{
764
+ type: Component,
765
+ args: [{
766
+ providers: [
767
+ TdDynamicFormsService,
768
+ {
769
+ provide: NG_VALUE_ACCESSOR,
770
+ useExisting: forwardRef((() => TdDynamicElementComponent)),
771
+ multi: true,
772
+ },
773
+ ],
774
+ selector: 'td-dynamic-element',
775
+ template: '<div tdDynamicContainer></div>',
776
+ }]
777
+ }], function () { return [{ type: i0.ComponentFactoryResolver }, { type: TdDynamicFormsService }, { type: i0.ChangeDetectorRef }]; }, { dynamicControl: [{
778
+ type: Input
779
+ }], label: [{
780
+ type: Input
781
+ }], hint: [{
782
+ type: Input
783
+ }], name: [{
784
+ type: Input
785
+ }], type: [{
786
+ type: Input
787
+ }], required: [{
788
+ type: Input
789
+ }], min: [{
790
+ type: Input
791
+ }], max: [{
792
+ type: Input
793
+ }], minLength: [{
794
+ type: Input
795
+ }], maxLength: [{
796
+ type: Input
797
+ }], selections: [{
798
+ type: Input
799
+ }], multiple: [{
800
+ type: Input
801
+ }], customConfig: [{
802
+ type: Input
803
+ }], errorMessageTemplate: [{
804
+ type: Input
805
+ }], placeholder: [{
806
+ type: Input
807
+ }], childElement: [{
808
+ type: ViewChild,
809
+ args: [TdDynamicElementDirective, { static: true }]
810
+ }], maxAttr: [{
811
+ type: HostBinding,
812
+ args: ['attr.max']
813
+ }], minAttr: [{
814
+ type: HostBinding,
815
+ args: ['attr.min']
816
+ }] });
817
+ })();
818
+
819
+ function TdDynamicFormsComponent_ng_template_2_td_dynamic_element_1_Template(rf, ctx) {
820
+ if (rf & 1) {
821
+ i0.ɵɵelement(0, "td-dynamic-element", 5, 6);
822
+ }
823
+ if (rf & 2) {
824
+ const element_r1 = i0.ɵɵnextContext().$implicit;
825
+ const ctx_r2 = i0.ɵɵnextContext();
826
+ i0.ɵɵproperty("formControlName", element_r1.name)("dynamicControl", ctx_r2.dynamicForm.controls[element_r1.name])("id", element_r1.name)("name", element_r1.name)("label", element_r1.label || element_r1.name)("hint", element_r1.hint)("type", element_r1.type)("required", element_r1.required)("min", element_r1.min)("max", element_r1.max)("minLength", element_r1.minLength)("maxLength", element_r1.maxLength)("selections", element_r1.selections)("multiple", element_r1.multiple)("customConfig", element_r1.customConfig)("errorMessageTemplate", ctx_r2.getErrorTemplateRef(element_r1.name))("placeholder", element_r1.placeholder);
827
+ }
828
+ }
829
+ function TdDynamicFormsComponent_ng_template_2_Template(rf, ctx) {
830
+ if (rf & 1) {
831
+ i0.ɵɵelementStart(0, "div", 3);
832
+ i0.ɵɵtemplate(1, TdDynamicFormsComponent_ng_template_2_td_dynamic_element_1_Template, 2, 17, "td-dynamic-element", 4);
833
+ i0.ɵɵelementEnd();
834
+ }
835
+ if (rf & 2) {
836
+ const element_r1 = ctx.$implicit;
837
+ const ctx_r0 = i0.ɵɵnextContext();
838
+ i0.ɵɵstyleProp("max-width", element_r1.flex ? element_r1.flex : 100, "%")("flex", "1 1 " + (element_r1.flex ? element_r1.flex : 100) + "%")("-ms-flex", "1 1 " + (element_r1.flex ? element_r1.flex : 100) + "%")("-webkit-box-flex", 1);
839
+ i0.ɵɵadvance(1);
840
+ i0.ɵɵproperty("ngIf", ctx_r0.dynamicForm.controls[element_r1.name]);
841
+ }
842
+ }
843
+ const _c0 = ["*"];
844
+ class TdDynamicFormsComponent {
845
+ constructor(_formBuilder, _dynamicFormsService, _changeDetectorRef) {
846
+ this._formBuilder = _formBuilder;
847
+ this._dynamicFormsService = _dynamicFormsService;
848
+ this._changeDetectorRef = _changeDetectorRef;
849
+ this._renderedElements = [];
850
+ this._templateMap = new Map();
851
+ this._destroy$ = new Subject();
852
+ this._destroyControl$ = new Subject();
853
+ this.dynamicForm = this._formBuilder.group({});
854
+ }
855
+ /**
856
+ * elements: ITdDynamicElementConfig[]
857
+ * JS Object that will render the elements depending on its config.
858
+ * [name] property is required.
859
+ */
860
+ set elements(elements) {
861
+ if (elements) {
862
+ this._elements = elements;
863
+ }
864
+ else {
865
+ this._elements = [];
866
+ }
867
+ this._rerenderElements();
868
+ }
869
+ get elements() {
870
+ return this._renderedElements;
871
+ }
872
+ /**
873
+ * Getter property for dynamic [FormGroup].
874
+ */
875
+ get form() {
876
+ return this.dynamicForm;
877
+ }
878
+ /**
879
+ * Getter property for [valid] of dynamic [FormGroup].
880
+ */
881
+ get valid() {
882
+ if (this.dynamicForm) {
883
+ return this.dynamicForm.valid;
884
+ }
885
+ return false;
886
+ }
887
+ /**
888
+ * Getter property for [value] of dynamic [FormGroup].
889
+ */
890
+ get value() {
891
+ if (this.dynamicForm) {
892
+ return this.dynamicForm.value;
893
+ }
894
+ return {};
895
+ }
896
+ /**
897
+ * Getter property for [errors] of dynamic [FormGroup].
898
+ */
899
+ get errors() {
900
+ if (this.dynamicForm) {
901
+ const errors = {};
902
+ for (const name of Object.keys(this.dynamicForm.controls)) {
903
+ errors[name] = this.dynamicForm.controls[name].errors;
904
+ }
905
+ return errors;
906
+ }
907
+ return {};
908
+ }
909
+ /**
910
+ * Getter property for [controls] of dynamic [FormGroup].
911
+ */
912
+ get controls() {
913
+ if (this.dynamicForm) {
914
+ return this.dynamicForm.controls;
915
+ }
916
+ return {};
917
+ }
918
+ ngAfterContentInit() {
919
+ this._updateErrorTemplates();
920
+ }
921
+ ngOnDestroy() {
922
+ this._destroy$.next();
923
+ this._destroy$.complete();
924
+ this._destroyControl$.complete();
925
+ }
926
+ /**
927
+ * Refreshes the form and rerenders all validator/element modifications.
928
+ */
929
+ refresh() {
930
+ this._rerenderElements();
931
+ this._updateErrorTemplates();
932
+ }
933
+ /**
934
+ * Getter method for error template references
935
+ */
936
+ getErrorTemplateRef(name) {
937
+ return this._templateMap.get(name);
938
+ }
939
+ /**
940
+ * Loads error templates and sets them in a map for faster access.
941
+ */
942
+ _updateErrorTemplates() {
943
+ this._templateMap = new Map();
944
+ for (const errorTemplate of this._errorTemplates.toArray()) {
945
+ this._templateMap.set(errorTemplate.tdDynamicFormsError, errorTemplate.templateRef);
946
+ }
947
+ }
948
+ _rerenderElements() {
949
+ this._clearRemovedElements();
950
+ this._renderedElements = [];
951
+ const duplicates = [];
952
+ this._elements.forEach((elem) => {
953
+ this._dynamicFormsService.validateDynamicElementName(elem.name);
954
+ if (duplicates.indexOf(elem.name) > -1) {
955
+ throw new Error(`Dynamic element name: "${elem.name}" is duplicated`);
956
+ }
957
+ duplicates.push(elem.name);
958
+ const dynamicElement = this.dynamicForm.get(elem.name);
959
+ if (!dynamicElement) {
960
+ this.dynamicForm.addControl(elem.name, this._dynamicFormsService.createFormControl(elem));
961
+ this._subscribeToControlStatusChanges(elem.name);
962
+ }
963
+ else {
964
+ dynamicElement.setValue(elem.default);
965
+ dynamicElement.markAsPristine();
966
+ dynamicElement.markAsUntouched();
967
+ if (elem.disabled) {
968
+ dynamicElement.disable();
969
+ }
970
+ else {
971
+ dynamicElement.enable();
972
+ }
973
+ dynamicElement.setValidators(this._dynamicFormsService.createValidators(elem));
974
+ }
975
+ // copy objects so they are only changes when calling this method
976
+ this._renderedElements.push(Object.assign({}, elem));
977
+ });
978
+ // call a change detection since the whole form might change
979
+ this._changeDetectorRef.detectChanges();
980
+ timer()
981
+ .toPromise()
982
+ .then(() => {
983
+ // call a markForCheck so elements are rendered correctly in OnPush
984
+ this._changeDetectorRef.markForCheck();
985
+ });
986
+ }
987
+ _clearRemovedElements() {
988
+ this._renderedElements = this._renderedElements.filter((renderedElement) => !this._elements.some((element) => element.name === renderedElement.name));
989
+ // remove elements that were removed from the array
990
+ this._renderedElements.forEach((elem) => {
991
+ this._destroyControl$.next(elem.name);
992
+ this.dynamicForm.removeControl(elem.name);
993
+ });
994
+ }
995
+ // Updates component when manually adding errors to controls
996
+ _subscribeToControlStatusChanges(elementName) {
997
+ const control = this.controls[elementName];
998
+ const controlDestroyed$ = this._destroyControl$.pipe(filter((destroyedElementName) => destroyedElementName === elementName));
999
+ control.statusChanges.pipe(takeUntil(this._destroy$), takeUntil(controlDestroyed$)).subscribe(() => {
1000
+ this._changeDetectorRef.markForCheck();
1001
+ });
1002
+ }
1003
+ }
1004
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFormsComponent.ɵfac = function TdDynamicFormsComponent_Factory(t) { return new (t || TdDynamicFormsComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(TdDynamicFormsService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
1005
+ /** @nocollapse */ /** @nocollapse */ TdDynamicFormsComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdDynamicFormsComponent, selectors: [["td-dynamic-forms"]], contentQueries: function TdDynamicFormsComponent_ContentQueries(rf, ctx, dirIndex) {
1006
+ if (rf & 1) {
1007
+ i0.ɵɵcontentQuery(dirIndex, TdDynamicFormsErrorTemplateDirective, 5);
1008
+ }
1009
+ if (rf & 2) {
1010
+ let _t;
1011
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx._errorTemplates = _t);
1012
+ }
1013
+ }, inputs: { elements: "elements" }, ngContentSelectors: _c0, decls: 4, vars: 2, consts: [["novalidate", "", 3, "formGroup"], [1, "td-dynamic-form-wrapper"], ["ngFor", "", 3, "ngForOf"], [1, "td-dynamic-element-wrapper"], [3, "formControlName", "dynamicControl", "id", "name", "label", "hint", "type", "required", "min", "max", "minLength", "maxLength", "selections", "multiple", "customConfig", "errorMessageTemplate", "placeholder", 4, "ngIf"], [3, "formControlName", "dynamicControl", "id", "name", "label", "hint", "type", "required", "min", "max", "minLength", "maxLength", "selections", "multiple", "customConfig", "errorMessageTemplate", "placeholder"], ["dynamicElement", ""]], template: function TdDynamicFormsComponent_Template(rf, ctx) {
1014
+ if (rf & 1) {
1015
+ i0.ɵɵprojectionDef();
1016
+ i0.ɵɵelementStart(0, "form", 0);
1017
+ i0.ɵɵelementStart(1, "div", 1);
1018
+ i0.ɵɵtemplate(2, TdDynamicFormsComponent_ng_template_2_Template, 2, 9, "ng-template", 2);
1019
+ i0.ɵɵelementEnd();
1020
+ i0.ɵɵprojection(3);
1021
+ i0.ɵɵelementEnd();
1022
+ }
1023
+ if (rf & 2) {
1024
+ i0.ɵɵproperty("formGroup", ctx.dynamicForm);
1025
+ i0.ɵɵadvance(2);
1026
+ i0.ɵɵproperty("ngForOf", ctx.elements);
1027
+ }
1028
+ }, directives: [i3.ɵNgNoValidate, i3.NgControlStatusGroup, i3.FormGroupDirective, i4.NgForOf, i4.NgIf, TdDynamicElementComponent, i3.NgControlStatus, i3.FormControlName, i3.RequiredValidator], styles: [".td-dynamic-form-wrapper[_ngcontent-%COMP%]{-ms-flex-flow:row wrap;flex-flow:row wrap;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;max-width:100%;-ms-flex-pack:start;justify-content:flex-start}.td-dynamic-form-wrapper[_ngcontent-%COMP%] .mat-form-field-infix{width:auto}.td-dynamic-form-wrapper[_ngcontent-%COMP%] .td-dynamic-element-hint{font-size:75%;display:block}.td-dynamic-form-wrapper[_ngcontent-%COMP%] .td-dynamic-element-wrapper[_ngcontent-%COMP%]{max-height:100%;box-sizing:border-box;position:relative;padding:4px 4px 8px}"], changeDetection: 0 });
1029
+ (function () {
1030
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicFormsComponent, [{
1031
+ type: Component,
1032
+ args: [{ selector: 'td-dynamic-forms', changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"dynamicForm\" novalidate>\n <div class=\"td-dynamic-form-wrapper\">\n <ng-template let-element ngFor [ngForOf]=\"elements\">\n <div\n class=\"td-dynamic-element-wrapper\"\n [style.max-width.%]=\"element.flex ? element.flex : 100\"\n [style.flex]=\"'1 1 ' + (element.flex ? element.flex : 100) + '%'\"\n [style.-ms-flex]=\"'1 1 ' + (element.flex ? element.flex : 100) + '%'\"\n [style.-webkit-box-flex]=\"1\"\n >\n <td-dynamic-element\n #dynamicElement\n *ngIf=\"dynamicForm.controls[element.name]\"\n [formControlName]=\"element.name\"\n [dynamicControl]=\"dynamicForm.controls[element.name]\"\n [id]=\"element.name\"\n [name]=\"element.name\"\n [label]=\"element.label || element.name\"\n [hint]=\"element.hint\"\n [type]=\"element.type\"\n [required]=\"element.required\"\n [min]=\"element.min\"\n [max]=\"element.max\"\n [minLength]=\"element.minLength\"\n [maxLength]=\"element.maxLength\"\n [selections]=\"element.selections\"\n [multiple]=\"element.multiple\"\n [customConfig]=\"element.customConfig\"\n [errorMessageTemplate]=\"getErrorTemplateRef(element.name)\"\n [placeholder]=\"element.placeholder\"\n ></td-dynamic-element>\n </div>\n </ng-template>\n </div>\n <ng-content></ng-content>\n</form>\n", styles: [".td-dynamic-form-wrapper{-ms-flex-flow:row wrap;flex-flow:row wrap;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;max-width:100%;-ms-flex-pack:start;justify-content:flex-start}.td-dynamic-form-wrapper ::ng-deep .mat-form-field-infix{width:auto}.td-dynamic-form-wrapper ::ng-deep .td-dynamic-element-hint{font-size:75%;display:block}.td-dynamic-form-wrapper .td-dynamic-element-wrapper{max-height:100%;box-sizing:border-box;position:relative;padding:4px 4px 8px}\n"] }]
1033
+ }], function () { return [{ type: i3.FormBuilder }, { type: TdDynamicFormsService }, { type: i0.ChangeDetectorRef }]; }, { _errorTemplates: [{
1034
+ type: ContentChildren,
1035
+ args: [TdDynamicFormsErrorTemplateDirective, { descendants: true }]
1036
+ }], elements: [{
1037
+ type: Input,
1038
+ args: ['elements']
1039
+ }] });
1040
+ })();
1041
+
1042
+ const TD_DYNAMIC_FORMS = [
1043
+ TdDynamicFormsComponent,
1044
+ TdDynamicElementComponent,
1045
+ TdDynamicElementDirective,
1046
+ TdDynamicFormsErrorTemplateDirective,
1047
+ ];
1048
+ const TD_DYNAMIC_FORMS_ENTRY_COMPONENTS = [
1049
+ TdDynamicInputComponent,
1050
+ TdDynamicFileInputComponent,
1051
+ TdDynamicTextareaComponent,
1052
+ TdDynamicSlideToggleComponent,
1053
+ TdDynamicCheckboxComponent,
1054
+ TdDynamicSliderComponent,
1055
+ TdDynamicSelectComponent,
1056
+ TdDynamicDatepickerComponent,
1057
+ ];
1058
+ class CovalentDynamicFormsModule {
1059
+ }
1060
+ /** @nocollapse */ /** @nocollapse */ CovalentDynamicFormsModule.ɵfac = function CovalentDynamicFormsModule_Factory(t) { return new (t || CovalentDynamicFormsModule)(); };
1061
+ /** @nocollapse */ /** @nocollapse */ CovalentDynamicFormsModule.ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: CovalentDynamicFormsModule });
1062
+ /** @nocollapse */ /** @nocollapse */ CovalentDynamicFormsModule.ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ providers: [DYNAMIC_FORMS_PROVIDER], imports: [[
1063
+ CommonModule,
1064
+ ReactiveFormsModule,
1065
+ MatFormFieldModule,
1066
+ MatInputModule,
1067
+ MatSelectModule,
1068
+ MatCheckboxModule,
1069
+ MatSliderModule,
1070
+ MatSlideToggleModule,
1071
+ MatIconModule,
1072
+ MatButtonModule,
1073
+ MatDatepickerModule,
1074
+ CovalentCommonModule,
1075
+ CovalentFileModule,
1076
+ ]] });
1077
+ (function () {
1078
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentDynamicFormsModule, [{
1079
+ type: NgModule,
1080
+ args: [{
1081
+ declarations: [TD_DYNAMIC_FORMS, TD_DYNAMIC_FORMS_ENTRY_COMPONENTS],
1082
+ imports: [
1083
+ CommonModule,
1084
+ ReactiveFormsModule,
1085
+ MatFormFieldModule,
1086
+ MatInputModule,
1087
+ MatSelectModule,
1088
+ MatCheckboxModule,
1089
+ MatSliderModule,
1090
+ MatSlideToggleModule,
1091
+ MatIconModule,
1092
+ MatButtonModule,
1093
+ MatDatepickerModule,
1094
+ CovalentCommonModule,
1095
+ CovalentFileModule,
1096
+ ],
1097
+ exports: [TD_DYNAMIC_FORMS, TD_DYNAMIC_FORMS_ENTRY_COMPONENTS],
1098
+ providers: [DYNAMIC_FORMS_PROVIDER],
1099
+ }]
1100
+ }], null, null);
1101
+ })();
1102
+ (function () {
1103
+ (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CovalentDynamicFormsModule, { declarations: [TdDynamicFormsComponent,
1104
+ TdDynamicElementComponent,
1105
+ TdDynamicElementDirective,
1106
+ TdDynamicFormsErrorTemplateDirective, TdDynamicInputComponent,
1107
+ TdDynamicFileInputComponent,
1108
+ TdDynamicTextareaComponent,
1109
+ TdDynamicSlideToggleComponent,
1110
+ TdDynamicCheckboxComponent,
1111
+ TdDynamicSliderComponent,
1112
+ TdDynamicSelectComponent,
1113
+ TdDynamicDatepickerComponent], imports: [CommonModule,
1114
+ ReactiveFormsModule,
1115
+ MatFormFieldModule,
1116
+ MatInputModule,
1117
+ MatSelectModule,
1118
+ MatCheckboxModule,
1119
+ MatSliderModule,
1120
+ MatSlideToggleModule,
1121
+ MatIconModule,
1122
+ MatButtonModule,
1123
+ MatDatepickerModule,
1124
+ CovalentCommonModule,
1125
+ CovalentFileModule], exports: [TdDynamicFormsComponent,
1126
+ TdDynamicElementComponent,
1127
+ TdDynamicElementDirective,
1128
+ TdDynamicFormsErrorTemplateDirective, TdDynamicInputComponent,
1129
+ TdDynamicFileInputComponent,
1130
+ TdDynamicTextareaComponent,
1131
+ TdDynamicSlideToggleComponent,
1132
+ TdDynamicCheckboxComponent,
1133
+ TdDynamicSliderComponent,
1134
+ TdDynamicSelectComponent,
1135
+ TdDynamicDatepickerComponent] });
1136
+ })();
1137
+
1138
+ /**
1139
+ * Generated bundle index. Do not edit.
1140
+ */
1141
+
1142
+ export { CovalentDynamicFormsModule, DYNAMIC_ELEMENT_NAME_REGEX, DYNAMIC_FORMS_PROVIDER, DYNAMIC_FORMS_PROVIDER_FACTORY, TdDynamicCheckboxComponent, TdDynamicDatepickerComponent, TdDynamicElement, TdDynamicElementBase, TdDynamicElementComponent, TdDynamicElementDirective, TdDynamicFileInputComponent, TdDynamicFormsComponent, TdDynamicFormsErrorTemplateDirective, TdDynamicFormsService, TdDynamicInputComponent, TdDynamicSelectComponent, TdDynamicSlideToggleComponent, TdDynamicSliderComponent, TdDynamicTextareaComponent, TdDynamicType, _TdDynamicElementMixinBase };
1143
+ //# sourceMappingURL=covalent-dynamic-forms.mjs.map