@progress/kendo-angular-utils 21.4.1 → 22.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/progress-kendo-angular-utils.mjs +38 -38
- package/package.json +8 -16
- package/esm2022/adaptive-breakpoints/adaptive-settings.mjs +0 -20
- package/esm2022/adaptive-breakpoints/adaptive-settings.service.mjs +0 -29
- package/esm2022/adaptive-breakpoints/adaptive.service.mjs +0 -114
- package/esm2022/adaptive-breakpoints/index.mjs +0 -7
- package/esm2022/adaptive-breakpoints/models/adaptive-settings.mjs +0 -5
- package/esm2022/adaptive-breakpoints/models/adaptive-size.mjs +0 -5
- package/esm2022/directives.mjs +0 -45
- package/esm2022/drag-and-drop/drag-state.service.mjs +0 -139
- package/esm2022/drag-and-drop/draghandle.directive.mjs +0 -49
- package/esm2022/drag-and-drop/dragtarget-container.directive.mjs +0 -709
- package/esm2022/drag-and-drop/dragtarget.directive.mjs +0 -596
- package/esm2022/drag-and-drop/droptarget-container.directive.mjs +0 -236
- package/esm2022/drag-and-drop/droptarget.directive.mjs +0 -137
- package/esm2022/drag-and-drop/events/drag-target/drag-event.mjs +0 -52
- package/esm2022/drag-and-drop/events/drag-target/dragready-event.mjs +0 -32
- package/esm2022/drag-and-drop/events/drag-target/end-event.mjs +0 -46
- package/esm2022/drag-and-drop/events/drag-target/index.mjs +0 -10
- package/esm2022/drag-and-drop/events/drag-target/press-event.mjs +0 -46
- package/esm2022/drag-and-drop/events/drag-target/release-event.mjs +0 -46
- package/esm2022/drag-and-drop/events/drag-target/start-event.mjs +0 -48
- package/esm2022/drag-and-drop/events/drop-target-event.mjs +0 -53
- package/esm2022/drag-and-drop/events/index.mjs +0 -6
- package/esm2022/drag-and-drop/hint.component.mjs +0 -56
- package/esm2022/drag-and-drop/models/autoscroll-options.mjs +0 -5
- package/esm2022/drag-and-drop/models/coordinates.mjs +0 -5
- package/esm2022/drag-and-drop/models/drag-axis.mjs +0 -5
- package/esm2022/drag-and-drop/models/drag-mode.mjs +0 -5
- package/esm2022/drag-and-drop/models/functions.mjs +0 -5
- package/esm2022/drag-and-drop/models/hint-settings.mjs +0 -5
- package/esm2022/drag-and-drop/models/index.mjs +0 -5
- package/esm2022/drag-and-drop/models/scroll-direction.mjs +0 -5
- package/esm2022/drag-and-drop/util.mjs +0 -90
- package/esm2022/drag-and-drop.module.mjs +0 -45
- package/esm2022/index.mjs +0 -17
- package/esm2022/package-metadata.mjs +0 -16
- package/esm2022/progress-kendo-angular-utils.mjs +0 -8
- package/esm2022/utils.module.mjs +0 -45
|
@@ -1,709 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { ChangeDetectorRef, Directive, ElementRef, EventEmitter, Input, isDevMode, NgZone, Output, Renderer2, ViewContainerRef } from '@angular/core';
|
|
6
|
-
import { validatePackage } from '@progress/kendo-licensing';
|
|
7
|
-
import { packageMetadata } from '../package-metadata';
|
|
8
|
-
import { closestBySelector, getAction, isPresent, setElementStyles, dragTargetTransition, noop } from './util';
|
|
9
|
-
import { getScrollableParent } from '@progress/kendo-draggable-common';
|
|
10
|
-
import { DragStateService } from './drag-state.service';
|
|
11
|
-
import { contains, isDocumentAvailable, parseCSSClassNames } from '@progress/kendo-angular-common';
|
|
12
|
-
import { HintComponent } from './hint.component';
|
|
13
|
-
import { DragTargetDragEndEvent, DragTargetDragEvent, DragTargetDragReadyEvent, DragTargetDragStartEvent, DragTargetPressEvent, DragTargetReleaseEvent } from './events/drag-target';
|
|
14
|
-
import * as i0 from "@angular/core";
|
|
15
|
-
import * as i1 from "./drag-state.service";
|
|
16
|
-
let isDragStartPrevented = false;
|
|
17
|
-
let isDragPrevented = false;
|
|
18
|
-
/**
|
|
19
|
-
* Represents the [Kendo UI DragTargetContainer directive for Angular]({% slug api_utils_dragtargetcontainerdirective %}).
|
|
20
|
-
* Use this directive to make multiple elements draggable inside a container.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```html
|
|
24
|
-
* <ul kendoDragTargetContainer dragTargetFilter=".my-draggable">
|
|
25
|
-
* <li class="my-draggable"> Item 1</li>
|
|
26
|
-
* <li class="my-draggable"> Item 2</li>
|
|
27
|
-
* <li class="my-draggable"> Item 3</li>
|
|
28
|
-
* </ul>
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export class DragTargetContainerDirective {
|
|
32
|
-
wrapper;
|
|
33
|
-
ngZone;
|
|
34
|
-
renderer;
|
|
35
|
-
service;
|
|
36
|
-
viewContainer;
|
|
37
|
-
cdr;
|
|
38
|
-
/**
|
|
39
|
-
* 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_hint %}).
|
|
40
|
-
*
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
hint = false;
|
|
44
|
-
/**
|
|
45
|
-
* Sets a selector for elements in the container to make them draggable. The possible values include any
|
|
46
|
-
* DOM `selector`. [See example]({% slug drag_target_container %}).
|
|
47
|
-
*/
|
|
48
|
-
set dragTargetFilter(value) {
|
|
49
|
-
this._dragTargetFilter = value;
|
|
50
|
-
if (!this.dragDisabled) {
|
|
51
|
-
this.initializeDragTargets();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
get dragTargetFilter() {
|
|
55
|
-
return this._dragTargetFilter;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Sets a selector for elements inside each drag target to use as drag handles.
|
|
59
|
-
*/
|
|
60
|
-
dragHandle;
|
|
61
|
-
/**
|
|
62
|
-
* Sets the delay in milliseconds before dragging begins. [See example](slug:drag_target_container#toc-events).
|
|
63
|
-
*
|
|
64
|
-
* @default 0
|
|
65
|
-
*/
|
|
66
|
-
dragDelay = 0;
|
|
67
|
-
/**
|
|
68
|
-
* Sets the number of pixels the pointer must move before dragging starts. [See example]({% slug minimum_distance %}).
|
|
69
|
-
*
|
|
70
|
-
* @default 0
|
|
71
|
-
*/
|
|
72
|
-
threshold = 0;
|
|
73
|
-
/**
|
|
74
|
-
* Sets a unique identifier for each drag target.
|
|
75
|
-
* It exposes the current drag target HTML element and its index in the collection of drag targets as arguments.
|
|
76
|
-
*/
|
|
77
|
-
set dragTargetId(fn) {
|
|
78
|
-
if (isDevMode && typeof fn !== 'function') {
|
|
79
|
-
throw new Error(`dragTargetId must be a function, but received ${JSON.stringify(fn)}.`);
|
|
80
|
-
}
|
|
81
|
-
this._dragTargetId = fn;
|
|
82
|
-
}
|
|
83
|
-
get dragTargetId() {
|
|
84
|
-
return this._dragTargetId;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Sets a callback function to return custom data for `DropTarget` events.
|
|
88
|
-
* It exposes the current `DragTarget` HTML element, its `dragTargetId`, and its index in the collection of drag targets as arguments.
|
|
89
|
-
*/
|
|
90
|
-
set dragData(fn) {
|
|
91
|
-
if (isDevMode && typeof fn !== 'function') {
|
|
92
|
-
throw new Error(`dragData must be a function, but received ${JSON.stringify(fn)}.`);
|
|
93
|
-
}
|
|
94
|
-
this._dragData = fn;
|
|
95
|
-
}
|
|
96
|
-
get dragData() {
|
|
97
|
-
return this._dragData;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Disables dragging of drag targets in the container when set to `true`.
|
|
101
|
-
*
|
|
102
|
-
* @default false
|
|
103
|
-
*/
|
|
104
|
-
set dragDisabled(value) {
|
|
105
|
-
this._dragDisabled = value;
|
|
106
|
-
if (value) {
|
|
107
|
-
this.clearPreviousTargets();
|
|
108
|
-
this.removeListeners();
|
|
109
|
-
if (isPresent(this.hintElem)) {
|
|
110
|
-
this.destroyHint();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
if (isPresent(this.wrapper) || isPresent(this.currentDragTarget)) {
|
|
115
|
-
this.subscribe();
|
|
116
|
-
}
|
|
117
|
-
this.initializeDragTargets();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
get dragDisabled() {
|
|
121
|
-
return this._dragDisabled;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Sets whether to use the default dragging behavior or handle it manually.
|
|
125
|
-
*
|
|
126
|
-
* @default 'auto'
|
|
127
|
-
*/
|
|
128
|
-
mode = 'auto';
|
|
129
|
-
/**
|
|
130
|
-
* Sets the cursor style of the drag targets. Accepts same values as the [CSS `cursor` property](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#values).
|
|
131
|
-
*
|
|
132
|
-
* @default 'move'
|
|
133
|
-
*/
|
|
134
|
-
cursorStyle = 'move';
|
|
135
|
-
/**
|
|
136
|
-
* @hidden
|
|
137
|
-
*/
|
|
138
|
-
hintContext;
|
|
139
|
-
/**
|
|
140
|
-
* Fires when a drag target's `dragDelay` has passed and the user can drag the element.
|
|
141
|
-
*/
|
|
142
|
-
onDragReady = new EventEmitter();
|
|
143
|
-
/**
|
|
144
|
-
* Fires when the user presses a drag target element.
|
|
145
|
-
*/
|
|
146
|
-
onPress = new EventEmitter();
|
|
147
|
-
/**
|
|
148
|
-
* Fires when dragging of a drag target element begins.
|
|
149
|
-
*/
|
|
150
|
-
onDragStart = new EventEmitter();
|
|
151
|
-
/**
|
|
152
|
-
* Fires while the user drags a drag target element.
|
|
153
|
-
*/
|
|
154
|
-
onDrag = new EventEmitter();
|
|
155
|
-
/**
|
|
156
|
-
* Fires when the user releases a drag target element after pressing it.
|
|
157
|
-
*/
|
|
158
|
-
onRelease = new EventEmitter();
|
|
159
|
-
/**
|
|
160
|
-
* Fires when dragging of a drag target ends and the element is released.
|
|
161
|
-
*/
|
|
162
|
-
onDragEnd = new EventEmitter();
|
|
163
|
-
/**
|
|
164
|
-
* Notifies the `DragTargetContainer` that its content has changed.
|
|
165
|
-
*/
|
|
166
|
-
notify() {
|
|
167
|
-
this.cdr.detectChanges();
|
|
168
|
-
this.initializeDragTargets();
|
|
169
|
-
}
|
|
170
|
-
currentDragTarget = null;
|
|
171
|
-
dragTimeout = null;
|
|
172
|
-
pressed = false;
|
|
173
|
-
dragStarted = false;
|
|
174
|
-
hintComponent = null;
|
|
175
|
-
defaultHint = null;
|
|
176
|
-
currentDragTargetElement = null;
|
|
177
|
-
scrollableParent = null;
|
|
178
|
-
previousDragTargets = [];
|
|
179
|
-
initialPosition = { x: 0, y: 0 };
|
|
180
|
-
position = { x: 0, y: 0 };
|
|
181
|
-
positionsMap = new Map();
|
|
182
|
-
_dragTargetFilter = null;
|
|
183
|
-
_dragDisabled = false;
|
|
184
|
-
_dragData = () => null;
|
|
185
|
-
_dragTargetId = () => null;
|
|
186
|
-
prevUserSelect;
|
|
187
|
-
get allDragTargets() {
|
|
188
|
-
return this.queryHost(this.dragTargetFilter);
|
|
189
|
-
}
|
|
190
|
-
get dragHandles() {
|
|
191
|
-
return this.isHandleSelectorValid ? this.queryHost(this.dragHandle) : null;
|
|
192
|
-
}
|
|
193
|
-
get hintTemplate() {
|
|
194
|
-
return isPresent(this.hint) && typeof this.hint === 'object' ? this.hint.hintTemplate : null;
|
|
195
|
-
}
|
|
196
|
-
constructor(wrapper, ngZone, renderer, service, viewContainer, cdr) {
|
|
197
|
-
this.wrapper = wrapper;
|
|
198
|
-
this.ngZone = ngZone;
|
|
199
|
-
this.renderer = renderer;
|
|
200
|
-
this.service = service;
|
|
201
|
-
this.viewContainer = viewContainer;
|
|
202
|
-
this.cdr = cdr;
|
|
203
|
-
validatePackage(packageMetadata);
|
|
204
|
-
}
|
|
205
|
-
ngAfterViewInit() {
|
|
206
|
-
const isTargetPresent = isPresent(this.wrapper) || isPresent(this.currentDragTarget);
|
|
207
|
-
if (!this.dragDisabled && isTargetPresent) {
|
|
208
|
-
this.subscribe();
|
|
209
|
-
}
|
|
210
|
-
!this.dragDisabled && this.initializeDragTargets();
|
|
211
|
-
}
|
|
212
|
-
ngOnDestroy() {
|
|
213
|
-
this.removeListeners();
|
|
214
|
-
}
|
|
215
|
-
onPointerDown(event) {
|
|
216
|
-
const filterElement = closestBySelector(event.target, this.isHandleSelectorValid ? this.dragHandle : this.dragTargetFilter);
|
|
217
|
-
if (this.dragTargetFilter === '' || !isPresent(filterElement)) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (isPresent(this.dragHandles) && !this.isDragHandle(event.target)) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const action = getAction(event, this.currentDragTarget);
|
|
224
|
-
this.service.handleDragAndDrop(action);
|
|
225
|
-
this.subscribe();
|
|
226
|
-
}
|
|
227
|
-
onTouchStart(event) {
|
|
228
|
-
const filterElement = closestBySelector(event.target, this.isHandleSelectorValid ? this.dragHandle : this.dragTargetFilter);
|
|
229
|
-
if (this.dragTargetFilter === '' || !isPresent(filterElement)) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (isPresent(this.dragHandles) && !this.isDragHandle(event.target)) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
event.preventDefault();
|
|
236
|
-
const action = getAction(event, this.currentDragTarget);
|
|
237
|
-
this.service.handleDragAndDrop(action);
|
|
238
|
-
this.subscribe();
|
|
239
|
-
}
|
|
240
|
-
onPointerMove(event) {
|
|
241
|
-
const action = getAction(event, this.currentDragTarget);
|
|
242
|
-
this.service.handleDragAndDrop(action);
|
|
243
|
-
}
|
|
244
|
-
onTouchMove(event) {
|
|
245
|
-
event.preventDefault();
|
|
246
|
-
const action = getAction(event, this.currentDragTarget);
|
|
247
|
-
this.service.handleDragAndDrop(action);
|
|
248
|
-
}
|
|
249
|
-
onPointerUp(event) {
|
|
250
|
-
const action = getAction(event, this.currentDragTarget);
|
|
251
|
-
this.service.handleDragAndDrop(action);
|
|
252
|
-
this.subscribe();
|
|
253
|
-
}
|
|
254
|
-
onContextMenu(event) {
|
|
255
|
-
event.preventDefault();
|
|
256
|
-
const action = getAction(event, this.currentDragTarget);
|
|
257
|
-
this.service.handleDragAndDrop(action);
|
|
258
|
-
this.subscribe();
|
|
259
|
-
}
|
|
260
|
-
handlePress(event) {
|
|
261
|
-
if (this.dragDelay > 0) {
|
|
262
|
-
this.dragTimeout = window.setTimeout(() => {
|
|
263
|
-
this.pressed = true;
|
|
264
|
-
this.emitZoneAwareEvent('onDragReady', event);
|
|
265
|
-
}, this.dragDelay);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
this.pressed = true;
|
|
269
|
-
}
|
|
270
|
-
const eventTarget = event.originalEvent.target;
|
|
271
|
-
this.currentDragTargetElement = closestBySelector(eventTarget, this.dragTargetFilter);
|
|
272
|
-
this.currentDragTarget.element = this.currentDragTargetElement;
|
|
273
|
-
this.service.dragIndex = this.getDragIndex();
|
|
274
|
-
this.scrollableParent = this.hintTemplate ? document.body : this.currentDragTargetElement ? getScrollableParent(this.currentDragTargetElement) : null;
|
|
275
|
-
this.prevUserSelect = this.currentDragTargetElement.style.userSelect;
|
|
276
|
-
this.renderer.setStyle(this.currentDragTargetElement, 'user-select', 'none');
|
|
277
|
-
this.emitZoneAwareEvent('onPress', event);
|
|
278
|
-
}
|
|
279
|
-
handleDragStart(event) {
|
|
280
|
-
if (!this.pressed) {
|
|
281
|
-
if (this.dragTimeout) {
|
|
282
|
-
window.clearTimeout(this.dragTimeout);
|
|
283
|
-
this.dragTimeout = null;
|
|
284
|
-
}
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
isDragStartPrevented = this.emitZoneAwareEvent('onDragStart', event).isDefaultPrevented();
|
|
288
|
-
if (isDragStartPrevented) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
this.position = this.positionsMap.has(this.currentDragTargetElement) ? this.positionsMap.get(this.currentDragTargetElement) : { x: 0, y: 0 };
|
|
292
|
-
if (this.hint) {
|
|
293
|
-
this.createHint();
|
|
294
|
-
if (this.mode === 'auto') {
|
|
295
|
-
this.renderer.setStyle(this.currentDragTargetElement, 'opacity', '0.7');
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
this.initialPosition = { x: event.clientX - this.position.x, y: event.clientY - this.position.y };
|
|
300
|
-
}
|
|
301
|
-
this.dragStarted = this.threshold === 0;
|
|
302
|
-
this.service.dragTarget = this.currentDragTarget;
|
|
303
|
-
const targetIdArgs = { dragTarget: this.currentDragTargetElement, dragTargetIndex: this.service.dragIndex };
|
|
304
|
-
this.service.dragTargetId = this.dragTargetId(targetIdArgs);
|
|
305
|
-
const targetDataArgs = Object.assign({ dragTargetId: this.service.dragTargetId }, targetIdArgs);
|
|
306
|
-
this.service.dragData = this.dragData(targetDataArgs);
|
|
307
|
-
}
|
|
308
|
-
handleDrag(event) {
|
|
309
|
-
if (!this.pressed || isDragStartPrevented) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
const elem = this.hint ? this.hintElem : this.currentDragTargetElement;
|
|
313
|
-
this.position = this.calculatePosition(elem, event);
|
|
314
|
-
const thresholdNotReached = Math.abs(this.position.x) < this.threshold && Math.abs(this.position.y) < this.threshold;
|
|
315
|
-
if (!this.dragStarted && thresholdNotReached) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (!this.dragStarted && this.threshold > 0) {
|
|
319
|
-
this.dragStarted = true;
|
|
320
|
-
}
|
|
321
|
-
isDragPrevented = this.emitZoneAwareEvent('onDrag', event).isDefaultPrevented();
|
|
322
|
-
if (isDragPrevented) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (this.mode === 'auto') {
|
|
326
|
-
this.performDrag();
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
this.dragStarted = true;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
handleRelease(event) {
|
|
333
|
-
if (this.dragStarted) {
|
|
334
|
-
this.positionsMap.set(this.currentDragTargetElement, this.position);
|
|
335
|
-
}
|
|
336
|
-
if (this.dragTimeout) {
|
|
337
|
-
clearTimeout(this.dragTimeout);
|
|
338
|
-
this.dragTimeout = null;
|
|
339
|
-
}
|
|
340
|
-
this.pressed = false;
|
|
341
|
-
this.prevUserSelect ? this.renderer.setStyle(this.currentDragTargetElement, 'user-select', this.prevUserSelect) :
|
|
342
|
-
this.renderer.removeStyle(this.currentDragTargetElement, 'user-select');
|
|
343
|
-
this.prevUserSelect = null;
|
|
344
|
-
this.emitZoneAwareEvent('onRelease', event);
|
|
345
|
-
}
|
|
346
|
-
handleDragEnd(event) {
|
|
347
|
-
if (!this.dragStarted) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
if (this.mode === 'auto') {
|
|
351
|
-
const isDroppedOverParentTarget = isPresent(this.service.dropTarget) && !contains(this.service.dropTarget?.element, this.service.dragTarget?.element, true);
|
|
352
|
-
const elem = this.hint ? this.hintElem : this.currentDragTargetElement;
|
|
353
|
-
if (isDroppedOverParentTarget || this.service.dropTargets.length > 0 && isPresent(elem)) {
|
|
354
|
-
this.renderer.removeStyle(elem, 'transform');
|
|
355
|
-
setElementStyles(this.renderer, elem, {
|
|
356
|
-
transition: dragTargetTransition
|
|
357
|
-
});
|
|
358
|
-
this.positionsMap.delete(this.currentDragTargetElement);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
if (this.hint && isPresent(this.hintElem)) {
|
|
362
|
-
this.destroyHint();
|
|
363
|
-
if (this.mode === 'auto') {
|
|
364
|
-
this.renderer.removeStyle(this.currentDragTargetElement, 'opacity');
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
this.service.dragTarget = null;
|
|
368
|
-
this.service.dragIndex = null;
|
|
369
|
-
this.currentDragTarget.element = null;
|
|
370
|
-
this.emitZoneAwareEvent('onDragEnd', event);
|
|
371
|
-
if (isDragStartPrevented || isDragPrevented) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
this.dragStarted = false;
|
|
375
|
-
}
|
|
376
|
-
get nativeElement() {
|
|
377
|
-
return this.wrapper.nativeElement;
|
|
378
|
-
}
|
|
379
|
-
get hintElem() {
|
|
380
|
-
return this.hintTemplate && isPresent(this.hintComponent) ? this.hintComponent.instance.element.nativeElement : this.defaultHint;
|
|
381
|
-
}
|
|
382
|
-
removeListeners() {
|
|
383
|
-
if (isPresent(this.scrollableParent)) {
|
|
384
|
-
this.scrollableParent.removeEventListener('scroll', this.onPointerMove);
|
|
385
|
-
}
|
|
386
|
-
const element = this.nativeElement;
|
|
387
|
-
if (!isDocumentAvailable()) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
document.removeEventListener('pointermove', this.onPointerMove);
|
|
391
|
-
document.removeEventListener('pointerup', this.onPointerUp, true);
|
|
392
|
-
document.removeEventListener('pointercancel', this.onPointerUp);
|
|
393
|
-
document.removeEventListener('contextmenu', this.onContextMenu);
|
|
394
|
-
window.removeEventListener('touchmove', noop);
|
|
395
|
-
element.removeEventListener('touchmove', this.onTouchMove);
|
|
396
|
-
element.removeEventListener('touchend', this.onPointerUp);
|
|
397
|
-
document.removeEventListener('mousemove', this.onPointerMove);
|
|
398
|
-
document.removeEventListener('mouseup', this.onPointerUp);
|
|
399
|
-
document.removeEventListener('touchcancel', this.onPointerUp);
|
|
400
|
-
element.removeEventListener('pointerdown', this.onPointerDown);
|
|
401
|
-
element.removeEventListener('mousedown', this.onPointerDown);
|
|
402
|
-
element.removeEventListener('touchstart', this.onTouchStart);
|
|
403
|
-
}
|
|
404
|
-
get supportPointerEvent() {
|
|
405
|
-
return Boolean(typeof window !== 'undefined' && window.PointerEvent);
|
|
406
|
-
}
|
|
407
|
-
subscribe() {
|
|
408
|
-
this.ngZone.runOutsideAngular(() => {
|
|
409
|
-
this.removeListeners();
|
|
410
|
-
if (!(isDocumentAvailable() && isPresent(this.wrapper))) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
this.onPointerMove = this.onPointerMove.bind(this);
|
|
414
|
-
this.onPointerUp = this.onPointerUp.bind(this);
|
|
415
|
-
this.onTouchMove = this.onTouchMove.bind(this);
|
|
416
|
-
this.onContextMenu = this.onContextMenu.bind(this);
|
|
417
|
-
this.onPointerDown = this.onPointerDown.bind(this);
|
|
418
|
-
this.onTouchStart = this.onTouchStart.bind(this);
|
|
419
|
-
const element = this.nativeElement;
|
|
420
|
-
if (this.supportPointerEvent) {
|
|
421
|
-
if (isPresent(this.scrollableParent)) {
|
|
422
|
-
this.scrollableParent.addEventListener('scroll', this.onPointerMove, { passive: true });
|
|
423
|
-
}
|
|
424
|
-
element.addEventListener('pointerdown', this.onPointerDown, { passive: true });
|
|
425
|
-
if (this.pressed) {
|
|
426
|
-
document.addEventListener('pointermove', this.onPointerMove);
|
|
427
|
-
document.addEventListener('pointerup', this.onPointerUp, true);
|
|
428
|
-
document.addEventListener('contextmenu', this.onContextMenu);
|
|
429
|
-
document.addEventListener('pointercancel', this.onPointerUp, { passive: true });
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
window.addEventListener('touchmove', noop, { capture: false, passive: false });
|
|
434
|
-
element.addEventListener('mousedown', this.onPointerDown, { passive: true });
|
|
435
|
-
element.addEventListener('touchstart', this.onTouchStart, { passive: true });
|
|
436
|
-
if (this.pressed) {
|
|
437
|
-
document.addEventListener('mousemove', this.onPointerMove, { passive: true });
|
|
438
|
-
document.addEventListener('mouseup', this.onPointerUp, { passive: true });
|
|
439
|
-
element.addEventListener('touchmove', this.onTouchMove, { passive: true });
|
|
440
|
-
element.addEventListener('touchend', this.onPointerUp, { passive: true });
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
emitZoneAwareEvent(event, normalizedEvent) {
|
|
446
|
-
const targetIdArgs = { dragTarget: this.currentDragTargetElement, dragTargetIndex: this.service.dragIndex };
|
|
447
|
-
const eventProps = {
|
|
448
|
-
dragTarget: this.currentDragTargetElement,
|
|
449
|
-
dragEvent: normalizedEvent,
|
|
450
|
-
dragTargetIndex: this.service.dragIndex,
|
|
451
|
-
dragTargetId: this.dragTargetId(targetIdArgs)
|
|
452
|
-
};
|
|
453
|
-
if (this.hint && isPresent(this.hintElem)) {
|
|
454
|
-
eventProps.hintElement = this.hintElem;
|
|
455
|
-
}
|
|
456
|
-
let eventArgs;
|
|
457
|
-
switch (event) {
|
|
458
|
-
case 'onDragReady':
|
|
459
|
-
eventArgs = new DragTargetDragReadyEvent(eventProps);
|
|
460
|
-
break;
|
|
461
|
-
case 'onPress':
|
|
462
|
-
eventArgs = new DragTargetPressEvent(eventProps);
|
|
463
|
-
break;
|
|
464
|
-
case 'onDragStart':
|
|
465
|
-
eventArgs = new DragTargetDragStartEvent(eventProps);
|
|
466
|
-
break;
|
|
467
|
-
case 'onDrag':
|
|
468
|
-
eventArgs = new DragTargetDragEvent(eventProps);
|
|
469
|
-
break;
|
|
470
|
-
case 'onRelease':
|
|
471
|
-
eventArgs = new DragTargetReleaseEvent(eventProps);
|
|
472
|
-
break;
|
|
473
|
-
case 'onDragEnd':
|
|
474
|
-
eventArgs = new DragTargetDragEndEvent(eventProps);
|
|
475
|
-
break;
|
|
476
|
-
default:
|
|
477
|
-
break;
|
|
478
|
-
}
|
|
479
|
-
this.ngZone.run(() => {
|
|
480
|
-
this[event].emit(eventArgs);
|
|
481
|
-
});
|
|
482
|
-
return eventArgs;
|
|
483
|
-
}
|
|
484
|
-
createHint() {
|
|
485
|
-
if (!(isDocumentAvailable() && isPresent(this.wrapper))) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
if (isPresent(this.hint) && typeof this.hint === 'object') {
|
|
489
|
-
if (isPresent(this.hint.hintTemplate)) {
|
|
490
|
-
this.createCustomHint();
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
this.createDefaultHint();
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
this.createDefaultHint();
|
|
498
|
-
}
|
|
499
|
-
this.currentDragTarget.hint = this.hintElem;
|
|
500
|
-
if (typeof this.hint === 'object' && isPresent(this.hint.appendTo)) {
|
|
501
|
-
this.hint.appendTo.element.nativeElement.appendChild(this.hintElem);
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
document.body.appendChild(this.hintElem);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
createDefaultHint() {
|
|
508
|
-
this.defaultHint = this.currentDragTargetElement.cloneNode(true);
|
|
509
|
-
if (typeof this.hint === 'object') {
|
|
510
|
-
if (isPresent(this.hint.hintClass)) {
|
|
511
|
-
const hintClasses = parseCSSClassNames(this.hint.hintClass);
|
|
512
|
-
hintClasses.forEach(className => this.renderer.addClass(this.defaultHint, className));
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
createCustomHint() {
|
|
517
|
-
if (isPresent(this.hint.appendTo)) {
|
|
518
|
-
this.hintComponent = this.hint.appendTo.createComponent(HintComponent);
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
this.hintComponent = this.viewContainer.createComponent(HintComponent);
|
|
522
|
-
}
|
|
523
|
-
this.hintComponent.instance.template = this.hintTemplate;
|
|
524
|
-
this.hintComponent.instance.directive = this;
|
|
525
|
-
this.hintComponent.instance.targetIndex = this.service.dragIndex;
|
|
526
|
-
const targetDataArgs = { dragTarget: this.currentDragTargetElement, dragTargetId: this.service.dragTargetId, dragTargetIndex: this.service.dragIndex };
|
|
527
|
-
this.hintComponent.instance.contextData = this.dragData(targetDataArgs);
|
|
528
|
-
this.hintComponent.instance.customContext = this.hintContext;
|
|
529
|
-
this.hintComponent.changeDetectorRef.detectChanges();
|
|
530
|
-
}
|
|
531
|
-
destroyHint() {
|
|
532
|
-
if (isPresent(this.hintTemplate)) {
|
|
533
|
-
this.hintComponent.destroy();
|
|
534
|
-
this.hintComponent.changeDetectorRef.detectChanges();
|
|
535
|
-
this.hintComponent = null;
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
document.body.removeChild(this.defaultHint);
|
|
539
|
-
this.defaultHint = null;
|
|
540
|
-
}
|
|
541
|
-
this.currentDragTarget.hint = null;
|
|
542
|
-
}
|
|
543
|
-
getDragIndex() {
|
|
544
|
-
return this.allDragTargets.indexOf(this.currentDragTargetElement);
|
|
545
|
-
}
|
|
546
|
-
initializeDragTargets() {
|
|
547
|
-
if (!isPresent(this.allDragTargets)) {
|
|
548
|
-
if (this.previousDragTargets.length > 0) {
|
|
549
|
-
this.clearPreviousTargets();
|
|
550
|
-
}
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
this.allDragTargets.forEach(dragTargetEl => {
|
|
554
|
-
const isDragTargetInitialized = this.service.dragTargets.find(dt => dt.element === dragTargetEl);
|
|
555
|
-
if (!isDragTargetInitialized) {
|
|
556
|
-
this.service.dragTargets.push({
|
|
557
|
-
element: dragTargetEl,
|
|
558
|
-
hint: null,
|
|
559
|
-
onPress: this.handlePress.bind(this),
|
|
560
|
-
onRelease: this.handleRelease.bind(this),
|
|
561
|
-
onDragStart: this.handleDragStart.bind(this),
|
|
562
|
-
onDrag: this.handleDrag.bind(this),
|
|
563
|
-
onDragEnd: this.handleDragEnd.bind(this)
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
if (this.previousDragTargets.length > 0) {
|
|
568
|
-
const dragTargetsToRemove = this.previousDragTargets.filter(dt => !this.allDragTargets.includes(dt));
|
|
569
|
-
dragTargetsToRemove.forEach(dragTarget => {
|
|
570
|
-
const idx = this.service.dragTargets.findIndex(serviceDragTarget => serviceDragTarget.element === dragTarget);
|
|
571
|
-
if (idx > -1) {
|
|
572
|
-
this.service.dragTargets.splice(idx, 1);
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
this.previousDragTargets = this.allDragTargets;
|
|
577
|
-
this.currentDragTarget = {
|
|
578
|
-
element: null,
|
|
579
|
-
hint: null,
|
|
580
|
-
onPress: this.handlePress.bind(this),
|
|
581
|
-
onRelease: this.handleRelease.bind(this),
|
|
582
|
-
onDragStart: this.handleDragStart.bind(this),
|
|
583
|
-
onDrag: this.handleDrag.bind(this),
|
|
584
|
-
onDragEnd: this.handleDragEnd.bind(this)
|
|
585
|
-
};
|
|
586
|
-
this.setTargetStyles();
|
|
587
|
-
}
|
|
588
|
-
isDragHandle(el) {
|
|
589
|
-
return this.dragHandles.some(dh => contains(dh, el, true));
|
|
590
|
-
}
|
|
591
|
-
get isHandleSelectorValid() {
|
|
592
|
-
return isPresent(this.dragHandle) && this.dragHandle !== '';
|
|
593
|
-
}
|
|
594
|
-
setTargetStyles() {
|
|
595
|
-
if (!isDocumentAvailable()) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
if (isPresent(this.dragHandle) && this.dragHandle !== '') {
|
|
599
|
-
if (isPresent(this.dragHandles) && this.dragHandles.length > 0) {
|
|
600
|
-
this.dragHandles.forEach(handle => {
|
|
601
|
-
this.renderer.setStyle(handle, 'cursor', this.cursorStyle);
|
|
602
|
-
this.renderer.setStyle(handle, 'touch-action', 'none');
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
else {
|
|
607
|
-
this.allDragTargets.forEach(target => {
|
|
608
|
-
this.renderer.setStyle(target, 'cursor', this.cursorStyle);
|
|
609
|
-
this.renderer.setStyle(target, 'touch-action', 'none');
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
queryHost(selector) {
|
|
614
|
-
if (isPresent(selector) && selector !== "") {
|
|
615
|
-
return Array.from(this.nativeElement.querySelectorAll(selector));
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
clearPreviousTargets() {
|
|
619
|
-
this.previousDragTargets.forEach(dragTarget => {
|
|
620
|
-
const idx = this.service.dragTargets.findIndex(serviceDragTarget => serviceDragTarget.element === dragTarget);
|
|
621
|
-
if (idx > -1) {
|
|
622
|
-
this.service.dragTargets.splice(idx, 1);
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
this.previousDragTargets = [];
|
|
626
|
-
}
|
|
627
|
-
performDrag() {
|
|
628
|
-
const elem = this.hint ? this.hintElem : this.currentDragTargetElement;
|
|
629
|
-
if (elem) {
|
|
630
|
-
const styles = this.getStylesPerElement(elem);
|
|
631
|
-
setElementStyles(this.renderer, elem, styles);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
calculatePosition(element, event) {
|
|
635
|
-
let position = null;
|
|
636
|
-
if (!isDocumentAvailable()) {
|
|
637
|
-
return { x: 0, y: 0 };
|
|
638
|
-
}
|
|
639
|
-
if (element === this.hintElem) {
|
|
640
|
-
position = { x: event.clientX + window.scrollX, y: event.clientY + window.scrollY };
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
position = { x: event.clientX - this.initialPosition.x + event.scrollX, y: event.clientY - this.initialPosition.y + event.scrollY };
|
|
644
|
-
}
|
|
645
|
-
return position;
|
|
646
|
-
}
|
|
647
|
-
getStylesPerElement(element) {
|
|
648
|
-
if (element === this.hintElem) {
|
|
649
|
-
return {
|
|
650
|
-
top: `${this.position.y}px`,
|
|
651
|
-
left: `${this.position.x}px`,
|
|
652
|
-
transition: 'none',
|
|
653
|
-
position: 'absolute',
|
|
654
|
-
zIndex: 1999
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
const transform = `translate(${this.position.x}px, ${this.position.y}px)`;
|
|
659
|
-
return {
|
|
660
|
-
transform: transform,
|
|
661
|
-
transition: 'none'
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragTargetContainerDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.Renderer2 }, { token: i1.DragStateService }, { token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
666
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: DragTargetContainerDirective, isStandalone: true, selector: "[kendoDragTargetContainer]", inputs: { hint: "hint", dragTargetFilter: "dragTargetFilter", dragHandle: "dragHandle", dragDelay: "dragDelay", threshold: "threshold", dragTargetId: "dragTargetId", dragData: "dragData", dragDisabled: "dragDisabled", mode: "mode", cursorStyle: "cursorStyle", hintContext: "hintContext" }, outputs: { onDragReady: "onDragReady", onPress: "onPress", onDragStart: "onDragStart", onDrag: "onDrag", onRelease: "onRelease", onDragEnd: "onDragEnd" }, exportAs: ["kendoDragTargetContainer"], ngImport: i0 });
|
|
667
|
-
}
|
|
668
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragTargetContainerDirective, decorators: [{
|
|
669
|
-
type: Directive,
|
|
670
|
-
args: [{
|
|
671
|
-
selector: '[kendoDragTargetContainer]',
|
|
672
|
-
exportAs: 'kendoDragTargetContainer',
|
|
673
|
-
standalone: true
|
|
674
|
-
}]
|
|
675
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.Renderer2 }, { type: i1.DragStateService }, { type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }], propDecorators: { hint: [{
|
|
676
|
-
type: Input
|
|
677
|
-
}], dragTargetFilter: [{
|
|
678
|
-
type: Input
|
|
679
|
-
}], dragHandle: [{
|
|
680
|
-
type: Input
|
|
681
|
-
}], dragDelay: [{
|
|
682
|
-
type: Input
|
|
683
|
-
}], threshold: [{
|
|
684
|
-
type: Input
|
|
685
|
-
}], dragTargetId: [{
|
|
686
|
-
type: Input
|
|
687
|
-
}], dragData: [{
|
|
688
|
-
type: Input
|
|
689
|
-
}], dragDisabled: [{
|
|
690
|
-
type: Input
|
|
691
|
-
}], mode: [{
|
|
692
|
-
type: Input
|
|
693
|
-
}], cursorStyle: [{
|
|
694
|
-
type: Input
|
|
695
|
-
}], hintContext: [{
|
|
696
|
-
type: Input
|
|
697
|
-
}], onDragReady: [{
|
|
698
|
-
type: Output
|
|
699
|
-
}], onPress: [{
|
|
700
|
-
type: Output
|
|
701
|
-
}], onDragStart: [{
|
|
702
|
-
type: Output
|
|
703
|
-
}], onDrag: [{
|
|
704
|
-
type: Output
|
|
705
|
-
}], onRelease: [{
|
|
706
|
-
type: Output
|
|
707
|
-
}], onDragEnd: [{
|
|
708
|
-
type: Output
|
|
709
|
-
}] } });
|