@progress/kendo-angular-treeview 7.0.2-dev.202205261520 → 7.1.0-dev.202206151232

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.
@@ -64,6 +64,7 @@ export declare class CheckDirective implements OnChanges, OnDestroy {
64
64
  private unsubscribeClick;
65
65
  private checkNode;
66
66
  private checkParents;
67
+ private allChildrenSelected;
67
68
  private notify;
68
69
  private addCheckedItemsChildren;
69
70
  static ɵfac: i0.ɵɵFactoryDeclaration<CheckDirective, never>;
@@ -45,4 +45,11 @@ export interface CheckableSettings {
45
45
  * Defaults to `false`.
46
46
  */
47
47
  checkOnClick?: boolean;
48
+ /**
49
+ * Determines whether disabled children will be checked if their parent is checked.
50
+ * Defaults to `false`
51
+ *
52
+ * > The option works only together with the multiple selection mode and `checkChildren: true`.
53
+ */
54
+ checkDisabledChildren?: boolean;
48
55
  }
@@ -3,7 +3,7 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { AfterContentInit, ElementRef, NgZone, OnDestroy } from '@angular/core';
6
- import Draggable from '@telerik/kendo-draggable';
6
+ import Draggable from '@progress/kendo-draggable';
7
7
  import { DragClueService } from './drag-clue/drag-clue.service';
8
8
  import { DropHintService } from './drop-hint/drop-hint.service';
9
9
  import { DragClueTemplateDirective } from './drag-clue/drag-clue-template.directive';
@@ -169,10 +169,12 @@ export class CheckDirective {
169
169
  }
170
170
  const pendingCheck = [currentKey];
171
171
  if (this.options.checkChildren) {
172
- const descendants = fetchLoadedDescendants(node, ({ item }) => this.treeView.isVisible(item.dataItem, item.index) &&
173
- !this.treeView.isDisabled(item.dataItem, item.index))
174
- .map(({ item }) => this.itemKey(item));
175
- pendingCheck.push(...descendants);
172
+ const descendants = fetchLoadedDescendants(node, ({ item }) => (this.treeView.disableParentNodesOnly || this.options.checkDisabledChildren ?
173
+ this.treeView.isVisible(item.dataItem, item.index) :
174
+ this.treeView.isVisible(item.dataItem, item.index) &&
175
+ !this.treeView.isDisabled(item.dataItem, item.index)));
176
+ pendingCheck.push(...descendants.filter((item) => this.options.checkDisabledChildren || !this.treeView.isDisabled(item.item.dataItem, item.item.index))
177
+ .map(({ item }) => this.itemKey(item)));
176
178
  }
177
179
  const shouldCheck = !this.state.has(currentKey);
178
180
  pendingCheck.forEach(key => {
@@ -191,8 +193,9 @@ export class CheckDirective {
191
193
  let currentParent = parent;
192
194
  while (currentParent) {
193
195
  const parentKey = this.itemKey(currentParent.item);
196
+ const isDisabled = this.treeView.isDisabled(currentParent.item.dataItem, currentParent.item.index);
194
197
  const allChildrenSelected = currentParent.children.every(item => this.state.has(this.itemKey(item)));
195
- if (allChildrenSelected) {
198
+ if ((!isDisabled || this.options.checkDisabledChildren) && allChildrenSelected) {
196
199
  this.state.add(parentKey);
197
200
  }
198
201
  else {
@@ -201,6 +204,12 @@ export class CheckDirective {
201
204
  currentParent = currentParent.parent;
202
205
  }
203
206
  }
207
+ allChildrenSelected(children) {
208
+ return children.every(item => {
209
+ const childrenSel = this.allChildrenSelected(item.children);
210
+ return this.state.has(this.itemKey(item.item)) && childrenSel;
211
+ });
212
+ }
204
213
  notify() {
205
214
  this.lastChange = Array.from(this.state);
206
215
  this.checkedKeysChange.emit(this.lastChange);
@@ -210,6 +219,7 @@ export class CheckDirective {
210
219
  return;
211
220
  }
212
221
  const initiallyCheckedItemsCount = this.state.size;
222
+ const disabledItems = new Set();
213
223
  lookups.forEach(lookup => {
214
224
  const itemKey = this.itemKey(lookup.item);
215
225
  if (!this.state.has(itemKey)) {
@@ -217,12 +227,19 @@ export class CheckDirective {
217
227
  }
218
228
  lookup.children.forEach(item => {
219
229
  // ensure both the parent item and each child node is enabled
220
- if (!this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
221
- !this.treeView.isDisabled(item.dataItem, item.index)) {
230
+ if ((!this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
231
+ !this.treeView.isDisabled(item.dataItem, item.index)) ||
232
+ this.treeView.disableParentNodesOnly || this.options.checkDisabledChildren) {
222
233
  this.state.add(this.itemKey(item));
223
234
  }
235
+ if (this.treeView.disableParentNodesOnly &&
236
+ !this.options.checkDisabledChildren &&
237
+ this.treeView.isDisabled(item.dataItem, item.index)) {
238
+ disabledItems.add(this.itemKey(item));
239
+ }
224
240
  });
225
241
  });
242
+ disabledItems.forEach(item => this.state.delete(item));
226
243
  const hasNewlyCheckedItems = initiallyCheckedItemsCount !== this.state.size;
227
244
  if (hasNewlyCheckedItems) {
228
245
  this.zone.run(() => this.notify());
@@ -4,7 +4,7 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { Directive, ContentChild, Input, HostBinding } from '@angular/core';
6
6
  import { hasObservers } from '@progress/kendo-angular-common';
7
- import Draggable from '@telerik/kendo-draggable';
7
+ import Draggable from '@progress/kendo-draggable';
8
8
  import { DragClueService } from './drag-clue/drag-clue.service';
9
9
  import { DropHintService } from './drop-hint/drop-hint.service';
10
10
  import { DragClueTemplateDirective } from './drag-clue/drag-clue-template.directive';
@@ -126,6 +126,9 @@ export class NavigationService {
126
126
  return nodeIndex(this.focusableItem) === index;
127
127
  }
128
128
  isDisabled(index) {
129
+ if (!index) {
130
+ return false;
131
+ }
129
132
  return this.model.findNode(index).disabled;
130
133
  }
131
134
  registerItem(id, index, disabled, loadMoreButton = false, visible = true) {
@@ -138,6 +141,16 @@ export class NavigationService {
138
141
  }
139
142
  this.model.registerItem(id, index, disabled, loadMoreButton, visible);
140
143
  }
144
+ updateItem(index, disabled, visible = true) {
145
+ const itemAtIndex = this.model.findNode(index);
146
+ if (isPresent(itemAtIndex)) {
147
+ if (this.isActive(index)) {
148
+ this.deactivate();
149
+ }
150
+ }
151
+ itemAtIndex.disabled = disabled;
152
+ itemAtIndex.visible = visible;
153
+ }
141
154
  unregisterItem(id, index) {
142
155
  if (this.isActive(index)) {
143
156
  this.activateParent(index);
@@ -9,7 +9,7 @@ export const packageMetadata = {
9
9
  name: '@progress/kendo-angular-treeview',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1653578367,
12
+ publishDate: 1655296333,
13
13
  version: '',
14
14
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
15
15
  };
@@ -44,6 +44,7 @@ export class TreeViewGroupComponent {
44
44
  this.size = 'medium';
45
45
  this.initialNodesLoaded = false;
46
46
  this.loadingMoreNodes = false;
47
+ this.isItemExpandable = (node, index) => this.expandDisabledNodes || !this.isItemDisabled(node, index);
47
48
  this._data = [];
48
49
  this.singleRecordSubscriptions = new Subscription();
49
50
  this.isChecked = () => 'none';
@@ -161,6 +162,12 @@ export class TreeViewGroupComponent {
161
162
  this.loadMoreLocalNodes();
162
163
  }
163
164
  }
165
+ /**
166
+ * @hidden
167
+ */
168
+ isItemDisabled(node, index) {
169
+ return (this.disabled && !this.disableParentNodesOnly) || this.isDisabled(node, this.nodeIndex(index));
170
+ }
164
171
  /**
165
172
  * @hidden
166
173
  */
@@ -257,7 +264,7 @@ export class TreeViewGroupComponent {
257
264
  }
258
265
  }
259
266
  TreeViewGroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: TreeViewGroupComponent, deps: [{ token: i1.ExpandStateService }, { token: i2.LoadingNotificationService }, { token: i3.IndexBuilderService }, { token: i4.TreeViewLookupService }, { token: i5.NavigationService }, { token: i6.NodeChildrenService }, { token: i7.DataChangeNotificationService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
260
- TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: { checkboxes: "checkboxes", expandIcons: "expandIcons", disabled: "disabled", selectable: "selectable", touchActions: "touchActions", loadOnDemand: "loadOnDemand", trackBy: "trackBy", nodes: "nodes", textField: "textField", parentDataItem: "parentDataItem", parentIndex: "parentIndex", nodeTemplateRef: "nodeTemplateRef", loadMoreButtonTemplateRef: "loadMoreButtonTemplateRef", loadMoreService: "loadMoreService", size: "size", isChecked: "isChecked", isDisabled: "isDisabled", isExpanded: "isExpanded", isVisible: "isVisible", isSelected: "isSelected", children: "children", hasChildren: "hasChildren" }, host: { properties: { "class.k-treeview-group": "this.kGroupClass", "attr.role": "this.role" } }, usesOnChanges: true, ngImport: i0, template: `
267
+ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: { checkboxes: "checkboxes", expandIcons: "expandIcons", disabled: "disabled", selectable: "selectable", touchActions: "touchActions", disableParentNodesOnly: "disableParentNodesOnly", loadOnDemand: "loadOnDemand", trackBy: "trackBy", nodes: "nodes", textField: "textField", parentDataItem: "parentDataItem", parentIndex: "parentIndex", nodeTemplateRef: "nodeTemplateRef", loadMoreButtonTemplateRef: "loadMoreButtonTemplateRef", loadMoreService: "loadMoreService", size: "size", expandDisabledNodes: "expandDisabledNodes", isChecked: "isChecked", isDisabled: "isDisabled", isExpanded: "isExpanded", isVisible: "isVisible", isSelected: "isSelected", children: "children", hasChildren: "hasChildren" }, host: { properties: { "class.k-treeview-group": "this.kGroupClass", "attr.role": "this.role" } }, usesOnChanges: true, ngImport: i0, template: `
261
268
  <li
262
269
  *ngFor="let node of data; let index = index; trackBy: trackBy"
263
270
  class="k-treeview-item"
@@ -271,7 +278,7 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
271
278
  [loadOnDemand]="loadOnDemand"
272
279
  [checkable]="checkboxes"
273
280
  [isChecked]="isChecked(node, nodeIndex(index))"
274
- [isDisabled]="disabled || isDisabled(node, nodeIndex(index))"
281
+ [isDisabled]="isItemDisabled(node, index)"
275
282
  [isVisible]="isVisible(node, nodeIndex(index))"
276
283
  [expandable]="expandIcons && hasChildren(node)"
277
284
  [isExpanded]="isExpanded(node, nodeIndex(index))"
@@ -281,6 +288,7 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
281
288
  >
282
289
  <div [ngClass]="setItemClasses(data.length, index)">
283
290
  <span
291
+ [class.k-disabled]="!isItemExpandable(node, index)"
284
292
  class="k-treeview-toggle"
285
293
  [kendoTreeViewLoading]="nodeIndex(index)"
286
294
  (click)="expandNode(nodeIndex(index), node, !isExpanded(node, nodeIndex(index)))"
@@ -295,6 +303,7 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
295
303
  </span>
296
304
  <kendo-checkbox
297
305
  *ngIf="checkboxes"
306
+ [class.k-disabled]="isItemDisabled(node, index)"
298
307
  [size]="size"
299
308
  [node]="node"
300
309
  [index]="nodeIndex(index)"
@@ -310,6 +319,7 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
310
319
  [isSelected]="isSelected"
311
320
  class="k-treeview-leaf"
312
321
  [style.touch-action]="touchActions ? '' : 'none'"
322
+ [class.k-disabled]="isItemDisabled(node, index)"
313
323
  >
314
324
  <span class="k-treeview-leaf-text">
315
325
  <ng-container [ngSwitch]="hasTemplate">
@@ -344,7 +354,8 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
344
354
  [hasChildren]="hasChildren"
345
355
  [isChecked]="isChecked"
346
356
  [isDisabled]="isDisabled"
347
- [disabled]="disabled || isDisabled(node, nodeIndex(index))"
357
+ [disabled]="isItemDisabled(node, index)"
358
+ [expandDisabledNodes]="expandDisabledNodes"
348
359
  [isExpanded]="isExpanded"
349
360
  [isSelected]="isSelected"
350
361
  [isVisible]="isVisible"
@@ -356,6 +367,7 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
356
367
  [loadMoreService]="loadMoreService"
357
368
  [@toggle]="true"
358
369
  [trackBy]="trackBy"
370
+ [disableParentNodesOnly]="disableParentNodesOnly"
359
371
  >
360
372
  </ul>
361
373
  </li>
@@ -401,7 +413,7 @@ TreeViewGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
401
413
  </span>
402
414
  </div>
403
415
  </li>
404
- `, isInline: true, components: [{ type: i8.CheckBoxComponent, selector: "kendo-checkbox", inputs: ["id", "isChecked", "node", "index", "labelText", "tabindex", "size"], outputs: ["checkStateChange"] }, { type: TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: ["checkboxes", "expandIcons", "disabled", "selectable", "touchActions", "loadOnDemand", "trackBy", "nodes", "textField", "parentDataItem", "parentIndex", "nodeTemplateRef", "loadMoreButtonTemplateRef", "loadMoreService", "size", "isChecked", "isDisabled", "isExpanded", "isVisible", "isSelected", "children", "hasChildren"] }], directives: [{ type: i9.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10.TreeViewItemDirective, selector: "[kendoTreeViewItem]", inputs: ["dataItem", "index", "parentDataItem", "parentIndex", "role", "loadOnDemand", "checkable", "selectable", "expandable", "isChecked", "isDisabled", "isVisible", "isExpanded", "isSelected"] }, { type: i9.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i11.LoadingIndicatorDirective, selector: "[kendoTreeViewLoading]", inputs: ["kendoTreeViewLoading"] }, { type: i12.TreeViewItemContentDirective, selector: "[kendoTreeViewItemContent]", inputs: ["dataItem", "index", "initialSelection", "isSelected"] }, { type: i9.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i9.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i9.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i9.NgSwitchDefault, selector: "[ngSwitchDefault]" }], animations: [
416
+ `, isInline: true, components: [{ type: i8.CheckBoxComponent, selector: "kendo-checkbox", inputs: ["id", "isChecked", "node", "index", "labelText", "tabindex", "size"], outputs: ["checkStateChange"] }, { type: TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: ["checkboxes", "expandIcons", "disabled", "selectable", "touchActions", "disableParentNodesOnly", "loadOnDemand", "trackBy", "nodes", "textField", "parentDataItem", "parentIndex", "nodeTemplateRef", "loadMoreButtonTemplateRef", "loadMoreService", "size", "expandDisabledNodes", "isChecked", "isDisabled", "isExpanded", "isVisible", "isSelected", "children", "hasChildren"] }], directives: [{ type: i9.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10.TreeViewItemDirective, selector: "[kendoTreeViewItem]", inputs: ["dataItem", "index", "parentDataItem", "parentIndex", "role", "loadOnDemand", "checkable", "selectable", "expandable", "isChecked", "isDisabled", "isVisible", "isExpanded", "isSelected"] }, { type: i9.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i11.LoadingIndicatorDirective, selector: "[kendoTreeViewLoading]", inputs: ["kendoTreeViewLoading"] }, { type: i12.TreeViewItemContentDirective, selector: "[kendoTreeViewItemContent]", inputs: ["dataItem", "index", "initialSelection", "isSelected"] }, { type: i9.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i9.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i9.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i9.NgSwitchDefault, selector: "[ngSwitchDefault]" }], animations: [
405
417
  trigger('toggle', [
406
418
  transition('void => *', [
407
419
  style({ height: 0 }),
@@ -444,7 +456,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
444
456
  [loadOnDemand]="loadOnDemand"
445
457
  [checkable]="checkboxes"
446
458
  [isChecked]="isChecked(node, nodeIndex(index))"
447
- [isDisabled]="disabled || isDisabled(node, nodeIndex(index))"
459
+ [isDisabled]="isItemDisabled(node, index)"
448
460
  [isVisible]="isVisible(node, nodeIndex(index))"
449
461
  [expandable]="expandIcons && hasChildren(node)"
450
462
  [isExpanded]="isExpanded(node, nodeIndex(index))"
@@ -454,6 +466,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
454
466
  >
455
467
  <div [ngClass]="setItemClasses(data.length, index)">
456
468
  <span
469
+ [class.k-disabled]="!isItemExpandable(node, index)"
457
470
  class="k-treeview-toggle"
458
471
  [kendoTreeViewLoading]="nodeIndex(index)"
459
472
  (click)="expandNode(nodeIndex(index), node, !isExpanded(node, nodeIndex(index)))"
@@ -468,6 +481,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
468
481
  </span>
469
482
  <kendo-checkbox
470
483
  *ngIf="checkboxes"
484
+ [class.k-disabled]="isItemDisabled(node, index)"
471
485
  [size]="size"
472
486
  [node]="node"
473
487
  [index]="nodeIndex(index)"
@@ -483,6 +497,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
483
497
  [isSelected]="isSelected"
484
498
  class="k-treeview-leaf"
485
499
  [style.touch-action]="touchActions ? '' : 'none'"
500
+ [class.k-disabled]="isItemDisabled(node, index)"
486
501
  >
487
502
  <span class="k-treeview-leaf-text">
488
503
  <ng-container [ngSwitch]="hasTemplate">
@@ -517,7 +532,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
517
532
  [hasChildren]="hasChildren"
518
533
  [isChecked]="isChecked"
519
534
  [isDisabled]="isDisabled"
520
- [disabled]="disabled || isDisabled(node, nodeIndex(index))"
535
+ [disabled]="isItemDisabled(node, index)"
536
+ [expandDisabledNodes]="expandDisabledNodes"
521
537
  [isExpanded]="isExpanded"
522
538
  [isSelected]="isSelected"
523
539
  [isVisible]="isVisible"
@@ -529,6 +545,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
529
545
  [loadMoreService]="loadMoreService"
530
546
  [@toggle]="true"
531
547
  [trackBy]="trackBy"
548
+ [disableParentNodesOnly]="disableParentNodesOnly"
532
549
  >
533
550
  </ul>
534
551
  </li>
@@ -592,6 +609,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
592
609
  type: Input
593
610
  }], touchActions: [{
594
611
  type: Input
612
+ }], disableParentNodesOnly: [{
613
+ type: Input
595
614
  }], loadOnDemand: [{
596
615
  type: Input
597
616
  }], trackBy: [{
@@ -612,6 +631,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
612
631
  type: Input
613
632
  }], size: [{
614
633
  type: Input
634
+ }], expandDisabledNodes: [{
635
+ type: Input
615
636
  }], isChecked: [{
616
637
  type: Input
617
638
  }], isDisabled: [{
@@ -80,17 +80,13 @@ export class TreeViewItemDirective {
80
80
  this.isInitialized = true;
81
81
  this.setAttribute('role', this.role);
82
82
  this.setAriaAttributes();
83
- this.setDisabledClass();
84
83
  this.updateTabIndex();
85
84
  }
86
85
  ngOnChanges(changes) {
87
- const { index, isDisabled } = changes;
86
+ const { index } = changes;
88
87
  if (anyChanged(['index', 'checkable', 'isChecked', 'expandable', 'isExpanded', 'selectable', 'isSelected'], changes)) {
89
88
  this.setAriaAttributes();
90
89
  }
91
- if (isDisabled) {
92
- this.setDisabledClass();
93
- }
94
90
  if (this.loadOnDemand && !this.isButton) {
95
91
  this.moveLookupItem(changes);
96
92
  }
@@ -164,13 +160,12 @@ export class TreeViewItemDirective {
164
160
  updateNodeAvailability() {
165
161
  const service = this.navigationService;
166
162
  if (this.isDisabled || !this.isVisible) {
167
- service.activateClosest(this.index); // activate before unregister the item
163
+ service.activateClosest(this.index); // activate before updating the item
168
164
  }
169
165
  else {
170
166
  service.activateFocusable();
171
167
  }
172
- service.unregisterItem(this.id, this.index);
173
- service.registerItem(this.id, this.index, this.isDisabled, this.isButton, this.isVisible);
168
+ service.updateItem(this.index, this.isDisabled, this.isVisible);
174
169
  }
175
170
  setAriaAttributes() {
176
171
  this.setAttribute('aria-level', this.ib.level(this.index).toString());
@@ -179,13 +174,6 @@ export class TreeViewItemDirective {
179
174
  this.setAttribute('aria-selected', this.selectable ? this.isSelected.toString() : null);
180
175
  this.setAttribute('aria-checked', this.checkable ? this.ariaChecked : null);
181
176
  }
182
- setDisabledClass() {
183
- this.setClass('k-disabled', this.isDisabled);
184
- }
185
- setClass(className, toggle) {
186
- const action = toggle ? 'addClass' : 'removeClass';
187
- this.renderer[action](this.element.nativeElement, className);
188
- }
189
177
  updateTabIndex() {
190
178
  this.setAttribute('tabIndex', this.isFocusable() ? '0' : '-1');
191
179
  }
@@ -231,6 +231,11 @@ export class TreeViewComponent {
231
231
  * Sets an initial value of the built-in input element used for filtering.
232
232
  */
233
233
  this.filter = '';
234
+ /**
235
+ * Indicates whether only parent nodes should be disabled or their child nodes as well
236
+ * @default false
237
+ */
238
+ this.disableParentNodesOnly = false;
234
239
  this.checkboxes = false;
235
240
  this.expandIcons = false;
236
241
  this.selectable = false;
@@ -517,7 +522,11 @@ export class TreeViewComponent {
517
522
  focusItem = closestNode(e.target);
518
523
  }
519
524
  if (focusItem) {
520
- this.navigationService.activateIndex(nodeId(e.target));
525
+ const nodeIndex = nodeId(e.target);
526
+ if (this.navigationService.isDisabled(nodeIndex)) {
527
+ return;
528
+ }
529
+ this.navigationService.activateIndex(nodeIndex);
521
530
  if (!this.isActive && hasObservers(this.onFocus)) {
522
531
  this.ngZone.run(() => {
523
532
  this.onFocus.emit();
@@ -603,7 +612,7 @@ export class TreeViewComponent {
603
612
  }
604
613
  }
605
614
  TreeViewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: TreeViewComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.ExpandStateService }, { token: i2.NavigationService }, { token: i3.NodeChildrenService }, { token: i4.SelectionService }, { token: i5.TreeViewLookupService }, { token: i0.NgZone }, { token: i0.Renderer2 }, { token: i6.DataChangeNotificationService }, { token: i7.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
606
- TreeViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: TreeViewComponent, selector: "kendo-treeview", inputs: { filterInputPlaceholder: "filterInputPlaceholder", animate: "animate", nodeTemplateRef: ["nodeTemplate", "nodeTemplateRef"], loadMoreButtonTemplateRef: ["loadMoreButtonTemplate", "loadMoreButtonTemplateRef"], trackBy: "trackBy", nodes: "nodes", textField: "textField", hasChildren: "hasChildren", isChecked: "isChecked", isDisabled: "isDisabled", isExpanded: "isExpanded", isSelected: "isSelected", isVisible: "isVisible", navigable: "navigable", children: "children", loadOnDemand: "loadOnDemand", filterable: "filterable", filter: "filter", size: "size" }, outputs: { childrenLoaded: "childrenLoaded", onBlur: "blur", onFocus: "focus", expand: "expand", collapse: "collapse", nodeDragStart: "nodeDragStart", nodeDrag: "nodeDrag", filterStateChange: "filterStateChange", nodeDrop: "nodeDrop", nodeDragEnd: "nodeDragEnd", addItem: "addItem", removeItem: "removeItem", checkedChange: "checkedChange", selectionChange: "selectionChange", filterChange: "filterChange", nodeClick: "nodeClick", nodeDblClick: "nodeDblClick" }, host: { properties: { "class.k-treeview": "this.classNames", "attr.role": "this.role", "attr.dir": "this.direction", "@.disabled": "this.animate" } }, providers: providers, queries: [{ propertyName: "nodeTemplateQuery", first: true, predicate: NodeTemplateDirective, descendants: true }, { propertyName: "loadMoreButtonTemplateQuery", first: true, predicate: LoadMoreButtonTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "assetsContainer", first: true, predicate: ["assetsContainer"], descendants: true, read: ViewContainerRef, static: true }], exportAs: ["kendoTreeView"], usesOnChanges: true, ngImport: i0, template: `
615
+ TreeViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: TreeViewComponent, selector: "kendo-treeview", inputs: { filterInputPlaceholder: "filterInputPlaceholder", expandDisabledNodes: "expandDisabledNodes", animate: "animate", nodeTemplateRef: ["nodeTemplate", "nodeTemplateRef"], loadMoreButtonTemplateRef: ["loadMoreButtonTemplate", "loadMoreButtonTemplateRef"], trackBy: "trackBy", nodes: "nodes", textField: "textField", hasChildren: "hasChildren", isChecked: "isChecked", isDisabled: "isDisabled", isExpanded: "isExpanded", isSelected: "isSelected", isVisible: "isVisible", navigable: "navigable", children: "children", loadOnDemand: "loadOnDemand", filterable: "filterable", filter: "filter", size: "size", disableParentNodesOnly: "disableParentNodesOnly" }, outputs: { childrenLoaded: "childrenLoaded", onBlur: "blur", onFocus: "focus", expand: "expand", collapse: "collapse", nodeDragStart: "nodeDragStart", nodeDrag: "nodeDrag", filterStateChange: "filterStateChange", nodeDrop: "nodeDrop", nodeDragEnd: "nodeDragEnd", addItem: "addItem", removeItem: "removeItem", checkedChange: "checkedChange", selectionChange: "selectionChange", filterChange: "filterChange", nodeClick: "nodeClick", nodeDblClick: "nodeDblClick" }, host: { properties: { "class.k-treeview": "this.classNames", "attr.role": "this.role", "attr.dir": "this.direction", "@.disabled": "this.animate" } }, providers: providers, queries: [{ propertyName: "nodeTemplateQuery", first: true, predicate: NodeTemplateDirective, descendants: true }, { propertyName: "loadMoreButtonTemplateQuery", first: true, predicate: LoadMoreButtonTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "assetsContainer", first: true, predicate: ["assetsContainer"], descendants: true, read: ViewContainerRef, static: true }], exportAs: ["kendoTreeView"], usesOnChanges: true, ngImport: i0, template: `
607
616
  <span
608
617
  class="k-treeview-filter"
609
618
  *ngIf="filterable"
@@ -633,6 +642,7 @@ TreeViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
633
642
  [hasChildren]="hasChildren"
634
643
  [isChecked]="isChecked"
635
644
  [isDisabled]="isDisabled"
645
+ [disableParentNodesOnly]="disableParentNodesOnly"
636
646
  [isExpanded]="isExpanded"
637
647
  [isSelected]="isSelected"
638
648
  [isVisible]="isVisible"
@@ -642,10 +652,11 @@ TreeViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
642
652
  [nodes]="fetchNodes"
643
653
  [loadMoreService]="loadMoreService"
644
654
  [trackBy]="trackBy"
655
+ [expandDisabledNodes]="expandDisabledNodes"
645
656
  >
646
657
  </ul>
647
658
  <ng-container #assetsContainer></ng-container>
648
- `, isInline: true, components: [{ type: i8.TextBoxComponent, selector: "kendo-textbox", inputs: ["focusableId", "title", "disabled", "readonly", "tabindex", "value", "selectOnFocus", "showSuccessIcon", "showErrorIcon", "clearButton", "successIcon", "errorIcon", "clearButtonIcon", "size", "rounded", "fillMode", "tabIndex", "placeholder", "maxlength"], outputs: ["valueChange", "inputFocus", "inputBlur", "focus", "blur"], exportAs: ["kendoTextBox"] }, { type: i9.TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: ["checkboxes", "expandIcons", "disabled", "selectable", "touchActions", "loadOnDemand", "trackBy", "nodes", "textField", "parentDataItem", "parentIndex", "nodeTemplateRef", "loadMoreButtonTemplateRef", "loadMoreService", "size", "isChecked", "isDisabled", "isExpanded", "isVisible", "isSelected", "children", "hasChildren"] }], directives: [{ type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.TextBoxPrefixTemplateDirective, selector: "[kendoTextBoxPrefixTemplate]" }], changeDetection: i0.ChangeDetectionStrategy.Default });
659
+ `, isInline: true, components: [{ type: i8.TextBoxComponent, selector: "kendo-textbox", inputs: ["focusableId", "title", "disabled", "readonly", "tabindex", "value", "selectOnFocus", "showSuccessIcon", "showErrorIcon", "clearButton", "successIcon", "errorIcon", "clearButtonIcon", "size", "rounded", "fillMode", "tabIndex", "placeholder", "maxlength"], outputs: ["valueChange", "inputFocus", "inputBlur", "focus", "blur"], exportAs: ["kendoTextBox"] }, { type: i9.TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: ["checkboxes", "expandIcons", "disabled", "selectable", "touchActions", "disableParentNodesOnly", "loadOnDemand", "trackBy", "nodes", "textField", "parentDataItem", "parentIndex", "nodeTemplateRef", "loadMoreButtonTemplateRef", "loadMoreService", "size", "expandDisabledNodes", "isChecked", "isDisabled", "isExpanded", "isVisible", "isSelected", "children", "hasChildren"] }], directives: [{ type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.TextBoxPrefixTemplateDirective, selector: "[kendoTextBoxPrefixTemplate]" }], changeDetection: i0.ChangeDetectionStrategy.Default });
649
660
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: TreeViewComponent, decorators: [{
650
661
  type: Component,
651
662
  args: [{
@@ -683,6 +694,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
683
694
  [hasChildren]="hasChildren"
684
695
  [isChecked]="isChecked"
685
696
  [isDisabled]="isDisabled"
697
+ [disableParentNodesOnly]="disableParentNodesOnly"
686
698
  [isExpanded]="isExpanded"
687
699
  [isSelected]="isSelected"
688
700
  [isVisible]="isVisible"
@@ -692,6 +704,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
692
704
  [nodes]="fetchNodes"
693
705
  [loadMoreService]="loadMoreService"
694
706
  [trackBy]="trackBy"
707
+ [expandDisabledNodes]="expandDisabledNodes"
695
708
  >
696
709
  </ul>
697
710
  <ng-container #assetsContainer></ng-container>
@@ -711,6 +724,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
711
724
  args: ['assetsContainer', { read: ViewContainerRef, static: true }]
712
725
  }], filterInputPlaceholder: [{
713
726
  type: Input
727
+ }], expandDisabledNodes: [{
728
+ type: Input
714
729
  }], animate: [{
715
730
  type: Input
716
731
  }, {
@@ -794,4 +809,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
794
809
  type: Input
795
810
  }], size: [{
796
811
  type: Input
812
+ }], disableParentNodesOnly: [{
813
+ type: Input
797
814
  }] } });