@progress/kendo-angular-treeview 5.4.2-dev.202111011443 → 6.0.0-dev.202112021059
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-treeview.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/check.directive.js +30 -39
- package/dist/es/expand.directive.js +40 -41
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/selection/select.directive.js +22 -28
- package/dist/es/treeview.component.js +23 -10
- package/dist/es/utils.js +4 -6
- package/dist/es2015/check.directive.d.ts +8 -1
- package/dist/es2015/check.directive.js +30 -35
- package/dist/es2015/expand.directive.d.ts +12 -3
- package/dist/es2015/expand.directive.js +39 -36
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/main.d.ts +1 -0
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/es2015/selection/select.directive.d.ts +11 -3
- package/dist/es2015/selection/select.directive.js +22 -24
- package/dist/es2015/treeview-filter-settings.d.ts +2 -0
- package/dist/es2015/treeview.component.d.ts +20 -5
- package/dist/es2015/treeview.component.js +24 -11
- package/dist/es2015/utils.d.ts +2 -3
- package/dist/es2015/utils.js +4 -6
- package/dist/fesm2015/index.js +117 -113
- package/dist/fesm5/index.js +117 -125
- package/dist/npm/check.directive.js +30 -39
- package/dist/npm/expand.directive.js +40 -41
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/selection/select.directive.js +22 -28
- package/dist/npm/treeview.component.js +23 -10
- package/dist/npm/utils.js +4 -6
- package/dist/systemjs/kendo-angular-treeview.js +1 -1
- package/package.json +1 -1
package/dist/fesm2015/index.js
CHANGED
|
@@ -22,7 +22,7 @@ const packageMetadata = {
|
|
|
22
22
|
name: '@progress/kendo-angular-treeview',
|
|
23
23
|
productName: 'Kendo UI for Angular',
|
|
24
24
|
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
25
|
-
publishDate:
|
|
25
|
+
publishDate: 1638442548,
|
|
26
26
|
version: '',
|
|
27
27
|
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'
|
|
28
28
|
};
|
|
@@ -405,17 +405,15 @@ const fetchLoadedDescendants = (lookup, filterExpression) => {
|
|
|
405
405
|
/**
|
|
406
406
|
* @hidden
|
|
407
407
|
*
|
|
408
|
-
* Compares two
|
|
408
|
+
* Compares two Seets to determine whether all unique elements in one, are present in the other.
|
|
409
409
|
* Important:
|
|
410
410
|
* - it disregards the element order
|
|
411
|
-
* - it disregards element repetitions - sameValues([1, 1, 2], [1, 2, 2]) will return true
|
|
412
411
|
*/
|
|
413
|
-
const sameValues = (
|
|
414
|
-
if (
|
|
412
|
+
const sameValues = (as, bs) => {
|
|
413
|
+
if (as.size !== bs.size) {
|
|
415
414
|
return false;
|
|
416
415
|
}
|
|
417
|
-
|
|
418
|
-
return a.every(v => values.has(v));
|
|
416
|
+
return Array.from(as).every(v => bs.has(v));
|
|
419
417
|
};
|
|
420
418
|
|
|
421
419
|
const safe = node => (node || {});
|
|
@@ -1045,9 +1043,10 @@ const providers = [
|
|
|
1045
1043
|
* Represents the [Kendo UI TreeView component for Angular]({% slug overview_treeview %}).
|
|
1046
1044
|
*
|
|
1047
1045
|
* @example
|
|
1048
|
-
* {% meta height:
|
|
1049
|
-
* {% embed_file
|
|
1050
|
-
* {% embed_file
|
|
1046
|
+
* {% meta height:450 %}
|
|
1047
|
+
* {% embed_file get-started/app.component.ts preview %}
|
|
1048
|
+
* {% embed_file get-started/app.module.ts %}
|
|
1049
|
+
* {% embed_file shared/main.ts %}
|
|
1051
1050
|
* {% endmeta %}
|
|
1052
1051
|
*/
|
|
1053
1052
|
let TreeViewComponent = class TreeViewComponent {
|
|
@@ -1240,15 +1239,27 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
1240
1239
|
}
|
|
1241
1240
|
/**
|
|
1242
1241
|
* @hidden
|
|
1242
|
+
*
|
|
1243
|
+
* Defines the template for each node.
|
|
1244
|
+
* Takes precedence over nested templates in the TreeView tag.
|
|
1243
1245
|
*/
|
|
1244
1246
|
set nodeTemplateRef(template) {
|
|
1245
|
-
this.
|
|
1247
|
+
this._nodeTemplateRef = template;
|
|
1248
|
+
}
|
|
1249
|
+
get nodeTemplateRef() {
|
|
1250
|
+
return this._nodeTemplateRef || this.nodeTemplateQuery;
|
|
1246
1251
|
}
|
|
1247
1252
|
/**
|
|
1248
1253
|
* @hidden
|
|
1254
|
+
*
|
|
1255
|
+
* Defines the template for each load-more button.
|
|
1256
|
+
* Takes precedence over nested templates in the TreeView tag.
|
|
1249
1257
|
*/
|
|
1250
1258
|
set loadMoreButtonTemplateRef(template) {
|
|
1251
|
-
this.
|
|
1259
|
+
this._loadMoreButtonTemplateRef = template;
|
|
1260
|
+
}
|
|
1261
|
+
get loadMoreButtonTemplateRef() {
|
|
1262
|
+
return this._loadMoreButtonTemplateRef || this.loadMoreButtonTemplateQuery;
|
|
1252
1263
|
}
|
|
1253
1264
|
/**
|
|
1254
1265
|
* The nodes which will be displayed by the TreeView
|
|
@@ -1646,18 +1657,18 @@ __decorate([
|
|
|
1646
1657
|
__metadata("design:type", EventEmitter)
|
|
1647
1658
|
], TreeViewComponent.prototype, "nodeDblClick", void 0);
|
|
1648
1659
|
__decorate([
|
|
1649
|
-
ContentChild(NodeTemplateDirective, { static:
|
|
1660
|
+
ContentChild(NodeTemplateDirective, { static: false }),
|
|
1650
1661
|
__metadata("design:type", NodeTemplateDirective)
|
|
1651
|
-
], TreeViewComponent.prototype, "
|
|
1662
|
+
], TreeViewComponent.prototype, "nodeTemplateQuery", void 0);
|
|
1652
1663
|
__decorate([
|
|
1653
1664
|
Input('nodeTemplate'),
|
|
1654
1665
|
__metadata("design:type", NodeTemplateDirective),
|
|
1655
1666
|
__metadata("design:paramtypes", [NodeTemplateDirective])
|
|
1656
1667
|
], TreeViewComponent.prototype, "nodeTemplateRef", null);
|
|
1657
1668
|
__decorate([
|
|
1658
|
-
ContentChild(LoadMoreButtonTemplateDirective, { static:
|
|
1669
|
+
ContentChild(LoadMoreButtonTemplateDirective, { static: false }),
|
|
1659
1670
|
__metadata("design:type", LoadMoreButtonTemplateDirective)
|
|
1660
|
-
], TreeViewComponent.prototype, "
|
|
1671
|
+
], TreeViewComponent.prototype, "loadMoreButtonTemplateQuery", void 0);
|
|
1661
1672
|
__decorate([
|
|
1662
1673
|
Input('loadMoreButtonTemplate'),
|
|
1663
1674
|
__metadata("design:type", LoadMoreButtonTemplateDirective),
|
|
@@ -1758,8 +1769,8 @@ TreeViewComponent = __decorate([
|
|
|
1758
1769
|
[isExpanded]="isExpanded"
|
|
1759
1770
|
[isSelected]="isSelected"
|
|
1760
1771
|
[isVisible]="isVisible"
|
|
1761
|
-
[nodeTemplateRef]="
|
|
1762
|
-
[loadMoreButtonTemplateRef]="
|
|
1772
|
+
[nodeTemplateRef]="nodeTemplateRef?.templateRef"
|
|
1773
|
+
[loadMoreButtonTemplateRef]="loadMoreButtonTemplateRef?.templateRef"
|
|
1763
1774
|
[textField]="textField"
|
|
1764
1775
|
[nodes]="fetchNodes"
|
|
1765
1776
|
[loadMoreService]="loadMoreService"
|
|
@@ -2286,7 +2297,10 @@ let CheckDirective = class CheckDirective {
|
|
|
2286
2297
|
'multiple': (e) => this.checkMultiple(e),
|
|
2287
2298
|
'single': (e) => this.checkSingle(e)
|
|
2288
2299
|
};
|
|
2289
|
-
|
|
2300
|
+
/**
|
|
2301
|
+
* Reflectes the internal `checkedKeys` state.
|
|
2302
|
+
*/
|
|
2303
|
+
this.state = new Set();
|
|
2290
2304
|
this.subscriptions.add(this.treeView.checkedChange
|
|
2291
2305
|
.subscribe((e) => this.check(e)));
|
|
2292
2306
|
let expandedItems = [];
|
|
@@ -2301,16 +2315,6 @@ let CheckDirective = class CheckDirective {
|
|
|
2301
2315
|
set isChecked(value) {
|
|
2302
2316
|
this.treeView.isChecked = value;
|
|
2303
2317
|
}
|
|
2304
|
-
/**
|
|
2305
|
-
* Defines the collection that will store the checked keys
|
|
2306
|
-
* ([see example]({% slug checkboxes_treeview %})).
|
|
2307
|
-
*/
|
|
2308
|
-
get checkedKeys() {
|
|
2309
|
-
return this._checkedKeys;
|
|
2310
|
-
}
|
|
2311
|
-
set checkedKeys(keys) {
|
|
2312
|
-
this._checkedKeys = keys;
|
|
2313
|
-
}
|
|
2314
2318
|
get options() {
|
|
2315
2319
|
const defaultOptions = {
|
|
2316
2320
|
checkChildren: true,
|
|
@@ -2331,6 +2335,9 @@ let CheckDirective = class CheckDirective {
|
|
|
2331
2335
|
this.treeView.checkboxes = this.options.enabled;
|
|
2332
2336
|
this.toggleCheckOnClick();
|
|
2333
2337
|
}
|
|
2338
|
+
if (isChanged('checkedKeys', changes, false) && changes.checkedKeys.currentValue !== this.lastChange) {
|
|
2339
|
+
this.state = new Set(changes.checkedKeys.currentValue);
|
|
2340
|
+
}
|
|
2334
2341
|
}
|
|
2335
2342
|
ngOnDestroy() {
|
|
2336
2343
|
this.subscriptions.unsubscribe();
|
|
@@ -2340,11 +2347,11 @@ let CheckDirective = class CheckDirective {
|
|
|
2340
2347
|
if (!this.checkKey) {
|
|
2341
2348
|
return this.isIndexChecked(index);
|
|
2342
2349
|
}
|
|
2343
|
-
const
|
|
2344
|
-
return
|
|
2350
|
+
const hasKey = this.state.has(this.itemKey({ dataItem, index }));
|
|
2351
|
+
return hasKey ? 'checked' : 'none';
|
|
2345
2352
|
}
|
|
2346
2353
|
isIndexChecked(index) {
|
|
2347
|
-
const checkedKeys = this.
|
|
2354
|
+
const checkedKeys = Array.from(this.state).filter(matchKey(index));
|
|
2348
2355
|
if (indexChecked(checkedKeys, index)) {
|
|
2349
2356
|
return 'checked';
|
|
2350
2357
|
}
|
|
@@ -2375,7 +2382,11 @@ let CheckDirective = class CheckDirective {
|
|
|
2375
2382
|
}
|
|
2376
2383
|
checkSingle(node) {
|
|
2377
2384
|
const key = this.itemKey(node.item);
|
|
2378
|
-
|
|
2385
|
+
const hasKey = this.state.has(key);
|
|
2386
|
+
this.state.clear();
|
|
2387
|
+
if (!hasKey) {
|
|
2388
|
+
this.state.add(key);
|
|
2389
|
+
}
|
|
2379
2390
|
this.notify();
|
|
2380
2391
|
}
|
|
2381
2392
|
checkMultiple(node) {
|
|
@@ -2410,7 +2421,6 @@ let CheckDirective = class CheckDirective {
|
|
|
2410
2421
|
if (!isPresent(currentKey)) {
|
|
2411
2422
|
return;
|
|
2412
2423
|
}
|
|
2413
|
-
const checkedKeys = new Set(this.checkedKeys);
|
|
2414
2424
|
const pendingCheck = [currentKey];
|
|
2415
2425
|
if (this.options.checkChildren) {
|
|
2416
2426
|
const descendants = fetchLoadedDescendants(node, ({ item }) => this.treeView.isVisible(item.dataItem, item.index) &&
|
|
@@ -2418,61 +2428,57 @@ let CheckDirective = class CheckDirective {
|
|
|
2418
2428
|
.map(({ item }) => this.itemKey(item));
|
|
2419
2429
|
pendingCheck.push(...descendants);
|
|
2420
2430
|
}
|
|
2421
|
-
const shouldCheck = !
|
|
2431
|
+
const shouldCheck = !this.state.has(currentKey);
|
|
2422
2432
|
pendingCheck.forEach(key => {
|
|
2423
2433
|
if (shouldCheck) {
|
|
2424
|
-
|
|
2434
|
+
this.state.add(key);
|
|
2425
2435
|
}
|
|
2426
2436
|
else {
|
|
2427
|
-
|
|
2437
|
+
this.state.delete(key);
|
|
2428
2438
|
}
|
|
2429
2439
|
});
|
|
2430
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
2431
2440
|
}
|
|
2432
2441
|
checkParents(parent) {
|
|
2433
2442
|
if (!isPresent(parent)) {
|
|
2434
2443
|
return;
|
|
2435
2444
|
}
|
|
2436
|
-
const checkedKeys = new Set(this.checkedKeys);
|
|
2437
2445
|
let currentParent = parent;
|
|
2438
2446
|
while (currentParent) {
|
|
2439
2447
|
const parentKey = this.itemKey(currentParent.item);
|
|
2440
|
-
const allChildrenSelected = currentParent.children.every(item =>
|
|
2448
|
+
const allChildrenSelected = currentParent.children.every(item => this.state.has(this.itemKey(item)));
|
|
2441
2449
|
if (allChildrenSelected) {
|
|
2442
|
-
|
|
2450
|
+
this.state.add(parentKey);
|
|
2443
2451
|
}
|
|
2444
2452
|
else {
|
|
2445
|
-
|
|
2453
|
+
this.state.delete(parentKey);
|
|
2446
2454
|
}
|
|
2447
2455
|
currentParent = currentParent.parent;
|
|
2448
2456
|
}
|
|
2449
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
2450
2457
|
}
|
|
2451
2458
|
notify() {
|
|
2452
|
-
this.
|
|
2459
|
+
this.lastChange = Array.from(this.state);
|
|
2460
|
+
this.checkedKeysChange.emit(this.lastChange);
|
|
2453
2461
|
}
|
|
2454
2462
|
addCheckedItemsChildren(lookups) {
|
|
2455
2463
|
if (!isPresent(lookups) || lookups.length === 0) {
|
|
2456
2464
|
return;
|
|
2457
2465
|
}
|
|
2458
|
-
const initiallyCheckedItemsCount = this.
|
|
2459
|
-
const checkedKeys = new Set(this.checkedKeys);
|
|
2466
|
+
const initiallyCheckedItemsCount = this.state.size;
|
|
2460
2467
|
lookups.forEach(lookup => {
|
|
2461
2468
|
const itemKey = this.itemKey(lookup.item);
|
|
2462
|
-
if (!
|
|
2469
|
+
if (!this.state.has(itemKey)) {
|
|
2463
2470
|
return;
|
|
2464
2471
|
}
|
|
2465
2472
|
lookup.children.forEach(item => {
|
|
2466
2473
|
// ensure both the parent item and each child node is enabled
|
|
2467
2474
|
if (!this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
|
|
2468
2475
|
!this.treeView.isDisabled(item.dataItem, item.index)) {
|
|
2469
|
-
|
|
2476
|
+
this.state.add(this.itemKey(item));
|
|
2470
2477
|
}
|
|
2471
2478
|
});
|
|
2472
2479
|
});
|
|
2473
|
-
const hasNewlyCheckedItems = initiallyCheckedItemsCount !==
|
|
2480
|
+
const hasNewlyCheckedItems = initiallyCheckedItemsCount !== this.state.size;
|
|
2474
2481
|
if (hasNewlyCheckedItems) {
|
|
2475
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
2476
2482
|
this.zone.run(() => this.notify());
|
|
2477
2483
|
}
|
|
2478
2484
|
}
|
|
@@ -2488,9 +2494,8 @@ __decorate([
|
|
|
2488
2494
|
], CheckDirective.prototype, "checkKey", void 0);
|
|
2489
2495
|
__decorate([
|
|
2490
2496
|
Input(),
|
|
2491
|
-
__metadata("design:type", Array)
|
|
2492
|
-
|
|
2493
|
-
], CheckDirective.prototype, "checkedKeys", null);
|
|
2497
|
+
__metadata("design:type", Array)
|
|
2498
|
+
], CheckDirective.prototype, "checkedKeys", void 0);
|
|
2494
2499
|
__decorate([
|
|
2495
2500
|
Input('kendoTreeViewCheckable'),
|
|
2496
2501
|
__metadata("design:type", Object)
|
|
@@ -2585,8 +2590,11 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2585
2590
|
*/
|
|
2586
2591
|
this.expandedKeysChange = new EventEmitter();
|
|
2587
2592
|
this.subscriptions = new Subscription();
|
|
2588
|
-
|
|
2589
|
-
|
|
2593
|
+
/**
|
|
2594
|
+
* Reflectes the internal `expandedKeys` state.
|
|
2595
|
+
*/
|
|
2596
|
+
this.state = new Set();
|
|
2597
|
+
this.originalExpandedKeys = new Set();
|
|
2590
2598
|
this.isFiltered = false;
|
|
2591
2599
|
/**
|
|
2592
2600
|
* Fills array with the correct expand keys according to wrapper metadata.
|
|
@@ -2618,7 +2626,7 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2618
2626
|
if (this.component.filterStateChange) {
|
|
2619
2627
|
this.subscriptions.add(this.component.filterStateChange.subscribe(this.handleAutoExpand.bind(this)));
|
|
2620
2628
|
}
|
|
2621
|
-
this.component.isExpanded = (dataItem, index) => this.
|
|
2629
|
+
this.component.isExpanded = (dataItem, index) => this.state.has(this.itemKey({ dataItem, index }));
|
|
2622
2630
|
}
|
|
2623
2631
|
/**
|
|
2624
2632
|
* @hidden
|
|
@@ -2630,14 +2638,10 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2630
2638
|
const settings = isBoolean(this.expandOnFilter) ? { enabled: this.expandOnFilter } : Object.assign({}, this.expandOnFilter, { enabled: true });
|
|
2631
2639
|
return Object.assign({}, DEFAULT_FILTER_EXPAND_SETTINGS, settings);
|
|
2632
2640
|
}
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
return this._expandedKeys;
|
|
2638
|
-
}
|
|
2639
|
-
set expandedKeys(keys) {
|
|
2640
|
-
this._expandedKeys = keys;
|
|
2641
|
+
ngOnChanges(changes) {
|
|
2642
|
+
if (isChanged('expandedKeys', changes, false) && changes.expandedKeys.currentValue !== this.lastChange) {
|
|
2643
|
+
this.state = new Set(changes.expandedKeys.currentValue);
|
|
2644
|
+
}
|
|
2641
2645
|
}
|
|
2642
2646
|
ngOnDestroy() {
|
|
2643
2647
|
this.subscriptions.unsubscribe();
|
|
@@ -2657,19 +2661,19 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2657
2661
|
return e.index;
|
|
2658
2662
|
}
|
|
2659
2663
|
toggleExpand({ index, dataItem, expand }) {
|
|
2660
|
-
const
|
|
2661
|
-
const
|
|
2664
|
+
const key = this.itemKey({ index, dataItem });
|
|
2665
|
+
const isExpanded = this.state.has(key);
|
|
2662
2666
|
let notify = false;
|
|
2663
|
-
if (
|
|
2664
|
-
this.
|
|
2667
|
+
if (isExpanded && !expand) {
|
|
2668
|
+
this.state.delete(key);
|
|
2665
2669
|
notify = true;
|
|
2666
2670
|
}
|
|
2667
|
-
else if (
|
|
2668
|
-
this.
|
|
2671
|
+
else if (!isExpanded && expand) {
|
|
2672
|
+
this.state.add(key);
|
|
2669
2673
|
notify = true;
|
|
2670
2674
|
}
|
|
2671
2675
|
if (notify) {
|
|
2672
|
-
this.
|
|
2676
|
+
this.notify();
|
|
2673
2677
|
}
|
|
2674
2678
|
}
|
|
2675
2679
|
handleAutoExpand({ nodes, matchCount, term }) {
|
|
@@ -2678,7 +2682,7 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2678
2682
|
}
|
|
2679
2683
|
const { maxAutoExpandResults, expandMatches: autoExpandMatches, expandedOnClear } = this.filterExpandSettings;
|
|
2680
2684
|
if (!this.isFiltered) {
|
|
2681
|
-
this.originalExpandedKeys = this.
|
|
2685
|
+
this.originalExpandedKeys = new Set(this.state);
|
|
2682
2686
|
}
|
|
2683
2687
|
const exitingFilteredState = this.isFiltered && !term;
|
|
2684
2688
|
const maxExceeded = maxAutoExpandResults !== -1 && matchCount > maxAutoExpandResults;
|
|
@@ -2686,18 +2690,18 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2686
2690
|
if (exitAutoExpandedState) {
|
|
2687
2691
|
switch (expandedOnClear) {
|
|
2688
2692
|
case "initial": {
|
|
2689
|
-
if (!sameValues(this.
|
|
2690
|
-
this.
|
|
2691
|
-
this.
|
|
2693
|
+
if (!sameValues(this.state, this.originalExpandedKeys)) {
|
|
2694
|
+
this.state = this.originalExpandedKeys;
|
|
2695
|
+
this.notify();
|
|
2692
2696
|
}
|
|
2693
2697
|
break;
|
|
2694
2698
|
}
|
|
2695
2699
|
case "all": {
|
|
2696
|
-
this.
|
|
2700
|
+
this.state = new Set(nodes.reduce((acc, rootNode) => {
|
|
2697
2701
|
this.getEveryExpandKey(acc, rootNode);
|
|
2698
2702
|
return acc;
|
|
2699
|
-
}, []);
|
|
2700
|
-
this.
|
|
2703
|
+
}, []));
|
|
2704
|
+
this.notify();
|
|
2701
2705
|
break;
|
|
2702
2706
|
}
|
|
2703
2707
|
case "unchanged": {
|
|
@@ -2705,9 +2709,9 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2705
2709
|
}
|
|
2706
2710
|
case "none":
|
|
2707
2711
|
default: {
|
|
2708
|
-
if (this.
|
|
2709
|
-
this.
|
|
2710
|
-
this.
|
|
2712
|
+
if (this.state.size !== 0) {
|
|
2713
|
+
this.state.clear();
|
|
2714
|
+
this.notify();
|
|
2711
2715
|
}
|
|
2712
2716
|
break;
|
|
2713
2717
|
}
|
|
@@ -2715,16 +2719,20 @@ let ExpandDirective = class ExpandDirective {
|
|
|
2715
2719
|
this.isFiltered = false;
|
|
2716
2720
|
return;
|
|
2717
2721
|
}
|
|
2718
|
-
const indicesToExpand = nodes.reduce((acc, rootNode) => {
|
|
2722
|
+
const indicesToExpand = new Set(nodes.reduce((acc, rootNode) => {
|
|
2719
2723
|
this.updateExpandedNodes(acc, rootNode, autoExpandMatches);
|
|
2720
2724
|
return acc;
|
|
2721
|
-
}, []);
|
|
2722
|
-
if (!sameValues(this.
|
|
2723
|
-
this.
|
|
2724
|
-
this.
|
|
2725
|
+
}, []));
|
|
2726
|
+
if (!sameValues(this.state, indicesToExpand)) {
|
|
2727
|
+
this.state = indicesToExpand;
|
|
2728
|
+
this.notify();
|
|
2725
2729
|
}
|
|
2726
2730
|
this.isFiltered = true;
|
|
2727
2731
|
}
|
|
2732
|
+
notify() {
|
|
2733
|
+
this.lastChange = Array.from(this.state);
|
|
2734
|
+
this.expandedKeysChange.emit(this.lastChange);
|
|
2735
|
+
}
|
|
2728
2736
|
};
|
|
2729
2737
|
__decorate([
|
|
2730
2738
|
Input(),
|
|
@@ -2745,9 +2753,8 @@ __decorate([
|
|
|
2745
2753
|
], ExpandDirective.prototype, "expandedKeysChange", void 0);
|
|
2746
2754
|
__decorate([
|
|
2747
2755
|
Input(),
|
|
2748
|
-
__metadata("design:type", Array)
|
|
2749
|
-
|
|
2750
|
-
], ExpandDirective.prototype, "expandedKeys", null);
|
|
2756
|
+
__metadata("design:type", Array)
|
|
2757
|
+
], ExpandDirective.prototype, "expandedKeys", void 0);
|
|
2751
2758
|
ExpandDirective = __decorate([
|
|
2752
2759
|
Directive({ selector: '[kendoTreeViewExpandable]' }),
|
|
2753
2760
|
__metadata("design:paramtypes", [ExpandableComponent])
|
|
@@ -2769,9 +2776,12 @@ let SelectDirective = class SelectDirective {
|
|
|
2769
2776
|
'multiple': (e) => this.selectMultiple(e),
|
|
2770
2777
|
'single': (e) => this.selectSingle(e)
|
|
2771
2778
|
};
|
|
2772
|
-
|
|
2779
|
+
/**
|
|
2780
|
+
* Reflectes the internal `selectedKeys` state.
|
|
2781
|
+
*/
|
|
2782
|
+
this.state = new Set();
|
|
2773
2783
|
this.subscriptions.add(this.treeView.selectionChange.subscribe(this.select.bind(this)));
|
|
2774
|
-
this.treeView.isSelected = (dataItem, index) => (this.
|
|
2784
|
+
this.treeView.isSelected = (dataItem, index) => (this.state.has(this.itemKey({ dataItem, index })));
|
|
2775
2785
|
}
|
|
2776
2786
|
/**
|
|
2777
2787
|
* @hidden
|
|
@@ -2779,16 +2789,6 @@ let SelectDirective = class SelectDirective {
|
|
|
2779
2789
|
set isSelected(value) {
|
|
2780
2790
|
this.treeView.isSelected = value;
|
|
2781
2791
|
}
|
|
2782
|
-
/**
|
|
2783
|
-
* Defines the collection that will store the selected keys
|
|
2784
|
-
* ([see example]({% slug selection_treeview %}#toc-selection-modes)).
|
|
2785
|
-
*/
|
|
2786
|
-
get selectedKeys() {
|
|
2787
|
-
return this._selectedKeys;
|
|
2788
|
-
}
|
|
2789
|
-
set selectedKeys(keys) {
|
|
2790
|
-
this._selectedKeys = keys;
|
|
2791
|
-
}
|
|
2792
2792
|
get getAriaMultiselectable() {
|
|
2793
2793
|
return this.options.mode === 'multiple';
|
|
2794
2794
|
}
|
|
@@ -2803,6 +2803,11 @@ let SelectDirective = class SelectDirective {
|
|
|
2803
2803
|
const selectionSettings = isBoolean(this.selection) ? { enabled: this.selection } : this.selection;
|
|
2804
2804
|
return Object.assign(defaultOptions, selectionSettings);
|
|
2805
2805
|
}
|
|
2806
|
+
ngOnChanges(changes) {
|
|
2807
|
+
if (isChanged('selectedKeys', changes, false) && changes.selectedKeys.currentValue !== this.lastChange) {
|
|
2808
|
+
this.state = new Set(changes.selectedKeys.currentValue);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2806
2811
|
ngOnDestroy() {
|
|
2807
2812
|
this.subscriptions.unsubscribe();
|
|
2808
2813
|
}
|
|
@@ -2827,29 +2832,29 @@ let SelectDirective = class SelectDirective {
|
|
|
2827
2832
|
}
|
|
2828
2833
|
selectSingle(node) {
|
|
2829
2834
|
const key = this.itemKey(node);
|
|
2830
|
-
if (this.
|
|
2831
|
-
|
|
2835
|
+
if (!this.state.has(key)) {
|
|
2836
|
+
this.state.clear();
|
|
2837
|
+
this.state.add(key);
|
|
2838
|
+
this.notify();
|
|
2832
2839
|
}
|
|
2833
|
-
this.selectedKeys = [key];
|
|
2834
|
-
this.notify();
|
|
2835
2840
|
}
|
|
2836
2841
|
selectMultiple(node) {
|
|
2837
2842
|
const key = this.itemKey(node);
|
|
2838
|
-
const
|
|
2839
|
-
const isSelected = idx > -1;
|
|
2843
|
+
const isSelected = this.state.has(key);
|
|
2840
2844
|
if (!isPresent(key)) {
|
|
2841
2845
|
return;
|
|
2842
2846
|
}
|
|
2843
2847
|
if (isSelected) {
|
|
2844
|
-
this.
|
|
2848
|
+
this.state.delete(key);
|
|
2845
2849
|
}
|
|
2846
2850
|
else {
|
|
2847
|
-
this.
|
|
2851
|
+
this.state.add(key);
|
|
2848
2852
|
}
|
|
2849
2853
|
this.notify();
|
|
2850
2854
|
}
|
|
2851
2855
|
notify() {
|
|
2852
|
-
this.
|
|
2856
|
+
this.lastChange = Array.from(this.state);
|
|
2857
|
+
this.selectedKeysChange.emit(this.lastChange);
|
|
2853
2858
|
}
|
|
2854
2859
|
};
|
|
2855
2860
|
__decorate([
|
|
@@ -2867,9 +2872,8 @@ __decorate([
|
|
|
2867
2872
|
], SelectDirective.prototype, "selection", void 0);
|
|
2868
2873
|
__decorate([
|
|
2869
2874
|
Input(),
|
|
2870
|
-
__metadata("design:type", Array)
|
|
2871
|
-
|
|
2872
|
-
], SelectDirective.prototype, "selectedKeys", null);
|
|
2875
|
+
__metadata("design:type", Array)
|
|
2876
|
+
], SelectDirective.prototype, "selectedKeys", void 0);
|
|
2873
2877
|
__decorate([
|
|
2874
2878
|
Output(),
|
|
2875
2879
|
__metadata("design:type", EventEmitter)
|