@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
|
@@ -1,814 +0,0 @@
|
|
|
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
|
-
control;
|
|
35
|
-
label = '';
|
|
36
|
-
hint = '';
|
|
37
|
-
type;
|
|
38
|
-
required = false;
|
|
39
|
-
name = '';
|
|
40
|
-
min;
|
|
41
|
-
max;
|
|
42
|
-
minLength;
|
|
43
|
-
maxLength;
|
|
44
|
-
errorMessageTemplate;
|
|
45
|
-
placeholder = '';
|
|
46
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
47
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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"] }] });
|
|
48
|
-
}
|
|
49
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicInputComponent, decorators: [{
|
|
50
|
-
type: Component,
|
|
51
|
-
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"] }]
|
|
52
|
-
}] });
|
|
53
|
-
|
|
54
|
-
class TdDynamicFileInputComponent {
|
|
55
|
-
control;
|
|
56
|
-
required = false;
|
|
57
|
-
label = '';
|
|
58
|
-
name = '';
|
|
59
|
-
hint = '';
|
|
60
|
-
errorMessageTemplate;
|
|
61
|
-
placeholder = '';
|
|
62
|
-
_handlefileDrop(value) {
|
|
63
|
-
this.control?.setValue(value);
|
|
64
|
-
}
|
|
65
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFileInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
66
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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"] }] });
|
|
67
|
-
}
|
|
68
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFileInputComponent, decorators: [{
|
|
69
|
-
type: Component,
|
|
70
|
-
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"] }]
|
|
71
|
-
}] });
|
|
72
|
-
|
|
73
|
-
class TdDynamicTextareaComponent {
|
|
74
|
-
control;
|
|
75
|
-
label = '';
|
|
76
|
-
hint = '';
|
|
77
|
-
name = '';
|
|
78
|
-
required = false;
|
|
79
|
-
errorMessageTemplate;
|
|
80
|
-
placeholder = '';
|
|
81
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicTextareaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
82
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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"] }] });
|
|
83
|
-
}
|
|
84
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicTextareaComponent, decorators: [{
|
|
85
|
-
type: Component,
|
|
86
|
-
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"] }]
|
|
87
|
-
}] });
|
|
88
|
-
|
|
89
|
-
class TdDynamicSlideToggleComponent {
|
|
90
|
-
control;
|
|
91
|
-
label = '';
|
|
92
|
-
name = '';
|
|
93
|
-
hint = '';
|
|
94
|
-
required = false;
|
|
95
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicSlideToggleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
96
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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"] }] });
|
|
97
|
-
}
|
|
98
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicSlideToggleComponent, decorators: [{
|
|
99
|
-
type: Component,
|
|
100
|
-
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" }]
|
|
101
|
-
}] });
|
|
102
|
-
|
|
103
|
-
class TdDynamicCheckboxComponent {
|
|
104
|
-
control;
|
|
105
|
-
label = '';
|
|
106
|
-
name = '';
|
|
107
|
-
hint = '';
|
|
108
|
-
required = false;
|
|
109
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
110
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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]" }] });
|
|
111
|
-
}
|
|
112
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicCheckboxComponent, decorators: [{
|
|
113
|
-
type: Component,
|
|
114
|
-
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" }]
|
|
115
|
-
}] });
|
|
116
|
-
|
|
117
|
-
class TdDynamicSliderComponent {
|
|
118
|
-
_changeDetectorRef;
|
|
119
|
-
control;
|
|
120
|
-
label = '';
|
|
121
|
-
required = false;
|
|
122
|
-
name = '';
|
|
123
|
-
hint = '';
|
|
124
|
-
min;
|
|
125
|
-
max;
|
|
126
|
-
constructor(_changeDetectorRef) {
|
|
127
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
128
|
-
}
|
|
129
|
-
_handleBlur() {
|
|
130
|
-
setTimeout(() => {
|
|
131
|
-
this._changeDetectorRef.markForCheck();
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicSliderComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
135
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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"] }] });
|
|
136
|
-
}
|
|
137
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicSliderComponent, decorators: [{
|
|
138
|
-
type: Component,
|
|
139
|
-
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"] }]
|
|
140
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
|
|
141
|
-
|
|
142
|
-
class TdDynamicSelectComponent {
|
|
143
|
-
control;
|
|
144
|
-
label = '';
|
|
145
|
-
hint = '';
|
|
146
|
-
name = '';
|
|
147
|
-
required = false;
|
|
148
|
-
selections;
|
|
149
|
-
multiple;
|
|
150
|
-
errorMessageTemplate;
|
|
151
|
-
placeholder = '';
|
|
152
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
153
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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", "panelWidth", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }] });
|
|
154
|
-
}
|
|
155
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicSelectComponent, decorators: [{
|
|
156
|
-
type: Component,
|
|
157
|
-
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"] }]
|
|
158
|
-
}] });
|
|
159
|
-
|
|
160
|
-
class TdDynamicDatepickerComponent {
|
|
161
|
-
control;
|
|
162
|
-
label = '';
|
|
163
|
-
hint = '';
|
|
164
|
-
name = '';
|
|
165
|
-
type;
|
|
166
|
-
required = false;
|
|
167
|
-
min;
|
|
168
|
-
max;
|
|
169
|
-
errorMessageTemplate;
|
|
170
|
-
placeholder = '';
|
|
171
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicDatepickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
172
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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"] }] });
|
|
173
|
-
}
|
|
174
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicDatepickerComponent, decorators: [{
|
|
175
|
-
type: Component,
|
|
176
|
-
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"] }]
|
|
177
|
-
}] });
|
|
178
|
-
|
|
179
|
-
var TdDynamicType;
|
|
180
|
-
(function (TdDynamicType) {
|
|
181
|
-
TdDynamicType["Text"] = "text";
|
|
182
|
-
TdDynamicType["Boolean"] = "boolean";
|
|
183
|
-
TdDynamicType["Number"] = "number";
|
|
184
|
-
TdDynamicType["Array"] = "array";
|
|
185
|
-
TdDynamicType["Date"] = "date";
|
|
186
|
-
})(TdDynamicType || (TdDynamicType = {}));
|
|
187
|
-
var TdDynamicElement;
|
|
188
|
-
(function (TdDynamicElement) {
|
|
189
|
-
TdDynamicElement["Input"] = "input";
|
|
190
|
-
TdDynamicElement["Datepicker"] = "datepicker";
|
|
191
|
-
TdDynamicElement["Password"] = "password";
|
|
192
|
-
TdDynamicElement["Textarea"] = "textarea";
|
|
193
|
-
TdDynamicElement["Slider"] = "slider";
|
|
194
|
-
TdDynamicElement["SlideToggle"] = "slide-toggle";
|
|
195
|
-
TdDynamicElement["Checkbox"] = "checkbox";
|
|
196
|
-
TdDynamicElement["Select"] = "select";
|
|
197
|
-
TdDynamicElement["FileInput"] = "file-input";
|
|
198
|
-
})(TdDynamicElement || (TdDynamicElement = {}));
|
|
199
|
-
const DYNAMIC_ELEMENT_NAME_REGEX = /^[^0-9][^@]*$/;
|
|
200
|
-
class TdDynamicFormsService {
|
|
201
|
-
/**
|
|
202
|
-
* Method to validate if the [name] is a proper element name.
|
|
203
|
-
* Throws error if name is not valid.
|
|
204
|
-
*/
|
|
205
|
-
validateDynamicElementName(name) {
|
|
206
|
-
if (!DYNAMIC_ELEMENT_NAME_REGEX.test(name)) {
|
|
207
|
-
throw new Error('Dynamic element name: "${name}" is not valid.');
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Gets component to be rendered depending on [TdDynamicElement | TdDynamicType]
|
|
212
|
-
* Throws error if it does not exists or not supported.
|
|
213
|
-
*/
|
|
214
|
-
getDynamicElement(element) {
|
|
215
|
-
switch (element) {
|
|
216
|
-
case TdDynamicType.Text:
|
|
217
|
-
case TdDynamicType.Number:
|
|
218
|
-
case TdDynamicElement.Input:
|
|
219
|
-
case TdDynamicElement.Password:
|
|
220
|
-
return TdDynamicInputComponent;
|
|
221
|
-
case TdDynamicElement.Textarea:
|
|
222
|
-
return TdDynamicTextareaComponent;
|
|
223
|
-
case TdDynamicType.Boolean:
|
|
224
|
-
case TdDynamicElement.SlideToggle:
|
|
225
|
-
return TdDynamicSlideToggleComponent;
|
|
226
|
-
case TdDynamicElement.Checkbox:
|
|
227
|
-
return TdDynamicCheckboxComponent;
|
|
228
|
-
case TdDynamicElement.Slider:
|
|
229
|
-
return TdDynamicSliderComponent;
|
|
230
|
-
case TdDynamicType.Array:
|
|
231
|
-
case TdDynamicElement.Select:
|
|
232
|
-
return TdDynamicSelectComponent;
|
|
233
|
-
case TdDynamicElement.FileInput:
|
|
234
|
-
return TdDynamicFileInputComponent;
|
|
235
|
-
case TdDynamicElement.Datepicker:
|
|
236
|
-
case TdDynamicType.Date:
|
|
237
|
-
return TdDynamicDatepickerComponent;
|
|
238
|
-
default:
|
|
239
|
-
throw new Error(`Error: type ${element} does not exist or not supported.`);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Creates form control for element depending [ITdDynamicElementConfig] properties.
|
|
244
|
-
*/
|
|
245
|
-
createFormControl(config) {
|
|
246
|
-
const validator = this.createValidators(config);
|
|
247
|
-
return new UntypedFormControl({ value: config.default, disabled: config.disabled }, validator);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Creates form validationdepending [ITdDynamicElementConfig] properties.
|
|
251
|
-
*/
|
|
252
|
-
createValidators(config) {
|
|
253
|
-
let validator = null;
|
|
254
|
-
if (config.required) {
|
|
255
|
-
validator = Validators.required;
|
|
256
|
-
}
|
|
257
|
-
if (config.max || config.max === 0) {
|
|
258
|
-
validator = Validators.compose([
|
|
259
|
-
validator,
|
|
260
|
-
Validators.max(parseFloat(config.max)),
|
|
261
|
-
]);
|
|
262
|
-
}
|
|
263
|
-
if (config.min || config.min === 0) {
|
|
264
|
-
validator = Validators.compose([
|
|
265
|
-
validator,
|
|
266
|
-
Validators.min(parseFloat(config.min)),
|
|
267
|
-
]);
|
|
268
|
-
}
|
|
269
|
-
if (config.maxLength || config.maxLength === 0) {
|
|
270
|
-
validator = Validators.compose([
|
|
271
|
-
validator,
|
|
272
|
-
Validators.maxLength(parseFloat(config.maxLength)),
|
|
273
|
-
]);
|
|
274
|
-
}
|
|
275
|
-
if (config.minLength || config.minLength === 0) {
|
|
276
|
-
validator = Validators.compose([
|
|
277
|
-
validator,
|
|
278
|
-
Validators.minLength(parseFloat(config.minLength)),
|
|
279
|
-
]);
|
|
280
|
-
}
|
|
281
|
-
// Add provided custom validators to the validator function
|
|
282
|
-
if (config.validators) {
|
|
283
|
-
config.validators.forEach((validatorConfig) => {
|
|
284
|
-
validator = Validators.compose([
|
|
285
|
-
validator,
|
|
286
|
-
validatorConfig.validator,
|
|
287
|
-
]);
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
return validator;
|
|
291
|
-
}
|
|
292
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
293
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsService });
|
|
294
|
-
}
|
|
295
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsService, decorators: [{
|
|
296
|
-
type: Injectable
|
|
297
|
-
}] });
|
|
298
|
-
function DYNAMIC_FORMS_PROVIDER_FACTORY(parent) {
|
|
299
|
-
return parent || new TdDynamicFormsService();
|
|
300
|
-
}
|
|
301
|
-
const DYNAMIC_FORMS_PROVIDER = {
|
|
302
|
-
// If there is already a service available, use that. Otherwise, provide a new one.
|
|
303
|
-
provide: TdDynamicFormsService,
|
|
304
|
-
deps: [[new Optional(), new SkipSelf(), TdDynamicFormsService]],
|
|
305
|
-
useFactory: DYNAMIC_FORMS_PROVIDER_FACTORY,
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
class TdDynamicElementBase {
|
|
309
|
-
_changeDetectorRef;
|
|
310
|
-
constructor(_changeDetectorRef) {
|
|
311
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
/* tslint:disable-next-line */
|
|
315
|
-
const _TdDynamicElementMixinBase = mixinControlValueAccessor(TdDynamicElementBase);
|
|
316
|
-
class TdDynamicFormsErrorTemplateDirective extends CdkPortal {
|
|
317
|
-
templateRef;
|
|
318
|
-
tdDynamicFormsError;
|
|
319
|
-
constructor(templateRef, viewContainerRef) {
|
|
320
|
-
super(templateRef, viewContainerRef);
|
|
321
|
-
this.templateRef = templateRef;
|
|
322
|
-
}
|
|
323
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsErrorTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
324
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.7", type: TdDynamicFormsErrorTemplateDirective, selector: "[tdDynamicFormsError]ng-template", inputs: { tdDynamicFormsError: "tdDynamicFormsError" }, usesInheritance: true, ngImport: i0 });
|
|
325
|
-
}
|
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsErrorTemplateDirective, decorators: [{
|
|
327
|
-
type: Directive,
|
|
328
|
-
args: [{ selector: '[tdDynamicFormsError]ng-template' }]
|
|
329
|
-
}], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { tdDynamicFormsError: [{
|
|
330
|
-
type: Input
|
|
331
|
-
}] } });
|
|
332
|
-
class TdDynamicElementDirective {
|
|
333
|
-
viewContainer;
|
|
334
|
-
constructor(viewContainer) {
|
|
335
|
-
this.viewContainer = viewContainer;
|
|
336
|
-
}
|
|
337
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicElementDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
338
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.7", type: TdDynamicElementDirective, selector: "[tdDynamicContainer]", ngImport: i0 });
|
|
339
|
-
}
|
|
340
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicElementDirective, decorators: [{
|
|
341
|
-
type: Directive,
|
|
342
|
-
args: [{
|
|
343
|
-
selector: '[tdDynamicContainer]',
|
|
344
|
-
}]
|
|
345
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
|
|
346
|
-
class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
347
|
-
_injector;
|
|
348
|
-
_dynamicFormsService;
|
|
349
|
-
_instance;
|
|
350
|
-
/**
|
|
351
|
-
* Sets form control of the element.
|
|
352
|
-
*/
|
|
353
|
-
dynamicControl;
|
|
354
|
-
/**
|
|
355
|
-
* Sets label to be displayed.
|
|
356
|
-
*/
|
|
357
|
-
label = '';
|
|
358
|
-
/**
|
|
359
|
-
* Sets hint to be displayed.
|
|
360
|
-
*/
|
|
361
|
-
hint = '';
|
|
362
|
-
/**
|
|
363
|
-
* Sets name to be displayed as attribute.
|
|
364
|
-
*/
|
|
365
|
-
name = '';
|
|
366
|
-
/**
|
|
367
|
-
* Sets type or element of element to be rendered.
|
|
368
|
-
* Throws error if does not exist or no supported.
|
|
369
|
-
*/
|
|
370
|
-
type;
|
|
371
|
-
/**
|
|
372
|
-
* Sets required validation checkup (if supported by element).
|
|
373
|
-
*/
|
|
374
|
-
required;
|
|
375
|
-
/**
|
|
376
|
-
* Sets min validation checkup (if supported by element).
|
|
377
|
-
*/
|
|
378
|
-
min;
|
|
379
|
-
/**
|
|
380
|
-
* Sets max validation checkup (if supported by element).
|
|
381
|
-
*/
|
|
382
|
-
max;
|
|
383
|
-
/**
|
|
384
|
-
* Sets minLength validation checkup (if supported by element).
|
|
385
|
-
*/
|
|
386
|
-
minLength;
|
|
387
|
-
/**
|
|
388
|
-
* Sets maxLength validation checkup (if supported by element).
|
|
389
|
-
*/
|
|
390
|
-
maxLength;
|
|
391
|
-
/**
|
|
392
|
-
* Sets selections for array elements (if supported by element).
|
|
393
|
-
*/
|
|
394
|
-
selections;
|
|
395
|
-
/**
|
|
396
|
-
* Sets multiple property for array elements (if supported by element).
|
|
397
|
-
*/
|
|
398
|
-
multiple;
|
|
399
|
-
/**
|
|
400
|
-
* Sets any additional properties on custom component.
|
|
401
|
-
*/
|
|
402
|
-
customConfig;
|
|
403
|
-
/**
|
|
404
|
-
* Sets error message template so it can be injected into dynamic components.
|
|
405
|
-
*/
|
|
406
|
-
errorMessageTemplate;
|
|
407
|
-
/**
|
|
408
|
-
* Sets the placeholder message
|
|
409
|
-
*/
|
|
410
|
-
placeholder = '';
|
|
411
|
-
childElement;
|
|
412
|
-
get maxAttr() {
|
|
413
|
-
return this.max;
|
|
414
|
-
}
|
|
415
|
-
get minAttr() {
|
|
416
|
-
return this.min;
|
|
417
|
-
}
|
|
418
|
-
constructor(_injector, _dynamicFormsService, _changeDetectorRef) {
|
|
419
|
-
super(_changeDetectorRef);
|
|
420
|
-
this._injector = _injector;
|
|
421
|
-
this._dynamicFormsService = _dynamicFormsService;
|
|
422
|
-
}
|
|
423
|
-
ngOnInit() {
|
|
424
|
-
const component = this.type instanceof Type
|
|
425
|
-
? this.type
|
|
426
|
-
: this._dynamicFormsService.getDynamicElement(this.type);
|
|
427
|
-
const ref = this.childElement.viewContainer.createComponent(component, {
|
|
428
|
-
injector: this._injector,
|
|
429
|
-
});
|
|
430
|
-
this._instance = ref.instance;
|
|
431
|
-
this._instance.control = this.dynamicControl;
|
|
432
|
-
this._instance.label = this.label;
|
|
433
|
-
this._instance.hint = this.hint;
|
|
434
|
-
this._instance.name = this.name;
|
|
435
|
-
this._instance.type = this.type;
|
|
436
|
-
this._instance.value = this.value;
|
|
437
|
-
this._instance.required = this.required;
|
|
438
|
-
this._instance.min = this.min;
|
|
439
|
-
this._instance.max = this.max;
|
|
440
|
-
this._instance.minLength = this.minLength;
|
|
441
|
-
this._instance.maxLength = this.maxLength;
|
|
442
|
-
this._instance.selections = this.selections;
|
|
443
|
-
this._instance.multiple = this.multiple;
|
|
444
|
-
this._instance.errorMessageTemplate = this.errorMessageTemplate;
|
|
445
|
-
this._instance.placeholder = this.placeholder;
|
|
446
|
-
if (this.customConfig) {
|
|
447
|
-
Object.getOwnPropertyNames(this.customConfig).forEach((name) => {
|
|
448
|
-
if (this.customConfig) {
|
|
449
|
-
this._instance[name] = this.customConfig[name];
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Reassign any inputs that have changed
|
|
456
|
-
*/
|
|
457
|
-
ngOnChanges(changes) {
|
|
458
|
-
if (this._instance) {
|
|
459
|
-
for (const prop of Object.keys(changes)) {
|
|
460
|
-
this._instance[prop] = changes[prop].currentValue;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicElementComponent, deps: [{ token: i0.Injector }, { token: TdDynamicFormsService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
465
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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: [
|
|
466
|
-
TdDynamicFormsService,
|
|
467
|
-
{
|
|
468
|
-
provide: NG_VALUE_ACCESSOR,
|
|
469
|
-
useExisting: TdDynamicElementComponent,
|
|
470
|
-
multi: true,
|
|
471
|
-
},
|
|
472
|
-
], 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]" }] });
|
|
473
|
-
}
|
|
474
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicElementComponent, decorators: [{
|
|
475
|
-
type: Component,
|
|
476
|
-
args: [{
|
|
477
|
-
providers: [
|
|
478
|
-
TdDynamicFormsService,
|
|
479
|
-
{
|
|
480
|
-
provide: NG_VALUE_ACCESSOR,
|
|
481
|
-
useExisting: TdDynamicElementComponent,
|
|
482
|
-
multi: true,
|
|
483
|
-
},
|
|
484
|
-
],
|
|
485
|
-
selector: 'td-dynamic-element',
|
|
486
|
-
template: '<div tdDynamicContainer></div>',
|
|
487
|
-
}]
|
|
488
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: TdDynamicFormsService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { dynamicControl: [{
|
|
489
|
-
type: Input
|
|
490
|
-
}], label: [{
|
|
491
|
-
type: Input
|
|
492
|
-
}], hint: [{
|
|
493
|
-
type: Input
|
|
494
|
-
}], name: [{
|
|
495
|
-
type: Input
|
|
496
|
-
}], type: [{
|
|
497
|
-
type: Input
|
|
498
|
-
}], required: [{
|
|
499
|
-
type: Input
|
|
500
|
-
}], min: [{
|
|
501
|
-
type: Input
|
|
502
|
-
}], max: [{
|
|
503
|
-
type: Input
|
|
504
|
-
}], minLength: [{
|
|
505
|
-
type: Input
|
|
506
|
-
}], maxLength: [{
|
|
507
|
-
type: Input
|
|
508
|
-
}], selections: [{
|
|
509
|
-
type: Input
|
|
510
|
-
}], multiple: [{
|
|
511
|
-
type: Input
|
|
512
|
-
}], customConfig: [{
|
|
513
|
-
type: Input
|
|
514
|
-
}], errorMessageTemplate: [{
|
|
515
|
-
type: Input
|
|
516
|
-
}], placeholder: [{
|
|
517
|
-
type: Input
|
|
518
|
-
}], childElement: [{
|
|
519
|
-
type: ViewChild,
|
|
520
|
-
args: [TdDynamicElementDirective, { static: true }]
|
|
521
|
-
}], maxAttr: [{
|
|
522
|
-
type: HostBinding,
|
|
523
|
-
args: ['attr.max']
|
|
524
|
-
}], minAttr: [{
|
|
525
|
-
type: HostBinding,
|
|
526
|
-
args: ['attr.min']
|
|
527
|
-
}] } });
|
|
528
|
-
|
|
529
|
-
class TdDynamicFormsComponent {
|
|
530
|
-
_formBuilder;
|
|
531
|
-
_dynamicFormsService;
|
|
532
|
-
_changeDetectorRef;
|
|
533
|
-
_renderedElements = [];
|
|
534
|
-
_elements;
|
|
535
|
-
_templateMap = new Map();
|
|
536
|
-
_destroy$ = new Subject();
|
|
537
|
-
_destroyControl$ = new Subject();
|
|
538
|
-
_errorTemplates;
|
|
539
|
-
dynamicForm;
|
|
540
|
-
/**
|
|
541
|
-
* elements: ITdDynamicElementConfig[]
|
|
542
|
-
* JS Object that will render the elements depending on its config.
|
|
543
|
-
* [name] property is required.
|
|
544
|
-
*/
|
|
545
|
-
set elements(elements) {
|
|
546
|
-
if (elements) {
|
|
547
|
-
this._elements = elements;
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
this._elements = [];
|
|
551
|
-
}
|
|
552
|
-
this._rerenderElements();
|
|
553
|
-
}
|
|
554
|
-
get elements() {
|
|
555
|
-
return this._renderedElements;
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Getter property for dynamic [FormGroup].
|
|
559
|
-
*/
|
|
560
|
-
get form() {
|
|
561
|
-
return this.dynamicForm;
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* Getter property for [valid] of dynamic [FormGroup].
|
|
565
|
-
*/
|
|
566
|
-
get valid() {
|
|
567
|
-
if (this.dynamicForm) {
|
|
568
|
-
return this.dynamicForm.valid;
|
|
569
|
-
}
|
|
570
|
-
return false;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Getter property for [value] of dynamic [FormGroup].
|
|
574
|
-
*/
|
|
575
|
-
get value() {
|
|
576
|
-
if (this.dynamicForm) {
|
|
577
|
-
return this.dynamicForm.value;
|
|
578
|
-
}
|
|
579
|
-
return {};
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Getter property for [errors] of dynamic [FormGroup].
|
|
583
|
-
*/
|
|
584
|
-
get errors() {
|
|
585
|
-
if (this.dynamicForm) {
|
|
586
|
-
const errors = {};
|
|
587
|
-
for (const name of Object.keys(this.dynamicForm.controls)) {
|
|
588
|
-
errors[name] = this.dynamicForm.controls[name].errors;
|
|
589
|
-
}
|
|
590
|
-
return errors;
|
|
591
|
-
}
|
|
592
|
-
return {};
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Getter property for [controls] of dynamic [FormGroup].
|
|
596
|
-
*/
|
|
597
|
-
get controls() {
|
|
598
|
-
if (this.dynamicForm) {
|
|
599
|
-
return this.dynamicForm.controls;
|
|
600
|
-
}
|
|
601
|
-
return {};
|
|
602
|
-
}
|
|
603
|
-
constructor(_formBuilder, _dynamicFormsService, _changeDetectorRef) {
|
|
604
|
-
this._formBuilder = _formBuilder;
|
|
605
|
-
this._dynamicFormsService = _dynamicFormsService;
|
|
606
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
607
|
-
this.dynamicForm = this._formBuilder.group({});
|
|
608
|
-
}
|
|
609
|
-
ngAfterContentInit() {
|
|
610
|
-
this._updateErrorTemplates();
|
|
611
|
-
}
|
|
612
|
-
ngOnDestroy() {
|
|
613
|
-
this._destroy$.next(0);
|
|
614
|
-
this._destroy$.complete();
|
|
615
|
-
this._destroyControl$.complete();
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Refreshes the form and rerenders all validator/element modifications.
|
|
619
|
-
*/
|
|
620
|
-
refresh() {
|
|
621
|
-
this._rerenderElements();
|
|
622
|
-
this._updateErrorTemplates();
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Getter method for error template references
|
|
626
|
-
*/
|
|
627
|
-
getErrorTemplateRef(name) {
|
|
628
|
-
return this._templateMap.get(name);
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Loads error templates and sets them in a map for faster access.
|
|
632
|
-
*/
|
|
633
|
-
_updateErrorTemplates() {
|
|
634
|
-
this._templateMap = new Map();
|
|
635
|
-
for (const errorTemplate of this._errorTemplates.toArray()) {
|
|
636
|
-
this._templateMap.set(errorTemplate.tdDynamicFormsError ?? '', errorTemplate.templateRef);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
_rerenderElements() {
|
|
640
|
-
this._clearRemovedElements();
|
|
641
|
-
this._renderedElements = [];
|
|
642
|
-
const duplicates = [];
|
|
643
|
-
this._elements.forEach((elem) => {
|
|
644
|
-
this._dynamicFormsService.validateDynamicElementName(elem.name);
|
|
645
|
-
if (duplicates.indexOf(elem.name) > -1) {
|
|
646
|
-
throw new Error(`Dynamic element name: "${elem.name}" is duplicated`);
|
|
647
|
-
}
|
|
648
|
-
duplicates.push(elem.name);
|
|
649
|
-
const dynamicElement = this.dynamicForm.get(elem.name);
|
|
650
|
-
if (!dynamicElement) {
|
|
651
|
-
this.dynamicForm.addControl(elem.name, this._dynamicFormsService.createFormControl(elem));
|
|
652
|
-
this._subscribeToControlStatusChanges(elem.name);
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
dynamicElement.setValue(elem.default);
|
|
656
|
-
dynamicElement.markAsPristine();
|
|
657
|
-
dynamicElement.markAsUntouched();
|
|
658
|
-
if (elem.disabled) {
|
|
659
|
-
dynamicElement.disable();
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
dynamicElement.enable();
|
|
663
|
-
}
|
|
664
|
-
dynamicElement.setValidators(this._dynamicFormsService.createValidators(elem));
|
|
665
|
-
}
|
|
666
|
-
// copy objects so they are only changes when calling this method
|
|
667
|
-
this._renderedElements.push(Object.assign({}, elem));
|
|
668
|
-
});
|
|
669
|
-
// call a change detection since the whole form might change
|
|
670
|
-
this._changeDetectorRef.detectChanges();
|
|
671
|
-
timer(0)
|
|
672
|
-
.toPromise()
|
|
673
|
-
.then(() => {
|
|
674
|
-
// call a markForCheck so elements are rendered correctly in OnPush
|
|
675
|
-
this._changeDetectorRef.markForCheck();
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
_clearRemovedElements() {
|
|
679
|
-
this._renderedElements = this._renderedElements.filter((renderedElement) => !this._elements.some((element) => element.name === renderedElement.name));
|
|
680
|
-
// remove elements that were removed from the array
|
|
681
|
-
this._renderedElements.forEach((elem) => {
|
|
682
|
-
this._destroyControl$.next(elem.name);
|
|
683
|
-
this.dynamicForm.removeControl(elem.name);
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
// Updates component when manually adding errors to controls
|
|
687
|
-
_subscribeToControlStatusChanges(elementName) {
|
|
688
|
-
const control = this.controls[elementName];
|
|
689
|
-
const controlDestroyed$ = this._destroyControl$.pipe(filter((destroyedElementName) => destroyedElementName === elementName));
|
|
690
|
-
control.statusChanges
|
|
691
|
-
.pipe(takeUntil(this._destroy$), takeUntil(controlDestroyed$))
|
|
692
|
-
.subscribe(() => {
|
|
693
|
-
this._changeDetectorRef.markForCheck();
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsComponent, deps: [{ token: i2.UntypedFormBuilder }, { token: TdDynamicFormsService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
697
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", 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 });
|
|
698
|
-
}
|
|
699
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: TdDynamicFormsComponent, decorators: [{
|
|
700
|
-
type: Component,
|
|
701
|
-
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"] }]
|
|
702
|
-
}], ctorParameters: function () { return [{ type: i2.UntypedFormBuilder }, { type: TdDynamicFormsService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { _errorTemplates: [{
|
|
703
|
-
type: ContentChildren,
|
|
704
|
-
args: [TdDynamicFormsErrorTemplateDirective, { descendants: true }]
|
|
705
|
-
}], elements: [{
|
|
706
|
-
type: Input
|
|
707
|
-
}] } });
|
|
708
|
-
|
|
709
|
-
const TD_DYNAMIC_FORMS = [
|
|
710
|
-
TdDynamicFormsComponent,
|
|
711
|
-
TdDynamicElementComponent,
|
|
712
|
-
TdDynamicElementDirective,
|
|
713
|
-
TdDynamicFormsErrorTemplateDirective,
|
|
714
|
-
];
|
|
715
|
-
const TD_DYNAMIC_FORMS_ENTRY_COMPONENTS = [
|
|
716
|
-
TdDynamicInputComponent,
|
|
717
|
-
TdDynamicFileInputComponent,
|
|
718
|
-
TdDynamicTextareaComponent,
|
|
719
|
-
TdDynamicSlideToggleComponent,
|
|
720
|
-
TdDynamicCheckboxComponent,
|
|
721
|
-
TdDynamicSliderComponent,
|
|
722
|
-
TdDynamicSelectComponent,
|
|
723
|
-
TdDynamicDatepickerComponent,
|
|
724
|
-
];
|
|
725
|
-
class CovalentDynamicFormsModule {
|
|
726
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CovalentDynamicFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
727
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: CovalentDynamicFormsModule, declarations: [TdDynamicFormsComponent,
|
|
728
|
-
TdDynamicElementComponent,
|
|
729
|
-
TdDynamicElementDirective,
|
|
730
|
-
TdDynamicFormsErrorTemplateDirective,
|
|
731
|
-
TdDynamicInputComponent,
|
|
732
|
-
TdDynamicFileInputComponent,
|
|
733
|
-
TdDynamicTextareaComponent,
|
|
734
|
-
TdDynamicSlideToggleComponent,
|
|
735
|
-
TdDynamicCheckboxComponent,
|
|
736
|
-
TdDynamicSliderComponent,
|
|
737
|
-
TdDynamicSelectComponent,
|
|
738
|
-
TdDynamicDatepickerComponent], imports: [CommonModule,
|
|
739
|
-
ReactiveFormsModule,
|
|
740
|
-
MatFormFieldModule,
|
|
741
|
-
MatInputModule,
|
|
742
|
-
MatSelectModule,
|
|
743
|
-
MatCheckboxModule,
|
|
744
|
-
MatSliderModule,
|
|
745
|
-
MatSlideToggleModule,
|
|
746
|
-
MatIconModule,
|
|
747
|
-
MatButtonModule,
|
|
748
|
-
MatDatepickerModule,
|
|
749
|
-
CovalentFileModule], exports: [TdDynamicFormsComponent,
|
|
750
|
-
TdDynamicElementComponent,
|
|
751
|
-
TdDynamicElementDirective,
|
|
752
|
-
TdDynamicFormsErrorTemplateDirective, TdDynamicInputComponent,
|
|
753
|
-
TdDynamicFileInputComponent,
|
|
754
|
-
TdDynamicTextareaComponent,
|
|
755
|
-
TdDynamicSlideToggleComponent,
|
|
756
|
-
TdDynamicCheckboxComponent,
|
|
757
|
-
TdDynamicSliderComponent,
|
|
758
|
-
TdDynamicSelectComponent,
|
|
759
|
-
TdDynamicDatepickerComponent] });
|
|
760
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CovalentDynamicFormsModule, providers: [DYNAMIC_FORMS_PROVIDER], imports: [CommonModule,
|
|
761
|
-
ReactiveFormsModule,
|
|
762
|
-
MatFormFieldModule,
|
|
763
|
-
MatInputModule,
|
|
764
|
-
MatSelectModule,
|
|
765
|
-
MatCheckboxModule,
|
|
766
|
-
MatSliderModule,
|
|
767
|
-
MatSlideToggleModule,
|
|
768
|
-
MatIconModule,
|
|
769
|
-
MatButtonModule,
|
|
770
|
-
MatDatepickerModule,
|
|
771
|
-
CovalentFileModule] });
|
|
772
|
-
}
|
|
773
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CovalentDynamicFormsModule, decorators: [{
|
|
774
|
-
type: NgModule,
|
|
775
|
-
args: [{
|
|
776
|
-
declarations: [
|
|
777
|
-
TdDynamicFormsComponent,
|
|
778
|
-
TdDynamicElementComponent,
|
|
779
|
-
TdDynamicElementDirective,
|
|
780
|
-
TdDynamicFormsErrorTemplateDirective,
|
|
781
|
-
TdDynamicInputComponent,
|
|
782
|
-
TdDynamicFileInputComponent,
|
|
783
|
-
TdDynamicTextareaComponent,
|
|
784
|
-
TdDynamicSlideToggleComponent,
|
|
785
|
-
TdDynamicCheckboxComponent,
|
|
786
|
-
TdDynamicSliderComponent,
|
|
787
|
-
TdDynamicSelectComponent,
|
|
788
|
-
TdDynamicDatepickerComponent,
|
|
789
|
-
],
|
|
790
|
-
imports: [
|
|
791
|
-
CommonModule,
|
|
792
|
-
ReactiveFormsModule,
|
|
793
|
-
MatFormFieldModule,
|
|
794
|
-
MatInputModule,
|
|
795
|
-
MatSelectModule,
|
|
796
|
-
MatCheckboxModule,
|
|
797
|
-
MatSliderModule,
|
|
798
|
-
MatSlideToggleModule,
|
|
799
|
-
MatIconModule,
|
|
800
|
-
MatButtonModule,
|
|
801
|
-
MatDatepickerModule,
|
|
802
|
-
CovalentFileModule,
|
|
803
|
-
],
|
|
804
|
-
exports: [...TD_DYNAMIC_FORMS, ...TD_DYNAMIC_FORMS_ENTRY_COMPONENTS],
|
|
805
|
-
providers: [DYNAMIC_FORMS_PROVIDER],
|
|
806
|
-
}]
|
|
807
|
-
}] });
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* Generated bundle index. Do not edit.
|
|
811
|
-
*/
|
|
812
|
-
|
|
813
|
-
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 };
|
|
814
|
-
//# sourceMappingURL=covalent-dynamic-forms.mjs.map
|