@progress/kendo-angular-treeview 21.4.1-develop.1 → 22.0.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/fesm2022/progress-kendo-angular-treeview.mjs +115 -115
  2. package/filtering-base.d.ts +1 -1
  3. package/localization/messages.d.ts +1 -1
  4. package/package.json +11 -19
  5. package/schematics/ngAdd/index.js +4 -4
  6. package/esm2022/check-mode.mjs +0 -5
  7. package/esm2022/check.directive.mjs +0 -334
  8. package/esm2022/checkable-settings.mjs +0 -5
  9. package/esm2022/checkbox/checked-state.mjs +0 -5
  10. package/esm2022/data-bound-component.mjs +0 -19
  11. package/esm2022/data-change-notification.service.mjs +0 -14
  12. package/esm2022/default-callbacks.mjs +0 -36
  13. package/esm2022/directives.mjs +0 -53
  14. package/esm2022/disable.directive.mjs +0 -83
  15. package/esm2022/drag-and-drop/drag-and-drop-editing.directive.mjs +0 -76
  16. package/esm2022/drag-and-drop/drag-and-drop-utils.mjs +0 -270
  17. package/esm2022/drag-and-drop/drag-and-drop.directive.mjs +0 -348
  18. package/esm2022/drag-and-drop/drag-clue/drag-clue-template.directive.mjs +0 -44
  19. package/esm2022/drag-and-drop/drag-clue/drag-clue.component.mjs +0 -132
  20. package/esm2022/drag-and-drop/drag-clue/drag-clue.service.mjs +0 -123
  21. package/esm2022/drag-and-drop/drop-hint/drop-hint-template.directive.mjs +0 -43
  22. package/esm2022/drag-and-drop/drop-hint/drop-hint.component.mjs +0 -102
  23. package/esm2022/drag-and-drop/drop-hint/drop-hint.service.mjs +0 -41
  24. package/esm2022/drag-and-drop/editing-services/drag-and-drop-asset.service.mjs +0 -48
  25. package/esm2022/drag-and-drop/editing-services/flat-editing.service.mjs +0 -141
  26. package/esm2022/drag-and-drop/editing-services/hierarchy-editing.service.mjs +0 -88
  27. package/esm2022/drag-and-drop/models/drop-action.mjs +0 -32
  28. package/esm2022/drag-and-drop/models/drop-position.mjs +0 -22
  29. package/esm2022/drag-and-drop/models/editing-service.mjs +0 -5
  30. package/esm2022/drag-and-drop/models/preventable-event.mjs +0 -25
  31. package/esm2022/drag-and-drop/models/scroll-direction.mjs +0 -12
  32. package/esm2022/drag-and-drop/models/scroll-settings.mjs +0 -5
  33. package/esm2022/drag-and-drop/models/tree-item-filter-state.mjs +0 -5
  34. package/esm2022/drag-and-drop/models/treeitem-add-remove-args.mjs +0 -5
  35. package/esm2022/drag-and-drop/models/treeitem-drag-event.mjs +0 -24
  36. package/esm2022/drag-and-drop/models/treeitem-drag-start-event.mjs +0 -25
  37. package/esm2022/drag-and-drop/models/treeitem-drop-event.mjs +0 -54
  38. package/esm2022/drag-and-drop/models.mjs +0 -14
  39. package/esm2022/expand-state.service.mjs +0 -24
  40. package/esm2022/expand.directive.mjs +0 -226
  41. package/esm2022/expandable-component.mjs +0 -19
  42. package/esm2022/filter-expand-settings.interface.mjs +0 -5
  43. package/esm2022/filter-state.interface.mjs +0 -5
  44. package/esm2022/filtering-base.mjs +0 -92
  45. package/esm2022/flat-binding.directive.mjs +0 -165
  46. package/esm2022/funcs.mjs +0 -9
  47. package/esm2022/hierarchy-binding.directive.mjs +0 -164
  48. package/esm2022/index-builder.service.mjs +0 -33
  49. package/esm2022/index.mjs +0 -31
  50. package/esm2022/load-more/load-more-button-template.directive.mjs +0 -41
  51. package/esm2022/load-more/load-more-request-args.mjs +0 -5
  52. package/esm2022/load-more/load-more-utils.mjs +0 -35
  53. package/esm2022/load-more/load-more.directive.mjs +0 -137
  54. package/esm2022/load-more/load-more.service.mjs +0 -5
  55. package/esm2022/loading-indicator.directive.mjs +0 -69
  56. package/esm2022/loading-notification.service.mjs +0 -21
  57. package/esm2022/localization/custom-messages.component.mjs +0 -54
  58. package/esm2022/localization/localized-messages.directive.mjs +0 -39
  59. package/esm2022/localization/messages.mjs +0 -27
  60. package/esm2022/navigation/navigation-item.interface.mjs +0 -5
  61. package/esm2022/navigation/navigation-model.mjs +0 -152
  62. package/esm2022/navigation/navigation-state.interface.mjs +0 -5
  63. package/esm2022/navigation/navigation.service.mjs +0 -248
  64. package/esm2022/node-children.service.mjs +0 -21
  65. package/esm2022/node-click-event.interface.mjs +0 -5
  66. package/esm2022/node-template.directive.mjs +0 -45
  67. package/esm2022/package-metadata.mjs +0 -16
  68. package/esm2022/progress-kendo-angular-treeview.mjs +0 -8
  69. package/esm2022/selection/select.directive.mjs +0 -174
  70. package/esm2022/selection/selectable-settings.mjs +0 -5
  71. package/esm2022/selection/selection-mode.mjs +0 -5
  72. package/esm2022/selection/selection.service.mjs +0 -33
  73. package/esm2022/size.mjs +0 -5
  74. package/esm2022/treeitem-lookup.interface.mjs +0 -5
  75. package/esm2022/treeitem.interface.mjs +0 -5
  76. package/esm2022/treeview-filter-settings.mjs +0 -12
  77. package/esm2022/treeview-group.component.mjs +0 -759
  78. package/esm2022/treeview-item-content.directive.mjs +0 -82
  79. package/esm2022/treeview-item.directive.mjs +0 -245
  80. package/esm2022/treeview-lookup.service.mjs +0 -89
  81. package/esm2022/treeview.component.mjs +0 -874
  82. package/esm2022/treeview.module.mjs +0 -74
  83. package/esm2022/utils.mjs +0 -301
@@ -1,874 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2026 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { ChangeDetectionStrategy, Component, ContentChild, ElementRef, EventEmitter, HostBinding, Input, NgZone, Output, Renderer2, ViewChild, ViewContainerRef, isDevMode, forwardRef, ChangeDetectorRef } from '@angular/core';
6
- import { anyChanged, hasObservers, isDocumentAvailable } from '@progress/kendo-angular-common';
7
- import { L10N_PREFIX, LocalizationService } from '@progress/kendo-angular-l10n';
8
- import { BehaviorSubject, of, Subscription } from 'rxjs';
9
- import { validatePackage } from '@progress/kendo-licensing';
10
- import { packageMetadata } from './package-metadata';
11
- import { DataChangeNotificationService } from './data-change-notification.service';
12
- import { hasCheckbox, hasChildren, isChecked, isDisabled, isExpanded, isSelected, isVisible, trackBy } from './default-callbacks';
13
- import { ExpandStateService } from './expand-state.service';
14
- import { IndexBuilderService } from './index-builder.service';
15
- import { LoadingNotificationService } from './loading-notification.service';
16
- import { NavigationService } from './navigation/navigation.service';
17
- import { NodeChildrenService } from './node-children.service';
18
- import { NodeTemplateDirective } from './node-template.directive';
19
- import { LoadMoreButtonTemplateDirective } from './load-more/load-more-button-template.directive';
20
- import { DataBoundComponent } from './data-bound-component';
21
- import { ExpandableComponent } from './expandable-component';
22
- import { SelectionService } from './selection/selection.service';
23
- import { TreeViewLookupService } from './treeview-lookup.service';
24
- import { closestNode, focusableNode, hasParent, isContent, isFocusable, match, nodeId, isLoadMoreButton, isPresent, nodeIndex, buildTreeItem, getSizeClass } from './utils';
25
- import { searchIcon } from '@progress/kendo-svg-icons';
26
- import { TextBoxComponent, TextBoxPrefixTemplateDirective } from '@progress/kendo-angular-inputs';
27
- import { TreeViewGroupComponent } from './treeview-group.component';
28
- import { LocalizedMessagesDirective } from './localization/localized-messages.directive';
29
- import { IconWrapperComponent } from '@progress/kendo-angular-icons';
30
- import * as i0 from "@angular/core";
31
- import * as i1 from "./expand-state.service";
32
- import * as i2 from "./navigation/navigation.service";
33
- import * as i3 from "./node-children.service";
34
- import * as i4 from "./selection/selection.service";
35
- import * as i5 from "./treeview-lookup.service";
36
- import * as i6 from "./data-change-notification.service";
37
- import * as i7 from "@progress/kendo-angular-l10n";
38
- let nextId = 0;
39
- const LOAD_MORE_DOC_LINK = 'https://www.telerik.com/kendo-angular-ui/components/treeview/load-more-button/';
40
- const providers = [
41
- ExpandStateService,
42
- IndexBuilderService,
43
- TreeViewLookupService,
44
- LoadingNotificationService,
45
- NodeChildrenService,
46
- NavigationService,
47
- SelectionService,
48
- DataChangeNotificationService,
49
- LocalizationService,
50
- {
51
- provide: L10N_PREFIX,
52
- useValue: 'kendo.treeview'
53
- },
54
- {
55
- provide: DataBoundComponent,
56
- useExisting: forwardRef(() => TreeViewComponent)
57
- },
58
- {
59
- provide: ExpandableComponent,
60
- useExisting: forwardRef(() => TreeViewComponent)
61
- }
62
- ];
63
- /**
64
- * Represents the [Kendo UI TreeView component for Angular](slug:overview_treeview).
65
- *
66
- * @example
67
- * ```html
68
- * <kendo-treeview
69
- * kendoTreeViewExpandable
70
- * [nodes]="data"
71
- * textField="text"
72
- * [children]="fetchChildren"
73
- * [hasChildren]="hasChildren">
74
- * </kendo-treeview>
75
- * ```
76
- *
77
- * @remarks
78
- * Supported children components are: {@link CustomMessagesComponent}
79
- */
80
- export class TreeViewComponent {
81
- element;
82
- changeDetectorRef;
83
- expandService;
84
- navigationService;
85
- nodeChildrenService;
86
- selectionService;
87
- treeViewLookupService;
88
- ngZone;
89
- renderer;
90
- dataChangeNotification;
91
- localization;
92
- /**
93
- * @hidden
94
- */
95
- searchIcon = searchIcon;
96
- classNames = true;
97
- /** @hidden */
98
- get direction() {
99
- return this.localization.rtl ? 'rtl' : 'ltr';
100
- }
101
- /**
102
- * @hidden
103
- */
104
- assetsContainer;
105
- /**
106
- * @hidden
107
- */
108
- searchbox;
109
- /**
110
- * Sets the placeholder text for the filter input when the component is empty.
111
- */
112
- filterInputPlaceholder = "";
113
- /**
114
- * Allows expanding disabled nodes.
115
- *
116
- * @default false
117
- */
118
- expandDisabledNodes;
119
- /**
120
- * Enables or disables content animation.
121
- */
122
- set animate(value) {
123
- this._animate = value;
124
- }
125
- get animate() {
126
- return !this._animate;
127
- }
128
- /** @hidden */
129
- fetchNodes = () => this.data;
130
- /**
131
- * Fires when the children of the expanded node are loaded.
132
- */
133
- childrenLoaded = new EventEmitter();
134
- /**
135
- * Fires when the component loses focus.
136
- */
137
- onBlur = new EventEmitter();
138
- /**
139
- * Fires when the component receives focus.
140
- */
141
- onFocus = new EventEmitter();
142
- /**
143
- * Fires when a TreeView node expands.
144
- */
145
- expand = new EventEmitter();
146
- /**
147
- * Fires when a TreeView node collapses.
148
- */
149
- collapse = new EventEmitter();
150
- /**
151
- * Fires just before node dragging starts ([see example](slug:draganddrop_treeview#setup)). This event is preventable.
152
- * Prevent the default event to stop drag hint creation and further drag events.
153
- */
154
- nodeDragStart = new EventEmitter();
155
- /**
156
- * Fires when an item is being dragged ([see example](slug:draganddrop_treeview#setup)).
157
- */
158
- nodeDrag = new EventEmitter();
159
- /**
160
- * Emits when the built-in filtering mechanism updates node visibility.
161
- * Used for the built-in auto-expand functionalities. Handle this event for custom implementations.
162
- */
163
- filterStateChange = new EventEmitter();
164
- /**
165
- * Fires on the target TreeView when a dragged item is dropped ([see example](slug:draganddrop_treeview#setup)).
166
- *
167
- * Prevent the default event (`event.preventDefault()`) or set the event as invalid (`event.setValid(false)`) to stop the `addItem` and `removeItem` events from triggering.
168
- *
169
- * Use `preventDefault` to handle add/remove manually, or `setValid(false)` to indicate an unsuccessful operation. While `setValid(false)` animates the drag clue to its original position, `event.preventDefault()` simply removes the clue.
170
- */
171
- nodeDrop = new EventEmitter();
172
- /**
173
- * Fires on the source TreeView after the dragged item is dropped ([see example](slug:draganddrop_treeview#setup)).
174
- */
175
- nodeDragEnd = new EventEmitter();
176
- /**
177
- * Fires after a dragged item is dropped ([see example](slug:draganddrop_treeview#setup)). Called on the TreeView where the item is dropped.
178
- */
179
- addItem = new EventEmitter();
180
- /**
181
- * Fires after a dragged item is dropped ([see example](slug:draganddrop_treeview#setup)). Called on the TreeView from where the item is dragged.
182
- */
183
- removeItem = new EventEmitter();
184
- /**
185
- * Fires when a TreeView node checkbox is selected ([see example](slug:checkboxes_treeview#toc-modifying-the-checked-state)).
186
- */
187
- checkedChange = new EventEmitter();
188
- /**
189
- * Fires when a TreeView node is selected ([see example](slug:selection_treeview#modifying-the-selection-behavior)).
190
- */
191
- selectionChange = new EventEmitter();
192
- /**
193
- * Fires when the value of the built-in filter input changes.
194
- */
195
- filterChange = new EventEmitter();
196
- /**
197
- * Fires when a TreeView node is clicked.
198
- */
199
- nodeClick = new EventEmitter();
200
- /**
201
- * Fires when a TreeView node is double-clicked.
202
- */
203
- nodeDblClick = new EventEmitter();
204
- /**
205
- * @hidden
206
- *
207
- * Queries the template for a node template declaration.
208
- * Ignored if a `[nodeTemplate]` value is explicitly provided.
209
- */
210
- nodeTemplateQuery;
211
- /**
212
- * @hidden
213
- *
214
- * Defines the template for each node.
215
- * Takes precedence over nested templates in the TreeView tag.
216
- */
217
- set nodeTemplateRef(template) {
218
- this._nodeTemplateRef = template;
219
- }
220
- get nodeTemplateRef() {
221
- return this._nodeTemplateRef || this.nodeTemplateQuery;
222
- }
223
- /**
224
- * @hidden
225
- *
226
- * Queries the template for a load-more button template declaration.
227
- * Ignored if a `[loadMoreButtonTemplate]` value is explicitly provided.
228
- */
229
- loadMoreButtonTemplateQuery;
230
- /**
231
- * @hidden
232
- *
233
- * Defines the template for each load-more button.
234
- * Takes precedence over nested templates in the TreeView tag.
235
- */
236
- set loadMoreButtonTemplateRef(template) {
237
- this._loadMoreButtonTemplateRef = template;
238
- }
239
- get loadMoreButtonTemplateRef() {
240
- return this._loadMoreButtonTemplateRef || this.loadMoreButtonTemplateQuery;
241
- }
242
- /**
243
- * A function that defines how to track node changes.
244
- * By default, the TreeView tracks the nodes by data item object reference.
245
- */
246
- trackBy = trackBy;
247
- /**
248
- * The nodes displayed by the TreeView ([see example](slug:databinding_treeview)).
249
- */
250
- set nodes(value) {
251
- this.data.next(value || []);
252
- this.dataChangeNotification.notify();
253
- }
254
- get nodes() {
255
- return this.data.value;
256
- }
257
- /**
258
- * The fields of the data item that provide the text content of the nodes ([see example](slug:databinding_treeview)).
259
- * If set to an array, each level uses the field at the same index or the last item in the array.
260
- */
261
- textField;
262
- /**
263
- * A function that determines if a node has child nodes ([see example](slug:databinding_treeview)).
264
- */
265
- get hasChildren() {
266
- return this._hasChildren || hasChildren;
267
- }
268
- set hasChildren(callback) {
269
- this._hasChildren = callback;
270
- this.expandIcons = Boolean(this._isExpanded && this._hasChildren);
271
- }
272
- /**
273
- * A function that determines if a node is checked ([see example](slug:checkboxes_treeview#toc-modifying-the-checked-state)).
274
- */
275
- get isChecked() {
276
- return this._isChecked || isChecked;
277
- }
278
- set isChecked(callback) {
279
- this._isChecked = callback;
280
- this.checkboxes = Boolean(this._isChecked);
281
- }
282
- /**
283
- * A function that determines if a node is disabled.
284
- */
285
- isDisabled = isDisabled;
286
- /**
287
- * A function that determines if a node has a checkbox. If there is no checkbox, the node is not checkable and is excluded from built-in check functionality.
288
- */
289
- hasCheckbox = hasCheckbox;
290
- /**
291
- * A function that determines if a node is expanded.
292
- */
293
- get isExpanded() {
294
- return this._isExpanded || isExpanded;
295
- }
296
- set isExpanded(callback) {
297
- this._isExpanded = callback;
298
- this.expandIcons = Boolean(this._isExpanded && this._hasChildren);
299
- }
300
- /**
301
- * A function that determines if a node is selected ([see example](slug:selection_treeview#modifying-the-selection-behavior)).
302
- */
303
- get isSelected() {
304
- return this._isSelected || isSelected;
305
- }
306
- set isSelected(callback) {
307
- this._isSelected = callback;
308
- this.selectable = Boolean(this._isSelected);
309
- }
310
- /**
311
- * A callback that determines whether a TreeView node should be rendered as hidden. Uses the `.k-hidden` utility class. Useful for custom filtering.
312
- *
313
- */
314
- isVisible = isVisible;
315
- /**
316
- * Enables keyboard navigation for the TreeView.
317
- *
318
- * @default true
319
- */
320
- navigable = true;
321
- /**
322
- * A function that provides the child nodes for a given parent node ([see example](slug:databinding_treeview)).
323
- */
324
- children = () => of([]);
325
- /**
326
- * Indicates whether child nodes are fetched on expand or initally prefetched.
327
- *
328
- * @default true
329
- */
330
- loadOnDemand = true;
331
- /**
332
- * Renders the built-in input element for filtering. If `true`, emits the `filterChange` event that can be handled for [manual filtering](slug:filtering_treeview#toc-manual-filtering).
333
- * Built-in filtering is available with [`kendoTreeViewHierarchyBinding`](slug:api_treeview_hierarchybindingdirective) and [`kendoTreeViewFlatDataBinding`](slug:api_treeview_flatdatabindingdirective) directives.
334
- *
335
- * @default false
336
- */
337
- filterable = false;
338
- /**
339
- * Sets the initial value of the built-in filter input.
340
- */
341
- filter = '';
342
- /**
343
- * Sets the size of the component.
344
- *
345
- * @default 'medium'
346
- */
347
- set size(size) {
348
- const newSize = size ? size : 'medium';
349
- if (this.size !== 'none') {
350
- this.renderer.removeClass(this.element.nativeElement, getSizeClass('treeview', this.size));
351
- }
352
- this.renderer.addClass(this.element.nativeElement, getSizeClass('treeview', newSize));
353
- this._size = size;
354
- }
355
- get size() {
356
- return this._size;
357
- }
358
- get isActive() {
359
- return this.navigationService.isTreeViewActive;
360
- }
361
- /**
362
- * @hidden
363
- */
364
- get treeviewId() {
365
- return `treeview_${this._nextId}`;
366
- }
367
- /**
368
- * Indicates whether only parent nodes should be disabled or their child nodes as well.
369
- *
370
- * @default false
371
- */
372
- disableParentNodesOnly = false;
373
- /**
374
- * @hidden
375
- */
376
- loadMoreService;
377
- /**
378
- * @hidden
379
- */
380
- editService;
381
- checkboxes = false;
382
- expandIcons = false;
383
- selectable = false;
384
- touchActions = true;
385
- data = new BehaviorSubject([]);
386
- _animate = true;
387
- _isChecked;
388
- _isExpanded;
389
- _isSelected;
390
- _hasChildren;
391
- _nodeTemplateRef;
392
- _loadMoreButtonTemplateRef;
393
- _size = 'medium';
394
- subscriptions = new Subscription();
395
- domSubscriptions = [];
396
- _nextId = nextId;
397
- constructor(element, changeDetectorRef, expandService, navigationService, nodeChildrenService, selectionService, treeViewLookupService, ngZone, renderer, dataChangeNotification, localization) {
398
- this.element = element;
399
- this.changeDetectorRef = changeDetectorRef;
400
- this.expandService = expandService;
401
- this.navigationService = navigationService;
402
- this.nodeChildrenService = nodeChildrenService;
403
- this.selectionService = selectionService;
404
- this.treeViewLookupService = treeViewLookupService;
405
- this.ngZone = ngZone;
406
- this.renderer = renderer;
407
- this.dataChangeNotification = dataChangeNotification;
408
- this.localization = localization;
409
- validatePackage(packageMetadata);
410
- nextId++;
411
- }
412
- ngOnChanges(changes) {
413
- this.navigationService.navigable = Boolean(this.navigable);
414
- // TODO: should react to changes.loadOnDemand as well - should preload the data or clear the already cached items
415
- if (anyChanged(['nodes', 'children', 'hasChildren', 'loadOnDemand'], changes, false) && !this.loadOnDemand) {
416
- this.preloadChildNodes();
417
- }
418
- }
419
- ngOnDestroy() {
420
- this.subscriptions.unsubscribe();
421
- this.domSubscriptions.forEach(subscription => subscription());
422
- }
423
- ngOnInit() {
424
- this.subscriptions.add(this.nodeChildrenService
425
- .changes
426
- .subscribe((x) => this.childrenLoaded.emit(x)));
427
- this.subscriptions.add(this.expandService.changes
428
- .subscribe(({ index, dataItem, expand }) => expand
429
- ? this.expand.emit({ index, dataItem })
430
- : this.collapse.emit({ index, dataItem })));
431
- this.subscriptions.add(this.navigationService.checks
432
- .subscribe((x) => this.checkedChange.emit(this.treeViewLookupService.itemLookup(x))));
433
- this.subscriptions.add(this.selectionService.changes
434
- .subscribe((x) => {
435
- if (hasObservers(this.selectionChange)) {
436
- this.ngZone.run(() => {
437
- this.selectionChange.emit(x);
438
- });
439
- }
440
- }));
441
- if (this.element) {
442
- this.ngZone.runOutsideAngular(() => {
443
- this.attachDomHandlers();
444
- });
445
- }
446
- if (this.size) {
447
- this.renderer.addClass(this.element.nativeElement, getSizeClass('treeview', this.size));
448
- }
449
- }
450
- ngAfterViewInit() {
451
- if (this.searchbox) {
452
- this.renderer.setAttribute(this.searchbox.input.nativeElement, 'role', 'searchbox');
453
- this.renderer.setAttribute(this.searchbox.input.nativeElement, 'aria-controls', this.treeviewId);
454
- this.renderer.setAttribute(this.searchbox.input.nativeElement, 'aria-label', 'searchbar');
455
- }
456
- }
457
- /**
458
- * Blurs the focused TreeView item.
459
- */
460
- blur() {
461
- if (!isDocumentAvailable()) {
462
- return;
463
- }
464
- const target = focusableNode(this.element);
465
- if (document.activeElement === target) {
466
- target.blur();
467
- }
468
- }
469
- /**
470
- * Focuses the first focusable item in the TreeView if no hierarchical index is provided.
471
- */
472
- focus(index) {
473
- const focusIndex = index || nodeIndex(this.navigationService.focusableItem);
474
- this.navigationService.activateIndex(focusIndex);
475
- const target = focusableNode(this.element);
476
- if (target) {
477
- target.focus();
478
- }
479
- }
480
- /**
481
- * Returns the `TreeItemLookup` node for the specified index.
482
- *
483
- * @param index - The index of the node.
484
- * @returns {TreeItemLookup} - The looked up item.
485
- */
486
- itemLookup(index) {
487
- return this.treeViewLookupService.itemLookup(index);
488
- }
489
- /**
490
- * Calls the [`children`](slug:api_treeview_treeviewcomponent#children) function for every expanded node and fetches all rendered child nodes again.
491
- */
492
- rebindChildren() {
493
- this.dataChangeNotification.notify();
494
- }
495
- /**
496
- * Triggers the `expand` event for the provided node and shows its loading indicator.
497
- */
498
- expandNode(item, index) {
499
- this.expandService.expand(index, item);
500
- }
501
- /**
502
- * Triggers the `collapse` event for the provided node.
503
- */
504
- collapseNode(item, index) {
505
- this.expandService.collapse(index, item);
506
- }
507
- /**
508
- * Gets the current page size of the data item's children collection ([see example](slug:loadmorebutton_treeview#managing-page-sizes)).
509
- * Pass `null` as `dataItem` to get the root collection's page size.
510
- *
511
- * @param dataItem {any} - The parent data item of the targeted collection.
512
- * @returns {number} - The page size of the data item's children collection.
513
- */
514
- getNodePageSize(dataItem) {
515
- this.verifyLoadMoreService();
516
- return this.loadMoreService.getGroupSize(dataItem);
517
- }
518
- /**
519
- * Sets the page size of the data item's children collection ([see example](slug:loadmorebutton_treeview#managing-page-sizes)).
520
- * Pass `null` as `dataItem` to set the root collection's page size.
521
- *
522
- * @param dataItem {any} - The parent data item of the targeted collection.
523
- * @param pageSize {number} - The new page size.
524
- */
525
- setNodePageSize(dataItem, pageSize) {
526
- this.verifyLoadMoreService();
527
- this.loadMoreService.setGroupSize(dataItem, pageSize);
528
- }
529
- /**
530
- * @hidden
531
- *
532
- * Clears the current TreeViewLookupService node map and re-registers all nodes anew.
533
- * Child nodes are acquired through the provided `children` callback.
534
- */
535
- preloadChildNodes() {
536
- this.treeViewLookupService.reset();
537
- this.registerLookupItems(this.nodes);
538
- }
539
- attachDomHandlers() {
540
- const element = this.element.nativeElement;
541
- this.clickHandler = this.clickHandler.bind(this);
542
- this.domSubscriptions.push(this.renderer.listen(element, 'contextmenu', this.clickHandler), this.renderer.listen(element, 'click', this.clickHandler), this.renderer.listen(element, 'dblclick', this.clickHandler), this.renderer.listen(element, 'focusin', this.focusHandler.bind(this)), this.renderer.listen(element, 'focusout', this.blurHandler.bind(this)), this.renderer.listen(element, 'keydown', this.keydownHandler.bind(this)));
543
- }
544
- focusHandler(e) {
545
- let focusItem;
546
- if (match(e.target, '.k-treeview-item')) {
547
- focusItem = e.target;
548
- }
549
- else if (!isFocusable(e.target)) { // with compliments to IE
550
- focusItem = closestNode(e.target);
551
- }
552
- if (focusItem) {
553
- const nodeIndex = nodeId(e.target);
554
- if (this.navigationService.isDisabled(nodeIndex)) {
555
- return;
556
- }
557
- this.navigationService.activateIndex(nodeIndex);
558
- if (!this.isActive && hasObservers(this.onFocus)) {
559
- this.ngZone.run(() => {
560
- this.onFocus.emit();
561
- });
562
- }
563
- this.navigationService.isTreeViewActive = true;
564
- }
565
- }
566
- blurHandler(e) {
567
- if (this.isActive && match(e.target, '.k-treeview-item') &&
568
- (!e.relatedTarget || !match(e.relatedTarget, '.k-treeview-item') || !hasParent(e.relatedTarget, this.element.nativeElement))) {
569
- this.navigationService.deactivate();
570
- this.navigationService.isTreeViewActive = false;
571
- if (hasObservers(this.onBlur)) {
572
- this.ngZone.run(() => {
573
- this.onBlur.emit();
574
- });
575
- }
576
- }
577
- }
578
- clickHandler(e) {
579
- const target = e.target;
580
- if ((e.type === 'contextmenu' && !hasObservers(this.nodeClick)) ||
581
- (e.type === 'click' && !hasObservers(this.nodeClick) && !hasObservers(this.selectionChange) && !isLoadMoreButton(target)) ||
582
- (e.type === 'dblclick' && !hasObservers(this.nodeDblClick)) || isFocusable(target) ||
583
- (!isContent(target) && !isLoadMoreButton(target)) || !hasParent(target, this.element.nativeElement)) {
584
- return;
585
- }
586
- const index = nodeId(closestNode(target));
587
- // the disabled check is probably not needed due to the k-disabled styles
588
- if (!index || this.navigationService.isDisabled(index)) {
589
- return;
590
- }
591
- this.ngZone.run(() => {
592
- // record this value before emitting selectionChange (`this.navigationService.selectIndex`), as the treeview state may be changed on its emission
593
- const lookup = this.treeViewLookupService.itemLookup(index);
594
- if (e.type === 'click') {
595
- const loadMoreButton = this.navigationService.model.findNode(index).loadMoreButton;
596
- if (loadMoreButton) {
597
- this.navigationService.notifyLoadMore(index);
598
- return;
599
- }
600
- else {
601
- this.navigationService.selectIndex(index);
602
- }
603
- }
604
- const emitter = e.type === 'dblclick' ? this.nodeDblClick : this.nodeClick;
605
- emitter.emit({
606
- item: lookup.item,
607
- originalEvent: e,
608
- type: e.type
609
- });
610
- });
611
- }
612
- keydownHandler(e) {
613
- if (this.isActive && this.navigable) {
614
- this.ngZone.run(() => {
615
- this.navigationService.move(e);
616
- });
617
- }
618
- }
619
- verifyLoadMoreService() {
620
- if (isDevMode() && !isPresent(this.loadMoreService)) {
621
- throw new Error(`To use the TreeView paging functionality, you need to assign the \`kendoTreeViewLoadMore\` directive. See ${LOAD_MORE_DOC_LINK}.`);
622
- }
623
- }
624
- registerLookupItems(data, parentItem = null) {
625
- if (!isPresent(data) || data.length === 0) {
626
- return;
627
- }
628
- const parentIndex = nodeIndex(parentItem);
629
- const treeItems = data.map((node, index) => buildTreeItem(node, index, parentIndex));
630
- if (isPresent(parentItem)) {
631
- this.treeViewLookupService.registerChildren(parentIndex, treeItems);
632
- }
633
- treeItems.forEach(item => {
634
- this.treeViewLookupService.registerItem(item, parentItem);
635
- if (this.hasChildren(item.dataItem)) {
636
- this.children(item.dataItem)
637
- .subscribe(children => this.registerLookupItems(children, item));
638
- }
639
- });
640
- }
641
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", 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 });
642
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: TreeViewComponent, isStandalone: true, 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", hasCheckbox: "hasCheckbox", 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.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 }, { propertyName: "searchbox", first: true, predicate: ["searchbox"], descendants: true }], exportAs: ["kendoTreeView"], usesOnChanges: true, ngImport: i0, template: `
643
- <ng-container kendoTreeViewLocalizedMessages
644
- i18n-loadMore="kendo.treeview.loadMore|The title of the Load More button"
645
- loadMore="Load more..."
646
- >
647
- </ng-container>
648
- @if (filterable) {
649
- <span
650
- class="k-treeview-filter"
651
- >
652
- <kendo-textbox
653
- #searchbox
654
- [size]="size"
655
- [value]="filter"
656
- [clearButton]="true"
657
- (valueChange)="filterChange.emit($event)"
658
- [placeholder]="filterInputPlaceholder"
659
- >
660
- <ng-template kendoTextBoxPrefixTemplate>
661
- <kendo-icon-wrapper
662
- innerCssClass="k-input-icon"
663
- name="search"
664
- [svgIcon]="searchIcon"
665
- >
666
- </kendo-icon-wrapper>
667
- </ng-template>
668
- </kendo-textbox>
669
- </span>
670
- }
671
- <ul class="k-treeview-lines"
672
- kendoTreeViewGroup
673
- [attr.id]="treeviewId"
674
- role="tree"
675
- [size]="size"
676
- [loadOnDemand]="loadOnDemand"
677
- [checkboxes]="checkboxes"
678
- [expandIcons]="expandIcons"
679
- [selectable]="selectable"
680
- [touchActions]="touchActions"
681
- [children]="children"
682
- [hasChildren]="hasChildren"
683
- [isChecked]="isChecked"
684
- [isDisabled]="isDisabled"
685
- [hasCheckbox]="hasCheckbox"
686
- [disableParentNodesOnly]="disableParentNodesOnly"
687
- [isExpanded]="isExpanded"
688
- [isSelected]="isSelected"
689
- [isVisible]="isVisible"
690
- [nodeTemplateRef]="nodeTemplateRef?.templateRef"
691
- [loadMoreButtonTemplateRef]="loadMoreButtonTemplateRef?.templateRef"
692
- [textField]="textField"
693
- [nodes]="fetchNodes"
694
- [loadMoreService]="loadMoreService"
695
- [trackBy]="trackBy"
696
- [expandDisabledNodes]="expandDisabledNodes"
697
- >
698
- </ul>
699
- <ng-container #assetsContainer></ng-container>
700
- `, isInline: true, dependencies: [{ kind: "directive", type: LocalizedMessagesDirective, selector: "[kendoTreeViewLocalizedMessages]" }, { kind: "component", type: TextBoxComponent, selector: "kendo-textbox", inputs: ["focusableId", "title", "type", "disabled", "readonly", "tabindex", "value", "selectOnFocus", "showSuccessIcon", "showErrorIcon", "clearButton", "successIcon", "successSvgIcon", "errorIcon", "errorSvgIcon", "clearButtonIcon", "clearButtonSvgIcon", "size", "rounded", "fillMode", "tabIndex", "placeholder", "maxlength", "inputAttributes"], outputs: ["valueChange", "inputFocus", "inputBlur", "focus", "blur"], exportAs: ["kendoTextBox"] }, { kind: "directive", type: TextBoxPrefixTemplateDirective, selector: "[kendoTextBoxPrefixTemplate]", inputs: ["showSeparator"] }, { kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "component", type: TreeViewGroupComponent, selector: "[kendoTreeViewGroup]", inputs: ["checkboxes", "expandIcons", "disabled", "selectable", "touchActions", "disableParentNodesOnly", "loadOnDemand", "trackBy", "nodes", "textField", "parentDataItem", "parentIndex", "nodeTemplateRef", "loadMoreButtonTemplateRef", "loadMoreService", "size", "expandDisabledNodes", "isChecked", "isDisabled", "hasCheckbox", "isExpanded", "isVisible", "isSelected", "children", "hasChildren"] }], changeDetection: i0.ChangeDetectionStrategy.Default });
701
- }
702
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TreeViewComponent, decorators: [{
703
- type: Component,
704
- args: [{
705
- changeDetection: ChangeDetectionStrategy.Default,
706
- exportAs: 'kendoTreeView',
707
- providers: providers,
708
- selector: 'kendo-treeview',
709
- template: `
710
- <ng-container kendoTreeViewLocalizedMessages
711
- i18n-loadMore="kendo.treeview.loadMore|The title of the Load More button"
712
- loadMore="Load more..."
713
- >
714
- </ng-container>
715
- @if (filterable) {
716
- <span
717
- class="k-treeview-filter"
718
- >
719
- <kendo-textbox
720
- #searchbox
721
- [size]="size"
722
- [value]="filter"
723
- [clearButton]="true"
724
- (valueChange)="filterChange.emit($event)"
725
- [placeholder]="filterInputPlaceholder"
726
- >
727
- <ng-template kendoTextBoxPrefixTemplate>
728
- <kendo-icon-wrapper
729
- innerCssClass="k-input-icon"
730
- name="search"
731
- [svgIcon]="searchIcon"
732
- >
733
- </kendo-icon-wrapper>
734
- </ng-template>
735
- </kendo-textbox>
736
- </span>
737
- }
738
- <ul class="k-treeview-lines"
739
- kendoTreeViewGroup
740
- [attr.id]="treeviewId"
741
- role="tree"
742
- [size]="size"
743
- [loadOnDemand]="loadOnDemand"
744
- [checkboxes]="checkboxes"
745
- [expandIcons]="expandIcons"
746
- [selectable]="selectable"
747
- [touchActions]="touchActions"
748
- [children]="children"
749
- [hasChildren]="hasChildren"
750
- [isChecked]="isChecked"
751
- [isDisabled]="isDisabled"
752
- [hasCheckbox]="hasCheckbox"
753
- [disableParentNodesOnly]="disableParentNodesOnly"
754
- [isExpanded]="isExpanded"
755
- [isSelected]="isSelected"
756
- [isVisible]="isVisible"
757
- [nodeTemplateRef]="nodeTemplateRef?.templateRef"
758
- [loadMoreButtonTemplateRef]="loadMoreButtonTemplateRef?.templateRef"
759
- [textField]="textField"
760
- [nodes]="fetchNodes"
761
- [loadMoreService]="loadMoreService"
762
- [trackBy]="trackBy"
763
- [expandDisabledNodes]="expandDisabledNodes"
764
- >
765
- </ul>
766
- <ng-container #assetsContainer></ng-container>
767
- `,
768
- standalone: true,
769
- imports: [LocalizedMessagesDirective, TextBoxComponent, TextBoxPrefixTemplateDirective, IconWrapperComponent, TreeViewGroupComponent]
770
- }]
771
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.ExpandStateService }, { type: i2.NavigationService }, { type: i3.NodeChildrenService }, { type: i4.SelectionService }, { type: i5.TreeViewLookupService }, { type: i0.NgZone }, { type: i0.Renderer2 }, { type: i6.DataChangeNotificationService }, { type: i7.LocalizationService }], propDecorators: { classNames: [{
772
- type: HostBinding,
773
- args: ["class.k-treeview"]
774
- }], direction: [{
775
- type: HostBinding,
776
- args: ["attr.dir"]
777
- }], assetsContainer: [{
778
- type: ViewChild,
779
- args: ['assetsContainer', { read: ViewContainerRef, static: true }]
780
- }], searchbox: [{
781
- type: ViewChild,
782
- args: ['searchbox']
783
- }], filterInputPlaceholder: [{
784
- type: Input
785
- }], expandDisabledNodes: [{
786
- type: Input
787
- }], animate: [{
788
- type: Input
789
- }, {
790
- type: HostBinding,
791
- args: ['@.disabled']
792
- }], childrenLoaded: [{
793
- type: Output
794
- }], onBlur: [{
795
- type: Output,
796
- args: ['blur']
797
- }], onFocus: [{
798
- type: Output,
799
- args: ['focus']
800
- }], expand: [{
801
- type: Output
802
- }], collapse: [{
803
- type: Output
804
- }], nodeDragStart: [{
805
- type: Output
806
- }], nodeDrag: [{
807
- type: Output
808
- }], filterStateChange: [{
809
- type: Output
810
- }], nodeDrop: [{
811
- type: Output
812
- }], nodeDragEnd: [{
813
- type: Output
814
- }], addItem: [{
815
- type: Output
816
- }], removeItem: [{
817
- type: Output
818
- }], checkedChange: [{
819
- type: Output
820
- }], selectionChange: [{
821
- type: Output
822
- }], filterChange: [{
823
- type: Output
824
- }], nodeClick: [{
825
- type: Output
826
- }], nodeDblClick: [{
827
- type: Output
828
- }], nodeTemplateQuery: [{
829
- type: ContentChild,
830
- args: [NodeTemplateDirective, { static: false }]
831
- }], nodeTemplateRef: [{
832
- type: Input,
833
- args: ['nodeTemplate']
834
- }], loadMoreButtonTemplateQuery: [{
835
- type: ContentChild,
836
- args: [LoadMoreButtonTemplateDirective, { static: false }]
837
- }], loadMoreButtonTemplateRef: [{
838
- type: Input,
839
- args: ['loadMoreButtonTemplate']
840
- }], trackBy: [{
841
- type: Input
842
- }], nodes: [{
843
- type: Input
844
- }], textField: [{
845
- type: Input
846
- }], hasChildren: [{
847
- type: Input
848
- }], isChecked: [{
849
- type: Input
850
- }], isDisabled: [{
851
- type: Input
852
- }], hasCheckbox: [{
853
- type: Input
854
- }], isExpanded: [{
855
- type: Input
856
- }], isSelected: [{
857
- type: Input
858
- }], isVisible: [{
859
- type: Input
860
- }], navigable: [{
861
- type: Input
862
- }], children: [{
863
- type: Input
864
- }], loadOnDemand: [{
865
- type: Input
866
- }], filterable: [{
867
- type: Input
868
- }], filter: [{
869
- type: Input
870
- }], size: [{
871
- type: Input
872
- }], disableParentNodesOnly: [{
873
- type: Input
874
- }] } });