@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.
Files changed (83) hide show
  1. package/karma.conf.js +52 -0
  2. package/ng-package.json +8 -0
  3. package/package.json +6 -17
  4. package/src/lib/calendar/dynamic-ng-bootstrap-calendar.component.html +33 -0
  5. package/src/lib/calendar/dynamic-ng-bootstrap-calendar.component.spec.ts +104 -0
  6. package/src/lib/calendar/dynamic-ng-bootstrap-calendar.component.ts +54 -0
  7. package/src/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.html +38 -0
  8. package/src/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.spec.ts +104 -0
  9. package/src/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.ts +49 -0
  10. package/src/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.html +42 -0
  11. package/src/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.spec.ts +108 -0
  12. package/src/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.ts +59 -0
  13. package/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.html +51 -0
  14. package/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.spec.ts +103 -0
  15. package/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.ts +56 -0
  16. package/src/lib/dynamic-ng-bootstrap-form-array.component.html +45 -0
  17. package/src/lib/dynamic-ng-bootstrap-form-control-container.component.html +44 -0
  18. package/src/lib/dynamic-ng-bootstrap-form-control-container.component.spec.ts +198 -0
  19. package/src/lib/dynamic-ng-bootstrap-form-control-container.component.ts +214 -0
  20. package/src/lib/dynamic-ng-bootstrap-form-group.component.html +35 -0
  21. package/src/lib/dynamic-ng-bootstrap-form.component.html +26 -0
  22. package/src/lib/dynamic-ng-bootstrap-form.component.ts +65 -0
  23. package/src/lib/input/dynamic-ng-bootstrap-input.component.html +101 -0
  24. package/src/lib/input/dynamic-ng-bootstrap-input.component.spec.ts +107 -0
  25. package/src/lib/input/dynamic-ng-bootstrap-input.component.ts +52 -0
  26. package/src/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.html +42 -0
  27. package/src/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.spec.ts +106 -0
  28. package/src/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.ts +49 -0
  29. package/src/lib/rating/dynamic-ng-bootstrap-rating.component.html +28 -0
  30. package/src/lib/rating/dynamic-ng-bootstrap-rating.component.spec.ts +104 -0
  31. package/src/lib/rating/dynamic-ng-bootstrap-rating.component.ts +56 -0
  32. package/src/lib/select/dynamic-ng-bootstrap-select.component.html +39 -0
  33. package/src/lib/select/dynamic-ng-bootstrap-select.component.spec.ts +104 -0
  34. package/src/lib/select/dynamic-ng-bootstrap-select.component.ts +49 -0
  35. package/src/lib/switch/dynamic-ng-bootstrap-switch.component.html +35 -0
  36. package/src/lib/switch/dynamic-ng-bootstrap-switch.component.spec.ts +104 -0
  37. package/src/lib/switch/dynamic-ng-bootstrap-switch.component.ts +49 -0
  38. package/src/lib/textarea/dynamic-ng-bootstrap-textarea.component.html +39 -0
  39. package/src/lib/textarea/dynamic-ng-bootstrap-textarea.component.spec.ts +105 -0
  40. package/src/lib/textarea/dynamic-ng-bootstrap-textarea.component.ts +49 -0
  41. package/src/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.html +30 -0
  42. package/src/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.spec.ts +111 -0
  43. package/src/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.ts +54 -0
  44. package/{lib/ui-ng-bootstrap.d.ts → src/lib/ui-ng-bootstrap.ts} +18 -0
  45. package/src/public-api.ts +17 -0
  46. package/src/test.ts +35 -0
  47. package/tsconfig.lib.json +30 -0
  48. package/tsconfig.lib.prod.json +9 -0
  49. package/tsconfig.spec.json +17 -0
  50. package/tslint.json +17 -0
  51. package/esm2022/lib/calendar/dynamic-ng-bootstrap-calendar.component.mjs +0 -59
  52. package/esm2022/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.mjs +0 -53
  53. package/esm2022/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.mjs +0 -60
  54. package/esm2022/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.mjs +0 -62
  55. package/esm2022/lib/dynamic-ng-bootstrap-form-control-container.component.mjs +0 -201
  56. package/esm2022/lib/dynamic-ng-bootstrap-form.component.mjs +0 -59
  57. package/esm2022/lib/input/dynamic-ng-bootstrap-input.component.mjs +0 -54
  58. package/esm2022/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.mjs +0 -53
  59. package/esm2022/lib/rating/dynamic-ng-bootstrap-rating.component.mjs +0 -62
  60. package/esm2022/lib/select/dynamic-ng-bootstrap-select.component.mjs +0 -53
  61. package/esm2022/lib/switch/dynamic-ng-bootstrap-switch.component.mjs +0 -53
  62. package/esm2022/lib/textarea/dynamic-ng-bootstrap-textarea.component.mjs +0 -53
  63. package/esm2022/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.mjs +0 -59
  64. package/esm2022/lib/ui-ng-bootstrap.mjs +0 -29
  65. package/esm2022/public-api.mjs +0 -17
  66. package/esm2022/ui-ng-bootstrap.mjs +0 -5
  67. package/fesm2022/ui-ng-bootstrap.mjs +0 -820
  68. package/fesm2022/ui-ng-bootstrap.mjs.map +0 -1
  69. package/index.d.ts +0 -5
  70. package/lib/calendar/dynamic-ng-bootstrap-calendar.component.d.ts +0 -21
  71. package/lib/checkbox/dynamic-ng-bootstrap-checkbox.component.d.ts +0 -18
  72. package/lib/checkbox-group/dynamic-ng-bootstrap-checkbox-group.component.d.ts +0 -20
  73. package/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.d.ts +0 -22
  74. package/lib/dynamic-ng-bootstrap-form-control-container.component.d.ts +0 -65
  75. package/lib/dynamic-ng-bootstrap-form.component.d.ts +0 -21
  76. package/lib/input/dynamic-ng-bootstrap-input.component.d.ts +0 -18
  77. package/lib/radio-group/dynamic-ng-bootstrap-radio-group.component.d.ts +0 -18
  78. package/lib/rating/dynamic-ng-bootstrap-rating.component.d.ts +0 -22
  79. package/lib/select/dynamic-ng-bootstrap-select.component.d.ts +0 -18
  80. package/lib/switch/dynamic-ng-bootstrap-switch.component.d.ts +0 -18
  81. package/lib/textarea/dynamic-ng-bootstrap-textarea.component.d.ts +0 -18
  82. package/lib/timepicker/dynamic-ng-bootstrap-timepicker.component.d.ts +0 -21
  83. package/public-api.d.ts +0 -1
@@ -0,0 +1,106 @@
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, DynamicRadioGroupModel } from "@ng-dynamic-forms/core";
22
+ import { DynamicNGBootstrapRadioGroupComponent } from "./dynamic-ng-bootstrap-radio-group.component";
23
+
24
+ describe("DynamicNGBootstrapRadioGroupComponent test suite", () => {
25
+ const testModel = new DynamicRadioGroupModel({
26
+ id: "radioGroup",
27
+ options: [{value: "One"}, {value: "Two"}],
28
+ value: "One"
29
+ });
30
+ const formModel = [testModel];
31
+
32
+ let formGroup: UntypedFormGroup;
33
+ let fixture: ComponentFixture<DynamicNGBootstrapRadioGroupComponent>;
34
+ let component: DynamicNGBootstrapRadioGroupComponent;
35
+ let debugElement: DebugElement;
36
+ let testElement: DebugElement;
37
+
38
+ beforeEach(waitForAsync(() => {
39
+ TestBed.configureTestingModule({
40
+ imports: [DynamicNGBootstrapRadioGroupComponent]
41
+ }).compileComponents().then(() => {
42
+ fixture = TestBed.createComponent(DynamicNGBootstrapRadioGroupComponent);
43
+
44
+ component = fixture.componentInstance;
45
+ debugElement = fixture.debugElement;
46
+ });
47
+ }));
48
+
49
+ beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
50
+ formGroup = service.createFormGroup(formModel);
51
+
52
+ component.group = formGroup;
53
+ component.model = testModel;
54
+
55
+ fixture.detectChanges();
56
+
57
+ testElement = debugElement.query(By.css(`div[id="${testModel.id}"]`));
58
+ }));
59
+
60
+ it("should initialize correctly", () => {
61
+ expect(component.control instanceof UntypedFormControl).toBe(true);
62
+ expect(component.group instanceof UntypedFormGroup).toBe(true);
63
+ expect(component.model instanceof DynamicRadioGroupModel).toBe(true);
64
+
65
+ expect(component.blur).toBeDefined();
66
+ expect(component.change).toBeDefined();
67
+ expect(component.focus).toBeDefined();
68
+
69
+ expect(component.onBlur).toBeDefined();
70
+ expect(component.onChange).toBeDefined();
71
+ expect(component.onFocus).toBeDefined();
72
+
73
+ expect(component.hasFocus).toBe(false);
74
+ expect(component.isValid).toBe(true);
75
+ expect(component.isInvalid).toBe(false);
76
+ expect(component.showErrorMessages).toBe(false);
77
+ });
78
+
79
+ it("should have an radio group element", () => {
80
+ expect(testElement instanceof DebugElement).toBe(true);
81
+ });
82
+
83
+ it("should emit blur event", () => {
84
+ spyOn(component.blur, "emit");
85
+
86
+ component.onBlur(null);
87
+
88
+ expect(component.blur.emit).toHaveBeenCalled();
89
+ });
90
+
91
+ it("should emit change event", () => {
92
+ spyOn(component.change, "emit");
93
+
94
+ component.onChange(null);
95
+
96
+ expect(component.change.emit).toHaveBeenCalled();
97
+ });
98
+
99
+ it("should emit focus event", () => {
100
+ spyOn(component.focus, "emit");
101
+
102
+ component.onFocus(null);
103
+
104
+ expect(component.focus.emit).toHaveBeenCalled();
105
+ });
106
+ });
@@ -0,0 +1,49 @@
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
+ DynamicRadioGroupModel
26
+ } from "@ng-dynamic-forms/core";
27
+ import { NgClass, NgIf, NgFor, AsyncPipe } from "@angular/common";
28
+
29
+ @Component({
30
+ selector: "dynamic-ng-bootstrap-radio-group",
31
+ templateUrl: "./dynamic-ng-bootstrap-radio-group.component.html",
32
+ changeDetection: ChangeDetectionStrategy.OnPush,
33
+ standalone: true,
34
+ imports: [ReactiveFormsModule, NgClass, NgIf, NgFor, AsyncPipe]
35
+ })
36
+ export class DynamicNGBootstrapRadioGroupComponent extends DynamicFormControlComponent {
37
+ @Input() formLayout?: DynamicFormLayout;
38
+ @Input() group!: UntypedFormGroup;
39
+ @Input() layout?: DynamicFormControlLayout;
40
+ @Input() model!: DynamicRadioGroupModel<string>;
41
+
42
+ @Output() blur: EventEmitter<any> = new EventEmitter();
43
+ @Output() change: EventEmitter<any> = new EventEmitter();
44
+ @Output() focus: EventEmitter<any> = new EventEmitter();
45
+
46
+ constructor(protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService) {
47
+ super(layoutService, validationService);
48
+ }
49
+ }
@@ -0,0 +1,28 @@
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
+ <ngb-rating [formControlName]="model.id"
20
+ [id]="id"
21
+ [max]="model.max"
22
+ [ngClass]="getClass('element', 'control')"
23
+ [resettable]="model.getAdditional('resettable', config['resettable'])"
24
+ (hover)="onCustomEvent($event, 'hover')"
25
+ (leave)="onCustomEvent($event, 'leave')"
26
+ (rateChange)="onChange($event)"></ngb-rating>
27
+
28
+ </ng-container>
@@ -0,0 +1,104 @@
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, DynamicRatingModel } from "@ng-dynamic-forms/core";
22
+ import { DynamicNGBootstrapRatingComponent } from "./dynamic-ng-bootstrap-rating.component";
23
+ import { NgbRating } from "@ng-bootstrap/ng-bootstrap";
24
+
25
+ describe("DynamicNGBootstrapRatingComponent test suite", () => {
26
+ const testModel = new DynamicRatingModel({id: "rating"});
27
+ const formModel = [testModel];
28
+
29
+ let formGroup: UntypedFormGroup;
30
+ let fixture: ComponentFixture<DynamicNGBootstrapRatingComponent>;
31
+ let component: DynamicNGBootstrapRatingComponent;
32
+ let debugElement: DebugElement;
33
+ let testElement: DebugElement;
34
+
35
+ beforeEach(waitForAsync(() => {
36
+ TestBed.configureTestingModule({
37
+ imports: [DynamicNGBootstrapRatingComponent]
38
+ }).compileComponents().then(() => {
39
+ fixture = TestBed.createComponent(DynamicNGBootstrapRatingComponent);
40
+
41
+ component = fixture.componentInstance;
42
+ debugElement = fixture.debugElement;
43
+ });
44
+ }));
45
+
46
+ beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
47
+ formGroup = service.createFormGroup(formModel);
48
+
49
+ component.group = formGroup;
50
+ component.model = testModel;
51
+
52
+ fixture.detectChanges();
53
+
54
+ testElement = debugElement.query(By.css(`ngb-rating[id="${testModel.id}"]`));
55
+ }));
56
+
57
+ it("should initialize correctly", () => {
58
+ expect(component.control instanceof UntypedFormControl).toBe(true);
59
+ expect(component.group instanceof UntypedFormGroup).toBe(true);
60
+ expect(component.model instanceof DynamicRatingModel).toBe(true);
61
+ expect(component.ngbRating instanceof NgbRating).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 ngb-rating 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
+
86
+ expect(component.blur.emit).toHaveBeenCalled();
87
+ });
88
+
89
+ it("should emit change event", () => {
90
+ spyOn(component.change, "emit");
91
+
92
+ component.onChange(null);
93
+
94
+ expect(component.change.emit).toHaveBeenCalled();
95
+ });
96
+
97
+ it("should listen to and emit focus event", () => {
98
+ spyOn(component.focus, "emit");
99
+
100
+ component.onFocus(null);
101
+
102
+ expect(component.focus.emit).toHaveBeenCalled();
103
+ });
104
+ });
@@ -0,0 +1,56 @@
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, ViewChild } from "@angular/core";
18
+ import { UntypedFormGroup, ReactiveFormsModule } from "@angular/forms";
19
+ import { NgbRating, NgbRatingConfig, NgbRatingModule } from "@ng-bootstrap/ng-bootstrap";
20
+ import {
21
+ DynamicFormControlComponent,
22
+ DynamicFormControlCustomEvent,
23
+ DynamicFormControlLayout,
24
+ DynamicFormLayout,
25
+ DynamicFormLayoutService,
26
+ DynamicFormValidationService,
27
+ DynamicRatingModel
28
+ } from "@ng-dynamic-forms/core";
29
+ import { NgClass } from "@angular/common";
30
+
31
+ @Component({
32
+ selector: "dynamic-ng-bootstrap-rating",
33
+ templateUrl: "./dynamic-ng-bootstrap-rating.component.html",
34
+ changeDetection: ChangeDetectionStrategy.OnPush,
35
+ standalone: true,
36
+ imports: [ReactiveFormsModule, NgbRatingModule, NgClass]
37
+ })
38
+ export class DynamicNGBootstrapRatingComponent extends DynamicFormControlComponent {
39
+ @Input() formLayout?: DynamicFormLayout;
40
+ @Input() group!: UntypedFormGroup;
41
+ @Input() layout?: DynamicFormControlLayout;
42
+ @Input() model!: DynamicRatingModel;
43
+
44
+ @Output() blur: EventEmitter<any> = new EventEmitter();
45
+ @Output() change: EventEmitter<any> = new EventEmitter();
46
+ @Output() customEvent: EventEmitter<DynamicFormControlCustomEvent> = new EventEmitter();
47
+ @Output() focus: EventEmitter<any> = new EventEmitter();
48
+
49
+ @ViewChild(NgbRating, {static: true}) ngbRating!: NgbRating;
50
+
51
+ constructor(protected layoutService: DynamicFormLayoutService,
52
+ protected validationService: DynamicFormValidationService,
53
+ public config: NgbRatingConfig) {
54
+ super(layoutService, validationService);
55
+ }
56
+ }
@@ -0,0 +1,39 @@
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
+ <select class="form-control"
20
+ [class.is-invalid]="showErrorMessages"
21
+ [compareWith]="model.compareWithFn"
22
+ [formControlName]="model.id"
23
+ [id]="id"
24
+ [attr.aria-label]="model.label"
25
+ [name]="model.name"
26
+ [ngClass]="getClass('element', 'control')"
27
+ [required]="model.required"
28
+ [tabindex]="model.tabIndex"
29
+ (blur)="onBlur($event)"
30
+ (change)="onChange($event)"
31
+ (focus)="onFocus($event)">
32
+
33
+ <option *ngFor="let option of model.options$ | async"
34
+ [disabled]="option.disabled"
35
+ [ngValue]="option.value">{{ option.label }}</option>
36
+
37
+ </select>
38
+
39
+ </ng-container>
@@ -0,0 +1,104 @@
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, DynamicSelectModel } from "@ng-dynamic-forms/core";
22
+ import { DynamicNGBootstrapSelectComponent } from "./dynamic-ng-bootstrap-select.component";
23
+
24
+ describe("DynamicNGBootstrapSelectComponent test suite", () => {
25
+ const testModel = new DynamicSelectModel({id: "select", options: [{value: "One"}, {value: "Two"}], value: "One"});
26
+ const formModel = [testModel];
27
+
28
+ let formGroup: UntypedFormGroup;
29
+ let fixture: ComponentFixture<DynamicNGBootstrapSelectComponent>;
30
+ let component: DynamicNGBootstrapSelectComponent;
31
+ let debugElement: DebugElement;
32
+ let testElement: DebugElement;
33
+
34
+ beforeEach(waitForAsync(() => {
35
+ TestBed.configureTestingModule({
36
+ imports: [DynamicNGBootstrapSelectComponent]
37
+ }).compileComponents().then(() => {
38
+ fixture = TestBed.createComponent(DynamicNGBootstrapSelectComponent);
39
+
40
+ component = fixture.componentInstance;
41
+ debugElement = fixture.debugElement;
42
+ });
43
+ }));
44
+
45
+ beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
46
+ formGroup = service.createFormGroup(formModel);
47
+
48
+ component.group = formGroup;
49
+ component.model = testModel;
50
+
51
+ fixture.detectChanges();
52
+
53
+ testElement = debugElement.query(By.css(`select[id="${testModel.id}"]`));
54
+ }));
55
+
56
+ it("should initialize correctly", () => {
57
+ expect(component.control instanceof UntypedFormControl).toBe(true);
58
+ expect(component.group instanceof UntypedFormGroup).toBe(true);
59
+ expect(component.model instanceof DynamicSelectModel).toBe(true);
60
+
61
+ expect(component.blur).toBeDefined();
62
+ expect(component.change).toBeDefined();
63
+ expect(component.focus).toBeDefined();
64
+
65
+ expect(component.onBlur).toBeDefined();
66
+ expect(component.onChange).toBeDefined();
67
+ expect(component.onFocus).toBeDefined();
68
+
69
+ expect(component.hasFocus).toBe(false);
70
+ expect(component.isValid).toBe(true);
71
+ expect(component.isInvalid).toBe(false);
72
+ expect(component.showErrorMessages).toBe(false);
73
+ });
74
+
75
+ it("should have an select element", () => {
76
+ expect(testElement instanceof DebugElement).toBe(true);
77
+ });
78
+
79
+ it("should listen to and emit blur event", () => {
80
+ spyOn(component.blur, "emit");
81
+
82
+ component.onBlur(null);
83
+ testElement.triggerEventHandler("blur", null);
84
+
85
+ expect(component.blur.emit).toHaveBeenCalledTimes(2);
86
+ });
87
+
88
+ it("should emit change event", () => {
89
+ spyOn(component.change, "emit");
90
+
91
+ component.onChange(null);
92
+
93
+ expect(component.change.emit).toHaveBeenCalled();
94
+ });
95
+
96
+ it("should listen to and emit focus event", () => {
97
+ spyOn(component.focus, "emit");
98
+
99
+ component.onFocus(null);
100
+ testElement.triggerEventHandler("focus", null);
101
+
102
+ expect(component.focus.emit).toHaveBeenCalledTimes(2);
103
+ });
104
+ });
@@ -0,0 +1,49 @@
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
+ DynamicSelectModel
26
+ } from "@ng-dynamic-forms/core";
27
+ import { NgClass, NgFor, AsyncPipe } from "@angular/common";
28
+
29
+ @Component({
30
+ selector: "dynamic-ng-bootstrap-select",
31
+ templateUrl: "./dynamic-ng-bootstrap-select.component.html",
32
+ changeDetection: ChangeDetectionStrategy.Default,
33
+ standalone: true,
34
+ imports: [ReactiveFormsModule, NgClass, NgFor, AsyncPipe]
35
+ })
36
+ export class DynamicNGBootstrapSelectComponent extends DynamicFormControlComponent {
37
+ @Input() formLayout?: DynamicFormLayout;
38
+ @Input() group!: UntypedFormGroup;
39
+ @Input() layout?: DynamicFormControlLayout;
40
+ @Input() model!: DynamicSelectModel<string>;
41
+
42
+ @Output() blur: EventEmitter<any> = new EventEmitter();
43
+ @Output() change: EventEmitter<any> = new EventEmitter();
44
+ @Output() focus: EventEmitter<any> = new EventEmitter();
45
+
46
+ constructor(protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService) {
47
+ super(layoutService, validationService);
48
+ }
49
+ }
@@ -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
+ <div [formGroup]="group" class="custom-control custom-switch">
18
+
19
+ <input type="checkbox" class="custom-control-input"
20
+ [class.is-invalid]="showErrorMessages"
21
+ [formControlName]="model.id"
22
+ [id]="id"
23
+ [name]="model.name"
24
+ [ngClass]="getClass('element', 'control')"
25
+ [required]="model.required"
26
+ [tabindex]="model.tabIndex"
27
+ [value]="model.value"
28
+ (blur)="onBlur($event)"
29
+ (change)="onChange($event)"
30
+ (focus)="onFocus($event)">
31
+
32
+ <label class="custom-control-label" [for]="id" [innerHTML]="model.label"></label>
33
+
34
+ </div>
35
+
@@ -0,0 +1,104 @@
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, DynamicSwitchModel } from "@ng-dynamic-forms/core";
22
+ import { DynamicNGBootstrapSwitchComponent } from "./dynamic-ng-bootstrap-switch.component";
23
+
24
+ describe("DynamicNGBootstrapSwitchComponent test suite", () => {
25
+ const testModel = new DynamicSwitchModel({id: "switch"});
26
+ const formModel = [testModel];
27
+
28
+ let formGroup: UntypedFormGroup;
29
+ let fixture: ComponentFixture<DynamicNGBootstrapSwitchComponent>;
30
+ let component: DynamicNGBootstrapSwitchComponent;
31
+ let debugElement: DebugElement;
32
+ let testElement: DebugElement;
33
+
34
+ beforeEach(waitForAsync(() => {
35
+ TestBed.configureTestingModule({
36
+ imports: [DynamicNGBootstrapSwitchComponent]
37
+ }).compileComponents().then(() => {
38
+ fixture = TestBed.createComponent(DynamicNGBootstrapSwitchComponent);
39
+
40
+ component = fixture.componentInstance;
41
+ debugElement = fixture.debugElement;
42
+ });
43
+ }));
44
+
45
+ beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
46
+ formGroup = service.createFormGroup(formModel);
47
+
48
+ component.group = formGroup;
49
+ component.model = testModel;
50
+
51
+ fixture.detectChanges();
52
+
53
+ testElement = debugElement.query(By.css(`input[type="checkbox"][id="${testModel.id}"]`));
54
+ }));
55
+
56
+ it("should initialize correctly", () => {
57
+ expect(component.control instanceof UntypedFormControl).toBe(true);
58
+ expect(component.group instanceof UntypedFormGroup).toBe(true);
59
+ expect(component.model instanceof DynamicSwitchModel).toBe(true);
60
+
61
+ expect(component.blur).toBeDefined();
62
+ expect(component.change).toBeDefined();
63
+ expect(component.focus).toBeDefined();
64
+
65
+ expect(component.onBlur).toBeDefined();
66
+ expect(component.onChange).toBeDefined();
67
+ expect(component.onFocus).toBeDefined();
68
+
69
+ expect(component.hasFocus).toBe(false);
70
+ expect(component.isValid).toBe(true);
71
+ expect(component.isInvalid).toBe(false);
72
+ expect(component.showErrorMessages).toBe(false);
73
+ });
74
+
75
+ it("should have an switch element", () => {
76
+ expect(testElement instanceof DebugElement).toBe(true);
77
+ });
78
+
79
+ it("should listen to and emit blur event", () => {
80
+ spyOn(component.blur, "emit");
81
+
82
+ component.onBlur(null);
83
+ testElement.triggerEventHandler("blur", null);
84
+
85
+ expect(component.blur.emit).toHaveBeenCalledTimes(2);
86
+ });
87
+
88
+ it("should emit change event", () => {
89
+ spyOn(component.change, "emit");
90
+
91
+ component.onChange(null);
92
+
93
+ expect(component.change.emit).toHaveBeenCalled();
94
+ });
95
+
96
+ it("should listen to and emit focus event", () => {
97
+ spyOn(component.focus, "emit");
98
+
99
+ component.onFocus(null);
100
+ testElement.triggerEventHandler("focus", null);
101
+
102
+ expect(component.focus.emit).toHaveBeenCalledTimes(2);
103
+ });
104
+ });