@tft/interact 12.5.0 → 13.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 (103) hide show
  1. package/esm2020/index.mjs +6 -0
  2. package/esm2020/lib/directives/account-for-scale.directive.mjs +26 -0
  3. package/esm2020/lib/directives/apply-scale.directive.mjs +28 -0
  4. package/esm2020/lib/directives/auto-scroll.directive.mjs +56 -0
  5. package/esm2020/lib/directives/drag-preview.directive.mjs +20 -0
  6. package/esm2020/lib/directives/drag-root.directive.mjs +32 -0
  7. package/esm2020/lib/directives/draggable.directive.mjs +320 -0
  8. package/esm2020/lib/directives/dropzone.directive.mjs +114 -0
  9. package/esm2020/lib/directives/gesturable.directive.mjs +82 -0
  10. package/esm2020/lib/directives/index.mjs +10 -0
  11. package/esm2020/lib/directives/resizable.directive.mjs +228 -0
  12. package/esm2020/lib/interact.module.mjs +66 -0
  13. package/esm2020/lib/models/index.mjs +2 -0
  14. package/esm2020/lib/models/interact.mjs +28 -0
  15. package/esm2020/lib/pipes/array-of-n.pipe.mjs +22 -0
  16. package/esm2020/lib/pipes/index.mjs +2 -0
  17. package/esm2020/lib/services/interact.service.mjs +197 -0
  18. package/esm2020/lib/utils/helpers.mjs +35 -0
  19. package/esm2020/lib/utils/index.mjs +2 -0
  20. package/esm2020/tft-interact.mjs +5 -0
  21. package/fesm2015/{tft-interact.js → tft-interact.mjs} +511 -289
  22. package/fesm2015/tft-interact.mjs.map +1 -0
  23. package/fesm2020/tft-interact.mjs +1192 -0
  24. package/fesm2020/tft-interact.mjs.map +1 -0
  25. package/lib/directives/account-for-scale.directive.d.ts +3 -0
  26. package/lib/directives/apply-scale.directive.d.ts +3 -0
  27. package/lib/directives/auto-scroll.directive.d.ts +34 -0
  28. package/lib/directives/drag-preview.directive.d.ts +3 -0
  29. package/lib/directives/drag-root.directive.d.ts +3 -0
  30. package/lib/directives/draggable.directive.d.ts +9 -1
  31. package/lib/directives/dropzone.directive.d.ts +6 -0
  32. package/lib/directives/gesturable.directive.d.ts +3 -0
  33. package/lib/directives/index.d.ts +1 -0
  34. package/lib/directives/resizable.directive.d.ts +13 -3
  35. package/lib/interact.module.d.ts +15 -0
  36. package/lib/models/interact.d.ts +4 -0
  37. package/lib/pipes/array-of-n.pipe.d.ts +3 -0
  38. package/lib/services/interact.service.d.ts +5 -2
  39. package/package.json +23 -10
  40. package/tft-interact-13.0.0.tgz +0 -0
  41. package/tft-interact.d.ts +1 -2
  42. package/bundles/tft-interact.umd.js +0 -1382
  43. package/bundles/tft-interact.umd.js.map +0 -1
  44. package/esm2015/index.js +0 -6
  45. package/esm2015/index.js.map +0 -1
  46. package/esm2015/index.metadata.json +0 -1
  47. package/esm2015/lib/directives/account-for-scale.directive.js +0 -26
  48. package/esm2015/lib/directives/account-for-scale.directive.js.map +0 -1
  49. package/esm2015/lib/directives/account-for-scale.directive.metadata.json +0 -1
  50. package/esm2015/lib/directives/apply-scale.directive.js +0 -26
  51. package/esm2015/lib/directives/apply-scale.directive.js.map +0 -1
  52. package/esm2015/lib/directives/apply-scale.directive.metadata.json +0 -1
  53. package/esm2015/lib/directives/drag-preview.directive.js +0 -20
  54. package/esm2015/lib/directives/drag-preview.directive.js.map +0 -1
  55. package/esm2015/lib/directives/drag-preview.directive.metadata.json +0 -1
  56. package/esm2015/lib/directives/drag-root.directive.js +0 -27
  57. package/esm2015/lib/directives/drag-root.directive.js.map +0 -1
  58. package/esm2015/lib/directives/drag-root.directive.metadata.json +0 -1
  59. package/esm2015/lib/directives/draggable.directive.js +0 -255
  60. package/esm2015/lib/directives/draggable.directive.js.map +0 -1
  61. package/esm2015/lib/directives/draggable.directive.metadata.json +0 -1
  62. package/esm2015/lib/directives/dropzone.directive.js +0 -99
  63. package/esm2015/lib/directives/dropzone.directive.js.map +0 -1
  64. package/esm2015/lib/directives/dropzone.directive.metadata.json +0 -1
  65. package/esm2015/lib/directives/gesturable.directive.js +0 -77
  66. package/esm2015/lib/directives/gesturable.directive.js.map +0 -1
  67. package/esm2015/lib/directives/gesturable.directive.metadata.json +0 -1
  68. package/esm2015/lib/directives/index.js +0 -9
  69. package/esm2015/lib/directives/index.js.map +0 -1
  70. package/esm2015/lib/directives/index.metadata.json +0 -1
  71. package/esm2015/lib/directives/resizable.directive.js +0 -152
  72. package/esm2015/lib/directives/resizable.directive.js.map +0 -1
  73. package/esm2015/lib/directives/resizable.directive.metadata.json +0 -1
  74. package/esm2015/lib/interact.module.js +0 -42
  75. package/esm2015/lib/interact.module.js.map +0 -1
  76. package/esm2015/lib/interact.module.metadata.json +0 -1
  77. package/esm2015/lib/models/index.js +0 -2
  78. package/esm2015/lib/models/index.js.map +0 -1
  79. package/esm2015/lib/models/index.metadata.json +0 -1
  80. package/esm2015/lib/models/interact.js +0 -28
  81. package/esm2015/lib/models/interact.js.map +0 -1
  82. package/esm2015/lib/models/interact.metadata.json +0 -1
  83. package/esm2015/lib/pipes/array-of-n.pipe.js +0 -18
  84. package/esm2015/lib/pipes/array-of-n.pipe.js.map +0 -1
  85. package/esm2015/lib/pipes/array-of-n.pipe.metadata.json +0 -1
  86. package/esm2015/lib/pipes/index.js +0 -2
  87. package/esm2015/lib/pipes/index.js.map +0 -1
  88. package/esm2015/lib/pipes/index.metadata.json +0 -1
  89. package/esm2015/lib/services/interact.service.js +0 -208
  90. package/esm2015/lib/services/interact.service.js.map +0 -1
  91. package/esm2015/lib/services/interact.service.metadata.json +0 -1
  92. package/esm2015/lib/utils/helpers.js +0 -35
  93. package/esm2015/lib/utils/helpers.js.map +0 -1
  94. package/esm2015/lib/utils/helpers.metadata.json +0 -1
  95. package/esm2015/lib/utils/index.js +0 -2
  96. package/esm2015/lib/utils/index.js.map +0 -1
  97. package/esm2015/lib/utils/index.metadata.json +0 -1
  98. package/esm2015/tft-interact.js +0 -7
  99. package/esm2015/tft-interact.js.map +0 -1
  100. package/esm2015/tft-interact.metadata.json +0 -1
  101. package/fesm2015/tft-interact.js.map +0 -1
  102. package/tft-interact-12.5.0.tgz +0 -0
  103. package/tft-interact.metadata.json +0 -1
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Pipe, InjectionToken, Injectable, RendererFactory2, NgZone, Optional, Inject, Directive, ElementRef, Input, EventEmitter, Renderer2, Output, TemplateRef, Self, ViewContainerRef, SkipSelf, ContentChild, HostBinding, NgModule } from '@angular/core';
2
+ import { Pipe, InjectionToken, Directive, Input, Injectable, Optional, Inject, EventEmitter, HostBinding, Output, Self, HostListener, SkipSelf, ContentChild, NgModule } from '@angular/core';
3
3
  import { DOCUMENT, CommonModule } from '@angular/common';
4
4
  import interact from 'interactjs';
5
- import { BehaviorSubject, combineLatest } from 'rxjs';
6
- import { shareReplay, tap, map } from 'rxjs/operators';
5
+ import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
6
+ import { shareReplay, tap, map, scan } from 'rxjs/operators';
7
7
 
8
8
  class ArrayOfNPipe {
9
9
  /**
@@ -16,11 +16,14 @@ class ArrayOfNPipe {
16
16
  return new Array(length).fill(length).map((x, i) => i);
17
17
  }
18
18
  }
19
- ArrayOfNPipe.decorators = [
20
- { type: Pipe, args: [{
21
- name: 'arrayOfN'
22
- },] }
23
- ];
19
+ ArrayOfNPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ArrayOfNPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
20
+ ArrayOfNPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ArrayOfNPipe, name: "arrayOfN" });
21
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ArrayOfNPipe, decorators: [{
22
+ type: Pipe,
23
+ args: [{
24
+ name: 'arrayOfN'
25
+ }]
26
+ }] });
24
27
 
25
28
  const INTERACT_ROOT_CONFIG = new InjectionToken('INTERACT_ROOT_CONFIG_PARAMS');
26
29
  const DEFAULT_REGISTRY_ID = 'DEFAULT';
@@ -49,6 +52,59 @@ const defaultPosition = {
49
52
  targetElement: null
50
53
  };
51
54
 
55
+ const TFT_DRAG_PREVIEW = new InjectionToken('DragPreviewDirective');
56
+ class DragPreviewDirective {
57
+ constructor(templateRef) {
58
+ this.templateRef = templateRef;
59
+ }
60
+ }
61
+ DragPreviewDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DragPreviewDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
62
+ DragPreviewDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: DragPreviewDirective, selector: "ng-template[tftDragPreview]", inputs: { dragData: "dragData" }, ngImport: i0 });
63
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DragPreviewDirective, decorators: [{
64
+ type: Directive,
65
+ args: [{
66
+ // eslint-disable-next-line @angular-eslint/directive-selector
67
+ selector: 'ng-template[tftDragPreview]',
68
+ }]
69
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { dragData: [{
70
+ type: Input
71
+ }] } });
72
+
73
+ /** Gets the closest ancestor of an element that matches a selector. */
74
+ function getClosestMatchingAncestor(element, selector) {
75
+ let currentElement = element.parentElement;
76
+ while (currentElement) {
77
+ // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
78
+ if (currentElement.matches ? currentElement.matches(selector) :
79
+ currentElement.msMatchesSelector(selector)) {
80
+ return currentElement;
81
+ }
82
+ currentElement = currentElement.parentElement;
83
+ }
84
+ return null;
85
+ }
86
+ /**
87
+ * Create a copy of the HTML Element
88
+ */
89
+ function cloneElement$1(element) {
90
+ const clone = element.cloneNode(true);
91
+ clone.removeAttribute('id');
92
+ return clone;
93
+ }
94
+ /**
95
+ * Gets the root HTML element of an embedded view.
96
+ * If the root is not an HTML element it gets wrapped in one.
97
+ */
98
+ function getRootNode(viewRef, _document) {
99
+ const rootNodes = viewRef.rootNodes;
100
+ if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
101
+ return rootNodes[0];
102
+ }
103
+ const wrapper = _document.createElement('div');
104
+ rootNodes.forEach(node => wrapper.appendChild(node));
105
+ return wrapper;
106
+ }
107
+
52
108
  class InteractService {
53
109
  constructor(rendererFactory, ngZone, rootConfig) {
54
110
  this.rendererFactory = rendererFactory;
@@ -77,7 +133,7 @@ class InteractService {
77
133
  addDraggableToRegistry(customRegistryId = null, interactableId = null) {
78
134
  const registryId = customRegistryId || DEFAULT_REGISTRY_ID;
79
135
  // if we pass an id to createInteractableId then it is used when creating the interactable
80
- // and returned, otherwise a an id is created for the draggable.
136
+ // and returned, otherwise a new id is created for the draggable.
81
137
  const key = this.createInteractableId(interactableId);
82
138
  if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {
83
139
  this.dragRegistrySystem[registryId] = {};
@@ -86,7 +142,16 @@ class InteractService {
86
142
  return key;
87
143
  }
88
144
  destroyInteractable(interactableId, registryId = DEFAULT_REGISTRY_ID) {
89
- if (this.dragRegistrySystem[registryId][interactableId]) {
145
+ const interactableSystem = this.dragRegistrySystem[registryId][interactableId];
146
+ if (interactableSystem) {
147
+ // unsubscribe from all the subscriptions if they're subscriptions
148
+ for (const propName in interactableSystem) {
149
+ const prop = interactableSystem[propName];
150
+ if (prop.unsubscribe && typeof prop.unsubscribe === 'function') {
151
+ prop.unsubscribe();
152
+ }
153
+ ;
154
+ }
90
155
  delete this.dragRegistrySystem[registryId][interactableId];
91
156
  }
92
157
  }
@@ -178,21 +243,10 @@ class InteractService {
178
243
  * @param target the element to transform
179
244
  */
180
245
  setElementSize(width, height, target) {
181
- var _a;
182
246
  if (!target)
183
247
  return;
184
- const accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
185
- if (accountForScaleDirective) {
186
- const { scale } = accountForScaleDirective;
187
- const scaledWidth = width / scale;
188
- const scaledHeight = height / scale;
189
- this.renderer.setStyle(target, 'width', `${scaledWidth}${this.cssUnit}`);
190
- this.renderer.setStyle(target, 'height', `${scaledHeight}${this.cssUnit}`);
191
- }
192
- else {
193
- this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);
194
- this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);
195
- }
248
+ this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);
249
+ this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);
196
250
  }
197
251
  /**
198
252
  * Uses renderer to set position of angular component
@@ -201,20 +255,10 @@ class InteractService {
201
255
  * @param target the element to transform
202
256
  */
203
257
  setElementTransform(x, y, position) {
204
- var _a, _b;
205
258
  if (!(position === null || position === void 0 ? void 0 : position.targetElement))
206
259
  return;
207
- const dragRef = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef;
208
- const accountForScaleDirective = (dragRef === null || dragRef === void 0 ? void 0 : dragRef.account_for_scale_dir) || ((_b = dragRef === null || dragRef === void 0 ? void 0 : dragRef.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir);
209
- if (accountForScaleDirective) {
210
- const { scale } = accountForScaleDirective;
211
- this.renderer.setStyle(position.targetElement, 'left', `${x / scale}${this.cssUnit}`);
212
- this.renderer.setStyle(position.targetElement, 'top', `${y / scale}${this.cssUnit}`);
213
- }
214
- else {
215
- this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);
216
- this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);
217
- }
260
+ this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);
261
+ this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);
218
262
  }
219
263
  /**
220
264
  * Generates a translate string for the x and y arguments passed to
@@ -241,15 +285,19 @@ class InteractService {
241
285
  return position;
242
286
  }
243
287
  }
244
- InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(INTERACT_ROOT_CONFIG, 8)); }, token: InteractService, providedIn: "root" });
245
- InteractService.decorators = [
246
- { type: Injectable, args: [{ providedIn: 'root' },] }
247
- ];
248
- InteractService.ctorParameters = () => [
249
- { type: RendererFactory2 },
250
- { type: NgZone },
251
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INTERACT_ROOT_CONFIG,] }] }
252
- ];
288
+ InteractService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractService, deps: [{ token: i0.RendererFactory2 }, { token: i0.NgZone }, { token: INTERACT_ROOT_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
289
+ InteractService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractService, providedIn: 'root' });
290
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractService, decorators: [{
291
+ type: Injectable,
292
+ args: [{ providedIn: 'root' }]
293
+ }], ctorParameters: function () {
294
+ return [{ type: i0.RendererFactory2 }, { type: i0.NgZone }, { type: undefined, decorators: [{
295
+ type: Optional
296
+ }, {
297
+ type: Inject,
298
+ args: [INTERACT_ROOT_CONFIG]
299
+ }] }];
300
+ } });
253
301
 
254
302
  /**
255
303
  * Use to apply scale to the element and tell the drag and resize directives to account for the scale when
@@ -264,17 +312,16 @@ class AccountForScaleDirective {
264
312
  this.scale = 1;
265
313
  }
266
314
  }
267
- AccountForScaleDirective.decorators = [
268
- { type: Directive, args: [{
269
- selector: '[tftAccountForScale]'
270
- },] }
271
- ];
272
- AccountForScaleDirective.ctorParameters = () => [
273
- { type: ElementRef }
274
- ];
275
- AccountForScaleDirective.propDecorators = {
276
- scale: [{ type: Input }]
277
- };
315
+ AccountForScaleDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AccountForScaleDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
316
+ AccountForScaleDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: AccountForScaleDirective, selector: "[tftAccountForScale]", inputs: { scale: "scale" }, ngImport: i0 });
317
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AccountForScaleDirective, decorators: [{
318
+ type: Directive,
319
+ args: [{
320
+ selector: '[tftAccountForScale]'
321
+ }]
322
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { scale: [{
323
+ type: Input
324
+ }] } });
278
325
 
279
326
  class DropzoneDirective {
280
327
  constructor(el, renderer, interactService, account_for_scale_dir) {
@@ -283,12 +330,17 @@ class DropzoneDirective {
283
330
  this.interactService = interactService;
284
331
  this.account_for_scale_dir = account_for_scale_dir;
285
332
  this.dropzoneConfig = {};
333
+ this.position = 'relative';
286
334
  // proxies to pass interact events through to consumer of directive
287
335
  this.dropActivate = new EventEmitter();
288
336
  this.dragEnter = new EventEmitter();
289
337
  this.dragLeave = new EventEmitter();
290
338
  this.dragDrop = new EventEmitter();
291
339
  }
340
+ get scale() {
341
+ var _a;
342
+ return (_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale;
343
+ }
292
344
  ngOnInit() {
293
345
  // connects
294
346
  this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
@@ -331,10 +383,10 @@ class DropzoneDirective {
331
383
  * @param event the drop event emitted by interact, extended with extra fields we added to
332
384
  */
333
385
  mapDropzoneEvent(event) {
334
- var _a, _b, _c;
386
+ var _a, _b;
335
387
  const zoneElement = event.target;
336
388
  const dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
337
- const scale = ((_c = this.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || null;
389
+ const scale = this.scale;
338
390
  const positionInDropTarget = zoneElement && dragElement
339
391
  ? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
340
392
  : null;
@@ -347,83 +399,40 @@ class DropzoneDirective {
347
399
  };
348
400
  }
349
401
  }
350
- DropzoneDirective.decorators = [
351
- { type: Directive, args: [{
352
- selector: '[tftDropzone]',
353
- host: {
354
- '[id]': 'dropzoneId',
355
- }
356
- },] }
357
- ];
358
- DropzoneDirective.ctorParameters = () => [
359
- { type: ElementRef },
360
- { type: Renderer2 },
361
- { type: InteractService },
362
- { type: AccountForScaleDirective, decorators: [{ type: Optional }] }
363
- ];
364
- DropzoneDirective.propDecorators = {
365
- dropzoneId: [{ type: Input }],
366
- dropzoneConfig: [{ type: Input }],
367
- dropzoneData: [{ type: Input }],
368
- dropActivate: [{ type: Output }],
369
- dragEnter: [{ type: Output }],
370
- dragLeave: [{ type: Output }],
371
- dragDrop: [{ type: Output }]
372
- };
373
-
374
- const TFT_DRAG_PREVIEW = new InjectionToken('DragPreviewDirective');
375
- class DragPreviewDirective {
376
- constructor(templateRef) {
377
- this.templateRef = templateRef;
378
- }
379
- }
380
- DragPreviewDirective.decorators = [
381
- { type: Directive, args: [{
382
- // eslint-disable-next-line @angular-eslint/directive-selector
383
- selector: 'ng-template[tftDragPreview]',
384
- },] }
385
- ];
386
- DragPreviewDirective.ctorParameters = () => [
387
- { type: TemplateRef }
388
- ];
389
- DragPreviewDirective.propDecorators = {
390
- dragData: [{ type: Input }]
391
- };
392
-
393
- /** Gets the closest ancestor of an element that matches a selector. */
394
- function getClosestMatchingAncestor(element, selector) {
395
- let currentElement = element.parentElement;
396
- while (currentElement) {
397
- // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
398
- if (currentElement.matches ? currentElement.matches(selector) :
399
- currentElement.msMatchesSelector(selector)) {
400
- return currentElement;
401
- }
402
- currentElement = currentElement.parentElement;
403
- }
404
- return null;
405
- }
406
- /**
407
- * Create a copy of the HTML Element
408
- */
409
- function cloneElement$1(element) {
410
- const clone = element.cloneNode(true);
411
- clone.removeAttribute('id');
412
- return clone;
413
- }
414
- /**
415
- * Gets the root HTML element of an embedded view.
416
- * If the root is not an HTML element it gets wrapped in one.
417
- */
418
- function getRootNode(viewRef, _document) {
419
- const rootNodes = viewRef.rootNodes;
420
- if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
421
- return rootNodes[0];
422
- }
423
- const wrapper = _document.createElement('div');
424
- rootNodes.forEach(node => wrapper.appendChild(node));
425
- return wrapper;
426
- }
402
+ DropzoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DropzoneDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: InteractService }, { token: AccountForScaleDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
403
+ DropzoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: DropzoneDirective, selector: "[tftDropzone]", inputs: { dropzoneId: "dropzoneId", dropzoneConfig: "dropzoneConfig", dropzoneData: "dropzoneData", position: "position" }, outputs: { dropActivate: "dropActivate", dragEnter: "dragEnter", dragLeave: "dragLeave", dragDrop: "dragDrop" }, host: { properties: { "id": "dropzoneId", "style.position": "this.position" } }, usesOnChanges: true, ngImport: i0 });
404
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DropzoneDirective, decorators: [{
405
+ type: Directive,
406
+ args: [{
407
+ selector: '[tftDropzone]',
408
+ host: {
409
+ '[id]': 'dropzoneId'
410
+ }
411
+ }]
412
+ }], ctorParameters: function () {
413
+ return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: InteractService }, { type: AccountForScaleDirective, decorators: [{
414
+ type: Optional
415
+ }] }];
416
+ }, propDecorators: { dropzoneId: [{
417
+ type: Input
418
+ }], dropzoneConfig: [{
419
+ type: Input
420
+ }], dropzoneData: [{
421
+ type: Input
422
+ }], position: [{
423
+ type: Input
424
+ }, {
425
+ type: HostBinding,
426
+ args: ['style.position']
427
+ }], dropActivate: [{
428
+ type: Output
429
+ }], dragEnter: [{
430
+ type: Output
431
+ }], dragLeave: [{
432
+ type: Output
433
+ }], dragDrop: [{
434
+ type: Output
435
+ }] } });
427
436
 
428
437
  /**
429
438
  * Use this directive to select which element to attach the element to while dragging
@@ -439,22 +448,78 @@ class DragRootDirective {
439
448
  this.account_for_scale_dir = account_for_scale_dir;
440
449
  }
441
450
  }
442
- DragRootDirective.decorators = [
443
- { type: Directive, args: [{
444
- selector: '[tftDragRoot]',
445
- exportAs: 'tftDragRoot'
446
- },] }
447
- ];
448
- DragRootDirective.ctorParameters = () => [
449
- { type: ElementRef },
450
- { type: AccountForScaleDirective, decorators: [{ type: Optional }, { type: Self }] }
451
- ];
451
+ DragRootDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DragRootDirective, deps: [{ token: i0.ElementRef }, { token: AccountForScaleDirective, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
452
+ DragRootDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: DragRootDirective, selector: "[tftDragRoot]", exportAs: ["tftDragRoot"], ngImport: i0 });
453
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DragRootDirective, decorators: [{
454
+ type: Directive,
455
+ args: [{
456
+ selector: '[tftDragRoot]',
457
+ exportAs: 'tftDragRoot'
458
+ }]
459
+ }], ctorParameters: function () {
460
+ return [{ type: i0.ElementRef }, { type: AccountForScaleDirective, decorators: [{
461
+ type: Optional
462
+ }, {
463
+ type: Self
464
+ }] }];
465
+ } });
466
+
467
+ ;
468
+ /**
469
+ * Use to apply scale to the element and tell the drag and resize directives to account for the scale when
470
+ * @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
471
+ * @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
472
+ * element accounts for scale
473
+ */
474
+ class AutoScrollDirective {
475
+ constructor(el) {
476
+ this.el = el;
477
+ /**
478
+ * Limit minimum time between scroll events in milliseconds
479
+ */
480
+ this.autoScrollConfig = {
481
+ margin: 50,
482
+ distance: 3,
483
+ interval: 50,
484
+ speed: 300,
485
+ enabled: true
486
+ };
487
+ this.scrollDeltaObserver = new Subject();
488
+ const { scrollTop, scrollLeft } = el.nativeElement;
489
+ this.scrollSubject = new BehaviorSubject({ scrollTop, scrollLeft });
490
+ this.scrollObserver = this.scrollSubject.pipe(scan((previous, current) => {
491
+ const scrollTop = current.scrollTop - previous.scrollTop;
492
+ const scrollLeft = current.scrollLeft - previous.scrollLeft;
493
+ this.scrollDeltaObserver.next({ scrollTop, scrollLeft });
494
+ return current;
495
+ }), shareReplay(1));
496
+ this.scrollObserver.subscribe();
497
+ }
498
+ // this setup allows consumers to set x, y scale independently or just set them both with scale
499
+ scroll(scrollEvent) {
500
+ const target = scrollEvent.target;
501
+ const { scrollTop, scrollLeft } = target;
502
+ this.scrollSubject.next({ scrollTop, scrollLeft });
503
+ }
504
+ }
505
+ AutoScrollDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AutoScrollDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
506
+ AutoScrollDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: AutoScrollDirective, selector: "[tftAutoScroll]", inputs: { autoScrollConfig: "autoScrollConfig" }, host: { listeners: { "scroll": "scroll($event)" } }, ngImport: i0 });
507
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AutoScrollDirective, decorators: [{
508
+ type: Directive,
509
+ args: [{
510
+ selector: '[tftAutoScroll]'
511
+ }]
512
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { autoScrollConfig: [{
513
+ type: Input
514
+ }], scroll: [{
515
+ type: HostListener,
516
+ args: ['scroll', ['$event']]
517
+ }] } });
452
518
 
453
519
  /** @dynamic */
454
520
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
455
521
  class DraggableDirective {
456
- // cache holding element to use as placeholder while dragging
457
- constructor(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
522
+ constructor(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir, auto_scroll_dir) {
458
523
  this.el = el;
459
524
  this.interactService = interactService;
460
525
  this.renderer = renderer;
@@ -463,6 +528,7 @@ class DraggableDirective {
463
528
  this.account_for_scale_dir = account_for_scale_dir;
464
529
  this.dropzone_dir = dropzone_dir;
465
530
  this.drag_root_dir = drag_root_dir;
531
+ this.auto_scroll_dir = auto_scroll_dir;
466
532
  /* zIndex while dragging*/
467
533
  this.dragZIndex = 10000;
468
534
  this.enableDragDefault = true;
@@ -478,6 +544,11 @@ class DraggableDirective {
478
544
  this.dragInertiaStart = new EventEmitter();
479
545
  this.dragEnd = new EventEmitter();
480
546
  }
547
+ // check all the different places for scale
548
+ get scale() {
549
+ var _a, _b, _c, _d, _e;
550
+ return ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = this.drag_root_dir) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || ((_e = (_d = this.dragRoot) === null || _d === void 0 ? void 0 : _d.account_for_scale_dir) === null || _e === void 0 ? void 0 : _e.scale) || 1;
551
+ }
481
552
  ngOnInit() {
482
553
  var _a, _b, _c, _d, _e;
483
554
  this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
@@ -535,7 +606,10 @@ class DraggableDirective {
535
606
  }
536
607
  dragMoveListener(event, element) {
537
608
  const { dx, dy } = event;
538
- this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: dx, deltaY: dy }, element);
609
+ const scale = this.scale;
610
+ const deltaX = scale ? dx / scale : dx;
611
+ const deltaY = scale ? dy / scale : dy;
612
+ this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, element);
539
613
  }
540
614
  setDragStyles(dragElement) {
541
615
  this.renderer.setStyle(dragElement, 'touchAction', 'none');
@@ -551,8 +625,9 @@ class DraggableDirective {
551
625
  var _a;
552
626
  const { target, dropzone } = event;
553
627
  const dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
628
+ const scale = this.scale;
554
629
  const positionInDropTarget = target && dropzoneElement
555
- ? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef)
630
+ ? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
556
631
  : null;
557
632
  return {
558
633
  interactEvent: event,
@@ -580,8 +655,12 @@ class DraggableDirective {
580
655
  return typeof num === 'number' && !isNaN(num);
581
656
  }
582
657
  initiateDragEvents(dragConfig, nativeElement) {
583
- return interact(nativeElement).draggable(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }))
658
+ const defaultDragConfig = Object.assign(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }), (this.auto_scroll_dir && {
659
+ autoScroll: Object.assign(Object.assign({}, this.auto_scroll_dir.autoScrollConfig), { container: this.auto_scroll_dir.el.nativeElement })
660
+ }));
661
+ return interact(nativeElement).draggable(defaultDragConfig)
584
662
  .on('dragstart', (event) => {
663
+ var _a, _b, _c;
585
664
  const interaction = event.interaction;
586
665
  // check if we should append drag element to body
587
666
  if (this.enableDragDefault
@@ -600,12 +679,17 @@ class DraggableDirective {
600
679
  this.addDragPropertiesToElement(this.previewRef);
601
680
  this.setDragStyles(this.previewRef);
602
681
  this.dragRootEl.prepend(this.previewRef);
603
- const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement);
682
+ const scale = ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = this.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || 1;
683
+ const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement, scale);
604
684
  this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.previewRef);
605
685
  if (!this.showPlaceholder) {
606
686
  this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
607
687
  }
608
688
  }
689
+ // subscribe to scroll events if they are there, by only subscribing on dragstart we avoid wasting subscriptions on interactables that aren't be dragged
690
+ if (this.auto_scroll_dir) {
691
+ this.subscribeToScrollEvents();
692
+ }
609
693
  this.dragStart.emit(this.mapDragEvent(event));
610
694
  })
611
695
  .on('dragmove', (event) => {
@@ -627,6 +711,10 @@ class DraggableDirective {
627
711
  }
628
712
  this.renderer.setStyle(this.el.nativeElement, 'display', '');
629
713
  this.dragEnd.emit(mappedEvent);
714
+ // unsubscribe from scroll events if subscribed
715
+ if (this.auto_scroll_dir) {
716
+ this.scrollEventsSubscription.unsubscribe();
717
+ }
630
718
  if (this.el.nativeElement !== this.previewRef) {
631
719
  // we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
632
720
  setTimeout(() => {
@@ -635,47 +723,82 @@ class DraggableDirective {
635
723
  }
636
724
  });
637
725
  }
726
+ subscribeToScrollEvents() {
727
+ this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(({ scrollLeft, scrollTop }) => {
728
+ const deltaX = this.scale ? scrollLeft / this.scale : scrollLeft;
729
+ const deltaY = this.scale ? scrollTop / this.scale : scrollTop;
730
+ this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, this.previewRef);
731
+ });
732
+ }
638
733
  }
639
- DraggableDirective.decorators = [
640
- { type: Directive, args: [{
641
- selector: '[tftDraggable]',
642
- // eslint-disable-next-line @angular-eslint/no-host-metadata-property
643
- host: {
644
- '[style.touchAction]': 'this.dragDisabled ? "auto" : "none"',
645
- '[style.position]': '"absolute"',
646
- '[id]': 'interactableId',
647
- }
648
- },] }
649
- ];
650
- DraggableDirective.ctorParameters = () => [
651
- { type: ElementRef },
652
- { type: InteractService },
653
- { type: Renderer2 },
654
- { type: ViewContainerRef },
655
- { type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
656
- { type: AccountForScaleDirective, decorators: [{ type: Optional }] },
657
- { type: DropzoneDirective, decorators: [{ type: Optional }, { type: SkipSelf }] },
658
- { type: DragRootDirective, decorators: [{ type: Optional }, { type: SkipSelf }] }
659
- ];
660
- DraggableDirective.propDecorators = {
661
- x: [{ type: Input }],
662
- y: [{ type: Input }],
663
- dragZIndex: [{ type: Input }],
664
- zIndex: [{ type: Input }],
665
- interactableId: [{ type: Input }],
666
- dragData: [{ type: Input }],
667
- enableDragDefault: [{ type: Input }],
668
- disabled: [{ type: Input }],
669
- dragDisabled: [{ type: Input }],
670
- dragConfig: [{ type: Input }],
671
- showPlaceholder: [{ type: Input }],
672
- dragRoot: [{ type: Input }],
673
- dragStart: [{ type: Output }],
674
- dragMove: [{ type: Output }],
675
- dragInertiaStart: [{ type: Output }],
676
- dragEnd: [{ type: Output }],
677
- _previewTemplate: [{ type: ContentChild, args: [DragPreviewDirective,] }]
678
- };
734
+ DraggableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DraggableDirective, deps: [{ token: i0.ElementRef }, { token: InteractService }, { token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: DOCUMENT }, { token: AccountForScaleDirective, optional: true }, { token: DropzoneDirective, optional: true, skipSelf: true }, { token: DragRootDirective, optional: true, skipSelf: true }, { token: AutoScrollDirective, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
735
+ DraggableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: DraggableDirective, selector: "[tftDraggable]", inputs: { x: "x", y: "y", dragZIndex: "dragZIndex", zIndex: "zIndex", interactableId: "interactableId", dragData: "dragData", enableDragDefault: "enableDragDefault", disabled: "disabled", dragDisabled: "dragDisabled", dragConfig: "dragConfig", showPlaceholder: "showPlaceholder", dragRoot: "dragRoot" }, outputs: { dragStart: "dragStart", dragMove: "dragMove", dragInertiaStart: "dragInertiaStart", dragEnd: "dragEnd" }, host: { properties: { "style.touchAction": "this.dragDisabled ? \"auto\" : \"none\"", "style.position": "\"absolute\"", "id": "interactableId" } }, queries: [{ propertyName: "_previewTemplate", first: true, predicate: DragPreviewDirective, descendants: true }], usesOnChanges: true, ngImport: i0 });
736
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DraggableDirective, decorators: [{
737
+ type: Directive,
738
+ args: [{
739
+ selector: '[tftDraggable]',
740
+ // eslint-disable-next-line @angular-eslint/no-host-metadata-property
741
+ host: {
742
+ '[style.touchAction]': 'this.dragDisabled ? "auto" : "none"',
743
+ '[style.position]': '"absolute"',
744
+ '[id]': 'interactableId',
745
+ }
746
+ }]
747
+ }], ctorParameters: function () {
748
+ return [{ type: i0.ElementRef }, { type: InteractService }, { type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: Document, decorators: [{
749
+ type: Inject,
750
+ args: [DOCUMENT]
751
+ }] }, { type: AccountForScaleDirective, decorators: [{
752
+ type: Optional
753
+ }] }, { type: DropzoneDirective, decorators: [{
754
+ type: Optional
755
+ }, {
756
+ type: SkipSelf
757
+ }] }, { type: DragRootDirective, decorators: [{
758
+ type: Optional
759
+ }, {
760
+ type: SkipSelf
761
+ }] }, { type: AutoScrollDirective, decorators: [{
762
+ type: Optional
763
+ }, {
764
+ type: SkipSelf
765
+ }] }];
766
+ }, propDecorators: { x: [{
767
+ type: Input
768
+ }], y: [{
769
+ type: Input
770
+ }], dragZIndex: [{
771
+ type: Input
772
+ }], zIndex: [{
773
+ type: Input
774
+ }], interactableId: [{
775
+ type: Input
776
+ }], dragData: [{
777
+ type: Input
778
+ }], enableDragDefault: [{
779
+ type: Input
780
+ }], disabled: [{
781
+ type: Input
782
+ }], dragDisabled: [{
783
+ type: Input
784
+ }], dragConfig: [{
785
+ type: Input
786
+ }], showPlaceholder: [{
787
+ type: Input
788
+ }], dragRoot: [{
789
+ type: Input
790
+ }], dragStart: [{
791
+ type: Output
792
+ }], dragMove: [{
793
+ type: Output
794
+ }], dragInertiaStart: [{
795
+ type: Output
796
+ }], dragEnd: [{
797
+ type: Output
798
+ }], _previewTemplate: [{
799
+ type: ContentChild,
800
+ args: [DragPreviewDirective]
801
+ }] } });
679
802
  /**
680
803
  * Component utils
681
804
  */
@@ -697,15 +820,17 @@ function getPreviewInsertionPoint(documentRef) {
697
820
 
698
821
  /** @dynamic */
699
822
  class ResizableDirective {
700
- constructor(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir) {
823
+ constructor(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir, auto_scroll_dir) {
701
824
  var _a;
702
825
  this.el = el;
703
826
  this._document = _document;
704
827
  this.interactService = interactService;
705
828
  this.renderer = renderer;
829
+ this.drag_root_dir = drag_root_dir;
706
830
  this.account_for_scale_dir = account_for_scale_dir;
707
831
  this.draggable_dir = draggable_dir;
708
832
  this.dropzone_dir = dropzone_dir;
833
+ this.auto_scroll_dir = auto_scroll_dir;
709
834
  this.enableResizeDefault = true;
710
835
  // TODO: should this be an input with default or should consuming user set display in styles each time
711
836
  this.position = 'absolute';
@@ -717,7 +842,12 @@ class ResizableDirective {
717
842
  this.defaultConfig = {
718
843
  edges: { left: true, right: true, bottom: true, top: true }
719
844
  };
720
- this.dragRoot = ((_a = drag_root_dir === null || drag_root_dir === void 0 ? void 0 : drag_root_dir.el) === null || _a === void 0 ? void 0 : _a.nativeElement) || this._document.body;
845
+ this.activeEdges = { left: false, right: false, top: false, bottom: false };
846
+ this.dragRootEl = ((_a = drag_root_dir === null || drag_root_dir === void 0 ? void 0 : drag_root_dir.el) === null || _a === void 0 ? void 0 : _a.nativeElement) || this._document.body;
847
+ }
848
+ get scale() {
849
+ var _a, _b, _c;
850
+ return ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = this.drag_root_dir) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale);
721
851
  }
722
852
  ngOnInit() {
723
853
  var _a, _b;
@@ -746,9 +876,16 @@ class ResizableDirective {
746
876
  this.interactService.destroyInteractable(this.interactableId, this.registryId);
747
877
  }
748
878
  resizeListener(event) {
749
- const deltaX = event.deltaRect.left;
750
- const deltaY = event.deltaRect.top;
751
- const { width, height } = event.rect;
879
+ const element = this.el.nativeElement;
880
+ const scale = this.scale;
881
+ const { deltaRect } = event;
882
+ const deltaX = deltaRect.left / scale;
883
+ const deltaY = deltaRect.top / scale;
884
+ // We get the width and height directly from the native element because
885
+ // the event dimension can get out of sync when resizing with autoScroll
886
+ const rect = element.getBoundingClientRect();
887
+ const width = (rect.width + deltaRect.width) / scale;
888
+ const height = (rect.height + deltaRect.height) / scale;
752
889
  this.interactService.updateSize(this.interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
753
890
  }
754
891
  /**
@@ -761,9 +898,18 @@ class ResizableDirective {
761
898
  initiateResizeEvents(resizeConfig, nativeElement) {
762
899
  var _a;
763
900
  // TODO: This should try and get interactable from tft_draggable if it exists
901
+ const defaultResizeConfig = Object.assign(Object.assign(Object.assign({}, resizeConfig), { enabled: !this.resizeDisabled }), (this.auto_scroll_dir && {
902
+ autoScroll: Object.assign(Object.assign({}, this.auto_scroll_dir.autoScrollConfig), { container: this.auto_scroll_dir.el.nativeElement })
903
+ }));
764
904
  const interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact(nativeElement);
765
- return interactable.resizable(Object.assign(Object.assign({}, resizeConfig), { enabled: !this.resizeDisabled }))
766
- .on('resizestart', (event) => { this.resizeStart.emit(this.mapResizeEvent(event)); })
905
+ return interactable.resizable(defaultResizeConfig)
906
+ .on('resizestart', (event) => {
907
+ this.activeEdges = event.edges;
908
+ if (this.auto_scroll_dir) {
909
+ this.subscribeToScrollEvents();
910
+ }
911
+ this.resizeStart.emit(this.mapResizeEvent(event));
912
+ })
767
913
  .on('resizemove', (event) => {
768
914
  if (this.enableResizeDefault) {
769
915
  this.resizeListener(event);
@@ -772,23 +918,33 @@ class ResizableDirective {
772
918
  this.resizeMove.emit(mappedEvent);
773
919
  })
774
920
  .on('resizeinertiastart', (event) => this.resizeInertiaStart.emit(this.mapResizeEvent(event)))
775
- .on('resizeend', (event) => this.resizeEnd.emit(this.mapResizeEvent(event)));
921
+ .on('resizeend', (event) => {
922
+ if (this.auto_scroll_dir) {
923
+ this.scrollEventsSubscription.unsubscribe();
924
+ }
925
+ this.activeEdges = { left: false, right: false, top: false, bottom: false };
926
+ this.resizeEnd.emit(this.mapResizeEvent(event));
927
+ });
776
928
  }
777
929
  mapResizeEvent(event) {
778
930
  var _a, _b;
779
- const target = event.target;
931
+ const target = this.el.nativeElement;
780
932
  const relatedTarget = (_b = (_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.dropzone_dir) === null || _b === void 0 ? void 0 : _b.el.nativeElement;
933
+ const scale = this.scale;
781
934
  const positionInDropTarget = target && relatedTarget
782
- ? this.interactService.calculatePositionInElement(relatedTarget, target)
935
+ ? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
783
936
  : null;
784
937
  return {
785
938
  interactEvent: event,
786
939
  resizeRef: this,
787
- // should I remove this?
788
940
  dragRef: this.draggable_dir,
789
941
  dragOrigin: this.dropzone_dir,
790
942
  dropTarget: this.el.nativeElement.dropTarget,
791
- positionInDropTarget
943
+ positionInDropTarget,
944
+ size: {
945
+ width: target.clientWidth / scale,
946
+ height: target.clientHeight / scale
947
+ }
792
948
  };
793
949
  }
794
950
  alignDimensionsWithInputs(width, height) {
@@ -797,46 +953,81 @@ class ResizableDirective {
797
953
  addResizePropertiesToElement(nativeElement) {
798
954
  this.renderer.setProperty(nativeElement, 'resizeRef', this);
799
955
  }
956
+ subscribeToScrollEvents() {
957
+ this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(({ scrollLeft, scrollTop }) => {
958
+ const scale = this.scale;
959
+ const target = this.el.nativeElement;
960
+ const { width: prevWidth, height: prevHeight } = target.getBoundingClientRect();
961
+ const deltaHeight = scrollTop * (this.activeEdges.top ? -1 : this.activeEdges.bottom ? 1 : 0);
962
+ const deltaWidth = scrollLeft * (this.activeEdges.left ? -1 : this.activeEdges.right ? 1 : 0);
963
+ const height = (prevHeight + deltaHeight) / scale;
964
+ const width = (prevWidth + deltaWidth) / scale;
965
+ const deltaX = this.activeEdges.left ? (scrollLeft / scale) : 0;
966
+ const deltaY = this.activeEdges.top ? (scrollTop / scale) : 0;
967
+ this.interactService.updateSize(this.interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
968
+ });
969
+ }
800
970
  }
801
- ResizableDirective.decorators = [
802
- { type: Directive, args: [{
803
- selector: '[tftResizable]',
804
- // eslint-disable-next-line @angular-eslint/no-host-metadata-property
805
- host: {
806
- // prevents touch events from colliding with with mouse events
807
- // on touch screen
808
- '[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
809
- // default to absolute here to accommodate likely use cases
810
- // consuming component can easily over ride with position input
811
- '[style.position]': 'position',
812
- // follows interactjs suggested practices
813
- '[style.boxSizing]': '"border-box"',
814
- }
815
- },] }
816
- ];
817
- ResizableDirective.ctorParameters = () => [
818
- { type: ElementRef },
819
- { type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
820
- { type: InteractService },
821
- { type: Renderer2 },
822
- { type: DragRootDirective, decorators: [{ type: Optional }] },
823
- { type: AccountForScaleDirective, decorators: [{ type: Optional }] },
824
- { type: DraggableDirective, decorators: [{ type: Optional }] },
825
- { type: DropzoneDirective, decorators: [{ type: Optional }, { type: SkipSelf }] }
826
- ];
827
- ResizableDirective.propDecorators = {
828
- enableResizeDefault: [{ type: Input }],
829
- position: [{ type: Input }],
830
- resizeConfig: [{ type: Input }],
831
- interactableId: [{ type: Input }],
832
- width: [{ type: Input }],
833
- height: [{ type: Input }],
834
- resizeDisabled: [{ type: Input }],
835
- resizeStart: [{ type: Output }],
836
- resizeMove: [{ type: Output }],
837
- resizeInertiaStart: [{ type: Output }],
838
- resizeEnd: [{ type: Output }]
839
- };
971
+ ResizableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ResizableDirective, deps: [{ token: i0.ElementRef }, { token: DOCUMENT }, { token: InteractService }, { token: i0.Renderer2 }, { token: DragRootDirective, optional: true }, { token: AccountForScaleDirective, optional: true }, { token: DraggableDirective, optional: true }, { token: DropzoneDirective, optional: true, skipSelf: true }, { token: AutoScrollDirective, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
972
+ ResizableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: ResizableDirective, selector: "[tftResizable]", inputs: { enableResizeDefault: "enableResizeDefault", position: "position", resizeConfig: "resizeConfig", interactableId: "interactableId", width: "width", height: "height", resizeDisabled: "resizeDisabled" }, outputs: { resizeStart: "resizeStart", resizeMove: "resizeMove", resizeInertiaStart: "resizeInertiaStart", resizeEnd: "resizeEnd" }, host: { properties: { "style.touchAction": "this.resizeDisabled ? \"auto\" : \"none\"", "style.position": "position", "style.boxSizing": "\"border-box\"" } }, usesOnChanges: true, ngImport: i0 });
973
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ResizableDirective, decorators: [{
974
+ type: Directive,
975
+ args: [{
976
+ selector: '[tftResizable]',
977
+ // eslint-disable-next-line @angular-eslint/no-host-metadata-property
978
+ host: {
979
+ // prevents touch events from colliding with with mouse events
980
+ // on touch screen
981
+ '[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
982
+ // default to absolute here to accommodate likely use cases
983
+ // consuming component can easily over ride with position input
984
+ '[style.position]': 'position',
985
+ // follows interactjs suggested practices
986
+ '[style.boxSizing]': '"border-box"',
987
+ }
988
+ }]
989
+ }], ctorParameters: function () {
990
+ return [{ type: i0.ElementRef }, { type: Document, decorators: [{
991
+ type: Inject,
992
+ args: [DOCUMENT]
993
+ }] }, { type: InteractService }, { type: i0.Renderer2 }, { type: DragRootDirective, decorators: [{
994
+ type: Optional
995
+ }] }, { type: AccountForScaleDirective, decorators: [{
996
+ type: Optional
997
+ }] }, { type: DraggableDirective, decorators: [{
998
+ type: Optional
999
+ }] }, { type: DropzoneDirective, decorators: [{
1000
+ type: Optional
1001
+ }, {
1002
+ type: SkipSelf
1003
+ }] }, { type: AutoScrollDirective, decorators: [{
1004
+ type: Optional
1005
+ }, {
1006
+ type: SkipSelf
1007
+ }] }];
1008
+ }, propDecorators: { enableResizeDefault: [{
1009
+ type: Input
1010
+ }], position: [{
1011
+ type: Input
1012
+ }], resizeConfig: [{
1013
+ type: Input
1014
+ }], interactableId: [{
1015
+ type: Input
1016
+ }], width: [{
1017
+ type: Input
1018
+ }], height: [{
1019
+ type: Input
1020
+ }], resizeDisabled: [{
1021
+ type: Input
1022
+ }], resizeStart: [{
1023
+ type: Output
1024
+ }], resizeMove: [{
1025
+ type: Output
1026
+ }], resizeInertiaStart: [{
1027
+ type: Output
1028
+ }], resizeEnd: [{
1029
+ type: Output
1030
+ }] } });
840
1031
 
841
1032
  /** @dynamic */
842
1033
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -889,28 +1080,35 @@ class GesturableDirective {
889
1080
  });
890
1081
  }
891
1082
  }
892
- GesturableDirective.decorators = [
893
- { type: Directive, args: [{
894
- selector: '[tftGesturable]',
895
- // eslint-disable-next-line @angular-eslint/no-host-metadata-property
896
- host: {
897
- // '[style.touchAction]': 'this.gestureDisabled ? "auto" : "none"',
898
- '[id]': 'gesturableId',
899
- }
900
- },] }
901
- ];
902
- GesturableDirective.ctorParameters = () => [
903
- { type: ElementRef },
904
- { type: DraggableDirective, decorators: [{ type: Optional }] }
905
- ];
906
- GesturableDirective.propDecorators = {
907
- gesturableId: [{ type: Input }],
908
- gestureDisabled: [{ type: Input }],
909
- gestureConfig: [{ type: Input }],
910
- gestureStart: [{ type: Output }],
911
- gestureMove: [{ type: Output }],
912
- gestureEnd: [{ type: Output }]
913
- };
1083
+ GesturableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: GesturableDirective, deps: [{ token: i0.ElementRef }, { token: DraggableDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1084
+ GesturableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: GesturableDirective, selector: "[tftGesturable]", inputs: { gesturableId: "gesturableId", gestureDisabled: "gestureDisabled", gestureConfig: "gestureConfig" }, outputs: { gestureStart: "gestureStart", gestureMove: "gestureMove", gestureEnd: "gestureEnd" }, host: { properties: { "id": "gesturableId" } }, usesOnChanges: true, ngImport: i0 });
1085
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: GesturableDirective, decorators: [{
1086
+ type: Directive,
1087
+ args: [{
1088
+ selector: '[tftGesturable]',
1089
+ // eslint-disable-next-line @angular-eslint/no-host-metadata-property
1090
+ host: {
1091
+ // '[style.touchAction]': 'this.gestureDisabled ? "auto" : "none"',
1092
+ '[id]': 'gesturableId',
1093
+ }
1094
+ }]
1095
+ }], ctorParameters: function () {
1096
+ return [{ type: i0.ElementRef }, { type: DraggableDirective, decorators: [{
1097
+ type: Optional
1098
+ }] }];
1099
+ }, propDecorators: { gesturableId: [{
1100
+ type: Input
1101
+ }], gestureDisabled: [{
1102
+ type: Input
1103
+ }], gestureConfig: [{
1104
+ type: Input
1105
+ }], gestureStart: [{
1106
+ type: Output
1107
+ }], gestureMove: [{
1108
+ type: Output
1109
+ }], gestureEnd: [{
1110
+ type: Output
1111
+ }] } });
914
1112
 
915
1113
  class ApplyScaleDirective {
916
1114
  constructor(el) {
@@ -924,18 +1122,19 @@ class ApplyScaleDirective {
924
1122
  }
925
1123
  ;
926
1124
  }
927
- ApplyScaleDirective.decorators = [
928
- { type: Directive, args: [{
929
- selector: '[tftApplyScale]'
930
- },] }
931
- ];
932
- ApplyScaleDirective.ctorParameters = () => [
933
- { type: ElementRef }
934
- ];
935
- ApplyScaleDirective.propDecorators = {
936
- scale: [{ type: Input }],
937
- fontSize: [{ type: HostBinding, args: ['style.fontSize',] }]
938
- };
1125
+ ApplyScaleDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ApplyScaleDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1126
+ ApplyScaleDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: ApplyScaleDirective, selector: "[tftApplyScale]", inputs: { scale: "scale" }, host: { properties: { "style.fontSize": "this.fontSize" } }, ngImport: i0 });
1127
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ApplyScaleDirective, decorators: [{
1128
+ type: Directive,
1129
+ args: [{
1130
+ selector: '[tftApplyScale]'
1131
+ }]
1132
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { scale: [{
1133
+ type: Input
1134
+ }], fontSize: [{
1135
+ type: HostBinding,
1136
+ args: ['style.fontSize']
1137
+ }] } });
939
1138
 
940
1139
  const EXPORTS = [
941
1140
  DraggableDirective,
@@ -943,6 +1142,7 @@ const EXPORTS = [
943
1142
  DropzoneDirective,
944
1143
  GesturableDirective,
945
1144
  DragRootDirective,
1145
+ AutoScrollDirective,
946
1146
  AccountForScaleDirective,
947
1147
  ApplyScaleDirective,
948
1148
  DragPreviewDirective,
@@ -960,22 +1160,44 @@ class InteractModule {
960
1160
  };
961
1161
  }
962
1162
  }
963
- InteractModule.decorators = [
964
- { type: NgModule, args: [{
965
- imports: [CommonModule],
966
- // providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
967
- declarations: [
968
- ...EXPORTS,
969
- ],
970
- exports: [
971
- ...EXPORTS
972
- ]
973
- },] }
974
- ];
1163
+ InteractModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1164
+ InteractModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractModule, declarations: [DraggableDirective,
1165
+ ResizableDirective,
1166
+ DropzoneDirective,
1167
+ GesturableDirective,
1168
+ DragRootDirective,
1169
+ AutoScrollDirective,
1170
+ AccountForScaleDirective,
1171
+ ApplyScaleDirective,
1172
+ DragPreviewDirective,
1173
+ ArrayOfNPipe], imports: [CommonModule], exports: [DraggableDirective,
1174
+ ResizableDirective,
1175
+ DropzoneDirective,
1176
+ GesturableDirective,
1177
+ DragRootDirective,
1178
+ AutoScrollDirective,
1179
+ AccountForScaleDirective,
1180
+ ApplyScaleDirective,
1181
+ DragPreviewDirective,
1182
+ ArrayOfNPipe] });
1183
+ InteractModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractModule, imports: [[CommonModule]] });
1184
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InteractModule, decorators: [{
1185
+ type: NgModule,
1186
+ args: [{
1187
+ imports: [CommonModule],
1188
+ // providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
1189
+ declarations: [
1190
+ ...EXPORTS,
1191
+ ],
1192
+ exports: [
1193
+ ...EXPORTS
1194
+ ]
1195
+ }]
1196
+ }] });
975
1197
 
976
1198
  /**
977
1199
  * Generated bundle index. Do not edit.
978
1200
  */
979
1201
 
980
- export { AccountForScaleDirective, ApplyScaleDirective, ArrayOfNPipe, DEFAULT_REGISTRY_ID, DragPreviewDirective, DragRootDirective, DraggableDirective, DropzoneDirective, GesturableDirective, INTERACT_ROOT_CONFIG, InteractModule, ResizableDirective, TFT_DRAG_PREVIEW, cloneElement$1 as cloneElement, defaultDelta, defaultPosition, defaultSize, getClosestMatchingAncestor, getRootNode, DraggableDirective as ɵa, ResizableDirective as ɵb, DropzoneDirective as ɵc, GesturableDirective as ɵd, DragRootDirective as ɵe, AccountForScaleDirective as ɵf, ApplyScaleDirective as ɵg, DragPreviewDirective as ɵh, ArrayOfNPipe as ɵi };
981
- //# sourceMappingURL=tft-interact.js.map
1202
+ export { AccountForScaleDirective, ApplyScaleDirective, ArrayOfNPipe, AutoScrollDirective, DEFAULT_REGISTRY_ID, DragPreviewDirective, DragRootDirective, DraggableDirective, DropzoneDirective, GesturableDirective, INTERACT_ROOT_CONFIG, InteractModule, ResizableDirective, TFT_DRAG_PREVIEW, cloneElement$1 as cloneElement, defaultDelta, defaultPosition, defaultSize, getClosestMatchingAncestor, getRootNode };
1203
+ //# sourceMappingURL=tft-interact.mjs.map