@progress/kendo-angular-treeview 5.4.3 → 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 +1 -1
- 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/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/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/utils.d.ts +2 -3
- package/dist/es2015/utils.js +4 -6
- package/dist/fesm2015/index.js +93 -102
- package/dist/fesm5/index.js +94 -115
- 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/utils.js +4 -6
- package/dist/systemjs/kendo-angular-treeview.js +1 -1
- package/package.json +1 -1
package/dist/fesm5/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var 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
|
};
|
|
@@ -407,17 +407,15 @@ var fetchLoadedDescendants = function (lookup, filterExpression) {
|
|
|
407
407
|
/**
|
|
408
408
|
* @hidden
|
|
409
409
|
*
|
|
410
|
-
* Compares two
|
|
410
|
+
* Compares two Seets to determine whether all unique elements in one, are present in the other.
|
|
411
411
|
* Important:
|
|
412
412
|
* - it disregards the element order
|
|
413
|
-
* - it disregards element repetitions - sameValues([1, 1, 2], [1, 2, 2]) will return true
|
|
414
413
|
*/
|
|
415
|
-
var sameValues = function (
|
|
416
|
-
if (
|
|
414
|
+
var sameValues = function (as, bs) {
|
|
415
|
+
if (as.size !== bs.size) {
|
|
417
416
|
return false;
|
|
418
417
|
}
|
|
419
|
-
|
|
420
|
-
return a.every(function (v) { return values.has(v); });
|
|
418
|
+
return Array.from(as).every(function (v) { return bs.has(v); });
|
|
421
419
|
};
|
|
422
420
|
|
|
423
421
|
var safe = function (node) { return (node || {}); };
|
|
@@ -2254,7 +2252,10 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2254
2252
|
'multiple': function (e) { return _this.checkMultiple(e); },
|
|
2255
2253
|
'single': function (e) { return _this.checkSingle(e); }
|
|
2256
2254
|
};
|
|
2257
|
-
|
|
2255
|
+
/**
|
|
2256
|
+
* Reflectes the internal `checkedKeys` state.
|
|
2257
|
+
*/
|
|
2258
|
+
this.state = new Set();
|
|
2258
2259
|
this.subscriptions.add(this.treeView.checkedChange
|
|
2259
2260
|
.subscribe(function (e) { return _this.check(e); }));
|
|
2260
2261
|
var expandedItems = [];
|
|
@@ -2273,20 +2274,6 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2273
2274
|
enumerable: true,
|
|
2274
2275
|
configurable: true
|
|
2275
2276
|
});
|
|
2276
|
-
Object.defineProperty(CheckDirective.prototype, "checkedKeys", {
|
|
2277
|
-
/**
|
|
2278
|
-
* Defines the collection that will store the checked keys
|
|
2279
|
-
* ([see example]({% slug checkboxes_treeview %})).
|
|
2280
|
-
*/
|
|
2281
|
-
get: function () {
|
|
2282
|
-
return this._checkedKeys;
|
|
2283
|
-
},
|
|
2284
|
-
set: function (keys) {
|
|
2285
|
-
this._checkedKeys = keys;
|
|
2286
|
-
},
|
|
2287
|
-
enumerable: true,
|
|
2288
|
-
configurable: true
|
|
2289
|
-
});
|
|
2290
2277
|
Object.defineProperty(CheckDirective.prototype, "options", {
|
|
2291
2278
|
get: function () {
|
|
2292
2279
|
var defaultOptions = {
|
|
@@ -2311,6 +2298,9 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2311
2298
|
this.treeView.checkboxes = this.options.enabled;
|
|
2312
2299
|
this.toggleCheckOnClick();
|
|
2313
2300
|
}
|
|
2301
|
+
if (isChanged('checkedKeys', changes, false) && changes.checkedKeys.currentValue !== this.lastChange) {
|
|
2302
|
+
this.state = new Set(changes.checkedKeys.currentValue);
|
|
2303
|
+
}
|
|
2314
2304
|
};
|
|
2315
2305
|
CheckDirective.prototype.ngOnDestroy = function () {
|
|
2316
2306
|
this.subscriptions.unsubscribe();
|
|
@@ -2320,11 +2310,11 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2320
2310
|
if (!this.checkKey) {
|
|
2321
2311
|
return this.isIndexChecked(index);
|
|
2322
2312
|
}
|
|
2323
|
-
var
|
|
2324
|
-
return
|
|
2313
|
+
var hasKey = this.state.has(this.itemKey({ dataItem: dataItem, index: index }));
|
|
2314
|
+
return hasKey ? 'checked' : 'none';
|
|
2325
2315
|
};
|
|
2326
2316
|
CheckDirective.prototype.isIndexChecked = function (index) {
|
|
2327
|
-
var checkedKeys = this.
|
|
2317
|
+
var checkedKeys = Array.from(this.state).filter(matchKey(index));
|
|
2328
2318
|
if (indexChecked(checkedKeys, index)) {
|
|
2329
2319
|
return 'checked';
|
|
2330
2320
|
}
|
|
@@ -2355,7 +2345,11 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2355
2345
|
};
|
|
2356
2346
|
CheckDirective.prototype.checkSingle = function (node) {
|
|
2357
2347
|
var key = this.itemKey(node.item);
|
|
2358
|
-
|
|
2348
|
+
var hasKey = this.state.has(key);
|
|
2349
|
+
this.state.clear();
|
|
2350
|
+
if (!hasKey) {
|
|
2351
|
+
this.state.add(key);
|
|
2352
|
+
}
|
|
2359
2353
|
this.notify();
|
|
2360
2354
|
};
|
|
2361
2355
|
CheckDirective.prototype.checkMultiple = function (node) {
|
|
@@ -2392,7 +2386,6 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2392
2386
|
if (!isPresent(currentKey)) {
|
|
2393
2387
|
return;
|
|
2394
2388
|
}
|
|
2395
|
-
var checkedKeys = new Set(this.checkedKeys);
|
|
2396
2389
|
var pendingCheck = [currentKey];
|
|
2397
2390
|
if (this.options.checkChildren) {
|
|
2398
2391
|
var descendants = fetchLoadedDescendants(node, function (_a) {
|
|
@@ -2406,63 +2399,59 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2406
2399
|
});
|
|
2407
2400
|
pendingCheck.push.apply(pendingCheck, descendants);
|
|
2408
2401
|
}
|
|
2409
|
-
var shouldCheck = !
|
|
2402
|
+
var shouldCheck = !this.state.has(currentKey);
|
|
2410
2403
|
pendingCheck.forEach(function (key) {
|
|
2411
2404
|
if (shouldCheck) {
|
|
2412
|
-
|
|
2405
|
+
_this.state.add(key);
|
|
2413
2406
|
}
|
|
2414
2407
|
else {
|
|
2415
|
-
|
|
2408
|
+
_this.state.delete(key);
|
|
2416
2409
|
}
|
|
2417
2410
|
});
|
|
2418
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
2419
2411
|
};
|
|
2420
2412
|
CheckDirective.prototype.checkParents = function (parent) {
|
|
2421
2413
|
var _this = this;
|
|
2422
2414
|
if (!isPresent(parent)) {
|
|
2423
2415
|
return;
|
|
2424
2416
|
}
|
|
2425
|
-
var checkedKeys = new Set(this.checkedKeys);
|
|
2426
2417
|
var currentParent = parent;
|
|
2427
2418
|
while (currentParent) {
|
|
2428
2419
|
var parentKey = this.itemKey(currentParent.item);
|
|
2429
|
-
var allChildrenSelected = currentParent.children.every(function (item) { return
|
|
2420
|
+
var allChildrenSelected = currentParent.children.every(function (item) { return _this.state.has(_this.itemKey(item)); });
|
|
2430
2421
|
if (allChildrenSelected) {
|
|
2431
|
-
|
|
2422
|
+
this.state.add(parentKey);
|
|
2432
2423
|
}
|
|
2433
2424
|
else {
|
|
2434
|
-
|
|
2425
|
+
this.state.delete(parentKey);
|
|
2435
2426
|
}
|
|
2436
2427
|
currentParent = currentParent.parent;
|
|
2437
2428
|
}
|
|
2438
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
2439
2429
|
};
|
|
2440
2430
|
CheckDirective.prototype.notify = function () {
|
|
2441
|
-
this.
|
|
2431
|
+
this.lastChange = Array.from(this.state);
|
|
2432
|
+
this.checkedKeysChange.emit(this.lastChange);
|
|
2442
2433
|
};
|
|
2443
2434
|
CheckDirective.prototype.addCheckedItemsChildren = function (lookups) {
|
|
2444
2435
|
var _this = this;
|
|
2445
2436
|
if (!isPresent(lookups) || lookups.length === 0) {
|
|
2446
2437
|
return;
|
|
2447
2438
|
}
|
|
2448
|
-
var initiallyCheckedItemsCount = this.
|
|
2449
|
-
var checkedKeys = new Set(this.checkedKeys);
|
|
2439
|
+
var initiallyCheckedItemsCount = this.state.size;
|
|
2450
2440
|
lookups.forEach(function (lookup) {
|
|
2451
2441
|
var itemKey = _this.itemKey(lookup.item);
|
|
2452
|
-
if (!
|
|
2442
|
+
if (!_this.state.has(itemKey)) {
|
|
2453
2443
|
return;
|
|
2454
2444
|
}
|
|
2455
2445
|
lookup.children.forEach(function (item) {
|
|
2456
2446
|
// ensure both the parent item and each child node is enabled
|
|
2457
2447
|
if (!_this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
|
|
2458
2448
|
!_this.treeView.isDisabled(item.dataItem, item.index)) {
|
|
2459
|
-
|
|
2449
|
+
_this.state.add(_this.itemKey(item));
|
|
2460
2450
|
}
|
|
2461
2451
|
});
|
|
2462
2452
|
});
|
|
2463
|
-
var hasNewlyCheckedItems = initiallyCheckedItemsCount !==
|
|
2453
|
+
var hasNewlyCheckedItems = initiallyCheckedItemsCount !== this.state.size;
|
|
2464
2454
|
if (hasNewlyCheckedItems) {
|
|
2465
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
2466
2455
|
this.zone.run(function () { return _this.notify(); });
|
|
2467
2456
|
}
|
|
2468
2457
|
};
|
|
@@ -2477,9 +2466,8 @@ var CheckDirective = /** @class */ (function () {
|
|
|
2477
2466
|
], CheckDirective.prototype, "checkKey", void 0);
|
|
2478
2467
|
__decorate([
|
|
2479
2468
|
Input(),
|
|
2480
|
-
__metadata("design:type", Array)
|
|
2481
|
-
|
|
2482
|
-
], CheckDirective.prototype, "checkedKeys", null);
|
|
2469
|
+
__metadata("design:type", Array)
|
|
2470
|
+
], CheckDirective.prototype, "checkedKeys", void 0);
|
|
2483
2471
|
__decorate([
|
|
2484
2472
|
Input('kendoTreeViewCheckable'),
|
|
2485
2473
|
__metadata("design:type", Object)
|
|
@@ -2584,8 +2572,11 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2584
2572
|
*/
|
|
2585
2573
|
this.expandedKeysChange = new EventEmitter();
|
|
2586
2574
|
this.subscriptions = new Subscription();
|
|
2587
|
-
|
|
2588
|
-
|
|
2575
|
+
/**
|
|
2576
|
+
* Reflectes the internal `expandedKeys` state.
|
|
2577
|
+
*/
|
|
2578
|
+
this.state = new Set();
|
|
2579
|
+
this.originalExpandedKeys = new Set();
|
|
2589
2580
|
this.isFiltered = false;
|
|
2590
2581
|
/**
|
|
2591
2582
|
* Fills array with the correct expand keys according to wrapper metadata.
|
|
@@ -2618,7 +2609,7 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2618
2609
|
this.subscriptions.add(this.component.filterStateChange.subscribe(this.handleAutoExpand.bind(this)));
|
|
2619
2610
|
}
|
|
2620
2611
|
this.component.isExpanded = function (dataItem, index) {
|
|
2621
|
-
return _this.
|
|
2612
|
+
return _this.state.has(_this.itemKey({ dataItem: dataItem, index: index }));
|
|
2622
2613
|
};
|
|
2623
2614
|
}
|
|
2624
2615
|
Object.defineProperty(ExpandDirective.prototype, "isExpanded", {
|
|
@@ -2639,19 +2630,11 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2639
2630
|
enumerable: true,
|
|
2640
2631
|
configurable: true
|
|
2641
2632
|
});
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
return this._expandedKeys;
|
|
2648
|
-
},
|
|
2649
|
-
set: function (keys) {
|
|
2650
|
-
this._expandedKeys = keys;
|
|
2651
|
-
},
|
|
2652
|
-
enumerable: true,
|
|
2653
|
-
configurable: true
|
|
2654
|
-
});
|
|
2633
|
+
ExpandDirective.prototype.ngOnChanges = function (changes) {
|
|
2634
|
+
if (isChanged('expandedKeys', changes, false) && changes.expandedKeys.currentValue !== this.lastChange) {
|
|
2635
|
+
this.state = new Set(changes.expandedKeys.currentValue);
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2655
2638
|
ExpandDirective.prototype.ngOnDestroy = function () {
|
|
2656
2639
|
this.subscriptions.unsubscribe();
|
|
2657
2640
|
};
|
|
@@ -2671,19 +2654,19 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2671
2654
|
};
|
|
2672
2655
|
ExpandDirective.prototype.toggleExpand = function (_a) {
|
|
2673
2656
|
var index = _a.index, dataItem = _a.dataItem, expand = _a.expand;
|
|
2674
|
-
var
|
|
2675
|
-
var
|
|
2657
|
+
var key = this.itemKey({ index: index, dataItem: dataItem });
|
|
2658
|
+
var isExpanded = this.state.has(key);
|
|
2676
2659
|
var notify = false;
|
|
2677
|
-
if (
|
|
2678
|
-
this.
|
|
2660
|
+
if (isExpanded && !expand) {
|
|
2661
|
+
this.state.delete(key);
|
|
2679
2662
|
notify = true;
|
|
2680
2663
|
}
|
|
2681
|
-
else if (
|
|
2682
|
-
this.
|
|
2664
|
+
else if (!isExpanded && expand) {
|
|
2665
|
+
this.state.add(key);
|
|
2683
2666
|
notify = true;
|
|
2684
2667
|
}
|
|
2685
2668
|
if (notify) {
|
|
2686
|
-
this.
|
|
2669
|
+
this.notify();
|
|
2687
2670
|
}
|
|
2688
2671
|
};
|
|
2689
2672
|
ExpandDirective.prototype.handleAutoExpand = function (_a) {
|
|
@@ -2694,7 +2677,7 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2694
2677
|
}
|
|
2695
2678
|
var _b = this.filterExpandSettings, maxAutoExpandResults = _b.maxAutoExpandResults, autoExpandMatches = _b.expandMatches, expandedOnClear = _b.expandedOnClear;
|
|
2696
2679
|
if (!this.isFiltered) {
|
|
2697
|
-
this.originalExpandedKeys = this.
|
|
2680
|
+
this.originalExpandedKeys = new Set(this.state);
|
|
2698
2681
|
}
|
|
2699
2682
|
var exitingFilteredState = this.isFiltered && !term;
|
|
2700
2683
|
var maxExceeded = maxAutoExpandResults !== -1 && matchCount > maxAutoExpandResults;
|
|
@@ -2702,18 +2685,18 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2702
2685
|
if (exitAutoExpandedState) {
|
|
2703
2686
|
switch (expandedOnClear) {
|
|
2704
2687
|
case "initial": {
|
|
2705
|
-
if (!sameValues(this.
|
|
2706
|
-
this.
|
|
2707
|
-
this.
|
|
2688
|
+
if (!sameValues(this.state, this.originalExpandedKeys)) {
|
|
2689
|
+
this.state = this.originalExpandedKeys;
|
|
2690
|
+
this.notify();
|
|
2708
2691
|
}
|
|
2709
2692
|
break;
|
|
2710
2693
|
}
|
|
2711
2694
|
case "all": {
|
|
2712
|
-
this.
|
|
2695
|
+
this.state = new Set(nodes.reduce(function (acc, rootNode) {
|
|
2713
2696
|
_this.getEveryExpandKey(acc, rootNode);
|
|
2714
2697
|
return acc;
|
|
2715
|
-
}, []);
|
|
2716
|
-
this.
|
|
2698
|
+
}, []));
|
|
2699
|
+
this.notify();
|
|
2717
2700
|
break;
|
|
2718
2701
|
}
|
|
2719
2702
|
case "unchanged": {
|
|
@@ -2721,9 +2704,9 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2721
2704
|
}
|
|
2722
2705
|
case "none":
|
|
2723
2706
|
default: {
|
|
2724
|
-
if (this.
|
|
2725
|
-
this.
|
|
2726
|
-
this.
|
|
2707
|
+
if (this.state.size !== 0) {
|
|
2708
|
+
this.state.clear();
|
|
2709
|
+
this.notify();
|
|
2727
2710
|
}
|
|
2728
2711
|
break;
|
|
2729
2712
|
}
|
|
@@ -2731,16 +2714,20 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2731
2714
|
this.isFiltered = false;
|
|
2732
2715
|
return;
|
|
2733
2716
|
}
|
|
2734
|
-
var indicesToExpand = nodes.reduce(function (acc, rootNode) {
|
|
2717
|
+
var indicesToExpand = new Set(nodes.reduce(function (acc, rootNode) {
|
|
2735
2718
|
_this.updateExpandedNodes(acc, rootNode, autoExpandMatches);
|
|
2736
2719
|
return acc;
|
|
2737
|
-
}, []);
|
|
2738
|
-
if (!sameValues(this.
|
|
2739
|
-
this.
|
|
2740
|
-
this.
|
|
2720
|
+
}, []));
|
|
2721
|
+
if (!sameValues(this.state, indicesToExpand)) {
|
|
2722
|
+
this.state = indicesToExpand;
|
|
2723
|
+
this.notify();
|
|
2741
2724
|
}
|
|
2742
2725
|
this.isFiltered = true;
|
|
2743
2726
|
};
|
|
2727
|
+
ExpandDirective.prototype.notify = function () {
|
|
2728
|
+
this.lastChange = Array.from(this.state);
|
|
2729
|
+
this.expandedKeysChange.emit(this.lastChange);
|
|
2730
|
+
};
|
|
2744
2731
|
__decorate([
|
|
2745
2732
|
Input(),
|
|
2746
2733
|
__metadata("design:type", Function),
|
|
@@ -2760,9 +2747,8 @@ var ExpandDirective = /** @class */ (function () {
|
|
|
2760
2747
|
], ExpandDirective.prototype, "expandedKeysChange", void 0);
|
|
2761
2748
|
__decorate([
|
|
2762
2749
|
Input(),
|
|
2763
|
-
__metadata("design:type", Array)
|
|
2764
|
-
|
|
2765
|
-
], ExpandDirective.prototype, "expandedKeys", null);
|
|
2750
|
+
__metadata("design:type", Array)
|
|
2751
|
+
], ExpandDirective.prototype, "expandedKeys", void 0);
|
|
2766
2752
|
ExpandDirective = __decorate([
|
|
2767
2753
|
Directive({ selector: '[kendoTreeViewExpandable]' }),
|
|
2768
2754
|
__metadata("design:paramtypes", [ExpandableComponent])
|
|
@@ -2787,9 +2773,12 @@ var SelectDirective = /** @class */ (function () {
|
|
|
2787
2773
|
'multiple': function (e) { return _this.selectMultiple(e); },
|
|
2788
2774
|
'single': function (e) { return _this.selectSingle(e); }
|
|
2789
2775
|
};
|
|
2790
|
-
|
|
2776
|
+
/**
|
|
2777
|
+
* Reflectes the internal `selectedKeys` state.
|
|
2778
|
+
*/
|
|
2779
|
+
this.state = new Set();
|
|
2791
2780
|
this.subscriptions.add(this.treeView.selectionChange.subscribe(this.select.bind(this)));
|
|
2792
|
-
this.treeView.isSelected = function (dataItem, index) { return (_this.
|
|
2781
|
+
this.treeView.isSelected = function (dataItem, index) { return (_this.state.has(_this.itemKey({ dataItem: dataItem, index: index }))); };
|
|
2793
2782
|
}
|
|
2794
2783
|
Object.defineProperty(SelectDirective.prototype, "isSelected", {
|
|
2795
2784
|
/**
|
|
@@ -2801,20 +2790,6 @@ var SelectDirective = /** @class */ (function () {
|
|
|
2801
2790
|
enumerable: true,
|
|
2802
2791
|
configurable: true
|
|
2803
2792
|
});
|
|
2804
|
-
Object.defineProperty(SelectDirective.prototype, "selectedKeys", {
|
|
2805
|
-
/**
|
|
2806
|
-
* Defines the collection that will store the selected keys
|
|
2807
|
-
* ([see example]({% slug selection_treeview %}#toc-selection-modes)).
|
|
2808
|
-
*/
|
|
2809
|
-
get: function () {
|
|
2810
|
-
return this._selectedKeys;
|
|
2811
|
-
},
|
|
2812
|
-
set: function (keys) {
|
|
2813
|
-
this._selectedKeys = keys;
|
|
2814
|
-
},
|
|
2815
|
-
enumerable: true,
|
|
2816
|
-
configurable: true
|
|
2817
|
-
});
|
|
2818
2793
|
Object.defineProperty(SelectDirective.prototype, "getAriaMultiselectable", {
|
|
2819
2794
|
get: function () {
|
|
2820
2795
|
return this.options.mode === 'multiple';
|
|
@@ -2837,6 +2812,11 @@ var SelectDirective = /** @class */ (function () {
|
|
|
2837
2812
|
enumerable: true,
|
|
2838
2813
|
configurable: true
|
|
2839
2814
|
});
|
|
2815
|
+
SelectDirective.prototype.ngOnChanges = function (changes) {
|
|
2816
|
+
if (isChanged('selectedKeys', changes, false) && changes.selectedKeys.currentValue !== this.lastChange) {
|
|
2817
|
+
this.state = new Set(changes.selectedKeys.currentValue);
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2840
2820
|
SelectDirective.prototype.ngOnDestroy = function () {
|
|
2841
2821
|
this.subscriptions.unsubscribe();
|
|
2842
2822
|
};
|
|
@@ -2861,29 +2841,29 @@ var SelectDirective = /** @class */ (function () {
|
|
|
2861
2841
|
};
|
|
2862
2842
|
SelectDirective.prototype.selectSingle = function (node) {
|
|
2863
2843
|
var key = this.itemKey(node);
|
|
2864
|
-
if (this.
|
|
2865
|
-
|
|
2844
|
+
if (!this.state.has(key)) {
|
|
2845
|
+
this.state.clear();
|
|
2846
|
+
this.state.add(key);
|
|
2847
|
+
this.notify();
|
|
2866
2848
|
}
|
|
2867
|
-
this.selectedKeys = [key];
|
|
2868
|
-
this.notify();
|
|
2869
2849
|
};
|
|
2870
2850
|
SelectDirective.prototype.selectMultiple = function (node) {
|
|
2871
2851
|
var key = this.itemKey(node);
|
|
2872
|
-
var
|
|
2873
|
-
var isSelected = idx > -1;
|
|
2852
|
+
var isSelected = this.state.has(key);
|
|
2874
2853
|
if (!isPresent(key)) {
|
|
2875
2854
|
return;
|
|
2876
2855
|
}
|
|
2877
2856
|
if (isSelected) {
|
|
2878
|
-
this.
|
|
2857
|
+
this.state.delete(key);
|
|
2879
2858
|
}
|
|
2880
2859
|
else {
|
|
2881
|
-
this.
|
|
2860
|
+
this.state.add(key);
|
|
2882
2861
|
}
|
|
2883
2862
|
this.notify();
|
|
2884
2863
|
};
|
|
2885
2864
|
SelectDirective.prototype.notify = function () {
|
|
2886
|
-
this.
|
|
2865
|
+
this.lastChange = Array.from(this.state);
|
|
2866
|
+
this.selectedKeysChange.emit(this.lastChange);
|
|
2887
2867
|
};
|
|
2888
2868
|
__decorate([
|
|
2889
2869
|
Input(),
|
|
@@ -2900,9 +2880,8 @@ var SelectDirective = /** @class */ (function () {
|
|
|
2900
2880
|
], SelectDirective.prototype, "selection", void 0);
|
|
2901
2881
|
__decorate([
|
|
2902
2882
|
Input(),
|
|
2903
|
-
__metadata("design:type", Array)
|
|
2904
|
-
|
|
2905
|
-
], SelectDirective.prototype, "selectedKeys", null);
|
|
2883
|
+
__metadata("design:type", Array)
|
|
2884
|
+
], SelectDirective.prototype, "selectedKeys", void 0);
|
|
2906
2885
|
__decorate([
|
|
2907
2886
|
Output(),
|
|
2908
2887
|
__metadata("design:type", EventEmitter)
|
|
@@ -10,6 +10,7 @@ var treeview_component_1 = require("./treeview.component");
|
|
|
10
10
|
var utils_1 = require("./utils");
|
|
11
11
|
var rxjs_1 = require("rxjs");
|
|
12
12
|
var operators_1 = require("rxjs/operators");
|
|
13
|
+
var kendo_angular_common_1 = require("@progress/kendo-angular-common");
|
|
13
14
|
var indexChecked = function (keys, index) { return keys.filter(function (k) { return k === index; }).length > 0; };
|
|
14
15
|
var ɵ0 = indexChecked;
|
|
15
16
|
exports.ɵ0 = ɵ0;
|
|
@@ -50,7 +51,10 @@ var CheckDirective = /** @class */ (function () {
|
|
|
50
51
|
'multiple': function (e) { return _this.checkMultiple(e); },
|
|
51
52
|
'single': function (e) { return _this.checkSingle(e); }
|
|
52
53
|
};
|
|
53
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Reflectes the internal `checkedKeys` state.
|
|
56
|
+
*/
|
|
57
|
+
this.state = new Set();
|
|
54
58
|
this.subscriptions.add(this.treeView.checkedChange
|
|
55
59
|
.subscribe(function (e) { return _this.check(e); }));
|
|
56
60
|
var expandedItems = [];
|
|
@@ -69,20 +73,6 @@ var CheckDirective = /** @class */ (function () {
|
|
|
69
73
|
enumerable: true,
|
|
70
74
|
configurable: true
|
|
71
75
|
});
|
|
72
|
-
Object.defineProperty(CheckDirective.prototype, "checkedKeys", {
|
|
73
|
-
/**
|
|
74
|
-
* Defines the collection that will store the checked keys
|
|
75
|
-
* ([see example]({% slug checkboxes_treeview %})).
|
|
76
|
-
*/
|
|
77
|
-
get: function () {
|
|
78
|
-
return this._checkedKeys;
|
|
79
|
-
},
|
|
80
|
-
set: function (keys) {
|
|
81
|
-
this._checkedKeys = keys;
|
|
82
|
-
},
|
|
83
|
-
enumerable: true,
|
|
84
|
-
configurable: true
|
|
85
|
-
});
|
|
86
76
|
Object.defineProperty(CheckDirective.prototype, "options", {
|
|
87
77
|
get: function () {
|
|
88
78
|
var defaultOptions = {
|
|
@@ -107,6 +97,9 @@ var CheckDirective = /** @class */ (function () {
|
|
|
107
97
|
this.treeView.checkboxes = this.options.enabled;
|
|
108
98
|
this.toggleCheckOnClick();
|
|
109
99
|
}
|
|
100
|
+
if (kendo_angular_common_1.isChanged('checkedKeys', changes, false) && changes.checkedKeys.currentValue !== this.lastChange) {
|
|
101
|
+
this.state = new Set(changes.checkedKeys.currentValue);
|
|
102
|
+
}
|
|
110
103
|
};
|
|
111
104
|
CheckDirective.prototype.ngOnDestroy = function () {
|
|
112
105
|
this.subscriptions.unsubscribe();
|
|
@@ -116,11 +109,11 @@ var CheckDirective = /** @class */ (function () {
|
|
|
116
109
|
if (!this.checkKey) {
|
|
117
110
|
return this.isIndexChecked(index);
|
|
118
111
|
}
|
|
119
|
-
var
|
|
120
|
-
return
|
|
112
|
+
var hasKey = this.state.has(this.itemKey({ dataItem: dataItem, index: index }));
|
|
113
|
+
return hasKey ? 'checked' : 'none';
|
|
121
114
|
};
|
|
122
115
|
CheckDirective.prototype.isIndexChecked = function (index) {
|
|
123
|
-
var checkedKeys = this.
|
|
116
|
+
var checkedKeys = Array.from(this.state).filter(matchKey(index));
|
|
124
117
|
if (indexChecked(checkedKeys, index)) {
|
|
125
118
|
return 'checked';
|
|
126
119
|
}
|
|
@@ -151,7 +144,11 @@ var CheckDirective = /** @class */ (function () {
|
|
|
151
144
|
};
|
|
152
145
|
CheckDirective.prototype.checkSingle = function (node) {
|
|
153
146
|
var key = this.itemKey(node.item);
|
|
154
|
-
|
|
147
|
+
var hasKey = this.state.has(key);
|
|
148
|
+
this.state.clear();
|
|
149
|
+
if (!hasKey) {
|
|
150
|
+
this.state.add(key);
|
|
151
|
+
}
|
|
155
152
|
this.notify();
|
|
156
153
|
};
|
|
157
154
|
CheckDirective.prototype.checkMultiple = function (node) {
|
|
@@ -188,7 +185,6 @@ var CheckDirective = /** @class */ (function () {
|
|
|
188
185
|
if (!utils_1.isPresent(currentKey)) {
|
|
189
186
|
return;
|
|
190
187
|
}
|
|
191
|
-
var checkedKeys = new Set(this.checkedKeys);
|
|
192
188
|
var pendingCheck = [currentKey];
|
|
193
189
|
if (this.options.checkChildren) {
|
|
194
190
|
var descendants = utils_1.fetchLoadedDescendants(node, function (_a) {
|
|
@@ -202,63 +198,59 @@ var CheckDirective = /** @class */ (function () {
|
|
|
202
198
|
});
|
|
203
199
|
pendingCheck.push.apply(pendingCheck, descendants);
|
|
204
200
|
}
|
|
205
|
-
var shouldCheck = !
|
|
201
|
+
var shouldCheck = !this.state.has(currentKey);
|
|
206
202
|
pendingCheck.forEach(function (key) {
|
|
207
203
|
if (shouldCheck) {
|
|
208
|
-
|
|
204
|
+
_this.state.add(key);
|
|
209
205
|
}
|
|
210
206
|
else {
|
|
211
|
-
|
|
207
|
+
_this.state.delete(key);
|
|
212
208
|
}
|
|
213
209
|
});
|
|
214
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
215
210
|
};
|
|
216
211
|
CheckDirective.prototype.checkParents = function (parent) {
|
|
217
212
|
var _this = this;
|
|
218
213
|
if (!utils_1.isPresent(parent)) {
|
|
219
214
|
return;
|
|
220
215
|
}
|
|
221
|
-
var checkedKeys = new Set(this.checkedKeys);
|
|
222
216
|
var currentParent = parent;
|
|
223
217
|
while (currentParent) {
|
|
224
218
|
var parentKey = this.itemKey(currentParent.item);
|
|
225
|
-
var allChildrenSelected = currentParent.children.every(function (item) { return
|
|
219
|
+
var allChildrenSelected = currentParent.children.every(function (item) { return _this.state.has(_this.itemKey(item)); });
|
|
226
220
|
if (allChildrenSelected) {
|
|
227
|
-
|
|
221
|
+
this.state.add(parentKey);
|
|
228
222
|
}
|
|
229
223
|
else {
|
|
230
|
-
|
|
224
|
+
this.state.delete(parentKey);
|
|
231
225
|
}
|
|
232
226
|
currentParent = currentParent.parent;
|
|
233
227
|
}
|
|
234
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
235
228
|
};
|
|
236
229
|
CheckDirective.prototype.notify = function () {
|
|
237
|
-
this.
|
|
230
|
+
this.lastChange = Array.from(this.state);
|
|
231
|
+
this.checkedKeysChange.emit(this.lastChange);
|
|
238
232
|
};
|
|
239
233
|
CheckDirective.prototype.addCheckedItemsChildren = function (lookups) {
|
|
240
234
|
var _this = this;
|
|
241
235
|
if (!utils_1.isPresent(lookups) || lookups.length === 0) {
|
|
242
236
|
return;
|
|
243
237
|
}
|
|
244
|
-
var initiallyCheckedItemsCount = this.
|
|
245
|
-
var checkedKeys = new Set(this.checkedKeys);
|
|
238
|
+
var initiallyCheckedItemsCount = this.state.size;
|
|
246
239
|
lookups.forEach(function (lookup) {
|
|
247
240
|
var itemKey = _this.itemKey(lookup.item);
|
|
248
|
-
if (!
|
|
241
|
+
if (!_this.state.has(itemKey)) {
|
|
249
242
|
return;
|
|
250
243
|
}
|
|
251
244
|
lookup.children.forEach(function (item) {
|
|
252
245
|
// ensure both the parent item and each child node is enabled
|
|
253
246
|
if (!_this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
|
|
254
247
|
!_this.treeView.isDisabled(item.dataItem, item.index)) {
|
|
255
|
-
|
|
248
|
+
_this.state.add(_this.itemKey(item));
|
|
256
249
|
}
|
|
257
250
|
});
|
|
258
251
|
});
|
|
259
|
-
var hasNewlyCheckedItems = initiallyCheckedItemsCount !==
|
|
252
|
+
var hasNewlyCheckedItems = initiallyCheckedItemsCount !== this.state.size;
|
|
260
253
|
if (hasNewlyCheckedItems) {
|
|
261
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
262
254
|
this.zone.run(function () { return _this.notify(); });
|
|
263
255
|
}
|
|
264
256
|
};
|
|
@@ -273,9 +265,8 @@ var CheckDirective = /** @class */ (function () {
|
|
|
273
265
|
], CheckDirective.prototype, "checkKey", void 0);
|
|
274
266
|
tslib_1.__decorate([
|
|
275
267
|
core_1.Input(),
|
|
276
|
-
tslib_1.__metadata("design:type", Array)
|
|
277
|
-
|
|
278
|
-
], CheckDirective.prototype, "checkedKeys", null);
|
|
268
|
+
tslib_1.__metadata("design:type", Array)
|
|
269
|
+
], CheckDirective.prototype, "checkedKeys", void 0);
|
|
279
270
|
tslib_1.__decorate([
|
|
280
271
|
core_1.Input('kendoTreeViewCheckable'),
|
|
281
272
|
tslib_1.__metadata("design:type", Object)
|