@4science_ng-dynamic-forms/ui-ng-bootstrap 19.0.1 → 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 +4 -15
  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
package/karma.conf.js ADDED
@@ -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
+ // Karma configuration file, see link for more information
18
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
19
+
20
+ module.exports = function (config) {
21
+ config.set({
22
+ basePath: '',
23
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
24
+ plugins: [
25
+ require('karma-jasmine'),
26
+ require('karma-chrome-launcher'),
27
+ require('karma-jasmine-html-reporter'),
28
+ require('karma-coverage'),
29
+ require('@angular-devkit/build-angular/plugins/karma')
30
+ ],
31
+ client: {
32
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
33
+ },
34
+ coverageReporter: {
35
+ dir: require('path').join(__dirname, '../../../coverage/ng-dynamic-forms/ui-ng-bootstrap'),
36
+ subdir: '.',
37
+ reporters: [
38
+ {type: 'html'},
39
+ {type: 'json'},
40
+ {type: 'lcovonly'}
41
+ ]
42
+ },
43
+ reporters: ['progress', 'kjhtml'],
44
+ port: 9876,
45
+ colors: true,
46
+ logLevel: config.LOG_INFO,
47
+ autoWatch: false,
48
+ browsers: ['ChromeHeadless'],
49
+ singleRun: true,
50
+ restartOnFileChange: false
51
+ });
52
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../../dist/ng-dynamic-forms/ui-ng-bootstrap",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts",
6
+ "flatModuleFile": "ui-ng-bootstrap"
7
+ }
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4science_ng-dynamic-forms/ui-ng-bootstrap",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "description": "NG Bootstrap UI package for NG Dynamic Forms",
5
5
  "keywords": [
6
6
  "angular",
@@ -23,8 +23,8 @@
23
23
  "url": "https://github.com/udos86/ng-dynamic-forms"
24
24
  },
25
25
  "main": "./bundles/ui-ng-bootstrap.umd.js",
26
- "module": "fesm2022/ui-ng-bootstrap.mjs",
27
- "typings": "index.d.ts",
26
+ "module": "./fesm5/ui-ng-bootstrap.js",
27
+ "typings": "./ui-ng-bootstrap.d.ts",
28
28
  "repository": {
29
29
  "type": "git",
30
30
  "url": "git+https://github.com/udos86/ng-dynamic-forms.git"
@@ -43,16 +43,5 @@
43
43
  "sideEffects": false,
44
44
  "dependencies": {
45
45
  "tslib": "^2.0.0"
46
- },
47
- "exports": {
48
- "./package.json": {
49
- "default": "./package.json"
50
- },
51
- ".": {
52
- "types": "./index.d.ts",
53
- "esm2022": "./esm2022/ui-ng-bootstrap.mjs",
54
- "esm": "./esm2022/ui-ng-bootstrap.mjs",
55
- "default": "./fesm2022/ui-ng-bootstrap.mjs"
56
- }
57
46
  }
58
- }
47
+ }
@@ -0,0 +1,33 @@
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-datepicker [displayMonths]="model.getAdditional('displayMonths', config['displayMonths'])"
20
+ [firstDayOfWeek]="model.getAdditional('firstDayOfWeek', config['firstDayOfWeek'])"
21
+ [formControlName]="model.id"
22
+ [id]="id"
23
+ [maxDate]="model.max"
24
+ [minDate]="model.min"
25
+ [navigation]="model.getAdditional('navigation', config['navigation'])"
26
+ [ngClass]="getClass('element', 'control')"
27
+ [outsideDays]="model.getAdditional('outsideDays', config['outsideDays'])"
28
+ [showWeekNumbers]="model.getAdditional('showWeekNumbers', config['showWeekNumbers'])"
29
+ [weekdays]="model.getAdditional('showWeekdays', config['weekdays'])"
30
+ [startDate]="model.focusedDate"
31
+ (select)="onChange($event)"></ngb-datepicker>
32
+
33
+ </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 { NgbDatepicker } from "@ng-bootstrap/ng-bootstrap";
22
+ import { DynamicDatePickerModel, DynamicFormService } from "@ng-dynamic-forms/core";
23
+ import { DynamicNGBootstrapCalendarComponent } from "./dynamic-ng-bootstrap-calendar.component";
24
+
25
+ describe("DynamicNGBootstrapCalendarComponent test suite", () => {
26
+ const testModel = new DynamicDatePickerModel({id: "calendar"});
27
+ const formModel = [testModel];
28
+
29
+ let formGroup: UntypedFormGroup;
30
+ let fixture: ComponentFixture<DynamicNGBootstrapCalendarComponent>;
31
+ let component: DynamicNGBootstrapCalendarComponent;
32
+ let debugElement: DebugElement;
33
+ let testElement: DebugElement;
34
+
35
+ beforeEach(waitForAsync(() => {
36
+ TestBed.configureTestingModule({
37
+ imports: [DynamicNGBootstrapCalendarComponent]
38
+ }).compileComponents().then(() => {
39
+ fixture = TestBed.createComponent(DynamicNGBootstrapCalendarComponent);
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-datepicker[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 DynamicDatePickerModel).toBe(true);
61
+ expect(component.ngbCalendar instanceof NgbDatepicker).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-datepicker element", () => {
78
+ expect(testElement instanceof DebugElement).toBe(true);
79
+ });
80
+
81
+ it("should 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 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,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 { NgbDatepicker, NgbDatepickerConfig, NgbDatepickerModule } from "@ng-bootstrap/ng-bootstrap";
20
+ import {
21
+ DynamicDatePickerModel,
22
+ DynamicFormControlComponent,
23
+ DynamicFormControlLayout,
24
+ DynamicFormLayout,
25
+ DynamicFormLayoutService,
26
+ DynamicFormValidationService
27
+ } from "@ng-dynamic-forms/core";
28
+ import { NgClass } from "@angular/common";
29
+
30
+ @Component({
31
+ selector: "dynamic-ng-bootstrap-calendar",
32
+ templateUrl: "./dynamic-ng-bootstrap-calendar.component.html",
33
+ changeDetection: ChangeDetectionStrategy.OnPush,
34
+ standalone: true,
35
+ imports: [ReactiveFormsModule, NgbDatepickerModule, NgClass]
36
+ })
37
+ export class DynamicNGBootstrapCalendarComponent extends DynamicFormControlComponent {
38
+ @Input() formLayout?: DynamicFormLayout;
39
+ @Input() group!: UntypedFormGroup;
40
+ @Input() layout?: DynamicFormControlLayout;
41
+ @Input() model!: DynamicDatePickerModel;
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(NgbDatepicker, {static: true}) ngbCalendar!: NgbDatepicker;
48
+
49
+ constructor(protected layoutService: DynamicFormLayoutService,
50
+ protected validationService: DynamicFormValidationService,
51
+ public config: NgbDatepickerConfig) {
52
+ super(layoutService, validationService);
53
+ }
54
+ }
@@ -0,0 +1,38 @@
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="form-check" [class.disabled]="model.disabled">
18
+
19
+ <label class="form-check-label">
20
+
21
+ <input type="checkbox" class="form-check-input"
22
+ [checked]="model.checked"
23
+ [class.is-invalid]="showErrorMessages"
24
+ [formControlName]="model.id"
25
+ [id]="id"
26
+ [indeterminate]="model.indeterminate"
27
+ [name]="model.name"
28
+ [ngClass]="getClass('element', 'control')"
29
+ [required]="model.required"
30
+ [tabindex]="model.tabIndex"
31
+ [value]="model.value"
32
+ (blur)="onBlur($event)"
33
+ (change)="onChange($event)"
34
+ (focus)="onFocus($event)"/><span [innerHTML]="model.label"
35
+ [ngClass]="[getClass('element', 'label'), getClass('grid', 'label')]"></span>
36
+ </label>
37
+
38
+ </div>
@@ -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 { DynamicCheckboxModel, DynamicFormService } from "@ng-dynamic-forms/core";
22
+ import { DynamicNGBootstrapCheckboxComponent } from "./dynamic-ng-bootstrap-checkbox.component";
23
+
24
+ describe("DynamicNGBootstrapCheckboxComponent test suite", () => {
25
+ const testModel = new DynamicCheckboxModel({id: "checkbox"});
26
+ const formModel = [testModel];
27
+
28
+ let formGroup: UntypedFormGroup;
29
+ let fixture: ComponentFixture<DynamicNGBootstrapCheckboxComponent>;
30
+ let component: DynamicNGBootstrapCheckboxComponent;
31
+ let debugElement: DebugElement;
32
+ let testElement: DebugElement;
33
+
34
+ beforeEach(waitForAsync(() => {
35
+ TestBed.configureTestingModule({
36
+ imports: [DynamicNGBootstrapCheckboxComponent]
37
+ }).compileComponents().then(() => {
38
+ fixture = TestBed.createComponent(DynamicNGBootstrapCheckboxComponent);
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 DynamicCheckboxModel).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 checkbox 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
+ DynamicCheckboxModel,
21
+ DynamicFormControlComponent,
22
+ DynamicFormControlLayout,
23
+ DynamicFormLayout,
24
+ DynamicFormLayoutService,
25
+ DynamicFormValidationService
26
+ } from "@ng-dynamic-forms/core";
27
+ import { NgClass } from "@angular/common";
28
+
29
+ @Component({
30
+ selector: "dynamic-ng-bootstrap-checkbox",
31
+ templateUrl: "./dynamic-ng-bootstrap-checkbox.component.html",
32
+ changeDetection: ChangeDetectionStrategy.Default,
33
+ standalone: true,
34
+ imports: [ReactiveFormsModule, NgClass]
35
+ })
36
+ export class DynamicNGBootstrapCheckboxComponent extends DynamicFormControlComponent {
37
+ @Input() formLayout?: DynamicFormLayout;
38
+ @Input() group!: UntypedFormGroup;
39
+ @Input() layout?: DynamicFormControlLayout;
40
+ @Input() model!: DynamicCheckboxModel;
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,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 btn-group-toggle" data-bs-toggle="buttons"
20
+ [formGroupName]="model.id"
21
+ [id]="id"
22
+ [ngClass]="getClass('element', 'control')">
23
+
24
+ <label *ngFor="let checkboxModel of model.group"
25
+ [hidden]="checkboxModel.hidden"
26
+ [ngClass]="getClass('element', 'control', checkboxModel)">
27
+
28
+ <input type="checkbox"
29
+ [checked]="checkboxModel.checked"
30
+ [formControlName]="checkboxModel.id"
31
+ [id]="getCheckboxId(checkboxModel)"
32
+ [name]="checkboxModel.name"
33
+ [required]="checkboxModel.required"
34
+ [tabindex]="checkboxModel.tabIndex"
35
+ [value]="checkboxModel.value"
36
+ (blur)="onBlur($event)"
37
+ (change)="onCheckboxChange($event, checkboxModel)"
38
+ (focus)="onFocus($event)"/><span [ngClass]="getClass('element', 'label', checkboxModel)"
39
+ [innerHTML]="checkboxModel.label"></span></label>
40
+ </div>
41
+
42
+ </ng-container>
@@ -0,0 +1,108 @@
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 } from "@angular/forms";
20
+ import { NoopAnimationsModule } from "@angular/platform-browser/animations";
21
+ import { By } from "@angular/platform-browser";
22
+ import { DynamicCheckboxGroupModel, DynamicFormsCoreModule, DynamicFormService } from "@ng-dynamic-forms/core";
23
+ import { DynamicNGBootstrapCheckboxGroupComponent } from "./dynamic-ng-bootstrap-checkbox-group.component";
24
+
25
+ describe("DynamicNGBootstrapCheckboxGroupComponent test suite", () => {
26
+ const testModel = new DynamicCheckboxGroupModel({id: "checkboxGroup", group: []});
27
+ const formModel = [testModel];
28
+
29
+ let formGroup: UntypedFormGroup;
30
+ let fixture: ComponentFixture<DynamicNGBootstrapCheckboxGroupComponent>;
31
+ let component: DynamicNGBootstrapCheckboxGroupComponent;
32
+ let debugElement: DebugElement;
33
+ let testElement: DebugElement;
34
+
35
+ beforeEach(waitForAsync(() => {
36
+ TestBed.configureTestingModule({
37
+ imports: [
38
+ ReactiveFormsModule,
39
+ NoopAnimationsModule,
40
+ DynamicFormsCoreModule,
41
+ DynamicNGBootstrapCheckboxGroupComponent
42
+ ]
43
+ }).compileComponents().then(() => {
44
+ fixture = TestBed.createComponent(DynamicNGBootstrapCheckboxGroupComponent);
45
+
46
+ component = fixture.componentInstance;
47
+ debugElement = fixture.debugElement;
48
+ });
49
+ }));
50
+
51
+ beforeEach(inject([DynamicFormService], (service: DynamicFormService) => {
52
+ formGroup = service.createFormGroup(formModel);
53
+
54
+ component.group = formGroup;
55
+ component.model = testModel;
56
+
57
+ fixture.detectChanges();
58
+
59
+ testElement = debugElement.query(By.css(`div.btn-group`));
60
+ }));
61
+
62
+ it("should initialize correctly", () => {
63
+ expect(component.control instanceof UntypedFormGroup).toBe(true);
64
+ expect(component.group instanceof UntypedFormGroup).toBe(true);
65
+ expect(component.model instanceof DynamicCheckboxGroupModel).toBe(true);
66
+
67
+ expect(component.blur).toBeDefined();
68
+ expect(component.change).toBeDefined();
69
+ expect(component.focus).toBeDefined();
70
+
71
+ expect(component.onBlur).toBeDefined();
72
+ expect(component.onChange).toBeDefined();
73
+ expect(component.onFocus).toBeDefined();
74
+
75
+ expect(component.hasFocus).toBe(false);
76
+ expect(component.isValid).toBe(true);
77
+ expect(component.isInvalid).toBe(false);
78
+ expect(component.showErrorMessages).toBe(false);
79
+ });
80
+
81
+ it("should have an div.btn-group element", () => {
82
+ expect(testElement instanceof DebugElement).toBe(true);
83
+ });
84
+
85
+ it("should emit blur event", () => {
86
+ spyOn(component.blur, "emit");
87
+
88
+ component.onBlur(null);
89
+
90
+ expect(component.blur.emit).toHaveBeenCalled();
91
+ });
92
+
93
+ it("should emit change event", () => {
94
+ spyOn(component.change, "emit");
95
+
96
+ component.onChange(null);
97
+
98
+ expect(component.change.emit).toHaveBeenCalled();
99
+ });
100
+
101
+ it("should emit focus event", () => {
102
+ spyOn(component.focus, "emit");
103
+
104
+ component.onFocus(null);
105
+
106
+ expect(component.focus.emit).toHaveBeenCalled();
107
+ });
108
+ });