@progress/kendo-angular-utils 12.0.0-develop.8 → 12.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 (59) hide show
  1. package/drag-and-drop/drag-state.service.d.ts +4 -0
  2. package/drag-and-drop/draghandle.directive.d.ts +1 -0
  3. package/drag-and-drop/dragtarget-container.directive.d.ts +164 -0
  4. package/drag-and-drop/dragtarget.directive.d.ts +45 -42
  5. package/drag-and-drop/droptarget-container.directive.d.ts +89 -0
  6. package/drag-and-drop/droptarget.directive.d.ts +7 -18
  7. package/drag-and-drop/events/drag-target/drag-event.d.ts +23 -5
  8. package/drag-and-drop/events/drag-target/dragready-event.d.ts +30 -0
  9. package/drag-and-drop/events/drag-target/end-event.d.ts +22 -4
  10. package/drag-and-drop/events/drag-target/index.d.ts +2 -0
  11. package/drag-and-drop/events/drag-target/press-event.d.ts +23 -5
  12. package/drag-and-drop/events/drag-target/release-event.d.ts +40 -0
  13. package/drag-and-drop/events/drag-target/start-event.d.ts +22 -4
  14. package/drag-and-drop/events/drop-target-event.d.ts +48 -0
  15. package/drag-and-drop/events/index.d.ts +6 -0
  16. package/drag-and-drop/hint.component.d.ts +4 -4
  17. package/{esm2020/drag-and-drop/events/drop-target/drop-event.mjs → drag-and-drop/models/drag-mode.d.ts} +2 -9
  18. package/drag-and-drop/models/functions.d.ts +17 -0
  19. package/drag-and-drop/models/hint-settings.d.ts +22 -0
  20. package/drag-and-drop/models/index.d.ts +4 -2
  21. package/drag-and-drop/util.d.ts +22 -2
  22. package/drag-and-drop.module.d.ts +5 -3
  23. package/esm2020/drag-and-drop/drag-state.service.mjs +2 -0
  24. package/esm2020/drag-and-drop/draghandle.directive.mjs +1 -0
  25. package/esm2020/drag-and-drop/dragtarget-container.directive.mjs +621 -0
  26. package/esm2020/drag-and-drop/dragtarget.directive.mjs +260 -162
  27. package/esm2020/drag-and-drop/droptarget-container.directive.mjs +224 -0
  28. package/esm2020/drag-and-drop/droptarget.directive.mjs +25 -43
  29. package/esm2020/drag-and-drop/events/drag-target/drag-event.mjs +15 -1
  30. package/esm2020/drag-and-drop/events/{drop-target/enter-event.mjs → drag-target/dragready-event.mjs} +2 -2
  31. package/esm2020/drag-and-drop/events/drag-target/end-event.mjs +15 -1
  32. package/esm2020/drag-and-drop/events/drag-target/index.mjs +2 -0
  33. package/esm2020/drag-and-drop/events/drag-target/press-event.mjs +15 -1
  34. package/esm2020/drag-and-drop/events/{drop-target/leave-event.mjs → drag-target/release-event.mjs} +16 -2
  35. package/esm2020/drag-and-drop/events/drag-target/start-event.mjs +15 -1
  36. package/esm2020/drag-and-drop/events/drop-target-event.mjs +29 -0
  37. package/esm2020/drag-and-drop/events/index.mjs +6 -0
  38. package/esm2020/drag-and-drop/hint.component.mjs +11 -18
  39. package/esm2020/drag-and-drop/models/functions.mjs +5 -0
  40. package/esm2020/drag-and-drop/models/hint-settings.mjs +5 -0
  41. package/esm2020/drag-and-drop/util.mjs +73 -5
  42. package/esm2020/drag-and-drop.module.mjs +8 -0
  43. package/esm2020/index.mjs +4 -1
  44. package/esm2020/package-metadata.mjs +2 -2
  45. package/fesm2015/progress-kendo-angular-utils.mjs +1349 -306
  46. package/fesm2020/progress-kendo-angular-utils.mjs +1352 -312
  47. package/index.d.ts +4 -2
  48. package/package.json +3 -3
  49. package/drag-and-drop/events/drop-target/drop-event.d.ts +0 -22
  50. package/drag-and-drop/events/drop-target/enter-event.d.ts +0 -22
  51. package/drag-and-drop/events/drop-target/index.d.ts +0 -8
  52. package/drag-and-drop/events/drop-target/leave-event.d.ts +0 -22
  53. package/drag-and-drop/events/drop-target/over-event.d.ts +0 -22
  54. package/drag-and-drop/models/allowed-target.d.ts +0 -16
  55. package/esm2020/drag-and-drop/events/drop-target/index.mjs +0 -8
  56. package/esm2020/drag-and-drop/events/drop-target/over-event.mjs +0 -15
  57. /package/drag-and-drop/models/{dragaxis.d.ts → drag-axis.d.ts} +0 -0
  58. /package/esm2020/drag-and-drop/models/{allowed-target.mjs → drag-axis.mjs} +0 -0
  59. /package/esm2020/drag-and-drop/models/{dragaxis.mjs → drag-mode.mjs} +0 -0
@@ -3,12 +3,14 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import * as i0 from '@angular/core';
6
- import { Directive, HostBinding, Component, Input, Injectable, EventEmitter, Output, ContentChildren, NgModule } from '@angular/core';
6
+ import { Directive, HostBinding, Component, Input, Injectable, EventEmitter, isDevMode, Output, ContentChildren, NgModule } from '@angular/core';
7
7
  import * as i1 from '@angular/common';
8
8
  import { CommonModule } from '@angular/common';
9
9
  import { validatePackage } from '@progress/kendo-licensing';
10
10
  import { dispatchDragAndDrop, getScrollableParent, autoScroll } from '@progress/kendo-draggable-common';
11
- import { PreventableEvent, contains, isDocumentAvailable } from '@progress/kendo-angular-common';
11
+ import { PreventableEvent, contains, isDocumentAvailable, parseCSSClassNames } from '@progress/kendo-angular-common';
12
+ import { fromEvent, merge } from 'rxjs';
13
+ import { filter } from 'rxjs/operators';
12
14
 
13
15
  /**
14
16
  * @hidden
@@ -17,13 +19,14 @@ const packageMetadata = {
17
19
  name: '@progress/kendo-angular-utils',
18
20
  productName: 'Kendo UI for Angular',
19
21
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
20
- publishDate: 1681813768,
21
- version: '12.0.0-develop.8',
22
+ publishDate: 1682434159,
23
+ version: '12.0.0',
22
24
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
23
25
  };
24
26
 
25
27
  /**
26
28
  * Represents the Kendo UI DragHandle directive for Angular.
29
+ * It is used to specify a concrete element within a drag target as a handle for dragging, instead the drag target itself.
27
30
  */
28
31
  class DragHandleDirective {
29
32
  constructor(element) {
@@ -44,68 +47,78 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
44
47
  args: ['class.k-cursor-pointer']
45
48
  }] } });
46
49
 
47
- /**
48
- * Arguments for the press event of the DragTarget.
49
- */
50
- class DragTargetPressEvent {
51
- /**
52
- * @hidden
53
- */
54
- constructor(args) {
55
- Object.assign(this, args);
56
- }
50
+ function isDocumentNode(container) {
51
+ return container.nodeType === 9;
57
52
  }
58
-
59
53
  /**
60
- * Arguments for the dragStart event of the DragTarget.
54
+ * @hidden
61
55
  */
62
- class DragTargetDragStartEvent extends PreventableEvent {
63
- /**
64
- * @hidden
65
- */
66
- constructor(args) {
67
- super();
68
- Object.assign(this, args);
69
- }
70
- }
71
-
56
+ const getAction = (event, draggable) => {
57
+ return {
58
+ event: event,
59
+ payload: draggable
60
+ };
61
+ };
72
62
  /**
73
- * Arguments for the dragEnd event of the DragTarget.
63
+ * @hidden
74
64
  */
75
- class DragTargetDragEndEvent {
76
- /**
77
- * @hidden
78
- */
79
- constructor(args) {
80
- Object.assign(this, args);
81
- }
82
- }
83
-
65
+ const dragTargetTransition = 'transform .3s ease-in-out';
84
66
  /**
85
- * Arguments for the drag event of the DragTarget.
67
+ * @hidden
86
68
  */
87
- class DragTargetDragEvent extends PreventableEvent {
88
- /**
89
- * @hidden
90
- */
91
- constructor(args) {
92
- super();
93
- Object.assign(this, args);
94
- }
95
- }
96
-
69
+ const isPresent = (value) => value !== null && value !== undefined;
97
70
  /**
98
71
  * @hidden
99
72
  */
100
- const dragTargetTransition = 'transform .3s ease-in-out';
73
+ function closestBySelector(element, selector) {
74
+ if (element.closest) {
75
+ return element.closest(selector);
76
+ }
77
+ const matches = Element.prototype.matches ?
78
+ (el, sel) => el.matches(sel)
79
+ : (el, sel) => el.msMatchesSelector(sel);
80
+ let node = element;
81
+ while (node && !isDocumentNode(node)) {
82
+ if (matches(node, selector)) {
83
+ return node;
84
+ }
85
+ node = node.parentNode;
86
+ }
87
+ }
101
88
  /**
102
89
  * @hidden
103
90
  */
104
- const getAction = (event, draggable) => {
105
- return {
106
- event: event,
107
- payload: draggable
108
- };
91
+ const intersect = (element, candidates) => {
92
+ let max = 0;
93
+ let result = null;
94
+ candidates.forEach((candidate) => {
95
+ if (candidate && element) {
96
+ const ration = getRatio(element, candidate);
97
+ if (ration > max) {
98
+ max = ration;
99
+ result = candidate;
100
+ }
101
+ }
102
+ });
103
+ return result;
104
+ };
105
+ const getRatio = (element, target) => {
106
+ const elementRect = element.getBoundingClientRect();
107
+ const targetRect = target.getBoundingClientRect();
108
+ const top = Math.max(targetRect.top, elementRect.top);
109
+ const left = Math.max(targetRect.left, elementRect.left);
110
+ const right = Math.min(targetRect.left + targetRect.width, elementRect.left + elementRect.width);
111
+ const bottom = Math.min(targetRect.top + targetRect.height, elementRect.top + elementRect.height);
112
+ const width = right - left;
113
+ const height = bottom - top;
114
+ if (left < right && top < bottom) {
115
+ const targetArea = targetRect.width * targetRect.height;
116
+ const entryArea = elementRect.width * elementRect.height;
117
+ const intersectionArea = width * height;
118
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
119
+ return Number(intersectionRatio.toFixed(4));
120
+ }
121
+ return 0;
109
122
  };
110
123
  /**
111
124
  * @hidden
@@ -119,30 +132,36 @@ const setElementStyles = (renderer, elem, styles) => {
119
132
  /**
120
133
  * @hidden
121
134
  */
122
- const isPresent = (value) => value !== null && value !== undefined;
135
+ const allPointerDownEvents = ['pointerdown', 'mousedown', 'touchstart'];
136
+ /**
137
+ * @hidden
138
+ */
139
+ const allPointerMoveEvents = ['pointermove', 'mousemove', 'touchmove'];
140
+ /**
141
+ * @hidden
142
+ */
143
+ const allPointerUpEvents = ['pointerup', 'pointercancel', 'mouseup', 'contextmenu', 'touchend', 'touchcancel'];
123
144
 
124
- const DEFAULT_ZINDEX = 10;
125
145
  /**
126
146
  * @hidden
127
147
  */
128
148
  class HintComponent {
129
149
  constructor(element) {
130
150
  this.element = element;
131
- this.hostClasses = true;
132
- this.zIndex = DEFAULT_ZINDEX;
133
- this.touchAction = 'none';
151
+ this.pointerEvents = 'none';
134
152
  }
135
153
  }
136
154
  HintComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: HintComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
137
- HintComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: HintComponent, selector: "ng-component", inputs: { template: "template", directive: "directive" }, host: { properties: { "class.k-pos-absolute": "this.hostClasses", "class.k-cursor-grab": "this.hostClasses", "style.zIndex": "this.zIndex", "style.touch-action": "this.touchAction" } }, ngImport: i0, template: `
138
- <ng-container *ngTemplateOutlet="template; context: { $implicit: directive }">
155
+ HintComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: HintComponent, selector: "kendo-draghint", inputs: { template: "template", directive: "directive", targetIndex: "targetIndex", contextData: "contextData" }, host: { properties: { "style.pointer-events": "this.pointerEvents" } }, ngImport: i0, template: `
156
+ <ng-container *ngTemplateOutlet="template; context: { $implicit: directive, index: targetIndex, data: contextData }">
139
157
  </ng-container>
140
158
  `, isInline: true, directives: [{ type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
141
159
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: HintComponent, decorators: [{
142
160
  type: Component,
143
161
  args: [{
162
+ selector: 'kendo-draghint',
144
163
  template: `
145
- <ng-container *ngTemplateOutlet="template; context: { $implicit: directive }">
164
+ <ng-container *ngTemplateOutlet="template; context: { $implicit: directive, index: targetIndex, data: contextData }">
146
165
  </ng-container>
147
166
  `
148
167
  }]
@@ -150,20 +169,159 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
150
169
  type: Input
151
170
  }], directive: [{
152
171
  type: Input
153
- }], hostClasses: [{
154
- type: HostBinding,
155
- args: ['class.k-pos-absolute']
156
- }, {
157
- type: HostBinding,
158
- args: ['class.k-cursor-grab']
159
- }], zIndex: [{
160
- type: HostBinding,
161
- args: ['style.zIndex']
162
- }], touchAction: [{
172
+ }], targetIndex: [{
173
+ type: Input
174
+ }], contextData: [{
175
+ type: Input
176
+ }], pointerEvents: [{
163
177
  type: HostBinding,
164
- args: ['style.touch-action']
178
+ args: ['style.pointer-events']
165
179
  }] } });
166
180
 
181
+ /**
182
+ * Arguments for the press event of the DragTarget and DragTargetContainer.
183
+ */
184
+ class DragTargetPressEvent {
185
+ /**
186
+ * @hidden
187
+ */
188
+ constructor(args) {
189
+ Object.assign(this, args);
190
+ }
191
+ /**
192
+ * Left for backward compatibility for the DragTarget deprecated events.
193
+ * @hidden
194
+ */
195
+ get normalizedEvent() {
196
+ return this.dragEvent;
197
+ }
198
+ /**
199
+ * Left for backward compatibility for the DragTarget deprecated events.
200
+ * @hidden
201
+ */
202
+ get hostElement() {
203
+ return this.dragTarget;
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Arguments for the dragReady event of the DragTarget and DragTargetContainer.
209
+ */
210
+ class DragTargetDragReadyEvent {
211
+ /**
212
+ * @hidden
213
+ */
214
+ constructor(args) {
215
+ Object.assign(this, args);
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Arguments for the dragStart event of the DragTarget and DragTargetContainer.
221
+ */
222
+ class DragTargetDragStartEvent extends PreventableEvent {
223
+ /**
224
+ * @hidden
225
+ */
226
+ constructor(args) {
227
+ super();
228
+ Object.assign(this, args);
229
+ }
230
+ /**
231
+ * Left for backward compatibility for the DragTarget deprecated events.
232
+ * @hidden
233
+ */
234
+ get normalizedEvent() {
235
+ return this.dragEvent;
236
+ }
237
+ /**
238
+ * Left for backward compatibility for the DragTarget deprecated events.
239
+ * @hidden
240
+ */
241
+ get hostElement() {
242
+ return this.dragTarget;
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Arguments for the dragEnd event of the DragTarget and DragTargetContainer.
248
+ */
249
+ class DragTargetDragEndEvent {
250
+ /**
251
+ * @hidden
252
+ */
253
+ constructor(args) {
254
+ Object.assign(this, args);
255
+ }
256
+ /**
257
+ * Left for backward compatibility for the DragTarget deprecated events.
258
+ * @hidden
259
+ */
260
+ get normalizedEvent() {
261
+ return this.dragEvent;
262
+ }
263
+ /**
264
+ * Left for backward compatibility for the DragTarget deprecated events.
265
+ * @hidden
266
+ */
267
+ get hostElement() {
268
+ return this.dragTarget;
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Arguments for the drag event of the DragTarget and DragTargetContainer.
274
+ */
275
+ class DragTargetDragEvent extends PreventableEvent {
276
+ /**
277
+ * @hidden
278
+ */
279
+ constructor(args) {
280
+ super();
281
+ Object.assign(this, args);
282
+ }
283
+ /**
284
+ * Left for backward compatibility for the DragTarget deprecated events.
285
+ * @hidden
286
+ */
287
+ get normalizedEvent() {
288
+ return this.dragEvent;
289
+ }
290
+ /**
291
+ * Left for backward compatibility for the DragTarget deprecated events.
292
+ * @hidden
293
+ */
294
+ get hostElement() {
295
+ return this.dragTarget;
296
+ }
297
+ }
298
+
299
+ /**
300
+ * Arguments for the release event of the DragTarget and DragTargetContainer.
301
+ */
302
+ class DragTargetReleaseEvent {
303
+ /**
304
+ * @hidden
305
+ */
306
+ constructor(args) {
307
+ Object.assign(this, args);
308
+ }
309
+ /**
310
+ * Left for backward compatibility for the DragTarget deprecated events.
311
+ * @hidden
312
+ */
313
+ get normalizedEvent() {
314
+ return this.dragEvent;
315
+ }
316
+ /**
317
+ * Left for backward compatibility for the DragTarget deprecated events.
318
+ * @hidden
319
+ */
320
+ get hostElement() {
321
+ return this.dragTarget;
322
+ }
323
+ }
324
+
167
325
  /**
168
326
  * @hidden
169
327
  */
@@ -186,6 +344,8 @@ class DragStateService {
186
344
  this.offset = { x: 0, y: 0 };
187
345
  this.pageOffset = { x: 0, y: 0 };
188
346
  this.velocity = { x: 0, y: 0 };
347
+ this.dragIndex = null;
348
+ this.dropIndex = null;
189
349
  this.callbacks = {};
190
350
  this.scrollInterval = null;
191
351
  this.setCallbacks();
@@ -284,21 +444,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
284
444
  }]
285
445
  }], ctorParameters: function () { return []; } });
286
446
 
287
- let isDragStartPrevented = false;
288
- let isDragPrevented = false;
447
+ let isDragStartPrevented$1 = false;
448
+ let isDragPrevented$1 = false;
289
449
  /**
290
450
  * Represents the Kendo UI DragTarget directive for Angular.
291
451
  */
292
452
  class DragTargetDirective {
293
- constructor(element, renderer, ngZone, service, viewContainer, resolver) {
453
+ constructor(element, renderer, ngZone, service, viewContainer) {
294
454
  this.element = element;
295
455
  this.renderer = renderer;
296
456
  this.ngZone = ngZone;
297
457
  this.service = service;
298
458
  this.viewContainer = viewContainer;
299
- this.resolver = resolver;
300
459
  /**
301
- * The number of pixels the pointer moves in any direction before the dragging starts ([see example]({% slug minimum_distance %})).
460
+ * Defines whether a hint will be used for dragging. By default, the hint is a copy of the drag target. ([see example]({% slug drag_hint %})).
461
+ *
462
+ * @default false
463
+ */
464
+ this.hint = false;
465
+ /**
466
+ * The number of pixels the pointer moves in any direction before the dragging starts ([see example]({% slug minimum_distance %})). Applicable when `manualDrag` is set to `false`.
302
467
  *
303
468
  * @default 0
304
469
  */
@@ -315,18 +480,22 @@ class DragTargetDirective {
315
480
  * @default 0
316
481
  */
317
482
  this.dragDelay = 0;
483
+ /**
484
+ * Specifies whether the default dragging behavior will be performed or the developer will manually handle the drag action.
485
+ *
486
+ * @default 'auto'
487
+ */
488
+ this.mode = 'auto';
318
489
  /**
319
490
  * Fires when the user presses the DragTarget element.
320
491
  */
321
492
  this.press = new EventEmitter();
322
493
  /**
323
494
  * Fires when the dragging of the DragTarget element begins.
324
- * This event is preventable.
325
495
  */
326
496
  this.dragStart = new EventEmitter();
327
497
  /**
328
498
  * Fires while the user drags the DragTarget element.
329
- * This event is preventable.
330
499
  */
331
500
  this.drag = new EventEmitter();
332
501
  /**
@@ -341,32 +510,42 @@ class DragTargetDirective {
341
510
  * Fires when the dragging of the DragTarget ends and the element is released.
342
511
  */
343
512
  this.dragEnd = new EventEmitter();
344
- this.touchAction = 'none';
345
513
  this.dragTarget = null;
346
514
  this.domSubscriptions = [];
347
- this.hint = null;
348
- this.initialPosition = { x: 0, y: 0 };
515
+ this.hintComponent = null;
349
516
  this.dragStarted = false;
350
517
  this.pressed = false;
351
518
  this.dragTimeout = null;
519
+ this.initialPosition = { x: 0, y: 0 };
352
520
  this.position = { x: 0, y: 0 };
521
+ this.scrollableParent = null;
522
+ this.defaultHint = null;
523
+ this._dragData = () => null;
353
524
  validatePackage(packageMetadata);
354
525
  }
355
526
  /**
356
- * @hidden
527
+ * Defines a callback function used for attaching custom data to the dragTarget.
528
+ * The data will be available in the events of the respective [`DropTarget`]({% slug api_utils_droptargetdirective %}) or [`DropTargetContainer`]({% slug api_utils_droptargetcontainerdirective %}) directives.
529
+ * The current DragTarget HTML element and its `dragTargetId` will be available as arguments.
357
530
  */
531
+ set dragData(fn) {
532
+ if (isDevMode && typeof fn !== 'function') {
533
+ throw new Error(`dragData must be a function, but received ${JSON.stringify(fn)}.`);
534
+ }
535
+ this._dragData = fn;
536
+ }
537
+ get dragData() {
538
+ return this._dragData;
539
+ }
540
+ get hintTemplate() {
541
+ return isPresent(this.hint) && typeof this.hint === 'object' ? this.hint.hintTemplate : null;
542
+ }
358
543
  get nativeElement() {
359
544
  return this.element.nativeElement;
360
545
  }
361
- /**
362
- * @hidden
363
- */
364
546
  get hintElem() {
365
- return this.hint.instance.element.nativeElement;
547
+ return this.hintTemplate && isPresent(this.hintComponent) ? this.hintComponent.instance.element.nativeElement : this.defaultHint;
366
548
  }
367
- /**
368
- * @hidden
369
- */
370
549
  onPointerDown(event) {
371
550
  if (this.dragHandles.length && !this.isDragHandle(event.target)) {
372
551
  return;
@@ -377,127 +556,88 @@ class DragTargetDirective {
377
556
  this.service.autoScroll = typeof this.autoScroll === 'object' ? this.autoScroll.enabled !== false : this.autoScroll;
378
557
  this.service.scrollableParent = this.getAutoScrollContainer();
379
558
  this.service.autoScrollDirection = typeof this.autoScroll === 'object' ? this.autoScroll.direction : { horizontal: true, vertical: true };
380
- this.ngZone.runOutsideAngular(() => {
381
- this.attachDomHandlers();
382
- });
559
+ this.attachDomHandlers();
383
560
  }
384
- /**
385
- * @hidden
386
- */
387
561
  onPointerMove(event) {
388
562
  event.preventDefault();
389
563
  const action = getAction(event, this.dragTarget);
390
564
  this.service.handleDragAndDrop(action);
391
565
  }
392
- /**
393
- * @hidden
394
- */
395
566
  onPointerUp(event) {
396
567
  event.preventDefault();
397
568
  const action = getAction(event, this.dragTarget);
398
569
  this.service.handleDragAndDrop(action);
399
- this.ngZone.runOutsideAngular(() => {
400
- this.attachDomHandlers();
401
- });
570
+ this.attachDomHandlers();
402
571
  }
403
572
  ngOnInit() {
404
- this.initializeDraggable();
573
+ this.initializeDragTarget();
405
574
  }
406
575
  ngAfterContentInit() {
407
576
  if (isPresent(this.element) || isPresent(this.dragTarget)) {
408
- this.ngZone.runOutsideAngular(() => {
409
- this.attachDomHandlers();
410
- if (!this.dragHandles.length) {
411
- this.renderer.addClass(this.nativeElement, 'k-cursor-pointer');
412
- }
413
- });
577
+ this.attachDomHandlers();
578
+ if (!this.dragHandles.length) {
579
+ this.renderer.addClass(this.nativeElement, 'k-cursor-pointer');
580
+ }
414
581
  }
415
582
  this.service.dragTargets.push(this.dragTarget);
416
583
  }
417
584
  ngOnDestroy() {
418
585
  this.domSubscriptions.forEach(subscription => subscription());
419
586
  }
420
- /**
421
- * @hidden
422
- */
423
587
  handlePress(event) {
424
588
  if (this.dragDelay > 0) {
425
- this.dragTimeout = setTimeout(() => {
589
+ this.dragTimeout = window.setTimeout(() => {
426
590
  this.pressed = true;
427
- this.ngZone.run(() => {
428
- this.dragReady.emit();
429
- });
591
+ this.emitZoneAwareEvent('dragReady', event);
430
592
  }, this.dragDelay);
431
593
  }
432
594
  else {
433
595
  this.pressed = true;
434
596
  }
435
- this.ngZone.run(() => {
436
- const eventArgs = new DragTargetPressEvent({ normalizedEvent: event, hostElement: this.nativeElement });
437
- this.press.emit(eventArgs);
438
- });
597
+ this.scrollableParent = this.dragTarget.element ? getScrollableParent(this.dragTarget.element) : null;
598
+ this.emitZoneAwareEvent('press', event);
439
599
  }
440
- /**
441
- * @hidden
442
- */
443
600
  handleDragStart(event) {
444
601
  if (!this.pressed) {
445
602
  if (this.dragTimeout) {
446
- clearTimeout(this.dragTimeout);
603
+ window.clearTimeout(this.dragTimeout);
447
604
  this.dragTimeout = null;
448
605
  }
449
606
  return;
450
607
  }
451
- this.ngZone.run(() => {
452
- isDragStartPrevented = this.emitEvent('dragStart', { normalizedEvent: event, hostElement: this.nativeElement }).isDefaultPrevented();
453
- });
454
- if (isDragStartPrevented) {
608
+ isDragStartPrevented$1 = this.emitZoneAwareEvent('dragStart', event).isDefaultPrevented();
609
+ if (isDragStartPrevented$1) {
455
610
  return;
456
611
  }
457
- if (isPresent(this.hintTemplate)) {
612
+ if (this.hint) {
458
613
  this.createHint();
459
- if (isPresent(this.hint)) {
614
+ if (this.mode === 'auto') {
460
615
  this.renderer.setStyle(this.nativeElement, 'opacity', '0.7');
461
616
  }
617
+ this.initialPosition = { x: event.offsetX, y: event.offsetY };
618
+ }
619
+ else {
620
+ this.initialPosition = { x: event.clientX - this.position.x, y: event.clientY - this.position.y };
462
621
  }
463
622
  this.dragStarted = this.threshold === 0;
464
623
  this.service.dragTarget = this.dragTarget;
465
624
  this.service.dragTargetDirective = this;
466
- this.initialPosition = { x: event.clientX - this.position.x, y: event.clientY - this.position.y };
625
+ this.service.dragData = this.dragData(this.dragTarget.element, this.dragTargetIdResult);
467
626
  }
468
627
  handleDrag(event) {
469
- if (!this.pressed || isDragStartPrevented) {
628
+ if (!this.pressed || isDragStartPrevented$1) {
470
629
  return;
471
630
  }
472
- const elem = this.hint ? this.hintElem : this.nativeElement;
473
- const eventArgsProps = elem === this.nativeElement ? { normalizedEvent: event, hostElement: this.nativeElement } : { normalizedEvent: event, hostElement: this.nativeElement, hintElement: elem };
474
- this.ngZone.run(() => {
475
- isDragPrevented = this.emitEvent('drag', eventArgsProps).isDefaultPrevented();
476
- });
477
- if (isDragPrevented) {
631
+ isDragPrevented$1 = this.emitZoneAwareEvent('drag', event).isDefaultPrevented();
632
+ if (isDragPrevented$1) {
478
633
  return;
479
634
  }
480
- if (this.restrictByAxis === 'horizontal') {
481
- this.position = { x: event.clientX - this.initialPosition.x + event.scrollX, y: 0 };
482
- }
483
- else if (this.restrictByAxis === 'vertical') {
484
- this.position = { x: 0, y: event.clientY - this.initialPosition.y + event.scrollY };
635
+ if (this.mode === 'auto') {
636
+ this.performDrag(event);
485
637
  }
486
638
  else {
487
- this.position = { x: event.clientX - this.initialPosition.x + event.scrollX, y: event.clientY - this.initialPosition.y + event.scrollY };
488
- }
489
- const thresholdNotReached = Math.abs(this.position.x) < this.threshold && Math.abs(this.position.y) < this.threshold;
490
- if (!this.dragStarted && thresholdNotReached) {
491
- return;
492
- }
493
- if (!this.dragStarted && this.threshold > 0) {
494
639
  this.dragStarted = true;
495
640
  }
496
- const transform = `translate(${this.position.x}px, ${this.position.y}px)`;
497
- setElementStyles(this.renderer, elem, {
498
- transform: transform,
499
- transition: 'none'
500
- });
501
641
  }
502
642
  handleRelease(event) {
503
643
  if (this.dragTimeout) {
@@ -505,45 +645,36 @@ class DragTargetDirective {
505
645
  this.dragTimeout = null;
506
646
  this.pressed = false;
507
647
  }
508
- this.service.dragTarget = null;
509
- this.service.dragTargetDirective = null;
510
- this.ngZone.run(() => {
511
- const eventArgs = new DragTargetPressEvent({ normalizedEvent: event, hostElement: this.nativeElement });
512
- this.release.emit(eventArgs);
513
- });
648
+ this.emitZoneAwareEvent('release', event);
514
649
  }
515
650
  handleDragEnd(event) {
516
651
  var _a, _b;
517
- if (this.dragTimeout) {
518
- clearTimeout(this.dragTimeout);
519
- this.dragTimeout = null;
520
- this.pressed = false;
521
- }
522
- const isDroppedOverParentTarget = isPresent(this.service.dropTarget) && !contains((_a = this.service.dropTarget) === null || _a === void 0 ? void 0 : _a.element, (_b = this.service.dragTarget) === null || _b === void 0 ? void 0 : _b.element, true);
523
- const elem = this.hint ? this.hintElem : this.nativeElement;
524
- if (isDroppedOverParentTarget || this.service.dropTargets.length > 0) {
525
- this.renderer.removeStyle(elem, 'transform');
526
- setElementStyles(this.renderer, elem, {
527
- transition: dragTargetTransition
528
- });
529
- this.position = { x: 0, y: 0 };
652
+ if (this.mode === 'auto') {
653
+ const isDroppedOverParentTarget = isPresent(this.service.dropTarget) && !contains((_a = this.service.dropTarget) === null || _a === void 0 ? void 0 : _a.element, (_b = this.service.dragTarget) === null || _b === void 0 ? void 0 : _b.element, true);
654
+ const elem = this.hint ? this.hintElem : this.nativeElement;
655
+ if (isDroppedOverParentTarget || this.service.dropTargets.length > 0 && isPresent(elem)) {
656
+ this.renderer.removeStyle(elem, 'transform');
657
+ setElementStyles(this.renderer, elem, {
658
+ transition: dragTargetTransition
659
+ });
660
+ this.position = { x: 0, y: 0 };
661
+ }
530
662
  }
531
- if (isPresent(this.hint)) {
532
- this.renderer.removeStyle(this.nativeElement, 'opacity');
663
+ if (this.hint && isPresent(this.hintElem)) {
533
664
  this.destroyHint();
665
+ if (this.mode === 'auto') {
666
+ this.renderer.removeStyle(this.nativeElement, 'opacity');
667
+ }
534
668
  }
535
669
  this.service.dragTarget = null;
536
670
  this.service.dragTargetDirective = null;
537
- if (!this.dragStarted || isDragStartPrevented || isDragPrevented) {
671
+ if (!this.dragStarted || isDragStartPrevented$1 || isDragPrevented$1) {
538
672
  return;
539
673
  }
540
- this.ngZone.run(() => {
541
- const eventArgs = new DragTargetDragEndEvent({ normalizedEvent: event, hostElement: this.nativeElement });
542
- this.dragEnd.emit(eventArgs);
543
- });
674
+ this.emitZoneAwareEvent('dragEnd', event);
544
675
  this.dragStarted = false;
545
676
  }
546
- initializeDraggable() {
677
+ initializeDragTarget() {
547
678
  this.dragTarget = {
548
679
  element: this.nativeElement,
549
680
  hint: null,
@@ -555,43 +686,44 @@ class DragTargetDirective {
555
686
  };
556
687
  }
557
688
  attachDomHandlers() {
558
- if (this.domSubscriptions.length > 0) {
559
- this.domSubscriptions.forEach(subscription => subscription());
560
- }
561
- if (!(isDocumentAvailable() && isPresent(this.element))) {
562
- return;
563
- }
564
- if (this.service.pressed) {
565
- this.onPointerMove = this.onPointerMove.bind(this);
566
- this.onPointerUp = this.onPointerUp.bind(this);
567
- let scrollable = getScrollableParent(this.nativeElement);
568
- this.domSubscriptions = [
569
- this.renderer.listen(document, 'pointermove', this.onPointerMove),
570
- this.renderer.listen(document, 'mousemove', this.onPointerMove),
571
- this.renderer.listen(document, 'touchmove', this.onPointerMove),
572
- this.renderer.listen(document, 'pointerup', this.onPointerUp),
573
- this.renderer.listen(document, 'pointercancel', this.onPointerUp),
574
- this.renderer.listen(document, 'mouseup', this.onPointerUp),
575
- this.renderer.listen(document, 'contextmenu', this.onPointerUp),
576
- this.renderer.listen(document, 'touchend', this.onPointerUp),
577
- this.renderer.listen(document, 'touchcancel', this.onPointerUp)
578
- ];
579
- if (scrollable) {
580
- if (scrollable === document.getElementsByTagName('html')[0]) {
581
- scrollable = document;
689
+ this.ngZone.runOutsideAngular(() => {
690
+ if (this.domSubscriptions.length > 0) {
691
+ this.domSubscriptions.forEach(subscription => subscription());
692
+ }
693
+ if (!(isDocumentAvailable() && isPresent(this.element))) {
694
+ return;
695
+ }
696
+ if (this.service.pressed) {
697
+ this.onPointerMove = this.onPointerMove.bind(this);
698
+ this.onPointerUp = this.onPointerUp.bind(this);
699
+ this.domSubscriptions = [
700
+ this.renderer.listen(document, 'pointermove', this.onPointerMove),
701
+ this.renderer.listen(document, 'mousemove', this.onPointerMove),
702
+ this.renderer.listen(document, 'touchmove', this.onPointerMove),
703
+ this.renderer.listen(document, 'pointerup', this.onPointerUp),
704
+ this.renderer.listen(document, 'pointercancel', this.onPointerUp),
705
+ this.renderer.listen(document, 'mouseup', this.onPointerUp),
706
+ this.renderer.listen(document, 'contextmenu', this.onPointerUp),
707
+ this.renderer.listen(document, 'touchend', this.onPointerUp),
708
+ this.renderer.listen(document, 'touchcancel', this.onPointerUp)
709
+ ];
710
+ if (isPresent(this.scrollableParent)) {
711
+ if (this.scrollableParent === document.getElementsByTagName('html')[0]) {
712
+ this.scrollableParent = window;
713
+ }
714
+ this.domSubscriptions.push(this.renderer.listen(this.scrollableParent, 'scroll', this.onPointerMove));
582
715
  }
583
- this.domSubscriptions.push(this.renderer.listen(scrollable, 'scroll', this.onPointerMove));
584
716
  }
585
- }
586
- else {
587
- this.onPointerDown = this.onPointerDown.bind(this);
588
- const element = this.nativeElement;
589
- this.domSubscriptions = [
590
- this.renderer.listen(element, 'pointerdown', this.onPointerDown),
591
- this.renderer.listen(element, 'mousedown', this.onPointerDown),
592
- this.renderer.listen(element, 'touchstart', this.onPointerDown)
593
- ];
594
- }
717
+ else {
718
+ this.onPointerDown = this.onPointerDown.bind(this);
719
+ const element = this.nativeElement;
720
+ this.domSubscriptions = [
721
+ this.renderer.listen(element, 'pointerdown', this.onPointerDown),
722
+ this.renderer.listen(element, 'mousedown', this.onPointerDown),
723
+ this.renderer.listen(element, 'touchstart', this.onPointerDown)
724
+ ];
725
+ }
726
+ });
595
727
  }
596
728
  isDragHandle(el) {
597
729
  return this.dragHandles.toArray().some(dh => contains(dh.element.nativeElement, el, true));
@@ -603,55 +735,182 @@ class DragTargetDirective {
603
735
  this.autoScroll.boundaryElementRef.nativeElement : null;
604
736
  }
605
737
  createHint() {
606
- const hintComponent = this.resolver.resolveComponentFactory(HintComponent);
607
- this.hint = this.viewContainer.createComponent(hintComponent);
608
- this.hint.instance.template = this.hintTemplate;
609
- this.hint.instance.directive = this;
610
- this.hint.changeDetectorRef.detectChanges();
611
- this.dragTarget.hint = this.hint.instance.element.nativeElement;
738
+ if (!(isDocumentAvailable() && isPresent(this.element))) {
739
+ return;
740
+ }
741
+ if (isPresent(this.hint) && typeof this.hint === 'object') {
742
+ if (isPresent(this.hint.hintTemplate)) {
743
+ this.createCustomHint();
744
+ }
745
+ else {
746
+ this.createDefaultHint();
747
+ }
748
+ }
749
+ else {
750
+ this.createDefaultHint();
751
+ }
752
+ this.dragTarget.hint = this.hintElem;
753
+ if (typeof this.hint === 'object' && isPresent(this.hint.appendTo)) {
754
+ this.hint.appendTo.element.nativeElement.appendChild(this.hintElem);
755
+ }
756
+ else {
757
+ document.body.appendChild(this.hintElem);
758
+ }
759
+ }
760
+ createDefaultHint() {
761
+ this.defaultHint = this.nativeElement.cloneNode(true);
762
+ if (typeof this.hint === 'object') {
763
+ if (isPresent(this.hint.hintClass)) {
764
+ const hintClasses = parseCSSClassNames(this.hint.hintClass);
765
+ hintClasses.forEach(className => this.renderer.addClass(this.defaultHint, className));
766
+ }
767
+ }
768
+ }
769
+ createCustomHint() {
770
+ if (isPresent(this.hint.appendTo)) {
771
+ this.hintComponent = this.hint.appendTo.createComponent(HintComponent);
772
+ }
773
+ else {
774
+ this.hintComponent = this.viewContainer.createComponent(HintComponent);
775
+ }
776
+ this.hintComponent.instance.template = this.hintTemplate;
777
+ this.hintComponent.instance.directive = this;
778
+ this.hintComponent.changeDetectorRef.detectChanges();
612
779
  }
613
780
  destroyHint() {
614
- this.hint.destroy();
615
- this.hint.changeDetectorRef.detectChanges();
616
- this.hint = null;
781
+ if (isPresent(this.hintTemplate)) {
782
+ this.hintComponent.destroy();
783
+ this.hintComponent.changeDetectorRef.detectChanges();
784
+ this.hintComponent = null;
785
+ }
786
+ else {
787
+ if (typeof this.hint === 'object' && isPresent(this.hint.appendTo)) {
788
+ this.hint.appendTo.element.nativeElement.removeChild(this.defaultHint);
789
+ }
790
+ else {
791
+ document.body.removeChild(this.defaultHint);
792
+ }
793
+ this.defaultHint = null;
794
+ }
617
795
  this.dragTarget.hint = null;
618
796
  }
619
- emitEvent(event, args) {
797
+ emitZoneAwareEvent(event, normalizedEvent) {
798
+ const eventProps = {
799
+ dragTarget: this.nativeElement,
800
+ dragEvent: normalizedEvent
801
+ };
802
+ if (this.hint && isPresent(this.hintElem)) {
803
+ eventProps.hintElement = this.hintElem;
804
+ }
805
+ if (this.dragTargetId && this.dragTargetId !== '') {
806
+ eventProps.dragTargetId = this.dragTargetIdResult;
807
+ }
620
808
  let eventArgs;
621
809
  switch (event) {
810
+ case 'dragReady':
811
+ eventArgs = new DragTargetDragReadyEvent(eventProps);
812
+ break;
813
+ case 'press':
814
+ eventArgs = new DragTargetPressEvent(eventProps);
815
+ break;
622
816
  case 'dragStart':
623
- eventArgs = new DragTargetDragStartEvent(args);
817
+ eventArgs = new DragTargetDragStartEvent(eventProps);
624
818
  break;
625
819
  case 'drag':
626
- eventArgs = new DragTargetDragEvent(args);
820
+ eventArgs = new DragTargetDragEvent(eventProps);
821
+ break;
822
+ case 'release':
823
+ eventArgs = new DragTargetReleaseEvent(eventProps);
824
+ break;
825
+ case 'dragEnd':
826
+ eventArgs = new DragTargetDragEndEvent(eventProps);
627
827
  break;
628
828
  default:
629
829
  break;
630
830
  }
631
- this[event].emit(eventArgs);
831
+ this.ngZone.run(() => {
832
+ this[event].emit(eventArgs);
833
+ });
632
834
  return eventArgs;
633
835
  }
836
+ get dragTargetIdResult() {
837
+ if (this.dragTargetId && this.dragTargetId !== '') {
838
+ return typeof this.dragTargetId === 'string' ? this.dragTargetId : this.dragTargetId(this.dragTarget.element);
839
+ }
840
+ }
841
+ performDrag(event) {
842
+ const elem = this.hint ? this.hintElem : this.nativeElement;
843
+ this.position = this.calculatePosition(elem, event);
844
+ const thresholdNotReached = Math.abs(this.position.x) < this.threshold && Math.abs(this.position.y) < this.threshold;
845
+ if (!this.dragStarted && thresholdNotReached) {
846
+ return;
847
+ }
848
+ if (!this.dragStarted && this.threshold > 0) {
849
+ this.dragStarted = true;
850
+ }
851
+ const styles = this.getStylesPerElement(elem);
852
+ setElementStyles(this.renderer, elem, styles);
853
+ }
854
+ calculatePosition(element, event) {
855
+ let position = null;
856
+ if (element === this.hintElem) {
857
+ position = { x: event.clientX, y: event.clientY };
858
+ }
859
+ else {
860
+ position = { x: event.clientX - this.initialPosition.x + event.scrollX, y: event.clientY - this.initialPosition.y + event.scrollY };
861
+ }
862
+ if (this.restrictByAxis === 'horizontal') {
863
+ position.y = 0;
864
+ }
865
+ else if (this.restrictByAxis === 'vertical') {
866
+ position.x = 0;
867
+ }
868
+ return position;
869
+ }
870
+ getStylesPerElement(element) {
871
+ if (element === this.hintElem) {
872
+ const hintCoordinates = { x: this.position.x - this.initialPosition.x, y: this.position.y - this.initialPosition.y };
873
+ return {
874
+ top: `${hintCoordinates.y}px`,
875
+ left: `${hintCoordinates.x}px`,
876
+ transition: 'none',
877
+ position: 'absolute',
878
+ zIndex: 1999
879
+ };
880
+ }
881
+ else {
882
+ const transform = `translate(${this.position.x}px, ${this.position.y}px)`;
883
+ return {
884
+ transform: transform,
885
+ transition: 'none'
886
+ };
887
+ }
888
+ }
634
889
  }
635
- DragTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragTargetDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: DragStateService }, { token: i0.ViewContainerRef }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Directive });
636
- DragTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: DragTargetDirective, selector: "[kendoDragTarget]", inputs: { hintTemplate: "hintTemplate", threshold: "threshold", autoScroll: "autoScroll", link: "link", dragDelay: "dragDelay", restrictByAxis: "restrictByAxis" }, outputs: { press: "press", dragStart: "dragStart", drag: "drag", dragReady: "dragReady", release: "release", dragEnd: "dragEnd" }, host: { properties: { "style.touch-action": "this.touchAction" } }, queries: [{ propertyName: "dragHandles", predicate: DragHandleDirective }], exportAs: ["kendoDragTarget"], ngImport: i0 });
890
+ DragTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragTargetDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: DragStateService }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
891
+ DragTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: DragTargetDirective, selector: "[kendoDragTarget]", inputs: { hint: "hint", threshold: "threshold", autoScroll: "autoScroll", dragTargetId: "dragTargetId", dragDelay: "dragDelay", restrictByAxis: "restrictByAxis", mode: "mode", dragData: "dragData" }, outputs: { press: "press", dragStart: "dragStart", drag: "drag", dragReady: "dragReady", release: "release", dragEnd: "dragEnd" }, queries: [{ propertyName: "dragHandles", predicate: DragHandleDirective }], exportAs: ["kendoDragTarget"], ngImport: i0 });
637
892
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragTargetDirective, decorators: [{
638
893
  type: Directive,
639
894
  args: [{
640
895
  selector: '[kendoDragTarget]',
641
896
  exportAs: 'kendoDragTarget'
642
897
  }]
643
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: DragStateService }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { hintTemplate: [{
898
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: DragStateService }, { type: i0.ViewContainerRef }]; }, propDecorators: { hint: [{
644
899
  type: Input
645
900
  }], threshold: [{
646
901
  type: Input
647
902
  }], autoScroll: [{
648
903
  type: Input
649
- }], link: [{
904
+ }], dragTargetId: [{
650
905
  type: Input
651
906
  }], dragDelay: [{
652
907
  type: Input
653
908
  }], restrictByAxis: [{
654
909
  type: Input
910
+ }], mode: [{
911
+ type: Input
912
+ }], dragData: [{
913
+ type: Input
655
914
  }], press: [{
656
915
  type: Output
657
916
  }], dragStart: [{
@@ -664,59 +923,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
664
923
  type: Output
665
924
  }], dragEnd: [{
666
925
  type: Output
667
- }], touchAction: [{
668
- type: HostBinding,
669
- args: ['style.touch-action']
670
926
  }], dragHandles: [{
671
927
  type: ContentChildren,
672
928
  args: [DragHandleDirective]
673
929
  }] } });
674
930
 
675
931
  /**
676
- * Arguments for the dragEnter event of the DropTarget.
677
- */
678
- class DropTargetDragEnterEvent {
679
- /**
680
- * @hidden
681
- */
682
- constructor(args) {
683
- Object.assign(this, args);
684
- }
685
- }
686
-
687
- /**
688
- * Arguments for the dragOver event of the DropTarget.
932
+ * Arguments for the drag events of the DropTarget and DropTargetContainer directives.
689
933
  */
690
- class DropTargetDragOverEvent {
934
+ class DropTargetEvent {
691
935
  /**
692
936
  * @hidden
693
937
  */
694
938
  constructor(args) {
695
939
  Object.assign(this, args);
696
940
  }
697
- }
698
-
699
- /**
700
- * Arguments for the dragLeave event of the DropTarget.
701
- */
702
- class DropTargetDragLeaveEvent {
703
941
  /**
942
+ * Left for backward compatibility for the DropTarget deprecated events.
704
943
  * @hidden
705
944
  */
706
- constructor(args) {
707
- Object.assign(this, args);
945
+ get normalizedEvent() {
946
+ return this.dragEvent;
708
947
  }
709
- }
710
-
711
- /**
712
- * Arguments for the drop event of the DropTarget.
713
- */
714
- class DropTargetDropEvent {
715
948
  /**
949
+ * Left for backward compatibility for the DropTarget deprecated events.
716
950
  * @hidden
717
951
  */
718
- constructor(args) {
719
- Object.assign(this, args);
952
+ get hostElement() {
953
+ return this.dropTarget;
720
954
  }
721
955
  }
722
956
 
@@ -730,22 +964,18 @@ class DropTargetDirective {
730
964
  this.ngZone = ngZone;
731
965
  /**
732
966
  * Fires when a DragTarget element enters the DropTarget.
733
- * This event is preventable. Preventing it allows full logic customization.
734
967
  */
735
968
  this.dragEnter = new EventEmitter();
736
969
  /**
737
970
  * Fires when a DragTarget element is being dragged over the DropTarget.
738
- * This event is preventable. Preventing it allows full logic customization.
739
971
  */
740
972
  this.dragOver = new EventEmitter();
741
973
  /**
742
974
  * Fires when a DragTarget element leaves the DropTarget.
743
- * This event is preventable. Preventing it allows full logic customization.
744
975
  */
745
976
  this.dragLeave = new EventEmitter();
746
977
  /**
747
978
  * Fires when a DragTarget element is dropped over the DropTarget.
748
- * This event is preventable. Preventing it allows full logic customization.
749
979
  */
750
980
  this.drop = new EventEmitter();
751
981
  validatePackage(packageMetadata);
@@ -761,29 +991,10 @@ class DropTargetDirective {
761
991
  if (!this.service.dragTarget) {
762
992
  return;
763
993
  }
764
- let allowed = true;
765
- if (isPresent(this.allowedDragTargets)) {
766
- switch (typeof this.allowedDragTargets) {
767
- case 'function': {
768
- allowed = this.allowedDragTargets(this.service.dragTargetDirective);
769
- break;
770
- }
771
- case 'string': {
772
- allowed = this.service.dragTargetDirective.link === this.allowedDragTargets;
773
- break;
774
- }
775
- default: {
776
- allowed = this.allowedDragTargets.some(dt => dt === this.service.dragTargetDirective.link);
777
- }
778
- }
779
- }
780
- if (allowed) {
781
- this.service.dropTarget = this.dropTarget;
782
- this.ngZone.run(() => {
783
- const eventArgs = new DropTargetDragEnterEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
784
- this.dragEnter.emit(eventArgs);
785
- });
786
- }
994
+ this.service.dropTarget = this.dropTarget;
995
+ this.ngZone.run(() => {
996
+ this.emitEvent('dragEnter', event);
997
+ });
787
998
  }
788
999
  /**
789
1000
  * @hidden
@@ -794,8 +1005,7 @@ class DropTargetDirective {
794
1005
  return;
795
1006
  }
796
1007
  this.ngZone.run(() => {
797
- const eventArgs = new DropTargetDragLeaveEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
798
- this.dragLeave.emit(eventArgs);
1008
+ this.emitEvent('dragLeave', event);
799
1009
  });
800
1010
  }
801
1011
  /**
@@ -806,8 +1016,7 @@ class DropTargetDirective {
806
1016
  return;
807
1017
  }
808
1018
  this.ngZone.run(() => {
809
- const eventArgs = new DropTargetDragOverEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
810
- this.dragOver.emit(eventArgs);
1019
+ this.emitEvent('dragOver', event);
811
1020
  });
812
1021
  }
813
1022
  /**
@@ -815,13 +1024,9 @@ class DropTargetDirective {
815
1024
  */
816
1025
  handleDrop(event) {
817
1026
  this.ngZone.run(() => {
818
- const eventArgs = new DropTargetDropEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
819
- this.drop.emit(eventArgs);
1027
+ this.emitEvent('drop', event);
820
1028
  });
821
1029
  }
822
- /**
823
- * @hidden
824
- */
825
1030
  initializeDropTarget() {
826
1031
  this.dropTarget = {
827
1032
  element: this.element.nativeElement,
@@ -831,16 +1036,848 @@ class DropTargetDirective {
831
1036
  onDrop: this.handleDrop.bind(this)
832
1037
  };
833
1038
  }
1039
+ emitEvent(event, normalizedEvent) {
1040
+ var _a, _b;
1041
+ const eventProps = {
1042
+ dropTarget: this.element.nativeElement,
1043
+ dragTarget: (_a = this.service.dragTarget) === null || _a === void 0 ? void 0 : _a.element,
1044
+ dragEvent: normalizedEvent,
1045
+ dragData: this.service.dragData
1046
+ };
1047
+ if (isPresent((_b = this.service.dragTarget) === null || _b === void 0 ? void 0 : _b.hint)) {
1048
+ eventProps.hintElement = this.service.dragTarget.element;
1049
+ }
1050
+ const eventArgs = new DropTargetEvent(eventProps);
1051
+ this[event].emit(eventArgs);
1052
+ }
834
1053
  }
835
1054
  DropTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DropTargetDirective, deps: [{ token: DragStateService }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
836
- DropTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: DropTargetDirective, selector: "[kendoDropTarget]", inputs: { allowedDragTargets: "allowedDragTargets" }, outputs: { dragEnter: "dragEnter", dragOver: "dragOver", dragLeave: "dragLeave", drop: "drop" }, exportAs: ["kendoDropTarget"], ngImport: i0 });
1055
+ DropTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: DropTargetDirective, selector: "[kendoDropTarget]", outputs: { dragEnter: "dragEnter", dragOver: "dragOver", dragLeave: "dragLeave", drop: "drop" }, exportAs: ["kendoDropTarget"], ngImport: i0 });
837
1056
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DropTargetDirective, decorators: [{
838
1057
  type: Directive,
839
1058
  args: [{
840
1059
  selector: '[kendoDropTarget]',
841
1060
  exportAs: 'kendoDropTarget'
842
1061
  }]
843
- }], ctorParameters: function () { return [{ type: DragStateService }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { allowedDragTargets: [{
1062
+ }], ctorParameters: function () { return [{ type: DragStateService }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { dragEnter: [{
1063
+ type: Output
1064
+ }], dragOver: [{
1065
+ type: Output
1066
+ }], dragLeave: [{
1067
+ type: Output
1068
+ }], drop: [{
1069
+ type: Output
1070
+ }] } });
1071
+
1072
+ let isDragStartPrevented = false;
1073
+ let isDragPrevented = false;
1074
+ /**
1075
+ * Represents the [Kendo UI DragTargetContainer directive for Angular]({% slug api_utils_dragtargetcontainerdirective %}).
1076
+ * Used to configure multiple elements as draggable.
1077
+ *
1078
+ * @example
1079
+ * ```ts-no-run
1080
+ * <ul kendoDragTargetContainer dragTargetFilter=".my-draggable">
1081
+ * <li class="my-draggable">foo</li>
1082
+ * </ul>
1083
+ * ```
1084
+ */
1085
+ class DragTargetContainerDirective {
1086
+ constructor(wrapper, ngZone, renderer, service, viewContainer, cdr) {
1087
+ this.wrapper = wrapper;
1088
+ this.ngZone = ngZone;
1089
+ this.renderer = renderer;
1090
+ this.service = service;
1091
+ this.viewContainer = viewContainer;
1092
+ this.cdr = cdr;
1093
+ /**
1094
+ * Defines whether a hint will be used for dragging. By default, the hint is a copy of the current drag target. ([see example]({% slug drag_target_container_hint %})).
1095
+ *
1096
+ * @default false
1097
+ */
1098
+ this.hint = false;
1099
+ /**
1100
+ * Defines the delay in milliseconds after which the drag will begin ([see example]({% slug drag_target_container_delay %})).
1101
+ *
1102
+ * @default 0
1103
+ */
1104
+ this.dragDelay = 0;
1105
+ /**
1106
+ * The number of pixels the pointer moves in any direction before the dragging starts ([see example]({% slug drag_target_container_minimum_distance %})).
1107
+ *
1108
+ * @default 0
1109
+ */
1110
+ this.threshold = 0;
1111
+ /**
1112
+ * Specifies whether the default dragging behavior will be performed or the developer will manually handle the drag action.
1113
+ *
1114
+ * @default 'auto'
1115
+ */
1116
+ this.mode = 'auto';
1117
+ /**
1118
+ * Fires when a DragTarget's `dragDelay` has passed and the user is able to drag the element.
1119
+ */
1120
+ this.dragReady = new EventEmitter();
1121
+ /**
1122
+ * Fires when the user presses a DragTarget element.
1123
+ */
1124
+ this.press = new EventEmitter();
1125
+ /**
1126
+ * Fires when the dragging of a DragTarget element begins.
1127
+ */
1128
+ this.dragStart = new EventEmitter();
1129
+ /**
1130
+ * Fires while the user drags a DragTarget element.
1131
+ */
1132
+ this.drag = new EventEmitter();
1133
+ /**
1134
+ * Fires when the user releases a DragTarget element after being pressed.
1135
+ */
1136
+ this.release = new EventEmitter();
1137
+ /**
1138
+ * Fires when the dragging of a DragTarget ends and the element is released.
1139
+ */
1140
+ this.dragEnd = new EventEmitter();
1141
+ this.currentDragTarget = null;
1142
+ this.dragTimeout = null;
1143
+ this.pressed = false;
1144
+ this.dragStarted = false;
1145
+ this.hintComponent = null;
1146
+ this.defaultHint = null;
1147
+ this.currentDragTargetElement = null;
1148
+ this.scrollableParent = null;
1149
+ this.previousDragTargets = [];
1150
+ this.initialPosition = { x: 0, y: 0 };
1151
+ this.position = { x: 0, y: 0 };
1152
+ this.positionsMap = new Map();
1153
+ this._dragTargetFilter = null;
1154
+ this._dragDisabled = false;
1155
+ this._dragData = () => null;
1156
+ this._dragTargetId = () => null;
1157
+ validatePackage(packageMetadata);
1158
+ }
1159
+ /**
1160
+ * Specifies a selector for elements within a container which will be configured as draggable
1161
+ * ([see example]({% slug drag_target_container %})). The possible values include any
1162
+ * DOM `selector`.
1163
+ */
1164
+ set dragTargetFilter(value) {
1165
+ this._dragTargetFilter = value;
1166
+ if (!this.dragDisabled) {
1167
+ this.initializeDragTargets();
1168
+ }
1169
+ }
1170
+ get dragTargetFilter() {
1171
+ return this._dragTargetFilter;
1172
+ }
1173
+ /**
1174
+ * Defines a unique identifier for each drag target.
1175
+ * It exposes the current DragTarget HTML element and its index in the collection of drag targets as arguments.
1176
+ */
1177
+ set dragTargetId(fn) {
1178
+ if (isDevMode && typeof fn !== 'function') {
1179
+ throw new Error(`dragTargetId must be a function, but received ${JSON.stringify(fn)}.`);
1180
+ }
1181
+ this._dragTargetId = fn;
1182
+ }
1183
+ get dragTargetId() {
1184
+ return this._dragTargetId;
1185
+ }
1186
+ /**
1187
+ * Defines a callback function which returns custom data passed to the DropTarget events.
1188
+ * It exposes the current DragTarget HTML element, its `dragTargetId` and its index in the collection of drag targets as arguments.
1189
+ */
1190
+ set dragData(fn) {
1191
+ if (isDevMode && typeof fn !== 'function') {
1192
+ throw new Error(`dragData must be a function, but received ${JSON.stringify(fn)}.`);
1193
+ }
1194
+ this._dragData = fn;
1195
+ }
1196
+ get dragData() {
1197
+ return this._dragData;
1198
+ }
1199
+ /**
1200
+ * If set to true, the dragging of DragTargets within the container will be disabled.
1201
+ *
1202
+ * @default false
1203
+ */
1204
+ set dragDisabled(value) {
1205
+ this._dragDisabled = value;
1206
+ if (value) {
1207
+ this.clearPreviousTargets();
1208
+ this.unsubscribe();
1209
+ if (isPresent(this.hintElem)) {
1210
+ this.destroyHint();
1211
+ }
1212
+ }
1213
+ else {
1214
+ if (isPresent(this.wrapper) || isPresent(this.currentDragTarget)) {
1215
+ this.subscribe();
1216
+ }
1217
+ this.initializeDragTargets();
1218
+ }
1219
+ }
1220
+ get dragDisabled() {
1221
+ return this._dragDisabled;
1222
+ }
1223
+ /**
1224
+ * Used for notifying the DragTargetContainer that its content has changed.
1225
+ */
1226
+ notify() {
1227
+ this.cdr.detectChanges();
1228
+ this.initializeDragTargets();
1229
+ }
1230
+ get allDragTargets() {
1231
+ return this.queryHost(this.dragTargetFilter);
1232
+ }
1233
+ get dragHandles() {
1234
+ return this.queryHost(this.dragHandle);
1235
+ }
1236
+ get hintTemplate() {
1237
+ return isPresent(this.hint) && typeof this.hint === 'object' ? this.hint.hintTemplate : null;
1238
+ }
1239
+ ngAfterViewInit() {
1240
+ const isTargetPresent = isPresent(this.wrapper) || isPresent(this.currentDragTarget);
1241
+ if (!this.dragDisabled && isTargetPresent) {
1242
+ this.subscribe();
1243
+ }
1244
+ !this.dragDisabled && this.initializeDragTargets();
1245
+ }
1246
+ onPointerDown(event) {
1247
+ if (isPresent(this.dragHandles) && this.dragHandles.length && !this.isDragHandle(event.target)) {
1248
+ return;
1249
+ }
1250
+ const action = getAction(event, this.currentDragTarget);
1251
+ this.service.handleDragAndDrop(action);
1252
+ this.subscribe();
1253
+ }
1254
+ onPointerMove(event) {
1255
+ event.preventDefault();
1256
+ const action = getAction(event, this.currentDragTarget);
1257
+ this.service.handleDragAndDrop(action);
1258
+ }
1259
+ onPointerUp(event) {
1260
+ event.preventDefault();
1261
+ const action = getAction(event, this.currentDragTarget);
1262
+ this.service.handleDragAndDrop(action);
1263
+ this.ngZone.runOutsideAngular(() => {
1264
+ this.subscribe();
1265
+ });
1266
+ }
1267
+ handlePress(event) {
1268
+ if (this.dragDelay > 0) {
1269
+ this.dragTimeout = window.setTimeout(() => {
1270
+ this.pressed = true;
1271
+ this.emitZoneAwareEvent('dragReady', event);
1272
+ }, this.dragDelay);
1273
+ }
1274
+ else {
1275
+ this.pressed = true;
1276
+ }
1277
+ const eventTarget = event.originalEvent.target;
1278
+ this.currentDragTargetElement = closestBySelector(eventTarget, this.dragTargetFilter);
1279
+ this.currentDragTarget.element = this.currentDragTargetElement;
1280
+ this.service.dragIndex = this.getDragIndex();
1281
+ this.scrollableParent = this.hintTemplate ? document.body : this.currentDragTargetElement ? getScrollableParent(this.currentDragTargetElement) : null;
1282
+ this.emitZoneAwareEvent('press', event);
1283
+ }
1284
+ handleDragStart(event) {
1285
+ if (!this.pressed) {
1286
+ if (this.dragTimeout) {
1287
+ window.clearTimeout(this.dragTimeout);
1288
+ this.dragTimeout = null;
1289
+ }
1290
+ return;
1291
+ }
1292
+ isDragStartPrevented = this.emitZoneAwareEvent('dragStart', event).isDefaultPrevented();
1293
+ if (isDragStartPrevented) {
1294
+ return;
1295
+ }
1296
+ this.position = this.positionsMap.has(this.currentDragTargetElement) ? this.positionsMap.get(this.currentDragTargetElement) : { x: 0, y: 0 };
1297
+ if (this.hint) {
1298
+ this.createHint();
1299
+ if (this.mode === 'auto') {
1300
+ this.renderer.setStyle(this.currentDragTargetElement, 'opacity', '0.7');
1301
+ }
1302
+ }
1303
+ else {
1304
+ this.initialPosition = { x: event.clientX - this.position.x, y: event.clientY - this.position.y };
1305
+ }
1306
+ this.emitZoneAwareEvent('dragStart', event);
1307
+ this.dragStarted = this.threshold === 0;
1308
+ this.service.dragTarget = this.currentDragTarget;
1309
+ this.service.dragTargetId = this.dragTargetId(this.currentDragTargetElement, this.service.dragIndex);
1310
+ this.service.dragData = this.dragData(this.currentDragTargetElement, this.service.dragTargetId, this.service.dragIndex);
1311
+ }
1312
+ handleDrag(event) {
1313
+ if (!this.pressed || isDragStartPrevented) {
1314
+ return;
1315
+ }
1316
+ isDragPrevented = this.emitZoneAwareEvent('drag', event).isDefaultPrevented();
1317
+ if (isDragPrevented) {
1318
+ return;
1319
+ }
1320
+ if (this.mode === 'auto') {
1321
+ this.performDrag(event);
1322
+ }
1323
+ else {
1324
+ this.dragStarted = true;
1325
+ }
1326
+ this.dragStarted && this.emitZoneAwareEvent('drag', event);
1327
+ }
1328
+ handleRelease(event) {
1329
+ if (this.dragStarted) {
1330
+ this.positionsMap.set(this.currentDragTargetElement, this.position);
1331
+ }
1332
+ if (this.dragTimeout) {
1333
+ clearTimeout(this.dragTimeout);
1334
+ this.dragTimeout = null;
1335
+ this.pressed = false;
1336
+ }
1337
+ this.emitZoneAwareEvent('release', event);
1338
+ }
1339
+ handleDragEnd(event) {
1340
+ var _a, _b;
1341
+ if (!this.dragStarted) {
1342
+ return;
1343
+ }
1344
+ if (this.mode === 'auto') {
1345
+ const isDroppedOverParentTarget = isPresent(this.service.dropTarget) && !contains((_a = this.service.dropTarget) === null || _a === void 0 ? void 0 : _a.element, (_b = this.service.dragTarget) === null || _b === void 0 ? void 0 : _b.element, true);
1346
+ const elem = this.hint ? this.hintElem : this.currentDragTargetElement;
1347
+ if (isDroppedOverParentTarget || this.service.dropTargets.length > 0 && isPresent(elem)) {
1348
+ this.renderer.removeStyle(elem, 'transform');
1349
+ setElementStyles(this.renderer, elem, {
1350
+ transition: dragTargetTransition
1351
+ });
1352
+ this.positionsMap.delete(this.currentDragTargetElement);
1353
+ }
1354
+ }
1355
+ if (this.hint && isPresent(this.hintElem)) {
1356
+ this.destroyHint();
1357
+ if (this.mode === 'auto') {
1358
+ this.renderer.removeStyle(this.currentDragTargetElement, 'opacity');
1359
+ }
1360
+ }
1361
+ this.service.dragTarget = null;
1362
+ this.service.dragIndex = null;
1363
+ this.currentDragTarget.element = null;
1364
+ this.emitZoneAwareEvent('dragEnd', event);
1365
+ if (isDragStartPrevented || isDragPrevented) {
1366
+ return;
1367
+ }
1368
+ this.dragStarted = false;
1369
+ }
1370
+ get nativeElement() {
1371
+ return this.wrapper.nativeElement;
1372
+ }
1373
+ get hintElem() {
1374
+ return this.hintTemplate && isPresent(this.hintComponent) ? this.hintComponent.instance.element.nativeElement : this.defaultHint;
1375
+ }
1376
+ unsubscribe() {
1377
+ if (this.pointerDownSubscription) {
1378
+ this.pointerDownSubscription.unsubscribe();
1379
+ }
1380
+ if (this.pointerMoveSubscription) {
1381
+ this.pointerMoveSubscription.unsubscribe();
1382
+ }
1383
+ if (this.pointerUpSubscription) {
1384
+ this.pointerUpSubscription.unsubscribe();
1385
+ }
1386
+ if (this.scrollSubscription) {
1387
+ this.scrollSubscription.unsubscribe();
1388
+ }
1389
+ }
1390
+ subscribe() {
1391
+ this.ngZone.runOutsideAngular(() => {
1392
+ this.unsubscribe();
1393
+ if (!(isDocumentAvailable() && isPresent(this.wrapper))) {
1394
+ return;
1395
+ }
1396
+ const element = this.nativeElement;
1397
+ if (this.service.pressed) {
1398
+ const pointerMoveStreams = allPointerMoveEvents.map((ev) => fromEvent(document, ev));
1399
+ const pointerUpStreams = allPointerUpEvents.map((ev) => fromEvent(document, ev));
1400
+ this.pointerMoveSubscription = merge(...pointerMoveStreams)
1401
+ .pipe(filter(() => this.dragTargetFilter !== ''))
1402
+ .subscribe(e => this.onPointerMove(e));
1403
+ this.pointerUpSubscription = merge(...pointerUpStreams)
1404
+ .subscribe(e => this.onPointerUp(e));
1405
+ if (isPresent(this.scrollableParent)) {
1406
+ this.scrollSubscription = fromEvent(this.scrollableParent, 'scroll')
1407
+ .subscribe(e => this.onPointerMove(e));
1408
+ }
1409
+ }
1410
+ else {
1411
+ const pointerDownStreams = allPointerDownEvents.map((ev) => fromEvent(element, ev));
1412
+ this.pointerDownSubscription = merge(...pointerDownStreams)
1413
+ .pipe(filter(() => this.dragTargetFilter !== ''))
1414
+ .subscribe((e) => {
1415
+ const filterElement = closestBySelector(e.target, this.dragTargetFilter);
1416
+ if (filterElement) {
1417
+ this.onPointerDown(e);
1418
+ }
1419
+ });
1420
+ }
1421
+ });
1422
+ }
1423
+ emitZoneAwareEvent(event, normalizedEvent) {
1424
+ const eventProps = {
1425
+ dragTarget: this.currentDragTargetElement,
1426
+ dragEvent: normalizedEvent,
1427
+ dragTargetIndex: this.service.dragIndex,
1428
+ dragTargetId: this.dragTargetId(this.currentDragTargetElement, this.service.dragIndex)
1429
+ };
1430
+ if (this.hint && isPresent(this.hintElem)) {
1431
+ eventProps.hintElement = this.hintElem;
1432
+ }
1433
+ let eventArgs;
1434
+ switch (event) {
1435
+ case 'dragReady':
1436
+ eventArgs = new DragTargetDragReadyEvent(eventProps);
1437
+ break;
1438
+ case 'press':
1439
+ eventArgs = new DragTargetPressEvent(eventProps);
1440
+ break;
1441
+ case 'dragStart':
1442
+ eventArgs = new DragTargetDragStartEvent(eventProps);
1443
+ break;
1444
+ case 'drag':
1445
+ eventArgs = new DragTargetDragEvent(eventProps);
1446
+ break;
1447
+ case 'release':
1448
+ eventArgs = new DragTargetReleaseEvent(eventProps);
1449
+ break;
1450
+ case 'dragEnd':
1451
+ eventArgs = new DragTargetDragEndEvent(eventProps);
1452
+ break;
1453
+ default:
1454
+ break;
1455
+ }
1456
+ this.ngZone.run(() => {
1457
+ this[event].emit(eventArgs);
1458
+ });
1459
+ return eventArgs;
1460
+ }
1461
+ createHint() {
1462
+ if (!(isDocumentAvailable() && isPresent(this.wrapper))) {
1463
+ return;
1464
+ }
1465
+ if (isPresent(this.hint) && typeof this.hint === 'object') {
1466
+ if (isPresent(this.hint.hintTemplate)) {
1467
+ this.createCustomHint();
1468
+ }
1469
+ else {
1470
+ this.createDefaultHint();
1471
+ }
1472
+ }
1473
+ else {
1474
+ this.createDefaultHint();
1475
+ }
1476
+ this.currentDragTarget.hint = this.hintElem;
1477
+ if (typeof this.hint === 'object' && isPresent(this.hint.appendTo)) {
1478
+ this.hint.appendTo.element.nativeElement.appendChild(this.hintElem);
1479
+ }
1480
+ else {
1481
+ document.body.appendChild(this.hintElem);
1482
+ }
1483
+ }
1484
+ createDefaultHint() {
1485
+ this.defaultHint = this.currentDragTargetElement.cloneNode(true);
1486
+ if (typeof this.hint === 'object') {
1487
+ if (isPresent(this.hint.hintClass)) {
1488
+ const hintClasses = parseCSSClassNames(this.hint.hintClass);
1489
+ hintClasses.forEach(className => this.renderer.addClass(this.defaultHint, className));
1490
+ }
1491
+ }
1492
+ }
1493
+ createCustomHint() {
1494
+ if (isPresent(this.hint.appendTo)) {
1495
+ this.hintComponent = this.hint.appendTo.createComponent(HintComponent);
1496
+ }
1497
+ else {
1498
+ this.hintComponent = this.viewContainer.createComponent(HintComponent);
1499
+ }
1500
+ this.hintComponent.instance.template = this.hintTemplate;
1501
+ this.hintComponent.instance.directive = this;
1502
+ this.hintComponent.instance.targetIndex = this.service.dragIndex;
1503
+ this.hintComponent.instance.contextData = this.dragData(this.currentDragTargetElement, this.service.dragIndex);
1504
+ this.hintComponent.changeDetectorRef.detectChanges();
1505
+ }
1506
+ destroyHint() {
1507
+ if (isPresent(this.hintTemplate)) {
1508
+ this.hintComponent.destroy();
1509
+ this.hintComponent.changeDetectorRef.detectChanges();
1510
+ this.hintComponent = null;
1511
+ }
1512
+ else {
1513
+ document.body.removeChild(this.defaultHint);
1514
+ this.defaultHint = null;
1515
+ }
1516
+ this.currentDragTarget.hint = null;
1517
+ }
1518
+ getDragIndex() {
1519
+ return this.allDragTargets.indexOf(this.currentDragTargetElement);
1520
+ }
1521
+ initializeDragTargets() {
1522
+ if (!isPresent(this.allDragTargets)) {
1523
+ if (this.previousDragTargets.length > 0) {
1524
+ this.clearPreviousTargets();
1525
+ }
1526
+ return;
1527
+ }
1528
+ this.allDragTargets.forEach(dragTargetEl => {
1529
+ const isDragTargetInitialized = this.service.dragTargets.find(dt => dt.element === dragTargetEl);
1530
+ if (!isDragTargetInitialized) {
1531
+ this.service.dragTargets.push({
1532
+ element: dragTargetEl,
1533
+ hint: null,
1534
+ onPress: this.handlePress.bind(this),
1535
+ onRelease: this.handleRelease.bind(this),
1536
+ onDragStart: this.handleDragStart.bind(this),
1537
+ onDrag: this.handleDrag.bind(this),
1538
+ onDragEnd: this.handleDragEnd.bind(this)
1539
+ });
1540
+ }
1541
+ });
1542
+ if (this.previousDragTargets.length > 0) {
1543
+ const dragTargetsToRemove = this.previousDragTargets.filter(dt => !this.allDragTargets.includes(dt));
1544
+ dragTargetsToRemove.forEach(dragTarget => {
1545
+ const idx = this.service.dragTargets.findIndex(serviceDragTarget => serviceDragTarget.element === dragTarget);
1546
+ if (idx > -1) {
1547
+ this.service.dragTargets.splice(idx, 1);
1548
+ }
1549
+ });
1550
+ }
1551
+ this.previousDragTargets = this.allDragTargets;
1552
+ this.currentDragTarget = {
1553
+ element: null,
1554
+ hint: null,
1555
+ onPress: this.handlePress.bind(this),
1556
+ onRelease: this.handleRelease.bind(this),
1557
+ onDragStart: this.handleDragStart.bind(this),
1558
+ onDrag: this.handleDrag.bind(this),
1559
+ onDragEnd: this.handleDragEnd.bind(this)
1560
+ };
1561
+ this.setCursorStyle();
1562
+ }
1563
+ isDragHandle(el) {
1564
+ return this.dragHandles.some(dh => contains(dh, el, true));
1565
+ }
1566
+ setCursorStyle() {
1567
+ if (!isDocumentAvailable()) {
1568
+ return;
1569
+ }
1570
+ if (isPresent(this.dragHandles) && this.dragHandles.length > 0) {
1571
+ this.dragHandles.forEach(handle => {
1572
+ this.renderer.addClass(handle, 'k-cursor-pointer');
1573
+ });
1574
+ }
1575
+ else {
1576
+ this.allDragTargets.forEach(target => {
1577
+ this.renderer.addClass(target, 'k-cursor-pointer');
1578
+ });
1579
+ }
1580
+ }
1581
+ queryHost(selector) {
1582
+ if (isPresent(selector) && selector !== "") {
1583
+ return Array.from(this.nativeElement.querySelectorAll(selector));
1584
+ }
1585
+ }
1586
+ clearPreviousTargets() {
1587
+ this.previousDragTargets.forEach(dragTarget => {
1588
+ const idx = this.service.dragTargets.findIndex(serviceDragTarget => serviceDragTarget.element === dragTarget);
1589
+ if (idx > -1) {
1590
+ this.service.dragTargets.splice(idx, 1);
1591
+ }
1592
+ });
1593
+ this.previousDragTargets = [];
1594
+ }
1595
+ performDrag(event) {
1596
+ const elem = this.hint ? this.hintElem : this.currentDragTargetElement;
1597
+ this.position = this.calculatePosition(elem, event);
1598
+ const thresholdNotReached = Math.abs(this.position.x) < this.threshold && Math.abs(this.position.y) < this.threshold;
1599
+ if (!this.dragStarted && thresholdNotReached) {
1600
+ return;
1601
+ }
1602
+ if (!this.dragStarted && this.threshold > 0) {
1603
+ this.dragStarted = true;
1604
+ }
1605
+ const styles = this.getStylesPerElement(elem);
1606
+ setElementStyles(this.renderer, elem, styles);
1607
+ }
1608
+ calculatePosition(element, event) {
1609
+ let position = null;
1610
+ if (element === this.hintElem) {
1611
+ position = { x: event.clientX, y: event.clientY };
1612
+ }
1613
+ else {
1614
+ position = { x: event.clientX - this.initialPosition.x + event.scrollX, y: event.clientY - this.initialPosition.y + event.scrollY };
1615
+ }
1616
+ return position;
1617
+ }
1618
+ getStylesPerElement(element) {
1619
+ if (element === this.hintElem) {
1620
+ const hintCoordinates = { x: this.position.x - this.initialPosition.x, y: this.position.y - this.initialPosition.y };
1621
+ return {
1622
+ top: `${hintCoordinates.y}px`,
1623
+ left: `${hintCoordinates.x}px`,
1624
+ transition: 'none',
1625
+ position: 'absolute',
1626
+ zIndex: 1999
1627
+ };
1628
+ }
1629
+ else {
1630
+ const transform = `translate(${this.position.x}px, ${this.position.y}px)`;
1631
+ return {
1632
+ transform: transform,
1633
+ transition: 'none'
1634
+ };
1635
+ }
1636
+ }
1637
+ }
1638
+ DragTargetContainerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragTargetContainerDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.Renderer2 }, { token: DragStateService }, { token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1639
+ DragTargetContainerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: DragTargetContainerDirective, selector: "[kendoDragTargetContainer]", inputs: { hint: "hint", dragTargetFilter: "dragTargetFilter", dragHandle: "dragHandle", dragDelay: "dragDelay", threshold: "threshold", dragTargetId: "dragTargetId", dragData: "dragData", dragDisabled: "dragDisabled", mode: "mode" }, outputs: { dragReady: "dragReady", press: "press", dragStart: "dragStart", drag: "drag", release: "release", dragEnd: "dragEnd" }, exportAs: ["kendoDragTargetContainer"], ngImport: i0 });
1640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragTargetContainerDirective, decorators: [{
1641
+ type: Directive,
1642
+ args: [{
1643
+ selector: '[kendoDragTargetContainer]',
1644
+ exportAs: 'kendoDragTargetContainer'
1645
+ }]
1646
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.Renderer2 }, { type: DragStateService }, { type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { hint: [{
1647
+ type: Input
1648
+ }], dragTargetFilter: [{
1649
+ type: Input
1650
+ }], dragHandle: [{
1651
+ type: Input
1652
+ }], dragDelay: [{
1653
+ type: Input
1654
+ }], threshold: [{
1655
+ type: Input
1656
+ }], dragTargetId: [{
1657
+ type: Input
1658
+ }], dragData: [{
1659
+ type: Input
1660
+ }], dragDisabled: [{
1661
+ type: Input
1662
+ }], mode: [{
1663
+ type: Input
1664
+ }], dragReady: [{
1665
+ type: Output
1666
+ }], press: [{
1667
+ type: Output
1668
+ }], dragStart: [{
1669
+ type: Output
1670
+ }], drag: [{
1671
+ type: Output
1672
+ }], release: [{
1673
+ type: Output
1674
+ }], dragEnd: [{
1675
+ type: Output
1676
+ }] } });
1677
+
1678
+ /**
1679
+ * Represents the [Kendo UI DropTargetContainer directive for Angular]({% slug api_utils_droptargetcontainerdirective %}).
1680
+ * Used to configure multiple elements as drop targets.
1681
+ *
1682
+ * @example
1683
+ * ```ts-no-run
1684
+ * <div kendoDropTargetContainer dropTargetFilter=".my-droptarget">
1685
+ * <div class="my-droptarget">foo</div>
1686
+ * </div>
1687
+ * ```
1688
+ */
1689
+ class DropTargetContainerDirective {
1690
+ constructor(service, element, ngZone, cdr) {
1691
+ this.service = service;
1692
+ this.element = element;
1693
+ this.ngZone = ngZone;
1694
+ this.cdr = cdr;
1695
+ /**
1696
+ * Fires when a DragTarget element enters the DropTarget.
1697
+ */
1698
+ this.dragEnter = new EventEmitter();
1699
+ /**
1700
+ * Fires when a DragTarget element is being dragged over the DropTarget.
1701
+ */
1702
+ this.dragOver = new EventEmitter();
1703
+ /**
1704
+ * Fires when a DragTarget element leaves the DropTarget.
1705
+ */
1706
+ this.dragLeave = new EventEmitter();
1707
+ /**
1708
+ * Fires when a DragTarget element is dropped over the DropTarget.
1709
+ */
1710
+ this.drop = new EventEmitter();
1711
+ this.currentDropTarget = null;
1712
+ this.currentDropTargetElement = null;
1713
+ this.previousDropTargets = [];
1714
+ this._dropTargetFilter = null;
1715
+ this._dropDisabled = false;
1716
+ validatePackage(packageMetadata);
1717
+ }
1718
+ /**
1719
+ * Specifies a selector for elements within a container which will be configured as drop targets
1720
+ * ([see example]({% slug drop_target_container %})). The possible values include any
1721
+ * DOM `selector`.
1722
+ */
1723
+ set dropTargetFilter(value) {
1724
+ this._dropTargetFilter = value;
1725
+ if (!this.dropDisabled) {
1726
+ this.initializeDropTargets();
1727
+ }
1728
+ }
1729
+ get dropTargetFilter() {
1730
+ return this._dropTargetFilter;
1731
+ }
1732
+ /**
1733
+ * Specifies whether the Drop Targets within the container will emit the corresponding events upon interaction with a Drag Target.
1734
+ */
1735
+ set dropDisabled(value) {
1736
+ if (value) {
1737
+ this.clearPreviousTargets();
1738
+ }
1739
+ else {
1740
+ this.initializeDropTargets();
1741
+ }
1742
+ }
1743
+ get dropDisabled() {
1744
+ return this._dropDisabled;
1745
+ }
1746
+ /**
1747
+ * Used for notifying the DropTargetContainer that its content has changed.
1748
+ */
1749
+ notify() {
1750
+ this.cdr.detectChanges();
1751
+ this.initializeDropTargets();
1752
+ }
1753
+ get nativeElement() {
1754
+ return this.element.nativeElement;
1755
+ }
1756
+ ngAfterViewInit() {
1757
+ !this.dropDisabled && this.initializeDropTargets();
1758
+ }
1759
+ get allDropTargets() {
1760
+ if (isPresent(this.dropTargetFilter) && this.dropTargetFilter !== '') {
1761
+ return Array.from(this.nativeElement.querySelectorAll(this.dropTargetFilter));
1762
+ }
1763
+ }
1764
+ /**
1765
+ * @hidden
1766
+ */
1767
+ handleDragEnter(event) {
1768
+ if (!this.service.dragTarget) {
1769
+ return;
1770
+ }
1771
+ const eventTarget = event.originalEvent.target;
1772
+ this.currentDropTargetElement = intersect(eventTarget, this.allDropTargets);
1773
+ this.currentDropTarget = this.service.dropTargets.find(dt => dt.element === this.currentDropTargetElement);
1774
+ this.service.dropTarget = this.currentDropTarget;
1775
+ this.service.dropIndex = this.getDropIndex();
1776
+ this.emitZoneAwareEvent('dragEnter', event);
1777
+ }
1778
+ /**
1779
+ * @hidden
1780
+ */
1781
+ handleDragLeave(event) {
1782
+ this.service.dropTarget = null;
1783
+ if (!this.service.dragTarget) {
1784
+ return;
1785
+ }
1786
+ this.emitZoneAwareEvent('dragLeave', event);
1787
+ }
1788
+ /**
1789
+ * @hidden
1790
+ */
1791
+ handleDragOver(event) {
1792
+ if (!this.service.dragTarget) {
1793
+ return;
1794
+ }
1795
+ this.emitZoneAwareEvent('dragOver', event);
1796
+ }
1797
+ /**
1798
+ * @hidden
1799
+ */
1800
+ handleDrop(event) {
1801
+ if (!this.service.dragTarget) {
1802
+ return;
1803
+ }
1804
+ this.emitZoneAwareEvent('drop', event);
1805
+ this.currentDropTarget = null;
1806
+ this.currentDropTargetElement = null;
1807
+ this.service.dropIndex = null;
1808
+ }
1809
+ initializeDropTargets() {
1810
+ if (!isPresent(this.allDropTargets)) {
1811
+ if (this.previousDropTargets.length > 0) {
1812
+ this.clearPreviousTargets();
1813
+ }
1814
+ return;
1815
+ }
1816
+ this.allDropTargets.forEach(dropTargetEl => {
1817
+ const isDropTargetInitialized = this.service.dropTargets.find(dt => dt.element === dropTargetEl);
1818
+ if (!isDropTargetInitialized) {
1819
+ this.service.dropTargets.push({
1820
+ element: dropTargetEl,
1821
+ onDragEnter: this.handleDragEnter.bind(this),
1822
+ onDragLeave: this.handleDragLeave.bind(this),
1823
+ onDragOver: this.handleDragOver.bind(this),
1824
+ onDrop: this.handleDrop.bind(this)
1825
+ });
1826
+ }
1827
+ });
1828
+ if (this.previousDropTargets.length > 0) {
1829
+ const dropTargetsToRemove = this.previousDropTargets.filter(dt => !this.allDropTargets.includes(dt));
1830
+ dropTargetsToRemove.forEach(dropTarget => {
1831
+ const idx = this.service.dropTargets.findIndex(serviceDropTarget => serviceDropTarget.element === dropTarget);
1832
+ if (idx > -1) {
1833
+ this.service.dropTargets.splice(idx, 1);
1834
+ }
1835
+ });
1836
+ }
1837
+ this.previousDropTargets = this.allDropTargets;
1838
+ }
1839
+ emitZoneAwareEvent(event, normalizedEvent) {
1840
+ var _a;
1841
+ const eventProps = {
1842
+ dragTarget: this.service.dragTarget,
1843
+ dropTarget: this.currentDropTargetElement,
1844
+ dragData: this.service.dragData,
1845
+ dragEvent: normalizedEvent,
1846
+ dropTargetIndex: this.service.dropIndex
1847
+ };
1848
+ if (isPresent((_a = this.service.dragTarget) === null || _a === void 0 ? void 0 : _a.hint)) {
1849
+ eventProps.hintElement = this.service.dragTarget.hint;
1850
+ }
1851
+ const eventArgs = new DropTargetEvent(eventProps);
1852
+ this.ngZone.run(() => {
1853
+ this[event].emit(eventArgs);
1854
+ });
1855
+ }
1856
+ getDropIndex() {
1857
+ const allTargets = this.nativeElement.querySelectorAll(this.dropTargetFilter);
1858
+ return Array.from(allTargets).indexOf(this.currentDropTargetElement);
1859
+ }
1860
+ clearPreviousTargets() {
1861
+ this.previousDropTargets.forEach(dropTarget => {
1862
+ const idx = this.service.dropTargets.findIndex(serviceDropTarget => serviceDropTarget.element === dropTarget);
1863
+ if (idx > -1) {
1864
+ this.service.dropTargets.splice(idx, 1);
1865
+ }
1866
+ });
1867
+ this.previousDropTargets = [];
1868
+ }
1869
+ }
1870
+ DropTargetContainerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DropTargetContainerDirective, deps: [{ token: DragStateService }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1871
+ DropTargetContainerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: DropTargetContainerDirective, selector: "[kendoDropTargetContainer]", inputs: { dropTargetFilter: "dropTargetFilter", dropDisabled: "dropDisabled" }, outputs: { dragEnter: "dragEnter", dragOver: "dragOver", dragLeave: "dragLeave", drop: "drop" }, exportAs: ["kendoDropTargetContainer"], ngImport: i0 });
1872
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DropTargetContainerDirective, decorators: [{
1873
+ type: Directive,
1874
+ args: [{
1875
+ selector: '[kendoDropTargetContainer]',
1876
+ exportAs: 'kendoDropTargetContainer'
1877
+ }]
1878
+ }], ctorParameters: function () { return [{ type: DragStateService }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { dropTargetFilter: [{
1879
+ type: Input
1880
+ }], dropDisabled: [{
844
1881
  type: Input
845
1882
  }], dragEnter: [{
846
1883
  type: Output
@@ -856,6 +1893,8 @@ const EXPORTS = [
856
1893
  DragTargetDirective,
857
1894
  DragHandleDirective,
858
1895
  DropTargetDirective,
1896
+ DragTargetContainerDirective,
1897
+ DropTargetContainerDirective,
859
1898
  HintComponent
860
1899
  ];
861
1900
  /**
@@ -895,9 +1934,13 @@ DragAndDropModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", versio
895
1934
  DragAndDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragAndDropModule, declarations: [DragTargetDirective,
896
1935
  DragHandleDirective,
897
1936
  DropTargetDirective,
1937
+ DragTargetContainerDirective,
1938
+ DropTargetContainerDirective,
898
1939
  HintComponent], imports: [CommonModule], exports: [DragTargetDirective,
899
1940
  DragHandleDirective,
900
1941
  DropTargetDirective,
1942
+ DragTargetContainerDirective,
1943
+ DropTargetContainerDirective,
901
1944
  HintComponent] });
902
1945
  DragAndDropModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragAndDropModule, imports: [[CommonModule]] });
903
1946
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DragAndDropModule, decorators: [{
@@ -957,5 +2000,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
957
2000
  * Generated bundle index. Do not edit.
958
2001
  */
959
2002
 
960
- export { DragAndDropModule, DragHandleDirective, DragTargetDirective, DragTargetDragEndEvent, DragTargetDragEvent, DragTargetDragStartEvent, DragTargetPressEvent, DropTargetDirective, DropTargetDragEnterEvent, DropTargetDragLeaveEvent, DropTargetDragOverEvent, DropTargetDropEvent, HintComponent, UtilsModule };
2003
+ export { DragAndDropModule, DragHandleDirective, DragTargetContainerDirective, DragTargetDirective, DragTargetDragEndEvent, DragTargetDragEvent, DragTargetDragReadyEvent, DragTargetDragStartEvent, DragTargetPressEvent, DragTargetReleaseEvent, DropTargetContainerDirective, DropTargetDirective, DropTargetEvent, HintComponent, UtilsModule };
961
2004