@progress/kendo-angular-utils 0.1.3 → 11.0.0-develop.100

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 (67) hide show
  1. package/LICENSE.md +1 -1
  2. package/NOTICE.txt +4 -4
  3. package/README.md +1 -1
  4. package/drag-and-drop/drag-state.service.d.ts +1 -1
  5. package/drag-and-drop/draghandle.directive.d.ts +1 -1
  6. package/drag-and-drop/dragtarget.directive.d.ts +1 -1
  7. package/drag-and-drop/droptarget.directive.d.ts +1 -1
  8. package/drag-and-drop/events/drag-target/drag-event.d.ts +1 -1
  9. package/drag-and-drop/events/drag-target/end-event.d.ts +1 -1
  10. package/drag-and-drop/events/drag-target/index.d.ts +1 -1
  11. package/drag-and-drop/events/drag-target/press-event.d.ts +1 -1
  12. package/drag-and-drop/events/drag-target/start-event.d.ts +1 -1
  13. package/drag-and-drop/events/drop-target/drop-event.d.ts +1 -1
  14. package/drag-and-drop/events/drop-target/enter-event.d.ts +1 -1
  15. package/drag-and-drop/events/drop-target/index.d.ts +1 -1
  16. package/drag-and-drop/events/drop-target/leave-event.d.ts +1 -1
  17. package/drag-and-drop/events/drop-target/over-event.d.ts +1 -1
  18. package/drag-and-drop/hint.component.d.ts +1 -1
  19. package/drag-and-drop/models/allowed-target.d.ts +1 -1
  20. package/drag-and-drop/models/autoscroll-options.d.ts +1 -1
  21. package/drag-and-drop/models/coordinates.d.ts +1 -1
  22. package/drag-and-drop/models/dragaxis.d.ts +1 -1
  23. package/drag-and-drop/models/index.d.ts +1 -1
  24. package/drag-and-drop/models/scroll-direction.d.ts +1 -1
  25. package/drag-and-drop/util.d.ts +1 -1
  26. package/drag-and-drop.module.d.ts +1 -1
  27. package/{esm2015/drag-and-drop/drag-state.service.js → esm2020/drag-and-drop/drag-state.service.mjs} +4 -4
  28. package/{esm2015/drag-and-drop/draghandle.directive.js → esm2020/drag-and-drop/draghandle.directive.mjs} +5 -5
  29. package/{esm2015/drag-and-drop/dragtarget.directive.js → esm2020/drag-and-drop/dragtarget.directive.mjs} +7 -6
  30. package/{esm2015/drag-and-drop/droptarget.directive.js → esm2020/drag-and-drop/droptarget.directive.mjs} +6 -5
  31. package/{esm2015/drag-and-drop/events/drag-target/drag-event.js → esm2020/drag-and-drop/events/drag-target/drag-event.mjs} +1 -1
  32. package/{esm2015/drag-and-drop/events/drag-target/end-event.js → esm2020/drag-and-drop/events/drag-target/end-event.mjs} +1 -1
  33. package/{esm2015/drag-and-drop/events/drag-target/index.js → esm2020/drag-and-drop/events/drag-target/index.mjs} +1 -1
  34. package/{esm2015/drag-and-drop/events/drag-target/press-event.js → esm2020/drag-and-drop/events/drag-target/press-event.mjs} +1 -1
  35. package/{esm2015/drag-and-drop/events/drag-target/start-event.js → esm2020/drag-and-drop/events/drag-target/start-event.mjs} +1 -1
  36. package/{esm2015/drag-and-drop/events/drop-target/drop-event.js → esm2020/drag-and-drop/events/drop-target/drop-event.mjs} +1 -1
  37. package/{esm2015/drag-and-drop/events/drop-target/enter-event.js → esm2020/drag-and-drop/events/drop-target/enter-event.mjs} +1 -1
  38. package/{esm2015/drag-and-drop/events/drop-target/index.js → esm2020/drag-and-drop/events/drop-target/index.mjs} +1 -1
  39. package/{esm2015/drag-and-drop/events/drop-target/leave-event.js → esm2020/drag-and-drop/events/drop-target/leave-event.mjs} +1 -1
  40. package/{esm2015/drag-and-drop/events/drop-target/over-event.js → esm2020/drag-and-drop/events/drop-target/over-event.mjs} +1 -1
  41. package/{esm2015/drag-and-drop/hint.component.js → esm2020/drag-and-drop/hint.component.mjs} +5 -5
  42. package/{esm2015/drag-and-drop/models/dragaxis.js → esm2020/drag-and-drop/models/allowed-target.mjs} +1 -1
  43. package/{esm2015/drag-and-drop/models/autoscroll-options.js → esm2020/drag-and-drop/models/autoscroll-options.mjs} +1 -1
  44. package/{esm2015/drag-and-drop/models/allowed-target.js → esm2020/drag-and-drop/models/coordinates.mjs} +1 -1
  45. package/{esm2015/drag-and-drop/models/coordinates.js → esm2020/drag-and-drop/models/dragaxis.mjs} +1 -1
  46. package/esm2020/drag-and-drop/models/index.mjs +5 -0
  47. package/esm2020/drag-and-drop/models/scroll-direction.mjs +5 -0
  48. package/{esm2015/drag-and-drop/util.js → esm2020/drag-and-drop/util.mjs} +1 -1
  49. package/{esm2015/drag-and-drop.module.js → esm2020/drag-and-drop.module.mjs} +5 -5
  50. package/{esm2015/main.js → esm2020/index.mjs} +1 -1
  51. package/{esm2015/package-metadata.js → esm2020/package-metadata.mjs} +3 -3
  52. package/{esm2015/kendo-angular-utils.js → esm2020/progress-kendo-angular-utils.mjs} +2 -2
  53. package/{esm2015/utils.module.js → esm2020/utils.module.mjs} +5 -5
  54. package/fesm2015/{kendo-angular-utils.js → progress-kendo-angular-utils.mjs} +27 -27
  55. package/fesm2020/progress-kendo-angular-utils.mjs +960 -0
  56. package/{main.d.ts → index.d.ts} +1 -1
  57. package/package-metadata.d.ts +1 -1
  58. package/package.json +32 -59
  59. package/{kendo-angular-utils.d.ts → progress-kendo-angular-utils.d.ts} +2 -2
  60. package/utils.module.d.ts +1 -1
  61. package/bundles/kendo-angular-utils.umd.js +0 -5
  62. package/esm2015/drag-and-drop/models/index.js +0 -5
  63. package/esm2015/drag-and-drop/models/scroll-direction.js +0 -5
  64. package/schematics/collection.json +0 -12
  65. package/schematics/ngAdd/index.js +0 -21
  66. package/schematics/ngAdd/index.js.map +0 -1
  67. package/schematics/ngAdd/schema.json +0 -28
@@ -0,0 +1,960 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as i0 from '@angular/core';
6
+ import { Directive, HostBinding, Injectable, Component, Input, EventEmitter, Output, ContentChildren, NgModule } from '@angular/core';
7
+ import * as i1 from '@angular/common';
8
+ import { CommonModule } from '@angular/common';
9
+ import { validatePackage } from '@progress/kendo-licensing';
10
+ import { dispatchDragAndDrop, getScrollableParent, autoScroll } from '@progress/kendo-draggable-common';
11
+ import { PreventableEvent, contains, isDocumentAvailable } from '@progress/kendo-angular-common';
12
+
13
+ /**
14
+ * @hidden
15
+ */
16
+ const packageMetadata = {
17
+ name: '@progress/kendo-angular-utils',
18
+ productName: 'Kendo UI for Angular',
19
+ productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
20
+ publishDate: 1673469105,
21
+ version: '',
22
+ licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
23
+ };
24
+
25
+ /**
26
+ * Represents the Kendo UI DragHandle directive for Angular.
27
+ */
28
+ class DragHandleDirective {
29
+ constructor(element) {
30
+ this.element = element;
31
+ this.hostClass = true;
32
+ }
33
+ }
34
+ DragHandleDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragHandleDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
35
+ DragHandleDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: DragHandleDirective, selector: "[kendoDragHandle]", host: { properties: { "class.k-cursor-pointer": "this.hostClass" } }, exportAs: ["kendoDragHandle"], ngImport: i0 });
36
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragHandleDirective, decorators: [{
37
+ type: Directive,
38
+ args: [{
39
+ selector: '[kendoDragHandle]',
40
+ exportAs: 'kendoDragHandle'
41
+ }]
42
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { hostClass: [{
43
+ type: HostBinding,
44
+ args: ['class.k-cursor-pointer']
45
+ }] } });
46
+
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
+ }
57
+ }
58
+
59
+ /**
60
+ * Arguments for the dragStart event of the DragTarget.
61
+ */
62
+ class DragTargetDragStartEvent extends PreventableEvent {
63
+ /**
64
+ * @hidden
65
+ */
66
+ constructor(args) {
67
+ super();
68
+ Object.assign(this, args);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Arguments for the dragEnd event of the DragTarget.
74
+ */
75
+ class DragTargetDragEndEvent {
76
+ /**
77
+ * @hidden
78
+ */
79
+ constructor(args) {
80
+ Object.assign(this, args);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Arguments for the drag event of the DragTarget.
86
+ */
87
+ class DragTargetDragEvent extends PreventableEvent {
88
+ /**
89
+ * @hidden
90
+ */
91
+ constructor(args) {
92
+ super();
93
+ Object.assign(this, args);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * @hidden
99
+ */
100
+ class DragStateService {
101
+ constructor() {
102
+ this.dragTarget = null;
103
+ this.dropTarget = null;
104
+ this.dragTargets = [];
105
+ this.dropTargets = [];
106
+ this.pressed = false;
107
+ this.ignoreMouse = false;
108
+ this.autoScroll = true;
109
+ this.isScrolling = false;
110
+ this.scrollableParent = null;
111
+ this.autoScrollDirection = { horizontal: true, vertical: true };
112
+ this.initialClientOffset = { x: 0, y: 0 };
113
+ this.clientOffset = { x: 0, y: 0 };
114
+ this.initialScrollOffset = { x: 0, y: 0 };
115
+ this.scrollOffset = { x: 0, y: 0 };
116
+ this.offset = { x: 0, y: 0 };
117
+ this.pageOffset = { x: 0, y: 0 };
118
+ this.velocity = { x: 0, y: 0 };
119
+ this.callbacks = {};
120
+ this.scrollInterval = null;
121
+ this.setCallbacks();
122
+ }
123
+ handleDragAndDrop(action) {
124
+ this.updateState();
125
+ dispatchDragAndDrop(this.state, action, this.callbacks);
126
+ }
127
+ setPressed(pressed) {
128
+ this.pressed = pressed;
129
+ }
130
+ setScrolling(isScrolling) {
131
+ this.isScrolling = isScrolling;
132
+ if (isScrolling) {
133
+ const scrollableParent = getScrollableParent(document.elementFromPoint(this.clientOffset.x, this.clientOffset.y));
134
+ window.clearInterval(this.scrollInterval);
135
+ this.scrollInterval = window.setInterval(() => {
136
+ autoScroll(scrollableParent, { x: this.velocity.x, y: this.velocity.y });
137
+ }, 50);
138
+ }
139
+ else {
140
+ if (this.scrollInterval) {
141
+ window.clearInterval(this.scrollInterval);
142
+ this.scrollInterval = null;
143
+ }
144
+ }
145
+ }
146
+ setVelocity(velocity) {
147
+ this.velocity = velocity;
148
+ }
149
+ setOffset(offset) {
150
+ this.offset = offset;
151
+ }
152
+ setClientOffset(clientOffset) {
153
+ this.clientOffset = clientOffset;
154
+ }
155
+ setPageOffset(pageOffset) {
156
+ this.pageOffset = pageOffset;
157
+ }
158
+ setInitialClientOffset(initialClientOffset) {
159
+ this.initialClientOffset = initialClientOffset;
160
+ }
161
+ setScrollOffset(scrollOffset) {
162
+ this.scrollOffset = scrollOffset;
163
+ }
164
+ setInitialScrollOffset(initialScrollOffset) {
165
+ this.initialScrollOffset = initialScrollOffset;
166
+ }
167
+ updateState() {
168
+ this.state = {
169
+ drag: this.dragTarget,
170
+ drop: this.dropTarget,
171
+ drags: this.dragTargets,
172
+ drops: this.dropTargets,
173
+ pressed: this.pressed,
174
+ ignoreMouse: this.ignoreMouse,
175
+ autoScroll: this.autoScroll,
176
+ isScrolling: this.isScrolling,
177
+ scrollableParent: this.scrollableParent,
178
+ autoScrollDirection: this.autoScrollDirection,
179
+ initialClientOffset: this.initialClientOffset,
180
+ clientOffset: this.clientOffset,
181
+ initialScrollOffset: this.initialScrollOffset,
182
+ scrollOffset: this.scrollOffset,
183
+ offset: this.offset,
184
+ pageOffset: this.pageOffset,
185
+ velocity: this.velocity
186
+ };
187
+ }
188
+ setCallbacks() {
189
+ this.callbacks = {
190
+ onVelocityChange: this.setVelocity.bind(this),
191
+ onOffsetChange: this.setOffset.bind(this),
192
+ onClientOffsetChange: this.setClientOffset.bind(this),
193
+ onPageOffsetChange: this.setPageOffset.bind(this),
194
+ onInitialClientOffsetChange: this.setInitialClientOffset.bind(this),
195
+ onScrollOffsetChange: this.setScrollOffset.bind(this),
196
+ onInitialScrollOffsetChange: this.setInitialScrollOffset.bind(this),
197
+ onIsPressedChange: this.setPressed.bind(this),
198
+ onIsScrollingChange: this.setScrolling.bind(this)
199
+ };
200
+ }
201
+ ngOnDestroy() {
202
+ if (this.scrollInterval) {
203
+ window.clearInterval(this.scrollInterval);
204
+ this.scrollInterval = null;
205
+ }
206
+ }
207
+ }
208
+ DragStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
209
+ DragStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragStateService, providedIn: 'root' });
210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragStateService, decorators: [{
211
+ type: Injectable,
212
+ args: [{
213
+ providedIn: 'root'
214
+ }]
215
+ }], ctorParameters: function () { return []; } });
216
+
217
+ /**
218
+ * @hidden
219
+ */
220
+ const dragTargetTransition = 'transform .3s ease-in-out';
221
+ /**
222
+ * @hidden
223
+ */
224
+ const getAction = (event, draggable) => {
225
+ return {
226
+ event: event,
227
+ payload: draggable
228
+ };
229
+ };
230
+ /**
231
+ * @hidden
232
+ */
233
+ const setElementStyles = (renderer, elem, styles) => {
234
+ const props = Object.keys(styles);
235
+ props.forEach(p => {
236
+ renderer.setStyle(elem, p, styles[p]);
237
+ });
238
+ };
239
+ /**
240
+ * @hidden
241
+ */
242
+ const isPresent = (value) => value !== null && value !== undefined;
243
+
244
+ const DEFAULT_ZINDEX = 10;
245
+ /**
246
+ * @hidden
247
+ */
248
+ class HintComponent {
249
+ constructor(element) {
250
+ this.element = element;
251
+ this.hostClasses = true;
252
+ this.zIndex = DEFAULT_ZINDEX;
253
+ this.touchAction = 'none';
254
+ }
255
+ }
256
+ HintComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: HintComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
257
+ HintComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", 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: `
258
+ <ng-container *ngTemplateOutlet="template; context: { $implicit: directive }">
259
+ </ng-container>
260
+ `, isInline: true, directives: [{ type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
261
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: HintComponent, decorators: [{
262
+ type: Component,
263
+ args: [{
264
+ template: `
265
+ <ng-container *ngTemplateOutlet="template; context: { $implicit: directive }">
266
+ </ng-container>
267
+ `
268
+ }]
269
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { template: [{
270
+ type: Input
271
+ }], directive: [{
272
+ type: Input
273
+ }], hostClasses: [{
274
+ type: HostBinding,
275
+ args: ['class.k-pos-absolute']
276
+ }, {
277
+ type: HostBinding,
278
+ args: ['class.k-cursor-grab']
279
+ }], zIndex: [{
280
+ type: HostBinding,
281
+ args: ['style.zIndex']
282
+ }], touchAction: [{
283
+ type: HostBinding,
284
+ args: ['style.touch-action']
285
+ }] } });
286
+
287
+ let isDragStartPrevented = false;
288
+ let isDragPrevented = false;
289
+ /**
290
+ * Represents the Kendo UI DragTarget directive for Angular.
291
+ */
292
+ class DragTargetDirective {
293
+ constructor(element, renderer, ngZone, service, viewContainer, resolver) {
294
+ this.element = element;
295
+ this.renderer = renderer;
296
+ this.ngZone = ngZone;
297
+ this.service = service;
298
+ this.viewContainer = viewContainer;
299
+ this.resolver = resolver;
300
+ /**
301
+ * The number of pixels the pointer moves in any direction before the dragging starts ([see example]({% slug minimum_distance %})).
302
+ *
303
+ * @default 0
304
+ */
305
+ this.threshold = 0;
306
+ /**
307
+ * Defines the automatic container scrolling behavior when close to the edge ([see example]({% slug auto_scroll %})).
308
+ *
309
+ * @default true
310
+ */
311
+ this.autoScroll = true;
312
+ /**
313
+ * Defines the delay in milliseconds after which the drag will begin ([see example]({% slug drag_delay %})).
314
+ *
315
+ * @default 0
316
+ */
317
+ this.dragDelay = 0;
318
+ /**
319
+ * Fires when the user presses the DragTarget element.
320
+ */
321
+ this.press = new EventEmitter();
322
+ /**
323
+ * Fires when the dragging of the DragTarget element begins.
324
+ * This event is preventable.
325
+ */
326
+ this.dragStart = new EventEmitter();
327
+ /**
328
+ * Fires while the user drags the DragTarget element.
329
+ * This event is preventable.
330
+ */
331
+ this.drag = new EventEmitter();
332
+ /**
333
+ * Fires when the DragTarget's `dragDelay` has passed and the user is able to drag the element.
334
+ */
335
+ this.dragReady = new EventEmitter();
336
+ /**
337
+ * Fires when the user releases the DragTarget element after being pressed.
338
+ */
339
+ this.release = new EventEmitter();
340
+ /**
341
+ * Fires when the dragging of the DragTarget ends and the element is released.
342
+ */
343
+ this.dragEnd = new EventEmitter();
344
+ this.touchAction = 'none';
345
+ this.dragTarget = null;
346
+ this.domSubscriptions = [];
347
+ this.hint = null;
348
+ this.initialPosition = { x: 0, y: 0 };
349
+ this.dragStarted = false;
350
+ this.pressed = false;
351
+ this.dragTimeout = null;
352
+ this.position = { x: 0, y: 0 };
353
+ validatePackage(packageMetadata);
354
+ }
355
+ /**
356
+ * @hidden
357
+ */
358
+ get nativeElement() {
359
+ return this.element.nativeElement;
360
+ }
361
+ /**
362
+ * @hidden
363
+ */
364
+ get hintElem() {
365
+ return this.hint.instance.element.nativeElement;
366
+ }
367
+ /**
368
+ * @hidden
369
+ */
370
+ onPointerDown(event) {
371
+ if (this.dragHandles.length && !this.isDragHandle(event.target)) {
372
+ return;
373
+ }
374
+ event.preventDefault();
375
+ const action = getAction(event, this.dragTarget);
376
+ this.service.handleDragAndDrop(action);
377
+ this.service.autoScroll = typeof this.autoScroll === 'object' ? this.autoScroll.enabled !== false : this.autoScroll;
378
+ this.service.scrollableParent = this.getAutoScrollContainer();
379
+ this.service.autoScrollDirection = typeof this.autoScroll === 'object' ? this.autoScroll.direction : { horizontal: true, vertical: true };
380
+ this.ngZone.runOutsideAngular(() => {
381
+ this.attachDomHandlers();
382
+ });
383
+ }
384
+ /**
385
+ * @hidden
386
+ */
387
+ onPointerMove(event) {
388
+ event.preventDefault();
389
+ const action = getAction(event, this.dragTarget);
390
+ this.service.handleDragAndDrop(action);
391
+ }
392
+ /**
393
+ * @hidden
394
+ */
395
+ onPointerUp(event) {
396
+ event.preventDefault();
397
+ const action = getAction(event, this.dragTarget);
398
+ this.service.handleDragAndDrop(action);
399
+ this.ngZone.runOutsideAngular(() => {
400
+ this.attachDomHandlers();
401
+ });
402
+ }
403
+ ngOnInit() {
404
+ this.initializeDraggable();
405
+ }
406
+ ngAfterContentInit() {
407
+ 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
+ });
414
+ }
415
+ this.service.dragTargets.push(this.dragTarget);
416
+ }
417
+ ngOnDestroy() {
418
+ this.domSubscriptions.forEach(subscription => subscription());
419
+ }
420
+ /**
421
+ * @hidden
422
+ */
423
+ handlePress(event) {
424
+ if (this.dragDelay > 0) {
425
+ this.dragTimeout = setTimeout(() => {
426
+ this.pressed = true;
427
+ this.ngZone.run(() => {
428
+ this.dragReady.emit();
429
+ });
430
+ }, this.dragDelay);
431
+ }
432
+ else {
433
+ this.pressed = true;
434
+ }
435
+ this.ngZone.run(() => {
436
+ const eventArgs = new DragTargetPressEvent({ normalizedEvent: event, hostElement: this.nativeElement });
437
+ this.press.emit(eventArgs);
438
+ });
439
+ }
440
+ /**
441
+ * @hidden
442
+ */
443
+ handleDragStart(event) {
444
+ if (!this.pressed) {
445
+ if (this.dragTimeout) {
446
+ clearTimeout(this.dragTimeout);
447
+ this.dragTimeout = null;
448
+ }
449
+ return;
450
+ }
451
+ this.ngZone.run(() => {
452
+ isDragStartPrevented = this.emitEvent('dragStart', { normalizedEvent: event, hostElement: this.nativeElement }).isDefaultPrevented();
453
+ });
454
+ if (isDragStartPrevented) {
455
+ return;
456
+ }
457
+ if (isPresent(this.hintTemplate)) {
458
+ this.createHint();
459
+ if (isPresent(this.hint)) {
460
+ this.renderer.setStyle(this.nativeElement, 'opacity', '0.7');
461
+ }
462
+ }
463
+ this.dragStarted = this.threshold === 0;
464
+ this.service.dragTarget = this.dragTarget;
465
+ this.service.dragTargetDirective = this;
466
+ this.initialPosition = { x: event.clientX - this.position.x, y: event.clientY - this.position.y };
467
+ }
468
+ handleDrag(event) {
469
+ if (!this.pressed || isDragStartPrevented) {
470
+ return;
471
+ }
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) {
478
+ return;
479
+ }
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 };
485
+ }
486
+ 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
+ this.dragStarted = true;
495
+ }
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
+ }
502
+ handleRelease(event) {
503
+ if (this.dragTimeout) {
504
+ clearTimeout(this.dragTimeout);
505
+ this.dragTimeout = null;
506
+ this.pressed = false;
507
+ }
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
+ });
514
+ }
515
+ handleDragEnd(event) {
516
+ if (this.dragTimeout) {
517
+ clearTimeout(this.dragTimeout);
518
+ this.dragTimeout = null;
519
+ this.pressed = false;
520
+ }
521
+ const isDroppedOverParentTarget = isPresent(this.service.dropTarget) && !contains(this.service.dropTarget.element, this.service.dragTarget.element, true);
522
+ const elem = this.hint ? this.hintElem : this.nativeElement;
523
+ if (isDroppedOverParentTarget || this.service.dropTargets.length > 0) {
524
+ this.renderer.removeStyle(elem, 'transform');
525
+ setElementStyles(this.renderer, elem, {
526
+ transition: dragTargetTransition
527
+ });
528
+ this.position = { x: 0, y: 0 };
529
+ }
530
+ if (isPresent(this.hint)) {
531
+ this.renderer.removeStyle(this.nativeElement, 'opacity');
532
+ this.destroyHint();
533
+ }
534
+ this.service.dragTarget = null;
535
+ this.service.dragTargetDirective = null;
536
+ if (!this.dragStarted || isDragStartPrevented || isDragPrevented) {
537
+ return;
538
+ }
539
+ this.ngZone.run(() => {
540
+ const eventArgs = new DragTargetDragEndEvent({ normalizedEvent: event, hostElement: this.nativeElement });
541
+ this.dragEnd.emit(eventArgs);
542
+ });
543
+ this.dragStarted = false;
544
+ }
545
+ initializeDraggable() {
546
+ this.dragTarget = {
547
+ element: this.nativeElement,
548
+ hint: null,
549
+ onPress: this.handlePress.bind(this),
550
+ onRelease: this.handleRelease.bind(this),
551
+ onDragStart: this.handleDragStart.bind(this),
552
+ onDrag: this.handleDrag.bind(this),
553
+ onDragEnd: this.handleDragEnd.bind(this)
554
+ };
555
+ }
556
+ attachDomHandlers() {
557
+ if (this.domSubscriptions.length > 0) {
558
+ this.domSubscriptions.forEach(subscription => subscription());
559
+ }
560
+ if (!(isDocumentAvailable() && isPresent(this.element))) {
561
+ return;
562
+ }
563
+ if (this.service.pressed) {
564
+ this.onPointerMove = this.onPointerMove.bind(this);
565
+ this.onPointerUp = this.onPointerUp.bind(this);
566
+ let scrollable = getScrollableParent(this.nativeElement);
567
+ this.domSubscriptions = [
568
+ this.renderer.listen(document, 'pointermove', this.onPointerMove),
569
+ this.renderer.listen(document, 'mousemove', this.onPointerMove),
570
+ this.renderer.listen(document, 'touchmove', this.onPointerMove),
571
+ this.renderer.listen(document, 'pointerup', this.onPointerUp),
572
+ this.renderer.listen(document, 'pointercancel', this.onPointerUp),
573
+ this.renderer.listen(document, 'mouseup', this.onPointerUp),
574
+ this.renderer.listen(document, 'contextmenu', this.onPointerUp),
575
+ this.renderer.listen(document, 'touchend', this.onPointerUp),
576
+ this.renderer.listen(document, 'touchcancel', this.onPointerUp)
577
+ ];
578
+ if (scrollable) {
579
+ if (scrollable === document.getElementsByTagName('html')[0]) {
580
+ scrollable = document;
581
+ }
582
+ this.domSubscriptions.push(this.renderer.listen(scrollable, 'scroll', this.onPointerMove));
583
+ }
584
+ }
585
+ else {
586
+ this.onPointerDown = this.onPointerDown.bind(this);
587
+ const element = this.nativeElement;
588
+ this.domSubscriptions = [
589
+ this.renderer.listen(element, 'pointerdown', this.onPointerDown),
590
+ this.renderer.listen(element, 'mousedown', this.onPointerDown),
591
+ this.renderer.listen(element, 'touchstart', this.onPointerDown)
592
+ ];
593
+ }
594
+ }
595
+ isDragHandle(el) {
596
+ return this.dragHandles.toArray().some(dh => contains(dh.element.nativeElement, el, true));
597
+ }
598
+ getAutoScrollContainer() {
599
+ return typeof this.autoScroll === 'object' &&
600
+ this.autoScroll.boundaryElementRef &&
601
+ this.autoScroll.boundaryElementRef.nativeElement ?
602
+ this.autoScroll.boundaryElementRef.nativeElement : null;
603
+ }
604
+ createHint() {
605
+ const hintComponent = this.resolver.resolveComponentFactory(HintComponent);
606
+ this.hint = this.viewContainer.createComponent(hintComponent);
607
+ this.hint.instance.template = this.hintTemplate;
608
+ this.hint.instance.directive = this;
609
+ this.hint.changeDetectorRef.detectChanges();
610
+ this.dragTarget.hint = this.hint.instance.element.nativeElement;
611
+ }
612
+ destroyHint() {
613
+ this.hint.destroy();
614
+ this.hint.changeDetectorRef.detectChanges();
615
+ this.hint = null;
616
+ this.dragTarget.hint = null;
617
+ }
618
+ emitEvent(event, args) {
619
+ let eventArgs;
620
+ switch (event) {
621
+ case 'dragStart':
622
+ eventArgs = new DragTargetDragStartEvent(args);
623
+ break;
624
+ case 'drag':
625
+ eventArgs = new DragTargetDragEvent(args);
626
+ break;
627
+ default:
628
+ break;
629
+ }
630
+ this[event].emit(eventArgs);
631
+ return eventArgs;
632
+ }
633
+ }
634
+ DragTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", 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 });
635
+ DragTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", 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 });
636
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragTargetDirective, decorators: [{
637
+ type: Directive,
638
+ args: [{
639
+ selector: '[kendoDragTarget]',
640
+ exportAs: 'kendoDragTarget'
641
+ }]
642
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: DragStateService }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { hintTemplate: [{
643
+ type: Input
644
+ }], threshold: [{
645
+ type: Input
646
+ }], autoScroll: [{
647
+ type: Input
648
+ }], link: [{
649
+ type: Input
650
+ }], dragDelay: [{
651
+ type: Input
652
+ }], restrictByAxis: [{
653
+ type: Input
654
+ }], press: [{
655
+ type: Output
656
+ }], dragStart: [{
657
+ type: Output
658
+ }], drag: [{
659
+ type: Output
660
+ }], dragReady: [{
661
+ type: Output
662
+ }], release: [{
663
+ type: Output
664
+ }], dragEnd: [{
665
+ type: Output
666
+ }], touchAction: [{
667
+ type: HostBinding,
668
+ args: ['style.touch-action']
669
+ }], dragHandles: [{
670
+ type: ContentChildren,
671
+ args: [DragHandleDirective]
672
+ }] } });
673
+
674
+ /**
675
+ * Arguments for the dragEnter event of the DropTarget.
676
+ */
677
+ class DropTargetDragEnterEvent {
678
+ /**
679
+ * @hidden
680
+ */
681
+ constructor(args) {
682
+ Object.assign(this, args);
683
+ }
684
+ }
685
+
686
+ /**
687
+ * Arguments for the dragOver event of the DropTarget.
688
+ */
689
+ class DropTargetDragOverEvent {
690
+ /**
691
+ * @hidden
692
+ */
693
+ constructor(args) {
694
+ Object.assign(this, args);
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Arguments for the dragLeave event of the DropTarget.
700
+ */
701
+ class DropTargetDragLeaveEvent {
702
+ /**
703
+ * @hidden
704
+ */
705
+ constructor(args) {
706
+ Object.assign(this, args);
707
+ }
708
+ }
709
+
710
+ /**
711
+ * Arguments for the drop event of the DropTarget.
712
+ */
713
+ class DropTargetDropEvent {
714
+ /**
715
+ * @hidden
716
+ */
717
+ constructor(args) {
718
+ Object.assign(this, args);
719
+ }
720
+ }
721
+
722
+ /**
723
+ * Represents the Kendo UI DropTarget directive for Angular.
724
+ */
725
+ class DropTargetDirective {
726
+ constructor(service, element, ngZone) {
727
+ this.service = service;
728
+ this.element = element;
729
+ this.ngZone = ngZone;
730
+ /**
731
+ * Fires when a DragTarget element enters the DropTarget.
732
+ * This event is preventable. Preventing it allows full logic customization.
733
+ */
734
+ this.dragEnter = new EventEmitter();
735
+ /**
736
+ * Fires when a DragTarget element is being dragged over the DropTarget.
737
+ * This event is preventable. Preventing it allows full logic customization.
738
+ */
739
+ this.dragOver = new EventEmitter();
740
+ /**
741
+ * Fires when a DragTarget element leaves the DropTarget.
742
+ * This event is preventable. Preventing it allows full logic customization.
743
+ */
744
+ this.dragLeave = new EventEmitter();
745
+ /**
746
+ * Fires when a DragTarget element is dropped over the DropTarget.
747
+ * This event is preventable. Preventing it allows full logic customization.
748
+ */
749
+ this.drop = new EventEmitter();
750
+ validatePackage(packageMetadata);
751
+ }
752
+ ngOnInit() {
753
+ this.initializeDropTarget();
754
+ this.service.dropTargets.push(this.dropTarget);
755
+ }
756
+ /**
757
+ * @hidden
758
+ */
759
+ handleDragEnter(event) {
760
+ if (!this.service.dragTarget) {
761
+ return;
762
+ }
763
+ let allowed = true;
764
+ if (isPresent(this.allowedDragTargets)) {
765
+ switch (typeof this.allowedDragTargets) {
766
+ case 'function': {
767
+ allowed = this.allowedDragTargets(this.service.dragTargetDirective);
768
+ break;
769
+ }
770
+ case 'string': {
771
+ allowed = this.service.dragTargetDirective.link === this.allowedDragTargets;
772
+ break;
773
+ }
774
+ default: {
775
+ allowed = this.allowedDragTargets.some(dt => dt === this.service.dragTargetDirective.link);
776
+ }
777
+ }
778
+ }
779
+ if (allowed) {
780
+ this.service.dropTarget = this.dropTarget;
781
+ this.ngZone.run(() => {
782
+ const eventArgs = new DropTargetDragEnterEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
783
+ this.dragEnter.emit(eventArgs);
784
+ });
785
+ }
786
+ }
787
+ /**
788
+ * @hidden
789
+ */
790
+ handleDragLeave(event) {
791
+ this.service.dropTarget = null;
792
+ if (!this.service.dragTarget) {
793
+ return;
794
+ }
795
+ this.ngZone.run(() => {
796
+ const eventArgs = new DropTargetDragLeaveEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
797
+ this.dragLeave.emit(eventArgs);
798
+ });
799
+ }
800
+ /**
801
+ * @hidden
802
+ */
803
+ handleDragOver(event) {
804
+ if (!this.service.dragTarget) {
805
+ return;
806
+ }
807
+ this.ngZone.run(() => {
808
+ const eventArgs = new DropTargetDragOverEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
809
+ this.dragOver.emit(eventArgs);
810
+ });
811
+ }
812
+ /**
813
+ * @hidden
814
+ */
815
+ handleDrop(event) {
816
+ this.ngZone.run(() => {
817
+ const eventArgs = new DropTargetDropEvent({ normalizedEvent: event, hostElement: this.element.nativeElement });
818
+ this.drop.emit(eventArgs);
819
+ });
820
+ }
821
+ /**
822
+ * @hidden
823
+ */
824
+ initializeDropTarget() {
825
+ this.dropTarget = {
826
+ element: this.element.nativeElement,
827
+ onDragEnter: this.handleDragEnter.bind(this),
828
+ onDragLeave: this.handleDragLeave.bind(this),
829
+ onDragOver: this.handleDragOver.bind(this),
830
+ onDrop: this.handleDrop.bind(this)
831
+ };
832
+ }
833
+ }
834
+ DropTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DropTargetDirective, deps: [{ token: DragStateService }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
835
+ DropTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: DropTargetDirective, selector: "[kendoDropTarget]", inputs: { allowedDragTargets: "allowedDragTargets" }, outputs: { dragEnter: "dragEnter", dragOver: "dragOver", dragLeave: "dragLeave", drop: "drop" }, exportAs: ["kendoDropTarget"], ngImport: i0 });
836
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DropTargetDirective, decorators: [{
837
+ type: Directive,
838
+ args: [{
839
+ selector: '[kendoDropTarget]',
840
+ exportAs: 'kendoDropTarget'
841
+ }]
842
+ }], ctorParameters: function () { return [{ type: DragStateService }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { allowedDragTargets: [{
843
+ type: Input
844
+ }], dragEnter: [{
845
+ type: Output
846
+ }], dragOver: [{
847
+ type: Output
848
+ }], dragLeave: [{
849
+ type: Output
850
+ }], drop: [{
851
+ type: Output
852
+ }] } });
853
+
854
+ const EXPORTS = [
855
+ DragTargetDirective,
856
+ DragHandleDirective,
857
+ DropTargetDirective,
858
+ HintComponent
859
+ ];
860
+ /**
861
+ * Represents the [NgModule](link:site.data.urls.angular['ngmodules'])
862
+ * definition for the Drag and Drop directives.
863
+ *
864
+ * @example
865
+ *
866
+ * ```ts-no-run
867
+ * // Import the DragAndDrop module
868
+ * import { DragAndDropModule } from '@progress/kendo-angular-utils';
869
+ *
870
+ * // The browser platform with a compiler
871
+ * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
872
+ *
873
+ * import { NgModule } from '@angular/core';
874
+ *
875
+ * // Import the app component
876
+ * import { AppComponent } from './app.component';
877
+ *
878
+ * // Define the app module
879
+ * _@NgModule({
880
+ * declarations: [AppComponent], // declare app component
881
+ * imports: [BrowserModule, DragAndDropModule], // import DragAndDropModule module
882
+ * bootstrap: [AppComponent]
883
+ * })
884
+ * export class AppModule {}
885
+ *
886
+ * // Compile and launch the module
887
+ * platformBrowserDynamic().bootstrapModule(AppModule);
888
+ *
889
+ * ```
890
+ */
891
+ class DragAndDropModule {
892
+ }
893
+ DragAndDropModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragAndDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
894
+ DragAndDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragAndDropModule, declarations: [DragTargetDirective,
895
+ DragHandleDirective,
896
+ DropTargetDirective,
897
+ HintComponent], imports: [CommonModule], exports: [DragTargetDirective,
898
+ DragHandleDirective,
899
+ DropTargetDirective,
900
+ HintComponent] });
901
+ DragAndDropModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragAndDropModule, imports: [[CommonModule]] });
902
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DragAndDropModule, decorators: [{
903
+ type: NgModule,
904
+ args: [{
905
+ declarations: [...EXPORTS],
906
+ exports: [...EXPORTS],
907
+ imports: [CommonModule],
908
+ entryComponents: [HintComponent]
909
+ }]
910
+ }] });
911
+
912
+ /**
913
+ * Represents the [NgModule](link:site.data.urls.angular['ngmodules'])
914
+ * definition for the Utils components.
915
+ *
916
+ * @example
917
+ *
918
+ * ```ts-no-run
919
+ * // Import the Utils module
920
+ * import { UtilsModule } from '@progress/kendo-angular-utils';
921
+ *
922
+ * // The browser platform with a compiler
923
+ * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
924
+ *
925
+ * import { NgModule } from '@angular/core';
926
+ *
927
+ * // Import the app component
928
+ * import { AppComponent } from './app.component';
929
+ *
930
+ * // Define the app module
931
+ * _@NgModule({
932
+ * declarations: [AppComponent], // declare app component
933
+ * imports: [BrowserModule, UtilsModule], // import Utils module
934
+ * bootstrap: [AppComponent]
935
+ * })
936
+ * export class AppModule {}
937
+ *
938
+ * // Compile and launch the module
939
+ * platformBrowserDynamic().bootstrapModule(AppModule);
940
+ *
941
+ * ```
942
+ */
943
+ class UtilsModule {
944
+ }
945
+ UtilsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UtilsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
946
+ UtilsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UtilsModule, exports: [DragAndDropModule] });
947
+ UtilsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UtilsModule, imports: [DragAndDropModule] });
948
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UtilsModule, decorators: [{
949
+ type: NgModule,
950
+ args: [{
951
+ exports: [DragAndDropModule]
952
+ }]
953
+ }] });
954
+
955
+ /**
956
+ * Generated bundle index. Do not edit.
957
+ */
958
+
959
+ export { DragAndDropModule, DragHandleDirective, DragTargetDirective, DragTargetDragEndEvent, DragTargetDragEvent, DragTargetDragStartEvent, DragTargetPressEvent, DropTargetDirective, DropTargetDragEnterEvent, DropTargetDragLeaveEvent, DropTargetDragOverEvent, DropTargetDropEvent, HintComponent, UtilsModule };
960
+