@progress/kendo-angular-dropdowns 5.4.0 → 5.5.0-dev.202110281138
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/dist/cdn/js/kendo-angular-dropdowns.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/localization/messages.js +4 -0
- package/dist/es/common/shared.module.js +3 -1
- package/dist/es/dropdowntrees/checked-state/base-check.directive.js +54 -0
- package/dist/es/dropdowntrees/checked-state/check-all.directive.js +181 -0
- package/dist/es/dropdowntrees/checked-state/check.directive.js +15 -36
- package/dist/es/dropdowntrees/multiselecttree.component.js +58 -13
- package/dist/es/index.js +2 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es2015/common/localization/messages.d.ts +4 -0
- package/dist/es2015/common/localization/messages.js +4 -0
- package/dist/es2015/common/shared.module.js +3 -1
- package/dist/es2015/dropdowntrees/checked-state/base-check.directive.d.ts +32 -0
- package/dist/es2015/dropdowntrees/checked-state/base-check.directive.js +48 -0
- package/dist/es2015/dropdowntrees/checked-state/check-all.directive.d.ts +53 -0
- package/dist/es2015/dropdowntrees/checked-state/check-all.directive.js +161 -0
- package/dist/es2015/dropdowntrees/checked-state/check.directive.d.ts +3 -5
- package/dist/es2015/dropdowntrees/checked-state/check.directive.js +5 -26
- package/dist/es2015/dropdowntrees/multiselecttree.component.d.ts +14 -0
- package/dist/es2015/dropdowntrees/multiselecttree.component.js +82 -15
- package/dist/es2015/index.d.ts +2 -0
- package/dist/es2015/index.js +2 -0
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/fesm2015/index.js +287 -43
- package/dist/fesm5/index.js +298 -51
- package/dist/npm/common/localization/messages.js +4 -0
- package/dist/npm/common/shared.module.js +3 -1
- package/dist/npm/dropdowntrees/checked-state/base-check.directive.js +56 -0
- package/dist/npm/dropdowntrees/checked-state/check-all.directive.js +183 -0
- package/dist/npm/dropdowntrees/checked-state/check.directive.js +14 -35
- package/dist/npm/dropdowntrees/multiselecttree.component.js +58 -13
- package/dist/npm/index.js +4 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-angular-dropdowns.js +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,10 @@ var Messages = /** @class */ (function (_super) {
|
|
|
21
21
|
Input(),
|
|
22
22
|
tslib_1.__metadata("design:type", String)
|
|
23
23
|
], Messages.prototype, "clearTitle", void 0);
|
|
24
|
+
tslib_1.__decorate([
|
|
25
|
+
Input(),
|
|
26
|
+
tslib_1.__metadata("design:type", String)
|
|
27
|
+
], Messages.prototype, "checkAllText", void 0);
|
|
24
28
|
return Messages;
|
|
25
29
|
}(ComponentMessages));
|
|
26
30
|
export { Messages };
|
|
@@ -16,6 +16,7 @@ import { ListItemDirective } from './list-item.directive';
|
|
|
16
16
|
import { SelectableDirective } from './selection/selectable.directive';
|
|
17
17
|
import { TemplateContextDirective } from './templates/template-context.directive';
|
|
18
18
|
import { CheckDirective } from '../dropdowntrees/checked-state/check.directive';
|
|
19
|
+
import { CheckAllDirective } from '../dropdowntrees/checked-state/check-all.directive';
|
|
19
20
|
var INTERNAL_DIRECTIVES = [
|
|
20
21
|
ListComponent,
|
|
21
22
|
ListItemDirective,
|
|
@@ -23,7 +24,8 @@ var INTERNAL_DIRECTIVES = [
|
|
|
23
24
|
SearchBarComponent,
|
|
24
25
|
TemplateContextDirective,
|
|
25
26
|
TagListComponent,
|
|
26
|
-
CheckDirective
|
|
27
|
+
CheckDirective,
|
|
28
|
+
CheckAllDirective
|
|
27
29
|
];
|
|
28
30
|
/**
|
|
29
31
|
* @hidden
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as tslib_1 from "tslib";
|
|
6
|
+
import { Input } from '@angular/core';
|
|
7
|
+
import { getHierarchicalItemLevel, valueFrom } from '../../common/util';
|
|
8
|
+
/**
|
|
9
|
+
* @hidden
|
|
10
|
+
*
|
|
11
|
+
* A directive which manages the in-memory checked state of the MultiSelectTree nodes.
|
|
12
|
+
*/
|
|
13
|
+
var BaseCheckDirective = /** @class */ (function () {
|
|
14
|
+
function BaseCheckDirective() {
|
|
15
|
+
}
|
|
16
|
+
BaseCheckDirective.prototype.addItem = function (item) {
|
|
17
|
+
if (this.isItemChecked(item)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var level = getHierarchicalItemLevel(item.index);
|
|
21
|
+
var candidate = tslib_1.__assign({}, item, { level: level });
|
|
22
|
+
this.checkedItems.push(candidate);
|
|
23
|
+
this.checkedKeys.add(valueFrom(candidate, this.valueField));
|
|
24
|
+
};
|
|
25
|
+
BaseCheckDirective.prototype.removeItem = function (item) {
|
|
26
|
+
var _this = this;
|
|
27
|
+
if (!this.isItemChecked(item)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var level = getHierarchicalItemLevel(item.index);
|
|
31
|
+
var candidate = tslib_1.__assign({}, item, { level: level });
|
|
32
|
+
this.checkedItems = this.checkedItems
|
|
33
|
+
.filter(function (item) { return valueFrom(item, _this.valueField) !== valueFrom(candidate, _this.valueField); });
|
|
34
|
+
this.checkedKeys.delete(valueFrom(candidate, this.valueField));
|
|
35
|
+
};
|
|
36
|
+
BaseCheckDirective.prototype.isItemChecked = function (item) {
|
|
37
|
+
return this.checkedKeys.has(valueFrom(item, this.valueField));
|
|
38
|
+
};
|
|
39
|
+
BaseCheckDirective.prototype.updateItems = function () {
|
|
40
|
+
var _this = this;
|
|
41
|
+
this.checkedItems = this.checkedItems || [];
|
|
42
|
+
this.checkedKeys = new Set(this.checkedItems.map(function (item) { return valueFrom(item, _this.valueField); }));
|
|
43
|
+
};
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
Input(),
|
|
46
|
+
tslib_1.__metadata("design:type", Object)
|
|
47
|
+
], BaseCheckDirective.prototype, "valueField", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
Input(),
|
|
50
|
+
tslib_1.__metadata("design:type", Array)
|
|
51
|
+
], BaseCheckDirective.prototype, "checkedItems", void 0);
|
|
52
|
+
return BaseCheckDirective;
|
|
53
|
+
}());
|
|
54
|
+
export { BaseCheckDirective };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as tslib_1 from "tslib";
|
|
6
|
+
import { ChangeDetectorRef, Directive, ElementRef, EventEmitter, HostListener, Input, NgZone, Output, Renderer2 } from '@angular/core';
|
|
7
|
+
import { TreeViewComponent } from '@progress/kendo-angular-treeview';
|
|
8
|
+
import { fetchDescendentNodes, isPresent } from '../../common/util';
|
|
9
|
+
import { BaseCheckDirective } from './base-check.directive';
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*
|
|
13
|
+
* A directive which manages the in-memory checked state of the MultiSelectTree nodes.
|
|
14
|
+
*/
|
|
15
|
+
var CheckAllDirective = /** @class */ (function (_super) {
|
|
16
|
+
tslib_1.__extends(CheckAllDirective, _super);
|
|
17
|
+
function CheckAllDirective(element, zone, cdr, renderer) {
|
|
18
|
+
var _this = _super.call(this) || this;
|
|
19
|
+
_this.element = element;
|
|
20
|
+
_this.zone = zone;
|
|
21
|
+
_this.cdr = cdr;
|
|
22
|
+
_this.renderer = renderer;
|
|
23
|
+
/**
|
|
24
|
+
* Fires when the `checkedItems` collection was updated.
|
|
25
|
+
*/
|
|
26
|
+
_this.checkedItemsChange = new EventEmitter();
|
|
27
|
+
/**
|
|
28
|
+
* Holds a Set with just the checked item keys.
|
|
29
|
+
*
|
|
30
|
+
* Should be updated each time the `checkedItems` value or content is changed.
|
|
31
|
+
* Can be used for efficient look-up of whether an item is checked or not (O(1) access time).
|
|
32
|
+
*/
|
|
33
|
+
_this.checkedKeys = new Set();
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
CheckAllDirective.prototype.handleChange = function (event) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
// Need to store the current checkbox state at the moment of click
|
|
39
|
+
this.currentCheckedState = event.checked;
|
|
40
|
+
this.currentIndeterminateState = this.isIndeterminate;
|
|
41
|
+
this.treeview.nodes.map(function (_value, index) {
|
|
42
|
+
var itemIndex = String(index);
|
|
43
|
+
var itemLookup = _this.treeview.itemLookup(itemIndex);
|
|
44
|
+
_this.checkNode(itemLookup);
|
|
45
|
+
});
|
|
46
|
+
this.checkedItemsChange.emit(this.checkedItems.slice());
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(CheckAllDirective.prototype, "isIndeterminate", {
|
|
49
|
+
get: function () {
|
|
50
|
+
var _this = this;
|
|
51
|
+
var isIndeterminate = this.treeview.nodes.some(function (_node, index) {
|
|
52
|
+
var itemIndex = String(index);
|
|
53
|
+
var itemLookup = _this.treeview.itemLookup(itemIndex);
|
|
54
|
+
return _this.someChecked(itemLookup);
|
|
55
|
+
});
|
|
56
|
+
return this.isChecked ? false : isIndeterminate;
|
|
57
|
+
},
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(CheckAllDirective.prototype, "isChecked", {
|
|
62
|
+
get: function () {
|
|
63
|
+
var _this = this;
|
|
64
|
+
var isChecked = this.treeview.nodes.every(function (_node, index) {
|
|
65
|
+
var itemIndex = String(index);
|
|
66
|
+
var itemLookup = _this.treeview.itemLookup(itemIndex);
|
|
67
|
+
return _this.allChecked(itemLookup);
|
|
68
|
+
});
|
|
69
|
+
return isChecked;
|
|
70
|
+
},
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true
|
|
73
|
+
});
|
|
74
|
+
CheckAllDirective.prototype.ngOnChanges = function (changes) {
|
|
75
|
+
if (isPresent(changes.checkedItems)) {
|
|
76
|
+
this.updateItems();
|
|
77
|
+
this.renderer.setProperty(this.element.nativeElement, 'checked', this.isChecked);
|
|
78
|
+
this.renderer.setProperty(this.element.nativeElement, 'indeterminate', this.isIndeterminate);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
CheckAllDirective.prototype.ngOnInit = function () {
|
|
82
|
+
var _this = this;
|
|
83
|
+
if (this.focused) {
|
|
84
|
+
this.nextTick(function () { return _this.element.nativeElement.focus(); });
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
CheckAllDirective.prototype.nextTick = function (fn) {
|
|
88
|
+
this.zone.runOutsideAngular(function () { return setTimeout(fn); });
|
|
89
|
+
};
|
|
90
|
+
CheckAllDirective.prototype.checkNode = function (itemLookup) {
|
|
91
|
+
var _this = this;
|
|
92
|
+
if (this.treeview.isDisabled(itemLookup.item.dataItem, itemLookup.item.index)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
var pendingCheck = [];
|
|
96
|
+
var filter = function (item) {
|
|
97
|
+
return _this.treeview.isVisible(item.dataItem, item.index) &&
|
|
98
|
+
!_this.treeview.isDisabled(item.dataItem, item.index);
|
|
99
|
+
};
|
|
100
|
+
pendingCheck.push(itemLookup.item);
|
|
101
|
+
fetchDescendentNodes(itemLookup, filter)
|
|
102
|
+
.forEach(function (lookup) { return pendingCheck.push(lookup.item); });
|
|
103
|
+
pendingCheck.forEach(function (item) {
|
|
104
|
+
if (_this.currentIndeterminateState) {
|
|
105
|
+
_this.lastAction === 'check' ?
|
|
106
|
+
_this.addItem(item) :
|
|
107
|
+
_this.removeItem(item);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
_this.currentCheckedState ?
|
|
111
|
+
_this.addItem(item) :
|
|
112
|
+
_this.removeItem(item);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
CheckAllDirective.prototype.allChecked = function (lookup) {
|
|
116
|
+
var _this = this;
|
|
117
|
+
var children = lookup && lookup.children;
|
|
118
|
+
if (!Array.isArray(children)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var childrenChecked = children.every(function (child) {
|
|
122
|
+
if (child.children.length) {
|
|
123
|
+
return _this.isItemChecked(child.item) && _this.allChecked(child);
|
|
124
|
+
}
|
|
125
|
+
return _this.isItemChecked(child.item);
|
|
126
|
+
});
|
|
127
|
+
return childrenChecked && this.isItemChecked(lookup.item);
|
|
128
|
+
};
|
|
129
|
+
CheckAllDirective.prototype.someChecked = function (lookup) {
|
|
130
|
+
var _this = this;
|
|
131
|
+
var children = lookup && lookup.children;
|
|
132
|
+
if (!Array.isArray(children)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var childrenChecked = children.some(function (child) {
|
|
136
|
+
if (child.children.length) {
|
|
137
|
+
return _this.isItemChecked(child.item) || _this.someChecked(child);
|
|
138
|
+
}
|
|
139
|
+
return _this.isItemChecked(child.item);
|
|
140
|
+
});
|
|
141
|
+
return childrenChecked || this.isItemChecked(lookup.item);
|
|
142
|
+
};
|
|
143
|
+
tslib_1.__decorate([
|
|
144
|
+
Input(),
|
|
145
|
+
tslib_1.__metadata("design:type", String)
|
|
146
|
+
], CheckAllDirective.prototype, "lastAction", void 0);
|
|
147
|
+
tslib_1.__decorate([
|
|
148
|
+
Input(),
|
|
149
|
+
tslib_1.__metadata("design:type", TreeViewComponent)
|
|
150
|
+
], CheckAllDirective.prototype, "treeview", void 0);
|
|
151
|
+
tslib_1.__decorate([
|
|
152
|
+
Input(),
|
|
153
|
+
tslib_1.__metadata("design:type", Array)
|
|
154
|
+
], CheckAllDirective.prototype, "checkedItems", void 0);
|
|
155
|
+
tslib_1.__decorate([
|
|
156
|
+
Input(),
|
|
157
|
+
tslib_1.__metadata("design:type", Object)
|
|
158
|
+
], CheckAllDirective.prototype, "valueField", void 0);
|
|
159
|
+
tslib_1.__decorate([
|
|
160
|
+
Input('checkAll'),
|
|
161
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
162
|
+
], CheckAllDirective.prototype, "focused", void 0);
|
|
163
|
+
tslib_1.__decorate([
|
|
164
|
+
Output(),
|
|
165
|
+
tslib_1.__metadata("design:type", EventEmitter)
|
|
166
|
+
], CheckAllDirective.prototype, "checkedItemsChange", void 0);
|
|
167
|
+
tslib_1.__decorate([
|
|
168
|
+
HostListener('change', ['$event.target']),
|
|
169
|
+
tslib_1.__metadata("design:type", Function),
|
|
170
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
171
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
172
|
+
], CheckAllDirective.prototype, "handleChange", null);
|
|
173
|
+
CheckAllDirective = tslib_1.__decorate([
|
|
174
|
+
Directive({
|
|
175
|
+
selector: '[checkAll]' // tslint:disable-line
|
|
176
|
+
}),
|
|
177
|
+
tslib_1.__metadata("design:paramtypes", [ElementRef, NgZone, ChangeDetectorRef, Renderer2])
|
|
178
|
+
], CheckAllDirective);
|
|
179
|
+
return CheckAllDirective;
|
|
180
|
+
}(BaseCheckDirective));
|
|
181
|
+
export { CheckAllDirective };
|
|
@@ -7,39 +7,41 @@ import { Directive, EventEmitter, Input, Output } from '@angular/core';
|
|
|
7
7
|
import { TreeViewComponent } from '@progress/kendo-angular-treeview';
|
|
8
8
|
import { Subscription } from 'rxjs';
|
|
9
9
|
import { filter } from 'rxjs/operators';
|
|
10
|
-
import { fetchDescendentNodes,
|
|
10
|
+
import { fetchDescendentNodes, isPresent } from '../../common/util';
|
|
11
|
+
import { BaseCheckDirective } from './base-check.directive';
|
|
11
12
|
/**
|
|
12
13
|
* @hidden
|
|
13
14
|
*
|
|
14
15
|
* A directive which manages the in-memory checked state of the MultiSelectTree nodes.
|
|
15
16
|
*/
|
|
16
|
-
var CheckDirective = /** @class */ (function () {
|
|
17
|
+
var CheckDirective = /** @class */ (function (_super) {
|
|
18
|
+
tslib_1.__extends(CheckDirective, _super);
|
|
17
19
|
function CheckDirective(treeView) {
|
|
18
|
-
|
|
20
|
+
var _this = _super.call(this) || this;
|
|
21
|
+
_this.treeView = treeView;
|
|
19
22
|
/**
|
|
20
23
|
* Fires when the `checkedItems` collection was updated.
|
|
21
24
|
*/
|
|
22
|
-
|
|
25
|
+
_this.checkedItemsChange = new EventEmitter();
|
|
23
26
|
/**
|
|
24
27
|
* Holds a Set with just the checked item keys.
|
|
25
28
|
*
|
|
26
29
|
* Should be updated each time the `checkedItems` value or content is changed.
|
|
27
30
|
* Can be used for efficient look-up of whether an item is checked or not (O(1) access time).
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.subscribe(
|
|
33
|
-
|
|
32
|
+
_this.checkedKeys = new Set();
|
|
33
|
+
_this.subscriptions = new Subscription();
|
|
34
|
+
_this.subscriptions.add(_this.treeView.checkedChange
|
|
35
|
+
.subscribe(_this.handleCheckedChange.bind(_this)));
|
|
36
|
+
_this.treeView.isChecked = _this.getCheckedState.bind(_this);
|
|
37
|
+
return _this;
|
|
34
38
|
}
|
|
35
39
|
CheckDirective.prototype.ngOnChanges = function (changes) {
|
|
36
|
-
var _this = this;
|
|
37
40
|
if (isPresent(changes.checkable)) {
|
|
38
41
|
this.toggleCheckOnClick();
|
|
39
42
|
}
|
|
40
43
|
if (isPresent(changes.checkedItems)) {
|
|
41
|
-
this.
|
|
42
|
-
this.checkedKeys = new Set(this.checkedItems.map(function (item) { return valueFrom(item, _this.valueField); }));
|
|
44
|
+
this.updateItems();
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
CheckDirective.prototype.ngOnDestroy = function () {
|
|
@@ -124,29 +126,6 @@ var CheckDirective = /** @class */ (function () {
|
|
|
124
126
|
currentParent = currentParent.parent;
|
|
125
127
|
}
|
|
126
128
|
};
|
|
127
|
-
CheckDirective.prototype.addItem = function (item) {
|
|
128
|
-
if (this.isItemChecked(item)) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
var level = getHierarchicalItemLevel(item.index);
|
|
132
|
-
var candidate = tslib_1.__assign({}, item, { level: level });
|
|
133
|
-
this.checkedItems.push(candidate);
|
|
134
|
-
this.checkedKeys.add(valueFrom(candidate, this.valueField));
|
|
135
|
-
};
|
|
136
|
-
CheckDirective.prototype.removeItem = function (item) {
|
|
137
|
-
var _this = this;
|
|
138
|
-
if (!this.isItemChecked(item)) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
var level = getHierarchicalItemLevel(item.index);
|
|
142
|
-
var candidate = tslib_1.__assign({}, item, { level: level });
|
|
143
|
-
this.checkedItems = this.checkedItems
|
|
144
|
-
.filter(function (item) { return valueFrom(item, _this.valueField) !== valueFrom(candidate, _this.valueField); });
|
|
145
|
-
this.checkedKeys.delete(valueFrom(candidate, this.valueField));
|
|
146
|
-
};
|
|
147
|
-
CheckDirective.prototype.isItemChecked = function (item) {
|
|
148
|
-
return this.checkedKeys.has(valueFrom(item, this.valueField));
|
|
149
|
-
};
|
|
150
129
|
CheckDirective.prototype.isItemIndeterminate = function (lookup) {
|
|
151
130
|
var children = lookup.children;
|
|
152
131
|
if (!Array.isArray(children) || children.length === 0) {
|
|
@@ -186,5 +165,5 @@ var CheckDirective = /** @class */ (function () {
|
|
|
186
165
|
tslib_1.__metadata("design:paramtypes", [TreeViewComponent])
|
|
187
166
|
], CheckDirective);
|
|
188
167
|
return CheckDirective;
|
|
189
|
-
}());
|
|
168
|
+
}(BaseCheckDirective));
|
|
190
169
|
export { CheckDirective };
|
|
@@ -106,6 +106,12 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
106
106
|
* @default false
|
|
107
107
|
*/
|
|
108
108
|
this.filterable = false;
|
|
109
|
+
/**
|
|
110
|
+
* If `checkАll` is set to `true` and the checkboxes are enabled, a tri-state checkbox appears above the embedded treeview.
|
|
111
|
+
* Clicking the checkbox checks or unchecks all enabled items of the treeview that are loaded.
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
this.checkAll = false;
|
|
109
115
|
/**
|
|
110
116
|
* A function which determines if a specific node has child nodes.
|
|
111
117
|
*/
|
|
@@ -209,6 +215,7 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
209
215
|
this._checkableSettings = DEFAULT_CHECKABLE_SETTINGS;
|
|
210
216
|
this._isFocused = false;
|
|
211
217
|
this.subscriptions = [];
|
|
218
|
+
this.lastAction = 'check';
|
|
212
219
|
this.onTouchedCallback = noop;
|
|
213
220
|
this.onChangeCallback = noop;
|
|
214
221
|
this.direction = localization.rtl ? 'rtl' : 'ltr';
|
|
@@ -224,7 +231,7 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
224
231
|
this._treeview = treeview;
|
|
225
232
|
if (treeview) {
|
|
226
233
|
// If filtering is enabled, focus the TreeView on mobile devices instead of the filter input
|
|
227
|
-
if (this.isFocused && !this.filterable || this.touchEnabled) {
|
|
234
|
+
if (this.isFocused && !this.filterable && !this.checkAll || this.touchEnabled) {
|
|
228
235
|
treeview.focus();
|
|
229
236
|
}
|
|
230
237
|
/**
|
|
@@ -545,6 +552,20 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
545
552
|
enumerable: true,
|
|
546
553
|
configurable: true
|
|
547
554
|
});
|
|
555
|
+
Object.defineProperty(MultiSelectTreeComponent.prototype, "isFilterActive", {
|
|
556
|
+
get: function () {
|
|
557
|
+
return this.filterInput && document.activeElement === this.filterInput.nativeElement;
|
|
558
|
+
},
|
|
559
|
+
enumerable: true,
|
|
560
|
+
configurable: true
|
|
561
|
+
});
|
|
562
|
+
Object.defineProperty(MultiSelectTreeComponent.prototype, "isCheckAllActive", {
|
|
563
|
+
get: function () {
|
|
564
|
+
return this.checkAllInput && document.activeElement === this.checkAllInput.nativeElement;
|
|
565
|
+
},
|
|
566
|
+
enumerable: true,
|
|
567
|
+
configurable: true
|
|
568
|
+
});
|
|
548
569
|
MultiSelectTreeComponent.prototype.ngOnInit = function () {
|
|
549
570
|
var _this = this;
|
|
550
571
|
this.renderer.removeAttribute(this.hostElement.nativeElement, 'tabindex');
|
|
@@ -768,6 +789,7 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
768
789
|
*/
|
|
769
790
|
MultiSelectTreeComponent.prototype.handleCheckedItemsChange = function (items) {
|
|
770
791
|
this.valueDepth = items.map(function (item) { return item.level; });
|
|
792
|
+
this.lastAction = items.length > this.dataItems.length ? 'check' : 'uncheck';
|
|
771
793
|
this.dataItems = items.slice();
|
|
772
794
|
this.updateValue(this.dataItems);
|
|
773
795
|
};
|
|
@@ -860,6 +882,13 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
860
882
|
this.filterChange.next(term);
|
|
861
883
|
this.allNodesHidden = this.nodes.every(function (node, index) { return !_this.isVisible(node, String(index)); });
|
|
862
884
|
};
|
|
885
|
+
/**
|
|
886
|
+
* @hidden
|
|
887
|
+
*/
|
|
888
|
+
MultiSelectTreeComponent.prototype.toggleCheckAll = function () {
|
|
889
|
+
this.checkAllInput.nativeElement.focus();
|
|
890
|
+
this.checkAllInput.nativeElement.click();
|
|
891
|
+
};
|
|
863
892
|
MultiSelectTreeComponent.prototype.verifySettings = function () {
|
|
864
893
|
if (!isDevMode()) {
|
|
865
894
|
return;
|
|
@@ -985,17 +1014,20 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
985
1014
|
return;
|
|
986
1015
|
}
|
|
987
1016
|
var isFirstNodeActive = this.treeview['navigationService']['activeIndex'] === '0';
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
if (isFilterActive) {
|
|
991
|
-
this.focus();
|
|
992
|
-
}
|
|
993
|
-
else if (!isFilterActive && isFirstNodeActive) {
|
|
994
|
-
this.filterInput.nativeElement.focus();
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
if (!this.filterable && isFirstNodeActive) {
|
|
1017
|
+
// Current focus is on the filter input => should focus the wrapper
|
|
1018
|
+
if (this.filterable && this.isFilterActive) {
|
|
998
1019
|
this.focus();
|
|
1020
|
+
// Current focus is on the treeview first node => should focus the check all checkbox if enabled
|
|
1021
|
+
}
|
|
1022
|
+
else if (this.checkAll && !this.isCheckAllActive && isFirstNodeActive) {
|
|
1023
|
+
this.checkAllInput.nativeElement.focus();
|
|
1024
|
+
// Current focus is either on the check all checkbox or the treeview's first node
|
|
1025
|
+
// => should focus either the filter input (if enabled) or the wrapper
|
|
1026
|
+
}
|
|
1027
|
+
else if (this.isCheckAllActive || isFirstNodeActive) {
|
|
1028
|
+
this.filterable ?
|
|
1029
|
+
this.filterInput.nativeElement.focus() :
|
|
1030
|
+
this.focus();
|
|
999
1031
|
}
|
|
1000
1032
|
};
|
|
1001
1033
|
MultiSelectTreeComponent.prototype.handleDownKey = function (event) {
|
|
@@ -1003,9 +1035,14 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
1003
1035
|
return;
|
|
1004
1036
|
}
|
|
1005
1037
|
event.originalEvent.preventDefault();
|
|
1006
|
-
//
|
|
1038
|
+
// Current focus is on the wrapper => should focus the filter input
|
|
1007
1039
|
if (this.filterable && this.isWrapperActive) {
|
|
1008
1040
|
this.filterInput.nativeElement.focus();
|
|
1041
|
+
// Current focus is on the wrapper/filter input => should focus check all checkbox if enabled
|
|
1042
|
+
}
|
|
1043
|
+
else if (this.checkAll && (this.isWrapperActive || this.isFilterActive)) {
|
|
1044
|
+
this.checkAllInput.nativeElement.focus();
|
|
1045
|
+
// Should focus the treeview if filterable and check all are disabled
|
|
1009
1046
|
}
|
|
1010
1047
|
else if (!this.treeview.isActive) {
|
|
1011
1048
|
this.treeview.focus();
|
|
@@ -1166,6 +1203,10 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
1166
1203
|
ViewChild('filterInput', { static: false }),
|
|
1167
1204
|
tslib_1.__metadata("design:type", ElementRef)
|
|
1168
1205
|
], MultiSelectTreeComponent.prototype, "filterInput", void 0);
|
|
1206
|
+
tslib_1.__decorate([
|
|
1207
|
+
ViewChild('checkAllInput', { static: false }),
|
|
1208
|
+
tslib_1.__metadata("design:type", ElementRef)
|
|
1209
|
+
], MultiSelectTreeComponent.prototype, "checkAllInput", void 0);
|
|
1169
1210
|
tslib_1.__decorate([
|
|
1170
1211
|
Input(),
|
|
1171
1212
|
tslib_1.__metadata("design:type", Number),
|
|
@@ -1248,6 +1289,10 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
1248
1289
|
Input(),
|
|
1249
1290
|
tslib_1.__metadata("design:type", Boolean)
|
|
1250
1291
|
], MultiSelectTreeComponent.prototype, "filterable", void 0);
|
|
1292
|
+
tslib_1.__decorate([
|
|
1293
|
+
Input(),
|
|
1294
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
1295
|
+
], MultiSelectTreeComponent.prototype, "checkAll", void 0);
|
|
1251
1296
|
tslib_1.__decorate([
|
|
1252
1297
|
Input(),
|
|
1253
1298
|
tslib_1.__metadata("design:type", Function)
|
|
@@ -1348,7 +1393,7 @@ var MultiSelectTreeComponent = /** @class */ (function () {
|
|
|
1348
1393
|
}
|
|
1349
1394
|
],
|
|
1350
1395
|
selector: 'kendo-multiselecttree',
|
|
1351
|
-
template: "\n <ng-container kendoMultiSelectTreeLocalizedMessages\n i18n-noDataText=\"kendo.multiselecttree.noDataText|The text displayed in the popup when there are no items\"\n noDataText=\"NO DATA FOUND\"\n\n i18n-clearTitle=\"kendo.multiselecttree.clearTitle|The title of the clear button\"\n clearTitle=\"clear\"\n >\n </ng-container>\n <div #wrapper\n [ngClass]=\"{\n 'k-multiselect-wrap': true,\n 'k-floatwrap': true,\n 'k-state-disabled': this.disabled\n }\"\n role=\"listbox\"\n aria-haspopup=\"tree\"\n [attr.aria-describedby]=\"tagListId\"\n [attr.aria-readonly]=\"readonly\"\n [attr.aria-activedescendant]=\"focusedTagId\"\n [attr.tabindex]=\"tabindex\"\n [attr.id]=\"focusableId\"\n [attr.dir]=\"direction\"\n (click)=\"handleClick()\"\n (keydown)=\"handleKeydown($event)\"\n [kendoEventsOutsideAngular]=\"{\n focus: handleFocus,\n blur: handleBlur\n }\"\n [scope]=\"this\"\n >\n <kendo-taglist\n [id]=\"tagListId\"\n [tags]=\"tags\"\n [focused]=\"focusedTagIndex\"\n [textField]=\"textField\"\n [valueField]=\"valueField\"\n [valueDepth]=\"valueDepth\"\n [disabled]=\"disabled\"\n [tagPrefix]=\"tagPrefix\"\n [template]=\"tagTemplate\"\n [groupTemplate]=\"groupTagTemplate\"\n [disabledIndices]=\"disabledIndices\"\n (removeTag)=\"handleRemoveTag($event)\"\n >\n </kendo-taglist>\n <span *ngIf=\"!tags || !tags.length\"\n class=\"k-input k-readonly\"\n >\n {{ placeholder }}\n </span>\n <span\n *ngIf=\"!disabled && !loading && !readonly && clearButton && tags?.length\"\n class=\"k-icon k-clear-value k-i-close\"\n [attr.title]=\"messageFor('clearTitle')\"\n role=\"button\"\n tabindex=\"-1\"\n (click)=\"clearAll($event)\"\n >\n </span>\n <span\n *ngIf=\"loading\"\n class=\"k-icon k-i-loading\"\n >\n </span>\n </div>\n <ng-template #popupTemplate>\n <span\n *ngIf=\"filterable\"\n class=\"k-list-filter\"\n >\n <input\n #filterInput\n (input)=\"handleFilterInputChange($event.target.value)\"\n [filterInput]=\"filterable && !touchEnabled\"\n (keydown
|
|
1396
|
+
template: "\n <ng-container kendoMultiSelectTreeLocalizedMessages\n i18n-noDataText=\"kendo.multiselecttree.noDataText|The text displayed in the popup when there are no items\"\n noDataText=\"NO DATA FOUND\"\n\n i18n-clearTitle=\"kendo.multiselecttree.clearTitle|The title of the clear button\"\n clearTitle=\"clear\"\n\n i18n-checkAllText=\"kendo.multiselecttree.checkAllText|The text displayed for the check-all checkbox\"\n checkAllText=\"Check all\"\n >\n </ng-container>\n <div #wrapper\n [ngClass]=\"{\n 'k-multiselect-wrap': true,\n 'k-floatwrap': true,\n 'k-state-disabled': this.disabled\n }\"\n role=\"listbox\"\n aria-haspopup=\"tree\"\n [attr.aria-describedby]=\"tagListId\"\n [attr.aria-readonly]=\"readonly\"\n [attr.aria-activedescendant]=\"focusedTagId\"\n [attr.tabindex]=\"tabindex\"\n [attr.id]=\"focusableId\"\n [attr.dir]=\"direction\"\n (click)=\"handleClick()\"\n (keydown)=\"handleKeydown($event)\"\n [kendoEventsOutsideAngular]=\"{\n focus: handleFocus,\n blur: handleBlur\n }\"\n [scope]=\"this\"\n >\n <kendo-taglist\n [id]=\"tagListId\"\n [tags]=\"tags\"\n [focused]=\"focusedTagIndex\"\n [textField]=\"textField\"\n [valueField]=\"valueField\"\n [valueDepth]=\"valueDepth\"\n [disabled]=\"disabled\"\n [tagPrefix]=\"tagPrefix\"\n [template]=\"tagTemplate\"\n [groupTemplate]=\"groupTagTemplate\"\n [disabledIndices]=\"disabledIndices\"\n (removeTag)=\"handleRemoveTag($event)\"\n >\n </kendo-taglist>\n <span *ngIf=\"!tags || !tags.length\"\n class=\"k-input k-readonly\"\n >\n {{ placeholder }}\n </span>\n <span\n *ngIf=\"!disabled && !loading && !readonly && clearButton && tags?.length\"\n class=\"k-icon k-clear-value k-i-close\"\n [attr.title]=\"messageFor('clearTitle')\"\n role=\"button\"\n tabindex=\"-1\"\n (click)=\"clearAll($event)\"\n >\n </span>\n <span\n *ngIf=\"loading\"\n class=\"k-icon k-i-loading\"\n >\n </span>\n </div>\n <ng-template #popupTemplate>\n <span\n *ngIf=\"filterable\"\n class=\"k-list-filter\"\n >\n <input\n #filterInput\n (input)=\"handleFilterInputChange($event.target.value)\"\n [filterInput]=\"filterable && !touchEnabled\"\n (keydown)=\"handleKeydown($event)\"\n [(ngModel)]=\"filter\"\n class=\"k-textbox\"\n role=\"textbox\"\n aria-haspopup=\"true\"\n aria-expanded=\"false\"\n tabindex=\"0\"\n aria-disabled=\"false\"\n aria-readonly=\"false\"\n [kendoEventsOutsideAngular]=\"{\n blur: handleBlur\n }\"\n [scope]=\"this\"\n >\n <span class=\"k-icon k-i-zoom\"></span>\n </span>\n <!--header template-->\n <ng-template\n *ngIf=\"headerTemplate\"\n [templateContext]=\"{\n templateRef: headerTemplate?.templateRef\n }\">\n </ng-template>\n <div *ngIf=\"checkAll\" class=\"k-check-all\">\n <input\n #checkAllInput\n [checkAll]=\"!filterable && !touchEnabled\"\n type=\"checkbox\"\n class=\"k-checkbox\"\n role=\"checkbox\"\n tabindex=\"0\"\n aria-disabled=\"false\"\n aria-readonly=\"false\"\n [treeview]=\"treeview\"\n [checkedItems]=\"checkedItems\"\n [valueField]=\"valueField\"\n [lastAction]=\"lastAction\"\n (checkedItemsChange)=\"handleCheckedItemsChange($event)\"\n (keydown)=\"handleKeydown($event)\"\n [kendoEventsOutsideAngular]=\"{\n blur: handleBlur\n }\"\n [scope]=\"this\"\n >\n <span\n class=\"k-checkbox-label\"\n (click)=\"toggleCheckAll()\"\n (mousedown)=\"$event.preventDefault()\"\n >\n {{ messageFor('checkAllText') }}\n </span>\n </div>\n <kendo-treeview\n #treeview\n [nodes]=\"data\"\n [style.maxHeight.px]=\"listHeight\"\n [animate]=\"false\"\n kendoMultiSelectTreeCheckable\n [checkable]=\"checkableSettings\"\n [checkedItems]=\"checkedItems\"\n [valueField]=\"valueField\"\n [textField]=\"textField\"\n [children]=\"children\"\n [hasChildren]=\"hasChildren\"\n [isExpanded]=\"isNodeExpanded\"\n [isDisabled]=\"itemDisabled\"\n [nodeTemplate]=\"nodeTemplate\"\n [loadOnDemand]=\"loadOnDemand\"\n [filter]=\"filter\"\n [isVisible]=\"isNodeVisible\"\n (keydown)=\"handleKeydown($event)\"\n (nodeClick)=\"handleNodeClick($event)\"\n (expand)=\"nodeExpand.emit($event)\"\n (collapse)=\"nodeCollapse.emit($event)\"\n (checkedItemsChange)=\"handleCheckedItemsChange($event)\"\n [kendoEventsOutsideAngular]=\"{\n focusout: handleBlur\n }\"\n [scope]=\"this\"\n >\n </kendo-treeview>\n <!--footer template-->\n <ng-template\n *ngIf=\"footerTemplate\"\n [templateContext]=\"{\n templateRef: footerTemplate?.templateRef\n }\">\n </ng-template>\n <!--no-data template-->\n <div class=\"k-nodata\" *ngIf=\"data?.length === 0 || allNodesHidden\">\n <ng-template [ngIf]=\"noDataTemplate\"\n [templateContext]=\"{\n templateRef: noDataTemplate?.templateRef\n }\">\n </ng-template>\n <ng-template [ngIf]=\"!noDataTemplate\">\n <div>{{ messageFor('noDataText') }}</div>\n </ng-template>\n </div>\n </ng-template>\n <ng-container #container></ng-container>\n "
|
|
1352
1397
|
}),
|
|
1353
1398
|
tslib_1.__param(7, Optional()), tslib_1.__param(7, Inject(TOUCH_ENABLED)),
|
|
1354
1399
|
tslib_1.__metadata("design:paramtypes", [PopupService,
|
package/dist/es/index.js
CHANGED
|
@@ -24,5 +24,7 @@ export { TagListComponent } from './common/taglist.component';
|
|
|
24
24
|
export { NoDataTemplateDirective } from './common/templates/no-data-template.directive';
|
|
25
25
|
export { TagTemplateDirective } from './common/templates/tag-template.directive';
|
|
26
26
|
export { DROPDOWNLIST_VALUE_ACCESSOR } from './dropdownlist/dropdownlist.component';
|
|
27
|
+
export { BaseCheckDirective } from './dropdowntrees/checked-state/base-check.directive';
|
|
28
|
+
export { CheckAllDirective } from './dropdowntrees/checked-state/check-all.directive';
|
|
27
29
|
export { CheckDirective } from './dropdowntrees/checked-state/check.directive';
|
|
28
30
|
export { MultiSelectTreeSummaryTagDirective } from './dropdowntrees/summary-tag/summary-tag.directive';
|
|
@@ -9,7 +9,7 @@ export var packageMetadata = {
|
|
|
9
9
|
name: '@progress/kendo-angular-dropdowns',
|
|
10
10
|
productName: 'Kendo UI for Angular',
|
|
11
11
|
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
12
|
-
publishDate:
|
|
12
|
+
publishDate: 1635420981,
|
|
13
13
|
version: '',
|
|
14
14
|
licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
|
|
15
15
|
};
|
|
@@ -16,6 +16,7 @@ import { ListItemDirective } from './list-item.directive';
|
|
|
16
16
|
import { SelectableDirective } from './selection/selectable.directive';
|
|
17
17
|
import { TemplateContextDirective } from './templates/template-context.directive';
|
|
18
18
|
import { CheckDirective } from '../dropdowntrees/checked-state/check.directive';
|
|
19
|
+
import { CheckAllDirective } from '../dropdowntrees/checked-state/check-all.directive';
|
|
19
20
|
const INTERNAL_DIRECTIVES = [
|
|
20
21
|
ListComponent,
|
|
21
22
|
ListItemDirective,
|
|
@@ -23,7 +24,8 @@ const INTERNAL_DIRECTIVES = [
|
|
|
23
24
|
SearchBarComponent,
|
|
24
25
|
TemplateContextDirective,
|
|
25
26
|
TagListComponent,
|
|
26
|
-
CheckDirective
|
|
27
|
+
CheckDirective,
|
|
28
|
+
CheckAllDirective
|
|
27
29
|
];
|
|
28
30
|
/**
|
|
29
31
|
* @hidden
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { TreeItem } from '@progress/kendo-angular-treeview';
|
|
6
|
+
import { CheckedItem } from './checked-item';
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*
|
|
10
|
+
* A directive which manages the in-memory checked state of the MultiSelectTree nodes.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class BaseCheckDirective {
|
|
13
|
+
/**
|
|
14
|
+
* The item key/keys by which the data items will be compared.
|
|
15
|
+
*/
|
|
16
|
+
abstract valueField: string | string[];
|
|
17
|
+
/**
|
|
18
|
+
* Defines the collection that will store the full checked items.
|
|
19
|
+
*/
|
|
20
|
+
abstract checkedItems: CheckedItem[];
|
|
21
|
+
/**
|
|
22
|
+
* Holds a Set with just the checked item keys.
|
|
23
|
+
*
|
|
24
|
+
* Should be updated each time the `checkedItems` value or content is changed.
|
|
25
|
+
* Can be used for efficient look-up of whether an item is checked or not (O(1) access time).
|
|
26
|
+
*/
|
|
27
|
+
abstract checkedKeys: Set<any>;
|
|
28
|
+
protected addItem(item: TreeItem): void;
|
|
29
|
+
protected removeItem(item: TreeItem): void;
|
|
30
|
+
protected isItemChecked(item: CheckedItem): boolean;
|
|
31
|
+
protected updateItems(): void;
|
|
32
|
+
}
|