@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,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
+ DynamicSwitchModel
26
+ } from "@ng-dynamic-forms/core";
27
+ import { NgClass } from "@angular/common";
28
+
29
+ @Component({
30
+ selector: "dynamic-ng-bootstrap-switch",
31
+ templateUrl: "./dynamic-ng-bootstrap-switch.component.html",
32
+ changeDetection: ChangeDetectionStrategy.Default,
33
+ standalone: true,
34
+ imports: [ReactiveFormsModule, NgClass]
35
+ })
36
+ export class DynamicNGBootstrapSwitchComponent extends DynamicFormControlComponent {
37
+ @Input() formLayout?: DynamicFormLayout;
38
+ @Input() group!: UntypedFormGroup;
39
+ @Input() layout?: DynamicFormControlLayout;
40
+ @Input() model!: DynamicSwitchModel;
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,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
+ <textarea class="form-control"
20
+ [class.is-invalid]="showErrorMessages"
21
+ [cols]="model.cols"
22
+ [formControlName]="model.id"
23
+ [id]="id"
24
+ [maxlength]="model.maxLength"
25
+ [minlength]="model.minLength"
26
+ [name]="model.name"
27
+ [ngClass]="getClass('element', 'control')"
28
+ [placeholder]="model.placeholder"
29
+ [readonly]="model.readOnly"
30
+ [required]="model.required"
31
+ [rows]="model.rows"
32
+ [spellcheck]="model.spellCheck"
33
+ [tabindex]="model.tabIndex"
34
+ [wrap]="model.wrap"
35
+ (blur)="onBlur($event)"
36
+ (change)="onChange($event)"
37
+ (focus)="onFocus($event)"></textarea>
38
+
39
+ </ng-container>
@@ -0,0 +1,105 @@
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, DynamicTextAreaModel } from "@ng-dynamic-forms/core";
22
+ import { DynamicNGBootstrapTextAreaComponent } from "./dynamic-ng-bootstrap-textarea.component";
23
+
24
+ describe("DynamicNGBootstrapTextAreaComponent test suite", () => {
25
+ const testModel = new DynamicTextAreaModel({id: "textarea"});
26
+ const formModel = [testModel];
27
+
28
+ let formGroup: UntypedFormGroup;
29
+ let fixture: ComponentFixture<DynamicNGBootstrapTextAreaComponent>;
30
+ let component: DynamicNGBootstrapTextAreaComponent;
31
+ let debugElement: DebugElement;
32
+ let testElement: DebugElement;
33
+
34
+ beforeEach(waitForAsync(() => {
35
+ TestBed.configureTestingModule({
36
+ imports: [DynamicNGBootstrapTextAreaComponent]
37
+ }).compileComponents().then(() => {
38
+ fixture = TestBed.createComponent(DynamicNGBootstrapTextAreaComponent);
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(`textarea[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 DynamicTextAreaModel).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 textarea 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
+ testElement.triggerEventHandler("change", 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
+ testElement.triggerEventHandler("focus", null);
102
+
103
+ expect(component.focus.emit).toHaveBeenCalledTimes(2);
104
+ });
105
+ });
@@ -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
+ DynamicTextAreaModel
26
+ } from "@ng-dynamic-forms/core";
27
+ import { NgClass } from "@angular/common";
28
+
29
+ @Component({
30
+ selector: "dynamic-ng-bootstrap-textarea",
31
+ templateUrl: "./dynamic-ng-bootstrap-textarea.component.html",
32
+ changeDetection: ChangeDetectionStrategy.Default,
33
+ standalone: true,
34
+ imports: [ReactiveFormsModule, NgClass]
35
+ })
36
+ export class DynamicNGBootstrapTextAreaComponent extends DynamicFormControlComponent {
37
+ @Input() formLayout?: DynamicFormLayout;
38
+ @Input() group!: UntypedFormGroup;
39
+ @Input() layout?: DynamicFormControlLayout;
40
+ @Input() model!: DynamicTextAreaModel;
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,30 @@
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-timepicker [id]="id"
20
+ [formControlName]="model.id"
21
+ [hourStep]="model.getAdditional('hourStep', config['hourStep'])"
22
+ [meridian]="model.meridian"
23
+ [minuteStep]="model.getAdditional('minuteStep', config['minuteStep'])"
24
+ [ngClass]="getClass('element', 'control')"
25
+ [seconds]="model.showSeconds"
26
+ [secondStep]="model.getAdditional('secondStep', config['secondStep'])"
27
+ [size]="model.getAdditional('size', config['size'])"
28
+ [spinners]="model.getAdditional('spinners', config['spinners'])"></ngb-timepicker>
29
+
30
+ </ng-container>
@@ -0,0 +1,111 @@
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 { ReactiveFormsModule, UntypedFormGroup, UntypedFormControl } from "@angular/forms";
20
+ import { NoopAnimationsModule } from "@angular/platform-browser/animations";
21
+ import { By } from "@angular/platform-browser";
22
+ import { NgbTimepicker, NgbTimepickerModule } from "@ng-bootstrap/ng-bootstrap";
23
+ import { DynamicFormsCoreModule, DynamicFormService, DynamicTimePickerModel } from "@ng-dynamic-forms/core";
24
+ import { DynamicNGBootstrapTimePickerComponent } from "./dynamic-ng-bootstrap-timepicker.component";
25
+
26
+ describe("DynamicNGBootstrapTimePickerComponent test suite", () => {
27
+ const testModel = new DynamicTimePickerModel({id: "timepicker"});
28
+ const formModel = [testModel];
29
+
30
+ let formGroup: UntypedFormGroup;
31
+ let fixture: ComponentFixture<DynamicNGBootstrapTimePickerComponent>;
32
+ let component: DynamicNGBootstrapTimePickerComponent;
33
+ let debugElement: DebugElement;
34
+ let testElement: DebugElement;
35
+
36
+ beforeEach(waitForAsync(() => {
37
+ TestBed.configureTestingModule({
38
+ imports: [
39
+ ReactiveFormsModule,
40
+ NoopAnimationsModule,
41
+ NgbTimepickerModule,
42
+ DynamicFormsCoreModule,
43
+ DynamicNGBootstrapTimePickerComponent
44
+ ]
45
+ }).compileComponents().then(() => {
46
+ fixture = TestBed.createComponent(DynamicNGBootstrapTimePickerComponent);
47
+
48
+ component = fixture.componentInstance;
49
+ debugElement = fixture.debugElement;
50
+ });
51
+ }));
52
+
53
+ beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
54
+ formGroup = service.createFormGroup(formModel);
55
+
56
+ component.group = formGroup;
57
+ component.model = testModel;
58
+
59
+ fixture.detectChanges();
60
+
61
+ testElement = debugElement.query(By.css(`ngb-timepicker[id="${testModel.id}"]`));
62
+ }));
63
+
64
+ it("should initialize correctly", () => {
65
+ expect(component.control instanceof UntypedFormControl).toBe(true);
66
+ expect(component.group instanceof UntypedFormGroup).toBe(true);
67
+ expect(component.model instanceof DynamicTimePickerModel).toBe(true);
68
+ expect(component.ngbTimePicker instanceof NgbTimepicker).toBe(true);
69
+
70
+ expect(component.blur).toBeDefined();
71
+ expect(component.change).toBeDefined();
72
+ expect(component.focus).toBeDefined();
73
+
74
+ expect(component.onBlur).toBeDefined();
75
+ expect(component.onChange).toBeDefined();
76
+ expect(component.onFocus).toBeDefined();
77
+
78
+ expect(component.hasFocus).toBe(false);
79
+ expect(component.isValid).toBe(true);
80
+ expect(component.isInvalid).toBe(false);
81
+ expect(component.showErrorMessages).toBe(false);
82
+ });
83
+
84
+ it("should have an ngb-timepicker element", () => {
85
+ expect(testElement instanceof DebugElement).toBe(true);
86
+ });
87
+
88
+ it("should emit blur event", () => {
89
+ spyOn(component.blur, "emit");
90
+
91
+ component.onBlur(null);
92
+
93
+ expect(component.blur.emit).toHaveBeenCalled();
94
+ });
95
+
96
+ it("should emit change event", () => {
97
+ spyOn(component.change, "emit");
98
+
99
+ component.onChange(null);
100
+
101
+ expect(component.change.emit).toHaveBeenCalled();
102
+ });
103
+
104
+ it("should emit focus event", () => {
105
+ spyOn(component.focus, "emit");
106
+
107
+ component.onFocus(null);
108
+
109
+ expect(component.focus.emit).toHaveBeenCalled();
110
+ });
111
+ });
@@ -0,0 +1,54 @@
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 { NgbTimepicker, NgbTimepickerConfig, NgbTimepickerModule } from "@ng-bootstrap/ng-bootstrap";
20
+ import {
21
+ DynamicFormControlComponent,
22
+ DynamicFormControlLayout,
23
+ DynamicFormLayout,
24
+ DynamicFormLayoutService,
25
+ DynamicFormValidationService,
26
+ DynamicTimePickerModel
27
+ } from "@ng-dynamic-forms/core";
28
+ import { NgClass } from "@angular/common";
29
+
30
+ @Component({
31
+ selector: "dynamic-ng-bootstrap-timepicker",
32
+ templateUrl: "./dynamic-ng-bootstrap-timepicker.component.html",
33
+ changeDetection: ChangeDetectionStrategy.OnPush,
34
+ standalone: true,
35
+ imports: [ReactiveFormsModule, NgbTimepickerModule, NgClass]
36
+ })
37
+ export class DynamicNGBootstrapTimePickerComponent extends DynamicFormControlComponent {
38
+ @Input() formLayout?: DynamicFormLayout;
39
+ @Input() group!: UntypedFormGroup;
40
+ @Input() layout?: DynamicFormControlLayout;
41
+ @Input() model!: DynamicTimePickerModel;
42
+
43
+ @Output() blur: EventEmitter<any> = new EventEmitter();
44
+ @Output() change: EventEmitter<any> = new EventEmitter();
45
+ @Output() focus: EventEmitter<any> = new EventEmitter();
46
+
47
+ @ViewChild(NgbTimepicker, {static: true}) ngbTimePicker!: NgbTimepicker;
48
+
49
+ constructor(protected layoutService: DynamicFormLayoutService,
50
+ protected validationService: DynamicFormValidationService,
51
+ public config: NgbTimepickerConfig) {
52
+ super(layoutService, validationService);
53
+ }
54
+ }
@@ -1,3 +1,19 @@
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
+
1
17
  export * from "./calendar/dynamic-ng-bootstrap-calendar.component";
2
18
  export * from "./checkbox/dynamic-ng-bootstrap-checkbox.component";
3
19
  export * from "./checkbox-group/dynamic-ng-bootstrap-checkbox-group.component";
@@ -9,5 +25,7 @@ export * from "./select/dynamic-ng-bootstrap-select.component";
9
25
  export * from "./switch/dynamic-ng-bootstrap-switch.component";
10
26
  export * from "./textarea/dynamic-ng-bootstrap-textarea.component";
11
27
  export * from "./timepicker/dynamic-ng-bootstrap-timepicker.component";
28
+
12
29
  export * from "./dynamic-ng-bootstrap-form.component";
13
30
  export * from "./dynamic-ng-bootstrap-form-control-container.component";
31
+
@@ -0,0 +1,17 @@
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
+ export * from "./lib/ui-ng-bootstrap";
package/src/test.ts ADDED
@@ -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
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
18
+
19
+ import 'core-js/es/reflect';
20
+ import 'zone.js';
21
+ import 'zone.js/testing';
22
+ import '@angular/localize/init';
23
+ import { getTestBed } from '@angular/core/testing';
24
+ import {
25
+ BrowserDynamicTestingModule,
26
+ platformBrowserDynamicTesting
27
+ } from '@angular/platform-browser-dynamic/testing';
28
+
29
+ // First, initialize the Angular testing environment.
30
+ getTestBed().initTestEnvironment(
31
+ BrowserDynamicTestingModule,
32
+ platformBrowserDynamicTesting(), {
33
+ teardown: { destroyAfterEach: false }
34
+ }
35
+ );
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../out-tsc/lib",
5
+ "declarationMap": true,
6
+ "module": "es2015",
7
+ "moduleResolution": "node",
8
+ "declaration": true,
9
+ "sourceMap": true,
10
+ "inlineSources": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "types": [],
14
+ "lib": [
15
+ "dom",
16
+ "es2018"
17
+ ]
18
+ },
19
+ "angularCompilerOptions": {
20
+ "skipTemplateCodegen": true,
21
+ "strictMetadataEmit": true,
22
+ "fullTemplateTypeCheck": true,
23
+ "strictInjectionParameters": true,
24
+ "enableResourceInlining": true
25
+ },
26
+ "exclude": [
27
+ "src/test.ts",
28
+ "**/*.spec.ts"
29
+ ]
30
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.lib.json",
3
+ "compilerOptions": {
4
+ "declarationMap": false
5
+ },
6
+ "angularCompilerOptions": {
7
+ "compilationMode": "partial"
8
+ }
9
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../out-tsc/spec",
5
+ "types": [
6
+ "jasmine",
7
+ "node"
8
+ ]
9
+ },
10
+ "files": [
11
+ "src/test.ts"
12
+ ],
13
+ "include": [
14
+ "**/*.spec.ts",
15
+ "**/*.d.ts"
16
+ ]
17
+ }
package/tslint.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../../../tslint.json",
3
+ "rules": {
4
+ "directive-selector": [
5
+ true,
6
+ "attribute",
7
+ "dynamic",
8
+ "camelCase"
9
+ ],
10
+ "component-selector": [
11
+ true,
12
+ "element",
13
+ "dynamic",
14
+ "kebab-case"
15
+ ]
16
+ }
17
+ }