@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.
- package/dist/cdn/js/kendo-angular-treeview.js +18 -18
- package/dist/cdn/main.js +1 -1
- package/dist/es/check.directive.js +30 -39
- package/dist/es/checkbox/checkbox.component.js +17 -1
- package/dist/es/drag-and-drop/drag-and-drop-utils.js +3 -3
- package/dist/es/drag-and-drop/drag-and-drop.directive.js +2 -2
- 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/size.js +4 -0
- package/dist/es/treeview-group.component.js +7 -2
- package/dist/es/treeview-item-content.directive.js +2 -2
- package/dist/es/treeview-item.directive.js +1 -1
- package/dist/es/treeview.component.js +58 -13
- package/dist/es/utils.js +21 -11
- package/dist/es2015/check.directive.d.ts +8 -1
- package/dist/es2015/check.directive.js +30 -35
- package/dist/es2015/checkbox/checkbox.component.d.ts +6 -0
- package/dist/es2015/checkbox/checkbox.component.js +13 -1
- package/dist/es2015/drag-and-drop/drag-and-drop-utils.js +3 -3
- package/dist/es2015/drag-and-drop/drag-and-drop.directive.js +2 -2
- 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/size.d.ts +14 -0
- package/dist/es2015/size.js +4 -0
- package/dist/es2015/treeview-filter-settings.d.ts +2 -0
- package/dist/es2015/treeview-group.component.d.ts +2 -0
- package/dist/es2015/treeview-group.component.js +49 -35
- package/dist/es2015/treeview-item-content.directive.js +2 -2
- package/dist/es2015/treeview-item.directive.js +1 -1
- package/dist/es2015/treeview.component.d.ts +33 -5
- package/dist/es2015/treeview.component.js +70 -24
- package/dist/es2015/utils.d.ts +9 -4
- package/dist/es2015/utils.js +21 -11
- package/dist/fesm2015/index.js +248 -174
- package/dist/fesm5/index.js +199 -143
- package/dist/npm/check.directive.js +30 -39
- package/dist/npm/checkbox/checkbox.component.js +17 -1
- package/dist/npm/drag-and-drop/drag-and-drop-utils.js +3 -3
- package/dist/npm/drag-and-drop/drag-and-drop.directive.js +2 -2
- 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/size.js +6 -0
- package/dist/npm/treeview-group.component.js +7 -2
- package/dist/npm/treeview-item-content.directive.js +2 -2
- package/dist/npm/treeview-item.directive.js +1 -1
- package/dist/npm/treeview.component.js +57 -12
- package/dist/npm/utils.js +21 -11
- package/dist/systemjs/kendo-angular-treeview.js +1 -1
- package/package.json +9 -8
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { EventEmitter, OnDestroy } from '@angular/core';
|
|
5
|
+
import { EventEmitter, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
|
|
6
6
|
import { TreeViewComponent } from '../treeview.component';
|
|
7
7
|
import { SelectableSettings } from './selectable-settings';
|
|
8
8
|
import { Subscription } from 'rxjs';
|
|
@@ -11,7 +11,7 @@ import { TreeItem } from '../treeitem.interface';
|
|
|
11
11
|
* A directive which manages the in-memory selection state of the TreeView node
|
|
12
12
|
* ([see example]({% slug selection_treeview %})).
|
|
13
13
|
*/
|
|
14
|
-
export declare class SelectDirective implements OnDestroy {
|
|
14
|
+
export declare class SelectDirective implements OnDestroy, OnChanges {
|
|
15
15
|
protected treeView: TreeViewComponent;
|
|
16
16
|
/**
|
|
17
17
|
* @hidden
|
|
@@ -39,8 +39,16 @@ export declare class SelectDirective implements OnDestroy {
|
|
|
39
39
|
protected subscriptions: Subscription;
|
|
40
40
|
private readonly options;
|
|
41
41
|
private selectActions;
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Reflectes the internal `selectedKeys` state.
|
|
44
|
+
*/
|
|
45
|
+
private state;
|
|
46
|
+
/**
|
|
47
|
+
* Holds the last emitted `selectedKeys` collection.
|
|
48
|
+
*/
|
|
49
|
+
private lastChange;
|
|
43
50
|
constructor(treeView: TreeViewComponent);
|
|
51
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
44
52
|
ngOnDestroy(): void;
|
|
45
53
|
protected itemKey(e: any): any;
|
|
46
54
|
protected select(e: any): void;
|
|
@@ -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 %})).
|
|
@@ -23,9 +24,12 @@ let SelectDirective = class SelectDirective {
|
|
|
23
24
|
'multiple': (e) => this.selectMultiple(e),
|
|
24
25
|
'single': (e) => this.selectSingle(e)
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Reflectes the internal `selectedKeys` state.
|
|
29
|
+
*/
|
|
30
|
+
this.state = new Set();
|
|
27
31
|
this.subscriptions.add(this.treeView.selectionChange.subscribe(this.select.bind(this)));
|
|
28
|
-
this.treeView.isSelected = (dataItem, index) => (this.
|
|
32
|
+
this.treeView.isSelected = (dataItem, index) => (this.state.has(this.itemKey({ dataItem, index })));
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
35
|
* @hidden
|
|
@@ -33,16 +37,6 @@ let SelectDirective = class SelectDirective {
|
|
|
33
37
|
set isSelected(value) {
|
|
34
38
|
this.treeView.isSelected = value;
|
|
35
39
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Defines the collection that will store the selected keys
|
|
38
|
-
* ([see example]({% slug selection_treeview %}#toc-selection-modes)).
|
|
39
|
-
*/
|
|
40
|
-
get selectedKeys() {
|
|
41
|
-
return this._selectedKeys;
|
|
42
|
-
}
|
|
43
|
-
set selectedKeys(keys) {
|
|
44
|
-
this._selectedKeys = keys;
|
|
45
|
-
}
|
|
46
40
|
get getAriaMultiselectable() {
|
|
47
41
|
return this.options.mode === 'multiple';
|
|
48
42
|
}
|
|
@@ -57,6 +51,11 @@ let SelectDirective = class SelectDirective {
|
|
|
57
51
|
const selectionSettings = isBoolean(this.selection) ? { enabled: this.selection } : this.selection;
|
|
58
52
|
return Object.assign(defaultOptions, selectionSettings);
|
|
59
53
|
}
|
|
54
|
+
ngOnChanges(changes) {
|
|
55
|
+
if (isChanged('selectedKeys', changes, false) && changes.selectedKeys.currentValue !== this.lastChange) {
|
|
56
|
+
this.state = new Set(changes.selectedKeys.currentValue);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
60
59
|
ngOnDestroy() {
|
|
61
60
|
this.subscriptions.unsubscribe();
|
|
62
61
|
}
|
|
@@ -81,29 +80,29 @@ let SelectDirective = class SelectDirective {
|
|
|
81
80
|
}
|
|
82
81
|
selectSingle(node) {
|
|
83
82
|
const key = this.itemKey(node);
|
|
84
|
-
if (this.
|
|
85
|
-
|
|
83
|
+
if (!this.state.has(key)) {
|
|
84
|
+
this.state.clear();
|
|
85
|
+
this.state.add(key);
|
|
86
|
+
this.notify();
|
|
86
87
|
}
|
|
87
|
-
this.selectedKeys = [key];
|
|
88
|
-
this.notify();
|
|
89
88
|
}
|
|
90
89
|
selectMultiple(node) {
|
|
91
90
|
const key = this.itemKey(node);
|
|
92
|
-
const
|
|
93
|
-
const isSelected = idx > -1;
|
|
91
|
+
const isSelected = this.state.has(key);
|
|
94
92
|
if (!isPresent(key)) {
|
|
95
93
|
return;
|
|
96
94
|
}
|
|
97
95
|
if (isSelected) {
|
|
98
|
-
this.
|
|
96
|
+
this.state.delete(key);
|
|
99
97
|
}
|
|
100
98
|
else {
|
|
101
|
-
this.
|
|
99
|
+
this.state.add(key);
|
|
102
100
|
}
|
|
103
101
|
this.notify();
|
|
104
102
|
}
|
|
105
103
|
notify() {
|
|
106
|
-
this.
|
|
104
|
+
this.lastChange = Array.from(this.state);
|
|
105
|
+
this.selectedKeysChange.emit(this.lastChange);
|
|
107
106
|
}
|
|
108
107
|
};
|
|
109
108
|
tslib_1.__decorate([
|
|
@@ -121,9 +120,8 @@ tslib_1.__decorate([
|
|
|
121
120
|
], SelectDirective.prototype, "selection", void 0);
|
|
122
121
|
tslib_1.__decorate([
|
|
123
122
|
Input(),
|
|
124
|
-
tslib_1.__metadata("design:type", Array)
|
|
125
|
-
|
|
126
|
-
], SelectDirective.prototype, "selectedKeys", null);
|
|
123
|
+
tslib_1.__metadata("design:type", Array)
|
|
124
|
+
], SelectDirective.prototype, "selectedKeys", void 0);
|
|
127
125
|
tslib_1.__decorate([
|
|
128
126
|
Output(),
|
|
129
127
|
tslib_1.__metadata("design:type", EventEmitter)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* Represents the possible size options of the TreeView.
|
|
7
|
+
*
|
|
8
|
+
* The possible values are:
|
|
9
|
+
* - `'small'`
|
|
10
|
+
* - `'medium'`
|
|
11
|
+
* - `'large'`
|
|
12
|
+
* - `null`
|
|
13
|
+
*/
|
|
14
|
+
export declare type TreeViewSize = 'small' | 'medium' | 'large';
|
|
@@ -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
|
+
*-------------------------------------------------------------------------------------------*/
|
|
@@ -32,6 +32,8 @@ export interface TreeViewFilterSettings {
|
|
|
32
32
|
* Determines the behavior of the filtering algorithm.
|
|
33
33
|
* - `"strict"`—does not show child nodes of filter matches. Instead, only matching nodes themselves are displayed.
|
|
34
34
|
* - `"lenient"`—all child nodes of each filter match are included in the filter results.
|
|
35
|
+
*
|
|
36
|
+
* The default mode is `"lenient"`
|
|
35
37
|
*/
|
|
36
38
|
mode?: "strict" | "lenient";
|
|
37
39
|
}
|
|
@@ -13,6 +13,7 @@ import { LoadingNotificationService } from './loading-notification.service';
|
|
|
13
13
|
import { CheckedState } from './checkbox/checked-state';
|
|
14
14
|
import { Observable } from 'rxjs';
|
|
15
15
|
import { DataChangeNotificationService } from './data-change-notification.service';
|
|
16
|
+
import { TreeViewSize } from './size';
|
|
16
17
|
/**
|
|
17
18
|
* @hidden
|
|
18
19
|
*/
|
|
@@ -41,6 +42,7 @@ export declare class TreeViewGroupComponent implements OnChanges, OnInit, OnDest
|
|
|
41
42
|
nodeTemplateRef: TemplateRef<any>;
|
|
42
43
|
loadMoreButtonTemplateRef: TemplateRef<any>;
|
|
43
44
|
loadMoreService: LoadMoreService;
|
|
45
|
+
size: TreeViewSize;
|
|
44
46
|
initialNodesLoaded: boolean;
|
|
45
47
|
loadingMoreNodes: boolean;
|
|
46
48
|
readonly moreNodesAvailable: boolean;
|
|
@@ -33,6 +33,7 @@ let TreeViewGroupComponent = class TreeViewGroupComponent {
|
|
|
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 = [];
|
|
@@ -233,7 +234,7 @@ let TreeViewGroupComponent = class TreeViewGroupComponent {
|
|
|
233
234
|
}
|
|
234
235
|
};
|
|
235
236
|
tslib_1.__decorate([
|
|
236
|
-
HostBinding("class.k-group"),
|
|
237
|
+
HostBinding("class.k-treeview-group"),
|
|
237
238
|
tslib_1.__metadata("design:type", Boolean)
|
|
238
239
|
], TreeViewGroupComponent.prototype, "kGroupClass", void 0);
|
|
239
240
|
tslib_1.__decorate([
|
|
@@ -296,6 +297,10 @@ tslib_1.__decorate([
|
|
|
296
297
|
Input(),
|
|
297
298
|
tslib_1.__metadata("design:type", Object)
|
|
298
299
|
], TreeViewGroupComponent.prototype, "loadMoreService", void 0);
|
|
300
|
+
tslib_1.__decorate([
|
|
301
|
+
Input(),
|
|
302
|
+
tslib_1.__metadata("design:type", String)
|
|
303
|
+
], TreeViewGroupComponent.prototype, "size", void 0);
|
|
299
304
|
tslib_1.__decorate([
|
|
300
305
|
Input(),
|
|
301
306
|
tslib_1.__metadata("design:type", Function)
|
|
@@ -342,7 +347,7 @@ TreeViewGroupComponent = tslib_1.__decorate([
|
|
|
342
347
|
template: `
|
|
343
348
|
<li
|
|
344
349
|
*ngFor="let node of data; let index = index; trackBy: trackBy"
|
|
345
|
-
class="k-
|
|
350
|
+
class="k-treeview-item"
|
|
346
351
|
[class.k-display-none]="!isVisible(node, nodeIndex(index))"
|
|
347
352
|
kendoTreeViewItem
|
|
348
353
|
[attr.aria-setsize]="totalNodesCount"
|
|
@@ -361,18 +366,23 @@ TreeViewGroupComponent = tslib_1.__decorate([
|
|
|
361
366
|
[isSelected]="isSelected(node, nodeIndex(index))"
|
|
362
367
|
[attr.data-treeindex]="nodeIndex(index)"
|
|
363
368
|
>
|
|
364
|
-
<div class="k-mid">
|
|
369
|
+
<div class="k-treeview-mid">
|
|
365
370
|
<span
|
|
366
|
-
class="k-
|
|
367
|
-
[class.k-i-collapse]="isExpanded(node, nodeIndex(index))"
|
|
368
|
-
[class.k-i-expand]="!isExpanded(node, nodeIndex(index))"
|
|
371
|
+
class="k-treeview-toggle"
|
|
369
372
|
[kendoTreeViewLoading]="nodeIndex(index)"
|
|
370
373
|
(click)="expandNode(nodeIndex(index), node, !isExpanded(node, nodeIndex(index)))"
|
|
371
374
|
*ngIf="expandIcons && hasChildren(node)"
|
|
372
375
|
>
|
|
376
|
+
<span
|
|
377
|
+
class="k-icon"
|
|
378
|
+
[class.k-i-collapse]="isExpanded(node, nodeIndex(index))"
|
|
379
|
+
[class.k-i-expand]="!isExpanded(node, nodeIndex(index))"
|
|
380
|
+
>
|
|
381
|
+
</span>
|
|
373
382
|
</span>
|
|
374
383
|
<kendo-checkbox
|
|
375
384
|
*ngIf="checkboxes"
|
|
385
|
+
[size]="size"
|
|
376
386
|
[node]="node"
|
|
377
387
|
[index]="nodeIndex(index)"
|
|
378
388
|
[isChecked]="isChecked"
|
|
@@ -385,24 +395,26 @@ TreeViewGroupComponent = tslib_1.__decorate([
|
|
|
385
395
|
[index]="nodeIndex(index)"
|
|
386
396
|
[initialSelection]="isSelected(node, nodeIndex(index))"
|
|
387
397
|
[isSelected]="isSelected"
|
|
388
|
-
class="k-
|
|
398
|
+
class="k-treeview-leaf"
|
|
389
399
|
[style.touch-action]="touchActions ? '' : 'none'"
|
|
390
400
|
>
|
|
391
|
-
<
|
|
392
|
-
<ng-container
|
|
393
|
-
<ng-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
+
<span class="k-treeview-leaf-text">
|
|
402
|
+
<ng-container [ngSwitch]="hasTemplate">
|
|
403
|
+
<ng-container *ngSwitchCase="true">
|
|
404
|
+
<ng-template
|
|
405
|
+
[ngTemplateOutlet]="nodeTemplateRef"
|
|
406
|
+
[ngTemplateOutletContext]="{
|
|
407
|
+
$implicit: node,
|
|
408
|
+
index: nodeIndex(index)
|
|
409
|
+
}"
|
|
410
|
+
>
|
|
411
|
+
</ng-template>
|
|
412
|
+
</ng-container>
|
|
413
|
+
<ng-container *ngSwitchDefault>
|
|
414
|
+
{{nodeText(node)}}
|
|
415
|
+
</ng-container>
|
|
401
416
|
</ng-container>
|
|
402
|
-
|
|
403
|
-
{{nodeText(node)}}
|
|
404
|
-
</ng-container>
|
|
405
|
-
</ng-container>
|
|
417
|
+
</span>
|
|
406
418
|
</span>
|
|
407
419
|
</div>
|
|
408
420
|
<ul
|
|
@@ -436,7 +448,7 @@ TreeViewGroupComponent = tslib_1.__decorate([
|
|
|
436
448
|
</li>
|
|
437
449
|
<li
|
|
438
450
|
*ngIf="initialNodesLoaded && moreNodesAvailable"
|
|
439
|
-
class="k-
|
|
451
|
+
class="k-treeview-item"
|
|
440
452
|
[class.k-treeview-load-more-checkboxes-container]="checkboxes"
|
|
441
453
|
kendoTreeViewItem
|
|
442
454
|
role="button"
|
|
@@ -448,29 +460,31 @@ TreeViewGroupComponent = tslib_1.__decorate([
|
|
|
448
460
|
[parentIndex]="parentIndex"
|
|
449
461
|
[attr.data-treeindex]="loadMoreButtonIndex"
|
|
450
462
|
>
|
|
451
|
-
<div class="k-mid">
|
|
463
|
+
<div class="k-treeview-mid">
|
|
452
464
|
<span
|
|
453
465
|
*ngIf="loadingMoreNodes"
|
|
454
466
|
class="k-icon k-i-loading k-i-expand"
|
|
455
467
|
>
|
|
456
468
|
</span>
|
|
457
469
|
<span
|
|
458
|
-
class="k-
|
|
470
|
+
class="k-treeview-leaf k-treeview-load-more-button"
|
|
459
471
|
[attr.data-treeindex]="loadMoreButtonIndex"
|
|
460
472
|
kendoTreeViewItemContent
|
|
461
473
|
[index]="loadMoreButtonIndex"
|
|
462
474
|
>
|
|
463
|
-
<
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
475
|
+
<span class="k-treeview-leaf-text">
|
|
476
|
+
<ng-template
|
|
477
|
+
*ngIf="loadMoreButtonTemplateRef"
|
|
478
|
+
[ngTemplateOutlet]="loadMoreButtonTemplateRef"
|
|
479
|
+
[ngTemplateOutletContext]="{
|
|
480
|
+
index: loadMoreButtonIndex
|
|
481
|
+
}"
|
|
482
|
+
>
|
|
483
|
+
</ng-template>
|
|
484
|
+
<ng-container *ngIf="!loadMoreButtonTemplateRef">
|
|
485
|
+
Load more
|
|
486
|
+
</ng-container>
|
|
487
|
+
</span>
|
|
474
488
|
</span>
|
|
475
489
|
</div>
|
|
476
490
|
</li>
|
|
@@ -45,10 +45,10 @@ let TreeViewItemContentDirective = class TreeViewItemContentDirective {
|
|
|
45
45
|
this.subscriptions.unsubscribe();
|
|
46
46
|
}
|
|
47
47
|
updateFocusClass() {
|
|
48
|
-
this.render(this.navigationService.isActive(this.index), 'k-
|
|
48
|
+
this.render(this.navigationService.isActive(this.index), 'k-focus');
|
|
49
49
|
}
|
|
50
50
|
updateSelectionClass(selected) {
|
|
51
|
-
this.render(selected, 'k-
|
|
51
|
+
this.render(selected, 'k-selected');
|
|
52
52
|
}
|
|
53
53
|
render(addClass, className) {
|
|
54
54
|
const action = addClass ? 'addClass' : 'removeClass';
|
|
@@ -181,7 +181,7 @@ let TreeViewItemDirective = class TreeViewItemDirective {
|
|
|
181
181
|
this.setAttribute('aria-checked', this.checkable ? this.ariaChecked : null);
|
|
182
182
|
}
|
|
183
183
|
setDisabledClass() {
|
|
184
|
-
this.setClass('k-
|
|
184
|
+
this.setClass('k-disabled', this.isDisabled);
|
|
185
185
|
}
|
|
186
186
|
setClass(className, toggle) {
|
|
187
187
|
const action = toggle ? 'addClass' : 'removeClass';
|
|
@@ -21,13 +21,15 @@ import { TreeViewLookupService } from './treeview-lookup.service';
|
|
|
21
21
|
import { LoadMoreService } from './load-more/load-more.service';
|
|
22
22
|
import { TreeItemDropEvent, TreeItemAddRemoveArgs, EditService, TreeItemDragEvent, TreeItemDragStartEvent } from './drag-and-drop/models';
|
|
23
23
|
import { FilterState } from './filter-state.interface';
|
|
24
|
+
import { TreeViewSize } from './size';
|
|
24
25
|
/**
|
|
25
26
|
* Represents the [Kendo UI TreeView component for Angular]({% slug overview_treeview %}).
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
28
|
-
* {% meta height:
|
|
29
|
-
* {% embed_file
|
|
30
|
-
* {% embed_file
|
|
29
|
+
* {% meta height:450 %}
|
|
30
|
+
* {% embed_file get-started/app.component.ts preview %}
|
|
31
|
+
* {% embed_file get-started/app.module.ts %}
|
|
32
|
+
* {% embed_file shared/main.ts %}
|
|
31
33
|
* {% endmeta %}
|
|
32
34
|
*/
|
|
33
35
|
export declare class TreeViewComponent implements OnChanges, OnInit, OnDestroy, DataBoundComponent {
|
|
@@ -145,18 +147,30 @@ export declare class TreeViewComponent implements OnChanges, OnInit, OnDestroy,
|
|
|
145
147
|
nodeDblClick: EventEmitter<NodeClickEvent>;
|
|
146
148
|
/**
|
|
147
149
|
* @hidden
|
|
150
|
+
*
|
|
151
|
+
* Queries the template for a node template declaration.
|
|
152
|
+
* Ignored if a `[nodeTemplate]` value is explicitly provided.
|
|
148
153
|
*/
|
|
149
|
-
|
|
154
|
+
nodeTemplateQuery: NodeTemplateDirective;
|
|
150
155
|
/**
|
|
151
156
|
* @hidden
|
|
157
|
+
*
|
|
158
|
+
* Defines the template for each node.
|
|
159
|
+
* Takes precedence over nested templates in the TreeView tag.
|
|
152
160
|
*/
|
|
153
161
|
nodeTemplateRef: NodeTemplateDirective;
|
|
154
162
|
/**
|
|
155
163
|
* @hidden
|
|
164
|
+
*
|
|
165
|
+
* Queries the template for a load-more button template declaration.
|
|
166
|
+
* Ignored if a `[loadMoreButtonTemplate]` value is explicitly provided.
|
|
156
167
|
*/
|
|
157
|
-
|
|
168
|
+
loadMoreButtonTemplateQuery: LoadMoreButtonTemplateDirective;
|
|
158
169
|
/**
|
|
159
170
|
* @hidden
|
|
171
|
+
*
|
|
172
|
+
* Defines the template for each load-more button.
|
|
173
|
+
* Takes precedence over nested templates in the TreeView tag.
|
|
160
174
|
*/
|
|
161
175
|
loadMoreButtonTemplateRef: LoadMoreButtonTemplateDirective;
|
|
162
176
|
/**
|
|
@@ -253,6 +267,17 @@ export declare class TreeViewComponent implements OnChanges, OnInit, OnDestroy,
|
|
|
253
267
|
* Sets an initial value of the built-in input element used for filtering.
|
|
254
268
|
*/
|
|
255
269
|
filter: string;
|
|
270
|
+
/**
|
|
271
|
+
* Sets the size of the component.
|
|
272
|
+
*
|
|
273
|
+
* The possible values are:
|
|
274
|
+
* * `'small'`
|
|
275
|
+
* * `'medium'` (default)
|
|
276
|
+
* * `'large'`
|
|
277
|
+
* * `null`
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
size: TreeViewSize;
|
|
256
281
|
/**
|
|
257
282
|
* @hidden
|
|
258
283
|
*/
|
|
@@ -272,6 +297,9 @@ export declare class TreeViewComponent implements OnChanges, OnInit, OnDestroy,
|
|
|
272
297
|
private _isExpanded;
|
|
273
298
|
private _isSelected;
|
|
274
299
|
private _hasChildren;
|
|
300
|
+
private _nodeTemplateRef;
|
|
301
|
+
private _loadMoreButtonTemplateRef;
|
|
302
|
+
private _size;
|
|
275
303
|
private subscriptions;
|
|
276
304
|
private domSubscriptions;
|
|
277
305
|
constructor(element: ElementRef<HTMLElement>, changeDetectorRef: ChangeDetectorRef, expandService: ExpandStateService, navigationService: NavigationService, nodeChildrenService: NodeChildrenService, selectionService: SelectionService, treeViewLookupService: TreeViewLookupService, ngZone: NgZone, renderer: Renderer2, dataChangeNotification: DataChangeNotificationService, localization: LocalizationService);
|
|
@@ -22,7 +22,7 @@ import { DataBoundComponent } from './data-bound-component';
|
|
|
22
22
|
import { ExpandableComponent } from './expandable-component';
|
|
23
23
|
import { SelectionService } from './selection/selection.service';
|
|
24
24
|
import { TreeViewLookupService } from './treeview-lookup.service';
|
|
25
|
-
import { closestNode, focusableNode, hasParent, isContent, isFocusable, match, nodeId, isLoadMoreButton, isPresent, nodeIndex, buildTreeItem } from './utils';
|
|
25
|
+
import { closestNode, focusableNode, hasParent, isContent, isFocusable, match, nodeId, isLoadMoreButton, isPresent, nodeIndex, buildTreeItem, getSizeClass } from './utils';
|
|
26
26
|
const LOAD_MORE_DOC_LINK = 'http://www.telerik.com/kendo-angular-ui/components/treeview/load-more-button/';
|
|
27
27
|
const providers = [
|
|
28
28
|
ExpandStateService,
|
|
@@ -52,9 +52,10 @@ const providers = [
|
|
|
52
52
|
* Represents the [Kendo UI TreeView component for Angular]({% slug overview_treeview %}).
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
|
-
* {% meta height:
|
|
56
|
-
* {% embed_file
|
|
57
|
-
* {% embed_file
|
|
55
|
+
* {% meta height:450 %}
|
|
56
|
+
* {% embed_file get-started/app.component.ts preview %}
|
|
57
|
+
* {% embed_file get-started/app.module.ts %}
|
|
58
|
+
* {% embed_file shared/main.ts %}
|
|
58
59
|
* {% endmeta %}
|
|
59
60
|
*/
|
|
60
61
|
let TreeViewComponent = class TreeViewComponent {
|
|
@@ -228,6 +229,7 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
228
229
|
this.isActive = false;
|
|
229
230
|
this.data = new BehaviorSubject([]);
|
|
230
231
|
this._animate = true;
|
|
232
|
+
this._size = 'medium';
|
|
231
233
|
this.subscriptions = new Subscription();
|
|
232
234
|
this.domSubscriptions = [];
|
|
233
235
|
validatePackage(packageMetadata);
|
|
@@ -247,15 +249,27 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
247
249
|
}
|
|
248
250
|
/**
|
|
249
251
|
* @hidden
|
|
252
|
+
*
|
|
253
|
+
* Defines the template for each node.
|
|
254
|
+
* Takes precedence over nested templates in the TreeView tag.
|
|
250
255
|
*/
|
|
251
256
|
set nodeTemplateRef(template) {
|
|
252
|
-
this.
|
|
257
|
+
this._nodeTemplateRef = template;
|
|
258
|
+
}
|
|
259
|
+
get nodeTemplateRef() {
|
|
260
|
+
return this._nodeTemplateRef || this.nodeTemplateQuery;
|
|
253
261
|
}
|
|
254
262
|
/**
|
|
255
263
|
* @hidden
|
|
264
|
+
*
|
|
265
|
+
* Defines the template for each load-more button.
|
|
266
|
+
* Takes precedence over nested templates in the TreeView tag.
|
|
256
267
|
*/
|
|
257
268
|
set loadMoreButtonTemplateRef(template) {
|
|
258
|
-
this.
|
|
269
|
+
this._loadMoreButtonTemplateRef = template;
|
|
270
|
+
}
|
|
271
|
+
get loadMoreButtonTemplateRef() {
|
|
272
|
+
return this._loadMoreButtonTemplateRef || this.loadMoreButtonTemplateQuery;
|
|
259
273
|
}
|
|
260
274
|
/**
|
|
261
275
|
* The nodes which will be displayed by the TreeView
|
|
@@ -311,6 +325,26 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
311
325
|
this._isSelected = callback;
|
|
312
326
|
this.selectable = Boolean(this._isSelected);
|
|
313
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Sets the size of the component.
|
|
330
|
+
*
|
|
331
|
+
* The possible values are:
|
|
332
|
+
* * `'small'`
|
|
333
|
+
* * `'medium'` (default)
|
|
334
|
+
* * `'large'`
|
|
335
|
+
* * `null`
|
|
336
|
+
*
|
|
337
|
+
*/
|
|
338
|
+
set size(size) {
|
|
339
|
+
this.renderer.removeClass(this.element.nativeElement, getSizeClass('treeview', this.size));
|
|
340
|
+
if (size) {
|
|
341
|
+
this.renderer.addClass(this.element.nativeElement, getSizeClass('treeview', size));
|
|
342
|
+
}
|
|
343
|
+
this._size = size;
|
|
344
|
+
}
|
|
345
|
+
get size() {
|
|
346
|
+
return this._size;
|
|
347
|
+
}
|
|
314
348
|
ngOnChanges(changes) {
|
|
315
349
|
this.navigationService.navigable = Boolean(this.navigable);
|
|
316
350
|
// TODO: should react to changes.loadOnDemand as well - should preload the data or clear the already cached items
|
|
@@ -345,6 +379,9 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
345
379
|
this.attachDomHandlers();
|
|
346
380
|
});
|
|
347
381
|
}
|
|
382
|
+
if (this.size) {
|
|
383
|
+
this.renderer.addClass(this.element.nativeElement, getSizeClass('treeview', this.size));
|
|
384
|
+
}
|
|
348
385
|
}
|
|
349
386
|
/**
|
|
350
387
|
* Blurs the focused TreeView item.
|
|
@@ -501,7 +538,7 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
501
538
|
return;
|
|
502
539
|
}
|
|
503
540
|
const index = nodeId(closestNode(target));
|
|
504
|
-
// the disabled check is probably not needed due to the k-
|
|
541
|
+
// the disabled check is probably not needed due to the k-disabled styles
|
|
505
542
|
if (!index || this.navigationService.isDisabled(index)) {
|
|
506
543
|
return;
|
|
507
544
|
}
|
|
@@ -557,7 +594,6 @@ let TreeViewComponent = class TreeViewComponent {
|
|
|
557
594
|
}
|
|
558
595
|
};
|
|
559
596
|
tslib_1.__decorate([
|
|
560
|
-
HostBinding("class.k-widget"),
|
|
561
597
|
HostBinding("class.k-treeview"),
|
|
562
598
|
tslib_1.__metadata("design:type", Boolean)
|
|
563
599
|
], TreeViewComponent.prototype, "classNames", void 0);
|
|
@@ -653,18 +689,18 @@ tslib_1.__decorate([
|
|
|
653
689
|
tslib_1.__metadata("design:type", EventEmitter)
|
|
654
690
|
], TreeViewComponent.prototype, "nodeDblClick", void 0);
|
|
655
691
|
tslib_1.__decorate([
|
|
656
|
-
ContentChild(NodeTemplateDirective, { static:
|
|
692
|
+
ContentChild(NodeTemplateDirective, { static: false }),
|
|
657
693
|
tslib_1.__metadata("design:type", NodeTemplateDirective)
|
|
658
|
-
], TreeViewComponent.prototype, "
|
|
694
|
+
], TreeViewComponent.prototype, "nodeTemplateQuery", void 0);
|
|
659
695
|
tslib_1.__decorate([
|
|
660
696
|
Input('nodeTemplate'),
|
|
661
697
|
tslib_1.__metadata("design:type", NodeTemplateDirective),
|
|
662
698
|
tslib_1.__metadata("design:paramtypes", [NodeTemplateDirective])
|
|
663
699
|
], TreeViewComponent.prototype, "nodeTemplateRef", null);
|
|
664
700
|
tslib_1.__decorate([
|
|
665
|
-
ContentChild(LoadMoreButtonTemplateDirective, { static:
|
|
701
|
+
ContentChild(LoadMoreButtonTemplateDirective, { static: false }),
|
|
666
702
|
tslib_1.__metadata("design:type", LoadMoreButtonTemplateDirective)
|
|
667
|
-
], TreeViewComponent.prototype, "
|
|
703
|
+
], TreeViewComponent.prototype, "loadMoreButtonTemplateQuery", void 0);
|
|
668
704
|
tslib_1.__decorate([
|
|
669
705
|
Input('loadMoreButtonTemplate'),
|
|
670
706
|
tslib_1.__metadata("design:type", LoadMoreButtonTemplateDirective),
|
|
@@ -731,6 +767,11 @@ tslib_1.__decorate([
|
|
|
731
767
|
Input(),
|
|
732
768
|
tslib_1.__metadata("design:type", String)
|
|
733
769
|
], TreeViewComponent.prototype, "filter", void 0);
|
|
770
|
+
tslib_1.__decorate([
|
|
771
|
+
Input(),
|
|
772
|
+
tslib_1.__metadata("design:type", String),
|
|
773
|
+
tslib_1.__metadata("design:paramtypes", [String])
|
|
774
|
+
], TreeViewComponent.prototype, "size", null);
|
|
734
775
|
TreeViewComponent = tslib_1.__decorate([
|
|
735
776
|
Component({
|
|
736
777
|
changeDetection: ChangeDetectionStrategy.Default,
|
|
@@ -738,21 +779,26 @@ TreeViewComponent = tslib_1.__decorate([
|
|
|
738
779
|
providers: providers,
|
|
739
780
|
selector: 'kendo-treeview',
|
|
740
781
|
template: `
|
|
741
|
-
<
|
|
742
|
-
|
|
782
|
+
<span
|
|
783
|
+
class="k-treeview-filter"
|
|
743
784
|
*ngIf="filterable"
|
|
744
|
-
[value]="filter"
|
|
745
|
-
[clearButton]="true"
|
|
746
|
-
(valueChange)="filterChange.emit($event)"
|
|
747
|
-
[placeholder]="filterInputPlaceholder"
|
|
748
785
|
>
|
|
749
|
-
<
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
786
|
+
<kendo-textbox
|
|
787
|
+
[size]="size"
|
|
788
|
+
[value]="filter"
|
|
789
|
+
[clearButton]="true"
|
|
790
|
+
(valueChange)="filterChange.emit($event)"
|
|
791
|
+
[placeholder]="filterInputPlaceholder"
|
|
792
|
+
>
|
|
793
|
+
<ng-template kendoTextBoxPrefixTemplate>
|
|
794
|
+
<span class="k-input-icon k-icon k-i-search"></span>
|
|
795
|
+
</ng-template>
|
|
796
|
+
</kendo-textbox>
|
|
797
|
+
</span>
|
|
753
798
|
<ul class="k-treeview-lines"
|
|
754
799
|
kendoTreeViewGroup
|
|
755
800
|
role="group"
|
|
801
|
+
[size]="size"
|
|
756
802
|
[loadOnDemand]="loadOnDemand"
|
|
757
803
|
[checkboxes]="checkboxes"
|
|
758
804
|
[expandIcons]="expandIcons"
|
|
@@ -765,8 +811,8 @@ TreeViewComponent = tslib_1.__decorate([
|
|
|
765
811
|
[isExpanded]="isExpanded"
|
|
766
812
|
[isSelected]="isSelected"
|
|
767
813
|
[isVisible]="isVisible"
|
|
768
|
-
[nodeTemplateRef]="
|
|
769
|
-
[loadMoreButtonTemplateRef]="
|
|
814
|
+
[nodeTemplateRef]="nodeTemplateRef?.templateRef"
|
|
815
|
+
[loadMoreButtonTemplateRef]="loadMoreButtonTemplateRef?.templateRef"
|
|
770
816
|
[textField]="textField"
|
|
771
817
|
[nodes]="fetchNodes"
|
|
772
818
|
[loadMoreService]="loadMoreService"
|