@tft/interact 21.0.7 → 21.1.2
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/README.md +317 -22
- package/fesm2022/tft-interact.mjs +244 -390
- package/fesm2022/tft-interact.mjs.map +1 -1
- package/package.json +1 -1
- package/types/tft-interact.d.ts +112 -116
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe, InjectionToken, inject, RendererFactory2, NgZone, Injectable, ElementRef,
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { Pipe, InjectionToken, inject, RendererFactory2, NgZone, Injectable, ElementRef, input, Directive, Renderer2, output, signal, computed, effect, TemplateRef, HostListener, ViewContainerRef, DOCUMENT, ContentChild, NgModule } from '@angular/core';
|
|
4
3
|
import interact from 'interactjs';
|
|
5
4
|
import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
|
|
6
5
|
import { shareReplay, tap, map, scan } from 'rxjs/operators';
|
|
@@ -16,13 +15,13 @@ class ArrayOfNPipe {
|
|
|
16
15
|
return new Array(length).fill(length).map((x, i) => i);
|
|
17
16
|
}
|
|
18
17
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ArrayOfNPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
19
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.6", ngImport: i0, type: ArrayOfNPipe, isStandalone:
|
|
18
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.6", ngImport: i0, type: ArrayOfNPipe, isStandalone: true, name: "arrayOfN" }); }
|
|
20
19
|
}
|
|
21
20
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ArrayOfNPipe, decorators: [{
|
|
22
21
|
type: Pipe,
|
|
23
22
|
args: [{
|
|
24
23
|
name: 'arrayOfN',
|
|
25
|
-
standalone:
|
|
24
|
+
standalone: true,
|
|
26
25
|
}]
|
|
27
26
|
}] });
|
|
28
27
|
|
|
@@ -250,59 +249,53 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
250
249
|
class AccountForScaleDirective {
|
|
251
250
|
constructor() {
|
|
252
251
|
this.el = inject(ElementRef);
|
|
253
|
-
|
|
254
|
-
this.scale = 1;
|
|
252
|
+
this.scale = input(1, ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
255
253
|
}
|
|
256
254
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AccountForScaleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
257
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
255
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: AccountForScaleDirective, isStandalone: true, selector: "[tftAccountForScale]", inputs: { scale: { classPropertyName: "scale", publicName: "scale", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
258
256
|
}
|
|
259
257
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AccountForScaleDirective, decorators: [{
|
|
260
258
|
type: Directive,
|
|
261
259
|
args: [{
|
|
262
260
|
selector: '[tftAccountForScale]',
|
|
263
|
-
standalone:
|
|
261
|
+
standalone: true,
|
|
264
262
|
}]
|
|
265
|
-
}], propDecorators: { scale: [{
|
|
266
|
-
type: Input
|
|
267
|
-
}] } });
|
|
263
|
+
}], propDecorators: { scale: [{ type: i0.Input, args: [{ isSignal: true, alias: "scale", required: false }] }] } });
|
|
268
264
|
|
|
269
265
|
class DropzoneDirective {
|
|
266
|
+
ngOnInit() {
|
|
267
|
+
this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig());
|
|
268
|
+
this._registeredId.set(this.interactService.addRegistryToSystem(this.dropzoneId()));
|
|
269
|
+
}
|
|
270
270
|
constructor() {
|
|
271
271
|
this.el = inject(ElementRef);
|
|
272
272
|
this.renderer = inject(Renderer2);
|
|
273
273
|
this.interactService = inject(InteractService);
|
|
274
274
|
this.account_for_scale_dir = inject(AccountForScaleDirective, { optional: true });
|
|
275
|
-
this.
|
|
276
|
-
this.
|
|
277
|
-
//
|
|
278
|
-
this.
|
|
279
|
-
this.
|
|
280
|
-
this.
|
|
281
|
-
this.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return;
|
|
294
|
-
// this.dropzone.unset();
|
|
295
|
-
// this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig)
|
|
296
|
-
this.dropzone.dropzone(this.dropzoneConfig);
|
|
275
|
+
this.dropzoneId = input(...(ngDevMode ? [undefined, { debugName: "dropzoneId" }] : []));
|
|
276
|
+
this.dropzoneConfig = input({}, ...(ngDevMode ? [{ debugName: "dropzoneConfig" }] : []));
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
+
this.dropzoneData = input(...(ngDevMode ? [undefined, { debugName: "dropzoneData" }] : []));
|
|
279
|
+
this.position = input('relative', ...(ngDevMode ? [{ debugName: "position" }] : []));
|
|
280
|
+
this.dropActivate = output();
|
|
281
|
+
this.dragEnter = output();
|
|
282
|
+
this.dragLeave = output();
|
|
283
|
+
this.dragDrop = output();
|
|
284
|
+
/** The actual registered ID — may differ from the dropzoneId input if none was provided. Drives [id] host binding. */
|
|
285
|
+
this._registeredId = signal(null, ...(ngDevMode ? [{ debugName: "_registeredId" }] : []));
|
|
286
|
+
this.scale = computed(() => this.account_for_scale_dir?.scale(), ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
287
|
+
effect(() => {
|
|
288
|
+
const config = this.dropzoneConfig();
|
|
289
|
+
if (!this.dropzone)
|
|
290
|
+
return;
|
|
291
|
+
this.dropzone.dropzone(config);
|
|
292
|
+
});
|
|
297
293
|
}
|
|
298
294
|
/**
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
* @param dropzoneConfig the interact configuration to use when connecting
|
|
302
|
-
*/
|
|
295
|
+
* Connects element to interact's dropzone events and returns a reference to the interactable
|
|
296
|
+
*/
|
|
303
297
|
connectDropzoneEvents(nativeElement, dropzoneConfig) {
|
|
304
298
|
return interact(nativeElement).dropzone(dropzoneConfig)
|
|
305
|
-
// TODO: investigate when this fires in different scenarios
|
|
306
299
|
.on('dropactivate', (event) => {
|
|
307
300
|
this.dropActivate.emit(this.mapDropzoneEvent(event));
|
|
308
301
|
})
|
|
@@ -322,12 +315,11 @@ class DropzoneDirective {
|
|
|
322
315
|
}
|
|
323
316
|
/**
|
|
324
317
|
* Maps the drop event emitted by interact to something a little easier to use
|
|
325
|
-
* @param event the drop event emitted by interact, extended with extra fields we added to
|
|
326
318
|
*/
|
|
327
319
|
mapDropzoneEvent(event) {
|
|
328
320
|
const zoneElement = event.target;
|
|
329
321
|
const dragElement = event.relatedTarget?.dragRef?.previewRef;
|
|
330
|
-
const scale = this.scale;
|
|
322
|
+
const scale = this.scale();
|
|
331
323
|
const positionInDropTarget = zoneElement && dragElement
|
|
332
324
|
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
333
325
|
: null;
|
|
@@ -336,60 +328,41 @@ class DropzoneDirective {
|
|
|
336
328
|
dragRef: dragElement.dragRef,
|
|
337
329
|
dragOrigin: dragElement.dragOrigin,
|
|
338
330
|
dropTarget: event.relatedTarget.dropTarget,
|
|
339
|
-
positionInDropTarget
|
|
331
|
+
positionInDropTarget,
|
|
340
332
|
};
|
|
341
333
|
}
|
|
342
334
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DropzoneDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
343
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
335
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: DropzoneDirective, isStandalone: true, selector: "[tftDropzone]", inputs: { dropzoneId: { classPropertyName: "dropzoneId", publicName: "dropzoneId", isSignal: true, isRequired: false, transformFunction: null }, dropzoneConfig: { classPropertyName: "dropzoneConfig", publicName: "dropzoneConfig", isSignal: true, isRequired: false, transformFunction: null }, dropzoneData: { classPropertyName: "dropzoneData", publicName: "dropzoneData", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dropActivate: "dropActivate", dragEnter: "dragEnter", dragLeave: "dragLeave", dragDrop: "dragDrop" }, host: { properties: { "id": "_registeredId()", "style.position": "position()" } }, ngImport: i0 }); }
|
|
344
336
|
}
|
|
345
337
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DropzoneDirective, decorators: [{
|
|
346
338
|
type: Directive,
|
|
347
339
|
args: [{
|
|
348
340
|
selector: '[tftDropzone]',
|
|
341
|
+
standalone: true,
|
|
349
342
|
host: {
|
|
350
|
-
'[id]': '
|
|
343
|
+
'[id]': '_registeredId()',
|
|
344
|
+
'[style.position]': 'position()',
|
|
351
345
|
},
|
|
352
|
-
standalone: false
|
|
353
346
|
}]
|
|
354
|
-
}], propDecorators: { dropzoneId: [{
|
|
355
|
-
type: Input
|
|
356
|
-
}], dropzoneConfig: [{
|
|
357
|
-
type: Input
|
|
358
|
-
}], dropzoneData: [{
|
|
359
|
-
type: Input
|
|
360
|
-
}], position: [{
|
|
361
|
-
type: Input
|
|
362
|
-
}, {
|
|
363
|
-
type: HostBinding,
|
|
364
|
-
args: ['style.position']
|
|
365
|
-
}], dropActivate: [{
|
|
366
|
-
type: Output
|
|
367
|
-
}], dragEnter: [{
|
|
368
|
-
type: Output
|
|
369
|
-
}], dragLeave: [{
|
|
370
|
-
type: Output
|
|
371
|
-
}], dragDrop: [{
|
|
372
|
-
type: Output
|
|
373
|
-
}] } });
|
|
347
|
+
}], ctorParameters: () => [], propDecorators: { dropzoneId: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropzoneId", required: false }] }], dropzoneConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropzoneConfig", required: false }] }], dropzoneData: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropzoneData", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], dropActivate: [{ type: i0.Output, args: ["dropActivate"] }], dragEnter: [{ type: i0.Output, args: ["dragEnter"] }], dragLeave: [{ type: i0.Output, args: ["dragLeave"] }], dragDrop: [{ type: i0.Output, args: ["dragDrop"] }] } });
|
|
374
348
|
|
|
375
349
|
const TFT_DRAG_PREVIEW = new InjectionToken('DragPreviewDirective');
|
|
376
350
|
class DragPreviewDirective {
|
|
377
351
|
constructor() {
|
|
378
352
|
this.templateRef = inject(TemplateRef);
|
|
353
|
+
this.dragData = input(...(ngDevMode ? [undefined, { debugName: "dragData" }] : []));
|
|
379
354
|
}
|
|
380
355
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DragPreviewDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
381
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
356
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: DragPreviewDirective, isStandalone: true, selector: "ng-template[tftDragPreview]", inputs: { dragData: { classPropertyName: "dragData", publicName: "dragData", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
382
357
|
}
|
|
383
358
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DragPreviewDirective, decorators: [{
|
|
384
359
|
type: Directive,
|
|
385
360
|
args: [{
|
|
386
361
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
387
362
|
selector: 'ng-template[tftDragPreview]',
|
|
388
|
-
standalone:
|
|
363
|
+
standalone: true,
|
|
389
364
|
}]
|
|
390
|
-
}], propDecorators: { dragData: [{
|
|
391
|
-
type: Input
|
|
392
|
-
}] } });
|
|
365
|
+
}], propDecorators: { dragData: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragData", required: false }] }] } });
|
|
393
366
|
|
|
394
367
|
/** Gets the closest ancestor of an element that matches a selector. */
|
|
395
368
|
function getClosestMatchingAncestor(element, selector) {
|
|
@@ -437,28 +410,38 @@ class DragRootDirective {
|
|
|
437
410
|
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
438
411
|
// It allows the the interact service to check if the drag root has some scaling applied to it and account for it when the component is dragged
|
|
439
412
|
this.account_for_scale_dir = inject(AccountForScaleDirective, { optional: true, self: true });
|
|
413
|
+
this._suppressNextClick = false;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Called by DraggableDirective on dragend to suppress the spurious click that
|
|
417
|
+
* fires when the drag clone (appended as a direct child of this element) receives
|
|
418
|
+
* the pointerup and bubbles a click event up to this element.
|
|
419
|
+
*/
|
|
420
|
+
suppressNextClick() {
|
|
421
|
+
this._suppressNextClick = true;
|
|
422
|
+
}
|
|
423
|
+
onRootClick(event) {
|
|
424
|
+
if (this._suppressNextClick) {
|
|
425
|
+
this._suppressNextClick = false;
|
|
426
|
+
event.stopImmediatePropagation();
|
|
427
|
+
}
|
|
440
428
|
}
|
|
441
429
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DragRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
442
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.6", type: DragRootDirective, isStandalone:
|
|
430
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.6", type: DragRootDirective, isStandalone: true, selector: "[tftDragRoot]", host: { listeners: { "click": "onRootClick($event)" } }, exportAs: ["tftDragRoot"], ngImport: i0 }); }
|
|
443
431
|
}
|
|
444
432
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DragRootDirective, decorators: [{
|
|
445
433
|
type: Directive,
|
|
446
434
|
args: [{
|
|
447
435
|
selector: '[tftDragRoot]',
|
|
448
436
|
exportAs: 'tftDragRoot',
|
|
449
|
-
standalone:
|
|
437
|
+
standalone: true,
|
|
450
438
|
}]
|
|
451
|
-
}]
|
|
439
|
+
}], propDecorators: { onRootClick: [{
|
|
440
|
+
type: HostListener,
|
|
441
|
+
args: ['click', ['$event']]
|
|
442
|
+
}] } });
|
|
452
443
|
|
|
453
|
-
;
|
|
454
|
-
/**
|
|
455
|
-
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
456
|
-
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
457
|
-
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
458
|
-
* element accounts for scale
|
|
459
|
-
*/
|
|
460
444
|
class AutoScrollDirective {
|
|
461
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
462
445
|
scroll(scrollEvent) {
|
|
463
446
|
const target = scrollEvent.target;
|
|
464
447
|
const { scrollTop, scrollLeft } = target;
|
|
@@ -466,16 +449,13 @@ class AutoScrollDirective {
|
|
|
466
449
|
}
|
|
467
450
|
constructor() {
|
|
468
451
|
this.el = inject(ElementRef);
|
|
469
|
-
|
|
470
|
-
* Limit minimum time between scroll events in milliseconds
|
|
471
|
-
*/
|
|
472
|
-
this.autoScrollConfig = {
|
|
452
|
+
this.autoScrollConfig = input({
|
|
473
453
|
margin: 50,
|
|
474
454
|
distance: 3,
|
|
475
455
|
interval: 50,
|
|
476
456
|
speed: 300,
|
|
477
|
-
enabled: true
|
|
478
|
-
};
|
|
457
|
+
enabled: true,
|
|
458
|
+
}, ...(ngDevMode ? [{ debugName: "autoScrollConfig" }] : []));
|
|
479
459
|
this.scrollDeltaObserver = new Subject();
|
|
480
460
|
const el = this.el;
|
|
481
461
|
const { scrollTop, scrollLeft } = el.nativeElement;
|
|
@@ -489,17 +469,15 @@ class AutoScrollDirective {
|
|
|
489
469
|
this.scrollObserver.subscribe();
|
|
490
470
|
}
|
|
491
471
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AutoScrollDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
492
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
472
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: AutoScrollDirective, isStandalone: true, selector: "[tftAutoScroll]", inputs: { autoScrollConfig: { classPropertyName: "autoScrollConfig", publicName: "autoScrollConfig", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "scroll": "scroll($event)" } }, ngImport: i0 }); }
|
|
493
473
|
}
|
|
494
474
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AutoScrollDirective, decorators: [{
|
|
495
475
|
type: Directive,
|
|
496
476
|
args: [{
|
|
497
477
|
selector: '[tftAutoScroll]',
|
|
498
|
-
standalone:
|
|
478
|
+
standalone: true,
|
|
499
479
|
}]
|
|
500
|
-
}], ctorParameters: () => [], propDecorators: { autoScrollConfig: [{
|
|
501
|
-
type: Input
|
|
502
|
-
}], scroll: [{
|
|
480
|
+
}], ctorParameters: () => [], propDecorators: { autoScrollConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoScrollConfig", required: false }] }], scroll: [{
|
|
503
481
|
type: HostListener,
|
|
504
482
|
args: ['scroll', ['$event']]
|
|
505
483
|
}] } });
|
|
@@ -517,67 +495,60 @@ class DraggableDirective {
|
|
|
517
495
|
this.dropzone_dir = inject(DropzoneDirective, { optional: true, skipSelf: true });
|
|
518
496
|
this.drag_root_dir = inject(DragRootDirective, { optional: true, skipSelf: true });
|
|
519
497
|
this.auto_scroll_dir = inject(AutoScrollDirective, { optional: true, skipSelf: true });
|
|
520
|
-
|
|
521
|
-
this.
|
|
522
|
-
|
|
498
|
+
this.x = input(...(ngDevMode ? [undefined, { debugName: "x" }] : []));
|
|
499
|
+
this.y = input(...(ngDevMode ? [undefined, { debugName: "y" }] : []));
|
|
500
|
+
/** zIndex while dragging */
|
|
501
|
+
this.dragZIndex = input(10000, ...(ngDevMode ? [{ debugName: "dragZIndex" }] : []));
|
|
502
|
+
/** zIndex while at rest */
|
|
503
|
+
this.zIndex = input(...(ngDevMode ? [undefined, { debugName: "zIndex" }] : []));
|
|
504
|
+
this.dragData = input(...(ngDevMode ? [undefined, { debugName: "dragData" }] : []));
|
|
505
|
+
this.enableDragDefault = input(true, ...(ngDevMode ? [{ debugName: "enableDragDefault" }] : []));
|
|
523
506
|
/**
|
|
524
507
|
* @deprecated replaced by 'dragDisabled' property, please migrate before v13
|
|
525
508
|
*/
|
|
526
|
-
this.disabled = false;
|
|
527
|
-
this.dragDisabled = false;
|
|
528
|
-
this.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
509
|
+
this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
510
|
+
this.dragDisabled = input(false, ...(ngDevMode ? [{ debugName: "dragDisabled" }] : []));
|
|
511
|
+
this.dragConfig = input(...(ngDevMode ? [undefined, { debugName: "dragConfig" }] : []));
|
|
512
|
+
this.showPlaceholder = input(false, ...(ngDevMode ? [{ debugName: "showPlaceholder" }] : []));
|
|
513
|
+
/**
|
|
514
|
+
* The element we want to prepend the drag element to.
|
|
515
|
+
* Use `tftDragRoot` directive on a parent element to set custom root element
|
|
516
|
+
* @default document.body
|
|
517
|
+
*/
|
|
518
|
+
this.dragRoot = input(...(ngDevMode ? [undefined, { debugName: "dragRoot" }] : []));
|
|
519
|
+
this.dragStart = output();
|
|
520
|
+
this.dragMove = output();
|
|
521
|
+
this.dragInertiaStart = output();
|
|
522
|
+
this.dragEnd = output();
|
|
523
|
+
this.scale = computed(() => this.account_for_scale_dir?.scale() || this.drag_root_dir?.account_for_scale_dir?.scale() || this.dragRoot()?.account_for_scale_dir?.scale() || 1, ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
524
|
+
this.syncPosition = effect(() => {
|
|
525
|
+
this.alignPositionWithInputs(this.x(), this.y());
|
|
526
|
+
}, ...(ngDevMode ? [{ debugName: "syncPosition" }] : []));
|
|
527
|
+
this.syncDragConfig = effect(() => {
|
|
528
|
+
const config = this.dragConfig();
|
|
529
|
+
const enabled = !(this.disabled() || this.dragDisabled());
|
|
530
|
+
if (!this.interactable)
|
|
531
|
+
return;
|
|
532
|
+
this.setDragConfig(config, enabled);
|
|
533
|
+
}, ...(ngDevMode ? [{ debugName: "syncDragConfig" }] : []));
|
|
538
534
|
}
|
|
539
535
|
ngOnInit() {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
this.
|
|
545
|
-
|
|
536
|
+
const disabled = this.disabled();
|
|
537
|
+
if (disabled) {
|
|
538
|
+
console.warn(`It looks like your using the 'disabled' input on a tftDraggable directive, it has been deprecated and is replaced with 'dragDisabled', please migrate by v13`);
|
|
539
|
+
}
|
|
540
|
+
this.interactable = this.initiateDragEvents(this.dragConfig(), this.el.nativeElement);
|
|
541
|
+
this.dragRootEl = (this.dragRoot()?.el?.nativeElement || this.drag_root_dir?.el?.nativeElement) || this._document.body;
|
|
542
|
+
this.registryId = this.dropzone_dir?._registeredId() || DEFAULT_REGISTRY_ID;
|
|
546
543
|
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
547
|
-
this.alignPositionWithInputs(this.x, this.y);
|
|
548
|
-
// cache subscription to interactable state so we can unsubscribe onDestroy
|
|
544
|
+
this.alignPositionWithInputs(this.x(), this.y());
|
|
549
545
|
this.interactableState = this.interactService
|
|
550
546
|
.getInteractableState(this.interactableId, this.registryId);
|
|
551
|
-
|
|
552
|
-
this.
|
|
553
|
-
this.y = state.y;
|
|
554
|
-
this.x = state.x;
|
|
555
|
-
});
|
|
556
|
-
this.setDragConfig();
|
|
557
|
-
}
|
|
558
|
-
// TODO: watch config here as well and update interactable
|
|
559
|
-
ngOnChanges(changes) {
|
|
560
|
-
// we do this here instead of using a setter on the input so that it
|
|
561
|
-
// will only run once when there is a change to x and y
|
|
562
|
-
if (changes.y || changes.x) {
|
|
563
|
-
this.alignPositionWithInputs(this.x, this.y);
|
|
564
|
-
}
|
|
565
|
-
if (changes.dragConfig || changes.disabled || changes.dragDisabled) {
|
|
566
|
-
if (!this.interactable)
|
|
567
|
-
return;
|
|
568
|
-
this.setDragConfig();
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* @deprecated remove this in v13
|
|
572
|
-
*/
|
|
573
|
-
if (changes.disabled) {
|
|
574
|
-
console.warn(`It looks like your using the 'disabled' input on a tftDraggable directive, it has been deprecated and is replaced with 'dragDisabled', please migrate by v13`);
|
|
575
|
-
}
|
|
547
|
+
this.interactableSubscription = this.interactableState.subscribe();
|
|
548
|
+
this.setDragConfig(this.dragConfig(), !(this.disabled() || this.dragDisabled()));
|
|
576
549
|
}
|
|
577
|
-
setDragConfig() {
|
|
578
|
-
|
|
579
|
-
const dragConfig = { ...this.dragConfig, enabled };
|
|
580
|
-
this.interactable.draggable(dragConfig);
|
|
550
|
+
setDragConfig(config, enabled) {
|
|
551
|
+
this.interactable.draggable({ ...config, enabled });
|
|
581
552
|
}
|
|
582
553
|
ngAfterViewInit() {
|
|
583
554
|
this.addDragPropertiesToElement(this.el.nativeElement);
|
|
@@ -586,20 +557,19 @@ class DraggableDirective {
|
|
|
586
557
|
}
|
|
587
558
|
}
|
|
588
559
|
ngOnDestroy() {
|
|
589
|
-
// clean up state and subscriptions related to destroyed component
|
|
590
560
|
this.interactableSubscription.unsubscribe();
|
|
591
561
|
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
592
562
|
}
|
|
593
563
|
dragMoveListener(event, element) {
|
|
594
564
|
const { dx, dy } = event;
|
|
595
|
-
const scale = this.scale;
|
|
565
|
+
const scale = this.scale();
|
|
596
566
|
const deltaX = scale ? dx / scale : dx;
|
|
597
567
|
const deltaY = scale ? dy / scale : dy;
|
|
598
568
|
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, element);
|
|
599
569
|
}
|
|
600
570
|
setDragStyles(dragElement) {
|
|
601
571
|
this.renderer.setStyle(dragElement, 'touch-action', 'none');
|
|
602
|
-
this.renderer.setStyle(dragElement, 'z-index', this.dragZIndex);
|
|
572
|
+
this.renderer.setStyle(dragElement, 'z-index', this.dragZIndex());
|
|
603
573
|
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
604
574
|
// Prevents highlighting text if dragging over, which will interrupt the next drag action
|
|
605
575
|
this.renderer.setStyle(dragElement, 'user-select', 'none');
|
|
@@ -612,7 +582,7 @@ class DraggableDirective {
|
|
|
612
582
|
mapDragEvent(event) {
|
|
613
583
|
const { target, dropzone } = event;
|
|
614
584
|
const dropzoneElement = dropzone?.target || target.dropTarget?.el.nativeElement;
|
|
615
|
-
const scale = this.scale;
|
|
585
|
+
const scale = this.scale();
|
|
616
586
|
const positionInDropTarget = target && dropzoneElement
|
|
617
587
|
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
|
|
618
588
|
: null;
|
|
@@ -621,14 +591,13 @@ class DraggableDirective {
|
|
|
621
591
|
dragRef: this,
|
|
622
592
|
dragOrigin: target.dragOrigin,
|
|
623
593
|
dropTarget: target.dropTarget,
|
|
624
|
-
positionInDropTarget
|
|
594
|
+
positionInDropTarget,
|
|
625
595
|
};
|
|
626
596
|
}
|
|
627
597
|
setPosition(x, y) {
|
|
628
598
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.el.nativeElement);
|
|
629
599
|
}
|
|
630
600
|
alignPositionWithInputs(x, y) {
|
|
631
|
-
// short circuit if positions aren't numbers or if they haven't changed
|
|
632
601
|
if (!this.isValidPosition(x, y))
|
|
633
602
|
return;
|
|
634
603
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.el.nativeElement);
|
|
@@ -636,27 +605,24 @@ class DraggableDirective {
|
|
|
636
605
|
isValidPosition(x, y) {
|
|
637
606
|
return this.isNumeric(x) && this.isNumeric(y);
|
|
638
607
|
}
|
|
639
|
-
// We use use this instead of isNaN here to try and help performance
|
|
640
|
-
// We should be able to reliably restrict to numbers or falsey values
|
|
641
608
|
isNumeric(num) {
|
|
642
609
|
return typeof num === 'number' && !isNaN(num);
|
|
643
610
|
}
|
|
644
611
|
initiateDragEvents(dragConfig, nativeElement) {
|
|
645
612
|
const defaultDragConfig = {
|
|
646
613
|
...dragConfig,
|
|
647
|
-
enabled: !(this.disabled || this.dragDisabled),
|
|
614
|
+
enabled: !(this.disabled() || this.dragDisabled()),
|
|
648
615
|
...(this.auto_scroll_dir && {
|
|
649
616
|
autoScroll: {
|
|
650
|
-
...this.auto_scroll_dir.autoScrollConfig,
|
|
651
|
-
container: this.auto_scroll_dir.el.nativeElement
|
|
652
|
-
}
|
|
653
|
-
})
|
|
617
|
+
...this.auto_scroll_dir.autoScrollConfig(),
|
|
618
|
+
container: this.auto_scroll_dir.el.nativeElement,
|
|
619
|
+
},
|
|
620
|
+
}),
|
|
654
621
|
};
|
|
655
622
|
return interact(nativeElement).draggable(defaultDragConfig)
|
|
656
623
|
.on('dragstart', (event) => {
|
|
657
624
|
const interaction = event.interaction;
|
|
658
|
-
|
|
659
|
-
if (this.enableDragDefault && interaction.pointerIsDown) {
|
|
625
|
+
if (this.enableDragDefault() && interaction.pointerIsDown) {
|
|
660
626
|
if (this._previewTemplate) {
|
|
661
627
|
const viewRef = this._viewContainerRef.createEmbeddedView(this._previewTemplate.templateRef);
|
|
662
628
|
this.previewRef = getRootNode(viewRef, this._document);
|
|
@@ -667,26 +633,24 @@ class DraggableDirective {
|
|
|
667
633
|
this.addDragPropertiesToElement(this.previewRef);
|
|
668
634
|
this.setDragStyles(this.previewRef);
|
|
669
635
|
this.dragRootEl.prepend(this.previewRef);
|
|
670
|
-
const scale = this.account_for_scale_dir?.scale || this.dragRoot?.account_for_scale_dir?.scale || 1;
|
|
636
|
+
const scale = this.account_for_scale_dir?.scale() || this.dragRoot()?.account_for_scale_dir?.scale() || 1;
|
|
671
637
|
const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement, scale);
|
|
672
638
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.previewRef);
|
|
673
|
-
if (!this.showPlaceholder) {
|
|
639
|
+
if (!this.showPlaceholder()) {
|
|
674
640
|
this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
|
|
675
641
|
}
|
|
676
642
|
}
|
|
677
|
-
// subscribe to scroll events if they are there, by only subscribing on dragstart we avoid wasting subscriptions on interactables that aren't be dragged
|
|
678
643
|
if (this.auto_scroll_dir) {
|
|
679
644
|
this.subscribeToScrollEvents();
|
|
680
645
|
}
|
|
681
646
|
this.dragStart.emit(this.mapDragEvent(event));
|
|
682
647
|
})
|
|
683
648
|
.on('dragmove', (event) => {
|
|
684
|
-
if (this.enableDragDefault) {
|
|
649
|
+
if (this.enableDragDefault()) {
|
|
685
650
|
const dragElement = this.dropzone_dir && this.previewRef || nativeElement;
|
|
686
651
|
this.dragMoveListener(event, dragElement);
|
|
687
652
|
}
|
|
688
|
-
|
|
689
|
-
this.dragMove.emit(mappedEvent);
|
|
653
|
+
this.dragMove.emit(this.mapDragEvent(event));
|
|
690
654
|
})
|
|
691
655
|
.on('draginertiastart', (event) => {
|
|
692
656
|
this.dragInertiaStart.emit(this.mapDragEvent(event));
|
|
@@ -698,13 +662,14 @@ class DraggableDirective {
|
|
|
698
662
|
this.setPosition(x, y);
|
|
699
663
|
}
|
|
700
664
|
this.renderer.setStyle(this.el.nativeElement, 'display', '');
|
|
665
|
+
// Prevents triggering a click event on the drag root when dropping
|
|
666
|
+
// a drag element, which can deselect drag items
|
|
667
|
+
(this.drag_root_dir ?? this.dragRoot())?.suppressNextClick();
|
|
701
668
|
this.dragEnd.emit(mappedEvent);
|
|
702
|
-
// unsubscribe from scroll events if subscribed
|
|
703
669
|
if (this.auto_scroll_dir) {
|
|
704
670
|
this.scrollEventsSubscription.unsubscribe();
|
|
705
671
|
}
|
|
706
672
|
if (this.el.nativeElement !== this.previewRef) {
|
|
707
|
-
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
708
673
|
setTimeout(() => {
|
|
709
674
|
this.dragRootEl.removeChild(this.previewRef);
|
|
710
675
|
});
|
|
@@ -713,86 +678,41 @@ class DraggableDirective {
|
|
|
713
678
|
}
|
|
714
679
|
subscribeToScrollEvents() {
|
|
715
680
|
this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(({ scrollLeft, scrollTop }) => {
|
|
716
|
-
const deltaX = this.scale ? scrollLeft / this.scale : scrollLeft;
|
|
717
|
-
const deltaY = this.scale ? scrollTop / this.scale : scrollTop;
|
|
681
|
+
const deltaX = this.scale() ? scrollLeft / this.scale() : scrollLeft;
|
|
682
|
+
const deltaY = this.scale() ? scrollTop / this.scale() : scrollTop;
|
|
718
683
|
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, this.previewRef);
|
|
719
684
|
});
|
|
720
685
|
}
|
|
721
686
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DraggableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
722
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
687
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: DraggableDirective, isStandalone: true, selector: "[tftDraggable]", inputs: { x: { classPropertyName: "x", publicName: "x", isSignal: true, isRequired: false, transformFunction: null }, y: { classPropertyName: "y", publicName: "y", isSignal: true, isRequired: false, transformFunction: null }, dragZIndex: { classPropertyName: "dragZIndex", publicName: "dragZIndex", isSignal: true, isRequired: false, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null }, dragData: { classPropertyName: "dragData", publicName: "dragData", isSignal: true, isRequired: false, transformFunction: null }, enableDragDefault: { classPropertyName: "enableDragDefault", publicName: "enableDragDefault", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dragDisabled: { classPropertyName: "dragDisabled", publicName: "dragDisabled", isSignal: true, isRequired: false, transformFunction: null }, dragConfig: { classPropertyName: "dragConfig", publicName: "dragConfig", isSignal: true, isRequired: false, transformFunction: null }, showPlaceholder: { classPropertyName: "showPlaceholder", publicName: "showPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, dragRoot: { classPropertyName: "dragRoot", publicName: "dragRoot", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dragStart: "dragStart", dragMove: "dragMove", dragInertiaStart: "dragInertiaStart", dragEnd: "dragEnd" }, host: { properties: { "style.user-select": "dragDisabled() ? \"auto\" : \"none\"", "style.touch-action": "dragDisabled() ? \"auto\" : \"none\"", "style.position": "\"absolute\"", "id": "interactableId" } }, queries: [{ propertyName: "_previewTemplate", first: true, predicate: DragPreviewDirective, descendants: true }], ngImport: i0 }); }
|
|
723
688
|
}
|
|
724
689
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DraggableDirective, decorators: [{
|
|
725
690
|
type: Directive,
|
|
726
691
|
args: [{
|
|
727
692
|
selector: '[tftDraggable]',
|
|
728
|
-
|
|
693
|
+
standalone: true,
|
|
729
694
|
host: {
|
|
730
|
-
'[style.
|
|
695
|
+
'[style.user-select]': 'dragDisabled() ? "auto" : "none"',
|
|
696
|
+
'[style.touch-action]': 'dragDisabled() ? "auto" : "none"',
|
|
731
697
|
'[style.position]': '"absolute"',
|
|
732
698
|
'[id]': 'interactableId',
|
|
733
699
|
},
|
|
734
|
-
standalone: false
|
|
735
700
|
}]
|
|
736
|
-
}], propDecorators: { x: [{
|
|
737
|
-
type: Input
|
|
738
|
-
}], y: [{
|
|
739
|
-
type: Input
|
|
740
|
-
}], dragZIndex: [{
|
|
741
|
-
type: Input
|
|
742
|
-
}], zIndex: [{
|
|
743
|
-
type: Input
|
|
744
|
-
}], interactableId: [{
|
|
745
|
-
type: Input
|
|
746
|
-
}], dragData: [{
|
|
747
|
-
type: Input
|
|
748
|
-
}], enableDragDefault: [{
|
|
749
|
-
type: Input
|
|
750
|
-
}], disabled: [{
|
|
751
|
-
type: Input
|
|
752
|
-
}], dragDisabled: [{
|
|
753
|
-
type: Input
|
|
754
|
-
}], dragConfig: [{
|
|
755
|
-
type: Input
|
|
756
|
-
}], showPlaceholder: [{
|
|
757
|
-
type: Input
|
|
758
|
-
}], dragRoot: [{
|
|
759
|
-
type: Input
|
|
760
|
-
}], dragStart: [{
|
|
761
|
-
type: Output
|
|
762
|
-
}], dragMove: [{
|
|
763
|
-
type: Output
|
|
764
|
-
}], dragInertiaStart: [{
|
|
765
|
-
type: Output
|
|
766
|
-
}], dragEnd: [{
|
|
767
|
-
type: Output
|
|
768
|
-
}], _previewTemplate: [{
|
|
701
|
+
}], propDecorators: { x: [{ type: i0.Input, args: [{ isSignal: true, alias: "x", required: false }] }], y: [{ type: i0.Input, args: [{ isSignal: true, alias: "y", required: false }] }], dragZIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragZIndex", required: false }] }], zIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "zIndex", required: false }] }], dragData: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragData", required: false }] }], enableDragDefault: [{ type: i0.Input, args: [{ isSignal: true, alias: "enableDragDefault", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dragDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragDisabled", required: false }] }], dragConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragConfig", required: false }] }], showPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "showPlaceholder", required: false }] }], dragRoot: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragRoot", required: false }] }], dragStart: [{ type: i0.Output, args: ["dragStart"] }], dragMove: [{ type: i0.Output, args: ["dragMove"] }], dragInertiaStart: [{ type: i0.Output, args: ["dragInertiaStart"] }], dragEnd: [{ type: i0.Output, args: ["dragEnd"] }], _previewTemplate: [{
|
|
769
702
|
type: ContentChild,
|
|
770
703
|
args: [DragPreviewDirective]
|
|
771
704
|
}] } });
|
|
772
705
|
/**
|
|
773
706
|
* Component utils
|
|
774
707
|
*/
|
|
775
|
-
// create a clone of the component passed in and add it to the root component
|
|
776
708
|
function cloneElement(element) {
|
|
777
709
|
const clone = element.cloneNode(true);
|
|
778
710
|
clone.removeAttribute('id');
|
|
779
711
|
return clone;
|
|
780
712
|
}
|
|
781
|
-
function getPreviewInsertionPoint(documentRef) {
|
|
782
|
-
// We can't use the body if the user is in fullscreen mode,
|
|
783
|
-
// because the preview will render under the fullscreen element.
|
|
784
|
-
return documentRef.fullscreenElement ||
|
|
785
|
-
documentRef.webkitFullscreenElement ||
|
|
786
|
-
documentRef.mozFullScreenElement ||
|
|
787
|
-
documentRef.msFullscreenElement ||
|
|
788
|
-
documentRef.body;
|
|
789
|
-
}
|
|
790
713
|
|
|
791
714
|
/** @dynamic */
|
|
792
715
|
class ResizableDirective {
|
|
793
|
-
get scale() {
|
|
794
|
-
return this.account_for_scale_dir?.scale || this.drag_root_dir?.account_for_scale_dir?.scale;
|
|
795
|
-
}
|
|
796
716
|
constructor() {
|
|
797
717
|
this.el = inject(ElementRef);
|
|
798
718
|
this._document = inject(DOCUMENT);
|
|
@@ -803,77 +723,69 @@ class ResizableDirective {
|
|
|
803
723
|
this.draggable_dir = inject(DraggableDirective, { optional: true });
|
|
804
724
|
this.dropzone_dir = inject(DropzoneDirective, { optional: true, skipSelf: true });
|
|
805
725
|
this.auto_scroll_dir = inject(AutoScrollDirective, { optional: true, skipSelf: true });
|
|
806
|
-
this.enableResizeDefault = true;
|
|
807
|
-
|
|
808
|
-
this.
|
|
809
|
-
this.
|
|
810
|
-
this.
|
|
811
|
-
this.
|
|
812
|
-
this.
|
|
813
|
-
this.
|
|
726
|
+
this.enableResizeDefault = input(true, ...(ngDevMode ? [{ debugName: "enableResizeDefault" }] : []));
|
|
727
|
+
this.position = input('absolute', ...(ngDevMode ? [{ debugName: "position" }] : []));
|
|
728
|
+
this.resizeConfig = input(...(ngDevMode ? [undefined, { debugName: "resizeConfig" }] : []));
|
|
729
|
+
this.interactableId = input(...(ngDevMode ? [undefined, { debugName: "interactableId" }] : []));
|
|
730
|
+
this.width = input(...(ngDevMode ? [undefined, { debugName: "width" }] : []));
|
|
731
|
+
this.height = input(...(ngDevMode ? [undefined, { debugName: "height" }] : []));
|
|
732
|
+
this.resizeDisabled = input(false, ...(ngDevMode ? [{ debugName: "resizeDisabled" }] : []));
|
|
733
|
+
this.resizeStart = output();
|
|
734
|
+
this.resizeMove = output();
|
|
735
|
+
this.resizeInertiaStart = output();
|
|
736
|
+
this.resizeEnd = output();
|
|
814
737
|
this.defaultConfig = {
|
|
815
|
-
edges: { left: true, right: true, bottom: true, top: true }
|
|
738
|
+
edges: { left: true, right: true, bottom: true, top: true },
|
|
816
739
|
};
|
|
817
740
|
this.activeEdges = { left: false, right: false, top: false, bottom: false };
|
|
818
|
-
|
|
819
|
-
this.dragRootEl = drag_root_dir?.el?.nativeElement || this._document.body;
|
|
741
|
+
this.scale = computed(() => this.account_for_scale_dir?.scale() || this.drag_root_dir?.account_for_scale_dir?.scale(), ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
742
|
+
this.dragRootEl = this.drag_root_dir?.el?.nativeElement || this._document.body;
|
|
743
|
+
effect(() => {
|
|
744
|
+
this.resizeConfig();
|
|
745
|
+
this.resizeDisabled();
|
|
746
|
+
if (!this.interactable)
|
|
747
|
+
return;
|
|
748
|
+
this.interactable.resizable({ ...this.resizeConfig(), enabled: !this.resizeDisabled() });
|
|
749
|
+
});
|
|
750
|
+
effect(() => {
|
|
751
|
+
this.alignDimensionsWithInputs(this.width(), this.height());
|
|
752
|
+
});
|
|
820
753
|
}
|
|
821
754
|
ngOnInit() {
|
|
822
755
|
this.addResizePropertiesToElement(this.el.nativeElement);
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
this.
|
|
827
|
-
this.interactableId = this.draggable_dir?.interactableId || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
828
|
-
this.interactable = this.initiateResizeEvents({ ...this.defaultConfig, ...this.resizeConfig }, this.el.nativeElement);
|
|
829
|
-
this.alignDimensionsWithInputs(this.width, this.height);
|
|
756
|
+
this.registryId = this.dropzone_dir?._registeredId() || DEFAULT_REGISTRY_ID;
|
|
757
|
+
this._interactableId = this.draggable_dir?.interactableId || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId());
|
|
758
|
+
this.interactable = this.initiateResizeEvents({ ...this.defaultConfig, ...this.resizeConfig() }, this.el.nativeElement);
|
|
759
|
+
this.alignDimensionsWithInputs(this.width(), this.height());
|
|
830
760
|
this.interactableSubscription = this.interactService
|
|
831
|
-
.getInteractableState(this.
|
|
761
|
+
.getInteractableState(this._interactableId, this.registryId)
|
|
832
762
|
.subscribe();
|
|
833
763
|
}
|
|
834
|
-
ngOnChanges(changes) {
|
|
835
|
-
if ((changes.resizeConfig || changes.resizeDisabled) && this.interactable) {
|
|
836
|
-
this.interactable.resizable({ ...this.resizeConfig, enabled: !this.resizeDisabled, });
|
|
837
|
-
}
|
|
838
|
-
if (changes.width || changes.height) {
|
|
839
|
-
this.alignDimensionsWithInputs(this.width, this.height);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
764
|
ngOnDestroy() {
|
|
843
765
|
this.interactableSubscription.unsubscribe();
|
|
844
|
-
this.interactService.destroyInteractable(this.
|
|
766
|
+
this.interactService.destroyInteractable(this._interactableId, this.registryId);
|
|
845
767
|
}
|
|
846
768
|
resizeListener(event) {
|
|
847
769
|
const element = this.el.nativeElement;
|
|
848
|
-
const scale = this.scale;
|
|
770
|
+
const scale = this.scale();
|
|
849
771
|
const { deltaRect } = event;
|
|
850
772
|
const deltaX = deltaRect.left / scale;
|
|
851
773
|
const deltaY = deltaRect.top / scale;
|
|
852
|
-
// We get the width and height directly from the native element because
|
|
853
|
-
// the event dimension can get out of sync when resizing with autoScroll
|
|
854
774
|
const rect = element.getBoundingClientRect();
|
|
855
775
|
const width = (rect.width + deltaRect.width) / scale;
|
|
856
776
|
const height = (rect.height + deltaRect.height) / scale;
|
|
857
|
-
this.interactService.updateSize(this.
|
|
777
|
+
this.interactService.updateSize(this._interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
|
|
858
778
|
}
|
|
859
|
-
/**
|
|
860
|
-
* hook elements into interacts resize event listeners
|
|
861
|
-
* we spread the configs so that the consuming component only overwrites the
|
|
862
|
-
* pieces that it explicitly indicates
|
|
863
|
-
* @param resizeConfig
|
|
864
|
-
* @param nativeElement
|
|
865
|
-
*/
|
|
866
779
|
initiateResizeEvents(resizeConfig, nativeElement) {
|
|
867
|
-
// TODO: This should try and get interactable from tft_draggable if it exists
|
|
868
780
|
const defaultResizeConfig = {
|
|
869
781
|
...resizeConfig,
|
|
870
|
-
enabled: !this.resizeDisabled,
|
|
782
|
+
enabled: !this.resizeDisabled(),
|
|
871
783
|
...(this.auto_scroll_dir && {
|
|
872
784
|
autoScroll: {
|
|
873
|
-
...this.auto_scroll_dir.autoScrollConfig,
|
|
874
|
-
container: this.auto_scroll_dir.el.nativeElement
|
|
875
|
-
}
|
|
876
|
-
})
|
|
785
|
+
...this.auto_scroll_dir.autoScrollConfig(),
|
|
786
|
+
container: this.auto_scroll_dir.el.nativeElement,
|
|
787
|
+
},
|
|
788
|
+
}),
|
|
877
789
|
};
|
|
878
790
|
const interactable = this.draggable_dir?.interactable || interact(nativeElement);
|
|
879
791
|
return interactable.resizable(defaultResizeConfig)
|
|
@@ -885,11 +797,10 @@ class ResizableDirective {
|
|
|
885
797
|
this.resizeStart.emit(this.mapResizeEvent(event));
|
|
886
798
|
})
|
|
887
799
|
.on('resizemove', (event) => {
|
|
888
|
-
if (this.enableResizeDefault) {
|
|
800
|
+
if (this.enableResizeDefault()) {
|
|
889
801
|
this.resizeListener(event);
|
|
890
802
|
}
|
|
891
|
-
|
|
892
|
-
this.resizeMove.emit(mappedEvent);
|
|
803
|
+
this.resizeMove.emit(this.mapResizeEvent(event));
|
|
893
804
|
})
|
|
894
805
|
.on('resizeinertiastart', (event) => this.resizeInertiaStart.emit(this.mapResizeEvent(event)))
|
|
895
806
|
.on('resizeend', (event) => {
|
|
@@ -903,7 +814,7 @@ class ResizableDirective {
|
|
|
903
814
|
mapResizeEvent(event) {
|
|
904
815
|
const target = this.el.nativeElement;
|
|
905
816
|
const relatedTarget = this.draggable_dir?.dropzone_dir?.el.nativeElement;
|
|
906
|
-
const scale = this.scale;
|
|
817
|
+
const scale = this.scale();
|
|
907
818
|
const positionInDropTarget = target && relatedTarget
|
|
908
819
|
? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
|
|
909
820
|
: null;
|
|
@@ -916,19 +827,19 @@ class ResizableDirective {
|
|
|
916
827
|
positionInDropTarget,
|
|
917
828
|
size: {
|
|
918
829
|
width: target.clientWidth / scale,
|
|
919
|
-
height: target.clientHeight / scale
|
|
920
|
-
}
|
|
830
|
+
height: target.clientHeight / scale,
|
|
831
|
+
},
|
|
921
832
|
};
|
|
922
833
|
}
|
|
923
834
|
alignDimensionsWithInputs(width, height) {
|
|
924
|
-
this.interactService.updateSize(this.
|
|
835
|
+
this.interactService.updateSize(this._interactableId, this.registryId, { deltaX: 0, deltaY: 0, width, height }, this.el.nativeElement);
|
|
925
836
|
}
|
|
926
837
|
addResizePropertiesToElement(nativeElement) {
|
|
927
838
|
this.renderer.setProperty(nativeElement, 'resizeRef', this);
|
|
928
839
|
}
|
|
929
840
|
subscribeToScrollEvents() {
|
|
930
841
|
this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(({ scrollLeft, scrollTop }) => {
|
|
931
|
-
const scale = this.scale;
|
|
842
|
+
const scale = this.scale();
|
|
932
843
|
const target = this.el.nativeElement;
|
|
933
844
|
const { width: prevWidth, height: prevHeight } = target.getBoundingClientRect();
|
|
934
845
|
const deltaHeight = scrollTop * (this.activeEdges.top ? -1 : this.activeEdges.bottom ? 1 : 0);
|
|
@@ -937,52 +848,28 @@ class ResizableDirective {
|
|
|
937
848
|
const width = (prevWidth + deltaWidth) / scale;
|
|
938
849
|
const deltaX = this.activeEdges.left ? (scrollLeft / scale) : 0;
|
|
939
850
|
const deltaY = this.activeEdges.top ? (scrollTop / scale) : 0;
|
|
940
|
-
this.interactService.updateSize(this.
|
|
851
|
+
this.interactService.updateSize(this._interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
|
|
941
852
|
});
|
|
942
853
|
}
|
|
943
854
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ResizableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
944
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
855
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: ResizableDirective, isStandalone: true, selector: "[tftResizable]", inputs: { enableResizeDefault: { classPropertyName: "enableResizeDefault", publicName: "enableResizeDefault", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, resizeConfig: { classPropertyName: "resizeConfig", publicName: "resizeConfig", isSignal: true, isRequired: false, transformFunction: null }, interactableId: { classPropertyName: "interactableId", publicName: "interactableId", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, resizeDisabled: { classPropertyName: "resizeDisabled", publicName: "resizeDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { resizeStart: "resizeStart", resizeMove: "resizeMove", resizeInertiaStart: "resizeInertiaStart", resizeEnd: "resizeEnd" }, host: { properties: { "style.touch-action": "resizeDisabled() ? \"auto\" : \"none\"", "style.position": "position()", "style.box-sizing": "\"border-box\"" } }, ngImport: i0 }); }
|
|
945
856
|
}
|
|
946
857
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ResizableDirective, decorators: [{
|
|
947
858
|
type: Directive,
|
|
948
859
|
args: [{
|
|
949
860
|
selector: '[tftResizable]',
|
|
861
|
+
standalone: true,
|
|
950
862
|
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
|
951
863
|
host: {
|
|
952
|
-
// prevents touch events from colliding with
|
|
953
|
-
|
|
954
|
-
'[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
|
|
864
|
+
// prevents touch events from colliding with mouse events on touch screen
|
|
865
|
+
'[style.touch-action]': 'resizeDisabled() ? "auto" : "none"',
|
|
955
866
|
// default to absolute here to accommodate likely use cases
|
|
956
|
-
|
|
957
|
-
'[style.position]': 'position',
|
|
867
|
+
'[style.position]': 'position()',
|
|
958
868
|
// follows interactjs suggested practices
|
|
959
|
-
'[style.
|
|
869
|
+
'[style.box-sizing]': '"border-box"',
|
|
960
870
|
},
|
|
961
|
-
standalone: false
|
|
962
871
|
}]
|
|
963
|
-
}], ctorParameters: () => [], propDecorators: { enableResizeDefault: [{
|
|
964
|
-
type: Input
|
|
965
|
-
}], position: [{
|
|
966
|
-
type: Input
|
|
967
|
-
}], resizeConfig: [{
|
|
968
|
-
type: Input
|
|
969
|
-
}], interactableId: [{
|
|
970
|
-
type: Input
|
|
971
|
-
}], width: [{
|
|
972
|
-
type: Input
|
|
973
|
-
}], height: [{
|
|
974
|
-
type: Input
|
|
975
|
-
}], resizeDisabled: [{
|
|
976
|
-
type: Input
|
|
977
|
-
}], resizeStart: [{
|
|
978
|
-
type: Output
|
|
979
|
-
}], resizeMove: [{
|
|
980
|
-
type: Output
|
|
981
|
-
}], resizeInertiaStart: [{
|
|
982
|
-
type: Output
|
|
983
|
-
}], resizeEnd: [{
|
|
984
|
-
type: Output
|
|
985
|
-
}] } });
|
|
872
|
+
}], ctorParameters: () => [], propDecorators: { enableResizeDefault: [{ type: i0.Input, args: [{ isSignal: true, alias: "enableResizeDefault", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], resizeConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "resizeConfig", required: false }] }], interactableId: [{ type: i0.Input, args: [{ isSignal: true, alias: "interactableId", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], resizeDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "resizeDisabled", required: false }] }], resizeStart: [{ type: i0.Output, args: ["resizeStart"] }], resizeMove: [{ type: i0.Output, args: ["resizeMove"] }], resizeInertiaStart: [{ type: i0.Output, args: ["resizeInertiaStart"] }], resizeEnd: [{ type: i0.Output, args: ["resizeEnd"] }] } });
|
|
986
873
|
|
|
987
874
|
/** @dynamic */
|
|
988
875
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -990,35 +877,32 @@ class GesturableDirective {
|
|
|
990
877
|
constructor() {
|
|
991
878
|
this.el = inject(ElementRef);
|
|
992
879
|
this.draggable_dir = inject(DraggableDirective, { optional: true });
|
|
993
|
-
this.
|
|
994
|
-
|
|
995
|
-
this.
|
|
996
|
-
this.
|
|
997
|
-
this.
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
this.setGestureConfig();
|
|
1003
|
-
}
|
|
1004
|
-
// TODO: watch config here as well and update interactable
|
|
1005
|
-
ngOnChanges(changes) {
|
|
1006
|
-
// we do this here instead of using a setter on the input so that it
|
|
1007
|
-
// will only run once when there is a change to x and y
|
|
1008
|
-
if (changes.gestureConfig || changes.gestureDisabled) {
|
|
880
|
+
this.gesturableId = input(...(ngDevMode ? [undefined, { debugName: "gesturableId" }] : []));
|
|
881
|
+
this.gestureDisabled = input(false, ...(ngDevMode ? [{ debugName: "gestureDisabled" }] : []));
|
|
882
|
+
this.gestureConfig = input(...(ngDevMode ? [undefined, { debugName: "gestureConfig" }] : []));
|
|
883
|
+
this.gestureStart = output();
|
|
884
|
+
this.gestureMove = output();
|
|
885
|
+
this.gestureEnd = output();
|
|
886
|
+
effect(() => {
|
|
887
|
+
this.gestureConfig();
|
|
888
|
+
this.gestureDisabled();
|
|
1009
889
|
if (!this.interactable)
|
|
1010
890
|
return;
|
|
1011
891
|
this.setGestureConfig();
|
|
1012
|
-
}
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
ngOnInit() {
|
|
895
|
+
this.interactable = this.initiateGestureEvents(this.gestureConfig(), this.el.nativeElement);
|
|
896
|
+
this.setGestureConfig();
|
|
1013
897
|
}
|
|
1014
898
|
setGestureConfig() {
|
|
1015
|
-
const enabled = !this.gestureDisabled;
|
|
1016
|
-
const gestureConfig = { ...this.gestureConfig, enabled };
|
|
899
|
+
const enabled = !this.gestureDisabled();
|
|
900
|
+
const gestureConfig = { ...this.gestureConfig(), enabled };
|
|
1017
901
|
this.interactable.gesturable(gestureConfig);
|
|
1018
902
|
}
|
|
1019
903
|
initiateGestureEvents(gestureConfig, nativeElement) {
|
|
1020
904
|
const defaultConfig = {
|
|
1021
|
-
enabled: !this.gestureDisabled,
|
|
905
|
+
enabled: !this.gestureDisabled(),
|
|
1022
906
|
};
|
|
1023
907
|
const interactable = this.draggable_dir?.interactable || interact(nativeElement);
|
|
1024
908
|
return interactable.gesturable({ ...defaultConfig, ...gestureConfig })
|
|
@@ -1033,59 +917,38 @@ class GesturableDirective {
|
|
|
1033
917
|
});
|
|
1034
918
|
}
|
|
1035
919
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: GesturableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1036
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
920
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: GesturableDirective, isStandalone: true, selector: "[tftGesturable]", inputs: { gesturableId: { classPropertyName: "gesturableId", publicName: "gesturableId", isSignal: true, isRequired: false, transformFunction: null }, gestureDisabled: { classPropertyName: "gestureDisabled", publicName: "gestureDisabled", isSignal: true, isRequired: false, transformFunction: null }, gestureConfig: { classPropertyName: "gestureConfig", publicName: "gestureConfig", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { gestureStart: "gestureStart", gestureMove: "gestureMove", gestureEnd: "gestureEnd" }, host: { properties: { "id": "gesturableId()" } }, ngImport: i0 }); }
|
|
1037
921
|
}
|
|
1038
922
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: GesturableDirective, decorators: [{
|
|
1039
923
|
type: Directive,
|
|
1040
924
|
args: [{
|
|
1041
925
|
selector: '[tftGesturable]',
|
|
1042
|
-
|
|
926
|
+
standalone: true,
|
|
1043
927
|
host: {
|
|
1044
|
-
// '[style.
|
|
1045
|
-
'[id]': 'gesturableId',
|
|
928
|
+
// '[style.touch-action]': 'gestureDisabled() ? "auto" : "none"',
|
|
929
|
+
'[id]': 'gesturableId()',
|
|
1046
930
|
},
|
|
1047
|
-
standalone: false
|
|
1048
931
|
}]
|
|
1049
|
-
}], propDecorators: { gesturableId: [{
|
|
1050
|
-
type: Input
|
|
1051
|
-
}], gestureDisabled: [{
|
|
1052
|
-
type: Input
|
|
1053
|
-
}], gestureConfig: [{
|
|
1054
|
-
type: Input
|
|
1055
|
-
}], gestureStart: [{
|
|
1056
|
-
type: Output
|
|
1057
|
-
}], gestureMove: [{
|
|
1058
|
-
type: Output
|
|
1059
|
-
}], gestureEnd: [{
|
|
1060
|
-
type: Output
|
|
1061
|
-
}] } });
|
|
932
|
+
}], ctorParameters: () => [], propDecorators: { gesturableId: [{ type: i0.Input, args: [{ isSignal: true, alias: "gesturableId", required: false }] }], gestureDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "gestureDisabled", required: false }] }], gestureConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "gestureConfig", required: false }] }], gestureStart: [{ type: i0.Output, args: ["gestureStart"] }], gestureMove: [{ type: i0.Output, args: ["gestureMove"] }], gestureEnd: [{ type: i0.Output, args: ["gestureEnd"] }] } });
|
|
1062
933
|
|
|
1063
934
|
class ApplyScaleDirective {
|
|
1064
935
|
constructor() {
|
|
1065
936
|
this.el = inject(ElementRef);
|
|
1066
|
-
this.
|
|
1067
|
-
}
|
|
1068
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
1069
|
-
set scale(val) {
|
|
1070
|
-
this._scale;
|
|
1071
|
-
this.fontSize = `${val}px`;
|
|
937
|
+
this.scale = input(1, ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
1072
938
|
}
|
|
1073
|
-
;
|
|
1074
939
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ApplyScaleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1075
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
940
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: ApplyScaleDirective, isStandalone: true, selector: "[tftApplyScale]", inputs: { scale: { classPropertyName: "scale", publicName: "scale", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.font-size": "scale() + \"px\"" } }, ngImport: i0 }); }
|
|
1076
941
|
}
|
|
1077
942
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ApplyScaleDirective, decorators: [{
|
|
1078
943
|
type: Directive,
|
|
1079
944
|
args: [{
|
|
1080
945
|
selector: '[tftApplyScale]',
|
|
1081
|
-
standalone:
|
|
946
|
+
standalone: true,
|
|
947
|
+
host: {
|
|
948
|
+
'[style.font-size]': 'scale() + "px"',
|
|
949
|
+
},
|
|
1082
950
|
}]
|
|
1083
|
-
}], propDecorators: { scale: [{
|
|
1084
|
-
type: Input
|
|
1085
|
-
}], fontSize: [{
|
|
1086
|
-
type: HostBinding,
|
|
1087
|
-
args: ['style.fontSize']
|
|
1088
|
-
}] } });
|
|
951
|
+
}], propDecorators: { scale: [{ type: i0.Input, args: [{ isSignal: true, alias: "scale", required: false }] }] } });
|
|
1089
952
|
|
|
1090
953
|
/**
|
|
1091
954
|
* Directive that handles lasso (drag-to-select) interaction geometry.
|
|
@@ -1108,16 +971,16 @@ class LassoDirective {
|
|
|
1108
971
|
constructor() {
|
|
1109
972
|
this.host = inject((ElementRef));
|
|
1110
973
|
/** Scale factor applied to the host element — used to convert viewport px to container-local px. */
|
|
1111
|
-
this.scale = 1;
|
|
974
|
+
this.scale = input(1, ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
1112
975
|
/** When true, lasso interaction is disabled. */
|
|
1113
|
-
this.lassoDisabled = false;
|
|
1114
|
-
/** Emitted on
|
|
1115
|
-
this.lassoStart =
|
|
976
|
+
this.lassoDisabled = input(false, ...(ngDevMode ? [{ debugName: "lassoDisabled" }] : []));
|
|
977
|
+
/** Emitted on pointerdown (before any drag). Use to clear previous selection state. */
|
|
978
|
+
this.lassoStart = output();
|
|
1116
979
|
/**
|
|
1117
|
-
* Emitted on
|
|
980
|
+
* Emitted on pointerup when the drag exceeded the 5 px threshold.
|
|
1118
981
|
* Rect is in viewport (clientX/Y) space — pass directly to getBoundingClientRect comparisons.
|
|
1119
982
|
*/
|
|
1120
|
-
this.lassoCommit =
|
|
983
|
+
this.lassoCommit = output();
|
|
1121
984
|
// -------------------------------------------------------------------------
|
|
1122
985
|
// Internal state
|
|
1123
986
|
// -------------------------------------------------------------------------
|
|
@@ -1150,15 +1013,15 @@ class LassoDirective {
|
|
|
1150
1013
|
toLocal(vpX, vpY) {
|
|
1151
1014
|
const rect = this.host.nativeElement.getBoundingClientRect();
|
|
1152
1015
|
return {
|
|
1153
|
-
x: (vpX - rect.left) / this.scale,
|
|
1154
|
-
y: (vpY - rect.top) / this.scale,
|
|
1016
|
+
x: (vpX - rect.left) / this.scale(),
|
|
1017
|
+
y: (vpY - rect.top) / this.scale(),
|
|
1155
1018
|
};
|
|
1156
1019
|
}
|
|
1157
1020
|
// -------------------------------------------------------------------------
|
|
1158
1021
|
// Event handling
|
|
1159
1022
|
// -------------------------------------------------------------------------
|
|
1160
1023
|
onPointerDown(e) {
|
|
1161
|
-
if (this.lassoDisabled)
|
|
1024
|
+
if (this.lassoDisabled())
|
|
1162
1025
|
return;
|
|
1163
1026
|
if (e.target !== e.currentTarget)
|
|
1164
1027
|
return; // ignore clicks on children
|
|
@@ -1208,27 +1071,19 @@ class LassoDirective {
|
|
|
1208
1071
|
}
|
|
1209
1072
|
}
|
|
1210
1073
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: LassoDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1211
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
1074
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.6", type: LassoDirective, isStandalone: true, selector: "[tftLasso]", inputs: { scale: { classPropertyName: "scale", publicName: "scale", isSignal: true, isRequired: false, transformFunction: null }, lassoDisabled: { classPropertyName: "lassoDisabled", publicName: "lassoDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { lassoStart: "lassoStart", lassoCommit: "lassoCommit" }, host: { listeners: { "pointerdown": "onPointerDown($event)", "pointermove": "onPointerMove($event)", "pointerup": "onPointerUp($event)", "pointercancel": "onPointerUp($event)", "click": "onClick($event)" }, properties: { "style.touch-action": "lassoDisabled() ? \"auto\" : \"none\"" } }, exportAs: ["tftLasso"], ngImport: i0 }); }
|
|
1212
1075
|
}
|
|
1213
1076
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: LassoDirective, decorators: [{
|
|
1214
1077
|
type: Directive,
|
|
1215
1078
|
args: [{
|
|
1216
1079
|
selector: '[tftLasso]',
|
|
1217
1080
|
exportAs: 'tftLasso',
|
|
1218
|
-
standalone:
|
|
1081
|
+
standalone: true,
|
|
1219
1082
|
host: {
|
|
1220
|
-
'[style.touch-action]': 'lassoDisabled ? "auto" : "none"',
|
|
1083
|
+
'[style.touch-action]': 'lassoDisabled() ? "auto" : "none"',
|
|
1221
1084
|
},
|
|
1222
1085
|
}]
|
|
1223
|
-
}], propDecorators: { scale: [{
|
|
1224
|
-
type: Input
|
|
1225
|
-
}], lassoDisabled: [{
|
|
1226
|
-
type: Input
|
|
1227
|
-
}], lassoStart: [{
|
|
1228
|
-
type: Output
|
|
1229
|
-
}], lassoCommit: [{
|
|
1230
|
-
type: Output
|
|
1231
|
-
}], onPointerDown: [{
|
|
1086
|
+
}], propDecorators: { scale: [{ type: i0.Input, args: [{ isSignal: true, alias: "scale", required: false }] }], lassoDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "lassoDisabled", required: false }] }], lassoStart: [{ type: i0.Output, args: ["lassoStart"] }], lassoCommit: [{ type: i0.Output, args: ["lassoCommit"] }], onPointerDown: [{
|
|
1232
1087
|
type: HostListener,
|
|
1233
1088
|
args: ['pointerdown', ['$event']]
|
|
1234
1089
|
}], onPointerMove: [{
|
|
@@ -1258,6 +1113,11 @@ const EXPORTS = [
|
|
|
1258
1113
|
LassoDirective,
|
|
1259
1114
|
ArrayOfNPipe,
|
|
1260
1115
|
];
|
|
1116
|
+
/**
|
|
1117
|
+
* @deprecated All directives are now standalone. Import them directly instead of using InteractModule.
|
|
1118
|
+
* InteractModule will be removed in the next major version.
|
|
1119
|
+
* `InteractModule.forRoot()` is still supported for providing InteractService configuration.
|
|
1120
|
+
*/
|
|
1261
1121
|
class InteractModule {
|
|
1262
1122
|
static forRoot(config) {
|
|
1263
1123
|
const defaultConfig = { cssDimensionUnit: 'px' };
|
|
@@ -1265,12 +1125,12 @@ class InteractModule {
|
|
|
1265
1125
|
ngModule: InteractModule,
|
|
1266
1126
|
providers: [
|
|
1267
1127
|
{ provide: INTERACT_ROOT_CONFIG, useValue: { ...defaultConfig, ...config } },
|
|
1268
|
-
InteractService
|
|
1269
|
-
]
|
|
1128
|
+
InteractService,
|
|
1129
|
+
],
|
|
1270
1130
|
};
|
|
1271
1131
|
}
|
|
1272
1132
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1273
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.6", ngImport: i0, type: InteractModule,
|
|
1133
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.6", ngImport: i0, type: InteractModule, imports: [DraggableDirective,
|
|
1274
1134
|
ResizableDirective,
|
|
1275
1135
|
DropzoneDirective,
|
|
1276
1136
|
GesturableDirective,
|
|
@@ -1280,7 +1140,7 @@ class InteractModule {
|
|
|
1280
1140
|
ApplyScaleDirective,
|
|
1281
1141
|
DragPreviewDirective,
|
|
1282
1142
|
LassoDirective,
|
|
1283
|
-
ArrayOfNPipe],
|
|
1143
|
+
ArrayOfNPipe], exports: [DraggableDirective,
|
|
1284
1144
|
ResizableDirective,
|
|
1285
1145
|
DropzoneDirective,
|
|
1286
1146
|
GesturableDirective,
|
|
@@ -1291,19 +1151,13 @@ class InteractModule {
|
|
|
1291
1151
|
DragPreviewDirective,
|
|
1292
1152
|
LassoDirective,
|
|
1293
1153
|
ArrayOfNPipe] }); }
|
|
1294
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule
|
|
1154
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule }); }
|
|
1295
1155
|
}
|
|
1296
1156
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule, decorators: [{
|
|
1297
1157
|
type: NgModule,
|
|
1298
1158
|
args: [{
|
|
1299
|
-
imports: [
|
|
1300
|
-
|
|
1301
|
-
declarations: [
|
|
1302
|
-
...EXPORTS,
|
|
1303
|
-
],
|
|
1304
|
-
exports: [
|
|
1305
|
-
...EXPORTS
|
|
1306
|
-
]
|
|
1159
|
+
imports: [...EXPORTS],
|
|
1160
|
+
exports: [...EXPORTS],
|
|
1307
1161
|
}]
|
|
1308
1162
|
}] });
|
|
1309
1163
|
|