@progress/kendo-angular-treeview 5.4.2 → 6.0.0-dev.202201111033

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 (56) hide show
  1. package/dist/cdn/js/kendo-angular-treeview.js +18 -18
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/check.directive.js +30 -39
  4. package/dist/es/checkbox/checkbox.component.js +17 -1
  5. package/dist/es/drag-and-drop/drag-and-drop-utils.js +3 -3
  6. package/dist/es/drag-and-drop/drag-and-drop.directive.js +2 -2
  7. package/dist/es/expand.directive.js +40 -41
  8. package/dist/es/package-metadata.js +1 -1
  9. package/dist/es/selection/select.directive.js +22 -28
  10. package/dist/es/size.js +4 -0
  11. package/dist/es/treeview-group.component.js +7 -2
  12. package/dist/es/treeview-item-content.directive.js +2 -2
  13. package/dist/es/treeview-item.directive.js +1 -1
  14. package/dist/es/treeview.component.js +58 -13
  15. package/dist/es/utils.js +21 -11
  16. package/dist/es2015/check.directive.d.ts +8 -1
  17. package/dist/es2015/check.directive.js +30 -35
  18. package/dist/es2015/checkbox/checkbox.component.d.ts +6 -0
  19. package/dist/es2015/checkbox/checkbox.component.js +13 -1
  20. package/dist/es2015/drag-and-drop/drag-and-drop-utils.js +3 -3
  21. package/dist/es2015/drag-and-drop/drag-and-drop.directive.js +2 -2
  22. package/dist/es2015/expand.directive.d.ts +12 -3
  23. package/dist/es2015/expand.directive.js +39 -36
  24. package/dist/es2015/index.metadata.json +1 -1
  25. package/dist/es2015/main.d.ts +1 -0
  26. package/dist/es2015/package-metadata.js +1 -1
  27. package/dist/es2015/selection/select.directive.d.ts +11 -3
  28. package/dist/es2015/selection/select.directive.js +22 -24
  29. package/dist/es2015/size.d.ts +14 -0
  30. package/dist/es2015/size.js +4 -0
  31. package/dist/es2015/treeview-filter-settings.d.ts +2 -0
  32. package/dist/es2015/treeview-group.component.d.ts +2 -0
  33. package/dist/es2015/treeview-group.component.js +49 -35
  34. package/dist/es2015/treeview-item-content.directive.js +2 -2
  35. package/dist/es2015/treeview-item.directive.js +1 -1
  36. package/dist/es2015/treeview.component.d.ts +33 -5
  37. package/dist/es2015/treeview.component.js +70 -24
  38. package/dist/es2015/utils.d.ts +9 -4
  39. package/dist/es2015/utils.js +21 -11
  40. package/dist/fesm2015/index.js +248 -174
  41. package/dist/fesm5/index.js +199 -143
  42. package/dist/npm/check.directive.js +30 -39
  43. package/dist/npm/checkbox/checkbox.component.js +17 -1
  44. package/dist/npm/drag-and-drop/drag-and-drop-utils.js +3 -3
  45. package/dist/npm/drag-and-drop/drag-and-drop.directive.js +2 -2
  46. package/dist/npm/expand.directive.js +40 -41
  47. package/dist/npm/package-metadata.js +1 -1
  48. package/dist/npm/selection/select.directive.js +22 -28
  49. package/dist/npm/size.js +6 -0
  50. package/dist/npm/treeview-group.component.js +7 -2
  51. package/dist/npm/treeview-item-content.directive.js +2 -2
  52. package/dist/npm/treeview-item.directive.js +1 -1
  53. package/dist/npm/treeview.component.js +57 -12
  54. package/dist/npm/utils.js +21 -11
  55. package/dist/systemjs/kendo-angular-treeview.js +1 -1
  56. package/package.json +9 -8
@@ -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
  const DEFAULT_FILTER_EXPAND_SETTINGS = {
12
13
  maxAutoExpandResults: -1,
13
14
  expandMatches: false,
@@ -31,8 +32,11 @@ let ExpandDirective = class ExpandDirective {
31
32
  */
32
33
  this.expandedKeysChange = new EventEmitter();
33
34
  this.subscriptions = new Subscription();
34
- this._expandedKeys = [];
35
- this.originalExpandedKeys = [];
35
+ /**
36
+ * Reflectes the internal `expandedKeys` state.
37
+ */
38
+ this.state = new Set();
39
+ this.originalExpandedKeys = new Set();
36
40
  this.isFiltered = false;
37
41
  /**
38
42
  * Fills array with the correct expand keys according to wrapper metadata.
@@ -64,7 +68,7 @@ let ExpandDirective = class ExpandDirective {
64
68
  if (this.component.filterStateChange) {
65
69
  this.subscriptions.add(this.component.filterStateChange.subscribe(this.handleAutoExpand.bind(this)));
66
70
  }
67
- this.component.isExpanded = (dataItem, index) => this.expandedKeys.indexOf(this.itemKey({ dataItem, index })) > -1;
71
+ this.component.isExpanded = (dataItem, index) => this.state.has(this.itemKey({ dataItem, index }));
68
72
  }
69
73
  /**
70
74
  * @hidden
@@ -76,14 +80,10 @@ let ExpandDirective = class ExpandDirective {
76
80
  const settings = isBoolean(this.expandOnFilter) ? { enabled: this.expandOnFilter } : Object.assign({}, this.expandOnFilter, { enabled: true });
77
81
  return Object.assign({}, DEFAULT_FILTER_EXPAND_SETTINGS, settings);
78
82
  }
79
- /**
80
- * Defines the collection that will store the expanded keys.
81
- */
82
- get expandedKeys() {
83
- return this._expandedKeys;
84
- }
85
- set expandedKeys(keys) {
86
- this._expandedKeys = keys;
83
+ ngOnChanges(changes) {
84
+ if (isChanged('expandedKeys', changes, false) && changes.expandedKeys.currentValue !== this.lastChange) {
85
+ this.state = new Set(changes.expandedKeys.currentValue);
86
+ }
87
87
  }
88
88
  ngOnDestroy() {
89
89
  this.subscriptions.unsubscribe();
@@ -103,19 +103,19 @@ let ExpandDirective = class ExpandDirective {
103
103
  return e.index;
104
104
  }
105
105
  toggleExpand({ index, dataItem, expand }) {
106
- const item = this.itemKey({ index, dataItem });
107
- const idx = this.expandedKeys.indexOf(item);
106
+ const key = this.itemKey({ index, dataItem });
107
+ const isExpanded = this.state.has(key);
108
108
  let notify = false;
109
- if (idx > -1 && !expand) {
110
- this.expandedKeys.splice(idx, 1);
109
+ if (isExpanded && !expand) {
110
+ this.state.delete(key);
111
111
  notify = true;
112
112
  }
113
- else if (idx === -1 && expand) {
114
- this.expandedKeys.push(item);
113
+ else if (!isExpanded && expand) {
114
+ this.state.add(key);
115
115
  notify = true;
116
116
  }
117
117
  if (notify) {
118
- this.expandedKeysChange.emit(this.expandedKeys);
118
+ this.notify();
119
119
  }
120
120
  }
121
121
  handleAutoExpand({ nodes, matchCount, term }) {
@@ -124,7 +124,7 @@ let ExpandDirective = class ExpandDirective {
124
124
  }
125
125
  const { maxAutoExpandResults, expandMatches: autoExpandMatches, expandedOnClear } = this.filterExpandSettings;
126
126
  if (!this.isFiltered) {
127
- this.originalExpandedKeys = this.expandedKeys.slice();
127
+ this.originalExpandedKeys = new Set(this.state);
128
128
  }
129
129
  const exitingFilteredState = this.isFiltered && !term;
130
130
  const maxExceeded = maxAutoExpandResults !== -1 && matchCount > maxAutoExpandResults;
@@ -132,18 +132,18 @@ let ExpandDirective = class ExpandDirective {
132
132
  if (exitAutoExpandedState) {
133
133
  switch (expandedOnClear) {
134
134
  case "initial": {
135
- if (!sameValues(this.expandedKeys, this.originalExpandedKeys)) {
136
- this.expandedKeys = this.originalExpandedKeys;
137
- this.expandedKeysChange.emit(this.expandedKeys);
135
+ if (!sameValues(this.state, this.originalExpandedKeys)) {
136
+ this.state = this.originalExpandedKeys;
137
+ this.notify();
138
138
  }
139
139
  break;
140
140
  }
141
141
  case "all": {
142
- this.expandedKeys = nodes.reduce((acc, rootNode) => {
142
+ this.state = new Set(nodes.reduce((acc, rootNode) => {
143
143
  this.getEveryExpandKey(acc, rootNode);
144
144
  return acc;
145
- }, []);
146
- this.expandedKeysChange.emit(this.expandedKeys);
145
+ }, []));
146
+ this.notify();
147
147
  break;
148
148
  }
149
149
  case "unchanged": {
@@ -151,9 +151,9 @@ let ExpandDirective = class ExpandDirective {
151
151
  }
152
152
  case "none":
153
153
  default: {
154
- if (this.expandedKeys.length !== 0) {
155
- this.expandedKeys = [];
156
- this.expandedKeysChange.emit(this.expandedKeys);
154
+ if (this.state.size !== 0) {
155
+ this.state.clear();
156
+ this.notify();
157
157
  }
158
158
  break;
159
159
  }
@@ -161,16 +161,20 @@ let ExpandDirective = class ExpandDirective {
161
161
  this.isFiltered = false;
162
162
  return;
163
163
  }
164
- const indicesToExpand = nodes.reduce((acc, rootNode) => {
164
+ const indicesToExpand = new Set(nodes.reduce((acc, rootNode) => {
165
165
  this.updateExpandedNodes(acc, rootNode, autoExpandMatches);
166
166
  return acc;
167
- }, []);
168
- if (!sameValues(this.expandedKeys, indicesToExpand)) {
169
- this.expandedKeys = indicesToExpand;
170
- this.expandedKeysChange.emit(this.expandedKeys);
167
+ }, []));
168
+ if (!sameValues(this.state, indicesToExpand)) {
169
+ this.state = indicesToExpand;
170
+ this.notify();
171
171
  }
172
172
  this.isFiltered = true;
173
173
  }
174
+ notify() {
175
+ this.lastChange = Array.from(this.state);
176
+ this.expandedKeysChange.emit(this.lastChange);
177
+ }
174
178
  };
175
179
  tslib_1.__decorate([
176
180
  Input(),
@@ -191,9 +195,8 @@ tslib_1.__decorate([
191
195
  ], ExpandDirective.prototype, "expandedKeysChange", void 0);
192
196
  tslib_1.__decorate([
193
197
  Input(),
194
- tslib_1.__metadata("design:type", Array),
195
- tslib_1.__metadata("design:paramtypes", [Array])
196
- ], ExpandDirective.prototype, "expandedKeys", null);
198
+ tslib_1.__metadata("design:type", Array)
199
+ ], ExpandDirective.prototype, "expandedKeys", void 0);
197
200
  ExpandDirective = tslib_1.__decorate([
198
201
  Directive({ selector: '[kendoTreeViewExpandable]' }),
199
202
  tslib_1.__metadata("design:paramtypes", [ExpandableComponent])