@4science_ng-dynamic-forms/ui-ng-bootstrap 19.0.0 → 19.0.2
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/karma.conf.js +52 -0
- package/ng-package.json +8 -0
- package/package.json +6 -17
- package/src/lib/calendar/dynamic-ng-bootstrap-calendar.component.html +33 -0
- package/src/lib/calendar/dynamic-ng-bootstrap-calendar.component.spec.ts +104 -0
- package/src/lib/calendar/dynamic-ng-bootstrap-calendar.component.ts +54 -0
- package/src/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.html +38 -0
- package/src/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.spec.ts +104 -0
- package/src/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.ts +49 -0
- package/src/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.html +42 -0
- package/src/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.spec.ts +108 -0
- package/src/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.ts +59 -0
- package/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.html +51 -0
- package/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.spec.ts +103 -0
- package/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.ts +56 -0
- package/src/lib/dynamic-ng-bootstrap-form-array.component.html +45 -0
- package/src/lib/dynamic-ng-bootstrap-form-control-container.component.html +44 -0
- package/src/lib/dynamic-ng-bootstrap-form-control-container.component.spec.ts +198 -0
- package/src/lib/dynamic-ng-bootstrap-form-control-container.component.ts +214 -0
- package/src/lib/dynamic-ng-bootstrap-form-group.component.html +35 -0
- package/src/lib/dynamic-ng-bootstrap-form.component.html +26 -0
- package/src/lib/dynamic-ng-bootstrap-form.component.ts +65 -0
- package/src/lib/input/dynamic-ng-bootstrap-input.component.html +101 -0
- package/src/lib/input/dynamic-ng-bootstrap-input.component.spec.ts +107 -0
- package/src/lib/input/dynamic-ng-bootstrap-input.component.ts +52 -0
- package/src/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.html +42 -0
- package/src/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.spec.ts +106 -0
- package/src/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.ts +49 -0
- package/src/lib/rating/dynamic-ng-bootstrap-rating.component.html +28 -0
- package/src/lib/rating/dynamic-ng-bootstrap-rating.component.spec.ts +104 -0
- package/src/lib/rating/dynamic-ng-bootstrap-rating.component.ts +56 -0
- package/src/lib/select/dynamic-ng-bootstrap-select.component.html +39 -0
- package/src/lib/select/dynamic-ng-bootstrap-select.component.spec.ts +104 -0
- package/src/lib/select/dynamic-ng-bootstrap-select.component.ts +49 -0
- package/src/lib/switch/dynamic-ng-bootstrap-switch.component.html +35 -0
- package/src/lib/switch/dynamic-ng-bootstrap-switch.component.spec.ts +104 -0
- package/src/lib/switch/dynamic-ng-bootstrap-switch.component.ts +49 -0
- package/src/lib/textarea/dynamic-ng-bootstrap-textarea.component.html +39 -0
- package/src/lib/textarea/dynamic-ng-bootstrap-textarea.component.spec.ts +105 -0
- package/src/lib/textarea/dynamic-ng-bootstrap-textarea.component.ts +49 -0
- package/src/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.html +30 -0
- package/src/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.spec.ts +111 -0
- package/src/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.ts +54 -0
- package/{lib/ui-ng-bootstrap.d.ts → src/lib/ui-ng-bootstrap.ts} +18 -0
- package/src/public-api.ts +17 -0
- package/src/test.ts +35 -0
- package/tsconfig.lib.json +30 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +17 -0
- package/esm2022/lib/calendar/dynamic-ng-bootstrap-calendar.component.mjs +0 -59
- package/esm2022/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.mjs +0 -53
- package/esm2022/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.mjs +0 -60
- package/esm2022/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.mjs +0 -62
- package/esm2022/lib/dynamic-ng-bootstrap-form-control-container.component.mjs +0 -201
- package/esm2022/lib/dynamic-ng-bootstrap-form.component.mjs +0 -59
- package/esm2022/lib/input/dynamic-ng-bootstrap-input.component.mjs +0 -54
- package/esm2022/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.mjs +0 -53
- package/esm2022/lib/rating/dynamic-ng-bootstrap-rating.component.mjs +0 -62
- package/esm2022/lib/select/dynamic-ng-bootstrap-select.component.mjs +0 -53
- package/esm2022/lib/switch/dynamic-ng-bootstrap-switch.component.mjs +0 -53
- package/esm2022/lib/textarea/dynamic-ng-bootstrap-textarea.component.mjs +0 -53
- package/esm2022/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.mjs +0 -59
- package/esm2022/lib/ui-ng-bootstrap.mjs +0 -29
- package/esm2022/public-api.mjs +0 -17
- package/esm2022/ui-ng-bootstrap.mjs +0 -5
- package/fesm2022/ui-ng-bootstrap.mjs +0 -820
- package/fesm2022/ui-ng-bootstrap.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/calendar/dynamic-ng-bootstrap-calendar.component.d.ts +0 -21
- package/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.d.ts +0 -18
- package/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.d.ts +0 -20
- package/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.d.ts +0 -22
- package/lib/dynamic-ng-bootstrap-form-control-container.component.d.ts +0 -65
- package/lib/dynamic-ng-bootstrap-form.component.d.ts +0 -21
- package/lib/input/dynamic-ng-bootstrap-input.component.d.ts +0 -18
- package/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.d.ts +0 -18
- package/lib/rating/dynamic-ng-bootstrap-rating.component.d.ts +0 -22
- package/lib/select/dynamic-ng-bootstrap-select.component.d.ts +0 -18
- package/lib/switch/dynamic-ng-bootstrap-switch.component.d.ts +0 -18
- package/lib/textarea/dynamic-ng-bootstrap-textarea.component.d.ts +0 -18
- package/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.d.ts +0 -21
- package/public-api.d.ts +0 -1
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
ChangeDetectionStrategy,
|
|
19
|
+
ChangeDetectorRef,
|
|
20
|
+
Component,
|
|
21
|
+
ComponentFactoryResolver,
|
|
22
|
+
ContentChildren,
|
|
23
|
+
EventEmitter,
|
|
24
|
+
HostBinding,
|
|
25
|
+
Input,
|
|
26
|
+
Output,
|
|
27
|
+
QueryList,
|
|
28
|
+
Type,
|
|
29
|
+
ViewChild,
|
|
30
|
+
ViewChildren,
|
|
31
|
+
ViewContainerRef
|
|
32
|
+
} from "@angular/core";
|
|
33
|
+
import { UntypedFormGroup, ReactiveFormsModule } from "@angular/forms";
|
|
34
|
+
import {
|
|
35
|
+
DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
|
36
|
+
DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX,
|
|
37
|
+
DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP,
|
|
38
|
+
DYNAMIC_FORM_CONTROL_TYPE_DATEPICKER,
|
|
39
|
+
DYNAMIC_FORM_CONTROL_TYPE_GROUP,
|
|
40
|
+
DYNAMIC_FORM_CONTROL_TYPE_INPUT,
|
|
41
|
+
DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP,
|
|
42
|
+
DYNAMIC_FORM_CONTROL_TYPE_RATING,
|
|
43
|
+
DYNAMIC_FORM_CONTROL_TYPE_SELECT,
|
|
44
|
+
DYNAMIC_FORM_CONTROL_TYPE_SWITCH,
|
|
45
|
+
DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA,
|
|
46
|
+
DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER,
|
|
47
|
+
DynamicDatePickerModel,
|
|
48
|
+
DynamicFormArrayComponent,
|
|
49
|
+
DynamicFormArrayGroupModel,
|
|
50
|
+
DynamicFormArrayModel,
|
|
51
|
+
DynamicFormComponentService,
|
|
52
|
+
DynamicFormControl,
|
|
53
|
+
DynamicFormControlContainerComponent,
|
|
54
|
+
DynamicFormControlCustomEvent,
|
|
55
|
+
DynamicFormControlEvent,
|
|
56
|
+
DynamicFormControlLayout,
|
|
57
|
+
DynamicFormControlModel,
|
|
58
|
+
DynamicFormGroupComponent,
|
|
59
|
+
DynamicFormGroupModel,
|
|
60
|
+
DynamicFormLayout,
|
|
61
|
+
DynamicFormLayoutService,
|
|
62
|
+
DynamicFormRelationService,
|
|
63
|
+
DynamicFormValidationService,
|
|
64
|
+
DynamicTemplateDirective
|
|
65
|
+
} from "@ng-dynamic-forms/core";
|
|
66
|
+
import { DynamicNGBootstrapCheckboxComponent } from "./checkbox/dynamic-ng-bootstrap-checkbox.component";
|
|
67
|
+
import { DynamicNGBootstrapCheckboxGroupComponent } from "./checkbox-group/dynamic-ng-bootstrap-checkbox-group.component";
|
|
68
|
+
import { DynamicNGBootstrapCalendarComponent } from "./calendar/dynamic-ng-bootstrap-calendar.component";
|
|
69
|
+
import { DynamicNGBootstrapDatePickerComponent } from "./datepicker/dynamic-ng-bootstrap-datepicker.component";
|
|
70
|
+
import { DynamicNGBootstrapInputComponent } from "./input/dynamic-ng-bootstrap-input.component";
|
|
71
|
+
import { DynamicNGBootstrapRadioGroupComponent } from "./radio-group/dynamic-ng-bootstrap-radio-group.component";
|
|
72
|
+
import { DynamicNGBootstrapRatingComponent } from "./rating/dynamic-ng-bootstrap-rating.component";
|
|
73
|
+
import { DynamicNGBootstrapSelectComponent } from "./select/dynamic-ng-bootstrap-select.component";
|
|
74
|
+
import { DynamicNGBootstrapSwitchComponent } from "./switch/dynamic-ng-bootstrap-switch.component";
|
|
75
|
+
import { DynamicNGBootstrapTextAreaComponent } from "./textarea/dynamic-ng-bootstrap-textarea.component";
|
|
76
|
+
import { DynamicNGBootstrapTimePickerComponent } from "./timepicker/dynamic-ng-bootstrap-timepicker.component";
|
|
77
|
+
import { NgClass, NgFor, NgTemplateOutlet, NgIf } from "@angular/common";
|
|
78
|
+
|
|
79
|
+
@Component({
|
|
80
|
+
selector: "dynamic-ng-bootstrap-form-control",
|
|
81
|
+
templateUrl: "./dynamic-ng-bootstrap-form-control-container.component.html",
|
|
82
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
83
|
+
standalone: true,
|
|
84
|
+
imports: [ReactiveFormsModule, NgClass, NgIf, NgTemplateOutlet, NgFor]
|
|
85
|
+
})
|
|
86
|
+
export class DynamicNGBootstrapFormControlContainerComponent extends DynamicFormControlContainerComponent {
|
|
87
|
+
@ContentChildren(DynamicTemplateDirective) contentTemplateList!: QueryList<DynamicTemplateDirective>;
|
|
88
|
+
|
|
89
|
+
@HostBinding("class") klass?: string;
|
|
90
|
+
|
|
91
|
+
@Input() asBootstrapFormGroup = true;
|
|
92
|
+
@Input() context: DynamicFormArrayGroupModel | null = null;
|
|
93
|
+
@Input() group!: UntypedFormGroup;
|
|
94
|
+
@Input() hostClass?: string[];
|
|
95
|
+
// tslint:disable-next-line:no-input-rename
|
|
96
|
+
@Input("templates") inputTemplateList?: QueryList<DynamicTemplateDirective>;
|
|
97
|
+
@Input() layout?: DynamicFormLayout;
|
|
98
|
+
@Input() model!: DynamicFormControlModel;
|
|
99
|
+
|
|
100
|
+
@Output() blur: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
101
|
+
@Output() change: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
102
|
+
@Output() focus: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
103
|
+
// tslint:disable-next-line:no-output-rename
|
|
104
|
+
@Output("ngbEvent") customEvent: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
105
|
+
|
|
106
|
+
@ViewChild("componentViewContainer", {read: ViewContainerRef, static: true}) componentViewContainerRef!: ViewContainerRef;
|
|
107
|
+
|
|
108
|
+
constructor(protected changeDetectorRef: ChangeDetectorRef,
|
|
109
|
+
protected componentFactoryResolver: ComponentFactoryResolver,
|
|
110
|
+
protected layoutService: DynamicFormLayoutService,
|
|
111
|
+
protected validationService: DynamicFormValidationService,
|
|
112
|
+
protected componentService: DynamicFormComponentService,
|
|
113
|
+
protected relationService: DynamicFormRelationService) {
|
|
114
|
+
super(changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get componentType(): Type<DynamicFormControl> | null {
|
|
118
|
+
return this.componentService.getCustomComponentType(this.model) || ngBootstrapUIFormControlMapFn(this.model);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function ngBootstrapUIFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
|
123
|
+
switch (model.type) {
|
|
124
|
+
case DYNAMIC_FORM_CONTROL_TYPE_ARRAY:
|
|
125
|
+
return DynamicNGBootstrapFormArrayComponent;
|
|
126
|
+
|
|
127
|
+
case DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX:
|
|
128
|
+
return DynamicNGBootstrapCheckboxComponent;
|
|
129
|
+
|
|
130
|
+
case DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP:
|
|
131
|
+
return DynamicNGBootstrapCheckboxGroupComponent;
|
|
132
|
+
|
|
133
|
+
case DYNAMIC_FORM_CONTROL_TYPE_DATEPICKER:
|
|
134
|
+
const datePickerModel = model as DynamicDatePickerModel;
|
|
135
|
+
return datePickerModel.inline ? DynamicNGBootstrapCalendarComponent : DynamicNGBootstrapDatePickerComponent;
|
|
136
|
+
|
|
137
|
+
case DYNAMIC_FORM_CONTROL_TYPE_GROUP:
|
|
138
|
+
return DynamicNGBootstrapFormGroupComponent;
|
|
139
|
+
|
|
140
|
+
case DYNAMIC_FORM_CONTROL_TYPE_INPUT:
|
|
141
|
+
return DynamicNGBootstrapInputComponent;
|
|
142
|
+
|
|
143
|
+
case DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP:
|
|
144
|
+
return DynamicNGBootstrapRadioGroupComponent;
|
|
145
|
+
|
|
146
|
+
case DYNAMIC_FORM_CONTROL_TYPE_RATING:
|
|
147
|
+
return DynamicNGBootstrapRatingComponent;
|
|
148
|
+
|
|
149
|
+
case DYNAMIC_FORM_CONTROL_TYPE_SELECT:
|
|
150
|
+
return DynamicNGBootstrapSelectComponent;
|
|
151
|
+
|
|
152
|
+
case DYNAMIC_FORM_CONTROL_TYPE_SWITCH:
|
|
153
|
+
return DynamicNGBootstrapSwitchComponent;
|
|
154
|
+
|
|
155
|
+
case DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA:
|
|
156
|
+
return DynamicNGBootstrapTextAreaComponent;
|
|
157
|
+
|
|
158
|
+
case DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER:
|
|
159
|
+
return DynamicNGBootstrapTimePickerComponent;
|
|
160
|
+
|
|
161
|
+
default:
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@Component({
|
|
167
|
+
selector: "dynamic-ng-bootstrap-form-array",
|
|
168
|
+
templateUrl: "./dynamic-ng-bootstrap-form-array.component.html",
|
|
169
|
+
standalone: true,
|
|
170
|
+
imports: [ReactiveFormsModule, NgClass, NgFor, NgTemplateOutlet, DynamicNGBootstrapFormControlContainerComponent]
|
|
171
|
+
})
|
|
172
|
+
export class DynamicNGBootstrapFormArrayComponent extends DynamicFormArrayComponent {
|
|
173
|
+
@Input() formLayout?: DynamicFormLayout;
|
|
174
|
+
@Input() group!: UntypedFormGroup;
|
|
175
|
+
@Input() layout?: DynamicFormControlLayout;
|
|
176
|
+
@Input() model!: DynamicFormArrayModel;
|
|
177
|
+
@Input() templates?: QueryList<DynamicTemplateDirective>;
|
|
178
|
+
|
|
179
|
+
@Output() blur: EventEmitter<any> = new EventEmitter();
|
|
180
|
+
@Output() change: EventEmitter<any> = new EventEmitter();
|
|
181
|
+
@Output() customEvent: EventEmitter<DynamicFormControlCustomEvent> = new EventEmitter();
|
|
182
|
+
@Output() focus: EventEmitter<any> = new EventEmitter();
|
|
183
|
+
|
|
184
|
+
@ViewChildren(DynamicNGBootstrapFormControlContainerComponent) components!: QueryList<DynamicNGBootstrapFormControlContainerComponent>;
|
|
185
|
+
|
|
186
|
+
constructor(protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService) {
|
|
187
|
+
super(layoutService, validationService);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@Component({
|
|
192
|
+
selector: "dynamic-ng-bootstrap-form-group",
|
|
193
|
+
templateUrl: "./dynamic-ng-bootstrap-form-group.component.html",
|
|
194
|
+
standalone: true,
|
|
195
|
+
imports: [ReactiveFormsModule, NgClass, NgFor, DynamicNGBootstrapFormControlContainerComponent]
|
|
196
|
+
})
|
|
197
|
+
export class DynamicNGBootstrapFormGroupComponent extends DynamicFormGroupComponent {
|
|
198
|
+
@Input() formLayout?: DynamicFormLayout;
|
|
199
|
+
@Input() group!: UntypedFormGroup;
|
|
200
|
+
@Input() layout?: DynamicFormControlLayout;
|
|
201
|
+
@Input() model!: DynamicFormGroupModel;
|
|
202
|
+
@Input() templates?: QueryList<DynamicTemplateDirective> | DynamicTemplateDirective[];
|
|
203
|
+
|
|
204
|
+
@Output() blur: EventEmitter<any> = new EventEmitter();
|
|
205
|
+
@Output() change: EventEmitter<any> = new EventEmitter();
|
|
206
|
+
@Output() customEvent: EventEmitter<DynamicFormControlCustomEvent> = new EventEmitter();
|
|
207
|
+
@Output() focus: EventEmitter<any> = new EventEmitter();
|
|
208
|
+
|
|
209
|
+
@ViewChildren(DynamicNGBootstrapFormControlContainerComponent) components!: QueryList<DynamicNGBootstrapFormControlContainerComponent>;
|
|
210
|
+
|
|
211
|
+
constructor(protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService) {
|
|
212
|
+
super(layoutService, validationService);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
~ Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
~
|
|
4
|
+
~ Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
~ purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
~ copyright notice and this permission notice appear in all copies.
|
|
7
|
+
~
|
|
8
|
+
~ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
~ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
~ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
~ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
~ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
~ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
~ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
<ng-container [formGroup]="group">
|
|
18
|
+
|
|
19
|
+
<div role="group" [formGroupName]="model.id" [id]="id" [ngClass]="getClass('element','control')">
|
|
20
|
+
|
|
21
|
+
<dynamic-ng-bootstrap-form-control *ngFor="let _model of model.group"
|
|
22
|
+
[asBootstrapFormGroup]="true"
|
|
23
|
+
[group]="control"
|
|
24
|
+
[hidden]="_model.hidden"
|
|
25
|
+
[layout]="formLayout"
|
|
26
|
+
[model]="_model"
|
|
27
|
+
[templates]="templates"
|
|
28
|
+
[hostClass]="[getClass('element','children'), getClass('grid','children')]"
|
|
29
|
+
(blur)="onBlur($event)"
|
|
30
|
+
(change)="onChange($event)"
|
|
31
|
+
(focus)="onFocus($event)"
|
|
32
|
+
(ngbEvent)="onCustomEvent($event, null, true)"></dynamic-ng-bootstrap-form-control>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
</ng-container>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
~ Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
~
|
|
4
|
+
~ Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
~ purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
~ copyright notice and this permission notice appear in all copies.
|
|
7
|
+
~
|
|
8
|
+
~ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
~ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
~ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
~ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
~ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
~ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
~ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
<dynamic-ng-bootstrap-form-control *ngFor="let controlModel of model; trackBy: trackByFn"
|
|
18
|
+
[group]="group"
|
|
19
|
+
[hidden]="controlModel.hidden"
|
|
20
|
+
[layout]="layout"
|
|
21
|
+
[model]="controlModel"
|
|
22
|
+
[templates]="templates"
|
|
23
|
+
(blur)="onBlur($event)"
|
|
24
|
+
(change)="onChange($event)"
|
|
25
|
+
(focus)="onFocus($event)"
|
|
26
|
+
(ngbEvent)="onCustomEvent($event, ngbEvent)"></dynamic-ng-bootstrap-form-control>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
ChangeDetectionStrategy,
|
|
19
|
+
ChangeDetectorRef,
|
|
20
|
+
Component,
|
|
21
|
+
ContentChildren,
|
|
22
|
+
EventEmitter,
|
|
23
|
+
Input,
|
|
24
|
+
Output,
|
|
25
|
+
QueryList,
|
|
26
|
+
ViewChildren
|
|
27
|
+
} from "@angular/core";
|
|
28
|
+
import { UntypedFormGroup } from "@angular/forms";
|
|
29
|
+
import {
|
|
30
|
+
DynamicFormComponent,
|
|
31
|
+
DynamicFormComponentService,
|
|
32
|
+
DynamicFormControlEvent,
|
|
33
|
+
DynamicFormLayout,
|
|
34
|
+
DynamicFormModel,
|
|
35
|
+
DynamicTemplateDirective
|
|
36
|
+
} from "@ng-dynamic-forms/core";
|
|
37
|
+
import { DynamicNGBootstrapFormControlContainerComponent } from "./dynamic-ng-bootstrap-form-control-container.component";
|
|
38
|
+
import { NgFor } from "@angular/common";
|
|
39
|
+
|
|
40
|
+
@Component({
|
|
41
|
+
selector: "dynamic-ng-bootstrap-form",
|
|
42
|
+
templateUrl: "./dynamic-ng-bootstrap-form.component.html",
|
|
43
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
44
|
+
standalone: true,
|
|
45
|
+
imports: [NgFor, DynamicNGBootstrapFormControlContainerComponent]
|
|
46
|
+
})
|
|
47
|
+
export class DynamicNGBootstrapFormComponent extends DynamicFormComponent {
|
|
48
|
+
@Input() group!: UntypedFormGroup;
|
|
49
|
+
@Input() model!: DynamicFormModel;
|
|
50
|
+
@Input() layout?: DynamicFormLayout;
|
|
51
|
+
|
|
52
|
+
@Output() blur: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
53
|
+
@Output() change: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
54
|
+
@Output() focus: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
55
|
+
|
|
56
|
+
@Output() ngbEvent: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
|
|
57
|
+
|
|
58
|
+
@ContentChildren(DynamicTemplateDirective) templates!: QueryList<DynamicTemplateDirective>;
|
|
59
|
+
|
|
60
|
+
@ViewChildren(DynamicNGBootstrapFormControlContainerComponent) components!: QueryList<DynamicNGBootstrapFormControlContainerComponent>;
|
|
61
|
+
|
|
62
|
+
constructor(protected changeDetectorRef: ChangeDetectorRef, protected componentService: DynamicFormComponentService) {
|
|
63
|
+
super(changeDetectorRef, componentService);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
~ Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
~
|
|
4
|
+
~ Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
~ purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
~ copyright notice and this permission notice appear in all copies.
|
|
7
|
+
~
|
|
8
|
+
~ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
~ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
~ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
~ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
~ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
~ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
~ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
<div [formGroup]="group" [class.input-group]="model.prefix || model.suffix">
|
|
18
|
+
|
|
19
|
+
<span *ngIf="model.prefix" class="input-group-text" [innerHTML]="model.prefix"></span>
|
|
20
|
+
|
|
21
|
+
<input *ngIf="model.inputType === 'file'; else maskedInput" class="form-control"
|
|
22
|
+
[attr.accept]="model.accept"
|
|
23
|
+
[attr.max]="model.max"
|
|
24
|
+
[attr.min]="model.min"
|
|
25
|
+
[attr.multiple]="model.multiple"
|
|
26
|
+
[attr.step]="model.step"
|
|
27
|
+
[autocomplete]="model.autoComplete"
|
|
28
|
+
[autofocus]="model.autoFocus"
|
|
29
|
+
[class.is-invalid]="showErrorMessages"
|
|
30
|
+
[dynamicList]="model.listId"
|
|
31
|
+
[formControlName]="model.id"
|
|
32
|
+
[id]="id"
|
|
33
|
+
[maxlength]="model.maxLength"
|
|
34
|
+
[minlength]="model.minLength"
|
|
35
|
+
[name]="model.name"
|
|
36
|
+
[ngClass]="getClass('element', 'control')"
|
|
37
|
+
[pattern]="model.pattern"
|
|
38
|
+
[placeholder]="model.placeholder"
|
|
39
|
+
[readonly]="model.readOnly"
|
|
40
|
+
[required]="model.required"
|
|
41
|
+
[spellcheck]="model.spellCheck"
|
|
42
|
+
[tabindex]="model.tabIndex"
|
|
43
|
+
[type]="model.inputType"
|
|
44
|
+
(blur)="onBlur($event)"
|
|
45
|
+
(change)="onChange($event)"
|
|
46
|
+
(focus)="onFocus($event)"/>
|
|
47
|
+
|
|
48
|
+
<ng-template #maskedInput>
|
|
49
|
+
<input class="form-control"
|
|
50
|
+
[attr.accept]="model.accept"
|
|
51
|
+
[attr.max]="model.max"
|
|
52
|
+
[attr.min]="model.min"
|
|
53
|
+
[attr.multiple]="model.multiple"
|
|
54
|
+
[attr.step]="model.step"
|
|
55
|
+
[autocomplete]="model.autoComplete"
|
|
56
|
+
[autofocus]="model.autoFocus"
|
|
57
|
+
[class.is-invalid]="showErrorMessages"
|
|
58
|
+
[dynamicList]="model.listId"
|
|
59
|
+
[formControlName]="model.id"
|
|
60
|
+
[id]="id"
|
|
61
|
+
[maxlength]="model.maxLength"
|
|
62
|
+
[minlength]="model.minLength"
|
|
63
|
+
[name]="model.name"
|
|
64
|
+
[ngClass]="getClass('element', 'control')"
|
|
65
|
+
[pattern]="model.pattern"
|
|
66
|
+
[placeholder]="model.placeholder"
|
|
67
|
+
[readonly]="model.readOnly"
|
|
68
|
+
[required]="model.required"
|
|
69
|
+
[spellcheck]="model.spellCheck"
|
|
70
|
+
[tabindex]="model.tabIndex"
|
|
71
|
+
[mask]="model.mask"
|
|
72
|
+
[specialCharacters]="model.maskConfig?.specialCharacters"
|
|
73
|
+
[patterns]="model.maskConfig?.patterns"
|
|
74
|
+
[prefix]="model.maskConfig?.prefix"
|
|
75
|
+
[suffix]="model.maskConfig?.suffix"
|
|
76
|
+
[thousandSeparator]="model.maskConfig?.thousandSeparator"
|
|
77
|
+
[decimalMarker]="model.maskConfig?.decimalMarker"
|
|
78
|
+
[dropSpecialCharacters]="model.maskConfig?.dropSpecialCharacters"
|
|
79
|
+
[hiddenInput]="model.maskConfig?.hiddenInput"
|
|
80
|
+
[showMaskTyped]="model.maskConfig?.showMaskTyped"
|
|
81
|
+
[placeHolderCharacter]="model.maskConfig?.placeHolderCharacter"
|
|
82
|
+
[shownMaskExpression]="model.maskConfig?.shownMaskExpression"
|
|
83
|
+
[showTemplate]="model.maskConfig?.showTemplate"
|
|
84
|
+
[clearIfNotMatch]="model.maskConfig.clearIfNotMatch"
|
|
85
|
+
[validation]="model.maskConfig.validation"
|
|
86
|
+
[separatorLimit]="model.maskConfig.separatorLimit"
|
|
87
|
+
[allowNegativeNumbers]="model.maskConfig.allowNegativeNumbers"
|
|
88
|
+
[leadZeroDateTime]="model.maskConfig.leadZeroDateTime"
|
|
89
|
+
[type]="model.inputType"
|
|
90
|
+
(blur)="onBlur($event)"
|
|
91
|
+
(change)="onChange($event)"
|
|
92
|
+
(focus)="onFocus($event)"/>
|
|
93
|
+
</ng-template>
|
|
94
|
+
|
|
95
|
+
<span *ngIf="model.suffix" class="input-group-text" [innerHTML]="model.suffix"></span>
|
|
96
|
+
|
|
97
|
+
<datalist *ngIf="model.hasList" [id]="model.listId">
|
|
98
|
+
<option *ngFor="let option of model.list$ | async" [value]="option">
|
|
99
|
+
</datalist>
|
|
100
|
+
|
|
101
|
+
</div>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { TestBed, inject, ComponentFixture, waitForAsync } from "@angular/core/testing";
|
|
18
|
+
import { DebugElement } from "@angular/core";
|
|
19
|
+
import { UntypedFormGroup, UntypedFormControl } from "@angular/forms";
|
|
20
|
+
import { By } from "@angular/platform-browser";
|
|
21
|
+
import { DynamicFormService, DynamicInputModel } from "@ng-dynamic-forms/core";
|
|
22
|
+
import { DynamicNGBootstrapInputComponent } from "./dynamic-ng-bootstrap-input.component";
|
|
23
|
+
import { provideNgxMask } from "ngx-mask";
|
|
24
|
+
|
|
25
|
+
describe("DynamicNGBootstrapInputComponent test suite", () => {
|
|
26
|
+
const testModel = new DynamicInputModel({id: "input"});
|
|
27
|
+
const formModel = [testModel];
|
|
28
|
+
|
|
29
|
+
let formGroup: UntypedFormGroup;
|
|
30
|
+
let fixture: ComponentFixture<DynamicNGBootstrapInputComponent>;
|
|
31
|
+
let component: DynamicNGBootstrapInputComponent;
|
|
32
|
+
let debugElement: DebugElement;
|
|
33
|
+
let testElement: DebugElement;
|
|
34
|
+
|
|
35
|
+
beforeEach(waitForAsync(() => {
|
|
36
|
+
TestBed.configureTestingModule({
|
|
37
|
+
imports: [DynamicNGBootstrapInputComponent],
|
|
38
|
+
providers: [provideNgxMask()]
|
|
39
|
+
}).compileComponents().then(() => {
|
|
40
|
+
fixture = TestBed.createComponent(DynamicNGBootstrapInputComponent);
|
|
41
|
+
|
|
42
|
+
component = fixture.componentInstance;
|
|
43
|
+
debugElement = fixture.debugElement;
|
|
44
|
+
});
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
|
|
48
|
+
formGroup = service.createFormGroup(formModel);
|
|
49
|
+
|
|
50
|
+
component.group = formGroup;
|
|
51
|
+
component.model = testModel;
|
|
52
|
+
|
|
53
|
+
fixture.detectChanges();
|
|
54
|
+
|
|
55
|
+
testElement = debugElement.query(By.css(`input[id="${testModel.id}"]`));
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
it("should initialize correctly", () => {
|
|
59
|
+
expect(component.control instanceof UntypedFormControl).toBe(true);
|
|
60
|
+
expect(component.group instanceof UntypedFormGroup).toBe(true);
|
|
61
|
+
expect(component.model instanceof DynamicInputModel).toBe(true);
|
|
62
|
+
|
|
63
|
+
expect(component.blur).toBeDefined();
|
|
64
|
+
expect(component.change).toBeDefined();
|
|
65
|
+
expect(component.focus).toBeDefined();
|
|
66
|
+
|
|
67
|
+
expect(component.onBlur).toBeDefined();
|
|
68
|
+
expect(component.onChange).toBeDefined();
|
|
69
|
+
expect(component.onFocus).toBeDefined();
|
|
70
|
+
|
|
71
|
+
expect(component.hasFocus).toBe(false);
|
|
72
|
+
expect(component.isValid).toBe(true);
|
|
73
|
+
expect(component.isInvalid).toBe(false);
|
|
74
|
+
expect(component.showErrorMessages).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should have an input element", () => {
|
|
78
|
+
expect(testElement instanceof DebugElement).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("should listen to and emit blur event", () => {
|
|
82
|
+
spyOn(component.blur, "emit");
|
|
83
|
+
|
|
84
|
+
component.onBlur(null);
|
|
85
|
+
testElement.triggerEventHandler("blur", null);
|
|
86
|
+
|
|
87
|
+
expect(component.blur.emit).toHaveBeenCalledTimes(2);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should emit change event", () => {
|
|
91
|
+
spyOn(component.change, "emit");
|
|
92
|
+
|
|
93
|
+
component.onChange(null);
|
|
94
|
+
testElement.triggerEventHandler("change", null);
|
|
95
|
+
|
|
96
|
+
expect(component.change.emit).toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should listen to and emit focus event", () => {
|
|
100
|
+
spyOn(component.focus, "emit");
|
|
101
|
+
|
|
102
|
+
component.onFocus(null);
|
|
103
|
+
testElement.triggerEventHandler("focus", null);
|
|
104
|
+
|
|
105
|
+
expect(component.focus.emit).toHaveBeenCalledTimes(2);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from "@angular/core";
|
|
18
|
+
import { UntypedFormGroup, ReactiveFormsModule } from "@angular/forms";
|
|
19
|
+
import {
|
|
20
|
+
DynamicFormControlComponent,
|
|
21
|
+
DynamicFormControlLayout,
|
|
22
|
+
DynamicFormLayout,
|
|
23
|
+
DynamicFormLayoutService,
|
|
24
|
+
DynamicFormValidationService,
|
|
25
|
+
DynamicInputModel,
|
|
26
|
+
DynamicFormsCoreModule
|
|
27
|
+
} from "@ng-dynamic-forms/core";
|
|
28
|
+
import { NgxMaskDirective, provideNgxMask } from "ngx-mask";
|
|
29
|
+
import { NgIf, NgClass, NgFor, AsyncPipe } from "@angular/common";
|
|
30
|
+
|
|
31
|
+
@Component({
|
|
32
|
+
selector: "dynamic-ng-bootstrap-input",
|
|
33
|
+
templateUrl: "./dynamic-ng-bootstrap-input.component.html",
|
|
34
|
+
changeDetection: ChangeDetectionStrategy.Default,
|
|
35
|
+
standalone: true,
|
|
36
|
+
imports: [ReactiveFormsModule, NgIf, DynamicFormsCoreModule, NgClass, NgxMaskDirective, NgFor, AsyncPipe],
|
|
37
|
+
providers: [provideNgxMask()]
|
|
38
|
+
})
|
|
39
|
+
export class DynamicNGBootstrapInputComponent extends DynamicFormControlComponent {
|
|
40
|
+
@Input() formLayout?: DynamicFormLayout;
|
|
41
|
+
@Input() group!: UntypedFormGroup;
|
|
42
|
+
@Input() layout?: DynamicFormControlLayout;
|
|
43
|
+
@Input() model!: DynamicInputModel;
|
|
44
|
+
|
|
45
|
+
@Output() blur: EventEmitter<any> = new EventEmitter();
|
|
46
|
+
@Output() change: EventEmitter<any> = new EventEmitter();
|
|
47
|
+
@Output() focus: EventEmitter<any> = new EventEmitter();
|
|
48
|
+
|
|
49
|
+
constructor(protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService) {
|
|
50
|
+
super(layoutService, validationService);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
~ Copyright (c) 2016-2021, Udo Schöfer http://www.udos86.de
|
|
3
|
+
~
|
|
4
|
+
~ Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
~ purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
~ copyright notice and this permission notice appear in all copies.
|
|
7
|
+
~
|
|
8
|
+
~ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
~ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
~ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
~ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
~ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
~ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
~ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
<ng-container [formGroup]="group">
|
|
18
|
+
|
|
19
|
+
<div class="btn-group" role="group"
|
|
20
|
+
ngDefaultControl
|
|
21
|
+
[formControlName]="model.id"
|
|
22
|
+
[id]="id"
|
|
23
|
+
[ngClass]="getClass('element', 'control')"
|
|
24
|
+
[tabindex]="model.tabIndex"
|
|
25
|
+
(change)="onChange($event)">
|
|
26
|
+
|
|
27
|
+
<legend *ngIf="model.legend" [innerHTML]="model.legend"></legend>
|
|
28
|
+
|
|
29
|
+
<label *ngFor="let option of model.options$ | async"
|
|
30
|
+
[ngClass]="[getClass('element', 'option'), getClass('grid', 'option')]">
|
|
31
|
+
|
|
32
|
+
<input type="radio"
|
|
33
|
+
[disabled]="option.disabled"
|
|
34
|
+
[name]="model.name"
|
|
35
|
+
[value]="option.value"
|
|
36
|
+
(blur)="onBlur($event)"
|
|
37
|
+
(focus)="onFocus($event)"/><span [innerHTML]="option.label"></span>
|
|
38
|
+
</label>
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
</ng-container>
|