ngx-iso-form 1.0.0
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/README.md +116 -0
- package/esm2022/lib/Models/Control.mjs +2 -0
- package/esm2022/lib/Models/IsoForm.mjs +8 -0
- package/esm2022/lib/Models/Schema.mjs +2 -0
- package/esm2022/lib/components/controls/iso-base-control.component.mjs +25 -0
- package/esm2022/lib/components/controls/iso-mat-checkbox.component.mjs +17 -0
- package/esm2022/lib/components/controls/iso-mat-currency.component.mjs +18 -0
- package/esm2022/lib/components/controls/iso-mat-date.component.mjs +19 -0
- package/esm2022/lib/components/controls/iso-mat-datetime.component.mjs +19 -0
- package/esm2022/lib/components/controls/iso-mat-input.component.mjs +18 -0
- package/esm2022/lib/components/controls/iso-mat-select.component.mjs +19 -0
- package/esm2022/lib/components/controls/iso-mat-textarea.component.mjs +18 -0
- package/esm2022/lib/components/index.mjs +10 -0
- package/esm2022/lib/components/iso-control/iso-control.component.mjs +72 -0
- package/esm2022/lib/ngx-iso-form.component.mjs +173 -0
- package/esm2022/lib/ngx-iso-form.module.mjs +115 -0
- package/esm2022/lib/ngx-iso-form.service.mjs +228 -0
- package/esm2022/lib/shared/components/dynamic/ngx-dynamic.component.mjs +33 -0
- package/esm2022/lib/shared/directives/component-content.directive.mjs +16 -0
- package/esm2022/lib/shared/models/component.model.mjs +7 -0
- package/esm2022/lib/shared/pipe/error.pipe.mjs +33 -0
- package/esm2022/lib/shared/pipe/general.pipe.mjs +33 -0
- package/esm2022/lib/shared/pipe/translate.pipe.mjs +33 -0
- package/esm2022/lib/shared/services/component.service.mjs +15 -0
- package/esm2022/lib/shared/services/control.service.mjs +35 -0
- package/esm2022/lib/shared/services/index.mjs +3 -0
- package/esm2022/ngx-iso-form.mjs +5 -0
- package/esm2022/public-api.mjs +9 -0
- package/fesm2022/ngx-iso-form.mjs +859 -0
- package/fesm2022/ngx-iso-form.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/Models/Control.d.ts +20 -0
- package/lib/Models/IsoForm.d.ts +5 -0
- package/lib/Models/Schema.d.ts +28 -0
- package/lib/components/controls/iso-base-control.component.d.ts +10 -0
- package/lib/components/controls/iso-mat-checkbox.component.d.ts +6 -0
- package/lib/components/controls/iso-mat-currency.component.d.ts +6 -0
- package/lib/components/controls/iso-mat-date.component.d.ts +6 -0
- package/lib/components/controls/iso-mat-datetime.component.d.ts +6 -0
- package/lib/components/controls/iso-mat-input.component.d.ts +6 -0
- package/lib/components/controls/iso-mat-select.component.d.ts +6 -0
- package/lib/components/controls/iso-mat-textarea.component.d.ts +6 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/iso-control/iso-control.component.d.ts +21 -0
- package/lib/ngx-iso-form.component.d.ts +34 -0
- package/lib/ngx-iso-form.module.d.ts +33 -0
- package/lib/ngx-iso-form.service.d.ts +17 -0
- package/lib/shared/components/dynamic/ngx-dynamic.component.d.ts +13 -0
- package/lib/shared/directives/component-content.directive.d.ts +8 -0
- package/lib/shared/models/component.model.d.ts +6 -0
- package/lib/shared/pipe/error.pipe.d.ts +10 -0
- package/lib/shared/pipe/general.pipe.d.ts +10 -0
- package/lib/shared/pipe/translate.pipe.d.ts +10 -0
- package/lib/shared/services/component.service.d.ts +5 -0
- package/lib/shared/services/control.service.d.ts +6 -0
- package/lib/shared/services/index.d.ts +2 -0
- package/lib/styles/index.scss +33 -0
- package/lib/styles/ngx-iso-form.component.scss +10 -0
- package/package.json +47 -0
- package/public-api.d.ts +6 -0
|
@@ -0,0 +1,859 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Component, ChangeDetectionStrategy, Input, Pipe, Directive, ViewChild, forwardRef, Injectable, Inject, NgModule } from '@angular/core';
|
|
3
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
4
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
5
|
+
import * as i2 from '@angular/forms';
|
|
6
|
+
import { Validators, NG_VALUE_ACCESSOR, FormGroup, FormControl, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
7
|
+
import * as i4$2 from '@angular/material/expansion';
|
|
8
|
+
import { MatExpansionModule } from '@angular/material/expansion';
|
|
9
|
+
import * as i3 from '@angular/material/form-field';
|
|
10
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
11
|
+
import * as i5$1 from '@angular/material/core';
|
|
12
|
+
import { MatNativeDateModule } from '@angular/material/core';
|
|
13
|
+
import * as i9 from '@angular/material/icon';
|
|
14
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
15
|
+
import * as i4 from '@angular/material/input';
|
|
16
|
+
import { MatInputModule } from '@angular/material/input';
|
|
17
|
+
import * as i6 from '@angular/material/button';
|
|
18
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
19
|
+
import * as i5 from '@angular/material/datepicker';
|
|
20
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
21
|
+
import * as i4$1 from '@angular/material/select';
|
|
22
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
23
|
+
import * as i1 from '@ngx-translate/core';
|
|
24
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
25
|
+
import * as i1$1 from '@angular/common';
|
|
26
|
+
import { __decorate } from 'tslib';
|
|
27
|
+
|
|
28
|
+
class IsoBaseControlComponent {
|
|
29
|
+
getKeys(errors) {
|
|
30
|
+
if (errors) {
|
|
31
|
+
return Object.keys(errors);
|
|
32
|
+
}
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoBaseControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
36
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoBaseControlComponent, selector: "iso-base", inputs: { control: "control", formControl: "formControl" }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
37
|
+
}
|
|
38
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoBaseControlComponent, decorators: [{
|
|
39
|
+
type: Component,
|
|
40
|
+
args: [{
|
|
41
|
+
selector: 'iso-base',
|
|
42
|
+
template: '',
|
|
43
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
44
|
+
}]
|
|
45
|
+
}], propDecorators: { control: [{
|
|
46
|
+
type: Input
|
|
47
|
+
}], formControl: [{
|
|
48
|
+
type: Input
|
|
49
|
+
}] } });
|
|
50
|
+
|
|
51
|
+
class IsoTranslatePipe {
|
|
52
|
+
constructor(translateService) {
|
|
53
|
+
this.translateService = translateService;
|
|
54
|
+
}
|
|
55
|
+
transform(value, id, defaultValue) {
|
|
56
|
+
let key = `iso.${value}`;
|
|
57
|
+
let tran = this.translateService.instant(key);
|
|
58
|
+
if (tran === key) {
|
|
59
|
+
key = `iso.${id.toLocaleLowerCase()}`;
|
|
60
|
+
tran = this.translateService.instant(key);
|
|
61
|
+
if (tran === key) {
|
|
62
|
+
return defaultValue;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (tran.label) {
|
|
66
|
+
return tran.label;
|
|
67
|
+
}
|
|
68
|
+
return defaultValue;
|
|
69
|
+
}
|
|
70
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoTranslatePipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
71
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.2", ngImport: i0, type: IsoTranslatePipe, name: "trans", pure: false }); }
|
|
72
|
+
}
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoTranslatePipe, decorators: [{
|
|
74
|
+
type: Pipe,
|
|
75
|
+
args: [{
|
|
76
|
+
name: 'trans',
|
|
77
|
+
pure: false
|
|
78
|
+
}]
|
|
79
|
+
}], ctorParameters: function () { return [{ type: i1.TranslateService }]; } });
|
|
80
|
+
|
|
81
|
+
class IsoErrorPipe {
|
|
82
|
+
constructor(translateService) {
|
|
83
|
+
this.translateService = translateService;
|
|
84
|
+
}
|
|
85
|
+
transform(value, id, errorKey, defaultValue) {
|
|
86
|
+
let key = `iso.${value}`;
|
|
87
|
+
let tran = this.translateService.instant(key);
|
|
88
|
+
if (tran === key) {
|
|
89
|
+
key = `iso.${id.toLocaleLowerCase()}`;
|
|
90
|
+
tran = this.translateService.instant(key);
|
|
91
|
+
if (tran === key) {
|
|
92
|
+
return defaultValue;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (tran.error && tran.error[errorKey]) {
|
|
96
|
+
return tran.error[errorKey];
|
|
97
|
+
}
|
|
98
|
+
return defaultValue;
|
|
99
|
+
}
|
|
100
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoErrorPipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
101
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.2", ngImport: i0, type: IsoErrorPipe, name: "error", pure: false }); }
|
|
102
|
+
}
|
|
103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoErrorPipe, decorators: [{
|
|
104
|
+
type: Pipe,
|
|
105
|
+
args: [{
|
|
106
|
+
name: 'error',
|
|
107
|
+
pure: false
|
|
108
|
+
}]
|
|
109
|
+
}], ctorParameters: function () { return [{ type: i1.TranslateService }]; } });
|
|
110
|
+
|
|
111
|
+
class IsoMatDate extends IsoBaseControlComponent {
|
|
112
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatDate, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
113
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatDate, selector: "iso-mat-date", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput [matDatepicker]=\"picker\" [formControl]=\"formControl\">\r\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\r\n <mat-datepicker #picker></mat-datepicker>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.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.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.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.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i5.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i5.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }] }); }
|
|
114
|
+
}
|
|
115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatDate, decorators: [{
|
|
116
|
+
type: Component,
|
|
117
|
+
args: [{ selector: 'iso-mat-date', template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput [matDatepicker]=\"picker\" [formControl]=\"formControl\">\r\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\r\n <mat-datepicker #picker></mat-datepicker>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>" }]
|
|
118
|
+
}] });
|
|
119
|
+
|
|
120
|
+
class IsoGeneralPipe {
|
|
121
|
+
constructor(translateService) {
|
|
122
|
+
this.translateService = translateService;
|
|
123
|
+
}
|
|
124
|
+
transform(value, id, generalKey, defaultValue) {
|
|
125
|
+
let key = `iso.${value}`;
|
|
126
|
+
let tran = this.translateService.instant(key);
|
|
127
|
+
if (tran === key) {
|
|
128
|
+
key = `iso.${id.toLocaleLowerCase()}`;
|
|
129
|
+
tran = this.translateService.instant(key);
|
|
130
|
+
if (tran === key) {
|
|
131
|
+
return defaultValue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (tran.general && tran.general[generalKey]) {
|
|
135
|
+
return tran.general[generalKey];
|
|
136
|
+
}
|
|
137
|
+
return defaultValue;
|
|
138
|
+
}
|
|
139
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoGeneralPipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
140
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.2", ngImport: i0, type: IsoGeneralPipe, name: "general", pure: false }); }
|
|
141
|
+
}
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoGeneralPipe, decorators: [{
|
|
143
|
+
type: Pipe,
|
|
144
|
+
args: [{
|
|
145
|
+
name: 'general',
|
|
146
|
+
pure: false
|
|
147
|
+
}]
|
|
148
|
+
}], ctorParameters: function () { return [{ type: i1.TranslateService }]; } });
|
|
149
|
+
|
|
150
|
+
class IsoMatDateTime extends IsoBaseControlComponent {
|
|
151
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatDateTime, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
152
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatDateTime, selector: "iso-mat-datetime", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput placeholder=\"{{ control.name }}\" [formControl]=\"formControl\" [attr.minlength]=\"control.minLength\" [attr.maxlength]=\"control.maxLength\">\r\n <mat-hint>{{ control.id | general: control.id : \"format\" : \"YYYY-MM-DDThh:mm:ss.sss+/-hh:mm\" }}</mat-hint>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n \r\n</mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.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.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: 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: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }, { kind: "pipe", type: IsoGeneralPipe, name: "general" }] }); }
|
|
153
|
+
}
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatDateTime, decorators: [{
|
|
155
|
+
type: Component,
|
|
156
|
+
args: [{ selector: 'iso-mat-datetime', template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput placeholder=\"{{ control.name }}\" [formControl]=\"formControl\" [attr.minlength]=\"control.minLength\" [attr.maxlength]=\"control.maxLength\">\r\n <mat-hint>{{ control.id | general: control.id : \"format\" : \"YYYY-MM-DDThh:mm:ss.sss+/-hh:mm\" }}</mat-hint>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n \r\n</mat-form-field>" }]
|
|
157
|
+
}] });
|
|
158
|
+
|
|
159
|
+
class IsoMatInput extends IsoBaseControlComponent {
|
|
160
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatInput, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
161
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatInput, selector: "iso-mat-input", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput placeholder=\"{{ control.name }}\" [formControl]=\"formControl\" [attr.minlength]=\"control.minLength\" [attr.maxlength]=\"control.maxLength\">\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n \r\n</mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.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.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: 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: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }] }); }
|
|
162
|
+
}
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatInput, decorators: [{
|
|
164
|
+
type: Component,
|
|
165
|
+
args: [{ selector: 'iso-mat-input', template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput placeholder=\"{{ control.name }}\" [formControl]=\"formControl\" [attr.minlength]=\"control.minLength\" [attr.maxlength]=\"control.maxLength\">\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n \r\n</mat-form-field>" }]
|
|
166
|
+
}] });
|
|
167
|
+
|
|
168
|
+
class IsoMatCheckbox extends IsoBaseControlComponent {
|
|
169
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatCheckbox, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
170
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatCheckbox, selector: "iso-mat-checkbox", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-checkbox [formControl]=\"formControl\">{{ control.name | trans: control.id : control.name }}</mat-checkbox>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }] }); }
|
|
171
|
+
}
|
|
172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatCheckbox, decorators: [{
|
|
173
|
+
type: Component,
|
|
174
|
+
args: [{ selector: 'iso-mat-checkbox', template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-checkbox [formControl]=\"formControl\">{{ control.name | trans: control.id : control.name }}</mat-checkbox>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>" }]
|
|
175
|
+
}] });
|
|
176
|
+
|
|
177
|
+
class IsoMatTextarea extends IsoBaseControlComponent {
|
|
178
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatTextarea, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
179
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatTextarea, selector: "iso-mat-textarea", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-full\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <textarea matInput placeholder=\"{{control.name}}\" [formControl]=\"formControl\"></textarea>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.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.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: 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: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }] }); }
|
|
180
|
+
}
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatTextarea, decorators: [{
|
|
182
|
+
type: Component,
|
|
183
|
+
args: [{ selector: 'iso-mat-textarea', template: "<mat-form-field class=\"form-control form-control-full\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <textarea matInput placeholder=\"{{control.name}}\" [formControl]=\"formControl\"></textarea>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>" }]
|
|
184
|
+
}] });
|
|
185
|
+
|
|
186
|
+
class IsoMatSelect extends IsoBaseControlComponent {
|
|
187
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatSelect, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
188
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatSelect, selector: "iso-mat-select", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <mat-select [formControl]=\"formControl\">\r\n <mat-option *ngFor=\"let item of control.values\" [value]=\"item\">\r\n {{item}}\r\n </mat-option>\r\n </mat-select>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n </mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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: "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"] }, { kind: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }] }); }
|
|
189
|
+
}
|
|
190
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatSelect, decorators: [{
|
|
191
|
+
type: Component,
|
|
192
|
+
args: [{ selector: 'iso-mat-select', template: "<mat-form-field class=\"form-control form-control-m\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <mat-select [formControl]=\"formControl\">\r\n <mat-option *ngFor=\"let item of control.values\" [value]=\"item\">\r\n {{item}}\r\n </mat-option>\r\n </mat-select>\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item + \" validation failed\" }}\r\n </div>\r\n </ng-container>\r\n </mat-form-field>" }]
|
|
193
|
+
}] });
|
|
194
|
+
|
|
195
|
+
class IsoMatCurrency extends IsoBaseControlComponent {
|
|
196
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatCurrency, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
197
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: IsoMatCurrency, selector: "iso-mat-currency", usesInheritance: true, ngImport: i0, template: "<mat-form-field class=\"form-control form-control-s\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput placeholder=\"{{ control.name }}\" [formControl]=\"formControl\" [attr.maxlength]=\"control.maxLength\">\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>", dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.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.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: 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: "pipe", type: IsoTranslatePipe, name: "trans" }, { kind: "pipe", type: IsoErrorPipe, name: "error" }] }); }
|
|
198
|
+
}
|
|
199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: IsoMatCurrency, decorators: [{
|
|
200
|
+
type: Component,
|
|
201
|
+
args: [{ selector: 'iso-mat-currency', template: "<mat-form-field class=\"form-control form-control-s\">\r\n <mat-label>{{ control.name | trans: control.id : control.name }}</mat-label>\r\n <input matInput placeholder=\"{{ control.name }}\" [formControl]=\"formControl\" [attr.maxlength]=\"control.maxLength\">\r\n <ng-container *ngFor=\"let item of getKeys(formControl.errors)\">\r\n <div *ngIf=\"formControl.errors?.[item] && formControl.touched\" class=\"iso-mat-error\">\r\n {{ control.name | error: control.id : item : item }}\r\n </div>\r\n </ng-container>\r\n</mat-form-field>" }]
|
|
202
|
+
}] });
|
|
203
|
+
|
|
204
|
+
class ComponentModel {
|
|
205
|
+
constructor(component, prop) {
|
|
206
|
+
this.component = component;
|
|
207
|
+
this.prop = prop;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
class ControlService {
|
|
212
|
+
getComponentByType(controlModel, formControl) {
|
|
213
|
+
if (!controlModel.dataType) {
|
|
214
|
+
console.log("controlModel name {0}", controlModel.name);
|
|
215
|
+
throw `Argument null exception dataType`;
|
|
216
|
+
}
|
|
217
|
+
switch (controlModel.dataType.toLocaleLowerCase()) {
|
|
218
|
+
case "string":
|
|
219
|
+
case "decimal":
|
|
220
|
+
if (controlModel.name.toLocaleLowerCase().indexOf('ccy') > -1) {
|
|
221
|
+
return new ComponentModel(IsoMatCurrency, { "control": controlModel, "formControl": formControl });
|
|
222
|
+
}
|
|
223
|
+
if (controlModel.values?.length > 0) {
|
|
224
|
+
return new ComponentModel(IsoMatSelect, { "control": controlModel, "formControl": formControl });
|
|
225
|
+
}
|
|
226
|
+
if (controlModel.maxLength && parseInt(controlModel.maxLength, 10) > 50) {
|
|
227
|
+
return new ComponentModel(IsoMatTextarea, { "control": controlModel, "formControl": formControl });
|
|
228
|
+
}
|
|
229
|
+
return new ComponentModel(IsoMatInput, { "control": controlModel, "formControl": formControl });
|
|
230
|
+
case "date":
|
|
231
|
+
return new ComponentModel(IsoMatDate, { "control": controlModel, "formControl": formControl });
|
|
232
|
+
case "datetime":
|
|
233
|
+
return new ComponentModel(IsoMatDateTime, { "control": controlModel, "formControl": formControl });
|
|
234
|
+
case "boolean":
|
|
235
|
+
return new ComponentModel(IsoMatDate, { "control": controlModel, "formControl": formControl });
|
|
236
|
+
case "any":
|
|
237
|
+
return new ComponentModel(IsoMatTextarea, { "control": controlModel, "formControl": formControl });
|
|
238
|
+
default:
|
|
239
|
+
return new ComponentModel(IsoMatInput, { "control": controlModel, "formControl": formControl });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
class ComponentDirective {
|
|
245
|
+
constructor(viewContainerRef) {
|
|
246
|
+
this.viewContainerRef = viewContainerRef;
|
|
247
|
+
}
|
|
248
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: ComponentDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
249
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.2", type: ComponentDirective, selector: "[componentContent]", ngImport: i0 }); }
|
|
250
|
+
}
|
|
251
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: ComponentDirective, decorators: [{
|
|
252
|
+
type: Directive,
|
|
253
|
+
args: [{
|
|
254
|
+
selector: '[componentContent]',
|
|
255
|
+
}]
|
|
256
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
|
|
257
|
+
|
|
258
|
+
class NgxDynamicComponent {
|
|
259
|
+
constructor() { }
|
|
260
|
+
ngOnInit() {
|
|
261
|
+
this.loadComponent();
|
|
262
|
+
}
|
|
263
|
+
loadComponent() {
|
|
264
|
+
const viewContainerRef = this.componentContent.viewContainerRef;
|
|
265
|
+
viewContainerRef.clear();
|
|
266
|
+
const componentRef = viewContainerRef.createComponent(this.componentModel.component);
|
|
267
|
+
if (this.componentModel.prop) {
|
|
268
|
+
Object.assign(componentRef.instance, this.componentModel.prop);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxDynamicComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
272
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: NgxDynamicComponent, selector: "ngx-dynamic", inputs: { componentModel: "componentModel" }, viewQueries: [{ propertyName: "componentContent", first: true, predicate: ComponentDirective, descendants: true, static: true }], ngImport: i0, template: `<div><ng-template componentContent></ng-template></div>`, isInline: true, dependencies: [{ kind: "directive", type: ComponentDirective, selector: "[componentContent]" }] }); }
|
|
273
|
+
}
|
|
274
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxDynamicComponent, decorators: [{
|
|
275
|
+
type: Component,
|
|
276
|
+
args: [{
|
|
277
|
+
selector: 'ngx-dynamic',
|
|
278
|
+
template: `<div><ng-template componentContent></ng-template></div>`
|
|
279
|
+
}]
|
|
280
|
+
}], ctorParameters: function () { return []; }, propDecorators: { componentModel: [{
|
|
281
|
+
type: Input
|
|
282
|
+
}], componentContent: [{
|
|
283
|
+
type: ViewChild,
|
|
284
|
+
args: [ComponentDirective, { static: true }]
|
|
285
|
+
}] } });
|
|
286
|
+
|
|
287
|
+
class NgxIsoControlComponent {
|
|
288
|
+
constructor(controlService) {
|
|
289
|
+
this.controlService = controlService;
|
|
290
|
+
this.addValidator = () => {
|
|
291
|
+
try {
|
|
292
|
+
const minOccurs = parseInt(this.control.minOccurs, 10);
|
|
293
|
+
let minLength = parseInt(this.control.minLength, 10);
|
|
294
|
+
const maxLength = parseInt(this.control.maxLength, 10);
|
|
295
|
+
if (minOccurs) {
|
|
296
|
+
this.formControl.addValidators(Validators.required);
|
|
297
|
+
}
|
|
298
|
+
if (!Number.isNaN(minLength)) {
|
|
299
|
+
this.formControl.addValidators(Validators.minLength(minLength));
|
|
300
|
+
}
|
|
301
|
+
if (!Number.isNaN(maxLength)) {
|
|
302
|
+
this.formControl.addValidators(Validators.maxLength(maxLength));
|
|
303
|
+
}
|
|
304
|
+
if (this.control.pattern) {
|
|
305
|
+
this.formControl.addValidators(Validators.pattern(this.control.pattern));
|
|
306
|
+
}
|
|
307
|
+
if (this.control.fractionDigits) {
|
|
308
|
+
minLength = Number.isNaN(minLength) ? 0 : minLength;
|
|
309
|
+
const pattern = `^[\\d\\.\\d{0,${this.control.fractionDigits}}]{${minLength},${this.control.totalDigits}}$`;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
console.error(e);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
ngOnInit() {
|
|
318
|
+
this.addValidator();
|
|
319
|
+
this.component = this.controlService.getComponentByType(this.control, this.formControl);
|
|
320
|
+
}
|
|
321
|
+
writeValue(obj) {
|
|
322
|
+
}
|
|
323
|
+
registerOnChange(fn) {
|
|
324
|
+
}
|
|
325
|
+
registerOnTouched(fn) {
|
|
326
|
+
}
|
|
327
|
+
setDisabledState(isDisabled) {
|
|
328
|
+
}
|
|
329
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoControlComponent, deps: [{ token: ControlService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
330
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: NgxIsoControlComponent, selector: "ngx-iso-control", inputs: { formControl: "formControl", control: "control" }, providers: [
|
|
331
|
+
{
|
|
332
|
+
provide: NG_VALUE_ACCESSOR,
|
|
333
|
+
useExisting: forwardRef(() => NgxIsoControlComponent),
|
|
334
|
+
multi: true,
|
|
335
|
+
}
|
|
336
|
+
], ngImport: i0, template: "<ngx-dynamic *ngIf=\"component\" [componentModel]=\"component\"></ngx-dynamic>", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: NgxDynamicComponent, selector: "ngx-dynamic", inputs: ["componentModel"] }] }); }
|
|
337
|
+
}
|
|
338
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoControlComponent, decorators: [{
|
|
339
|
+
type: Component,
|
|
340
|
+
args: [{ selector: 'ngx-iso-control', providers: [
|
|
341
|
+
{
|
|
342
|
+
provide: NG_VALUE_ACCESSOR,
|
|
343
|
+
useExisting: forwardRef(() => NgxIsoControlComponent),
|
|
344
|
+
multi: true,
|
|
345
|
+
}
|
|
346
|
+
], template: "<ngx-dynamic *ngIf=\"component\" [componentModel]=\"component\"></ngx-dynamic>" }]
|
|
347
|
+
}], ctorParameters: function () { return [{ type: ControlService }]; }, propDecorators: { formControl: [{
|
|
348
|
+
type: Input
|
|
349
|
+
}], control: [{
|
|
350
|
+
type: Input
|
|
351
|
+
}] } });
|
|
352
|
+
|
|
353
|
+
class NgxIsoService {
|
|
354
|
+
constructor(fb) {
|
|
355
|
+
this.fb = fb;
|
|
356
|
+
this._formModel = [];
|
|
357
|
+
this.sanitize = (obj) => {
|
|
358
|
+
if (obj === null || obj === "") {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
if (Array.isArray(obj)) {
|
|
362
|
+
const cleanedObj = [];
|
|
363
|
+
for (const index in obj) {
|
|
364
|
+
const cleanedValue = this.sanitize(obj[index]);
|
|
365
|
+
if (cleanedValue !== null && cleanedValue !== "" && Object.keys(cleanedValue).length > 0 && (!Array.isArray(cleanedValue) || cleanedValue.length > 0)) {
|
|
366
|
+
cleanedObj.push(cleanedValue);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return cleanedObj;
|
|
370
|
+
}
|
|
371
|
+
else if (typeof obj === 'object') {
|
|
372
|
+
const cleanedObj = {};
|
|
373
|
+
for (const key in obj) {
|
|
374
|
+
const cleanedValue = this.sanitize(obj[key]);
|
|
375
|
+
if (cleanedValue !== null && cleanedValue !== "" && Object.keys(cleanedValue).length > 0 && (!Array.isArray(cleanedValue) || cleanedValue.length > 0)) {
|
|
376
|
+
cleanedObj[key] = cleanedValue;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return cleanedObj;
|
|
380
|
+
}
|
|
381
|
+
return obj;
|
|
382
|
+
};
|
|
383
|
+
this.getFormModel = (object, key) => {
|
|
384
|
+
if (object) {
|
|
385
|
+
if (object.elements.length) {
|
|
386
|
+
if (object.id === key) {
|
|
387
|
+
return object;
|
|
388
|
+
}
|
|
389
|
+
for (let i = 0; i < object.elements.length; i++) {
|
|
390
|
+
const obj = this.getFormModel(object.elements[i], key);
|
|
391
|
+
if (obj)
|
|
392
|
+
return obj;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
if (object.id === key) {
|
|
397
|
+
return object;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
maxOccurs(maxOccurs) {
|
|
404
|
+
return maxOccurs === 'unbounded' || parseInt(maxOccurs, 10) > 1;
|
|
405
|
+
}
|
|
406
|
+
initFormModel(model, form) {
|
|
407
|
+
if (typeof model === 'object') {
|
|
408
|
+
for (const key in model) {
|
|
409
|
+
if (Array.isArray(model[key])) {
|
|
410
|
+
const parentNode = this.getFormModel(this._formModel[0], key);
|
|
411
|
+
const item = model[key];
|
|
412
|
+
const formArray = form.get(key);
|
|
413
|
+
if (formArray && formArray.length !== item.length) {
|
|
414
|
+
const newEle = structuredClone(parentNode.elements[parentNode.elements.length - 1]);
|
|
415
|
+
if (!(newEle.maxOccurs && parseInt(newEle.maxOccurs, 10) <= parentNode.elements.length)) {
|
|
416
|
+
const newKeys = [];
|
|
417
|
+
const groupControls = this.getFormGroupControls(newEle.elements, newKeys, parentNode.elements.length - 1);
|
|
418
|
+
parentNode.elements.push(newEle);
|
|
419
|
+
formArray.push(groupControls);
|
|
420
|
+
parentNode.elements.forEach((element) => {
|
|
421
|
+
if (!element.minOccurs || parseInt(element.minOccurs, 10) === 0) {
|
|
422
|
+
element.minOccurs = "1";
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
for (let i = 0; i < item.length; i++) {
|
|
428
|
+
const formArray = form.get(key);
|
|
429
|
+
if (formArray) {
|
|
430
|
+
const frmGroup = formArray.at(i);
|
|
431
|
+
if (frmGroup) {
|
|
432
|
+
this.initFormModel(item[i], frmGroup);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else if (typeof model[key] === 'object') {
|
|
438
|
+
const node = this.getFormModel(this._formModel[0], key);
|
|
439
|
+
if (node && (!node.minOccurs || parseInt(node.minOccurs, 10) === 0)) {
|
|
440
|
+
node.minOccurs = "1";
|
|
441
|
+
}
|
|
442
|
+
const _form = form.get(key);
|
|
443
|
+
if (_form) {
|
|
444
|
+
if (node.dataType === 'choice') {
|
|
445
|
+
const choickKey = Object.keys(model[key])[0];
|
|
446
|
+
const choiceEle = node.elements.find((item) => item.id === choickKey);
|
|
447
|
+
node.choiceFormControl.setValue(choickKey);
|
|
448
|
+
choiceEle.hidden = false;
|
|
449
|
+
const newNode = structuredClone(choiceEle);
|
|
450
|
+
if (newNode.elements.length) {
|
|
451
|
+
const group = this.getFormGroupControls(newNode.elements, [], 0, true);
|
|
452
|
+
_form.addControl(newNode.id, group);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
const control = this.getFormControl('');
|
|
456
|
+
_form.addControl(newNode.id, control);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
this.initFormModel(model[key], _form);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
const _form = form.get(key);
|
|
464
|
+
_form.setValue(model[key]);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
else if (Array.isArray(model)) {
|
|
469
|
+
for (let i = 0; i < model.length; i++) {
|
|
470
|
+
const frmGroup = form.at(i);
|
|
471
|
+
this.initFormModel(model[i], frmGroup);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
getFormGroupControls(json, keys, index = 0, choiceEle = false) {
|
|
476
|
+
let control = {};
|
|
477
|
+
let controls;
|
|
478
|
+
let value = {};
|
|
479
|
+
json.forEach((item) => {
|
|
480
|
+
item.hidden = choiceEle;
|
|
481
|
+
value = item.elements;
|
|
482
|
+
const id = item.id;
|
|
483
|
+
const element = { ...item, elements: [], id };
|
|
484
|
+
if (item.elements.length > 0) {
|
|
485
|
+
let choice = item.dataType === 'choice';
|
|
486
|
+
if (choice) {
|
|
487
|
+
element.choiceFormControl = this.getFormControl('');
|
|
488
|
+
}
|
|
489
|
+
if (this.maxOccurs(item.maxOccurs)) {
|
|
490
|
+
element.uniqueId = `${element.id}_${index}`;
|
|
491
|
+
keys.push({ id: element.id, multi: true, xpath: element.xpath, elements: [element] });
|
|
492
|
+
const data = this.getFormGroupControls(item.elements, element.elements, index, choice);
|
|
493
|
+
controls = this.fb.array([]);
|
|
494
|
+
if (!choice) {
|
|
495
|
+
controls.push(data);
|
|
496
|
+
}
|
|
497
|
+
control[id] = controls;
|
|
498
|
+
}
|
|
499
|
+
else if (item.multi && !item.isFormControls) {
|
|
500
|
+
keys.push({ id: element.id, multi: true, xpath: element.xpath, elements: element.elements });
|
|
501
|
+
const data = this.getFormGroupControls(item.elements[item.elements.length - 1].elements, element.elements, index, choice);
|
|
502
|
+
controls = this.fb.array([]);
|
|
503
|
+
if (!choice) {
|
|
504
|
+
controls.push(data);
|
|
505
|
+
}
|
|
506
|
+
control[id] = controls;
|
|
507
|
+
}
|
|
508
|
+
else if (item.multi && item.isFormControls) {
|
|
509
|
+
if (item.elements.length > 1) {
|
|
510
|
+
item.elements.splice(1, item.elements.length - 1);
|
|
511
|
+
}
|
|
512
|
+
keys.push(item);
|
|
513
|
+
control[id] = this.fb.array([this.getFormControl(item.value || "")]);
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
keys.push(element);
|
|
517
|
+
const data = this.getFormGroupControls(item.elements, element.elements, index, choice);
|
|
518
|
+
if (!choice) {
|
|
519
|
+
control[id] = data;
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
control[id] = this.fb.group({});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
else if (this.maxOccurs(item.maxOccurs)) {
|
|
527
|
+
keys.push({ id: element.id, multi: true, xpath: element.xpath, elements: [element], isFormControls: true });
|
|
528
|
+
control[id] = this.fb.array([this.getFormControl(item.value)]);
|
|
529
|
+
}
|
|
530
|
+
else if (item.isCurrency) {
|
|
531
|
+
const _amountCurrency = this.getAmountCurrency(item);
|
|
532
|
+
keys.push(element);
|
|
533
|
+
const data = this.getFormGroupControls(_amountCurrency, element.elements, 0, false);
|
|
534
|
+
control[item.id] = data;
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
keys.push(element);
|
|
538
|
+
control[id] = this.getFormControl(item.value || "");
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
return new FormGroup(control);
|
|
542
|
+
}
|
|
543
|
+
getFormControl(values) {
|
|
544
|
+
return new FormControl(values || "", {
|
|
545
|
+
updateOn: 'blur'
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
getAmountCurrency(item) {
|
|
549
|
+
const elements = [];
|
|
550
|
+
const ccy = structuredClone(item);
|
|
551
|
+
const amt = structuredClone(item);
|
|
552
|
+
ccy.id = `${ccy.id}_ccy`;
|
|
553
|
+
ccy.name = "Ccy";
|
|
554
|
+
ccy.fractionDigits = '';
|
|
555
|
+
ccy.totalDigits = '';
|
|
556
|
+
ccy.maxLength = "3";
|
|
557
|
+
ccy.xpath = `${ccy.xpath}@ccy`;
|
|
558
|
+
ccy.isCurrency = false;
|
|
559
|
+
elements.push(ccy);
|
|
560
|
+
amt.id = `${amt.id}_amt`;
|
|
561
|
+
amt.xpath = `${amt.xpath}/amt`;
|
|
562
|
+
amt.isCurrency = false;
|
|
563
|
+
amt.pattern = '';
|
|
564
|
+
elements.push(amt);
|
|
565
|
+
return elements;
|
|
566
|
+
}
|
|
567
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoService, deps: [{ token: i2.FormBuilder }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
568
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoService, providedIn: 'root' }); }
|
|
569
|
+
}
|
|
570
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoService, decorators: [{
|
|
571
|
+
type: Injectable,
|
|
572
|
+
args: [{
|
|
573
|
+
providedIn: 'root'
|
|
574
|
+
}]
|
|
575
|
+
}], ctorParameters: function () { return [{ type: i2.FormBuilder }]; } });
|
|
576
|
+
|
|
577
|
+
class NgxIsoFormComponent {
|
|
578
|
+
constructor(service, changeDetection) {
|
|
579
|
+
this.service = service;
|
|
580
|
+
this.changeDetection = changeDetection;
|
|
581
|
+
}
|
|
582
|
+
ngOnChanges(changes) {
|
|
583
|
+
if (changes['schema'] && changes['schema'].currentValue) {
|
|
584
|
+
this.initiateForm();
|
|
585
|
+
}
|
|
586
|
+
if (changes['form'] && changes['form'].currentValue) {
|
|
587
|
+
this.initiateFormModel();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
get getIsoForm() {
|
|
591
|
+
if (this._form)
|
|
592
|
+
return this.service.sanitize(this._form.value);
|
|
593
|
+
}
|
|
594
|
+
get getFormModel() {
|
|
595
|
+
return this.service._formModel;
|
|
596
|
+
}
|
|
597
|
+
initiateForm() {
|
|
598
|
+
this.service._formModel = [structuredClone(this.schema)];
|
|
599
|
+
this.service._formModel[0].elements = [];
|
|
600
|
+
let group = {};
|
|
601
|
+
group[this.schema.id] = this.service.getFormGroupControls(this.schema.elements, this.service._formModel[0].elements);
|
|
602
|
+
this._form = new FormGroup(group);
|
|
603
|
+
if (!this._isFormInitiate) {
|
|
604
|
+
this.initiateFormModel();
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
initiateFormModel() {
|
|
608
|
+
if (this._form) {
|
|
609
|
+
this._ngModel = this.form._model;
|
|
610
|
+
this.form.getFormModel = () => {
|
|
611
|
+
return this.getIsoForm;
|
|
612
|
+
};
|
|
613
|
+
this._isFormInitiate = true;
|
|
614
|
+
this.service.initFormModel(this._ngModel, this._form);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
onChoiceSelectionChange(id, formElement, nodes) {
|
|
618
|
+
nodes.elements.forEach((element) => {
|
|
619
|
+
element.hidden = true;
|
|
620
|
+
formElement.removeControl(element.id);
|
|
621
|
+
if (element.id === id) {
|
|
622
|
+
element.hidden = false;
|
|
623
|
+
if (element.elements.length) {
|
|
624
|
+
const group = this.service.getFormGroupControls(element.elements, [], 0, true);
|
|
625
|
+
formElement.addControl(element.id, group);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
const control = this.service.getFormControl('');
|
|
629
|
+
formElement.addControl(element.id, control);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
maxOccurs(maxOccurs) {
|
|
635
|
+
return maxOccurs !== null && maxOccurs !== undefined && this.service.maxOccurs(maxOccurs);
|
|
636
|
+
}
|
|
637
|
+
expand(minOccurs) {
|
|
638
|
+
return minOccurs !== null && minOccurs !== undefined && parseInt(minOccurs, 10) > 0;
|
|
639
|
+
}
|
|
640
|
+
addSection($event, node, parentNode, parentFormEle) {
|
|
641
|
+
$event.stopPropagation();
|
|
642
|
+
const control = parentFormEle.get(node.id);
|
|
643
|
+
if (node.maxOccurs && parseInt(node.maxOccurs, 10) <= parentNode.elements.length) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const newEle = structuredClone(parentNode.elements[0]);
|
|
647
|
+
const newKeys = [];
|
|
648
|
+
const groupControls = this.service.getFormGroupControls(newEle.elements, newKeys, parentNode.elements.length - 1);
|
|
649
|
+
parentNode.elements.push(newEle);
|
|
650
|
+
control.push(groupControls);
|
|
651
|
+
this.changeDetection.detectChanges();
|
|
652
|
+
}
|
|
653
|
+
removeSection($event, parentNode, parentFormEle, index) {
|
|
654
|
+
$event.stopPropagation();
|
|
655
|
+
const control = parentFormEle.get(parentNode.id);
|
|
656
|
+
parentNode.elements.splice(index, 1);
|
|
657
|
+
control.removeAt(index);
|
|
658
|
+
this.changeDetection.detectChanges();
|
|
659
|
+
}
|
|
660
|
+
addNewControl($event, node, parentNode, parentFormEle) {
|
|
661
|
+
$event.stopPropagation();
|
|
662
|
+
if (node.maxOccurs && parseInt(node.maxOccurs, 10) <= parentNode.elements.length) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const control = parentFormEle.get(node.id);
|
|
666
|
+
const newControl = this.service.getFormControl('');
|
|
667
|
+
const newEle = structuredClone(parentNode.elements[parentNode.elements.length - 1]);
|
|
668
|
+
control.push(newControl);
|
|
669
|
+
parentNode.elements.push(newEle);
|
|
670
|
+
this.changeDetection.detectChanges();
|
|
671
|
+
}
|
|
672
|
+
removeNewControl($event, parentNode, parentFormEle, index) {
|
|
673
|
+
$event.stopPropagation();
|
|
674
|
+
const control = parentFormEle.get(parentNode.id);
|
|
675
|
+
parentNode.elements.splice(index, 1);
|
|
676
|
+
control.removeAt(index);
|
|
677
|
+
this.changeDetection.detectChanges();
|
|
678
|
+
}
|
|
679
|
+
isArray(myKey) {
|
|
680
|
+
if (myKey instanceof Array) {
|
|
681
|
+
return true;
|
|
682
|
+
}
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
isEmpty(formElement) {
|
|
686
|
+
return Object.keys(formElement.controls).length === 0;
|
|
687
|
+
}
|
|
688
|
+
getElement(formElement, element) {
|
|
689
|
+
if (element.hidden) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
let _element;
|
|
693
|
+
if (element.multi) {
|
|
694
|
+
_element = element.elements[element.elements.length - 1];
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
_element = element;
|
|
698
|
+
}
|
|
699
|
+
let formControl = formElement.controls[_element.id];
|
|
700
|
+
if (!formControl) {
|
|
701
|
+
formControl = formElement[_element.id];
|
|
702
|
+
if (!formControl)
|
|
703
|
+
throw `FormControl not found ${_element.id}`;
|
|
704
|
+
}
|
|
705
|
+
if (formControl instanceof FormArray) {
|
|
706
|
+
const formGroup = formControl.controls.find((item) => {
|
|
707
|
+
if (item instanceof FormControl)
|
|
708
|
+
return true;
|
|
709
|
+
return Object.keys(item.controls).find((ctrl) => {
|
|
710
|
+
return ctrl.indexOf(element.id) > -1;
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
if (formGroup)
|
|
714
|
+
return formControl.at(formControl.length - 1);
|
|
715
|
+
}
|
|
716
|
+
return formControl;
|
|
717
|
+
}
|
|
718
|
+
getFormControl(node) {
|
|
719
|
+
debugger;
|
|
720
|
+
return this.service.getFormControl('');
|
|
721
|
+
}
|
|
722
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoFormComponent, deps: [{ token: NgxIsoService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
723
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: NgxIsoFormComponent, selector: "ngx-iso-form", inputs: { form: "form", schema: "schema" }, usesOnChanges: true, ngImport: i0, template: "<form *ngIf=\"_form && schema\" [formGroup]=\"_form\">\r\n <div class=\"form-group\">\r\n <ng-template #nodeTemplateRef let-node=\"node\" let-formElement=\"formElement\" let-index=\"index\"\r\n let-parentNode=\"parentNode\" let-parentFormElement=\"parentFormElement\">\r\n <ng-container *ngIf=\"node.multi then arr else obj\"></ng-container>\r\n <ng-template #arr>\r\n <ng-template *ngFor=\"let model of node.elements;let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: formElement,\r\n parentFormElement: parentFormElement,\r\n parentNode: node,\r\n index: i\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #obj>\r\n <ng-container *ngIf=\"node.elements.length\">\r\n <mat-accordion [formGroup]=\"formElement\" *ngIf=\"!node.hidden\">\r\n <mat-expansion-panel multi [expanded]=\"expand(node.minOccurs)\" #expan>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>\r\n {{ node.name | trans: node.id : node.name }}\r\n </mat-panel-title>\r\n <mat-panel-description *ngIf=\"maxOccurs(node.maxOccurs)\">\r\n \r\n <button *ngIf=\"index < 1\" mat-icon-button (click)=\"addSection($event, node,parentNode, parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"index > 0\" mat-icon-button (click)=\"removeSection($event,parentNode,parentFormElement,index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <ng-container *ngIf=\"expan.expanded\">\r\n <mat-form-field *ngIf=\"node.dataType === 'choice'\">\r\n <mat-label>{{ node.name | trans: node.id : node.name }}</mat-label>\r\n <mat-select (selectionChange)=\"onChoiceSelectionChange($event.value,formElement, node)\" [formControl]=\"node.choiceFormControl\">\r\n <mat-option *ngFor=\"let item of node.elements\" [value]=\"item.id\">\r\n {{item.name}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n <ng-container *ngIf=\"!isEmpty(formElement)\">\r\n <ng-template *ngFor=\"let model of node.elements; let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(formElement,model),\r\n parentFormElement: formElement\r\n }\">\r\n </ng-template>\r\n </ng-container>\r\n <div *ngIf=\"node.elements.length === 0\">\r\n <ngx-iso-control *ngIf=\"!node.hidden\" [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </div>\r\n </ng-container>\r\n </mat-expansion-panel>\r\n </mat-accordion>\r\n </ng-container>\r\n <ng-container *ngIf=\"!node.elements.length && !node.hidden\">\r\n <div *ngIf=\"maxOccurs(node.maxOccurs)\" class=\"form-add-section\">\r\n \r\n <button *ngIf=\"index < 1\" mat-icon-button (click)=\"addNewControl($event, node,parentNode,parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"index > 0\" mat-icon-button (click)=\"removeNewControl($event,parentNode,parentFormElement,index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </div>\r\n <ngx-iso-control [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </ng-container>\r\n </ng-template>\r\n </ng-template>\r\n <ng-container *ngFor=\"let model of getFormModel; let i = index\">\r\n <ng-container *ngIf=\"isArray(model);then formArray else formObject\">\r\n </ng-container>\r\n <ng-template #formArray>\r\n <ng-template *ngFor=\"let key of model;let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: key,\r\n formElement: getElement(_form,key),\r\n parentFormElement: _form,\r\n index:i\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #formObject>\r\n <ng-template [ngTemplateOutlet]=\"nodeTemplateRef\" [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(_form,model),\r\n parentFormElement: _form,\r\n index: i,\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n </ng-container>\r\n </div>\r\n</form>", styles: [":host .mat-expansion-panel-header-description{justify-content:space-between;align-items:center}:host .mat-expansion-panel{width:100%;margin:5px 0}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { 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.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4$2.MatAccordion, selector: "mat-accordion", inputs: ["multi", "hideToggle", "displayMode", "togglePosition"], exportAs: ["matAccordion"] }, { kind: "component", type: i4$2.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i4$2.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "directive", type: i4$2.MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "directive", type: i4$2.MatExpansionPanelDescription, selector: "mat-panel-description" }, { 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: "component", type: i6.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { 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"] }, { kind: "component", type: i9.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: NgxIsoControlComponent, selector: "ngx-iso-control", inputs: ["formControl", "control"] }, { kind: "pipe", type: IsoTranslatePipe, name: "trans" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
724
|
+
}
|
|
725
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoFormComponent, decorators: [{
|
|
726
|
+
type: Component,
|
|
727
|
+
args: [{ selector: 'ngx-iso-form', changeDetection: ChangeDetectionStrategy.OnPush, template: "<form *ngIf=\"_form && schema\" [formGroup]=\"_form\">\r\n <div class=\"form-group\">\r\n <ng-template #nodeTemplateRef let-node=\"node\" let-formElement=\"formElement\" let-index=\"index\"\r\n let-parentNode=\"parentNode\" let-parentFormElement=\"parentFormElement\">\r\n <ng-container *ngIf=\"node.multi then arr else obj\"></ng-container>\r\n <ng-template #arr>\r\n <ng-template *ngFor=\"let model of node.elements;let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: formElement,\r\n parentFormElement: parentFormElement,\r\n parentNode: node,\r\n index: i\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #obj>\r\n <ng-container *ngIf=\"node.elements.length\">\r\n <mat-accordion [formGroup]=\"formElement\" *ngIf=\"!node.hidden\">\r\n <mat-expansion-panel multi [expanded]=\"expand(node.minOccurs)\" #expan>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>\r\n {{ node.name | trans: node.id : node.name }}\r\n </mat-panel-title>\r\n <mat-panel-description *ngIf=\"maxOccurs(node.maxOccurs)\">\r\n \r\n <button *ngIf=\"index < 1\" mat-icon-button (click)=\"addSection($event, node,parentNode, parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"index > 0\" mat-icon-button (click)=\"removeSection($event,parentNode,parentFormElement,index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <ng-container *ngIf=\"expan.expanded\">\r\n <mat-form-field *ngIf=\"node.dataType === 'choice'\">\r\n <mat-label>{{ node.name | trans: node.id : node.name }}</mat-label>\r\n <mat-select (selectionChange)=\"onChoiceSelectionChange($event.value,formElement, node)\" [formControl]=\"node.choiceFormControl\">\r\n <mat-option *ngFor=\"let item of node.elements\" [value]=\"item.id\">\r\n {{item.name}}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n <ng-container *ngIf=\"!isEmpty(formElement)\">\r\n <ng-template *ngFor=\"let model of node.elements; let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(formElement,model),\r\n parentFormElement: formElement\r\n }\">\r\n </ng-template>\r\n </ng-container>\r\n <div *ngIf=\"node.elements.length === 0\">\r\n <ngx-iso-control *ngIf=\"!node.hidden\" [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </div>\r\n </ng-container>\r\n </mat-expansion-panel>\r\n </mat-accordion>\r\n </ng-container>\r\n <ng-container *ngIf=\"!node.elements.length && !node.hidden\">\r\n <div *ngIf=\"maxOccurs(node.maxOccurs)\" class=\"form-add-section\">\r\n \r\n <button *ngIf=\"index < 1\" mat-icon-button (click)=\"addNewControl($event, node,parentNode,parentFormElement)\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n <button *ngIf=\"index > 0\" mat-icon-button (click)=\"removeNewControl($event,parentNode,parentFormElement,index)\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n </div>\r\n <ngx-iso-control [formControl]=\"formElement\" [control]=\"node\"></ngx-iso-control>\r\n </ng-container>\r\n </ng-template>\r\n </ng-template>\r\n <ng-container *ngFor=\"let model of getFormModel; let i = index\">\r\n <ng-container *ngIf=\"isArray(model);then formArray else formObject\">\r\n </ng-container>\r\n <ng-template #formArray>\r\n <ng-template *ngFor=\"let key of model;let i = index\" [ngTemplateOutlet]=\"nodeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n node: key,\r\n formElement: getElement(_form,key),\r\n parentFormElement: _form,\r\n index:i\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n <ng-template #formObject>\r\n <ng-template [ngTemplateOutlet]=\"nodeTemplateRef\" [ngTemplateOutletContext]=\"{\r\n node: model,\r\n formElement: getElement(_form,model),\r\n parentFormElement: _form,\r\n index: i,\r\n }\">\r\n </ng-template>\r\n </ng-template>\r\n </ng-container>\r\n </div>\r\n</form>", styles: [":host .mat-expansion-panel-header-description{justify-content:space-between;align-items:center}:host .mat-expansion-panel{width:100%;margin:5px 0}\n"] }]
|
|
728
|
+
}], ctorParameters: function () { return [{ type: NgxIsoService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { form: [{
|
|
729
|
+
type: Input,
|
|
730
|
+
args: [{ required: true }]
|
|
731
|
+
}], schema: [{
|
|
732
|
+
type: Input,
|
|
733
|
+
args: [{ required: true }]
|
|
734
|
+
}] } });
|
|
735
|
+
|
|
736
|
+
let ComponentService = class ComponentService {
|
|
737
|
+
getComponent(viewContainerRef, dynamicModel) {
|
|
738
|
+
const componentRef = viewContainerRef.createComponent(dynamicModel.component);
|
|
739
|
+
if (dynamicModel.prop) {
|
|
740
|
+
componentRef.instance.prop = dynamicModel.prop;
|
|
741
|
+
}
|
|
742
|
+
return componentRef;
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
ComponentService = __decorate([
|
|
746
|
+
Inject('root')
|
|
747
|
+
], ComponentService);
|
|
748
|
+
|
|
749
|
+
// // AoT requires an exported function for factories
|
|
750
|
+
// export function HttpLoaderFactory(http: HttpClient) {
|
|
751
|
+
// return new TranslateHttpLoader(http);
|
|
752
|
+
// }
|
|
753
|
+
class NgxIsoFormModule {
|
|
754
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
755
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoFormModule, declarations: [NgxIsoFormComponent,
|
|
756
|
+
NgxIsoControlComponent,
|
|
757
|
+
NgxDynamicComponent,
|
|
758
|
+
IsoBaseControlComponent,
|
|
759
|
+
IsoMatInput,
|
|
760
|
+
IsoMatTextarea,
|
|
761
|
+
IsoMatDate,
|
|
762
|
+
IsoMatDateTime,
|
|
763
|
+
IsoMatSelect,
|
|
764
|
+
IsoMatCheckbox,
|
|
765
|
+
IsoMatCurrency,
|
|
766
|
+
ComponentDirective,
|
|
767
|
+
IsoTranslatePipe,
|
|
768
|
+
IsoErrorPipe,
|
|
769
|
+
IsoGeneralPipe], imports: [BrowserModule,
|
|
770
|
+
BrowserAnimationsModule,
|
|
771
|
+
TranslateModule,
|
|
772
|
+
FormsModule,
|
|
773
|
+
ReactiveFormsModule,
|
|
774
|
+
MatExpansionModule,
|
|
775
|
+
MatFormFieldModule,
|
|
776
|
+
MatInputModule,
|
|
777
|
+
MatNativeDateModule,
|
|
778
|
+
MatDatepickerModule,
|
|
779
|
+
MatButtonModule,
|
|
780
|
+
MatSelectModule,
|
|
781
|
+
MatIconModule], exports: [NgxIsoFormComponent] }); }
|
|
782
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoFormModule, providers: [
|
|
783
|
+
ControlService
|
|
784
|
+
], imports: [BrowserModule,
|
|
785
|
+
BrowserAnimationsModule,
|
|
786
|
+
TranslateModule,
|
|
787
|
+
FormsModule,
|
|
788
|
+
ReactiveFormsModule,
|
|
789
|
+
MatExpansionModule,
|
|
790
|
+
MatFormFieldModule,
|
|
791
|
+
MatInputModule,
|
|
792
|
+
MatNativeDateModule,
|
|
793
|
+
MatDatepickerModule,
|
|
794
|
+
MatButtonModule,
|
|
795
|
+
MatSelectModule,
|
|
796
|
+
MatIconModule] }); }
|
|
797
|
+
}
|
|
798
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: NgxIsoFormModule, decorators: [{
|
|
799
|
+
type: NgModule,
|
|
800
|
+
args: [{
|
|
801
|
+
declarations: [
|
|
802
|
+
NgxIsoFormComponent,
|
|
803
|
+
NgxIsoControlComponent,
|
|
804
|
+
NgxDynamicComponent,
|
|
805
|
+
IsoBaseControlComponent,
|
|
806
|
+
IsoMatInput,
|
|
807
|
+
IsoMatTextarea,
|
|
808
|
+
IsoMatDate,
|
|
809
|
+
IsoMatDateTime,
|
|
810
|
+
IsoMatSelect,
|
|
811
|
+
IsoMatCheckbox,
|
|
812
|
+
IsoMatCurrency,
|
|
813
|
+
ComponentDirective,
|
|
814
|
+
IsoTranslatePipe,
|
|
815
|
+
IsoErrorPipe,
|
|
816
|
+
IsoGeneralPipe
|
|
817
|
+
],
|
|
818
|
+
imports: [
|
|
819
|
+
BrowserModule,
|
|
820
|
+
BrowserAnimationsModule,
|
|
821
|
+
TranslateModule,
|
|
822
|
+
FormsModule,
|
|
823
|
+
ReactiveFormsModule,
|
|
824
|
+
MatExpansionModule,
|
|
825
|
+
MatFormFieldModule,
|
|
826
|
+
MatInputModule,
|
|
827
|
+
MatNativeDateModule,
|
|
828
|
+
MatDatepickerModule,
|
|
829
|
+
MatButtonModule,
|
|
830
|
+
MatSelectModule,
|
|
831
|
+
MatIconModule,
|
|
832
|
+
],
|
|
833
|
+
providers: [
|
|
834
|
+
ControlService
|
|
835
|
+
],
|
|
836
|
+
exports: [
|
|
837
|
+
NgxIsoFormComponent
|
|
838
|
+
]
|
|
839
|
+
}]
|
|
840
|
+
}] });
|
|
841
|
+
|
|
842
|
+
class IsoForm {
|
|
843
|
+
constructor(model) {
|
|
844
|
+
this.getFormModel = () => {
|
|
845
|
+
};
|
|
846
|
+
this._model = model;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/*
|
|
851
|
+
* Public API Surface of ngx-iso-form
|
|
852
|
+
*/
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Generated bundle index. Do not edit.
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
export { ComponentService, ControlService, IsoForm, NgxIsoFormComponent, NgxIsoFormModule };
|
|
859
|
+
//# sourceMappingURL=ngx-iso-form.mjs.map
|