checkbox-selection-input 15.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/checkbox-selection-input-15.0.4.tgz +0 -0
- package/esm2022/checkbox-selection-input.mjs +5 -0
- package/esm2022/lib/checkbox-demo/checkbox-demo.component.mjs +137 -0
- package/esm2022/lib/checkbox-selection-input/checkbox-selection-input.component.mjs +198 -0
- package/esm2022/lib/checkbox-selection-input.module.mjs +97 -0
- package/esm2022/lib/models/index.mjs +6 -0
- package/esm2022/lib/models/selection-basic.model.mjs +10 -0
- package/esm2022/lib/models/selection-item.model.mjs +12 -0
- package/esm2022/lib/pipes/remove-underscore.pipe.mjs +17 -0
- package/esm2022/public-api.mjs +9 -0
- package/fesm2022/checkbox-selection-input.mjs +472 -0
- package/fesm2022/checkbox-selection-input.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/checkbox-demo/checkbox-demo.component.d.ts +43 -0
- package/lib/checkbox-selection-input/checkbox-selection-input.component.d.ts +51 -0
- package/lib/checkbox-selection-input.module.d.ts +26 -0
- package/lib/models/index.d.ts +2 -0
- package/lib/models/selection-basic.model.d.ts +10 -0
- package/lib/models/selection-item.model.d.ts +14 -0
- package/lib/pipes/remove-underscore.pipe.d.ts +7 -0
- package/package.json +25 -0
- package/public-api.d.ts +5 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class SelectionBasic {
|
|
2
|
+
constructor(id = 0, value = '') {
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.value = value;
|
|
5
|
+
}
|
|
6
|
+
static adapt(item) {
|
|
7
|
+
return new SelectionBasic(item?.id, (item?.value) ? item.value : item);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0aW9uLWJhc2ljLm1vZGVsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvY2hlY2tib3gtc2VsZWN0aW9uLWlucHV0L3NyYy9saWIvbW9kZWxzL3NlbGVjdGlvbi1iYXNpYy5tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxNQUFNLE9BQU8sY0FBYztJQUV6QixZQUNTLEtBQUssQ0FBQyxFQUNOLFFBQVEsRUFBRTtRQURWLE9BQUUsR0FBRixFQUFFLENBQUk7UUFDTixVQUFLLEdBQUwsS0FBSyxDQUFLO0lBQ2hCLENBQUM7SUFFSixNQUFNLENBQUMsS0FBSyxDQUFDLElBQVU7UUFFckIsT0FBTyxJQUFJLGNBQWMsQ0FDdkIsSUFBSSxFQUFFLEVBQUUsRUFDUixDQUFDLElBQUksRUFBRSxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUNsQyxDQUFDO0lBQ0osQ0FBQztDQUVGIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBTZWxlY3Rpb25CYXNpY0ludGVyZmFjZSB7XG4gIGlkOiBudW1iZXJ8c3RyaW5nO1xuICB2YWx1ZTogc3RyaW5nO1xufVxuXG5leHBvcnQgY2xhc3MgU2VsZWN0aW9uQmFzaWMgaW1wbGVtZW50cyBTZWxlY3Rpb25CYXNpY0ludGVyZmFjZSB7XG5cbiAgY29uc3RydWN0b3IoXG4gICAgcHVibGljIGlkID0gMCxcbiAgICBwdWJsaWMgdmFsdWUgPSAnJyxcbiAgKSB7fVxuXG4gIHN0YXRpYyBhZGFwdChpdGVtPzogYW55KSB7XG5cbiAgICByZXR1cm4gbmV3IFNlbGVjdGlvbkJhc2ljKFxuICAgICAgaXRlbT8uaWQsXG4gICAgICAoaXRlbT8udmFsdWUpID8gaXRlbS52YWx1ZSA6IGl0ZW0sXG4gICAgKTtcbiAgfVxuXG59XG4iXX0=
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class SelectionItem {
|
|
2
|
+
constructor(id = crypto.randomUUID(), value = '', disabled, selected) {
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.value = value;
|
|
5
|
+
this.disabled = disabled;
|
|
6
|
+
this.selected = selected;
|
|
7
|
+
}
|
|
8
|
+
static adapt(item) {
|
|
9
|
+
return new SelectionItem(item?.id, (item?.value) ? item.value : item, (item?.disabled) ? true : false, (item?.selected) ? true : false);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0aW9uLWl0ZW0ubW9kZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9jaGVja2JveC1zZWxlY3Rpb24taW5wdXQvc3JjL2xpYi9tb2RlbHMvc2VsZWN0aW9uLWl0ZW0ubW9kZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBT0EsTUFBTSxPQUFPLGFBQWE7SUFFeEIsWUFDUyxLQUFLLE1BQU0sQ0FBQyxVQUFVLEVBQUUsRUFDeEIsUUFBUSxFQUFFLEVBQ1YsUUFBa0IsRUFDbEIsUUFBa0I7UUFIbEIsT0FBRSxHQUFGLEVBQUUsQ0FBc0I7UUFDeEIsVUFBSyxHQUFMLEtBQUssQ0FBSztRQUNWLGFBQVEsR0FBUixRQUFRLENBQVU7UUFDbEIsYUFBUSxHQUFSLFFBQVEsQ0FBVTtJQUN4QixDQUFDO0lBRUosTUFBTSxDQUFDLEtBQUssQ0FBQyxJQUFVO1FBRXJCLE9BQU8sSUFBSSxhQUFhLENBQ3RCLElBQUksRUFBRSxFQUFFLEVBQ1IsQ0FBQyxJQUFJLEVBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLElBQUksRUFDakMsQ0FBQyxJQUFJLEVBQUUsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUMvQixDQUFDLElBQUksRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQ2hDLENBQUM7SUFDSixDQUFDO0NBRUYiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgaW50ZXJmYWNlIFNlbGVjdGlvbkl0ZW1JbnRlcmZhY2Uge1xuICBpZDogbnVtYmVyfHN0cmluZztcbiAgdmFsdWU6IHN0cmluZztcbiAgZGlzYWJsZWQ/OiBib29sZWFuO1xuICBzZWxlY3RlZD86IGJvb2xlYW47XG59XG5cbmV4cG9ydCBjbGFzcyBTZWxlY3Rpb25JdGVtIGltcGxlbWVudHMgU2VsZWN0aW9uSXRlbUludGVyZmFjZSB7XG5cbiAgY29uc3RydWN0b3IoXG4gICAgcHVibGljIGlkID0gY3J5cHRvLnJhbmRvbVVVSUQoKSxcbiAgICBwdWJsaWMgdmFsdWUgPSAnJyxcbiAgICBwdWJsaWMgZGlzYWJsZWQ/OiBib29sZWFuLFxuICAgIHB1YmxpYyBzZWxlY3RlZD86IGJvb2xlYW4sXG4gICkge31cblxuICBzdGF0aWMgYWRhcHQoaXRlbT86IGFueSkge1xuXG4gICAgcmV0dXJuIG5ldyBTZWxlY3Rpb25JdGVtKFxuICAgICAgaXRlbT8uaWQsXG4gICAgICAoaXRlbT8udmFsdWUpID8gaXRlbS52YWx1ZSA6IGl0ZW0sXG4gICAgICAoaXRlbT8uZGlzYWJsZWQpID8gdHJ1ZSA6IGZhbHNlLFxuICAgICAgKGl0ZW0/LnNlbGVjdGVkKSA/IHRydWUgOiBmYWxzZSxcbiAgICApO1xuICB9XG5cbn1cbiJdfQ==
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Pipe } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class RemoveUnderscorePipe {
|
|
4
|
+
transform(value) {
|
|
5
|
+
return value ? value.replace(/_/g, " ") : value;
|
|
6
|
+
}
|
|
7
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RemoveUnderscorePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
8
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: RemoveUnderscorePipe, isStandalone: true, name: "removeUnderscore" }); }
|
|
9
|
+
}
|
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RemoveUnderscorePipe, decorators: [{
|
|
11
|
+
type: Pipe,
|
|
12
|
+
args: [{
|
|
13
|
+
name: 'removeUnderscore',
|
|
14
|
+
standalone: true
|
|
15
|
+
}]
|
|
16
|
+
}] });
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtb3ZlLXVuZGVyc2NvcmUucGlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2NoZWNrYm94LXNlbGVjdGlvbi1pbnB1dC9zcmMvbGliL3BpcGVzL3JlbW92ZS11bmRlcnNjb3JlLnBpcGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLElBQUksRUFBaUIsTUFBTSxlQUFlLENBQUM7O0FBTXBELE1BQU0sT0FBTyxvQkFBb0I7SUFDL0IsU0FBUyxDQUFDLEtBQWE7UUFDckIsT0FBTyxLQUFLLENBQUEsQ0FBQyxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsSUFBSSxFQUFFLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUM7SUFDakQsQ0FBQzsrR0FIVSxvQkFBb0I7NkdBQXBCLG9CQUFvQjs7NEZBQXBCLG9CQUFvQjtrQkFKaEMsSUFBSTttQkFBQztvQkFDSixJQUFJLEVBQUUsa0JBQWtCO29CQUN4QixVQUFVLEVBQUUsSUFBSTtpQkFDakIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBQaXBlLCBQaXBlVHJhbnNmb3JtIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbkBQaXBlKHtcbiAgbmFtZTogJ3JlbW92ZVVuZGVyc2NvcmUnLFxuICBzdGFuZGFsb25lOiB0cnVlXG59KVxuZXhwb3J0IGNsYXNzIFJlbW92ZVVuZGVyc2NvcmVQaXBlIGltcGxlbWVudHMgUGlwZVRyYW5zZm9ybSB7XG4gIHRyYW5zZm9ybSh2YWx1ZTogc3RyaW5nKTogc3RyaW5nIHtcbiAgICByZXR1cm4gdmFsdWU/IHZhbHVlLnJlcGxhY2UoL18vZywgXCIgXCIpIDogdmFsdWU7XG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of checkbox-selection-input
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/models/index';
|
|
5
|
+
export * from './lib/pipes/remove-underscore.pipe';
|
|
6
|
+
export * from './lib/checkbox-demo/checkbox-demo.component';
|
|
7
|
+
export * from './lib/checkbox-selection-input/checkbox-selection-input.component';
|
|
8
|
+
export * from './lib/checkbox-selection-input.module';
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL2NoZWNrYm94LXNlbGVjdGlvbi1pbnB1dC9zcmMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsb0JBQW9CLENBQUM7QUFFbkMsY0FBYyxvQ0FBb0MsQ0FBQztBQUVuRCxjQUFjLDZDQUE2QyxDQUFDO0FBQzVELGNBQWMsbUVBQW1FLENBQUM7QUFDbEYsY0FBYyx1Q0FBdUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgY2hlY2tib3gtc2VsZWN0aW9uLWlucHV0XG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9kZWxzL2luZGV4JztcblxuZXhwb3J0ICogZnJvbSAnLi9saWIvcGlwZXMvcmVtb3ZlLXVuZGVyc2NvcmUucGlwZSc7XG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL2NoZWNrYm94LWRlbW8vY2hlY2tib3gtZGVtby5jb21wb25lbnQnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY2hlY2tib3gtc2VsZWN0aW9uLWlucHV0L2NoZWNrYm94LXNlbGVjdGlvbi1pbnB1dC5jb21wb25lbnQnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY2hlY2tib3gtc2VsZWN0aW9uLWlucHV0Lm1vZHVsZSc7XG4iXX0=
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Pipe, inject, EventEmitter, forwardRef, Component, Input, Output, NgModule } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/forms';
|
|
4
|
+
import { Validators, FormBuilder, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
import * as i1 from '@angular/common';
|
|
6
|
+
import { CommonModule } from '@angular/common';
|
|
7
|
+
import * as i3$1 from '@angular/material/button';
|
|
8
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
9
|
+
import * as i3 from '@angular/material/form-field';
|
|
10
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
11
|
+
import * as i5 from '@angular/material/button-toggle';
|
|
12
|
+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
13
|
+
import * as i6 from '@angular/material/divider';
|
|
14
|
+
import { MatDividerModule } from '@angular/material/divider';
|
|
15
|
+
import * as i7 from '@angular/material/slide-toggle';
|
|
16
|
+
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
17
|
+
import * as i4 from '@angular/material/checkbox';
|
|
18
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
19
|
+
import { MatSliderModule } from '@angular/material/slider';
|
|
20
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
21
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
22
|
+
import { MatRadioModule } from '@angular/material/radio';
|
|
23
|
+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
24
|
+
import { MatInputModule } from '@angular/material/input';
|
|
25
|
+
import { MatToolbarModule } from '@angular/material/toolbar';
|
|
26
|
+
import { MatOptionModule } from '@angular/material/core';
|
|
27
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
28
|
+
|
|
29
|
+
class SelectionBasic {
|
|
30
|
+
constructor(id = 0, value = '') {
|
|
31
|
+
this.id = id;
|
|
32
|
+
this.value = value;
|
|
33
|
+
}
|
|
34
|
+
static adapt(item) {
|
|
35
|
+
return new SelectionBasic(item?.id, (item?.value) ? item.value : item);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class SelectionItem {
|
|
40
|
+
constructor(id = crypto.randomUUID(), value = '', disabled, selected) {
|
|
41
|
+
this.id = id;
|
|
42
|
+
this.value = value;
|
|
43
|
+
this.disabled = disabled;
|
|
44
|
+
this.selected = selected;
|
|
45
|
+
}
|
|
46
|
+
static adapt(item) {
|
|
47
|
+
return new SelectionItem(item?.id, (item?.value) ? item.value : item, (item?.disabled) ? true : false, (item?.selected) ? true : false);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Public API Surface of selections
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
class RemoveUnderscorePipe {
|
|
56
|
+
transform(value) {
|
|
57
|
+
return value ? value.replace(/_/g, " ") : value;
|
|
58
|
+
}
|
|
59
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RemoveUnderscorePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
60
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: RemoveUnderscorePipe, isStandalone: true, name: "removeUnderscore" }); }
|
|
61
|
+
}
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RemoveUnderscorePipe, decorators: [{
|
|
63
|
+
type: Pipe,
|
|
64
|
+
args: [{
|
|
65
|
+
name: 'removeUnderscore',
|
|
66
|
+
standalone: true
|
|
67
|
+
}]
|
|
68
|
+
}] });
|
|
69
|
+
|
|
70
|
+
class CheckboxSelectionInputComponent {
|
|
71
|
+
set minSelection(value) {
|
|
72
|
+
this._minSelection = (value) ? value : 0;
|
|
73
|
+
}
|
|
74
|
+
get minSelection() {
|
|
75
|
+
return this._minSelection;
|
|
76
|
+
}
|
|
77
|
+
set maxSelection(value) {
|
|
78
|
+
this._maxSelection = (value) ? value : 0;
|
|
79
|
+
}
|
|
80
|
+
get maxSelection() {
|
|
81
|
+
return this._maxSelection;
|
|
82
|
+
}
|
|
83
|
+
set data(value) {
|
|
84
|
+
this.selectionControl = this.fb.group({});
|
|
85
|
+
this.isObjects = this.hasObjects(value);
|
|
86
|
+
this.raw = value;
|
|
87
|
+
this._data = (value) ? value.map(item => SelectionItem.adapt(item)) : [];
|
|
88
|
+
const selected = this.data.filter(item => item.selected).length;
|
|
89
|
+
if (this.maxSelection > 0 && selected >= this.maxSelection) {
|
|
90
|
+
for (let index = this.maxSelection + 1; index < this.data.length; index++) {
|
|
91
|
+
this.data[index].selected = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
this.data.map(item => {
|
|
95
|
+
const disabled = (item?.disabled) ? item.disabled : false;
|
|
96
|
+
const selected = (item?.selected) ? item.selected : false;
|
|
97
|
+
const newControl = this.fb.control({ value: selected, disabled }, Validators.required);
|
|
98
|
+
this.selectionControl.addControl(item.value, newControl);
|
|
99
|
+
});
|
|
100
|
+
this.initSelection();
|
|
101
|
+
}
|
|
102
|
+
get data() {
|
|
103
|
+
return this._data;
|
|
104
|
+
}
|
|
105
|
+
constructor() {
|
|
106
|
+
this.fb = inject(FormBuilder);
|
|
107
|
+
this.selectionControl = this.fb.group({});
|
|
108
|
+
this.disableMax = false;
|
|
109
|
+
this.useDefaultReset = false;
|
|
110
|
+
this._minSelection = 0;
|
|
111
|
+
this._maxSelection = 0;
|
|
112
|
+
this.isObjects = false;
|
|
113
|
+
this.formInitialized = false;
|
|
114
|
+
this.raw = [];
|
|
115
|
+
this._data = [];
|
|
116
|
+
this.selectionChange = new EventEmitter();
|
|
117
|
+
this.onChange = () => { };
|
|
118
|
+
this.onTouch = () => { };
|
|
119
|
+
// invalid = false
|
|
120
|
+
this.disabled = false;
|
|
121
|
+
this.isArray = (obj) => Array.isArray(obj);
|
|
122
|
+
this.isObject = (obj) => typeof obj === 'object' && obj !== null && !Array.isArray(obj);
|
|
123
|
+
this.hasObjects = (obj) => (this.isArray(obj) && obj.length > 0) ? this.isObject(obj[0]) : false;
|
|
124
|
+
this.objectIsEmpty = (obj) => Object.keys(obj).length === 0;
|
|
125
|
+
this.selectedCheckboxes = (obj) => Object.keys(obj).filter(key => obj[key]);
|
|
126
|
+
}
|
|
127
|
+
ngOnInit() {
|
|
128
|
+
}
|
|
129
|
+
ngAfterViewInit() {
|
|
130
|
+
this.formInitialized = true;
|
|
131
|
+
}
|
|
132
|
+
initSelection() {
|
|
133
|
+
const selectedCount = this.selectedCheckboxes(this.selectionControl.value).length;
|
|
134
|
+
const hasMax = selectedCount >= this.maxSelection && this.maxSelection > 0;
|
|
135
|
+
if (hasMax && this.disableMax) {
|
|
136
|
+
const disable = this.selectedValues(this.selectionControl.value, false);
|
|
137
|
+
disable.map(item => this.selectionControl.controls[item].disable());
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const enable = this.data.filter(item => (!item.disabled)).map(item => item.value);
|
|
141
|
+
enable.map(item => this.selectionControl.controls[item].enable());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
writeValue(value) {
|
|
145
|
+
const selected = value?.reduce((acc, item) => { return { ...acc, [item]: true }; }, {});
|
|
146
|
+
const newSelected = (selected && Object.keys(selected).length > this.maxSelection && this.maxSelection > 0)
|
|
147
|
+
? this.removeLast(selected, Object.keys(selected).length - this.maxSelection)
|
|
148
|
+
: selected;
|
|
149
|
+
if (newSelected) {
|
|
150
|
+
this.selectionControl.patchValue(newSelected, { emitEvent: false });
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (this.formInitialized)
|
|
154
|
+
this.selectionControl.reset();
|
|
155
|
+
}
|
|
156
|
+
this.formInitialized = true;
|
|
157
|
+
}
|
|
158
|
+
validate(control) {
|
|
159
|
+
const isRequired = control.hasValidator(Validators.required) ? true : false;
|
|
160
|
+
let errors = { 'minRequired': false, 'maxExceeded': false };
|
|
161
|
+
const selectedCount = this.selectedCheckboxes(this.selectionControl.value).length;
|
|
162
|
+
const hasValue = selectedCount > 0;
|
|
163
|
+
const hasMin = selectedCount < this.minSelection;
|
|
164
|
+
if (this.minSelection > 0)
|
|
165
|
+
errors.minRequired = hasMin;
|
|
166
|
+
const hasMax = selectedCount >= this.maxSelection && this.maxSelection > 0;
|
|
167
|
+
if (this.maxSelection > 0)
|
|
168
|
+
errors.maxExceeded = hasMax;
|
|
169
|
+
if (hasMax && this.disableMax) {
|
|
170
|
+
const disable = this.selectedValues(this.selectionControl.value, false);
|
|
171
|
+
disable.map(item => this.selectionControl.controls[item].disable());
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const enable = this.data.filter(item => (!item.disabled)).map(item => item.value);
|
|
175
|
+
enable.map(item => this.selectionControl.controls[item].enable());
|
|
176
|
+
}
|
|
177
|
+
const hasErrors = this.selectedValues(errors, true).length > 0;
|
|
178
|
+
const values = this.selectedValues(this.selectionControl.value, true).length;
|
|
179
|
+
const hasValues = (this.minSelection > 0 && values > this.minSelection) || (this.maxSelection > 0 && values < this.maxSelection);
|
|
180
|
+
const finalErrors = (isRequired && !hasValues && hasErrors) ? errors : null;
|
|
181
|
+
return finalErrors;
|
|
182
|
+
}
|
|
183
|
+
registerOnChange(fn) {
|
|
184
|
+
this.onChange = fn;
|
|
185
|
+
}
|
|
186
|
+
registerOnTouched(fn) {
|
|
187
|
+
this.onTouch = fn;
|
|
188
|
+
}
|
|
189
|
+
setDisabledState(isDisabled) {
|
|
190
|
+
this.disabled = isDisabled;
|
|
191
|
+
if (this.disabled) {
|
|
192
|
+
this.selectionControl.disable();
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
this.selectionControl.enable();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
onSelectionChange() {
|
|
199
|
+
const data = this.selectedCheckboxes(this.selectionControl.value);
|
|
200
|
+
const selectedData = (this.isObjects) ? this.raw.filter(item => data.includes(item.value)) : data;
|
|
201
|
+
this.onChange(selectedData);
|
|
202
|
+
this.selectionChange.emit(selectedData);
|
|
203
|
+
}
|
|
204
|
+
selectedValues(obj, state = false) {
|
|
205
|
+
return Object.entries(obj).filter(([key, value]) => value === state).map(([key, _]) => key);
|
|
206
|
+
}
|
|
207
|
+
removeLast(obj, index) {
|
|
208
|
+
const entries = Object.entries(obj);
|
|
209
|
+
const slicedEntries = entries.slice(0, entries.length - index);
|
|
210
|
+
return Object.fromEntries(slicedEntries);
|
|
211
|
+
}
|
|
212
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
213
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CheckboxSelectionInputComponent, selector: "app-checkbox-selection-input", inputs: { label: "label", placeholder: "placeholder", error: "error", disableMax: "disableMax", useDefaultReset: "useDefaultReset", minSelection: "minSelection", maxSelection: "maxSelection", data: "data" }, outputs: { selectionChange: "selectionChange" }, providers: [
|
|
214
|
+
{
|
|
215
|
+
provide: NG_VALUE_ACCESSOR,
|
|
216
|
+
useExisting: forwardRef(() => CheckboxSelectionInputComponent),
|
|
217
|
+
multi: true
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
provide: NG_VALIDATORS,
|
|
221
|
+
useExisting: forwardRef(() => CheckboxSelectionInputComponent),
|
|
222
|
+
multi: true
|
|
223
|
+
}
|
|
224
|
+
], ngImport: i0, template: "<div style=\"display: flex; flex-direction: column;\">\n <mat-label style=\"padding-left: 1rem; font-size: larger;\">\n {{ label }}\n </mat-label>\n <mat-label style=\"padding-left: 1rem; color: grey;\">\n {{ placeholder }}\n </mat-label>\n <ng-container *ngIf=\"data.length > 0; else NODATA\">\n <section\n [formGroup]=\"selectionControl\"\n class=\"container\"\n >\n <mat-checkbox\n class=\"item\"\n color=\"primary\"\n *ngFor=\"let option of data\"\n [formControlName]=\"option.value\"\n [value]=\"option.value\"\n (change)=\"onSelectionChange()\"\n >\n {{option.value}}\n </mat-checkbox>\n </section>\n </ng-container>\n <ng-template #NODATA>\n <div class=\"wrapper\">\n <ng-content></ng-content>\n </div>\n </ng-template>\n</div>\n\n", styles: [".container{display:grid;grid-template-columns:repeat(auto-fit,minmax(192px,1fr));grid-auto-rows:minmax(auto,auto)}.item{flex:1 1 calc(33.33% - 2rem);margin:.25rem;margin-bottom:0;box-sizing:border-box;padding:.25rem;white-space:nowrap}.wrapper:not(:empty)+.default{display:none}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "component", type: i4.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }] }); }
|
|
225
|
+
}
|
|
226
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionInputComponent, decorators: [{
|
|
227
|
+
type: Component,
|
|
228
|
+
args: [{ selector: 'app-checkbox-selection-input', providers: [
|
|
229
|
+
{
|
|
230
|
+
provide: NG_VALUE_ACCESSOR,
|
|
231
|
+
useExisting: forwardRef(() => CheckboxSelectionInputComponent),
|
|
232
|
+
multi: true
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
provide: NG_VALIDATORS,
|
|
236
|
+
useExisting: forwardRef(() => CheckboxSelectionInputComponent),
|
|
237
|
+
multi: true
|
|
238
|
+
}
|
|
239
|
+
], template: "<div style=\"display: flex; flex-direction: column;\">\n <mat-label style=\"padding-left: 1rem; font-size: larger;\">\n {{ label }}\n </mat-label>\n <mat-label style=\"padding-left: 1rem; color: grey;\">\n {{ placeholder }}\n </mat-label>\n <ng-container *ngIf=\"data.length > 0; else NODATA\">\n <section\n [formGroup]=\"selectionControl\"\n class=\"container\"\n >\n <mat-checkbox\n class=\"item\"\n color=\"primary\"\n *ngFor=\"let option of data\"\n [formControlName]=\"option.value\"\n [value]=\"option.value\"\n (change)=\"onSelectionChange()\"\n >\n {{option.value}}\n </mat-checkbox>\n </section>\n </ng-container>\n <ng-template #NODATA>\n <div class=\"wrapper\">\n <ng-content></ng-content>\n </div>\n </ng-template>\n</div>\n\n", styles: [".container{display:grid;grid-template-columns:repeat(auto-fit,minmax(192px,1fr));grid-auto-rows:minmax(auto,auto)}.item{flex:1 1 calc(33.33% - 2rem);margin:.25rem;margin-bottom:0;box-sizing:border-box;padding:.25rem;white-space:nowrap}.wrapper:not(:empty)+.default{display:none}\n"] }]
|
|
240
|
+
}], ctorParameters: function () { return []; }, propDecorators: { label: [{
|
|
241
|
+
type: Input
|
|
242
|
+
}], placeholder: [{
|
|
243
|
+
type: Input
|
|
244
|
+
}], error: [{
|
|
245
|
+
type: Input
|
|
246
|
+
}], disableMax: [{
|
|
247
|
+
type: Input
|
|
248
|
+
}], useDefaultReset: [{
|
|
249
|
+
type: Input
|
|
250
|
+
}], minSelection: [{
|
|
251
|
+
type: Input
|
|
252
|
+
}], maxSelection: [{
|
|
253
|
+
type: Input
|
|
254
|
+
}], data: [{
|
|
255
|
+
type: Input
|
|
256
|
+
}], selectionChange: [{
|
|
257
|
+
type: Output
|
|
258
|
+
}] } });
|
|
259
|
+
|
|
260
|
+
class CheckboxSelectionDemoComponent {
|
|
261
|
+
constructor() {
|
|
262
|
+
this.fb = inject(FormBuilder);
|
|
263
|
+
this.data_1 = [
|
|
264
|
+
{ id: 11, value: 'Telus', selected: true },
|
|
265
|
+
{ id: 12, value: 'AT&T', disabled: true },
|
|
266
|
+
{ id: 14, value: 'Bell', selected: true },
|
|
267
|
+
{ id: 63, value: 'Rogers', selected: true }
|
|
268
|
+
];
|
|
269
|
+
this.data_2 = ['Telus', 'AT&T', 'Bell', 'Rogers'];
|
|
270
|
+
this.data = this.data_2;
|
|
271
|
+
// CHECKBOX
|
|
272
|
+
this.selectionControl_1 = this.fb.control(null);
|
|
273
|
+
this.selectionControl_2 = this.fb.control(null, Validators.required);
|
|
274
|
+
this.selectionControl_3 = this.fb.control(null, Validators.required);
|
|
275
|
+
this.selectionControl_4 = this.fb.control(null, Validators.required);
|
|
276
|
+
this.selectionControl_5 = this.fb.control(null, Validators.required);
|
|
277
|
+
this.selectionControl_6 = this.fb.control(null, Validators.required);
|
|
278
|
+
//CHANGE
|
|
279
|
+
this.changeDetection_1 = this.fb.control(null);
|
|
280
|
+
this.changeDetection_2 = this.fb.control(null);
|
|
281
|
+
this.changeDetection_3 = this.fb.control(null);
|
|
282
|
+
this.changeDetection_4 = this.fb.control(null);
|
|
283
|
+
this.changeDetection_5 = this.fb.control(null);
|
|
284
|
+
this.changeDetection_6 = this.fb.control(null);
|
|
285
|
+
}
|
|
286
|
+
ngOnInit() {
|
|
287
|
+
// CHECKBOX
|
|
288
|
+
this.selectionControl_1.valueChanges.subscribe(data => {
|
|
289
|
+
if (this.changeDetection_1.value)
|
|
290
|
+
console.log('CHANGE:', data);
|
|
291
|
+
});
|
|
292
|
+
this.selectionControl_2.valueChanges.subscribe(data => {
|
|
293
|
+
if (this.changeDetection_2.value)
|
|
294
|
+
console.log('CHANGE:', data);
|
|
295
|
+
});
|
|
296
|
+
this.selectionControl_3.valueChanges.subscribe(data => {
|
|
297
|
+
if (this.changeDetection_3.value)
|
|
298
|
+
console.log('CHANGE:', data);
|
|
299
|
+
});
|
|
300
|
+
this.selectionControl_4.valueChanges.subscribe(data => {
|
|
301
|
+
if (this.changeDetection_4.value)
|
|
302
|
+
console.log('CHANGE:', data);
|
|
303
|
+
});
|
|
304
|
+
this.selectionControl_5.valueChanges.subscribe(data => {
|
|
305
|
+
if (this.changeDetection_5.value)
|
|
306
|
+
console.log('CHANGE:', data);
|
|
307
|
+
});
|
|
308
|
+
this.selectionControl_6.valueChanges.subscribe(data => {
|
|
309
|
+
if (this.changeDetection_6.value)
|
|
310
|
+
console.log('CHANGE:', data);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
// DISABLE
|
|
314
|
+
onDisabled_1(disable) {
|
|
315
|
+
if (disable) {
|
|
316
|
+
this.selectionControl_1.disable();
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
this.selectionControl_1.enable();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
onDisabled_2(disable) {
|
|
323
|
+
if (disable) {
|
|
324
|
+
this.selectionControl_2.disable();
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
this.selectionControl_2.enable();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
onDisabled_3(disable) {
|
|
331
|
+
if (disable) {
|
|
332
|
+
this.selectionControl_3.disable();
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.selectionControl_3.enable();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
onDisabled_4(disable) {
|
|
339
|
+
if (disable) {
|
|
340
|
+
this.selectionControl_4.disable();
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this.selectionControl_4.enable();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
onDisabled_5(disable) {
|
|
347
|
+
if (disable) {
|
|
348
|
+
this.selectionControl_5.disable();
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
this.selectionControl_5.enable();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
onDisabled_6(disable) {
|
|
355
|
+
if (disable) {
|
|
356
|
+
this.selectionControl_6.disable();
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.selectionControl_6.enable();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
onPerformPatch() {
|
|
363
|
+
this.selectionControl_1.patchValue(['Bell', 'Rogers']);
|
|
364
|
+
this.selectionControl_2.patchValue(['Bell', 'Telus']);
|
|
365
|
+
this.selectionControl_3.patchValue(['Telus', 'Bell']);
|
|
366
|
+
this.selectionControl_4.patchValue(['Rogers']);
|
|
367
|
+
this.selectionControl_5.patchValue(['Rogers']);
|
|
368
|
+
this.selectionControl_6.patchValue(['Telus', 'Bell', 'Rogers']);
|
|
369
|
+
}
|
|
370
|
+
onChangeDataType(type) {
|
|
371
|
+
if (type === 'strings') {
|
|
372
|
+
this.data = this.data_2;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
this.data = this.data_1;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionDemoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
379
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CheckboxSelectionDemoComponent, selector: "app-checkbox-selection-demo", ngImport: i0, template: "<div style=\"display: flex;\">\n <h1>Checkbox FormControl</h1>\n <div style=\"flex:1; text-align: right;\">\n <div style=\"display: flex; gap: 2rem; flex-direction: row-reverse;\">\n <mat-button-toggle (click)=\"onPerformPatch()\">Patch</mat-button-toggle>\n <mat-button-toggle-group #varTypes=\"matButtonToggleGroup\" (change)=\"onChangeDataType(varTypes.value)\">\n <mat-button-toggle value=\"strings\" checked=\"true\">Strings</mat-button-toggle>\n <mat-button-toggle value=\"objects\" checked=\"false\">Objects</mat-button-toggle>\n </mat-button-toggle-group>\n </div>\n </div>\n</div>\n\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n </div>\n <app-checkbox-selection-input error=\"No Data Provided\">\n <h3 style=\"color: red; margin-top: 0; margin-bottom: 0;\">No Data</h3>\n </app-checkbox-selection-input>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <h3 style=\"margin-bottom: 0;\">Checkbox Selection - {{ varTypes.value | uppercase }}</h3>\n\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_1.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n [formControl]=\"selectionControl_1\"\n ></app-checkbox-selection-input>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_1\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #disable1 (change)=\"onDisabled_1(disable1.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n No Label and Placeholder<br>\n Not Required<br>\n Valid {{ selectionControl_1.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_2.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Selections\"\n placeholder=\"My placeholder\"\n [formControl]=\"selectionControl_2\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error2.checked\">\n <mat-error *ngIf=\"selectionControl_2.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_2\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error2>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable2 (change)=\"onDisabled_2(disable2.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label and Placeholder<br>\n Required<br>\n Valid {{ selectionControl_2.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_3.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_3\"\n [minSelection]=\"2\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error3.checked\">\n <mat-error *ngIf=\"selectionControl_3.hasError('minRequired')\">Minimum of 1 required</mat-error>\n <mat-error *ngIf=\"selectionControl_3.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_3\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error3>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable3 (change)=\"onDisabled_3(disable3.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Minimum of 2 Required<br>\n Valid {{ selectionControl_3.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_4.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_4\"\n [maxSelection]=\"2\"\n [disableMax]=\"false\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error4.checked\">\n <mat-error *ngIf=\"selectionControl_4.hasError('maxExceeded')\">Maximum reached</mat-error>\n <mat-error *ngIf=\"selectionControl_4.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_4\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error4>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable4 (change)=\"onDisabled_4(disable4.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Maximum of 2 Required<br>\n Valid {{ selectionControl_4.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_5.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_5\"\n [maxSelection]=\"2\"\n [disableMax]=\"true\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error5.checked\">\n <mat-error *ngIf=\"selectionControl_5.hasError('maxExceeded')\">Maximum reached</mat-error>\n <mat-error *ngIf=\"selectionControl_5.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_5\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error5>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable5 (change)=\"onDisabled_5(disable5.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Maximum of 2 Required<br>\n Disable if Max Reached<br>\n Valid {{ selectionControl_5.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_6.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_6\"\n [minSelection]=\"1\"\n [maxSelection]=\"2\"\n [disableMax]=\"true\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error6.checked\">\n <mat-error *ngIf=\"selectionControl_6.hasError('minRequired')\">Minimum of 1 required</mat-error>\n <mat-error *ngIf=\"selectionControl_6.hasError('maxExceeded')\">Maximum reached</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_6\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error6>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable6 (change)=\"onDisabled_6(disable6.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Minimum of 1 Required<br>\n Maximum of 2 Required<br>\n Disable if Max Reached<br>\n Valid {{ selectionControl_6.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i3$1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i5.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { kind: "component", type: i5.MatButtonToggle, selector: "mat-button-toggle", inputs: ["disableRipple", "aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "appearance", "checked", "disabled"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { kind: "component", type: i6.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "component", type: i7.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex"], exportAs: ["matSlideToggle"] }, { kind: "component", type: CheckboxSelectionInputComponent, selector: "app-checkbox-selection-input", inputs: ["label", "placeholder", "error", "disableMax", "useDefaultReset", "minSelection", "maxSelection", "data"], outputs: ["selectionChange"] }, { kind: "pipe", type: i1.UpperCasePipe, name: "uppercase" }] }); }
|
|
380
|
+
}
|
|
381
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionDemoComponent, decorators: [{
|
|
382
|
+
type: Component,
|
|
383
|
+
args: [{ selector: 'app-checkbox-selection-demo', template: "<div style=\"display: flex;\">\n <h1>Checkbox FormControl</h1>\n <div style=\"flex:1; text-align: right;\">\n <div style=\"display: flex; gap: 2rem; flex-direction: row-reverse;\">\n <mat-button-toggle (click)=\"onPerformPatch()\">Patch</mat-button-toggle>\n <mat-button-toggle-group #varTypes=\"matButtonToggleGroup\" (change)=\"onChangeDataType(varTypes.value)\">\n <mat-button-toggle value=\"strings\" checked=\"true\">Strings</mat-button-toggle>\n <mat-button-toggle value=\"objects\" checked=\"false\">Objects</mat-button-toggle>\n </mat-button-toggle-group>\n </div>\n </div>\n</div>\n\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n </div>\n <app-checkbox-selection-input error=\"No Data Provided\">\n <h3 style=\"color: red; margin-top: 0; margin-bottom: 0;\">No Data</h3>\n </app-checkbox-selection-input>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <h3 style=\"margin-bottom: 0;\">Checkbox Selection - {{ varTypes.value | uppercase }}</h3>\n\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_1.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n [formControl]=\"selectionControl_1\"\n ></app-checkbox-selection-input>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_1\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #disable1 (change)=\"onDisabled_1(disable1.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n No Label and Placeholder<br>\n Not Required<br>\n Valid {{ selectionControl_1.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_2.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Selections\"\n placeholder=\"My placeholder\"\n [formControl]=\"selectionControl_2\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error2.checked\">\n <mat-error *ngIf=\"selectionControl_2.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_2\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error2>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable2 (change)=\"onDisabled_2(disable2.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label and Placeholder<br>\n Required<br>\n Valid {{ selectionControl_2.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_3.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_3\"\n [minSelection]=\"2\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error3.checked\">\n <mat-error *ngIf=\"selectionControl_3.hasError('minRequired')\">Minimum of 1 required</mat-error>\n <mat-error *ngIf=\"selectionControl_3.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_3\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error3>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable3 (change)=\"onDisabled_3(disable3.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Minimum of 2 Required<br>\n Valid {{ selectionControl_3.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_4.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_4\"\n [maxSelection]=\"2\"\n [disableMax]=\"false\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error4.checked\">\n <mat-error *ngIf=\"selectionControl_4.hasError('maxExceeded')\">Maximum reached</mat-error>\n <mat-error *ngIf=\"selectionControl_4.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_4\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error4>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable4 (change)=\"onDisabled_4(disable4.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Maximum of 2 Required<br>\n Valid {{ selectionControl_4.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_5.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_5\"\n [maxSelection]=\"2\"\n [disableMax]=\"true\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error5.checked\">\n <mat-error *ngIf=\"selectionControl_5.hasError('maxExceeded')\">Maximum reached</mat-error>\n <mat-error *ngIf=\"selectionControl_5.hasError('required')\">This field is Required</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_5\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error5>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable5 (change)=\"onDisabled_5(disable5.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Maximum of 2 Required<br>\n Disable if Max Reached<br>\n Valid {{ selectionControl_5.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n\n\n<div>\n <div style=\"display: flex;\">\n <span style=\"flex:1\"></span>\n <button mat-button (click)=\"selectionControl_6.reset()\">Reset</button>\n </div>\n <app-checkbox-selection-input\n [data]=\"data\"\n label=\"Providers\"\n [formControl]=\"selectionControl_6\"\n [minSelection]=\"1\"\n [maxSelection]=\"2\"\n [disableMax]=\"true\"\n ></app-checkbox-selection-input>\n <div *ngIf=\"error6.checked\">\n <mat-error *ngIf=\"selectionControl_6.hasError('minRequired')\">Minimum of 1 required</mat-error>\n <mat-error *ngIf=\"selectionControl_6.hasError('maxExceeded')\">Maximum reached</mat-error>\n </div>\n <div style=\"display: flex; gap: 2rem; margin-top: 2rem;\">\n <mat-slide-toggle [formControl]=\"changeDetection_6\">Change Detection</mat-slide-toggle>\n <mat-slide-toggle #error6>Display Error</mat-slide-toggle>\n <mat-slide-toggle #disable6 (change)=\"onDisabled_6(disable6.checked)\">Disable</mat-slide-toggle>\n <span style=\"flex:1\"></span>\n </div>\n <div style=\"margin-top: 2rem;\">\n Label<br>\n Minimum of 1 Required<br>\n Maximum of 2 Required<br>\n Disable if Max Reached<br>\n Valid {{ selectionControl_6.valid }}<br>\n </div>\n <div style=\"margin-top: .5rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n</div>\n" }]
|
|
384
|
+
}], ctorParameters: function () { return []; } });
|
|
385
|
+
|
|
386
|
+
class CheckboxSelectionInputModule {
|
|
387
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
388
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionInputModule, declarations: [CheckboxSelectionInputComponent,
|
|
389
|
+
CheckboxSelectionDemoComponent], imports: [CommonModule,
|
|
390
|
+
FormsModule,
|
|
391
|
+
ReactiveFormsModule,
|
|
392
|
+
MatSliderModule,
|
|
393
|
+
MatButtonModule,
|
|
394
|
+
MatIconModule,
|
|
395
|
+
MatFormFieldModule,
|
|
396
|
+
MatToolbarModule,
|
|
397
|
+
MatCheckboxModule,
|
|
398
|
+
MatMenuModule,
|
|
399
|
+
MatButtonToggleModule,
|
|
400
|
+
MatDividerModule,
|
|
401
|
+
MatRadioModule,
|
|
402
|
+
MatInputModule,
|
|
403
|
+
MatAutocompleteModule,
|
|
404
|
+
RemoveUnderscorePipe,
|
|
405
|
+
MatSelectModule,
|
|
406
|
+
MatOptionModule,
|
|
407
|
+
MatSlideToggleModule], exports: [CheckboxSelectionInputComponent,
|
|
408
|
+
CheckboxSelectionDemoComponent] }); }
|
|
409
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionInputModule, imports: [CommonModule,
|
|
410
|
+
FormsModule,
|
|
411
|
+
ReactiveFormsModule,
|
|
412
|
+
MatSliderModule,
|
|
413
|
+
MatButtonModule,
|
|
414
|
+
MatIconModule,
|
|
415
|
+
MatFormFieldModule,
|
|
416
|
+
MatToolbarModule,
|
|
417
|
+
MatCheckboxModule,
|
|
418
|
+
MatMenuModule,
|
|
419
|
+
MatButtonToggleModule,
|
|
420
|
+
MatDividerModule,
|
|
421
|
+
MatRadioModule,
|
|
422
|
+
MatInputModule,
|
|
423
|
+
MatAutocompleteModule,
|
|
424
|
+
MatSelectModule,
|
|
425
|
+
MatOptionModule,
|
|
426
|
+
MatSlideToggleModule] }); }
|
|
427
|
+
}
|
|
428
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckboxSelectionInputModule, decorators: [{
|
|
429
|
+
type: NgModule,
|
|
430
|
+
args: [{
|
|
431
|
+
imports: [
|
|
432
|
+
CommonModule,
|
|
433
|
+
FormsModule,
|
|
434
|
+
ReactiveFormsModule,
|
|
435
|
+
MatSliderModule,
|
|
436
|
+
MatButtonModule,
|
|
437
|
+
MatIconModule,
|
|
438
|
+
MatFormFieldModule,
|
|
439
|
+
MatToolbarModule,
|
|
440
|
+
MatCheckboxModule,
|
|
441
|
+
MatMenuModule,
|
|
442
|
+
MatButtonToggleModule,
|
|
443
|
+
MatDividerModule,
|
|
444
|
+
MatRadioModule,
|
|
445
|
+
MatInputModule,
|
|
446
|
+
MatAutocompleteModule,
|
|
447
|
+
RemoveUnderscorePipe,
|
|
448
|
+
MatSelectModule,
|
|
449
|
+
MatOptionModule,
|
|
450
|
+
MatSlideToggleModule,
|
|
451
|
+
],
|
|
452
|
+
declarations: [
|
|
453
|
+
CheckboxSelectionInputComponent,
|
|
454
|
+
CheckboxSelectionDemoComponent,
|
|
455
|
+
],
|
|
456
|
+
exports: [
|
|
457
|
+
CheckboxSelectionInputComponent,
|
|
458
|
+
CheckboxSelectionDemoComponent
|
|
459
|
+
]
|
|
460
|
+
}]
|
|
461
|
+
}] });
|
|
462
|
+
|
|
463
|
+
/*
|
|
464
|
+
* Public API Surface of checkbox-selection-input
|
|
465
|
+
*/
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Generated bundle index. Do not edit.
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
export { CheckboxSelectionDemoComponent, CheckboxSelectionInputComponent, CheckboxSelectionInputModule, RemoveUnderscorePipe, SelectionBasic, SelectionItem };
|
|
472
|
+
//# sourceMappingURL=checkbox-selection-input.mjs.map
|