@progress/kendo-angular-treeview 21.4.1 → 22.0.0

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,348 +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 { Directive, ElementRef, NgZone, ContentChild, Input, HostBinding } from '@angular/core';
6
- import { hasObservers } from '@progress/kendo-angular-common';
7
- import { Draggable } from '@progress/kendo-draggable';
8
- import { DragClueService } from './drag-clue/drag-clue.service';
9
- import { DropHintService } from './drop-hint/drop-hint.service';
10
- import { DragClueTemplateDirective } from './drag-clue/drag-clue-template.directive';
11
- import { DropHintTemplateDirective } from './drop-hint/drop-hint-template.directive';
12
- import { getDropAction, getDropPosition, treeItemFromEventTarget, getContainerOffset, getDropTarget } from './drag-and-drop-utils';
13
- import { closestWithMatch, isPresent, isContent } from '../utils';
14
- import { TreeViewComponent } from '../treeview.component';
15
- import { TreeItemDropEvent, DropPosition, TreeItemDragStartEvent } from './models';
16
- import * as i0 from "@angular/core";
17
- import * as i1 from "../treeview.component";
18
- import * as i2 from "./drag-clue/drag-clue.service";
19
- import * as i3 from "./drop-hint/drop-hint.service";
20
- const DEFAULT_SCROLL_SETTINGS = {
21
- enabled: true,
22
- step: 1,
23
- interval: 1
24
- };
25
- /**
26
- * Represents the directive that enables you to drag and drop items inside the current TreeView or between multiple linked TreeView component instances
27
- * ([see example](slug:draganddrop_treeview)).
28
- *
29
- * Triggers the [`nodeDragStart`](slug:api_treeview_treeviewcomponent#nodedragstart),
30
- * [`nodeDrag`](slug:api_treeview_treeviewcomponent#nodedrag),
31
- * [`nodeDrop`](slug:api_treeview_treeviewcomponent#nodedrop),
32
- * [`nodeDragEnd`](slug:api_treeview_treeviewcomponent#nodedragend),
33
- * [`addItem`](slug:api_treeview_treeviewcomponent#additem) and
34
- * [`removeItem`](slug:api_treeview_treeviewcomponent#removeitem)
35
- * events when you perform the corresponding actions.
36
- *
37
- * @example
38
- * ```html
39
- * <kendo-treeview
40
- * kendoTreeViewDragAndDrop
41
- * [dropZoneTreeViews]="treeView"
42
- * >
43
- * </kendo-treeview>
44
- * ```
45
- *
46
- * @remarks
47
- * Applied to: {@link TreeViewComponent}
48
- */
49
- export class DragAndDropDirective {
50
- element;
51
- zone;
52
- treeview;
53
- dragClueService;
54
- dropHintService;
55
- /**
56
- * Specifies whether the `removeItem` event fires after the user drops an item while pressing the `ctrl` key.
57
- * If enabled, the `removeItem` event does not fire on the source TreeView
58
- * ([see example](slug:draganddrop_treeview#multiple-treeviews)).
59
- *
60
- * @default false
61
- */
62
- allowCopy = false;
63
- /**
64
- * Specifies the `TreeViewComponent` instances into which the user can drop dragged items from the current `TreeViewComponent`
65
- * ([see example](slug:draganddrop_treeview#multiple-treeviews)).
66
- */
67
- dropZoneTreeViews = [];
68
- /**
69
- * Specifies the distance in pixels from the initial item `pointerdown` event before dragging starts.
70
- * The `nodeDragStart` and all subsequent TreeView drag events do not fire until dragging begins.
71
- *
72
- * @default 5
73
- */
74
- startDragAfter = 5;
75
- /**
76
- * Controls the auto-scrolling behavior during drag-and-drop ([see example](slug:draganddrop_treeview#auto-scrolling)).
77
- * Enabled by default. To turn off auto-scrolling, set this property to `false`.
78
- *
79
- * By default, scrolling occurs by 1 pixel every 1 millisecond when the dragged item reaches the top or bottom of the scrollable container.
80
- * You can override the `step` and `interval` by providing a `DragAndDropScrollSettings` object.
81
- *
82
- * @default true
83
- */
84
- autoScroll = true;
85
- /**
86
- * @hidden
87
- */
88
- dragClueTemplate;
89
- /**
90
- * @hidden
91
- */
92
- dropHintTemplate;
93
- /**
94
- * @hidden
95
- */
96
- userSelectStyle = 'none';
97
- draggable;
98
- draggedItem;
99
- /**
100
- * The pointer event of the last successful item pointerdown event (the draggable `press` event).
101
- * Used for determining whether the `startDragAfter` distance is covered and for the `nodeDragStart` event args.
102
- * Used also as a flag for whether a drag attempt is pending. Should be set to `null` once the dragging begins.
103
- */
104
- pendingDragStartEvent;
105
- get scrollSettings() {
106
- const userProvidedSettings = typeof this.autoScroll === 'boolean' ?
107
- { enabled: this.autoScroll } :
108
- this.autoScroll;
109
- return Object.assign({}, DEFAULT_SCROLL_SETTINGS, userProvidedSettings);
110
- }
111
- /**
112
- * Describes the offset of the parent element if the latter has the `transform` CSS prop applied.
113
- * Transformed parents create new stacking context and the fixed children must be position based on the transformed parent.
114
- * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
115
- */
116
- containerOffset = { top: 0, left: 0 };
117
- constructor(element, zone, treeview, dragClueService, dropHintService) {
118
- this.element = element;
119
- this.zone = zone;
120
- this.treeview = treeview;
121
- this.dragClueService = dragClueService;
122
- this.dropHintService = dropHintService;
123
- this.treeview.touchActions = false;
124
- }
125
- ngAfterContentInit() {
126
- this.initalizeDraggable();
127
- this.dragClueService.initialize(this.treeview.assetsContainer, this.dragClueTemplate && this.dragClueTemplate.templateRef);
128
- this.dropHintService.initialize(this.treeview.assetsContainer, this.dropHintTemplate && this.dropHintTemplate.templateRef);
129
- }
130
- ngOnDestroy() {
131
- this.draggable.destroy();
132
- }
133
- /**
134
- * @hidden
135
- */
136
- handlePress({ originalEvent }) {
137
- if (!isContent(originalEvent.target)) {
138
- return;
139
- }
140
- // store the drag target on press, show it only when it's actually dragged
141
- this.draggedItem = closestWithMatch(originalEvent.target, '.k-treeview-leaf');
142
- // record the current pointer down coords - copared to the `startDragAfter` value to calculate whether to initiate dragging
143
- this.pendingDragStartEvent = originalEvent;
144
- }
145
- /**
146
- * @hidden
147
- */
148
- handleDrag({ originalEvent, clientX, clientY }) {
149
- if (this.shouldInitiateDragStart({ clientX, clientY })) {
150
- this.initiateDragStart();
151
- }
152
- if (!isPresent(this.draggedItem) || isPresent(this.pendingDragStartEvent)) {
153
- return;
154
- }
155
- const dropTarget = getDropTarget(originalEvent);
156
- if (hasObservers(this.treeview.nodeDrag)) {
157
- this.zone.run(() => this.notifyDrag(originalEvent, dropTarget));
158
- }
159
- const targetTreeView = this.getTargetTreeView(dropTarget);
160
- const dropPosition = getDropPosition(this.draggedItem, dropTarget, clientY, targetTreeView, this.containerOffset);
161
- const dropHintAnchor = closestWithMatch(dropTarget, '.k-treeview-top, .k-treeview-mid, .k-treeview-bot');
162
- const dropAction = getDropAction(dropPosition, dropTarget);
163
- const sourceItem = treeItemFromEventTarget(this.treeview, this.draggedItem);
164
- const destinationItem = treeItemFromEventTarget(targetTreeView, dropTarget);
165
- this.updateDropHintState(dropPosition, dropHintAnchor, dropAction, sourceItem, destinationItem);
166
- this.updateDragClueState(dropAction, clientX, clientY, sourceItem, destinationItem);
167
- if (this.scrollSettings.enabled) {
168
- this.dragClueService.scrollIntoView(this.scrollSettings);
169
- }
170
- }
171
- /**
172
- * @hidden
173
- */
174
- handleRelease({ originalEvent, clientY }) {
175
- if (this.scrollSettings.enabled) {
176
- this.dragClueService.cancelScroll();
177
- }
178
- if (!isPresent(this.draggedItem) || isPresent(this.pendingDragStartEvent)) {
179
- this.pendingDragStartEvent = null;
180
- this.draggedItem = null;
181
- return;
182
- }
183
- const dropTarget = getDropTarget(originalEvent);
184
- const sourceTree = this.treeview;
185
- const destinationTree = this.getTargetTreeView(dropTarget);
186
- const dropPosition = getDropPosition(this.draggedItem, dropTarget, clientY, this.getTargetTreeView(dropTarget), this.containerOffset);
187
- const sourceItem = treeItemFromEventTarget(sourceTree, this.draggedItem);
188
- const destinationItem = treeItemFromEventTarget(destinationTree, dropTarget);
189
- if (isPresent(destinationItem) && isPresent(dropPosition)) {
190
- this.zone.run(() => this.notifyDrop({ sourceItem, destinationItem, dropPosition, sourceTree, destinationTree }, originalEvent));
191
- }
192
- else {
193
- this.dragClueService.animateDragClueToElementPosition(this.draggedItem);
194
- }
195
- if (hasObservers(this.treeview.nodeDragEnd)) {
196
- this.zone.run(() => this.notifyDragEnd({ sourceItem, destinationItem, originalEvent }));
197
- }
198
- this.dropHintService.hide();
199
- this.draggedItem = null;
200
- }
201
- updateDropHintState(dropPosition, dropHintAnchor, dropAction, sourceItem, destinationItem) {
202
- if (!isPresent(dropHintAnchor) || dropPosition === DropPosition.Over || !isPresent(dropPosition)) {
203
- this.dropHintService.hide();
204
- return;
205
- }
206
- const anchorViewPortCoords = dropHintAnchor.getBoundingClientRect();
207
- const insertBefore = dropPosition === DropPosition.Before;
208
- const top = insertBefore ? anchorViewPortCoords.top : (anchorViewPortCoords.top + anchorViewPortCoords.height);
209
- this.dropHintService.updateDropHintData(dropAction, sourceItem, destinationItem);
210
- // clear any possible container offset created by parent elements with `transform` css property set
211
- this.dropHintService.move(anchorViewPortCoords.left - this.containerOffset.left, top - this.containerOffset.top);
212
- this.dropHintService.show();
213
- }
214
- updateDragClueState(dropAction, clientX, clientY, sourceItem, destinationItem) {
215
- // clear any possible container offset created by parent elements with `transform` css property set
216
- this.dragClueService.move(clientX - this.containerOffset.left, clientY - this.containerOffset.top);
217
- this.dragClueService.updateDragClueData(dropAction, sourceItem, destinationItem);
218
- this.dragClueService.show();
219
- }
220
- initalizeDraggable() {
221
- this.draggable = new Draggable({
222
- press: this.handlePress.bind(this),
223
- drag: this.handleDrag.bind(this),
224
- release: this.handleRelease.bind(this)
225
- });
226
- this.zone.runOutsideAngular(() => this.draggable.bindTo(this.element.nativeElement));
227
- }
228
- notifyDragStart(originalEvent, dropTarget) {
229
- const sourceItem = treeItemFromEventTarget(this.treeview, dropTarget);
230
- const event = new TreeItemDragStartEvent({ sourceItem, originalEvent });
231
- this.treeview.nodeDragStart.emit(event);
232
- return event;
233
- }
234
- notifyDrag(originalEvent, dropTarget) {
235
- const dragEvent = {
236
- sourceItem: treeItemFromEventTarget(this.treeview, this.draggedItem),
237
- destinationItem: treeItemFromEventTarget(this.getTargetTreeView(dropTarget), dropTarget),
238
- originalEvent
239
- };
240
- this.treeview.nodeDrag.emit(dragEvent);
241
- }
242
- notifyDrop(args, originalEvent) {
243
- const event = new TreeItemDropEvent(args, originalEvent);
244
- args.destinationTree.nodeDrop.emit(event);
245
- // disable the animations on drop and restore them afterwards (if they were initially turned on)
246
- this.disableAnimationsForNextTick(args.destinationTree);
247
- if (args.sourceTree !== args.destinationTree) {
248
- this.disableAnimationsForNextTick(args.sourceTree);
249
- }
250
- if (!event.isDefaultPrevented() && event.isValid) {
251
- this.dragClueService.hide();
252
- // order matters in a flat data binding scenario (first add, then remove)
253
- args.destinationTree.addItem.emit(args);
254
- if (!(originalEvent.ctrlKey && this.allowCopy)) {
255
- args.sourceTree.removeItem.emit(args);
256
- }
257
- }
258
- else if (event.isDefaultPrevented()) {
259
- // directly hide the clue if the default is prevented
260
- this.dragClueService.hide();
261
- }
262
- else if (!event.isValid) {
263
- // animate the clue back to the source item position if marked as invalid
264
- this.dragClueService.animateDragClueToElementPosition(this.draggedItem);
265
- }
266
- }
267
- notifyDragEnd(dragEndEvent) {
268
- this.treeview.nodeDragEnd.emit(dragEndEvent);
269
- }
270
- getTargetTreeView(dropTarget) {
271
- const treeViewTagName = this.treeview.element.nativeElement.tagName;
272
- const targetTreeView = closestWithMatch(dropTarget, treeViewTagName);
273
- return [this.treeview, ...this.dropZoneTreeViews].find(treeView => isPresent(treeView) && treeView.element.nativeElement === targetTreeView);
274
- }
275
- disableAnimationsForNextTick(treeView) {
276
- // the treeView.animate getter returns `true` when the animations are turned off
277
- // confusing, but seems on purpose (the `animate` prop sets the value of the @.disabled host-bound attribute)
278
- if (treeView.animate) {
279
- return;
280
- }
281
- treeView.animate = false;
282
- this.zone.runOutsideAngular(() => setTimeout(() => treeView.animate = true));
283
- }
284
- shouldInitiateDragStart(currentPointerCoords) {
285
- if (!isPresent(this.pendingDragStartEvent)) {
286
- return false;
287
- }
288
- const distanceFromPointerDown = Math.sqrt(Math.pow((this.pendingDragStartEvent.clientX - currentPointerCoords.clientX), 2) +
289
- Math.pow((this.pendingDragStartEvent.clientY - currentPointerCoords.clientY), 2));
290
- return distanceFromPointerDown >= this.startDragAfter;
291
- }
292
- initiateDragStart() {
293
- if (hasObservers(this.treeview.nodeDragStart)) {
294
- const dragStartEvent = this.zone.run(() => this.notifyDragStart(this.pendingDragStartEvent, getDropTarget(this.pendingDragStartEvent)));
295
- if (dragStartEvent.isDefaultPrevented()) {
296
- this.pendingDragStartEvent = null;
297
- this.draggedItem = null;
298
- return;
299
- }
300
- }
301
- this.dragClueService.cancelReturnAnimation();
302
- this.dragClueService.updateText(this.draggedItem.innerText);
303
- this.containerOffset = getContainerOffset(this.draggedItem);
304
- this.pendingDragStartEvent = null;
305
- }
306
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragAndDropDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i1.TreeViewComponent }, { token: i2.DragClueService }, { token: i3.DropHintService }], target: i0.ɵɵFactoryTarget.Directive });
307
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: DragAndDropDirective, isStandalone: true, selector: "[kendoTreeViewDragAndDrop]", inputs: { allowCopy: "allowCopy", dropZoneTreeViews: "dropZoneTreeViews", startDragAfter: "startDragAfter", autoScroll: "autoScroll" }, host: { properties: { "style.user-select": "this.userSelectStyle", "style.-ms-user-select": "this.userSelectStyle", "style.-moz-user-select": "this.userSelectStyle", "style.-webkit-user-select": "this.userSelectStyle" } }, providers: [
308
- DragClueService,
309
- DropHintService
310
- ], queries: [{ propertyName: "dragClueTemplate", first: true, predicate: DragClueTemplateDirective, descendants: true }, { propertyName: "dropHintTemplate", first: true, predicate: DropHintTemplateDirective, descendants: true }], ngImport: i0 });
311
- }
312
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragAndDropDirective, decorators: [{
313
- type: Directive,
314
- args: [{
315
- selector: '[kendoTreeViewDragAndDrop]',
316
- providers: [
317
- DragClueService,
318
- DropHintService
319
- ],
320
- standalone: true
321
- }]
322
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.TreeViewComponent }, { type: i2.DragClueService }, { type: i3.DropHintService }], propDecorators: { allowCopy: [{
323
- type: Input
324
- }], dropZoneTreeViews: [{
325
- type: Input
326
- }], startDragAfter: [{
327
- type: Input
328
- }], autoScroll: [{
329
- type: Input
330
- }], dragClueTemplate: [{
331
- type: ContentChild,
332
- args: [DragClueTemplateDirective, { static: false }]
333
- }], dropHintTemplate: [{
334
- type: ContentChild,
335
- args: [DropHintTemplateDirective, { static: false }]
336
- }], userSelectStyle: [{
337
- type: HostBinding,
338
- args: ['style.user-select']
339
- }, {
340
- type: HostBinding,
341
- args: ['style.-ms-user-select']
342
- }, {
343
- type: HostBinding,
344
- args: ['style.-moz-user-select']
345
- }, {
346
- type: HostBinding,
347
- args: ['style.-webkit-user-select']
348
- }] } });
@@ -1,44 +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 { Directive, Optional, TemplateRef } from '@angular/core';
6
- import * as i0 from "@angular/core";
7
- /**
8
- * Represents the template for the TreeView drag clue when you drag an item.
9
- *
10
- * To define the drag clue template, nest an `<ng-template>` tag with the `kendoTreeViewDragClueTemplate` directive inside a `<kendo-treeview>` tag
11
- * ([see example](slug:draganddrop_treeview#toc-templates)).
12
- *
13
- * The template context provides the following variables:
14
- * - `let-text="text"` (`string`)&mdash;The display text of the item being dragged.
15
- * - `let-action="action"` ([`DropAction`](slug:api_treeview_dropaction))&mdash;The type of drop action that will occur.
16
- * - `let-sourceItem="sourceItem"` ([`TreeItemLookup`](slug:api_treeview_treeitemlookup))&mdash;The TreeView item that is being dragged from its original position.
17
- * - `let-destinationItem="destinationItem"` ([`TreeItemLookup`](slug:api_treeview_treeitemlookup))&mdash;The TreeView item that serves as the target for the drop operation.
18
- *
19
- * @example
20
- * ```html
21
- * <kendo-treeview>
22
- * <ng-template kendoTreeViewDragClueTemplate let-text="text">
23
- * Dragging: {{ text }}
24
- * </ng-template>
25
- * </kendo-treeview>
26
- * ```
27
- */
28
- export class DragClueTemplateDirective {
29
- templateRef;
30
- constructor(templateRef) {
31
- this.templateRef = templateRef;
32
- }
33
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueTemplateDirective, deps: [{ token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
34
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: DragClueTemplateDirective, isStandalone: true, selector: "[kendoTreeViewDragClueTemplate]", ngImport: i0 });
35
- }
36
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueTemplateDirective, decorators: [{
37
- type: Directive,
38
- args: [{
39
- selector: '[kendoTreeViewDragClueTemplate]',
40
- standalone: true
41
- }]
42
- }], ctorParameters: () => [{ type: i0.TemplateRef, decorators: [{
43
- type: Optional
44
- }] }] });
@@ -1,132 +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 { Component, HostBinding, ChangeDetectorRef, ChangeDetectionStrategy } from "@angular/core";
6
- import { DropAction } from '../models';
7
- import { cancelIcon, insertBottomIcon, insertMiddleIcon, insertTopIcon, plusIcon } from "@progress/kendo-svg-icons";
8
- import { NgTemplateOutlet } from "@angular/common";
9
- import { IconWrapperComponent } from "@progress/kendo-angular-icons";
10
- import * as i0 from "@angular/core";
11
- /**
12
- * @hidden
13
- */
14
- export class DragClueComponent {
15
- cdr;
16
- hostClasses = true;
17
- /**
18
- * The text value of the dragged TreeView item.
19
- */
20
- text;
21
- /**
22
- * The attempted operation according to the current drop target.
23
- */
24
- action;
25
- /**
26
- * The look-up info for the currently dragged item.
27
- */
28
- sourceItem;
29
- /**
30
- * The look-up info for the destination item (if hovering a valid drop target).
31
- */
32
- destinationItem;
33
- /**
34
- * Defines the drag clue content template.
35
- */
36
- template;
37
- posistionStyle = 'fixed';
38
- get statusIconClass() {
39
- switch (this.action) {
40
- case DropAction.Add: return 'plus';
41
- case DropAction.InsertTop: return 'insert-top';
42
- case DropAction.InsertBottom: return 'insert-bottom';
43
- case DropAction.InsertMiddle: return 'insert-middle';
44
- case DropAction.Invalid:
45
- default: return 'cancel';
46
- }
47
- }
48
- get statusSVGIcon() {
49
- switch (this.action) {
50
- case DropAction.Add: return plusIcon;
51
- case DropAction.InsertTop: return insertTopIcon;
52
- case DropAction.InsertBottom: return insertBottomIcon;
53
- case DropAction.InsertMiddle: return insertMiddleIcon;
54
- case DropAction.Invalid:
55
- default: return cancelIcon;
56
- }
57
- }
58
- constructor(cdr) {
59
- this.cdr = cdr;
60
- }
61
- // exposed as a public method that can be called from outside as the component uses `OnPush` strategy
62
- detectChanges() {
63
- this.cdr.detectChanges();
64
- }
65
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
66
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: DragClueComponent, isStandalone: true, selector: "kendo-treeview-drag-clue", host: { properties: { "class.k-header": "this.hostClasses", "class.k-drag-clue": "this.hostClasses", "style.position": "this.posistionStyle" } }, ngImport: i0, template: `
67
- @if (!template) {
68
- <kendo-icon-wrapper
69
- innerCssClass="k-drag-status"
70
- [name]="statusIconClass"
71
- [svgIcon]="statusSVGIcon"
72
- >
73
- </kendo-icon-wrapper>
74
- <span>{{text}}</span>
75
- }
76
-
77
- @if (template) {
78
- <ng-template
79
- [ngTemplateOutlet]="template"
80
- [ngTemplateOutletContext]="{
81
- text: text,
82
- action: action,
83
- sourceItem: sourceItem,
84
- destinationItem: destinationItem
85
- }"
86
- >
87
- </ng-template>
88
- }
89
- `, isInline: true, dependencies: [{ kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
90
- }
91
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueComponent, decorators: [{
92
- type: Component,
93
- args: [{
94
- changeDetection: ChangeDetectionStrategy.OnPush,
95
- selector: 'kendo-treeview-drag-clue',
96
- template: `
97
- @if (!template) {
98
- <kendo-icon-wrapper
99
- innerCssClass="k-drag-status"
100
- [name]="statusIconClass"
101
- [svgIcon]="statusSVGIcon"
102
- >
103
- </kendo-icon-wrapper>
104
- <span>{{text}}</span>
105
- }
106
-
107
- @if (template) {
108
- <ng-template
109
- [ngTemplateOutlet]="template"
110
- [ngTemplateOutletContext]="{
111
- text: text,
112
- action: action,
113
- sourceItem: sourceItem,
114
- destinationItem: destinationItem
115
- }"
116
- >
117
- </ng-template>
118
- }
119
- `,
120
- standalone: true,
121
- imports: [IconWrapperComponent, NgTemplateOutlet]
122
- }]
123
- }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { hostClasses: [{
124
- type: HostBinding,
125
- args: ['class.k-header']
126
- }, {
127
- type: HostBinding,
128
- args: ['class.k-drag-clue']
129
- }], posistionStyle: [{
130
- type: HostBinding,
131
- args: ['style.position']
132
- }] } });
@@ -1,123 +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 { Injectable } from '@angular/core';
6
- import { DragClueComponent } from './drag-clue.component';
7
- import { ScrollDirection } from '../models';
8
- import { isPresent, dataItemsEqual } from '../../utils';
9
- import { DragAndDropAssetService } from '../editing-services/drag-and-drop-asset.service';
10
- import { scrollElementBy, getScrollableContainer } from '../drag-and-drop-utils';
11
- import * as i0 from "@angular/core";
12
- /**
13
- * @hidden
14
- */
15
- export const CLUE_OFFSET = 10;
16
- /**
17
- * @hidden
18
- */
19
- export const RETURN_ANIMATION_DURATION = 200;
20
- /**
21
- * @hidden
22
- */
23
- export class DragClueService extends DragAndDropAssetService {
24
- returnAnimation;
25
- scrollInterval;
26
- constructor() {
27
- super();
28
- }
29
- initialize(container, template) {
30
- if (isPresent(this._componentRef)) {
31
- this.ngOnDestroy();
32
- }
33
- this.componentRef = container.createComponent(DragClueComponent);
34
- this.hide();
35
- this.componentRef.instance.template = template;
36
- this.componentRef.changeDetectorRef.detectChanges();
37
- }
38
- ngOnDestroy() {
39
- this.cancelReturnAnimation();
40
- this.cancelScroll();
41
- super.ngOnDestroy();
42
- }
43
- move(left, top) {
44
- super.move(left, top, CLUE_OFFSET);
45
- }
46
- animateDragClueToElementPosition(target) {
47
- if (!(isPresent(target) && isPresent(this.element.animate))) {
48
- this.hide();
49
- return;
50
- }
51
- const targetElementViewPortCoords = target.getBoundingClientRect();
52
- const clueElementViewPortCoords = this.element.getBoundingClientRect();
53
- this.returnAnimation = this.element.animate([
54
- { transform: 'translate(0, 0)' },
55
- { transform: `translate(${targetElementViewPortCoords.left - clueElementViewPortCoords.left}px, ${targetElementViewPortCoords.top - clueElementViewPortCoords.top}px)` }
56
- ], RETURN_ANIMATION_DURATION);
57
- this.returnAnimation.onfinish = () => this.hide();
58
- }
59
- cancelReturnAnimation() {
60
- if (!isPresent(this.returnAnimation)) {
61
- return;
62
- }
63
- this.returnAnimation.cancel();
64
- this.returnAnimation = null;
65
- }
66
- updateDragClueData(action, sourceItem, destinationItem) {
67
- const dragClue = this.componentRef.instance;
68
- if (action === dragClue.action && dataItemsEqual(sourceItem, dragClue.sourceItem) && dataItemsEqual(destinationItem, dragClue.destinationItem)) {
69
- return;
70
- }
71
- dragClue.action = action;
72
- dragClue.sourceItem = sourceItem;
73
- dragClue.destinationItem = destinationItem;
74
- dragClue.detectChanges();
75
- }
76
- updateText(text) {
77
- if (text === this.componentRef.instance.text) {
78
- return;
79
- }
80
- this.componentRef.instance.text = text;
81
- this.componentRef.instance.detectChanges();
82
- }
83
- /**
84
- * Triggers the first scrollable parent to scroll upwards or downwards.
85
- * Uses setInterval, so should be called outside the angular zone.
86
- */
87
- scrollIntoView({ step, interval }) {
88
- this.cancelScroll();
89
- const scrollableContainer = getScrollableContainer(this.element);
90
- if (!isPresent(scrollableContainer)) {
91
- return;
92
- }
93
- const containerRect = scrollableContainer.getBoundingClientRect();
94
- const clueRect = this.element.getBoundingClientRect();
95
- // if the beginning of the scrollable container is above the current viewport, fall-back to 0
96
- const firstVisibleClientTopPart = Math.max(containerRect.top, 0);
97
- // start scrolling up when the first visible item is dragged over
98
- const topLimit = firstVisibleClientTopPart + clueRect.height;
99
- // if the end of the scrollable container is beneath the current viewport, fall-back to its client height
100
- // add the distance from the start of the viewport to the beginning of the container to ensure scrolling bottom begins when the actual end of the container is reached
101
- const bottomLimit = firstVisibleClientTopPart + Math.min(containerRect.bottom, scrollableContainer.clientHeight);
102
- if (clueRect.top < topLimit) {
103
- this.scrollInterval = setInterval(() => scrollElementBy(scrollableContainer, step, ScrollDirection.Up), interval);
104
- }
105
- else if (clueRect.bottom > bottomLimit) {
106
- this.scrollInterval = setInterval(() => scrollElementBy(scrollableContainer, step, ScrollDirection.Down), interval);
107
- }
108
- }
109
- /**
110
- * Cancels out the on-going scroll animation, if present.
111
- */
112
- cancelScroll() {
113
- if (isPresent(this.scrollInterval)) {
114
- clearInterval(this.scrollInterval);
115
- this.scrollInterval = null;
116
- }
117
- }
118
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
119
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueService });
120
- }
121
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragClueService, decorators: [{
122
- type: Injectable
123
- }], ctorParameters: () => [] });