@progress/kendo-angular-utils 0.1.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 (64) hide show
  1. package/LICENSE.md +11 -0
  2. package/NOTICE.txt +654 -0
  3. package/README.md +31 -0
  4. package/bundles/kendo-angular-utils.umd.js +5 -0
  5. package/drag-and-drop/drag-state.service.d.ts +52 -0
  6. package/drag-and-drop/draghandle.directive.d.ts +16 -0
  7. package/drag-and-drop/dragtarget.directive.d.ts +155 -0
  8. package/drag-and-drop/droptarget.directive.d.ts +67 -0
  9. package/drag-and-drop/events/drag-target/drag-event.d.ts +23 -0
  10. package/drag-and-drop/events/drag-target/end-event.d.ts +23 -0
  11. package/drag-and-drop/events/drag-target/index.d.ts +9 -0
  12. package/drag-and-drop/events/drag-target/press-event.d.ts +22 -0
  13. package/drag-and-drop/events/drag-target/release-event.d.ts +22 -0
  14. package/drag-and-drop/events/drag-target/start-event.d.ts +23 -0
  15. package/drag-and-drop/events/drop-target/drop-event.d.ts +23 -0
  16. package/drag-and-drop/events/drop-target/enter-event.d.ts +23 -0
  17. package/drag-and-drop/events/drop-target/index.d.ts +8 -0
  18. package/drag-and-drop/events/drop-target/leave-event.d.ts +23 -0
  19. package/drag-and-drop/events/drop-target/over-event.d.ts +23 -0
  20. package/drag-and-drop/hint.component.d.ts +20 -0
  21. package/drag-and-drop/models/allowed-target.d.ts +16 -0
  22. package/drag-and-drop/models/autoscroll-options.d.ts +23 -0
  23. package/drag-and-drop/models/dragaxis.d.ts +8 -0
  24. package/drag-and-drop/models/index.d.ts +8 -0
  25. package/drag-and-drop/models/scroll-direction.d.ts +8 -0
  26. package/drag-and-drop/util.d.ts +29 -0
  27. package/drag-and-drop.module.d.ts +15 -0
  28. package/esm2015/drag-and-drop/drag-state.service.js +126 -0
  29. package/esm2015/drag-and-drop/draghandle.directive.js +27 -0
  30. package/esm2015/drag-and-drop/dragtarget.directive.js +389 -0
  31. package/esm2015/drag-and-drop/droptarget.directive.js +134 -0
  32. package/esm2015/drag-and-drop/events/drag-target/drag-event.js +17 -0
  33. package/esm2015/drag-and-drop/events/drag-target/end-event.js +17 -0
  34. package/esm2015/drag-and-drop/events/drag-target/index.js +9 -0
  35. package/esm2015/drag-and-drop/events/drag-target/press-event.js +15 -0
  36. package/esm2015/drag-and-drop/events/drag-target/release-event.js +15 -0
  37. package/esm2015/drag-and-drop/events/drag-target/start-event.js +17 -0
  38. package/esm2015/drag-and-drop/events/drop-target/drop-event.js +17 -0
  39. package/esm2015/drag-and-drop/events/drop-target/enter-event.js +17 -0
  40. package/esm2015/drag-and-drop/events/drop-target/index.js +8 -0
  41. package/esm2015/drag-and-drop/events/drop-target/leave-event.js +17 -0
  42. package/esm2015/drag-and-drop/events/drop-target/over-event.js +17 -0
  43. package/esm2015/drag-and-drop/hint.component.js +49 -0
  44. package/esm2015/drag-and-drop/models/allowed-target.js +5 -0
  45. package/esm2015/drag-and-drop/models/autoscroll-options.js +5 -0
  46. package/esm2015/drag-and-drop/models/dragaxis.js +5 -0
  47. package/esm2015/drag-and-drop/models/index.js +5 -0
  48. package/esm2015/drag-and-drop/models/scroll-direction.js +5 -0
  49. package/esm2015/drag-and-drop/util.js +30 -0
  50. package/esm2015/drag-and-drop.module.js +36 -0
  51. package/esm2015/kendo-angular-utils.js +8 -0
  52. package/esm2015/main.js +12 -0
  53. package/esm2015/package-metadata.js +15 -0
  54. package/esm2015/utils.module.js +49 -0
  55. package/fesm2015/kendo-angular-utils.js +925 -0
  56. package/kendo-angular-utils.d.ts +9 -0
  57. package/main.d.ts +13 -0
  58. package/package-metadata.d.ts +9 -0
  59. package/package.json +81 -0
  60. package/schematics/collection.json +12 -0
  61. package/schematics/ngAdd/index.js +21 -0
  62. package/schematics/ngAdd/index.js.map +1 -0
  63. package/schematics/ngAdd/schema.json +28 -0
  64. package/utils.module.d.ts +42 -0
@@ -0,0 +1,23 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { ElementRef } from "@angular/core";
6
+ import { ScrollDirection } from "./scroll-direction";
7
+ /**
8
+ * Represents additional configuration options for the autoScroll functionality of the DragTarget.
9
+ */
10
+ export interface AutoScrollOptions {
11
+ /**
12
+ * Overrides the calculated element used for boundary detection, used to calculate the autoScroll velocity.
13
+ */
14
+ boundaryElementRef?: ElementRef;
15
+ /**
16
+ * Specifies the direction of the autoScroll functionality.
17
+ */
18
+ direction?: ScrollDirection;
19
+ /**
20
+ * Specifies whether the autoScroll functionality will be enabled.
21
+ */
22
+ enabled?: boolean;
23
+ }
@@ -0,0 +1,8 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Represents the axis to which the dragging will be restricted.
7
+ */
8
+ export declare type DragAxis = 'horizontal' | 'vertical';
@@ -0,0 +1,8 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ export { AutoScrollOptions } from './autoscroll-options';
6
+ export { DragAxis } from './dragaxis';
7
+ export { AllowedTargetFn } from './allowed-target';
8
+ export { ScrollDirection } from './scroll-direction';
@@ -0,0 +1,8 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ export interface ScrollDirection {
6
+ horizontal: boolean;
7
+ vertical: boolean;
8
+ }
@@ -0,0 +1,29 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Renderer2 } from "@angular/core";
6
+ import { DragAndDropAction, DragTarget } from "@progress/kendo-draggable-common";
7
+ /**
8
+ * @hidden
9
+ */
10
+ export declare const dragTargetTransition = "transform .3s ease-in-out";
11
+ /**
12
+ * @hidden
13
+ */
14
+ export interface Coordinates {
15
+ x: number;
16
+ y: number;
17
+ }
18
+ /**
19
+ * @hidden
20
+ */
21
+ export declare const getAction: (event: PointerEvent | MouseEvent | TouchEvent | Event, draggable: DragTarget) => DragAndDropAction;
22
+ /**
23
+ * @hidden
24
+ */
25
+ export declare const setElementStyles: (renderer: Renderer2, elem: HTMLElement, styles: object) => void;
26
+ /**
27
+ * @hidden
28
+ */
29
+ export declare const isPresent: (value: any) => boolean;
@@ -0,0 +1,15 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 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 * as i1 from "./drag-and-drop/dragtarget.directive";
7
+ import * as i2 from "./drag-and-drop/draghandle.directive";
8
+ import * as i3 from "./drag-and-drop/droptarget.directive";
9
+ import * as i4 from "./drag-and-drop/hint.component";
10
+ import * as i5 from "@angular/common";
11
+ export declare class DragAndDropModule {
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<DragAndDropModule, never>;
13
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DragAndDropModule, [typeof i1.DragTargetDirective, typeof i2.DragHandleDirective, typeof i3.DropTargetDirective, typeof i4.HintComponent], [typeof i5.CommonModule], [typeof i1.DragTargetDirective, typeof i2.DragHandleDirective, typeof i3.DropTargetDirective, typeof i4.HintComponent]>;
14
+ static ɵinj: i0.ɵɵInjectorDeclaration<DragAndDropModule>;
15
+ }
@@ -0,0 +1,126 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Injectable } from '@angular/core';
6
+ import { dispatchDragAndDrop, getScrollableParent, autoScroll } from '@progress/kendo-draggable-common';
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * @hidden
10
+ */
11
+ export class DragStateService {
12
+ constructor() {
13
+ this.dragTarget = null;
14
+ this.dropTarget = null;
15
+ this.dragTargets = [];
16
+ this.dropTargets = [];
17
+ this.pressed = false;
18
+ this.ignoreMouse = false;
19
+ this.autoScroll = true;
20
+ this.isScrolling = false;
21
+ this.scrollableParent = null;
22
+ this.autoScrollDirection = { horizontal: true, vertical: true };
23
+ this.initialClientOffset = { x: 0, y: 0 };
24
+ this.clientOffset = { x: 0, y: 0 };
25
+ this.initialScrollOffset = { x: 0, y: 0 };
26
+ this.scrollOffset = { x: 0, y: 0 };
27
+ this.offset = { x: 0, y: 0 };
28
+ this.pageOffset = { x: 0, y: 0 };
29
+ this.velocity = { x: 0, y: 0 };
30
+ this.callbacks = {};
31
+ this.scrollInterval = null;
32
+ this.setCallbacks();
33
+ }
34
+ handleDragAndDrop(action) {
35
+ this.updateState();
36
+ dispatchDragAndDrop(this.state, action, this.callbacks);
37
+ }
38
+ setPressed(pressed) {
39
+ this.pressed = pressed;
40
+ }
41
+ setScrolling(isScrolling) {
42
+ this.isScrolling = isScrolling;
43
+ if (isScrolling) {
44
+ const scrollableParent = getScrollableParent(document.elementFromPoint(this.clientOffset.x, this.clientOffset.y));
45
+ window.clearInterval(this.scrollInterval);
46
+ this.scrollInterval = window.setInterval(() => {
47
+ autoScroll(scrollableParent, { x: this.velocity.x, y: this.velocity.y });
48
+ }, 50);
49
+ }
50
+ else {
51
+ if (this.scrollInterval) {
52
+ window.clearInterval(this.scrollInterval);
53
+ this.scrollInterval = null;
54
+ }
55
+ }
56
+ }
57
+ setVelocity(velocity) {
58
+ this.velocity = velocity;
59
+ }
60
+ setOffset(offset) {
61
+ this.offset = offset;
62
+ }
63
+ setClientOffset(clientOffset) {
64
+ this.clientOffset = clientOffset;
65
+ }
66
+ setPageOffset(pageOffset) {
67
+ this.pageOffset = pageOffset;
68
+ }
69
+ setInitialClientOffset(initialClientOffset) {
70
+ this.initialClientOffset = initialClientOffset;
71
+ }
72
+ setScrollOffset(scrollOffset) {
73
+ this.scrollOffset = scrollOffset;
74
+ }
75
+ setInitialScrollOffset(initialScrollOffset) {
76
+ this.initialScrollOffset = initialScrollOffset;
77
+ }
78
+ updateState() {
79
+ this.state = {
80
+ drag: this.dragTarget,
81
+ drop: this.dropTarget,
82
+ drags: this.dragTargets,
83
+ drops: this.dropTargets,
84
+ pressed: this.pressed,
85
+ ignoreMouse: this.ignoreMouse,
86
+ autoScroll: this.autoScroll,
87
+ isScrolling: this.isScrolling,
88
+ scrollableParent: this.scrollableParent,
89
+ autoScrollDirection: this.autoScrollDirection,
90
+ initialClientOffset: this.initialClientOffset,
91
+ clientOffset: this.clientOffset,
92
+ initialScrollOffset: this.initialScrollOffset,
93
+ scrollOffset: this.scrollOffset,
94
+ offset: this.offset,
95
+ pageOffset: this.pageOffset,
96
+ velocity: this.velocity
97
+ };
98
+ }
99
+ setCallbacks() {
100
+ this.callbacks = {
101
+ onVelocityChange: this.setVelocity.bind(this),
102
+ onOffsetChange: this.setOffset.bind(this),
103
+ onClientOffsetChange: this.setClientOffset.bind(this),
104
+ onPageOffsetChange: this.setPageOffset.bind(this),
105
+ onInitialClientOffsetChange: this.setInitialClientOffset.bind(this),
106
+ onScrollOffsetChange: this.setScrollOffset.bind(this),
107
+ onInitialScrollOffsetChange: this.setInitialScrollOffset.bind(this),
108
+ onIsPressedChange: this.setPressed.bind(this),
109
+ onIsScrollingChange: this.setScrolling.bind(this)
110
+ };
111
+ }
112
+ ngOnDestroy() {
113
+ if (this.scrollInterval) {
114
+ window.clearInterval(this.scrollInterval);
115
+ this.scrollInterval = null;
116
+ }
117
+ }
118
+ }
119
+ DragStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
120
+ DragStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragStateService, providedIn: 'root' });
121
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragStateService, decorators: [{
122
+ type: Injectable,
123
+ args: [{
124
+ providedIn: 'root'
125
+ }]
126
+ }], ctorParameters: function () { return []; } });
@@ -0,0 +1,27 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Directive, HostBinding } from "@angular/core";
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Represents the Kendo UI DragHandle directive for Angular.
9
+ */
10
+ export class DragHandleDirective {
11
+ constructor(element) {
12
+ this.element = element;
13
+ this.hostClass = true;
14
+ }
15
+ }
16
+ DragHandleDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragHandleDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
17
+ DragHandleDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: DragHandleDirective, selector: "[kendoDragHandle]", host: { properties: { "class.k-cursor-pointer": "this.hostClass" } }, exportAs: ["kendoDragHandle"], ngImport: i0 });
18
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragHandleDirective, decorators: [{
19
+ type: Directive,
20
+ args: [{
21
+ selector: '[kendoDragHandle]',
22
+ exportAs: 'kendoDragHandle'
23
+ }]
24
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { hostClass: [{
25
+ type: HostBinding,
26
+ args: ['class.k-cursor-pointer']
27
+ }] } });
@@ -0,0 +1,389 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Directive, EventEmitter, HostBinding, Output, Input, ContentChildren } from "@angular/core";
6
+ import { validatePackage } from '@progress/kendo-licensing';
7
+ import { packageMetadata } from '../package-metadata';
8
+ import { DragHandleDirective } from "./draghandle.directive";
9
+ import { getScrollableParent } from "@progress/kendo-draggable-common";
10
+ import { DragStartEvent, DragEndEvent, PressEvent, ReleaseEvent, DragEvent } from "./events/drag-target";
11
+ import { getAction, isPresent, setElementStyles, dragTargetTransition } from './util';
12
+ import { contains, isDocumentAvailable } from "@progress/kendo-angular-common";
13
+ import { HintComponent } from "./hint.component";
14
+ import * as i0 from "@angular/core";
15
+ import * as i1 from "./drag-state.service";
16
+ /**
17
+ * Represents the Kendo UI DragTarget directive for Angular.
18
+ */
19
+ export class DragTargetDirective {
20
+ constructor(element, renderer, ngZone, service, viewContainer, resolver) {
21
+ this.element = element;
22
+ this.renderer = renderer;
23
+ this.ngZone = ngZone;
24
+ this.service = service;
25
+ this.viewContainer = viewContainer;
26
+ this.resolver = resolver;
27
+ /**
28
+ * The number of pixels the pointer moves in any direction before the dragging starts ([see example]({% slug minimum_distance %})).
29
+ *
30
+ * @default 0
31
+ */
32
+ this.threshold = 0;
33
+ /**
34
+ * Defines the automatic container scrolling behavior when close to the edge ([see example]({% slug auto_scroll %})).
35
+ *
36
+ * @default true
37
+ */
38
+ this.autoScroll = true;
39
+ /**
40
+ * Defines the delay in milliseconds after which the drag will begin ([see example]({% slug drag_delay %})).
41
+ *
42
+ * @default 0
43
+ */
44
+ this.dragDelay = 0;
45
+ /**
46
+ * Fires when the user presses the DragTarget element.
47
+ * This event is preventable. Preventing it allows full logic customization.
48
+ */
49
+ this.press = new EventEmitter();
50
+ /**
51
+ * Fires when the dragging of the DragTarget element begins.
52
+ * This event is preventable. Preventing it allows full logic customization.
53
+ */
54
+ this.dragStart = new EventEmitter();
55
+ /**
56
+ * Fires while the user drags the DragTarget element.
57
+ * This event is preventable. Preventing it allows full logic customization.
58
+ */
59
+ this.drag = new EventEmitter();
60
+ /**
61
+ * Fires when the user releases the DragTarget element.
62
+ * This event is preventable. Preventing it allows full logic customization.
63
+ */
64
+ this.release = new EventEmitter();
65
+ /**
66
+ * Fires when the dragging of the DragTarget element ends.
67
+ * This event is preventable. Preventing it allows full logic customization.
68
+ */
69
+ this.dragEnd = new EventEmitter();
70
+ this.touchAction = 'none';
71
+ this.dragTarget = null;
72
+ this.domSubscriptions = [];
73
+ this.hint = null;
74
+ this.initialPosition = { x: 0, y: 0 };
75
+ this.dragStarted = false;
76
+ this.pressed = false;
77
+ this.dragTimeout = null;
78
+ validatePackage(packageMetadata);
79
+ }
80
+ /**
81
+ * @hidden
82
+ */
83
+ get nativeElement() {
84
+ return this.element.nativeElement;
85
+ }
86
+ /**
87
+ * @hidden
88
+ */
89
+ get hintElem() {
90
+ return this.hint.instance.element.nativeElement;
91
+ }
92
+ /**
93
+ * @hidden
94
+ */
95
+ onPointerDown(event) {
96
+ if (this.dragHandles.length && !this.isDragHandle(event.target)) {
97
+ return;
98
+ }
99
+ event.preventDefault();
100
+ const action = getAction(event, this.dragTarget);
101
+ this.service.handleDragAndDrop(action);
102
+ this.service.autoScroll = typeof this.autoScroll === 'object' ? this.autoScroll.enabled !== false : this.autoScroll;
103
+ this.service.scrollableParent = this.getAutoScrollContainer();
104
+ this.service.autoScrollDirection = typeof this.autoScroll === 'object' ? this.autoScroll.direction : { horizontal: true, vertical: true };
105
+ this.ngZone.runOutsideAngular(() => {
106
+ this.attachDomHandlers();
107
+ });
108
+ }
109
+ /**
110
+ * @hidden
111
+ */
112
+ onPointerMove(event) {
113
+ event.preventDefault();
114
+ const action = getAction(event, this.dragTarget);
115
+ this.service.handleDragAndDrop(action);
116
+ }
117
+ /**
118
+ * @hidden
119
+ */
120
+ onPointerUp(event) {
121
+ event.preventDefault();
122
+ const action = getAction(event, this.dragTarget);
123
+ this.service.handleDragAndDrop(action);
124
+ this.ngZone.runOutsideAngular(() => {
125
+ this.attachDomHandlers();
126
+ });
127
+ }
128
+ ngOnInit() {
129
+ this.initializeDraggable();
130
+ }
131
+ ngAfterContentInit() {
132
+ if (isPresent(this.element) || isPresent(this.dragTarget)) {
133
+ this.ngZone.runOutsideAngular(() => {
134
+ this.attachDomHandlers();
135
+ if (!this.dragHandles.length) {
136
+ this.renderer.addClass(this.nativeElement, 'k-cursor-pointer');
137
+ }
138
+ });
139
+ }
140
+ this.service.dragTargets.push(this.dragTarget);
141
+ }
142
+ ngOnDestroy() {
143
+ this.domSubscriptions.forEach(subscription => subscription());
144
+ }
145
+ /**
146
+ * @hidden
147
+ */
148
+ handlePress(event) {
149
+ if (this.dragDelay > 0) {
150
+ this.dragTimeout = setTimeout(() => {
151
+ this.pressed = true;
152
+ }, this.dragDelay);
153
+ }
154
+ else {
155
+ this.pressed = true;
156
+ }
157
+ this.ngZone.run(() => {
158
+ const eventArgs = new PressEvent({ event, element: this.nativeElement });
159
+ this.press.emit(eventArgs);
160
+ });
161
+ }
162
+ /**
163
+ * @hidden
164
+ */
165
+ handleDragStart(event) {
166
+ if (!this.pressed) {
167
+ if (this.dragTimeout) {
168
+ clearTimeout(this.dragTimeout);
169
+ this.dragTimeout = null;
170
+ }
171
+ return;
172
+ }
173
+ if (isPresent(this.hintTemplate)) {
174
+ this.createHint();
175
+ if (isPresent(this.hint)) {
176
+ this.renderer.setStyle(this.nativeElement, 'opacity', '0.7');
177
+ }
178
+ }
179
+ this.dragStarted = this.threshold === 0;
180
+ this.service.dragTarget = this.dragTarget;
181
+ this.service.dragTargetDirective = this;
182
+ this.initialPosition = { x: event.clientX, y: event.clientY };
183
+ this.ngZone.run(() => {
184
+ const eventArgs = new DragStartEvent({ event, element: this.nativeElement });
185
+ this.dragStart.emit(eventArgs);
186
+ });
187
+ }
188
+ /**
189
+ * @hidden
190
+ */
191
+ handleDrag(event) {
192
+ if (!this.pressed) {
193
+ return;
194
+ }
195
+ const elem = this.hint ? this.hintElem : this.nativeElement;
196
+ let coordinates = { x: 0, y: 0 };
197
+ if (this.restrictByAxis === 'horizontal') {
198
+ coordinates = { x: event.clientX - this.initialPosition.x + event.scrollX, y: 0 };
199
+ }
200
+ else if (this.restrictByAxis === 'vertical') {
201
+ coordinates = { x: 0, y: event.clientY - this.initialPosition.y + event.scrollY };
202
+ }
203
+ else {
204
+ coordinates = { x: event.clientX - this.initialPosition.x + event.scrollX, y: event.clientY - this.initialPosition.y + event.scrollY };
205
+ }
206
+ const thresholdNotReached = Math.abs(coordinates.x) < this.threshold && Math.abs(coordinates.y) < this.threshold;
207
+ if (!this.dragStarted && thresholdNotReached) {
208
+ return;
209
+ }
210
+ const transform = `translate(${coordinates.x}px, ${coordinates.y}px)`;
211
+ setElementStyles(this.renderer, elem, {
212
+ transform: transform,
213
+ transition: 'none'
214
+ });
215
+ if (!this.dragStarted && this.threshold > 0) {
216
+ this.dragStarted = true;
217
+ }
218
+ this.ngZone.run(() => {
219
+ const eventArgs = new DragEvent({ event, element: this.nativeElement });
220
+ this.drag.emit(eventArgs);
221
+ });
222
+ }
223
+ /**
224
+ * @hidden
225
+ */
226
+ handleRelease(event) {
227
+ if (this.dragTimeout) {
228
+ clearTimeout(this.dragTimeout);
229
+ this.dragTimeout = null;
230
+ this.pressed = false;
231
+ }
232
+ this.service.dragTarget = null;
233
+ this.service.dragTargetDirective = null;
234
+ this.ngZone.run(() => {
235
+ const eventArgs = new ReleaseEvent({ event, element: this.nativeElement });
236
+ this.release.emit(eventArgs);
237
+ });
238
+ }
239
+ /**
240
+ * @hidden
241
+ */
242
+ handleDragEnd(event) {
243
+ if (!this.dragStarted) {
244
+ return;
245
+ }
246
+ this.dragStarted = false;
247
+ const elem = this.hint ? this.hintElem : this.nativeElement;
248
+ if (isPresent(this.hint)) {
249
+ this.renderer.removeStyle(this.nativeElement, 'opacity');
250
+ this.destroyHint();
251
+ }
252
+ this.renderer.removeStyle(elem, 'transform');
253
+ setElementStyles(this.renderer, elem, {
254
+ transition: dragTargetTransition
255
+ });
256
+ this.ngZone.run(() => {
257
+ const eventArgs = new DragEndEvent({ event, element: this.nativeElement });
258
+ this.dragEnd.emit(eventArgs);
259
+ });
260
+ }
261
+ /**
262
+ * @hidden
263
+ */
264
+ initializeDraggable() {
265
+ this.dragTarget = {
266
+ element: this.nativeElement,
267
+ hint: null,
268
+ onPress: this.handlePress.bind(this),
269
+ onRelease: this.handleRelease.bind(this),
270
+ onDragStart: this.handleDragStart.bind(this),
271
+ onDrag: this.handleDrag.bind(this),
272
+ onDragEnd: this.handleDragEnd.bind(this)
273
+ };
274
+ }
275
+ /**
276
+ * @hidden
277
+ */
278
+ attachDomHandlers() {
279
+ if (this.domSubscriptions.length > 0) {
280
+ this.domSubscriptions.forEach(subscription => subscription());
281
+ }
282
+ if (!(isDocumentAvailable() && isPresent(this.element))) {
283
+ return;
284
+ }
285
+ if (this.service.pressed) {
286
+ this.onPointerMove = this.onPointerMove.bind(this);
287
+ this.onPointerUp = this.onPointerUp.bind(this);
288
+ let scrollable = getScrollableParent(this.nativeElement);
289
+ this.domSubscriptions = [
290
+ this.renderer.listen(document, 'pointermove', this.onPointerMove),
291
+ this.renderer.listen(document, 'mousemove', this.onPointerMove),
292
+ this.renderer.listen(document, 'touchmove', this.onPointerMove),
293
+ this.renderer.listen(document, 'pointerup', this.onPointerUp),
294
+ this.renderer.listen(document, 'pointercancel', this.onPointerUp),
295
+ this.renderer.listen(document, 'mouseup', this.onPointerUp),
296
+ this.renderer.listen(document, 'contextmenu', this.onPointerUp),
297
+ this.renderer.listen(document, 'touchend', this.onPointerUp),
298
+ this.renderer.listen(document, 'touchcancel', this.onPointerUp)
299
+ ];
300
+ if (scrollable) {
301
+ if (scrollable === document.getElementsByTagName('html')[0]) {
302
+ scrollable = document;
303
+ }
304
+ this.domSubscriptions.push(this.renderer.listen(scrollable, 'scroll', this.onPointerMove));
305
+ }
306
+ }
307
+ else {
308
+ this.onPointerDown = this.onPointerDown.bind(this);
309
+ const element = this.nativeElement;
310
+ this.domSubscriptions = [
311
+ this.renderer.listen(element, 'pointerdown', this.onPointerDown),
312
+ this.renderer.listen(element, 'mousedown', this.onPointerDown),
313
+ this.renderer.listen(element, 'touchstart', this.onPointerDown)
314
+ ];
315
+ }
316
+ }
317
+ /**
318
+ * @hidden
319
+ */
320
+ isDragHandle(el) {
321
+ return this.dragHandles.toArray().some(dh => contains(dh.element.nativeElement, el, true));
322
+ }
323
+ /**
324
+ * @hidden
325
+ */
326
+ getAutoScrollContainer() {
327
+ return typeof this.autoScroll === 'object' &&
328
+ this.autoScroll.boundaryElementRef &&
329
+ this.autoScroll.boundaryElementRef.nativeElement ?
330
+ this.autoScroll.boundaryElementRef.nativeElement : null;
331
+ }
332
+ /**
333
+ * @hidden
334
+ */
335
+ createHint() {
336
+ const hintComponent = this.resolver.resolveComponentFactory(HintComponent);
337
+ this.hint = this.viewContainer.createComponent(hintComponent);
338
+ this.hint.instance.template = this.hintTemplate;
339
+ this.hint.instance.directive = this;
340
+ this.hint.changeDetectorRef.detectChanges();
341
+ this.dragTarget.hint = this.hint.instance.element.nativeElement;
342
+ }
343
+ /**
344
+ * @hidden
345
+ */
346
+ destroyHint() {
347
+ this.hint.destroy();
348
+ this.hint.changeDetectorRef.detectChanges();
349
+ this.hint = null;
350
+ this.dragTarget.hint = null;
351
+ }
352
+ }
353
+ DragTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragTargetDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i1.DragStateService }, { token: i0.ViewContainerRef }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Directive });
354
+ DragTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: DragTargetDirective, selector: "[kendoDragTarget]", inputs: { hintTemplate: "hintTemplate", threshold: "threshold", autoScroll: "autoScroll", link: "link", dragDelay: "dragDelay", restrictByAxis: "restrictByAxis" }, outputs: { press: "press", dragStart: "dragStart", drag: "drag", release: "release", dragEnd: "dragEnd" }, host: { properties: { "style.touch-action": "this.touchAction" } }, queries: [{ propertyName: "dragHandles", predicate: DragHandleDirective }], exportAs: ["kendoDragTarget"], ngImport: i0 });
355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DragTargetDirective, decorators: [{
356
+ type: Directive,
357
+ args: [{
358
+ selector: '[kendoDragTarget]',
359
+ exportAs: 'kendoDragTarget'
360
+ }]
361
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i1.DragStateService }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { hintTemplate: [{
362
+ type: Input
363
+ }], threshold: [{
364
+ type: Input
365
+ }], autoScroll: [{
366
+ type: Input
367
+ }], link: [{
368
+ type: Input
369
+ }], dragDelay: [{
370
+ type: Input
371
+ }], restrictByAxis: [{
372
+ type: Input
373
+ }], press: [{
374
+ type: Output
375
+ }], dragStart: [{
376
+ type: Output
377
+ }], drag: [{
378
+ type: Output
379
+ }], release: [{
380
+ type: Output
381
+ }], dragEnd: [{
382
+ type: Output
383
+ }], touchAction: [{
384
+ type: HostBinding,
385
+ args: ['style.touch-action']
386
+ }], dragHandles: [{
387
+ type: ContentChildren,
388
+ args: [DragHandleDirective]
389
+ }] } });