@progress/kendo-angular-utils 21.4.1 → 22.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/fesm2022/progress-kendo-angular-utils.mjs +38 -38
  2. package/package.json +8 -16
  3. package/esm2022/adaptive-breakpoints/adaptive-settings.mjs +0 -20
  4. package/esm2022/adaptive-breakpoints/adaptive-settings.service.mjs +0 -29
  5. package/esm2022/adaptive-breakpoints/adaptive.service.mjs +0 -114
  6. package/esm2022/adaptive-breakpoints/index.mjs +0 -7
  7. package/esm2022/adaptive-breakpoints/models/adaptive-settings.mjs +0 -5
  8. package/esm2022/adaptive-breakpoints/models/adaptive-size.mjs +0 -5
  9. package/esm2022/directives.mjs +0 -45
  10. package/esm2022/drag-and-drop/drag-state.service.mjs +0 -139
  11. package/esm2022/drag-and-drop/draghandle.directive.mjs +0 -49
  12. package/esm2022/drag-and-drop/dragtarget-container.directive.mjs +0 -709
  13. package/esm2022/drag-and-drop/dragtarget.directive.mjs +0 -596
  14. package/esm2022/drag-and-drop/droptarget-container.directive.mjs +0 -236
  15. package/esm2022/drag-and-drop/droptarget.directive.mjs +0 -137
  16. package/esm2022/drag-and-drop/events/drag-target/drag-event.mjs +0 -52
  17. package/esm2022/drag-and-drop/events/drag-target/dragready-event.mjs +0 -32
  18. package/esm2022/drag-and-drop/events/drag-target/end-event.mjs +0 -46
  19. package/esm2022/drag-and-drop/events/drag-target/index.mjs +0 -10
  20. package/esm2022/drag-and-drop/events/drag-target/press-event.mjs +0 -46
  21. package/esm2022/drag-and-drop/events/drag-target/release-event.mjs +0 -46
  22. package/esm2022/drag-and-drop/events/drag-target/start-event.mjs +0 -48
  23. package/esm2022/drag-and-drop/events/drop-target-event.mjs +0 -53
  24. package/esm2022/drag-and-drop/events/index.mjs +0 -6
  25. package/esm2022/drag-and-drop/hint.component.mjs +0 -56
  26. package/esm2022/drag-and-drop/models/autoscroll-options.mjs +0 -5
  27. package/esm2022/drag-and-drop/models/coordinates.mjs +0 -5
  28. package/esm2022/drag-and-drop/models/drag-axis.mjs +0 -5
  29. package/esm2022/drag-and-drop/models/drag-mode.mjs +0 -5
  30. package/esm2022/drag-and-drop/models/functions.mjs +0 -5
  31. package/esm2022/drag-and-drop/models/hint-settings.mjs +0 -5
  32. package/esm2022/drag-and-drop/models/index.mjs +0 -5
  33. package/esm2022/drag-and-drop/models/scroll-direction.mjs +0 -5
  34. package/esm2022/drag-and-drop/util.mjs +0 -90
  35. package/esm2022/drag-and-drop.module.mjs +0 -45
  36. package/esm2022/index.mjs +0 -17
  37. package/esm2022/package-metadata.mjs +0 -16
  38. package/esm2022/progress-kendo-angular-utils.mjs +0 -8
  39. package/esm2022/utils.module.mjs +0 -45
@@ -1,596 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2026 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { Directive, EventEmitter, Output, ElementRef, Renderer2, NgZone, Input, ContentChildren, QueryList, ViewContainerRef, isDevMode, HostBinding } 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 { DragStateService } from "./drag-state.service";
11
- import { getAction, isPresent, setElementStyles, dragTargetTransition, noop } from './util';
12
- import { contains, isDocumentAvailable, parseCSSClassNames } from "@progress/kendo-angular-common";
13
- import { HintComponent } from "./hint.component";
14
- import { DragTargetDragEndEvent, DragTargetDragEvent, DragTargetDragStartEvent, DragTargetPressEvent } from "./events/drag-target";
15
- import { DragTargetReleaseEvent } from "./events/drag-target/release-event";
16
- import { DragTargetDragReadyEvent } from "./events/drag-target/dragready-event";
17
- import * as i0 from "@angular/core";
18
- import * as i1 from "./drag-state.service";
19
- let isDragStartPrevented = false;
20
- let isDragPrevented = false;
21
- /**
22
- * Represents the Kendo UI DragTarget directive for Angular.
23
- * Use this directive to make an element draggable.
24
- */
25
- export class DragTargetDirective {
26
- element;
27
- renderer;
28
- ngZone;
29
- service;
30
- viewContainer;
31
- get touchActionStyle() {
32
- return this.dragHandles.length > 0 ? null : 'none';
33
- }
34
- /**
35
- * Defines whether a hint will be used for dragging. By default, the hint is a copy of the drag target. ([see example]({% slug drag_hint %})).
36
- *
37
- * @default false
38
- */
39
- hint = false;
40
- /**
41
- * Sets the number of pixels the pointer must move before dragging starts. Applies when `manualDrag` is `false`. [See example]({% slug minimum_distance %}).
42
- *
43
- * @default 0
44
- */
45
- threshold = 0;
46
- /**
47
- * Sets the automatic container scrolling behavior when close to the edge. [See example]({% slug auto_scroll %}).
48
- *
49
- * @default true
50
- */
51
- autoScroll = true;
52
- /**
53
- * Sets a unique identifier for the drag target.
54
- */
55
- dragTargetId;
56
- /**
57
- * Sets the delay in milliseconds before dragging begins. [See example]({% slug drag_delay %}).
58
- *
59
- * @default 0
60
- */
61
- dragDelay = 0;
62
- /**
63
- * Restricts dragging to horizontal or vertical only. Applies when `mode` is `auto`. [See example]({% slug axis_lock %}).
64
- */
65
- restrictByAxis;
66
- /**
67
- * Specifies whether to use the default dragging behavior or handle it manually.
68
- *
69
- * @default 'auto'
70
- */
71
- mode = 'auto';
72
- /**
73
- * Defines a callback function used for attaching custom data to the drag target.
74
- * The data is available in the events of the respective [`DropTarget`]({% slug api_utils_droptargetdirective %}) or [`DropTargetContainer`]({% slug api_utils_droptargetcontainerdirective %}) directives.
75
- * The current DragTarget HTML element and its `dragTargetId` will be available as arguments.
76
- */
77
- set dragData(fn) {
78
- if (isDevMode && typeof fn !== 'function') {
79
- throw new Error(`dragData must be a function, but received ${JSON.stringify(fn)}.`);
80
- }
81
- this._dragData = fn;
82
- }
83
- get dragData() {
84
- return this._dragData;
85
- }
86
- /**
87
- * Sets the cursor style of the drag target. Accepts same values as the [CSS `cursor` property](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#values).
88
- *
89
- * @default 'move'
90
- */
91
- cursorStyle = 'move';
92
- /**
93
- * Fires when the user presses the drag target element.
94
- */
95
- onPress = new EventEmitter();
96
- /**
97
- * Fires when dragging of the drag target element begins.
98
- */
99
- onDragStart = new EventEmitter();
100
- /**
101
- * Fires while the user drags the drag target element.
102
- */
103
- onDrag = new EventEmitter();
104
- /**
105
- * Fires when the drag target's `dragDelay` has passed and the user can drag the element.
106
- */
107
- onDragReady = new EventEmitter();
108
- /**
109
- * Fires when `DragTarget` is released, either by dropping it on a drop target or by releasing the mouse button.
110
- */
111
- onRelease = new EventEmitter();
112
- /**
113
- * Fires when dragging of the drag target ends and the element is released.
114
- */
115
- onDragEnd = new EventEmitter();
116
- dragTarget = null;
117
- hintComponent = null;
118
- dragStarted = false;
119
- pressed = false;
120
- dragReady = false;
121
- dragTimeout = null;
122
- initialPosition = { x: 0, y: 0 };
123
- position = { x: 0, y: 0 };
124
- scrollableParent = null;
125
- defaultHint = null;
126
- _dragData = () => null;
127
- prevUserSelect;
128
- get hintTemplate() {
129
- return isPresent(this.hint) && typeof this.hint === 'object' ? this.hint.hintTemplate : null;
130
- }
131
- get nativeElement() {
132
- return this.element.nativeElement;
133
- }
134
- get hintElem() {
135
- return this.hintTemplate && isPresent(this.hintComponent) ? this.hintComponent.instance.element.nativeElement : this.defaultHint;
136
- }
137
- onPointerDown(event) {
138
- if (this.dragHandles.length && !this.isDragHandle(event.target)) {
139
- return;
140
- }
141
- const action = getAction(event, this.dragTarget);
142
- this.service.handleDragAndDrop(action);
143
- this.service.autoScroll = typeof this.autoScroll === 'object' ? this.autoScroll.enabled !== false : this.autoScroll;
144
- this.service.scrollableParent = this.getAutoScrollContainer();
145
- this.service.autoScrollDirection = typeof this.autoScroll === 'object' ? this.autoScroll.direction : { horizontal: true, vertical: true };
146
- this.attachDomHandlers();
147
- }
148
- onTouchStart(event) {
149
- if (this.dragHandles.length && !this.isDragHandle(event.target)) {
150
- return;
151
- }
152
- event.preventDefault();
153
- const action = getAction(event, this.dragTarget);
154
- this.service.handleDragAndDrop(action);
155
- this.service.autoScroll = typeof this.autoScroll === 'object' ? this.autoScroll.enabled !== false : this.autoScroll;
156
- this.service.scrollableParent = this.getAutoScrollContainer();
157
- this.service.autoScrollDirection = typeof this.autoScroll === 'object' ? this.autoScroll.direction : { horizontal: true, vertical: true };
158
- this.attachDomHandlers();
159
- }
160
- onPointerMove(event) {
161
- const action = getAction(event, this.dragTarget);
162
- this.service.handleDragAndDrop(action);
163
- }
164
- onTouchMove(event) {
165
- event.preventDefault();
166
- const action = getAction(event, this.dragTarget);
167
- this.service.handleDragAndDrop(action);
168
- }
169
- onPointerUp(event) {
170
- const action = getAction(event, this.dragTarget);
171
- this.service.handleDragAndDrop(action);
172
- this.attachDomHandlers();
173
- }
174
- onContextMenu(event) {
175
- event.preventDefault();
176
- const action = getAction(event, this.dragTarget);
177
- this.service.handleDragAndDrop(action);
178
- this.attachDomHandlers();
179
- }
180
- dragHandles;
181
- constructor(element, renderer, ngZone, service, viewContainer) {
182
- this.element = element;
183
- this.renderer = renderer;
184
- this.ngZone = ngZone;
185
- this.service = service;
186
- this.viewContainer = viewContainer;
187
- validatePackage(packageMetadata);
188
- }
189
- ngOnInit() {
190
- this.initializeDragTarget();
191
- }
192
- ngAfterContentInit() {
193
- if (isPresent(this.element) || isPresent(this.dragTarget)) {
194
- this.attachDomHandlers();
195
- if (!this.dragHandles.length) {
196
- this.renderer.setStyle(this.nativeElement, 'cursor', this.cursorStyle);
197
- }
198
- }
199
- this.service.dragTargets.push(this.dragTarget);
200
- }
201
- ngOnDestroy() {
202
- this.removeListeners();
203
- const currentDragTargetIndex = this.service.dragTargets.indexOf(this.dragTarget);
204
- this.service.dragTargets.splice(currentDragTargetIndex, 1);
205
- }
206
- handlePress(event) {
207
- this.pressed = true;
208
- if (this.dragDelay > 0) {
209
- this.dragTimeout = window.setTimeout(() => {
210
- this.dragReady = true;
211
- this.emitZoneAwareEvent('onDragReady', event);
212
- }, this.dragDelay);
213
- }
214
- else {
215
- this.dragReady = true;
216
- }
217
- this.scrollableParent = this.dragTarget.element ? getScrollableParent(this.dragTarget.element) : null;
218
- this.prevUserSelect = this.dragTarget.element.style.userSelect;
219
- this.renderer.setStyle(this.dragTarget.element, 'user-select', 'none');
220
- this.emitZoneAwareEvent('onPress', event);
221
- }
222
- handleDragStart(event) {
223
- if (!this.pressed) {
224
- if (this.dragTimeout) {
225
- window.clearTimeout(this.dragTimeout);
226
- this.dragTimeout = null;
227
- }
228
- return;
229
- }
230
- if (!this.dragReady) {
231
- return;
232
- }
233
- isDragStartPrevented = this.emitZoneAwareEvent('onDragStart', event).isDefaultPrevented();
234
- if (isDragStartPrevented) {
235
- return;
236
- }
237
- if (this.hint) {
238
- this.createHint();
239
- if (this.mode === 'auto') {
240
- this.renderer.setStyle(this.nativeElement, 'opacity', '0.7');
241
- }
242
- this.initialPosition = { x: event.offsetX, y: event.offsetY };
243
- }
244
- else {
245
- this.initialPosition = { x: event.clientX - this.position.x, y: event.clientY - this.position.y };
246
- }
247
- this.dragStarted = this.threshold === 0;
248
- this.service.dragTarget = this.dragTarget;
249
- this.service.dragTargetDirective = this;
250
- this.service.dragData = this.dragData({ dragTarget: this.dragTarget.element, dragTargetId: this.dragTargetIdResult, dragTargetIndex: null });
251
- }
252
- handleDrag(event) {
253
- if (!this.pressed || !this.dragReady || isDragStartPrevented) {
254
- return;
255
- }
256
- const elem = this.hint ? this.hintElem : this.nativeElement;
257
- this.position = this.calculatePosition(elem, event);
258
- const thresholdNotReached = Math.abs(this.position.x) < this.threshold && Math.abs(this.position.y) < this.threshold;
259
- if (!this.dragStarted && thresholdNotReached) {
260
- return;
261
- }
262
- if (!this.dragStarted && this.threshold > 0) {
263
- this.dragStarted = true;
264
- }
265
- isDragPrevented = this.emitZoneAwareEvent('onDrag', event).isDefaultPrevented();
266
- if (isDragPrevented) {
267
- return;
268
- }
269
- if (this.mode === 'auto') {
270
- this.performDrag();
271
- }
272
- else {
273
- this.dragStarted = true;
274
- }
275
- }
276
- handleRelease(event) {
277
- if (this.dragTimeout) {
278
- clearTimeout(this.dragTimeout);
279
- this.dragTimeout = null;
280
- }
281
- this.pressed = false;
282
- this.dragReady = false;
283
- if (this.prevUserSelect) {
284
- this.renderer.setStyle(this.dragTarget.element, 'user-select', this.prevUserSelect);
285
- }
286
- else {
287
- this.renderer.removeStyle(this.dragTarget.element, 'user-select');
288
- }
289
- this.prevUserSelect = null;
290
- this.emitZoneAwareEvent('onRelease', event);
291
- }
292
- handleDragEnd(event) {
293
- if (this.mode === 'auto') {
294
- const isDroppedOverParentTarget = isPresent(this.service.dropTarget) && !contains(this.service.dropTarget?.element, this.service.dragTarget?.element, true);
295
- const elem = this.hint ? this.hintElem : this.nativeElement;
296
- if (isDroppedOverParentTarget || this.service.dropTargets.length > 0 && isPresent(elem)) {
297
- this.renderer.removeStyle(elem, 'transform');
298
- setElementStyles(this.renderer, elem, {
299
- transition: dragTargetTransition
300
- });
301
- this.position = { x: 0, y: 0 };
302
- }
303
- }
304
- if (this.hint && isPresent(this.hintElem)) {
305
- this.destroyHint();
306
- if (this.mode === 'auto') {
307
- this.renderer.removeStyle(this.nativeElement, 'opacity');
308
- }
309
- }
310
- this.service.dragTarget = null;
311
- this.service.dragTargetDirective = null;
312
- if (!this.dragStarted || isDragStartPrevented || isDragPrevented) {
313
- return;
314
- }
315
- this.emitZoneAwareEvent('onDragEnd', event);
316
- this.dragStarted = false;
317
- }
318
- initializeDragTarget() {
319
- this.dragTarget = {
320
- element: this.nativeElement,
321
- hint: null,
322
- onPress: this.handlePress.bind(this),
323
- onRelease: this.handleRelease.bind(this),
324
- onDragStart: this.handleDragStart.bind(this),
325
- onDrag: this.handleDrag.bind(this),
326
- onDragEnd: this.handleDragEnd.bind(this)
327
- };
328
- }
329
- get supportPointerEvent() {
330
- return Boolean(typeof window !== 'undefined' && window.PointerEvent);
331
- }
332
- removeListeners() {
333
- if (isPresent(this.scrollableParent)) {
334
- this.scrollableParent.removeEventListener('scroll', this.onPointerMove);
335
- }
336
- const element = this.nativeElement;
337
- if (!isDocumentAvailable()) {
338
- return;
339
- }
340
- document.removeEventListener('pointermove', this.onPointerMove);
341
- document.removeEventListener('pointerup', this.onPointerUp, true);
342
- document.removeEventListener('contextmenu', this.onContextMenu);
343
- document.removeEventListener('pointercancel', this.onPointerUp);
344
- window.removeEventListener('touchmove', noop);
345
- element.removeEventListener('touchmove', this.onTouchMove);
346
- element.removeEventListener('touchend', this.onPointerUp);
347
- document.removeEventListener('mousemove', this.onPointerMove);
348
- document.removeEventListener('mouseup', this.onPointerUp);
349
- document.removeEventListener('touchcancel', this.onPointerUp);
350
- element.removeEventListener('pointerdown', this.onPointerDown);
351
- element.removeEventListener('mousedown', this.onPointerDown);
352
- element.removeEventListener('touchstart', this.onTouchStart);
353
- }
354
- attachDomHandlers() {
355
- this.ngZone.runOutsideAngular(() => {
356
- this.removeListeners();
357
- if (!(isDocumentAvailable() && isPresent(this.element))) {
358
- return;
359
- }
360
- this.onPointerMove = this.onPointerMove.bind(this);
361
- this.onPointerUp = this.onPointerUp.bind(this);
362
- this.onTouchMove = this.onTouchMove.bind(this);
363
- this.onContextMenu = this.onContextMenu.bind(this);
364
- this.onPointerDown = this.onPointerDown.bind(this);
365
- this.onTouchStart = this.onTouchStart.bind(this);
366
- const element = this.nativeElement;
367
- if (this.supportPointerEvent) {
368
- if (isPresent(this.scrollableParent)) {
369
- if (this.scrollableParent === document.getElementsByTagName('html')[0]) {
370
- this.scrollableParent = window;
371
- }
372
- this.scrollableParent.addEventListener('scroll', this.onPointerMove, { passive: true });
373
- }
374
- element.addEventListener('pointerdown', this.onPointerDown, { passive: true });
375
- if (this.pressed) {
376
- document.addEventListener('pointermove', this.onPointerMove);
377
- document.addEventListener('pointerup', this.onPointerUp, true);
378
- document.addEventListener('contextmenu', this.onContextMenu);
379
- document.addEventListener('pointercancel', this.onPointerUp, { passive: true });
380
- }
381
- }
382
- else {
383
- window.addEventListener('touchmove', noop, { capture: false, passive: false });
384
- element.addEventListener('mousedown', this.onPointerDown, { passive: true });
385
- element.addEventListener('touchstart', this.onTouchStart, { passive: true });
386
- if (this.pressed) {
387
- document.addEventListener('mousemove', this.onPointerMove, { passive: true });
388
- document.addEventListener('mouseup', this.onPointerUp, { passive: true });
389
- element.addEventListener('touchmove', this.onTouchMove, { passive: true });
390
- element.addEventListener('touchend', this.onPointerUp, { passive: true });
391
- }
392
- }
393
- });
394
- }
395
- isDragHandle(el) {
396
- return this.dragHandles.toArray().some(dh => contains(dh.element.nativeElement, el, true));
397
- }
398
- getAutoScrollContainer() {
399
- return typeof this.autoScroll === 'object' &&
400
- this.autoScroll.boundaryElementRef &&
401
- this.autoScroll.boundaryElementRef.nativeElement ?
402
- this.autoScroll.boundaryElementRef.nativeElement : null;
403
- }
404
- createHint() {
405
- if (!(isDocumentAvailable() && isPresent(this.element))) {
406
- return;
407
- }
408
- if (isPresent(this.hint) && typeof this.hint === 'object') {
409
- if (isPresent(this.hint.hintTemplate)) {
410
- this.createCustomHint();
411
- }
412
- else {
413
- this.createDefaultHint();
414
- }
415
- }
416
- else {
417
- this.createDefaultHint();
418
- }
419
- this.dragTarget.hint = this.hintElem;
420
- if (typeof this.hint === 'object' && isPresent(this.hint.appendTo)) {
421
- this.hint.appendTo.element.nativeElement.appendChild(this.hintElem);
422
- }
423
- else {
424
- document.body.appendChild(this.hintElem);
425
- }
426
- }
427
- createDefaultHint() {
428
- this.defaultHint = this.nativeElement.cloneNode(true);
429
- if (typeof this.hint === 'object') {
430
- if (isPresent(this.hint.hintClass)) {
431
- const hintClasses = parseCSSClassNames(this.hint.hintClass);
432
- hintClasses.forEach(className => this.renderer.addClass(this.defaultHint, className));
433
- }
434
- }
435
- }
436
- createCustomHint() {
437
- if (isPresent(this.hint.appendTo)) {
438
- this.hintComponent = this.hint.appendTo.createComponent(HintComponent);
439
- }
440
- else {
441
- this.hintComponent = this.viewContainer.createComponent(HintComponent);
442
- }
443
- this.hintComponent.instance.template = this.hintTemplate;
444
- this.hintComponent.instance.directive = this;
445
- this.hintComponent.changeDetectorRef.detectChanges();
446
- }
447
- destroyHint() {
448
- if (isPresent(this.hintTemplate)) {
449
- this.hintComponent.destroy();
450
- this.hintComponent.changeDetectorRef.detectChanges();
451
- this.hintComponent = null;
452
- }
453
- else {
454
- if (typeof this.hint === 'object' && isPresent(this.hint.appendTo)) {
455
- this.hint.appendTo.element.nativeElement.removeChild(this.defaultHint);
456
- }
457
- else {
458
- document.body.removeChild(this.defaultHint);
459
- }
460
- this.defaultHint = null;
461
- }
462
- this.dragTarget.hint = null;
463
- }
464
- emitZoneAwareEvent(event, normalizedEvent) {
465
- const eventProps = {
466
- dragTarget: this.nativeElement,
467
- dragEvent: normalizedEvent
468
- };
469
- if (this.hint && isPresent(this.hintElem)) {
470
- eventProps.hintElement = this.hintElem;
471
- }
472
- if (this.dragTargetId && this.dragTargetId !== '') {
473
- eventProps.dragTargetId = this.dragTargetIdResult;
474
- }
475
- let eventArgs;
476
- switch (event) {
477
- case 'onDragReady':
478
- eventArgs = new DragTargetDragReadyEvent(eventProps);
479
- break;
480
- case 'onPress':
481
- eventArgs = new DragTargetPressEvent(eventProps);
482
- break;
483
- case 'onDragStart':
484
- eventArgs = new DragTargetDragStartEvent(eventProps);
485
- break;
486
- case 'onDrag':
487
- eventArgs = new DragTargetDragEvent(eventProps);
488
- break;
489
- case 'onRelease':
490
- eventArgs = new DragTargetReleaseEvent(eventProps);
491
- break;
492
- case 'onDragEnd':
493
- eventArgs = new DragTargetDragEndEvent(eventProps);
494
- break;
495
- default:
496
- break;
497
- }
498
- this.ngZone.run(() => {
499
- this[event].emit(eventArgs);
500
- });
501
- return eventArgs;
502
- }
503
- get dragTargetIdResult() {
504
- if (this.dragTargetId && this.dragTargetId !== '') {
505
- return typeof this.dragTargetId === 'string' ? this.dragTargetId : this.dragTargetId({ dragTarget: this.dragTarget.element, dragTargetIndex: null });
506
- }
507
- }
508
- performDrag() {
509
- const elem = this.hint ? this.hintElem : this.nativeElement;
510
- if (elem) {
511
- const styles = this.getStylesPerElement(elem);
512
- setElementStyles(this.renderer, elem, styles);
513
- }
514
- }
515
- calculatePosition(element, event) {
516
- let position = null;
517
- if (element === this.hintElem) {
518
- position = { x: event.clientX + window.scrollX, y: event.clientY + window.scrollY };
519
- }
520
- else {
521
- position = { x: event.clientX - this.initialPosition.x + event.scrollX, y: event.clientY - this.initialPosition.y + event.scrollY };
522
- }
523
- if (this.restrictByAxis === 'horizontal') {
524
- position.y = 0;
525
- }
526
- else if (this.restrictByAxis === 'vertical') {
527
- position.x = 0;
528
- }
529
- return position;
530
- }
531
- getStylesPerElement(element) {
532
- if (element === this.hintElem) {
533
- const hintCoordinates = { x: this.position.x - this.initialPosition.x, y: this.position.y - this.initialPosition.y };
534
- return {
535
- top: `${hintCoordinates.y}px`,
536
- left: `${hintCoordinates.x}px`,
537
- transition: 'none',
538
- position: 'absolute',
539
- zIndex: 1999
540
- };
541
- }
542
- else {
543
- const transform = `translate(${this.position.x}px, ${this.position.y}px)`;
544
- return {
545
- transform: transform,
546
- transition: 'none'
547
- };
548
- }
549
- }
550
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragTargetDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i1.DragStateService }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
551
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: DragTargetDirective, isStandalone: true, selector: "[kendoDragTarget]", inputs: { hint: "hint", threshold: "threshold", autoScroll: "autoScroll", dragTargetId: "dragTargetId", dragDelay: "dragDelay", restrictByAxis: "restrictByAxis", mode: "mode", dragData: "dragData", cursorStyle: "cursorStyle" }, outputs: { onPress: "onPress", onDragStart: "onDragStart", onDrag: "onDrag", onDragReady: "onDragReady", onRelease: "onRelease", onDragEnd: "onDragEnd" }, host: { properties: { "style.touch-action": "this.touchActionStyle" } }, queries: [{ propertyName: "dragHandles", predicate: DragHandleDirective, descendants: true }], exportAs: ["kendoDragTarget"], ngImport: i0 });
552
- }
553
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DragTargetDirective, decorators: [{
554
- type: Directive,
555
- args: [{
556
- selector: '[kendoDragTarget]',
557
- exportAs: 'kendoDragTarget',
558
- standalone: true
559
- }]
560
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i1.DragStateService }, { type: i0.ViewContainerRef }], propDecorators: { touchActionStyle: [{
561
- type: HostBinding,
562
- args: ['style.touch-action']
563
- }], hint: [{
564
- type: Input
565
- }], threshold: [{
566
- type: Input
567
- }], autoScroll: [{
568
- type: Input
569
- }], dragTargetId: [{
570
- type: Input
571
- }], dragDelay: [{
572
- type: Input
573
- }], restrictByAxis: [{
574
- type: Input
575
- }], mode: [{
576
- type: Input
577
- }], dragData: [{
578
- type: Input
579
- }], cursorStyle: [{
580
- type: Input
581
- }], onPress: [{
582
- type: Output
583
- }], onDragStart: [{
584
- type: Output
585
- }], onDrag: [{
586
- type: Output
587
- }], onDragReady: [{
588
- type: Output
589
- }], onRelease: [{
590
- type: Output
591
- }], onDragEnd: [{
592
- type: Output
593
- }], dragHandles: [{
594
- type: ContentChildren,
595
- args: [DragHandleDirective, { descendants: true }]
596
- }] } });