@covalent/dynamic-forms 6.4.0 → 6.4.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.
- package/esm2020/lib/dynamic-element.component.mjs +176 -0
- package/esm2020/lib/dynamic-elements/dynamic-checkbox/dynamic-checkbox.component.mjs +19 -0
- package/esm2020/lib/dynamic-elements/dynamic-datepicker/dynamic-datepicker.component.mjs +23 -0
- package/esm2020/lib/dynamic-elements/dynamic-file-input/dynamic-file-input.component.mjs +28 -0
- package/esm2020/lib/dynamic-elements/dynamic-input/dynamic-input.component.mjs +22 -0
- package/esm2020/lib/dynamic-elements/dynamic-select/dynamic-select.component.mjs +23 -0
- package/esm2020/lib/dynamic-elements/dynamic-slide-toggle/dynamic-slide-toggle.component.mjs +19 -0
- package/esm2020/lib/dynamic-elements/dynamic-slider/dynamic-slider.component.mjs +26 -0
- package/esm2020/lib/dynamic-elements/dynamic-textarea/dynamic-textarea.component.mjs +22 -0
- package/esm2020/lib/dynamic-forms.component.mjs +185 -0
- package/{esm2022 → esm2020}/lib/dynamic-forms.module.mjs +48 -48
- package/{esm2022 → esm2020}/lib/services/dynamic-forms.service.mjs +4 -4
- package/fesm2015/covalent-dynamic-forms.mjs +745 -0
- package/{fesm2022 → fesm2015}/covalent-dynamic-forms.mjs.map +1 -1
- package/fesm2020/covalent-dynamic-forms.mjs +743 -0
- package/fesm2020/covalent-dynamic-forms.mjs.map +1 -0
- package/lib/dynamic-element.component.d.ts +2 -2
- package/lib/dynamic-forms.component.d.ts +1 -1
- package/package.json +14 -8
- package/esm2022/lib/dynamic-element.component.mjs +0 -229
- package/esm2022/lib/dynamic-elements/dynamic-checkbox/dynamic-checkbox.component.mjs +0 -18
- package/esm2022/lib/dynamic-elements/dynamic-datepicker/dynamic-datepicker.component.mjs +0 -26
- package/esm2022/lib/dynamic-elements/dynamic-file-input/dynamic-file-input.component.mjs +0 -28
- package/esm2022/lib/dynamic-elements/dynamic-input/dynamic-input.component.mjs +0 -27
- package/esm2022/lib/dynamic-elements/dynamic-select/dynamic-select.component.mjs +0 -25
- package/esm2022/lib/dynamic-elements/dynamic-slide-toggle/dynamic-slide-toggle.component.mjs +0 -18
- package/esm2022/lib/dynamic-elements/dynamic-slider/dynamic-slider.component.mjs +0 -30
- package/esm2022/lib/dynamic-elements/dynamic-textarea/dynamic-textarea.component.mjs +0 -22
- package/esm2022/lib/dynamic-forms.component.mjs +0 -191
- package/fesm2022/covalent-dynamic-forms.mjs +0 -814
- /package/{esm2022 → esm2020}/covalent-dynamic-forms.mjs +0 -0
- /package/{esm2022 → esm2020}/public_api.mjs +0 -0
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Component, Injectable, Optional, SkipSelf, Directive, Input, Type, ViewChild, HostBinding, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import * as i2 from '@angular/forms';
|
|
6
|
+
import { UntypedFormControl, Validators, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
|
7
|
+
import * as i3 from '@angular/material/form-field';
|
|
8
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
9
|
+
import * as i4 from '@angular/material/input';
|
|
10
|
+
import { MatInputModule } from '@angular/material/input';
|
|
11
|
+
import * as i4$1 from '@angular/material/select';
|
|
12
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
13
|
+
import * as i2$2 from '@angular/material/checkbox';
|
|
14
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
15
|
+
import * as i3$1 from '@angular/material/slider';
|
|
16
|
+
import { MatSliderModule } from '@angular/material/slider';
|
|
17
|
+
import * as i2$1 from '@angular/material/slide-toggle';
|
|
18
|
+
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
19
|
+
import * as i5 from '@angular/material/icon';
|
|
20
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
21
|
+
import * as i6 from '@angular/material/button';
|
|
22
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
23
|
+
import * as i5$2 from '@angular/material/datepicker';
|
|
24
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
25
|
+
import * as i7 from '@covalent/core/file';
|
|
26
|
+
import { CovalentFileModule } from '@covalent/core/file';
|
|
27
|
+
import * as i5$1 from '@angular/material/core';
|
|
28
|
+
import { CdkPortal } from '@angular/cdk/portal';
|
|
29
|
+
import { mixinControlValueAccessor } from '@covalent/core/common';
|
|
30
|
+
import { Subject, timer } from 'rxjs';
|
|
31
|
+
import { filter, takeUntil } from 'rxjs/operators';
|
|
32
|
+
|
|
33
|
+
class TdDynamicInputComponent {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.label = '';
|
|
36
|
+
this.hint = '';
|
|
37
|
+
this.required = false;
|
|
38
|
+
this.name = '';
|
|
39
|
+
this.placeholder = '';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
TdDynamicInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
43
|
+
TdDynamicInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicInputComponent, selector: "td-dynamic-input", ngImport: i0, 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 [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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-input-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-input-wrapper .td-dynamic-input-field{flex:1;box-sizing:border-box}\n"], dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }] });
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicInputComponent, decorators: [{
|
|
45
|
+
type: Component,
|
|
46
|
+
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 [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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-input-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-input-wrapper .td-dynamic-input-field{flex:1;box-sizing:border-box}\n"] }]
|
|
47
|
+
}] });
|
|
48
|
+
|
|
49
|
+
class TdDynamicFileInputComponent {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.required = false;
|
|
52
|
+
this.label = '';
|
|
53
|
+
this.name = '';
|
|
54
|
+
this.hint = '';
|
|
55
|
+
this.placeholder = '';
|
|
56
|
+
}
|
|
57
|
+
_handlefileDrop(value) {
|
|
58
|
+
this.control?.setValue(value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
TdDynamicFileInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFileInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
62
|
+
TdDynamicFileInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicFileInputComponent, selector: "td-dynamic-file-input", ngImport: i0, template: "<div class=\"td-dynamic-file-input-wrapper\">\n <mat-form-field\n tdFileDrop\n class=\"td-dynamic-file-input-field\"\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 [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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n <button\n mat-icon-button\n *ngIf=\"control.value\"\n (click)=\"fileInput.clear()\"\n (keyup.enter)=\"fileInput.clear()\"\n >\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{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-file-input-wrapper .td-dynamic-file-input-field{flex:1;box-sizing:border-box}.td-file-input{margin-left:10px}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i7.TdFileDropDirective, selector: "[tdFileDrop]", inputs: ["multiple", "disabled"], outputs: ["fileDrop"] }, { kind: "component", type: i7.TdFileInputComponent, selector: "td-file-input", inputs: ["disabled", "value", "color", "multiple", "accept"], outputs: ["selectFile"] }] });
|
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFileInputComponent, decorators: [{
|
|
64
|
+
type: Component,
|
|
65
|
+
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 [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 [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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n <button\n mat-icon-button\n *ngIf=\"control.value\"\n (click)=\"fileInput.clear()\"\n (keyup.enter)=\"fileInput.clear()\"\n >\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{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-file-input-wrapper .td-dynamic-file-input-field{flex:1;box-sizing:border-box}.td-file-input{margin-left:10px}\n"] }]
|
|
66
|
+
}] });
|
|
67
|
+
|
|
68
|
+
class TdDynamicTextareaComponent {
|
|
69
|
+
constructor() {
|
|
70
|
+
this.label = '';
|
|
71
|
+
this.hint = '';
|
|
72
|
+
this.name = '';
|
|
73
|
+
this.required = false;
|
|
74
|
+
this.placeholder = '';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
TdDynamicTextareaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicTextareaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
78
|
+
TdDynamicTextareaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicTextareaComponent, selector: "td-dynamic-textarea", ngImport: i0, 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 [name]=\"name\"\n rows=\"4\"\n ></textarea>\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-textarea-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-textarea-wrapper .td-dynamic-textarea-field{flex:1;box-sizing:border-box}\n"], dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }] });
|
|
79
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicTextareaComponent, decorators: [{
|
|
80
|
+
type: Component,
|
|
81
|
+
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 [name]=\"name\"\n rows=\"4\"\n ></textarea>\n <mat-hint>{{ hint }}</mat-hint>\n <mat-error>\n <ng-template\n [ngTemplateOutlet]=\"errorMessageTemplate\"\n [ngTemplateOutletContext]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-textarea-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-textarea-wrapper .td-dynamic-textarea-field{flex:1;box-sizing:border-box}\n"] }]
|
|
82
|
+
}] });
|
|
83
|
+
|
|
84
|
+
class TdDynamicSlideToggleComponent {
|
|
85
|
+
constructor() {
|
|
86
|
+
this.label = '';
|
|
87
|
+
this.name = '';
|
|
88
|
+
this.hint = '';
|
|
89
|
+
this.required = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
TdDynamicSlideToggleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicSlideToggleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
93
|
+
TdDynamicSlideToggleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicSlideToggleComponent, selector: "td-dynamic-slide-toggle", ngImport: i0, template: "<div class=\"td-dynamic-slide-toggle-wrapper\">\n <mat-slide-toggle\n [formControl]=\"control\"\n [attr.name]=\"name\"\n [required]=\"required\"\n >\n {{ label }}\n </mat-slide-toggle>\n <span class=\"mat-hint td-dynamic-element-hint\">{{ hint }}</span>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.MatSlideToggleRequiredValidator, selector: "mat-slide-toggle[required][formControlName], mat-slide-toggle[required][formControl], mat-slide-toggle[required][ngModel]" }, { kind: "component", type: i2$1.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex"], exportAs: ["matSlideToggle"] }] });
|
|
94
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicSlideToggleComponent, decorators: [{
|
|
95
|
+
type: Component,
|
|
96
|
+
args: [{ selector: 'td-dynamic-slide-toggle', template: "<div class=\"td-dynamic-slide-toggle-wrapper\">\n <mat-slide-toggle\n [formControl]=\"control\"\n [attr.name]=\"name\"\n [required]=\"required\"\n >\n {{ label }}\n </mat-slide-toggle>\n <span class=\"mat-hint td-dynamic-element-hint\">{{ hint }}</span>\n</div>\n" }]
|
|
97
|
+
}] });
|
|
98
|
+
|
|
99
|
+
class TdDynamicCheckboxComponent {
|
|
100
|
+
constructor() {
|
|
101
|
+
this.label = '';
|
|
102
|
+
this.name = '';
|
|
103
|
+
this.hint = '';
|
|
104
|
+
this.required = false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
TdDynamicCheckboxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
108
|
+
TdDynamicCheckboxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicCheckboxComponent, selector: "td-dynamic-checkbox", ngImport: i0, 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: [""], dependencies: [{ kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2$2.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "directive", type: i2$2.MatCheckboxRequiredValidator, selector: "mat-checkbox[required][formControlName], mat-checkbox[required][formControl], mat-checkbox[required][ngModel]" }] });
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicCheckboxComponent, decorators: [{
|
|
110
|
+
type: Component,
|
|
111
|
+
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" }]
|
|
112
|
+
}] });
|
|
113
|
+
|
|
114
|
+
class TdDynamicSliderComponent {
|
|
115
|
+
constructor(_changeDetectorRef) {
|
|
116
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
117
|
+
this.label = '';
|
|
118
|
+
this.required = false;
|
|
119
|
+
this.name = '';
|
|
120
|
+
this.hint = '';
|
|
121
|
+
}
|
|
122
|
+
_handleBlur() {
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
this._changeDetectorRef.markForCheck();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
TdDynamicSliderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicSliderComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
129
|
+
TdDynamicSliderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicSliderComponent, selector: "td-dynamic-slider", ngImport: i0, template: "<div\n class=\"td-dynamic-slider-wrapper mat-form-field mat-form-field-can-float mat-form-field-should-float\"\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\n *ngIf=\"required && !control?.disabled\"\n class=\"mat-form-field-required-marker\"\n >*</span\n >\n </label>\n </span>\n <div class=\"td-dynamic-slider-field\">\n <mat-slider\n #slider\n class=\"td-dynamic-slider\"\n thumbLabel\n tickInterval=\"auto\"\n (blur)=\"_handleBlur()\"\n >\n <input\n [attr.name]=\"name\"\n [min]=\"min\"\n [max]=\"max\"\n [formControl]=\"control\"\n [required]=\"required\"\n matSliderThumb\n />\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;flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-slider-field .td-dynamic-slider{flex:1}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3$1.MatSlider, selector: "mat-slider", inputs: ["color", "disableRipple", "disabled", "discrete", "showTickMarks", "min", "max", "step", "displayWith"], exportAs: ["matSlider"] }, { kind: "directive", type: i3$1.MatSliderThumb, selector: "input[matSliderThumb]", inputs: ["value"], outputs: ["valueChange", "dragStart", "dragEnd"], exportAs: ["matSliderThumb"] }] });
|
|
130
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicSliderComponent, decorators: [{
|
|
131
|
+
type: Component,
|
|
132
|
+
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>\n <span class=\"mat-form-field-label-wrapper\">\n <label class=\"mat-form-field-label mat-primary td-slider-label\">\n {{ label }}\n <span\n *ngIf=\"required && !control?.disabled\"\n class=\"mat-form-field-required-marker\"\n >*</span\n >\n </label>\n </span>\n <div class=\"td-dynamic-slider-field\">\n <mat-slider\n #slider\n class=\"td-dynamic-slider\"\n thumbLabel\n tickInterval=\"auto\"\n (blur)=\"_handleBlur()\"\n >\n <input\n [attr.name]=\"name\"\n [min]=\"min\"\n [max]=\"max\"\n [formControl]=\"control\"\n [required]=\"required\"\n matSliderThumb\n />\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;flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-slider-field .td-dynamic-slider{flex:1}\n"] }]
|
|
133
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
|
|
134
|
+
|
|
135
|
+
class TdDynamicSelectComponent {
|
|
136
|
+
constructor() {
|
|
137
|
+
this.label = '';
|
|
138
|
+
this.hint = '';
|
|
139
|
+
this.name = '';
|
|
140
|
+
this.required = false;
|
|
141
|
+
this.placeholder = '';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
TdDynamicSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
145
|
+
TdDynamicSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicSelectComponent, selector: "td-dynamic-select", ngImport: i0, 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\n *ngFor=\"let selection of selections\"\n [value]=\"selection.value ?? selection\"\n >\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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-select-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-select-wrapper .td-dynamic-select-field{flex:1;box-sizing:border-box}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i4$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }] });
|
|
146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicSelectComponent, decorators: [{
|
|
147
|
+
type: Component,
|
|
148
|
+
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\n *ngFor=\"let selection of selections\"\n [value]=\"selection.value ?? selection\"\n >\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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-select-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-select-wrapper .td-dynamic-select-field{flex:1;box-sizing:border-box}\n"] }]
|
|
149
|
+
}] });
|
|
150
|
+
|
|
151
|
+
class TdDynamicDatepickerComponent {
|
|
152
|
+
constructor() {
|
|
153
|
+
this.label = '';
|
|
154
|
+
this.hint = '';
|
|
155
|
+
this.name = '';
|
|
156
|
+
this.required = false;
|
|
157
|
+
this.placeholder = '';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
TdDynamicDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicDatepickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
161
|
+
TdDynamicDatepickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicDatepickerComponent, selector: "td-dynamic-datepicker", ngImport: i0, 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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n <mat-datepicker-toggle\n matSuffix\n [for]=\"dynamicDatePicker\"\n ></mat-datepicker-toggle>\n <mat-datepicker #dynamicDatePicker></mat-datepicker>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-datepicker-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-datepicker-wrapper .td-dynamic-datepicker-field{flex:1;box-sizing:border-box}\n"], dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i5$2.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i5$2.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i5$2.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }] });
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicDatepickerComponent, decorators: [{
|
|
163
|
+
type: Component,
|
|
164
|
+
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]=\"{\n control: control,\n errors: control.errors\n }\"\n ></ng-template>\n </mat-error>\n <mat-datepicker-toggle\n matSuffix\n [for]=\"dynamicDatePicker\"\n ></mat-datepicker-toggle>\n <mat-datepicker #dynamicDatePicker></mat-datepicker>\n </mat-form-field>\n</div>\n", styles: [".td-dynamic-datepicker-wrapper{flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-datepicker-wrapper .td-dynamic-datepicker-field{flex:1;box-sizing:border-box}\n"] }]
|
|
165
|
+
}] });
|
|
166
|
+
|
|
167
|
+
var TdDynamicType;
|
|
168
|
+
(function (TdDynamicType) {
|
|
169
|
+
TdDynamicType["Text"] = "text";
|
|
170
|
+
TdDynamicType["Boolean"] = "boolean";
|
|
171
|
+
TdDynamicType["Number"] = "number";
|
|
172
|
+
TdDynamicType["Array"] = "array";
|
|
173
|
+
TdDynamicType["Date"] = "date";
|
|
174
|
+
})(TdDynamicType || (TdDynamicType = {}));
|
|
175
|
+
var TdDynamicElement;
|
|
176
|
+
(function (TdDynamicElement) {
|
|
177
|
+
TdDynamicElement["Input"] = "input";
|
|
178
|
+
TdDynamicElement["Datepicker"] = "datepicker";
|
|
179
|
+
TdDynamicElement["Password"] = "password";
|
|
180
|
+
TdDynamicElement["Textarea"] = "textarea";
|
|
181
|
+
TdDynamicElement["Slider"] = "slider";
|
|
182
|
+
TdDynamicElement["SlideToggle"] = "slide-toggle";
|
|
183
|
+
TdDynamicElement["Checkbox"] = "checkbox";
|
|
184
|
+
TdDynamicElement["Select"] = "select";
|
|
185
|
+
TdDynamicElement["FileInput"] = "file-input";
|
|
186
|
+
})(TdDynamicElement || (TdDynamicElement = {}));
|
|
187
|
+
const DYNAMIC_ELEMENT_NAME_REGEX = /^[^0-9][^@]*$/;
|
|
188
|
+
class TdDynamicFormsService {
|
|
189
|
+
/**
|
|
190
|
+
* Method to validate if the [name] is a proper element name.
|
|
191
|
+
* Throws error if name is not valid.
|
|
192
|
+
*/
|
|
193
|
+
validateDynamicElementName(name) {
|
|
194
|
+
if (!DYNAMIC_ELEMENT_NAME_REGEX.test(name)) {
|
|
195
|
+
throw new Error('Dynamic element name: "${name}" is not valid.');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Gets component to be rendered depending on [TdDynamicElement | TdDynamicType]
|
|
200
|
+
* Throws error if it does not exists or not supported.
|
|
201
|
+
*/
|
|
202
|
+
getDynamicElement(element) {
|
|
203
|
+
switch (element) {
|
|
204
|
+
case TdDynamicType.Text:
|
|
205
|
+
case TdDynamicType.Number:
|
|
206
|
+
case TdDynamicElement.Input:
|
|
207
|
+
case TdDynamicElement.Password:
|
|
208
|
+
return TdDynamicInputComponent;
|
|
209
|
+
case TdDynamicElement.Textarea:
|
|
210
|
+
return TdDynamicTextareaComponent;
|
|
211
|
+
case TdDynamicType.Boolean:
|
|
212
|
+
case TdDynamicElement.SlideToggle:
|
|
213
|
+
return TdDynamicSlideToggleComponent;
|
|
214
|
+
case TdDynamicElement.Checkbox:
|
|
215
|
+
return TdDynamicCheckboxComponent;
|
|
216
|
+
case TdDynamicElement.Slider:
|
|
217
|
+
return TdDynamicSliderComponent;
|
|
218
|
+
case TdDynamicType.Array:
|
|
219
|
+
case TdDynamicElement.Select:
|
|
220
|
+
return TdDynamicSelectComponent;
|
|
221
|
+
case TdDynamicElement.FileInput:
|
|
222
|
+
return TdDynamicFileInputComponent;
|
|
223
|
+
case TdDynamicElement.Datepicker:
|
|
224
|
+
case TdDynamicType.Date:
|
|
225
|
+
return TdDynamicDatepickerComponent;
|
|
226
|
+
default:
|
|
227
|
+
throw new Error(`Error: type ${element} does not exist or not supported.`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Creates form control for element depending [ITdDynamicElementConfig] properties.
|
|
232
|
+
*/
|
|
233
|
+
createFormControl(config) {
|
|
234
|
+
const validator = this.createValidators(config);
|
|
235
|
+
return new UntypedFormControl({ value: config.default, disabled: config.disabled }, validator);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Creates form validationdepending [ITdDynamicElementConfig] properties.
|
|
239
|
+
*/
|
|
240
|
+
createValidators(config) {
|
|
241
|
+
let validator = null;
|
|
242
|
+
if (config.required) {
|
|
243
|
+
validator = Validators.required;
|
|
244
|
+
}
|
|
245
|
+
if (config.max || config.max === 0) {
|
|
246
|
+
validator = Validators.compose([
|
|
247
|
+
validator,
|
|
248
|
+
Validators.max(parseFloat(config.max)),
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
if (config.min || config.min === 0) {
|
|
252
|
+
validator = Validators.compose([
|
|
253
|
+
validator,
|
|
254
|
+
Validators.min(parseFloat(config.min)),
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
if (config.maxLength || config.maxLength === 0) {
|
|
258
|
+
validator = Validators.compose([
|
|
259
|
+
validator,
|
|
260
|
+
Validators.maxLength(parseFloat(config.maxLength)),
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
if (config.minLength || config.minLength === 0) {
|
|
264
|
+
validator = Validators.compose([
|
|
265
|
+
validator,
|
|
266
|
+
Validators.minLength(parseFloat(config.minLength)),
|
|
267
|
+
]);
|
|
268
|
+
}
|
|
269
|
+
// Add provided custom validators to the validator function
|
|
270
|
+
if (config.validators) {
|
|
271
|
+
config.validators.forEach((validatorConfig) => {
|
|
272
|
+
validator = Validators.compose([
|
|
273
|
+
validator,
|
|
274
|
+
validatorConfig.validator,
|
|
275
|
+
]);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return validator;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
TdDynamicFormsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
282
|
+
TdDynamicFormsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsService });
|
|
283
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsService, decorators: [{
|
|
284
|
+
type: Injectable
|
|
285
|
+
}] });
|
|
286
|
+
function DYNAMIC_FORMS_PROVIDER_FACTORY(parent) {
|
|
287
|
+
return parent || new TdDynamicFormsService();
|
|
288
|
+
}
|
|
289
|
+
const DYNAMIC_FORMS_PROVIDER = {
|
|
290
|
+
// If there is already a service available, use that. Otherwise, provide a new one.
|
|
291
|
+
provide: TdDynamicFormsService,
|
|
292
|
+
deps: [[new Optional(), new SkipSelf(), TdDynamicFormsService]],
|
|
293
|
+
useFactory: DYNAMIC_FORMS_PROVIDER_FACTORY,
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
class TdDynamicElementBase {
|
|
297
|
+
constructor(_changeDetectorRef) {
|
|
298
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/* tslint:disable-next-line */
|
|
302
|
+
const _TdDynamicElementMixinBase = mixinControlValueAccessor(TdDynamicElementBase);
|
|
303
|
+
class TdDynamicFormsErrorTemplateDirective extends CdkPortal {
|
|
304
|
+
constructor(templateRef, viewContainerRef) {
|
|
305
|
+
super(templateRef, viewContainerRef);
|
|
306
|
+
this.templateRef = templateRef;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
TdDynamicFormsErrorTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsErrorTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
310
|
+
TdDynamicFormsErrorTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicFormsErrorTemplateDirective, selector: "[tdDynamicFormsError]ng-template", inputs: { tdDynamicFormsError: "tdDynamicFormsError" }, usesInheritance: true, ngImport: i0 });
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsErrorTemplateDirective, decorators: [{
|
|
312
|
+
type: Directive,
|
|
313
|
+
args: [{ selector: '[tdDynamicFormsError]ng-template' }]
|
|
314
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { tdDynamicFormsError: [{
|
|
315
|
+
type: Input
|
|
316
|
+
}] } });
|
|
317
|
+
class TdDynamicElementDirective {
|
|
318
|
+
constructor(viewContainer) {
|
|
319
|
+
this.viewContainer = viewContainer;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
TdDynamicElementDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicElementDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
323
|
+
TdDynamicElementDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicElementDirective, selector: "[tdDynamicContainer]", ngImport: i0 });
|
|
324
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicElementDirective, decorators: [{
|
|
325
|
+
type: Directive,
|
|
326
|
+
args: [{
|
|
327
|
+
selector: '[tdDynamicContainer]',
|
|
328
|
+
}]
|
|
329
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
|
|
330
|
+
class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
331
|
+
get maxAttr() {
|
|
332
|
+
return this.max;
|
|
333
|
+
}
|
|
334
|
+
get minAttr() {
|
|
335
|
+
return this.min;
|
|
336
|
+
}
|
|
337
|
+
constructor(_injector, _dynamicFormsService, _changeDetectorRef) {
|
|
338
|
+
super(_changeDetectorRef);
|
|
339
|
+
this._injector = _injector;
|
|
340
|
+
this._dynamicFormsService = _dynamicFormsService;
|
|
341
|
+
/**
|
|
342
|
+
* Sets label to be displayed.
|
|
343
|
+
*/
|
|
344
|
+
this.label = '';
|
|
345
|
+
/**
|
|
346
|
+
* Sets hint to be displayed.
|
|
347
|
+
*/
|
|
348
|
+
this.hint = '';
|
|
349
|
+
/**
|
|
350
|
+
* Sets name to be displayed as attribute.
|
|
351
|
+
*/
|
|
352
|
+
this.name = '';
|
|
353
|
+
/**
|
|
354
|
+
* Sets the placeholder message
|
|
355
|
+
*/
|
|
356
|
+
this.placeholder = '';
|
|
357
|
+
}
|
|
358
|
+
ngOnInit() {
|
|
359
|
+
const component = this.type instanceof Type
|
|
360
|
+
? this.type
|
|
361
|
+
: this._dynamicFormsService.getDynamicElement(this.type);
|
|
362
|
+
const ref = this.childElement.viewContainer.createComponent(component, {
|
|
363
|
+
injector: this._injector,
|
|
364
|
+
});
|
|
365
|
+
this._instance = ref.instance;
|
|
366
|
+
this._instance.control = this.dynamicControl;
|
|
367
|
+
this._instance.label = this.label;
|
|
368
|
+
this._instance.hint = this.hint;
|
|
369
|
+
this._instance.name = this.name;
|
|
370
|
+
this._instance.type = this.type;
|
|
371
|
+
this._instance.value = this.value;
|
|
372
|
+
this._instance.required = this.required;
|
|
373
|
+
this._instance.min = this.min;
|
|
374
|
+
this._instance.max = this.max;
|
|
375
|
+
this._instance.minLength = this.minLength;
|
|
376
|
+
this._instance.maxLength = this.maxLength;
|
|
377
|
+
this._instance.selections = this.selections;
|
|
378
|
+
this._instance.multiple = this.multiple;
|
|
379
|
+
this._instance.errorMessageTemplate = this.errorMessageTemplate;
|
|
380
|
+
this._instance.placeholder = this.placeholder;
|
|
381
|
+
if (this.customConfig) {
|
|
382
|
+
Object.getOwnPropertyNames(this.customConfig).forEach((name) => {
|
|
383
|
+
if (this.customConfig) {
|
|
384
|
+
this._instance[name] = this.customConfig[name];
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Reassign any inputs that have changed
|
|
391
|
+
*/
|
|
392
|
+
ngOnChanges(changes) {
|
|
393
|
+
if (this._instance) {
|
|
394
|
+
for (const prop of Object.keys(changes)) {
|
|
395
|
+
this._instance[prop] = changes[prop].currentValue;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
TdDynamicElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicElementComponent, deps: [{ token: i0.Injector }, { token: TdDynamicFormsService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
401
|
+
TdDynamicElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicElementComponent, selector: "td-dynamic-element", 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" }, host: { properties: { "attr.max": "this.maxAttr", "attr.min": "this.minAttr" } }, providers: [
|
|
402
|
+
TdDynamicFormsService,
|
|
403
|
+
{
|
|
404
|
+
provide: NG_VALUE_ACCESSOR,
|
|
405
|
+
useExisting: TdDynamicElementComponent,
|
|
406
|
+
multi: true,
|
|
407
|
+
},
|
|
408
|
+
], viewQueries: [{ propertyName: "childElement", first: true, predicate: TdDynamicElementDirective, descendants: true, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<div tdDynamicContainer></div>', isInline: true, dependencies: [{ kind: "directive", type: TdDynamicElementDirective, selector: "[tdDynamicContainer]" }] });
|
|
409
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicElementComponent, decorators: [{
|
|
410
|
+
type: Component,
|
|
411
|
+
args: [{
|
|
412
|
+
providers: [
|
|
413
|
+
TdDynamicFormsService,
|
|
414
|
+
{
|
|
415
|
+
provide: NG_VALUE_ACCESSOR,
|
|
416
|
+
useExisting: TdDynamicElementComponent,
|
|
417
|
+
multi: true,
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
selector: 'td-dynamic-element',
|
|
421
|
+
template: '<div tdDynamicContainer></div>',
|
|
422
|
+
}]
|
|
423
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: TdDynamicFormsService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { dynamicControl: [{
|
|
424
|
+
type: Input
|
|
425
|
+
}], label: [{
|
|
426
|
+
type: Input
|
|
427
|
+
}], hint: [{
|
|
428
|
+
type: Input
|
|
429
|
+
}], name: [{
|
|
430
|
+
type: Input
|
|
431
|
+
}], type: [{
|
|
432
|
+
type: Input
|
|
433
|
+
}], required: [{
|
|
434
|
+
type: Input
|
|
435
|
+
}], min: [{
|
|
436
|
+
type: Input
|
|
437
|
+
}], max: [{
|
|
438
|
+
type: Input
|
|
439
|
+
}], minLength: [{
|
|
440
|
+
type: Input
|
|
441
|
+
}], maxLength: [{
|
|
442
|
+
type: Input
|
|
443
|
+
}], selections: [{
|
|
444
|
+
type: Input
|
|
445
|
+
}], multiple: [{
|
|
446
|
+
type: Input
|
|
447
|
+
}], customConfig: [{
|
|
448
|
+
type: Input
|
|
449
|
+
}], errorMessageTemplate: [{
|
|
450
|
+
type: Input
|
|
451
|
+
}], placeholder: [{
|
|
452
|
+
type: Input
|
|
453
|
+
}], childElement: [{
|
|
454
|
+
type: ViewChild,
|
|
455
|
+
args: [TdDynamicElementDirective, { static: true }]
|
|
456
|
+
}], maxAttr: [{
|
|
457
|
+
type: HostBinding,
|
|
458
|
+
args: ['attr.max']
|
|
459
|
+
}], minAttr: [{
|
|
460
|
+
type: HostBinding,
|
|
461
|
+
args: ['attr.min']
|
|
462
|
+
}] } });
|
|
463
|
+
|
|
464
|
+
class TdDynamicFormsComponent {
|
|
465
|
+
/**
|
|
466
|
+
* elements: ITdDynamicElementConfig[]
|
|
467
|
+
* JS Object that will render the elements depending on its config.
|
|
468
|
+
* [name] property is required.
|
|
469
|
+
*/
|
|
470
|
+
set elements(elements) {
|
|
471
|
+
if (elements) {
|
|
472
|
+
this._elements = elements;
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
this._elements = [];
|
|
476
|
+
}
|
|
477
|
+
this._rerenderElements();
|
|
478
|
+
}
|
|
479
|
+
get elements() {
|
|
480
|
+
return this._renderedElements;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Getter property for dynamic [FormGroup].
|
|
484
|
+
*/
|
|
485
|
+
get form() {
|
|
486
|
+
return this.dynamicForm;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Getter property for [valid] of dynamic [FormGroup].
|
|
490
|
+
*/
|
|
491
|
+
get valid() {
|
|
492
|
+
if (this.dynamicForm) {
|
|
493
|
+
return this.dynamicForm.valid;
|
|
494
|
+
}
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Getter property for [value] of dynamic [FormGroup].
|
|
499
|
+
*/
|
|
500
|
+
get value() {
|
|
501
|
+
if (this.dynamicForm) {
|
|
502
|
+
return this.dynamicForm.value;
|
|
503
|
+
}
|
|
504
|
+
return {};
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Getter property for [errors] of dynamic [FormGroup].
|
|
508
|
+
*/
|
|
509
|
+
get errors() {
|
|
510
|
+
if (this.dynamicForm) {
|
|
511
|
+
const errors = {};
|
|
512
|
+
for (const name of Object.keys(this.dynamicForm.controls)) {
|
|
513
|
+
errors[name] = this.dynamicForm.controls[name].errors;
|
|
514
|
+
}
|
|
515
|
+
return errors;
|
|
516
|
+
}
|
|
517
|
+
return {};
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Getter property for [controls] of dynamic [FormGroup].
|
|
521
|
+
*/
|
|
522
|
+
get controls() {
|
|
523
|
+
if (this.dynamicForm) {
|
|
524
|
+
return this.dynamicForm.controls;
|
|
525
|
+
}
|
|
526
|
+
return {};
|
|
527
|
+
}
|
|
528
|
+
constructor(_formBuilder, _dynamicFormsService, _changeDetectorRef) {
|
|
529
|
+
this._formBuilder = _formBuilder;
|
|
530
|
+
this._dynamicFormsService = _dynamicFormsService;
|
|
531
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
532
|
+
this._renderedElements = [];
|
|
533
|
+
this._templateMap = new Map();
|
|
534
|
+
this._destroy$ = new Subject();
|
|
535
|
+
this._destroyControl$ = new Subject();
|
|
536
|
+
this.dynamicForm = this._formBuilder.group({});
|
|
537
|
+
}
|
|
538
|
+
ngAfterContentInit() {
|
|
539
|
+
this._updateErrorTemplates();
|
|
540
|
+
}
|
|
541
|
+
ngOnDestroy() {
|
|
542
|
+
this._destroy$.next(0);
|
|
543
|
+
this._destroy$.complete();
|
|
544
|
+
this._destroyControl$.complete();
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Refreshes the form and rerenders all validator/element modifications.
|
|
548
|
+
*/
|
|
549
|
+
refresh() {
|
|
550
|
+
this._rerenderElements();
|
|
551
|
+
this._updateErrorTemplates();
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Getter method for error template references
|
|
555
|
+
*/
|
|
556
|
+
getErrorTemplateRef(name) {
|
|
557
|
+
return this._templateMap.get(name);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Loads error templates and sets them in a map for faster access.
|
|
561
|
+
*/
|
|
562
|
+
_updateErrorTemplates() {
|
|
563
|
+
this._templateMap = new Map();
|
|
564
|
+
for (const errorTemplate of this._errorTemplates.toArray()) {
|
|
565
|
+
this._templateMap.set(errorTemplate.tdDynamicFormsError ?? '', errorTemplate.templateRef);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
_rerenderElements() {
|
|
569
|
+
this._clearRemovedElements();
|
|
570
|
+
this._renderedElements = [];
|
|
571
|
+
const duplicates = [];
|
|
572
|
+
this._elements.forEach((elem) => {
|
|
573
|
+
this._dynamicFormsService.validateDynamicElementName(elem.name);
|
|
574
|
+
if (duplicates.indexOf(elem.name) > -1) {
|
|
575
|
+
throw new Error(`Dynamic element name: "${elem.name}" is duplicated`);
|
|
576
|
+
}
|
|
577
|
+
duplicates.push(elem.name);
|
|
578
|
+
const dynamicElement = this.dynamicForm.get(elem.name);
|
|
579
|
+
if (!dynamicElement) {
|
|
580
|
+
this.dynamicForm.addControl(elem.name, this._dynamicFormsService.createFormControl(elem));
|
|
581
|
+
this._subscribeToControlStatusChanges(elem.name);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
dynamicElement.setValue(elem.default);
|
|
585
|
+
dynamicElement.markAsPristine();
|
|
586
|
+
dynamicElement.markAsUntouched();
|
|
587
|
+
if (elem.disabled) {
|
|
588
|
+
dynamicElement.disable();
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
dynamicElement.enable();
|
|
592
|
+
}
|
|
593
|
+
dynamicElement.setValidators(this._dynamicFormsService.createValidators(elem));
|
|
594
|
+
}
|
|
595
|
+
// copy objects so they are only changes when calling this method
|
|
596
|
+
this._renderedElements.push(Object.assign({}, elem));
|
|
597
|
+
});
|
|
598
|
+
// call a change detection since the whole form might change
|
|
599
|
+
this._changeDetectorRef.detectChanges();
|
|
600
|
+
timer(0)
|
|
601
|
+
.toPromise()
|
|
602
|
+
.then(() => {
|
|
603
|
+
// call a markForCheck so elements are rendered correctly in OnPush
|
|
604
|
+
this._changeDetectorRef.markForCheck();
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
_clearRemovedElements() {
|
|
608
|
+
this._renderedElements = this._renderedElements.filter((renderedElement) => !this._elements.some((element) => element.name === renderedElement.name));
|
|
609
|
+
// remove elements that were removed from the array
|
|
610
|
+
this._renderedElements.forEach((elem) => {
|
|
611
|
+
this._destroyControl$.next(elem.name);
|
|
612
|
+
this.dynamicForm.removeControl(elem.name);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
// Updates component when manually adding errors to controls
|
|
616
|
+
_subscribeToControlStatusChanges(elementName) {
|
|
617
|
+
const control = this.controls[elementName];
|
|
618
|
+
const controlDestroyed$ = this._destroyControl$.pipe(filter((destroyedElementName) => destroyedElementName === elementName));
|
|
619
|
+
control.statusChanges
|
|
620
|
+
.pipe(takeUntil(this._destroy$), takeUntil(controlDestroyed$))
|
|
621
|
+
.subscribe(() => {
|
|
622
|
+
this._changeDetectorRef.markForCheck();
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
TdDynamicFormsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsComponent, deps: [{ token: i2.UntypedFormBuilder }, { token: TdDynamicFormsService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
627
|
+
TdDynamicFormsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdDynamicFormsComponent, selector: "td-dynamic-forms", inputs: { elements: "elements" }, queries: [{ propertyName: "_errorTemplates", predicate: TdDynamicFormsErrorTemplateDirective, descendants: true }], ngImport: i0, 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 ?? false\"\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{flex-flow:row wrap;box-sizing:border-box;display:flex;align-items:center;align-content:center;max-width:100%;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"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: TdDynamicElementComponent, selector: "td-dynamic-element", inputs: ["dynamicControl", "label", "hint", "name", "type", "required", "min", "max", "minLength", "maxLength", "selections", "multiple", "customConfig", "errorMessageTemplate", "placeholder"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
628
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdDynamicFormsComponent, decorators: [{
|
|
629
|
+
type: Component,
|
|
630
|
+
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 ?? false\"\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{flex-flow:row wrap;box-sizing:border-box;display:flex;align-items:center;align-content:center;max-width:100%;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"] }]
|
|
631
|
+
}], ctorParameters: function () { return [{ type: i2.UntypedFormBuilder }, { type: TdDynamicFormsService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { _errorTemplates: [{
|
|
632
|
+
type: ContentChildren,
|
|
633
|
+
args: [TdDynamicFormsErrorTemplateDirective, { descendants: true }]
|
|
634
|
+
}], elements: [{
|
|
635
|
+
type: Input
|
|
636
|
+
}] } });
|
|
637
|
+
|
|
638
|
+
const TD_DYNAMIC_FORMS = [
|
|
639
|
+
TdDynamicFormsComponent,
|
|
640
|
+
TdDynamicElementComponent,
|
|
641
|
+
TdDynamicElementDirective,
|
|
642
|
+
TdDynamicFormsErrorTemplateDirective,
|
|
643
|
+
];
|
|
644
|
+
const TD_DYNAMIC_FORMS_ENTRY_COMPONENTS = [
|
|
645
|
+
TdDynamicInputComponent,
|
|
646
|
+
TdDynamicFileInputComponent,
|
|
647
|
+
TdDynamicTextareaComponent,
|
|
648
|
+
TdDynamicSlideToggleComponent,
|
|
649
|
+
TdDynamicCheckboxComponent,
|
|
650
|
+
TdDynamicSliderComponent,
|
|
651
|
+
TdDynamicSelectComponent,
|
|
652
|
+
TdDynamicDatepickerComponent,
|
|
653
|
+
];
|
|
654
|
+
class CovalentDynamicFormsModule {
|
|
655
|
+
}
|
|
656
|
+
CovalentDynamicFormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentDynamicFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
657
|
+
CovalentDynamicFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: CovalentDynamicFormsModule, declarations: [TdDynamicFormsComponent,
|
|
658
|
+
TdDynamicElementComponent,
|
|
659
|
+
TdDynamicElementDirective,
|
|
660
|
+
TdDynamicFormsErrorTemplateDirective,
|
|
661
|
+
TdDynamicInputComponent,
|
|
662
|
+
TdDynamicFileInputComponent,
|
|
663
|
+
TdDynamicTextareaComponent,
|
|
664
|
+
TdDynamicSlideToggleComponent,
|
|
665
|
+
TdDynamicCheckboxComponent,
|
|
666
|
+
TdDynamicSliderComponent,
|
|
667
|
+
TdDynamicSelectComponent,
|
|
668
|
+
TdDynamicDatepickerComponent], imports: [CommonModule,
|
|
669
|
+
ReactiveFormsModule,
|
|
670
|
+
MatFormFieldModule,
|
|
671
|
+
MatInputModule,
|
|
672
|
+
MatSelectModule,
|
|
673
|
+
MatCheckboxModule,
|
|
674
|
+
MatSliderModule,
|
|
675
|
+
MatSlideToggleModule,
|
|
676
|
+
MatIconModule,
|
|
677
|
+
MatButtonModule,
|
|
678
|
+
MatDatepickerModule,
|
|
679
|
+
CovalentFileModule], exports: [TdDynamicFormsComponent,
|
|
680
|
+
TdDynamicElementComponent,
|
|
681
|
+
TdDynamicElementDirective,
|
|
682
|
+
TdDynamicFormsErrorTemplateDirective, TdDynamicInputComponent,
|
|
683
|
+
TdDynamicFileInputComponent,
|
|
684
|
+
TdDynamicTextareaComponent,
|
|
685
|
+
TdDynamicSlideToggleComponent,
|
|
686
|
+
TdDynamicCheckboxComponent,
|
|
687
|
+
TdDynamicSliderComponent,
|
|
688
|
+
TdDynamicSelectComponent,
|
|
689
|
+
TdDynamicDatepickerComponent] });
|
|
690
|
+
CovalentDynamicFormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentDynamicFormsModule, providers: [DYNAMIC_FORMS_PROVIDER], imports: [CommonModule,
|
|
691
|
+
ReactiveFormsModule,
|
|
692
|
+
MatFormFieldModule,
|
|
693
|
+
MatInputModule,
|
|
694
|
+
MatSelectModule,
|
|
695
|
+
MatCheckboxModule,
|
|
696
|
+
MatSliderModule,
|
|
697
|
+
MatSlideToggleModule,
|
|
698
|
+
MatIconModule,
|
|
699
|
+
MatButtonModule,
|
|
700
|
+
MatDatepickerModule,
|
|
701
|
+
CovalentFileModule] });
|
|
702
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentDynamicFormsModule, decorators: [{
|
|
703
|
+
type: NgModule,
|
|
704
|
+
args: [{
|
|
705
|
+
declarations: [
|
|
706
|
+
TdDynamicFormsComponent,
|
|
707
|
+
TdDynamicElementComponent,
|
|
708
|
+
TdDynamicElementDirective,
|
|
709
|
+
TdDynamicFormsErrorTemplateDirective,
|
|
710
|
+
TdDynamicInputComponent,
|
|
711
|
+
TdDynamicFileInputComponent,
|
|
712
|
+
TdDynamicTextareaComponent,
|
|
713
|
+
TdDynamicSlideToggleComponent,
|
|
714
|
+
TdDynamicCheckboxComponent,
|
|
715
|
+
TdDynamicSliderComponent,
|
|
716
|
+
TdDynamicSelectComponent,
|
|
717
|
+
TdDynamicDatepickerComponent,
|
|
718
|
+
],
|
|
719
|
+
imports: [
|
|
720
|
+
CommonModule,
|
|
721
|
+
ReactiveFormsModule,
|
|
722
|
+
MatFormFieldModule,
|
|
723
|
+
MatInputModule,
|
|
724
|
+
MatSelectModule,
|
|
725
|
+
MatCheckboxModule,
|
|
726
|
+
MatSliderModule,
|
|
727
|
+
MatSlideToggleModule,
|
|
728
|
+
MatIconModule,
|
|
729
|
+
MatButtonModule,
|
|
730
|
+
MatDatepickerModule,
|
|
731
|
+
CovalentFileModule,
|
|
732
|
+
],
|
|
733
|
+
exports: [...TD_DYNAMIC_FORMS, ...TD_DYNAMIC_FORMS_ENTRY_COMPONENTS],
|
|
734
|
+
providers: [DYNAMIC_FORMS_PROVIDER],
|
|
735
|
+
}]
|
|
736
|
+
}] });
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Generated bundle index. Do not edit.
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
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 };
|
|
743
|
+
//# sourceMappingURL=covalent-dynamic-forms.mjs.map
|