@progress/kendo-angular-treeview 5.4.3 → 6.0.0

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 (57) hide show
  1. package/LICENSE.md +1 -1
  2. package/NOTICE.txt +119 -79
  3. package/README.md +1 -1
  4. package/dist/cdn/js/kendo-angular-treeview.js +18 -18
  5. package/dist/cdn/main.js +1 -1
  6. package/dist/es/check.directive.js +30 -39
  7. package/dist/es/checkbox/checkbox.component.js +17 -1
  8. package/dist/es/drag-and-drop/drag-and-drop-utils.js +3 -3
  9. package/dist/es/drag-and-drop/drag-and-drop.directive.js +2 -2
  10. package/dist/es/expand.directive.js +40 -41
  11. package/dist/es/package-metadata.js +1 -1
  12. package/dist/es/selection/select.directive.js +22 -28
  13. package/dist/es/size.js +4 -0
  14. package/dist/es/treeview-group.component.js +7 -2
  15. package/dist/es/treeview-item-content.directive.js +2 -2
  16. package/dist/es/treeview-item.directive.js +1 -1
  17. package/dist/es/treeview.component.js +36 -4
  18. package/dist/es/utils.js +21 -11
  19. package/dist/es2015/check.directive.d.ts +8 -1
  20. package/dist/es2015/check.directive.js +30 -35
  21. package/dist/es2015/checkbox/checkbox.component.d.ts +6 -0
  22. package/dist/es2015/checkbox/checkbox.component.js +13 -1
  23. package/dist/es2015/drag-and-drop/drag-and-drop-utils.js +3 -3
  24. package/dist/es2015/drag-and-drop/drag-and-drop.directive.js +2 -2
  25. package/dist/es2015/expand.directive.d.ts +12 -3
  26. package/dist/es2015/expand.directive.js +39 -36
  27. package/dist/es2015/index.metadata.json +1 -1
  28. package/dist/es2015/package-metadata.js +1 -1
  29. package/dist/es2015/selection/select.directive.d.ts +11 -3
  30. package/dist/es2015/selection/select.directive.js +22 -24
  31. package/dist/es2015/size.d.ts +14 -0
  32. package/dist/es2015/size.js +4 -0
  33. package/dist/es2015/treeview-group.component.d.ts +2 -0
  34. package/dist/es2015/treeview-group.component.js +49 -35
  35. package/dist/es2015/treeview-item-content.directive.js +2 -2
  36. package/dist/es2015/treeview-item.directive.js +1 -1
  37. package/dist/es2015/treeview.component.d.ts +13 -0
  38. package/dist/es2015/treeview.component.js +46 -13
  39. package/dist/es2015/utils.d.ts +9 -4
  40. package/dist/es2015/utils.js +21 -11
  41. package/dist/fesm2015/index.js +224 -163
  42. package/dist/fesm5/index.js +177 -134
  43. package/dist/npm/check.directive.js +30 -39
  44. package/dist/npm/checkbox/checkbox.component.js +17 -1
  45. package/dist/npm/drag-and-drop/drag-and-drop-utils.js +3 -3
  46. package/dist/npm/drag-and-drop/drag-and-drop.directive.js +2 -2
  47. package/dist/npm/expand.directive.js +40 -41
  48. package/dist/npm/package-metadata.js +1 -1
  49. package/dist/npm/selection/select.directive.js +22 -28
  50. package/dist/npm/size.js +6 -0
  51. package/dist/npm/treeview-group.component.js +7 -2
  52. package/dist/npm/treeview-item-content.directive.js +2 -2
  53. package/dist/npm/treeview-item.directive.js +1 -1
  54. package/dist/npm/treeview.component.js +35 -3
  55. package/dist/npm/utils.js +21 -11
  56. package/dist/systemjs/kendo-angular-treeview.js +1 -1
  57. package/package.json +9 -8
@@ -8,6 +8,7 @@ import { TreeViewComponent } from './treeview.component';
8
8
  import { fetchLoadedDescendants, isBoolean, isPresent, noop } from './utils';
9
9
  import { Subscription } from 'rxjs';
10
10
  import { filter, take, switchMap, tap } from 'rxjs/operators';
11
+ import { isChanged } from '@progress/kendo-angular-common';
11
12
  var indexChecked = function (keys, index) { return keys.filter(function (k) { return k === index; }).length > 0; };
12
13
  var ɵ0 = indexChecked;
13
14
  var matchKey = function (index) { return function (k) {
@@ -46,7 +47,10 @@ var CheckDirective = /** @class */ (function () {
46
47
  'multiple': function (e) { return _this.checkMultiple(e); },
47
48
  'single': function (e) { return _this.checkSingle(e); }
48
49
  };
49
- this._checkedKeys = [];
50
+ /**
51
+ * Reflectes the internal `checkedKeys` state.
52
+ */
53
+ this.state = new Set();
50
54
  this.subscriptions.add(this.treeView.checkedChange
51
55
  .subscribe(function (e) { return _this.check(e); }));
52
56
  var expandedItems = [];
@@ -65,20 +69,6 @@ var CheckDirective = /** @class */ (function () {
65
69
  enumerable: true,
66
70
  configurable: true
67
71
  });
68
- Object.defineProperty(CheckDirective.prototype, "checkedKeys", {
69
- /**
70
- * Defines the collection that will store the checked keys
71
- * ([see example]({% slug checkboxes_treeview %})).
72
- */
73
- get: function () {
74
- return this._checkedKeys;
75
- },
76
- set: function (keys) {
77
- this._checkedKeys = keys;
78
- },
79
- enumerable: true,
80
- configurable: true
81
- });
82
72
  Object.defineProperty(CheckDirective.prototype, "options", {
83
73
  get: function () {
84
74
  var defaultOptions = {
@@ -103,6 +93,9 @@ var CheckDirective = /** @class */ (function () {
103
93
  this.treeView.checkboxes = this.options.enabled;
104
94
  this.toggleCheckOnClick();
105
95
  }
96
+ if (isChanged('checkedKeys', changes, false) && changes.checkedKeys.currentValue !== this.lastChange) {
97
+ this.state = new Set(changes.checkedKeys.currentValue);
98
+ }
106
99
  };
107
100
  CheckDirective.prototype.ngOnDestroy = function () {
108
101
  this.subscriptions.unsubscribe();
@@ -112,11 +105,11 @@ var CheckDirective = /** @class */ (function () {
112
105
  if (!this.checkKey) {
113
106
  return this.isIndexChecked(index);
114
107
  }
115
- var keyIndex = this.checkedKeys.indexOf(this.itemKey({ dataItem: dataItem, index: index }));
116
- return keyIndex > -1 ? 'checked' : 'none';
108
+ var hasKey = this.state.has(this.itemKey({ dataItem: dataItem, index: index }));
109
+ return hasKey ? 'checked' : 'none';
117
110
  };
118
111
  CheckDirective.prototype.isIndexChecked = function (index) {
119
- var checkedKeys = this.checkedKeys.filter(matchKey(index));
112
+ var checkedKeys = Array.from(this.state).filter(matchKey(index));
120
113
  if (indexChecked(checkedKeys, index)) {
121
114
  return 'checked';
122
115
  }
@@ -147,7 +140,11 @@ var CheckDirective = /** @class */ (function () {
147
140
  };
148
141
  CheckDirective.prototype.checkSingle = function (node) {
149
142
  var key = this.itemKey(node.item);
150
- this.checkedKeys = this.checkedKeys[0] !== key ? [key] : [];
143
+ var hasKey = this.state.has(key);
144
+ this.state.clear();
145
+ if (!hasKey) {
146
+ this.state.add(key);
147
+ }
151
148
  this.notify();
152
149
  };
153
150
  CheckDirective.prototype.checkMultiple = function (node) {
@@ -184,7 +181,6 @@ var CheckDirective = /** @class */ (function () {
184
181
  if (!isPresent(currentKey)) {
185
182
  return;
186
183
  }
187
- var checkedKeys = new Set(this.checkedKeys);
188
184
  var pendingCheck = [currentKey];
189
185
  if (this.options.checkChildren) {
190
186
  var descendants = fetchLoadedDescendants(node, function (_a) {
@@ -198,63 +194,59 @@ var CheckDirective = /** @class */ (function () {
198
194
  });
199
195
  pendingCheck.push.apply(pendingCheck, descendants);
200
196
  }
201
- var shouldCheck = !checkedKeys.has(currentKey);
197
+ var shouldCheck = !this.state.has(currentKey);
202
198
  pendingCheck.forEach(function (key) {
203
199
  if (shouldCheck) {
204
- checkedKeys.add(key);
200
+ _this.state.add(key);
205
201
  }
206
202
  else {
207
- checkedKeys.delete(key);
203
+ _this.state.delete(key);
208
204
  }
209
205
  });
210
- this.checkedKeys = Array.from(checkedKeys);
211
206
  };
212
207
  CheckDirective.prototype.checkParents = function (parent) {
213
208
  var _this = this;
214
209
  if (!isPresent(parent)) {
215
210
  return;
216
211
  }
217
- var checkedKeys = new Set(this.checkedKeys);
218
212
  var currentParent = parent;
219
213
  while (currentParent) {
220
214
  var parentKey = this.itemKey(currentParent.item);
221
- var allChildrenSelected = currentParent.children.every(function (item) { return checkedKeys.has(_this.itemKey(item)); });
215
+ var allChildrenSelected = currentParent.children.every(function (item) { return _this.state.has(_this.itemKey(item)); });
222
216
  if (allChildrenSelected) {
223
- checkedKeys.add(parentKey);
217
+ this.state.add(parentKey);
224
218
  }
225
219
  else {
226
- checkedKeys.delete(parentKey);
220
+ this.state.delete(parentKey);
227
221
  }
228
222
  currentParent = currentParent.parent;
229
223
  }
230
- this.checkedKeys = Array.from(checkedKeys);
231
224
  };
232
225
  CheckDirective.prototype.notify = function () {
233
- this.checkedKeysChange.emit(this.checkedKeys.slice());
226
+ this.lastChange = Array.from(this.state);
227
+ this.checkedKeysChange.emit(this.lastChange);
234
228
  };
235
229
  CheckDirective.prototype.addCheckedItemsChildren = function (lookups) {
236
230
  var _this = this;
237
231
  if (!isPresent(lookups) || lookups.length === 0) {
238
232
  return;
239
233
  }
240
- var initiallyCheckedItemsCount = this.checkedKeys.length;
241
- var checkedKeys = new Set(this.checkedKeys);
234
+ var initiallyCheckedItemsCount = this.state.size;
242
235
  lookups.forEach(function (lookup) {
243
236
  var itemKey = _this.itemKey(lookup.item);
244
- if (!checkedKeys.has(itemKey)) {
237
+ if (!_this.state.has(itemKey)) {
245
238
  return;
246
239
  }
247
240
  lookup.children.forEach(function (item) {
248
241
  // ensure both the parent item and each child node is enabled
249
242
  if (!_this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
250
243
  !_this.treeView.isDisabled(item.dataItem, item.index)) {
251
- checkedKeys.add(_this.itemKey(item));
244
+ _this.state.add(_this.itemKey(item));
252
245
  }
253
246
  });
254
247
  });
255
- var hasNewlyCheckedItems = initiallyCheckedItemsCount !== checkedKeys.size;
248
+ var hasNewlyCheckedItems = initiallyCheckedItemsCount !== this.state.size;
256
249
  if (hasNewlyCheckedItems) {
257
- this.checkedKeys = Array.from(checkedKeys);
258
250
  this.zone.run(function () { return _this.notify(); });
259
251
  }
260
252
  };
@@ -269,9 +261,8 @@ var CheckDirective = /** @class */ (function () {
269
261
  ], CheckDirective.prototype, "checkKey", void 0);
270
262
  tslib_1.__decorate([
271
263
  Input(),
272
- tslib_1.__metadata("design:type", Array),
273
- tslib_1.__metadata("design:paramtypes", [Array])
274
- ], CheckDirective.prototype, "checkedKeys", null);
264
+ tslib_1.__metadata("design:type", Array)
265
+ ], CheckDirective.prototype, "checkedKeys", void 0);
275
266
  tslib_1.__decorate([
276
267
  Input('kendoTreeViewCheckable'),
277
268
  tslib_1.__metadata("design:type", Object)
@@ -5,6 +5,7 @@
5
5
  import * as tslib_1 from "tslib";
6
6
  import { ChangeDetectorRef, Component, ElementRef, EventEmitter, HostBinding, Input, Output, Renderer2 } from '@angular/core';
7
7
  import { guid } from '@progress/kendo-angular-common';
8
+ import { getSizeClass } from '../utils';
8
9
  /**
9
10
  * @hidden
10
11
  *
@@ -24,6 +25,10 @@ var CheckBoxComponent = /** @class */ (function () {
24
25
  * Specifies the [`tabindex`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of the component.
25
26
  */
26
27
  this.tabindex = 0;
28
+ /**
29
+ * Specifies the size of the component.
30
+ */
31
+ this.size = 'medium';
27
32
  /**
28
33
  * Fires when the user changes the check state of the component.
29
34
  */
@@ -51,6 +56,13 @@ var CheckBoxComponent = /** @class */ (function () {
51
56
  enumerable: true,
52
57
  configurable: true
53
58
  });
59
+ Object.defineProperty(CheckBoxComponent.prototype, "checkBoxClasses", {
60
+ get: function () {
61
+ return "k-checkbox " + (this.size ? getSizeClass('checkbox', this.size) : '') + " k-rounded-md";
62
+ },
63
+ enumerable: true,
64
+ configurable: true
65
+ });
54
66
  CheckBoxComponent.prototype.ngOnInit = function () {
55
67
  this.renderer.removeAttribute(this.element.nativeElement, "tabindex");
56
68
  };
@@ -93,6 +105,10 @@ var CheckBoxComponent = /** @class */ (function () {
93
105
  Input(),
94
106
  tslib_1.__metadata("design:type", Number)
95
107
  ], CheckBoxComponent.prototype, "tabindex", void 0);
108
+ tslib_1.__decorate([
109
+ Input(),
110
+ tslib_1.__metadata("design:type", String)
111
+ ], CheckBoxComponent.prototype, "size", void 0);
96
112
  tslib_1.__decorate([
97
113
  Output(),
98
114
  tslib_1.__metadata("design:type", EventEmitter)
@@ -100,7 +116,7 @@ var CheckBoxComponent = /** @class */ (function () {
100
116
  CheckBoxComponent = tslib_1.__decorate([
101
117
  Component({
102
118
  selector: 'kendo-checkbox',
103
- template: "\n <input\n class=\"k-checkbox\"\n type=\"checkbox\"\n [id]=\"id\"\n [checked]=\"checked\"\n [indeterminate]=\"indeterminate\"\n [tabindex]=\"tabindex\"\n (change)=\"handleChange($event)\"\n />\n <label\n class=\"k-checkbox-label\"\n tabindex=\"-1\"\n [for]=\"id\"\n >{{labelText}}</label>\n "
119
+ template: "\n <input\n type=\"checkbox\"\n [class]=\"checkBoxClasses\"\n [id]=\"id\"\n [checked]=\"checked\"\n [indeterminate]=\"indeterminate\"\n [tabindex]=\"tabindex\"\n (change)=\"handleChange($event)\"\n />\n <label\n class=\"k-checkbox-label\"\n tabindex=\"-1\"\n [for]=\"id\"\n >{{labelText}}</label>\n "
104
120
  }),
105
121
  tslib_1.__metadata("design:paramtypes", [ElementRef,
106
122
  Renderer2,
@@ -96,12 +96,12 @@ export var getDropPosition = function (draggedItem, target, clientY, targetTreeV
96
96
  if (!(isPresent(draggedItem) && isPresent(target) && isPresent(targetTreeView) && isPresent(containerOffset))) {
97
97
  return;
98
98
  }
99
- // the .k-mid element starts just after the checkbox/expand arrow and stretches till the end of the treeview on the right
100
- var item = closestWithMatch(target, '.k-mid');
99
+ // the .k-treeview-mid element starts just after the checkbox/expand arrow and stretches till the end of the treeview on the right
100
+ var item = closestWithMatch(target, '.k-treeview-mid');
101
101
  if (!isPresent(item)) {
102
102
  return;
103
103
  }
104
- // the content element (.k-in:not(.k-treeview-load-more-button)) holds just the treeview item text
104
+ // the content element (.k-treeview-leaf:not(.k-treeview-load-more-button)) holds just the treeview item text
105
105
  var content = getContentElement(item);
106
106
  var targetChildOfDraggedItem = hasParent(item, closestNode(draggedItem));
107
107
  if (!isPresent(content) || (content === draggedItem) || targetChildOfDraggedItem) {
@@ -107,7 +107,7 @@ var DragAndDropDirective = /** @class */ (function () {
107
107
  return;
108
108
  }
109
109
  // store the drag target on press, show it only when it's actually dragged
110
- this.draggedItem = closestWithMatch(originalEvent.target, '.k-in');
110
+ this.draggedItem = closestWithMatch(originalEvent.target, '.k-treeview-leaf');
111
111
  // record the current pointer down coords - copared to the `startDragAfter` value to calculate whether to initiate dragging
112
112
  this.pendingDragStartEvent = originalEvent;
113
113
  };
@@ -129,7 +129,7 @@ var DragAndDropDirective = /** @class */ (function () {
129
129
  }
130
130
  var targetTreeView = this.getTargetTreeView(dropTarget);
131
131
  var dropPosition = getDropPosition(this.draggedItem, dropTarget, clientY, targetTreeView, this.containerOffset);
132
- var dropHintAnchor = closestWithMatch(dropTarget, '.k-mid');
132
+ var dropHintAnchor = closestWithMatch(dropTarget, '.k-treeview-mid');
133
133
  var dropAction = getDropAction(dropPosition, dropTarget);
134
134
  var sourceItem = treeItemFromEventTarget(this.treeview, this.draggedItem);
135
135
  var destinationItem = treeItemFromEventTarget(targetTreeView, dropTarget);
@@ -8,6 +8,7 @@ import { ExpandableComponent } from './expandable-component';
8
8
  import { Subscription, merge } from 'rxjs';
9
9
  import { map } from 'rxjs/operators';
10
10
  import { isArrayWithAtLeastOneItem, isBoolean, sameValues } from './utils';
11
+ import { isChanged } from '@progress/kendo-angular-common';
11
12
  var DEFAULT_FILTER_EXPAND_SETTINGS = {
12
13
  maxAutoExpandResults: -1,
13
14
  expandMatches: false,
@@ -32,8 +33,11 @@ var ExpandDirective = /** @class */ (function () {
32
33
  */
33
34
  this.expandedKeysChange = new EventEmitter();
34
35
  this.subscriptions = new Subscription();
35
- this._expandedKeys = [];
36
- this.originalExpandedKeys = [];
36
+ /**
37
+ * Reflectes the internal `expandedKeys` state.
38
+ */
39
+ this.state = new Set();
40
+ this.originalExpandedKeys = new Set();
37
41
  this.isFiltered = false;
38
42
  /**
39
43
  * Fills array with the correct expand keys according to wrapper metadata.
@@ -66,7 +70,7 @@ var ExpandDirective = /** @class */ (function () {
66
70
  this.subscriptions.add(this.component.filterStateChange.subscribe(this.handleAutoExpand.bind(this)));
67
71
  }
68
72
  this.component.isExpanded = function (dataItem, index) {
69
- return _this.expandedKeys.indexOf(_this.itemKey({ dataItem: dataItem, index: index })) > -1;
73
+ return _this.state.has(_this.itemKey({ dataItem: dataItem, index: index }));
70
74
  };
71
75
  }
72
76
  Object.defineProperty(ExpandDirective.prototype, "isExpanded", {
@@ -87,19 +91,11 @@ var ExpandDirective = /** @class */ (function () {
87
91
  enumerable: true,
88
92
  configurable: true
89
93
  });
90
- Object.defineProperty(ExpandDirective.prototype, "expandedKeys", {
91
- /**
92
- * Defines the collection that will store the expanded keys.
93
- */
94
- get: function () {
95
- return this._expandedKeys;
96
- },
97
- set: function (keys) {
98
- this._expandedKeys = keys;
99
- },
100
- enumerable: true,
101
- configurable: true
102
- });
94
+ ExpandDirective.prototype.ngOnChanges = function (changes) {
95
+ if (isChanged('expandedKeys', changes, false) && changes.expandedKeys.currentValue !== this.lastChange) {
96
+ this.state = new Set(changes.expandedKeys.currentValue);
97
+ }
98
+ };
103
99
  ExpandDirective.prototype.ngOnDestroy = function () {
104
100
  this.subscriptions.unsubscribe();
105
101
  };
@@ -119,19 +115,19 @@ var ExpandDirective = /** @class */ (function () {
119
115
  };
120
116
  ExpandDirective.prototype.toggleExpand = function (_a) {
121
117
  var index = _a.index, dataItem = _a.dataItem, expand = _a.expand;
122
- var item = this.itemKey({ index: index, dataItem: dataItem });
123
- var idx = this.expandedKeys.indexOf(item);
118
+ var key = this.itemKey({ index: index, dataItem: dataItem });
119
+ var isExpanded = this.state.has(key);
124
120
  var notify = false;
125
- if (idx > -1 && !expand) {
126
- this.expandedKeys.splice(idx, 1);
121
+ if (isExpanded && !expand) {
122
+ this.state.delete(key);
127
123
  notify = true;
128
124
  }
129
- else if (idx === -1 && expand) {
130
- this.expandedKeys.push(item);
125
+ else if (!isExpanded && expand) {
126
+ this.state.add(key);
131
127
  notify = true;
132
128
  }
133
129
  if (notify) {
134
- this.expandedKeysChange.emit(this.expandedKeys);
130
+ this.notify();
135
131
  }
136
132
  };
137
133
  ExpandDirective.prototype.handleAutoExpand = function (_a) {
@@ -142,7 +138,7 @@ var ExpandDirective = /** @class */ (function () {
142
138
  }
143
139
  var _b = this.filterExpandSettings, maxAutoExpandResults = _b.maxAutoExpandResults, autoExpandMatches = _b.expandMatches, expandedOnClear = _b.expandedOnClear;
144
140
  if (!this.isFiltered) {
145
- this.originalExpandedKeys = this.expandedKeys.slice();
141
+ this.originalExpandedKeys = new Set(this.state);
146
142
  }
147
143
  var exitingFilteredState = this.isFiltered && !term;
148
144
  var maxExceeded = maxAutoExpandResults !== -1 && matchCount > maxAutoExpandResults;
@@ -150,18 +146,18 @@ var ExpandDirective = /** @class */ (function () {
150
146
  if (exitAutoExpandedState) {
151
147
  switch (expandedOnClear) {
152
148
  case "initial": {
153
- if (!sameValues(this.expandedKeys, this.originalExpandedKeys)) {
154
- this.expandedKeys = this.originalExpandedKeys;
155
- this.expandedKeysChange.emit(this.expandedKeys);
149
+ if (!sameValues(this.state, this.originalExpandedKeys)) {
150
+ this.state = this.originalExpandedKeys;
151
+ this.notify();
156
152
  }
157
153
  break;
158
154
  }
159
155
  case "all": {
160
- this.expandedKeys = nodes.reduce(function (acc, rootNode) {
156
+ this.state = new Set(nodes.reduce(function (acc, rootNode) {
161
157
  _this.getEveryExpandKey(acc, rootNode);
162
158
  return acc;
163
- }, []);
164
- this.expandedKeysChange.emit(this.expandedKeys);
159
+ }, []));
160
+ this.notify();
165
161
  break;
166
162
  }
167
163
  case "unchanged": {
@@ -169,9 +165,9 @@ var ExpandDirective = /** @class */ (function () {
169
165
  }
170
166
  case "none":
171
167
  default: {
172
- if (this.expandedKeys.length !== 0) {
173
- this.expandedKeys = [];
174
- this.expandedKeysChange.emit(this.expandedKeys);
168
+ if (this.state.size !== 0) {
169
+ this.state.clear();
170
+ this.notify();
175
171
  }
176
172
  break;
177
173
  }
@@ -179,16 +175,20 @@ var ExpandDirective = /** @class */ (function () {
179
175
  this.isFiltered = false;
180
176
  return;
181
177
  }
182
- var indicesToExpand = nodes.reduce(function (acc, rootNode) {
178
+ var indicesToExpand = new Set(nodes.reduce(function (acc, rootNode) {
183
179
  _this.updateExpandedNodes(acc, rootNode, autoExpandMatches);
184
180
  return acc;
185
- }, []);
186
- if (!sameValues(this.expandedKeys, indicesToExpand)) {
187
- this.expandedKeys = indicesToExpand;
188
- this.expandedKeysChange.emit(this.expandedKeys);
181
+ }, []));
182
+ if (!sameValues(this.state, indicesToExpand)) {
183
+ this.state = indicesToExpand;
184
+ this.notify();
189
185
  }
190
186
  this.isFiltered = true;
191
187
  };
188
+ ExpandDirective.prototype.notify = function () {
189
+ this.lastChange = Array.from(this.state);
190
+ this.expandedKeysChange.emit(this.lastChange);
191
+ };
192
192
  tslib_1.__decorate([
193
193
  Input(),
194
194
  tslib_1.__metadata("design:type", Function),
@@ -208,9 +208,8 @@ var ExpandDirective = /** @class */ (function () {
208
208
  ], ExpandDirective.prototype, "expandedKeysChange", void 0);
209
209
  tslib_1.__decorate([
210
210
  Input(),
211
- tslib_1.__metadata("design:type", Array),
212
- tslib_1.__metadata("design:paramtypes", [Array])
213
- ], ExpandDirective.prototype, "expandedKeys", null);
211
+ tslib_1.__metadata("design:type", Array)
212
+ ], ExpandDirective.prototype, "expandedKeys", void 0);
214
213
  ExpandDirective = tslib_1.__decorate([
215
214
  Directive({ selector: '[kendoTreeViewExpandable]' }),
216
215
  tslib_1.__metadata("design:paramtypes", [ExpandableComponent])
@@ -9,7 +9,7 @@ export var packageMetadata = {
9
9
  name: '@progress/kendo-angular-treeview',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1638439762,
12
+ publishDate: 1642578286,
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
  };
@@ -7,6 +7,7 @@ import { Directive, EventEmitter, HostBinding, Input, Output } from '@angular/co
7
7
  import { TreeViewComponent } from '../treeview.component';
8
8
  import { isBoolean, isPresent, noop } from '../utils';
9
9
  import { Subscription } from 'rxjs';
10
+ import { isChanged } from '@progress/kendo-angular-common';
10
11
  /**
11
12
  * A directive which manages the in-memory selection state of the TreeView node
12
13
  * ([see example]({% slug selection_treeview %})).
@@ -24,9 +25,12 @@ var SelectDirective = /** @class */ (function () {
24
25
  'multiple': function (e) { return _this.selectMultiple(e); },
25
26
  'single': function (e) { return _this.selectSingle(e); }
26
27
  };
27
- this._selectedKeys = [];
28
+ /**
29
+ * Reflectes the internal `selectedKeys` state.
30
+ */
31
+ this.state = new Set();
28
32
  this.subscriptions.add(this.treeView.selectionChange.subscribe(this.select.bind(this)));
29
- this.treeView.isSelected = function (dataItem, index) { return (_this.selectedKeys.indexOf(_this.itemKey({ dataItem: dataItem, index: index })) > -1); };
33
+ this.treeView.isSelected = function (dataItem, index) { return (_this.state.has(_this.itemKey({ dataItem: dataItem, index: index }))); };
30
34
  }
31
35
  Object.defineProperty(SelectDirective.prototype, "isSelected", {
32
36
  /**
@@ -38,20 +42,6 @@ var SelectDirective = /** @class */ (function () {
38
42
  enumerable: true,
39
43
  configurable: true
40
44
  });
41
- Object.defineProperty(SelectDirective.prototype, "selectedKeys", {
42
- /**
43
- * Defines the collection that will store the selected keys
44
- * ([see example]({% slug selection_treeview %}#toc-selection-modes)).
45
- */
46
- get: function () {
47
- return this._selectedKeys;
48
- },
49
- set: function (keys) {
50
- this._selectedKeys = keys;
51
- },
52
- enumerable: true,
53
- configurable: true
54
- });
55
45
  Object.defineProperty(SelectDirective.prototype, "getAriaMultiselectable", {
56
46
  get: function () {
57
47
  return this.options.mode === 'multiple';
@@ -74,6 +64,11 @@ var SelectDirective = /** @class */ (function () {
74
64
  enumerable: true,
75
65
  configurable: true
76
66
  });
67
+ SelectDirective.prototype.ngOnChanges = function (changes) {
68
+ if (isChanged('selectedKeys', changes, false) && changes.selectedKeys.currentValue !== this.lastChange) {
69
+ this.state = new Set(changes.selectedKeys.currentValue);
70
+ }
71
+ };
77
72
  SelectDirective.prototype.ngOnDestroy = function () {
78
73
  this.subscriptions.unsubscribe();
79
74
  };
@@ -98,29 +93,29 @@ var SelectDirective = /** @class */ (function () {
98
93
  };
99
94
  SelectDirective.prototype.selectSingle = function (node) {
100
95
  var key = this.itemKey(node);
101
- if (this.selectedKeys[0] === key) {
102
- return;
96
+ if (!this.state.has(key)) {
97
+ this.state.clear();
98
+ this.state.add(key);
99
+ this.notify();
103
100
  }
104
- this.selectedKeys = [key];
105
- this.notify();
106
101
  };
107
102
  SelectDirective.prototype.selectMultiple = function (node) {
108
103
  var key = this.itemKey(node);
109
- var idx = this.selectedKeys.indexOf(key);
110
- var isSelected = idx > -1;
104
+ var isSelected = this.state.has(key);
111
105
  if (!isPresent(key)) {
112
106
  return;
113
107
  }
114
108
  if (isSelected) {
115
- this.selectedKeys.splice(idx, 1);
109
+ this.state.delete(key);
116
110
  }
117
111
  else {
118
- this.selectedKeys.push(key);
112
+ this.state.add(key);
119
113
  }
120
114
  this.notify();
121
115
  };
122
116
  SelectDirective.prototype.notify = function () {
123
- this.selectedKeysChange.emit(this.selectedKeys.slice());
117
+ this.lastChange = Array.from(this.state);
118
+ this.selectedKeysChange.emit(this.lastChange);
124
119
  };
125
120
  tslib_1.__decorate([
126
121
  Input(),
@@ -137,9 +132,8 @@ var SelectDirective = /** @class */ (function () {
137
132
  ], SelectDirective.prototype, "selection", void 0);
138
133
  tslib_1.__decorate([
139
134
  Input(),
140
- tslib_1.__metadata("design:type", Array),
141
- tslib_1.__metadata("design:paramtypes", [Array])
142
- ], SelectDirective.prototype, "selectedKeys", null);
135
+ tslib_1.__metadata("design:type", Array)
136
+ ], SelectDirective.prototype, "selectedKeys", void 0);
143
137
  tslib_1.__decorate([
144
138
  Output(),
145
139
  tslib_1.__metadata("design:type", EventEmitter)
@@ -0,0 +1,4 @@
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
+ *-------------------------------------------------------------------------------------------*/
@@ -33,6 +33,7 @@ var TreeViewGroupComponent = /** @class */ (function () {
33
33
  this.role = 'group';
34
34
  this.loadOnDemand = true;
35
35
  this.textField = "";
36
+ this.size = 'medium';
36
37
  this.initialNodesLoaded = false;
37
38
  this.loadingMoreNodes = false;
38
39
  this._data = [];
@@ -266,7 +267,7 @@ var TreeViewGroupComponent = /** @class */ (function () {
266
267
  this.emitChildrenLoaded(mappedChildren);
267
268
  };
268
269
  tslib_1.__decorate([
269
- HostBinding("class.k-group"),
270
+ HostBinding("class.k-treeview-group"),
270
271
  tslib_1.__metadata("design:type", Boolean)
271
272
  ], TreeViewGroupComponent.prototype, "kGroupClass", void 0);
272
273
  tslib_1.__decorate([
@@ -329,6 +330,10 @@ var TreeViewGroupComponent = /** @class */ (function () {
329
330
  Input(),
330
331
  tslib_1.__metadata("design:type", Object)
331
332
  ], TreeViewGroupComponent.prototype, "loadMoreService", void 0);
333
+ tslib_1.__decorate([
334
+ Input(),
335
+ tslib_1.__metadata("design:type", String)
336
+ ], TreeViewGroupComponent.prototype, "size", void 0);
332
337
  tslib_1.__decorate([
333
338
  Input(),
334
339
  tslib_1.__metadata("design:type", Function)
@@ -372,7 +377,7 @@ var TreeViewGroupComponent = /** @class */ (function () {
372
377
  ])
373
378
  ],
374
379
  selector: '[kendoTreeViewGroup]',
375
- template: "\n <li\n *ngFor=\"let node of data; let index = index; trackBy: trackBy\"\n class=\"k-item k-treeview-item\"\n [class.k-display-none]=\"!isVisible(node, nodeIndex(index))\"\n kendoTreeViewItem\n [attr.aria-setsize]=\"totalNodesCount\"\n [dataItem]=\"node\"\n [index]=\"nodeIndex(index)\"\n [parentDataItem]=\"parentDataItem\"\n [parentIndex]=\"parentIndex\"\n [loadOnDemand]=\"loadOnDemand\"\n [checkable]=\"checkboxes\"\n [isChecked]=\"isChecked(node, nodeIndex(index))\"\n [isDisabled]=\"disabled || isDisabled(node, nodeIndex(index))\"\n [isVisible]=\"isVisible(node, nodeIndex(index))\"\n [expandable]=\"expandIcons && hasChildren(node)\"\n [isExpanded]=\"isExpanded(node, nodeIndex(index))\"\n [selectable]=\"selectable\"\n [isSelected]=\"isSelected(node, nodeIndex(index))\"\n [attr.data-treeindex]=\"nodeIndex(index)\"\n >\n <div class=\"k-mid\">\n <span\n class=\"k-icon\"\n [class.k-i-collapse]=\"isExpanded(node, nodeIndex(index))\"\n [class.k-i-expand]=\"!isExpanded(node, nodeIndex(index))\"\n [kendoTreeViewLoading]=\"nodeIndex(index)\"\n (click)=\"expandNode(nodeIndex(index), node, !isExpanded(node, nodeIndex(index)))\"\n *ngIf=\"expandIcons && hasChildren(node)\"\n >\n </span>\n <kendo-checkbox\n *ngIf=\"checkboxes\"\n [node]=\"node\"\n [index]=\"nodeIndex(index)\"\n [isChecked]=\"isChecked\"\n (checkStateChange)=\"checkNode(nodeIndex(index))\"\n tabindex=\"-1\"\n ></kendo-checkbox>\n <span kendoTreeViewItemContent\n [attr.data-treeindex]=\"nodeIndex(index)\"\n [dataItem]=\"node\"\n [index]=\"nodeIndex(index)\"\n [initialSelection]=\"isSelected(node, nodeIndex(index))\"\n [isSelected]=\"isSelected\"\n class=\"k-in\"\n [style.touch-action]=\"touchActions ? '' : 'none'\"\n >\n <ng-container [ngSwitch]=\"hasTemplate\">\n <ng-container *ngSwitchCase=\"true\">\n <ng-template\n [ngTemplateOutlet]=\"nodeTemplateRef\"\n [ngTemplateOutletContext]=\"{\n $implicit: node,\n index: nodeIndex(index)\n }\"\n >\n </ng-template>\n </ng-container>\n <ng-container *ngSwitchDefault>\n {{nodeText(node)}}\n </ng-container>\n </ng-container>\n </span>\n </div>\n <ul\n *ngIf=\"isExpanded(node, nodeIndex(index)) && hasChildren(node)\"\n kendoTreeViewGroup\n role=\"group\"\n [nodes]=\"fetchChildren\"\n [loadOnDemand]=\"loadOnDemand\"\n [checkboxes]=\"checkboxes\"\n [expandIcons]=\"expandIcons\"\n [selectable]=\"selectable\"\n [touchActions]=\"touchActions\"\n [children]=\"children\"\n [hasChildren]=\"hasChildren\"\n [isChecked]=\"isChecked\"\n [isDisabled]=\"isDisabled\"\n [disabled]=\"disabled || isDisabled(node, nodeIndex(index))\"\n [isExpanded]=\"isExpanded\"\n [isSelected]=\"isSelected\"\n [isVisible]=\"isVisible\"\n [nodeTemplateRef]=\"nodeTemplateRef\"\n [loadMoreButtonTemplateRef]=\"loadMoreButtonTemplateRef\"\n [parentIndex]=\"nodeIndex(index)\"\n [parentDataItem]=\"node\"\n [textField]=\"nextFields\"\n [loadMoreService]=\"loadMoreService\"\n [@toggle]=\"true\"\n [trackBy]=\"trackBy\"\n >\n </ul>\n </li>\n <li\n *ngIf=\"initialNodesLoaded && moreNodesAvailable\"\n class=\"k-item k-treeview-item\"\n [class.k-treeview-load-more-checkboxes-container]=\"checkboxes\"\n kendoTreeViewItem\n role=\"button\"\n [selectable]=\"false\"\n [checkable]=\"false\"\n [expandable]=\"false\"\n [index]=\"loadMoreButtonIndex\"\n [parentDataItem]=\"parentDataItem\"\n [parentIndex]=\"parentIndex\"\n [attr.data-treeindex]=\"loadMoreButtonIndex\"\n >\n <div class=\"k-mid\">\n <span\n *ngIf=\"loadingMoreNodes\"\n class=\"k-icon k-i-loading k-i-expand\"\n >\n </span>\n <span\n class=\"k-in k-treeview-load-more-button\"\n [attr.data-treeindex]=\"loadMoreButtonIndex\"\n kendoTreeViewItemContent\n [index]=\"loadMoreButtonIndex\"\n >\n <ng-template\n *ngIf=\"loadMoreButtonTemplateRef\"\n [ngTemplateOutlet]=\"loadMoreButtonTemplateRef\"\n [ngTemplateOutletContext]=\"{\n index: loadMoreButtonIndex\n }\"\n >\n </ng-template>\n <ng-container *ngIf=\"!loadMoreButtonTemplateRef\">\n Load more\n </ng-container>\n </span>\n </div>\n </li>\n "
380
+ template: "\n <li\n *ngFor=\"let node of data; let index = index; trackBy: trackBy\"\n class=\"k-treeview-item\"\n [class.k-display-none]=\"!isVisible(node, nodeIndex(index))\"\n kendoTreeViewItem\n [attr.aria-setsize]=\"totalNodesCount\"\n [dataItem]=\"node\"\n [index]=\"nodeIndex(index)\"\n [parentDataItem]=\"parentDataItem\"\n [parentIndex]=\"parentIndex\"\n [loadOnDemand]=\"loadOnDemand\"\n [checkable]=\"checkboxes\"\n [isChecked]=\"isChecked(node, nodeIndex(index))\"\n [isDisabled]=\"disabled || isDisabled(node, nodeIndex(index))\"\n [isVisible]=\"isVisible(node, nodeIndex(index))\"\n [expandable]=\"expandIcons && hasChildren(node)\"\n [isExpanded]=\"isExpanded(node, nodeIndex(index))\"\n [selectable]=\"selectable\"\n [isSelected]=\"isSelected(node, nodeIndex(index))\"\n [attr.data-treeindex]=\"nodeIndex(index)\"\n >\n <div class=\"k-treeview-mid\">\n <span\n class=\"k-treeview-toggle\"\n [kendoTreeViewLoading]=\"nodeIndex(index)\"\n (click)=\"expandNode(nodeIndex(index), node, !isExpanded(node, nodeIndex(index)))\"\n *ngIf=\"expandIcons && hasChildren(node)\"\n >\n <span\n class=\"k-icon\"\n [class.k-i-collapse]=\"isExpanded(node, nodeIndex(index))\"\n [class.k-i-expand]=\"!isExpanded(node, nodeIndex(index))\"\n >\n </span>\n </span>\n <kendo-checkbox\n *ngIf=\"checkboxes\"\n [size]=\"size\"\n [node]=\"node\"\n [index]=\"nodeIndex(index)\"\n [isChecked]=\"isChecked\"\n (checkStateChange)=\"checkNode(nodeIndex(index))\"\n tabindex=\"-1\"\n ></kendo-checkbox>\n <span kendoTreeViewItemContent\n [attr.data-treeindex]=\"nodeIndex(index)\"\n [dataItem]=\"node\"\n [index]=\"nodeIndex(index)\"\n [initialSelection]=\"isSelected(node, nodeIndex(index))\"\n [isSelected]=\"isSelected\"\n class=\"k-treeview-leaf\"\n [style.touch-action]=\"touchActions ? '' : 'none'\"\n >\n <span class=\"k-treeview-leaf-text\">\n <ng-container [ngSwitch]=\"hasTemplate\">\n <ng-container *ngSwitchCase=\"true\">\n <ng-template\n [ngTemplateOutlet]=\"nodeTemplateRef\"\n [ngTemplateOutletContext]=\"{\n $implicit: node,\n index: nodeIndex(index)\n }\"\n >\n </ng-template>\n </ng-container>\n <ng-container *ngSwitchDefault>\n {{nodeText(node)}}\n </ng-container>\n </ng-container>\n </span>\n </span>\n </div>\n <ul\n *ngIf=\"isExpanded(node, nodeIndex(index)) && hasChildren(node)\"\n kendoTreeViewGroup\n role=\"group\"\n [nodes]=\"fetchChildren\"\n [loadOnDemand]=\"loadOnDemand\"\n [checkboxes]=\"checkboxes\"\n [expandIcons]=\"expandIcons\"\n [selectable]=\"selectable\"\n [touchActions]=\"touchActions\"\n [children]=\"children\"\n [hasChildren]=\"hasChildren\"\n [isChecked]=\"isChecked\"\n [isDisabled]=\"isDisabled\"\n [disabled]=\"disabled || isDisabled(node, nodeIndex(index))\"\n [isExpanded]=\"isExpanded\"\n [isSelected]=\"isSelected\"\n [isVisible]=\"isVisible\"\n [nodeTemplateRef]=\"nodeTemplateRef\"\n [loadMoreButtonTemplateRef]=\"loadMoreButtonTemplateRef\"\n [parentIndex]=\"nodeIndex(index)\"\n [parentDataItem]=\"node\"\n [textField]=\"nextFields\"\n [loadMoreService]=\"loadMoreService\"\n [@toggle]=\"true\"\n [trackBy]=\"trackBy\"\n >\n </ul>\n </li>\n <li\n *ngIf=\"initialNodesLoaded && moreNodesAvailable\"\n class=\"k-treeview-item\"\n [class.k-treeview-load-more-checkboxes-container]=\"checkboxes\"\n kendoTreeViewItem\n role=\"button\"\n [selectable]=\"false\"\n [checkable]=\"false\"\n [expandable]=\"false\"\n [index]=\"loadMoreButtonIndex\"\n [parentDataItem]=\"parentDataItem\"\n [parentIndex]=\"parentIndex\"\n [attr.data-treeindex]=\"loadMoreButtonIndex\"\n >\n <div class=\"k-treeview-mid\">\n <span\n *ngIf=\"loadingMoreNodes\"\n class=\"k-icon k-i-loading k-i-expand\"\n >\n </span>\n <span\n class=\"k-treeview-leaf k-treeview-load-more-button\"\n [attr.data-treeindex]=\"loadMoreButtonIndex\"\n kendoTreeViewItemContent\n [index]=\"loadMoreButtonIndex\"\n >\n <span class=\"k-treeview-leaf-text\">\n <ng-template\n *ngIf=\"loadMoreButtonTemplateRef\"\n [ngTemplateOutlet]=\"loadMoreButtonTemplateRef\"\n [ngTemplateOutletContext]=\"{\n index: loadMoreButtonIndex\n }\"\n >\n </ng-template>\n <ng-container *ngIf=\"!loadMoreButtonTemplateRef\">\n Load more\n </ng-container>\n </span>\n </span>\n </div>\n </li>\n "
376
381
  }),
377
382
  tslib_1.__metadata("design:paramtypes", [ExpandStateService,
378
383
  LoadingNotificationService,
@@ -48,10 +48,10 @@ var TreeViewItemContentDirective = /** @class */ (function () {
48
48
  this.subscriptions.unsubscribe();
49
49
  };
50
50
  TreeViewItemContentDirective.prototype.updateFocusClass = function () {
51
- this.render(this.navigationService.isActive(this.index), 'k-state-focused');
51
+ this.render(this.navigationService.isActive(this.index), 'k-focus');
52
52
  };
53
53
  TreeViewItemContentDirective.prototype.updateSelectionClass = function (selected) {
54
- this.render(selected, 'k-state-selected');
54
+ this.render(selected, 'k-selected');
55
55
  };
56
56
  TreeViewItemContentDirective.prototype.render = function (addClass, className) {
57
57
  var action = addClass ? 'addClass' : 'removeClass';
@@ -214,7 +214,7 @@ var TreeViewItemDirective = /** @class */ (function () {
214
214
  this.setAttribute('aria-checked', this.checkable ? this.ariaChecked : null);
215
215
  };
216
216
  TreeViewItemDirective.prototype.setDisabledClass = function () {
217
- this.setClass('k-state-disabled', this.isDisabled);
217
+ this.setClass('k-disabled', this.isDisabled);
218
218
  };
219
219
  TreeViewItemDirective.prototype.setClass = function (className, toggle) {
220
220
  var action = toggle ? 'addClass' : 'removeClass';