@tft/interact 21.0.7 → 21.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +317 -22
- package/fesm2022/tft-interact.mjs +221 -386
- package/fesm2022/tft-interact.mjs.map +1 -1
- package/package.json +1 -1
- package/types/tft-interact.d.ts +102 -115
|
@@ -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) {
|
|
@@ -439,26 +412,18 @@ class DragRootDirective {
|
|
|
439
412
|
this.account_for_scale_dir = inject(AccountForScaleDirective, { optional: true, self: true });
|
|
440
413
|
}
|
|
441
414
|
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:
|
|
415
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.6", type: DragRootDirective, isStandalone: true, selector: "[tftDragRoot]", exportAs: ["tftDragRoot"], ngImport: i0 }); }
|
|
443
416
|
}
|
|
444
417
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DragRootDirective, decorators: [{
|
|
445
418
|
type: Directive,
|
|
446
419
|
args: [{
|
|
447
420
|
selector: '[tftDragRoot]',
|
|
448
421
|
exportAs: 'tftDragRoot',
|
|
449
|
-
standalone:
|
|
422
|
+
standalone: true,
|
|
450
423
|
}]
|
|
451
424
|
}] });
|
|
452
425
|
|
|
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
426
|
class AutoScrollDirective {
|
|
461
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
462
427
|
scroll(scrollEvent) {
|
|
463
428
|
const target = scrollEvent.target;
|
|
464
429
|
const { scrollTop, scrollLeft } = target;
|
|
@@ -466,16 +431,13 @@ class AutoScrollDirective {
|
|
|
466
431
|
}
|
|
467
432
|
constructor() {
|
|
468
433
|
this.el = inject(ElementRef);
|
|
469
|
-
|
|
470
|
-
* Limit minimum time between scroll events in milliseconds
|
|
471
|
-
*/
|
|
472
|
-
this.autoScrollConfig = {
|
|
434
|
+
this.autoScrollConfig = input({
|
|
473
435
|
margin: 50,
|
|
474
436
|
distance: 3,
|
|
475
437
|
interval: 50,
|
|
476
438
|
speed: 300,
|
|
477
|
-
enabled: true
|
|
478
|
-
};
|
|
439
|
+
enabled: true,
|
|
440
|
+
}, ...(ngDevMode ? [{ debugName: "autoScrollConfig" }] : []));
|
|
479
441
|
this.scrollDeltaObserver = new Subject();
|
|
480
442
|
const el = this.el;
|
|
481
443
|
const { scrollTop, scrollLeft } = el.nativeElement;
|
|
@@ -489,17 +451,15 @@ class AutoScrollDirective {
|
|
|
489
451
|
this.scrollObserver.subscribe();
|
|
490
452
|
}
|
|
491
453
|
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: "
|
|
454
|
+
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
455
|
}
|
|
494
456
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AutoScrollDirective, decorators: [{
|
|
495
457
|
type: Directive,
|
|
496
458
|
args: [{
|
|
497
459
|
selector: '[tftAutoScroll]',
|
|
498
|
-
standalone:
|
|
460
|
+
standalone: true,
|
|
499
461
|
}]
|
|
500
|
-
}], ctorParameters: () => [], propDecorators: { autoScrollConfig: [{
|
|
501
|
-
type: Input
|
|
502
|
-
}], scroll: [{
|
|
462
|
+
}], ctorParameters: () => [], propDecorators: { autoScrollConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoScrollConfig", required: false }] }], scroll: [{
|
|
503
463
|
type: HostListener,
|
|
504
464
|
args: ['scroll', ['$event']]
|
|
505
465
|
}] } });
|
|
@@ -517,66 +477,61 @@ class DraggableDirective {
|
|
|
517
477
|
this.dropzone_dir = inject(DropzoneDirective, { optional: true, skipSelf: true });
|
|
518
478
|
this.drag_root_dir = inject(DragRootDirective, { optional: true, skipSelf: true });
|
|
519
479
|
this.auto_scroll_dir = inject(AutoScrollDirective, { optional: true, skipSelf: true });
|
|
520
|
-
|
|
521
|
-
this.
|
|
522
|
-
|
|
480
|
+
this.x = input(...(ngDevMode ? [undefined, { debugName: "x" }] : []));
|
|
481
|
+
this.y = input(...(ngDevMode ? [undefined, { debugName: "y" }] : []));
|
|
482
|
+
/** zIndex while dragging */
|
|
483
|
+
this.dragZIndex = input(10000, ...(ngDevMode ? [{ debugName: "dragZIndex" }] : []));
|
|
484
|
+
/** zIndex while at rest */
|
|
485
|
+
this.zIndex = input(...(ngDevMode ? [undefined, { debugName: "zIndex" }] : []));
|
|
486
|
+
this.dragData = input(...(ngDevMode ? [undefined, { debugName: "dragData" }] : []));
|
|
487
|
+
this.enableDragDefault = input(true, ...(ngDevMode ? [{ debugName: "enableDragDefault" }] : []));
|
|
523
488
|
/**
|
|
524
489
|
* @deprecated replaced by 'dragDisabled' property, please migrate before v13
|
|
525
490
|
*/
|
|
526
|
-
this.disabled = false;
|
|
527
|
-
this.dragDisabled = false;
|
|
528
|
-
this.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
491
|
+
this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
492
|
+
this.dragDisabled = input(false, ...(ngDevMode ? [{ debugName: "dragDisabled" }] : []));
|
|
493
|
+
this.dragConfig = input(...(ngDevMode ? [undefined, { debugName: "dragConfig" }] : []));
|
|
494
|
+
this.showPlaceholder = input(false, ...(ngDevMode ? [{ debugName: "showPlaceholder" }] : []));
|
|
495
|
+
/**
|
|
496
|
+
* The element we want to prepend the drag element to.
|
|
497
|
+
* Use `tftDragRoot` directive on a parent element to set custom root element
|
|
498
|
+
* @default document.body
|
|
499
|
+
*/
|
|
500
|
+
this.dragRoot = input(...(ngDevMode ? [undefined, { debugName: "dragRoot" }] : []));
|
|
501
|
+
this.dragStart = output();
|
|
502
|
+
this.dragMove = output();
|
|
503
|
+
this.dragInertiaStart = output();
|
|
504
|
+
this.dragEnd = output();
|
|
505
|
+
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" }] : []));
|
|
506
|
+
effect(() => {
|
|
507
|
+
this.alignPositionWithInputs(this.x(), this.y());
|
|
508
|
+
});
|
|
509
|
+
effect(() => {
|
|
510
|
+
const disabled = this.disabled();
|
|
511
|
+
this.dragConfig();
|
|
512
|
+
this.dragDisabled();
|
|
513
|
+
if (disabled) {
|
|
514
|
+
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`);
|
|
515
|
+
}
|
|
516
|
+
if (!this.interactable)
|
|
517
|
+
return;
|
|
518
|
+
this.setDragConfig();
|
|
519
|
+
});
|
|
538
520
|
}
|
|
539
521
|
ngOnInit() {
|
|
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
|
-
|
|
543
|
-
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
544
|
-
this.registryId = this.dropzone_dir?.dropzoneId || DEFAULT_REGISTRY_ID;
|
|
545
|
-
// add draggable to directory and store its id
|
|
522
|
+
this.interactable = this.initiateDragEvents(this.dragConfig(), this.el.nativeElement);
|
|
523
|
+
this.dragRootEl = (this.dragRoot()?.el?.nativeElement || this.drag_root_dir?.el?.nativeElement) || this._document.body;
|
|
524
|
+
this.registryId = this.dropzone_dir?._registeredId() || DEFAULT_REGISTRY_ID;
|
|
546
525
|
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
|
|
526
|
+
this.alignPositionWithInputs(this.x(), this.y());
|
|
549
527
|
this.interactableState = this.interactService
|
|
550
528
|
.getInteractableState(this.interactableId, this.registryId);
|
|
551
|
-
|
|
552
|
-
this.interactableSubscription = this.interactableState.subscribe((state) => {
|
|
553
|
-
this.y = state.y;
|
|
554
|
-
this.x = state.x;
|
|
555
|
-
});
|
|
529
|
+
this.interactableSubscription = this.interactableState.subscribe();
|
|
556
530
|
this.setDragConfig();
|
|
557
531
|
}
|
|
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
|
-
}
|
|
576
|
-
}
|
|
577
532
|
setDragConfig() {
|
|
578
|
-
const enabled = !(this.disabled || this.dragDisabled);
|
|
579
|
-
const dragConfig = { ...this.dragConfig, enabled };
|
|
533
|
+
const enabled = !(this.disabled() || this.dragDisabled());
|
|
534
|
+
const dragConfig = { ...this.dragConfig(), enabled };
|
|
580
535
|
this.interactable.draggable(dragConfig);
|
|
581
536
|
}
|
|
582
537
|
ngAfterViewInit() {
|
|
@@ -586,20 +541,19 @@ class DraggableDirective {
|
|
|
586
541
|
}
|
|
587
542
|
}
|
|
588
543
|
ngOnDestroy() {
|
|
589
|
-
// clean up state and subscriptions related to destroyed component
|
|
590
544
|
this.interactableSubscription.unsubscribe();
|
|
591
545
|
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
592
546
|
}
|
|
593
547
|
dragMoveListener(event, element) {
|
|
594
548
|
const { dx, dy } = event;
|
|
595
|
-
const scale = this.scale;
|
|
549
|
+
const scale = this.scale();
|
|
596
550
|
const deltaX = scale ? dx / scale : dx;
|
|
597
551
|
const deltaY = scale ? dy / scale : dy;
|
|
598
552
|
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, element);
|
|
599
553
|
}
|
|
600
554
|
setDragStyles(dragElement) {
|
|
601
555
|
this.renderer.setStyle(dragElement, 'touch-action', 'none');
|
|
602
|
-
this.renderer.setStyle(dragElement, 'z-index', this.dragZIndex);
|
|
556
|
+
this.renderer.setStyle(dragElement, 'z-index', this.dragZIndex());
|
|
603
557
|
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
604
558
|
// Prevents highlighting text if dragging over, which will interrupt the next drag action
|
|
605
559
|
this.renderer.setStyle(dragElement, 'user-select', 'none');
|
|
@@ -612,7 +566,7 @@ class DraggableDirective {
|
|
|
612
566
|
mapDragEvent(event) {
|
|
613
567
|
const { target, dropzone } = event;
|
|
614
568
|
const dropzoneElement = dropzone?.target || target.dropTarget?.el.nativeElement;
|
|
615
|
-
const scale = this.scale;
|
|
569
|
+
const scale = this.scale();
|
|
616
570
|
const positionInDropTarget = target && dropzoneElement
|
|
617
571
|
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
|
|
618
572
|
: null;
|
|
@@ -621,14 +575,13 @@ class DraggableDirective {
|
|
|
621
575
|
dragRef: this,
|
|
622
576
|
dragOrigin: target.dragOrigin,
|
|
623
577
|
dropTarget: target.dropTarget,
|
|
624
|
-
positionInDropTarget
|
|
578
|
+
positionInDropTarget,
|
|
625
579
|
};
|
|
626
580
|
}
|
|
627
581
|
setPosition(x, y) {
|
|
628
582
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.el.nativeElement);
|
|
629
583
|
}
|
|
630
584
|
alignPositionWithInputs(x, y) {
|
|
631
|
-
// short circuit if positions aren't numbers or if they haven't changed
|
|
632
585
|
if (!this.isValidPosition(x, y))
|
|
633
586
|
return;
|
|
634
587
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.el.nativeElement);
|
|
@@ -636,27 +589,24 @@ class DraggableDirective {
|
|
|
636
589
|
isValidPosition(x, y) {
|
|
637
590
|
return this.isNumeric(x) && this.isNumeric(y);
|
|
638
591
|
}
|
|
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
592
|
isNumeric(num) {
|
|
642
593
|
return typeof num === 'number' && !isNaN(num);
|
|
643
594
|
}
|
|
644
595
|
initiateDragEvents(dragConfig, nativeElement) {
|
|
645
596
|
const defaultDragConfig = {
|
|
646
597
|
...dragConfig,
|
|
647
|
-
enabled: !(this.disabled || this.dragDisabled),
|
|
598
|
+
enabled: !(this.disabled() || this.dragDisabled()),
|
|
648
599
|
...(this.auto_scroll_dir && {
|
|
649
600
|
autoScroll: {
|
|
650
|
-
...this.auto_scroll_dir.autoScrollConfig,
|
|
651
|
-
container: this.auto_scroll_dir.el.nativeElement
|
|
652
|
-
}
|
|
653
|
-
})
|
|
601
|
+
...this.auto_scroll_dir.autoScrollConfig(),
|
|
602
|
+
container: this.auto_scroll_dir.el.nativeElement,
|
|
603
|
+
},
|
|
604
|
+
}),
|
|
654
605
|
};
|
|
655
606
|
return interact(nativeElement).draggable(defaultDragConfig)
|
|
656
607
|
.on('dragstart', (event) => {
|
|
657
608
|
const interaction = event.interaction;
|
|
658
|
-
|
|
659
|
-
if (this.enableDragDefault && interaction.pointerIsDown) {
|
|
609
|
+
if (this.enableDragDefault() && interaction.pointerIsDown) {
|
|
660
610
|
if (this._previewTemplate) {
|
|
661
611
|
const viewRef = this._viewContainerRef.createEmbeddedView(this._previewTemplate.templateRef);
|
|
662
612
|
this.previewRef = getRootNode(viewRef, this._document);
|
|
@@ -667,26 +617,24 @@ class DraggableDirective {
|
|
|
667
617
|
this.addDragPropertiesToElement(this.previewRef);
|
|
668
618
|
this.setDragStyles(this.previewRef);
|
|
669
619
|
this.dragRootEl.prepend(this.previewRef);
|
|
670
|
-
const scale = this.account_for_scale_dir?.scale || this.dragRoot?.account_for_scale_dir?.scale || 1;
|
|
620
|
+
const scale = this.account_for_scale_dir?.scale() || this.dragRoot()?.account_for_scale_dir?.scale() || 1;
|
|
671
621
|
const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement, scale);
|
|
672
622
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.previewRef);
|
|
673
|
-
if (!this.showPlaceholder) {
|
|
623
|
+
if (!this.showPlaceholder()) {
|
|
674
624
|
this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
|
|
675
625
|
}
|
|
676
626
|
}
|
|
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
627
|
if (this.auto_scroll_dir) {
|
|
679
628
|
this.subscribeToScrollEvents();
|
|
680
629
|
}
|
|
681
630
|
this.dragStart.emit(this.mapDragEvent(event));
|
|
682
631
|
})
|
|
683
632
|
.on('dragmove', (event) => {
|
|
684
|
-
if (this.enableDragDefault) {
|
|
633
|
+
if (this.enableDragDefault()) {
|
|
685
634
|
const dragElement = this.dropzone_dir && this.previewRef || nativeElement;
|
|
686
635
|
this.dragMoveListener(event, dragElement);
|
|
687
636
|
}
|
|
688
|
-
|
|
689
|
-
this.dragMove.emit(mappedEvent);
|
|
637
|
+
this.dragMove.emit(this.mapDragEvent(event));
|
|
690
638
|
})
|
|
691
639
|
.on('draginertiastart', (event) => {
|
|
692
640
|
this.dragInertiaStart.emit(this.mapDragEvent(event));
|
|
@@ -699,12 +647,10 @@ class DraggableDirective {
|
|
|
699
647
|
}
|
|
700
648
|
this.renderer.setStyle(this.el.nativeElement, 'display', '');
|
|
701
649
|
this.dragEnd.emit(mappedEvent);
|
|
702
|
-
// unsubscribe from scroll events if subscribed
|
|
703
650
|
if (this.auto_scroll_dir) {
|
|
704
651
|
this.scrollEventsSubscription.unsubscribe();
|
|
705
652
|
}
|
|
706
653
|
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
654
|
setTimeout(() => {
|
|
709
655
|
this.dragRootEl.removeChild(this.previewRef);
|
|
710
656
|
});
|
|
@@ -713,86 +659,41 @@ class DraggableDirective {
|
|
|
713
659
|
}
|
|
714
660
|
subscribeToScrollEvents() {
|
|
715
661
|
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;
|
|
662
|
+
const deltaX = this.scale() ? scrollLeft / this.scale() : scrollLeft;
|
|
663
|
+
const deltaY = this.scale() ? scrollTop / this.scale() : scrollTop;
|
|
718
664
|
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, this.previewRef);
|
|
719
665
|
});
|
|
720
666
|
}
|
|
721
667
|
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: "
|
|
668
|
+
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
669
|
}
|
|
724
670
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: DraggableDirective, decorators: [{
|
|
725
671
|
type: Directive,
|
|
726
672
|
args: [{
|
|
727
673
|
selector: '[tftDraggable]',
|
|
728
|
-
|
|
674
|
+
standalone: true,
|
|
729
675
|
host: {
|
|
730
|
-
'[style.
|
|
676
|
+
'[style.user-select]': 'dragDisabled() ? "auto" : "none"',
|
|
677
|
+
'[style.touch-action]': 'dragDisabled() ? "auto" : "none"',
|
|
731
678
|
'[style.position]': '"absolute"',
|
|
732
679
|
'[id]': 'interactableId',
|
|
733
680
|
},
|
|
734
|
-
standalone: false
|
|
735
681
|
}]
|
|
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: [{
|
|
682
|
+
}], ctorParameters: () => [], 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
683
|
type: ContentChild,
|
|
770
684
|
args: [DragPreviewDirective]
|
|
771
685
|
}] } });
|
|
772
686
|
/**
|
|
773
687
|
* Component utils
|
|
774
688
|
*/
|
|
775
|
-
// create a clone of the component passed in and add it to the root component
|
|
776
689
|
function cloneElement(element) {
|
|
777
690
|
const clone = element.cloneNode(true);
|
|
778
691
|
clone.removeAttribute('id');
|
|
779
692
|
return clone;
|
|
780
693
|
}
|
|
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
694
|
|
|
791
695
|
/** @dynamic */
|
|
792
696
|
class ResizableDirective {
|
|
793
|
-
get scale() {
|
|
794
|
-
return this.account_for_scale_dir?.scale || this.drag_root_dir?.account_for_scale_dir?.scale;
|
|
795
|
-
}
|
|
796
697
|
constructor() {
|
|
797
698
|
this.el = inject(ElementRef);
|
|
798
699
|
this._document = inject(DOCUMENT);
|
|
@@ -803,77 +704,69 @@ class ResizableDirective {
|
|
|
803
704
|
this.draggable_dir = inject(DraggableDirective, { optional: true });
|
|
804
705
|
this.dropzone_dir = inject(DropzoneDirective, { optional: true, skipSelf: true });
|
|
805
706
|
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.
|
|
707
|
+
this.enableResizeDefault = input(true, ...(ngDevMode ? [{ debugName: "enableResizeDefault" }] : []));
|
|
708
|
+
this.position = input('absolute', ...(ngDevMode ? [{ debugName: "position" }] : []));
|
|
709
|
+
this.resizeConfig = input(...(ngDevMode ? [undefined, { debugName: "resizeConfig" }] : []));
|
|
710
|
+
this.interactableId = input(...(ngDevMode ? [undefined, { debugName: "interactableId" }] : []));
|
|
711
|
+
this.width = input(...(ngDevMode ? [undefined, { debugName: "width" }] : []));
|
|
712
|
+
this.height = input(...(ngDevMode ? [undefined, { debugName: "height" }] : []));
|
|
713
|
+
this.resizeDisabled = input(false, ...(ngDevMode ? [{ debugName: "resizeDisabled" }] : []));
|
|
714
|
+
this.resizeStart = output();
|
|
715
|
+
this.resizeMove = output();
|
|
716
|
+
this.resizeInertiaStart = output();
|
|
717
|
+
this.resizeEnd = output();
|
|
814
718
|
this.defaultConfig = {
|
|
815
|
-
edges: { left: true, right: true, bottom: true, top: true }
|
|
719
|
+
edges: { left: true, right: true, bottom: true, top: true },
|
|
816
720
|
};
|
|
817
721
|
this.activeEdges = { left: false, right: false, top: false, bottom: false };
|
|
818
|
-
|
|
819
|
-
this.dragRootEl = drag_root_dir?.el?.nativeElement || this._document.body;
|
|
722
|
+
this.scale = computed(() => this.account_for_scale_dir?.scale() || this.drag_root_dir?.account_for_scale_dir?.scale(), ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
723
|
+
this.dragRootEl = this.drag_root_dir?.el?.nativeElement || this._document.body;
|
|
724
|
+
effect(() => {
|
|
725
|
+
this.resizeConfig();
|
|
726
|
+
this.resizeDisabled();
|
|
727
|
+
if (!this.interactable)
|
|
728
|
+
return;
|
|
729
|
+
this.interactable.resizable({ ...this.resizeConfig(), enabled: !this.resizeDisabled() });
|
|
730
|
+
});
|
|
731
|
+
effect(() => {
|
|
732
|
+
this.alignDimensionsWithInputs(this.width(), this.height());
|
|
733
|
+
});
|
|
820
734
|
}
|
|
821
735
|
ngOnInit() {
|
|
822
736
|
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);
|
|
737
|
+
this.registryId = this.dropzone_dir?._registeredId() || DEFAULT_REGISTRY_ID;
|
|
738
|
+
this._interactableId = this.draggable_dir?.interactableId || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId());
|
|
739
|
+
this.interactable = this.initiateResizeEvents({ ...this.defaultConfig, ...this.resizeConfig() }, this.el.nativeElement);
|
|
740
|
+
this.alignDimensionsWithInputs(this.width(), this.height());
|
|
830
741
|
this.interactableSubscription = this.interactService
|
|
831
|
-
.getInteractableState(this.
|
|
742
|
+
.getInteractableState(this._interactableId, this.registryId)
|
|
832
743
|
.subscribe();
|
|
833
744
|
}
|
|
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
745
|
ngOnDestroy() {
|
|
843
746
|
this.interactableSubscription.unsubscribe();
|
|
844
|
-
this.interactService.destroyInteractable(this.
|
|
747
|
+
this.interactService.destroyInteractable(this._interactableId, this.registryId);
|
|
845
748
|
}
|
|
846
749
|
resizeListener(event) {
|
|
847
750
|
const element = this.el.nativeElement;
|
|
848
|
-
const scale = this.scale;
|
|
751
|
+
const scale = this.scale();
|
|
849
752
|
const { deltaRect } = event;
|
|
850
753
|
const deltaX = deltaRect.left / scale;
|
|
851
754
|
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
755
|
const rect = element.getBoundingClientRect();
|
|
855
756
|
const width = (rect.width + deltaRect.width) / scale;
|
|
856
757
|
const height = (rect.height + deltaRect.height) / scale;
|
|
857
|
-
this.interactService.updateSize(this.
|
|
758
|
+
this.interactService.updateSize(this._interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
|
|
858
759
|
}
|
|
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
760
|
initiateResizeEvents(resizeConfig, nativeElement) {
|
|
867
|
-
// TODO: This should try and get interactable from tft_draggable if it exists
|
|
868
761
|
const defaultResizeConfig = {
|
|
869
762
|
...resizeConfig,
|
|
870
|
-
enabled: !this.resizeDisabled,
|
|
763
|
+
enabled: !this.resizeDisabled(),
|
|
871
764
|
...(this.auto_scroll_dir && {
|
|
872
765
|
autoScroll: {
|
|
873
|
-
...this.auto_scroll_dir.autoScrollConfig,
|
|
874
|
-
container: this.auto_scroll_dir.el.nativeElement
|
|
875
|
-
}
|
|
876
|
-
})
|
|
766
|
+
...this.auto_scroll_dir.autoScrollConfig(),
|
|
767
|
+
container: this.auto_scroll_dir.el.nativeElement,
|
|
768
|
+
},
|
|
769
|
+
}),
|
|
877
770
|
};
|
|
878
771
|
const interactable = this.draggable_dir?.interactable || interact(nativeElement);
|
|
879
772
|
return interactable.resizable(defaultResizeConfig)
|
|
@@ -885,11 +778,10 @@ class ResizableDirective {
|
|
|
885
778
|
this.resizeStart.emit(this.mapResizeEvent(event));
|
|
886
779
|
})
|
|
887
780
|
.on('resizemove', (event) => {
|
|
888
|
-
if (this.enableResizeDefault) {
|
|
781
|
+
if (this.enableResizeDefault()) {
|
|
889
782
|
this.resizeListener(event);
|
|
890
783
|
}
|
|
891
|
-
|
|
892
|
-
this.resizeMove.emit(mappedEvent);
|
|
784
|
+
this.resizeMove.emit(this.mapResizeEvent(event));
|
|
893
785
|
})
|
|
894
786
|
.on('resizeinertiastart', (event) => this.resizeInertiaStart.emit(this.mapResizeEvent(event)))
|
|
895
787
|
.on('resizeend', (event) => {
|
|
@@ -903,7 +795,7 @@ class ResizableDirective {
|
|
|
903
795
|
mapResizeEvent(event) {
|
|
904
796
|
const target = this.el.nativeElement;
|
|
905
797
|
const relatedTarget = this.draggable_dir?.dropzone_dir?.el.nativeElement;
|
|
906
|
-
const scale = this.scale;
|
|
798
|
+
const scale = this.scale();
|
|
907
799
|
const positionInDropTarget = target && relatedTarget
|
|
908
800
|
? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
|
|
909
801
|
: null;
|
|
@@ -916,19 +808,19 @@ class ResizableDirective {
|
|
|
916
808
|
positionInDropTarget,
|
|
917
809
|
size: {
|
|
918
810
|
width: target.clientWidth / scale,
|
|
919
|
-
height: target.clientHeight / scale
|
|
920
|
-
}
|
|
811
|
+
height: target.clientHeight / scale,
|
|
812
|
+
},
|
|
921
813
|
};
|
|
922
814
|
}
|
|
923
815
|
alignDimensionsWithInputs(width, height) {
|
|
924
|
-
this.interactService.updateSize(this.
|
|
816
|
+
this.interactService.updateSize(this._interactableId, this.registryId, { deltaX: 0, deltaY: 0, width, height }, this.el.nativeElement);
|
|
925
817
|
}
|
|
926
818
|
addResizePropertiesToElement(nativeElement) {
|
|
927
819
|
this.renderer.setProperty(nativeElement, 'resizeRef', this);
|
|
928
820
|
}
|
|
929
821
|
subscribeToScrollEvents() {
|
|
930
822
|
this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(({ scrollLeft, scrollTop }) => {
|
|
931
|
-
const scale = this.scale;
|
|
823
|
+
const scale = this.scale();
|
|
932
824
|
const target = this.el.nativeElement;
|
|
933
825
|
const { width: prevWidth, height: prevHeight } = target.getBoundingClientRect();
|
|
934
826
|
const deltaHeight = scrollTop * (this.activeEdges.top ? -1 : this.activeEdges.bottom ? 1 : 0);
|
|
@@ -937,52 +829,28 @@ class ResizableDirective {
|
|
|
937
829
|
const width = (prevWidth + deltaWidth) / scale;
|
|
938
830
|
const deltaX = this.activeEdges.left ? (scrollLeft / scale) : 0;
|
|
939
831
|
const deltaY = this.activeEdges.top ? (scrollTop / scale) : 0;
|
|
940
|
-
this.interactService.updateSize(this.
|
|
832
|
+
this.interactService.updateSize(this._interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
|
|
941
833
|
});
|
|
942
834
|
}
|
|
943
835
|
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: "
|
|
836
|
+
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
837
|
}
|
|
946
838
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ResizableDirective, decorators: [{
|
|
947
839
|
type: Directive,
|
|
948
840
|
args: [{
|
|
949
841
|
selector: '[tftResizable]',
|
|
842
|
+
standalone: true,
|
|
950
843
|
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
|
951
844
|
host: {
|
|
952
|
-
// prevents touch events from colliding with
|
|
953
|
-
|
|
954
|
-
'[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
|
|
845
|
+
// prevents touch events from colliding with mouse events on touch screen
|
|
846
|
+
'[style.touch-action]': 'resizeDisabled() ? "auto" : "none"',
|
|
955
847
|
// default to absolute here to accommodate likely use cases
|
|
956
|
-
|
|
957
|
-
'[style.position]': 'position',
|
|
848
|
+
'[style.position]': 'position()',
|
|
958
849
|
// follows interactjs suggested practices
|
|
959
|
-
'[style.
|
|
850
|
+
'[style.box-sizing]': '"border-box"',
|
|
960
851
|
},
|
|
961
|
-
standalone: false
|
|
962
852
|
}]
|
|
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
|
-
}] } });
|
|
853
|
+
}], 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
854
|
|
|
987
855
|
/** @dynamic */
|
|
988
856
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -990,35 +858,32 @@ class GesturableDirective {
|
|
|
990
858
|
constructor() {
|
|
991
859
|
this.el = inject(ElementRef);
|
|
992
860
|
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) {
|
|
861
|
+
this.gesturableId = input(...(ngDevMode ? [undefined, { debugName: "gesturableId" }] : []));
|
|
862
|
+
this.gestureDisabled = input(false, ...(ngDevMode ? [{ debugName: "gestureDisabled" }] : []));
|
|
863
|
+
this.gestureConfig = input(...(ngDevMode ? [undefined, { debugName: "gestureConfig" }] : []));
|
|
864
|
+
this.gestureStart = output();
|
|
865
|
+
this.gestureMove = output();
|
|
866
|
+
this.gestureEnd = output();
|
|
867
|
+
effect(() => {
|
|
868
|
+
this.gestureConfig();
|
|
869
|
+
this.gestureDisabled();
|
|
1009
870
|
if (!this.interactable)
|
|
1010
871
|
return;
|
|
1011
872
|
this.setGestureConfig();
|
|
1012
|
-
}
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
ngOnInit() {
|
|
876
|
+
this.interactable = this.initiateGestureEvents(this.gestureConfig(), this.el.nativeElement);
|
|
877
|
+
this.setGestureConfig();
|
|
1013
878
|
}
|
|
1014
879
|
setGestureConfig() {
|
|
1015
|
-
const enabled = !this.gestureDisabled;
|
|
1016
|
-
const gestureConfig = { ...this.gestureConfig, enabled };
|
|
880
|
+
const enabled = !this.gestureDisabled();
|
|
881
|
+
const gestureConfig = { ...this.gestureConfig(), enabled };
|
|
1017
882
|
this.interactable.gesturable(gestureConfig);
|
|
1018
883
|
}
|
|
1019
884
|
initiateGestureEvents(gestureConfig, nativeElement) {
|
|
1020
885
|
const defaultConfig = {
|
|
1021
|
-
enabled: !this.gestureDisabled,
|
|
886
|
+
enabled: !this.gestureDisabled(),
|
|
1022
887
|
};
|
|
1023
888
|
const interactable = this.draggable_dir?.interactable || interact(nativeElement);
|
|
1024
889
|
return interactable.gesturable({ ...defaultConfig, ...gestureConfig })
|
|
@@ -1033,59 +898,38 @@ class GesturableDirective {
|
|
|
1033
898
|
});
|
|
1034
899
|
}
|
|
1035
900
|
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: "
|
|
901
|
+
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
902
|
}
|
|
1038
903
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: GesturableDirective, decorators: [{
|
|
1039
904
|
type: Directive,
|
|
1040
905
|
args: [{
|
|
1041
906
|
selector: '[tftGesturable]',
|
|
1042
|
-
|
|
907
|
+
standalone: true,
|
|
1043
908
|
host: {
|
|
1044
|
-
// '[style.
|
|
1045
|
-
'[id]': 'gesturableId',
|
|
909
|
+
// '[style.touch-action]': 'gestureDisabled() ? "auto" : "none"',
|
|
910
|
+
'[id]': 'gesturableId()',
|
|
1046
911
|
},
|
|
1047
|
-
standalone: false
|
|
1048
912
|
}]
|
|
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
|
-
}] } });
|
|
913
|
+
}], 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
914
|
|
|
1063
915
|
class ApplyScaleDirective {
|
|
1064
916
|
constructor() {
|
|
1065
917
|
this.el = inject(ElementRef);
|
|
1066
|
-
this.
|
|
918
|
+
this.scale = input(1, ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
1067
919
|
}
|
|
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`;
|
|
1072
|
-
}
|
|
1073
|
-
;
|
|
1074
920
|
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: "
|
|
921
|
+
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
922
|
}
|
|
1077
923
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: ApplyScaleDirective, decorators: [{
|
|
1078
924
|
type: Directive,
|
|
1079
925
|
args: [{
|
|
1080
926
|
selector: '[tftApplyScale]',
|
|
1081
|
-
standalone:
|
|
927
|
+
standalone: true,
|
|
928
|
+
host: {
|
|
929
|
+
'[style.font-size]': 'scale() + "px"',
|
|
930
|
+
},
|
|
1082
931
|
}]
|
|
1083
|
-
}], propDecorators: { scale: [{
|
|
1084
|
-
type: Input
|
|
1085
|
-
}], fontSize: [{
|
|
1086
|
-
type: HostBinding,
|
|
1087
|
-
args: ['style.fontSize']
|
|
1088
|
-
}] } });
|
|
932
|
+
}], propDecorators: { scale: [{ type: i0.Input, args: [{ isSignal: true, alias: "scale", required: false }] }] } });
|
|
1089
933
|
|
|
1090
934
|
/**
|
|
1091
935
|
* Directive that handles lasso (drag-to-select) interaction geometry.
|
|
@@ -1108,16 +952,16 @@ class LassoDirective {
|
|
|
1108
952
|
constructor() {
|
|
1109
953
|
this.host = inject((ElementRef));
|
|
1110
954
|
/** Scale factor applied to the host element — used to convert viewport px to container-local px. */
|
|
1111
|
-
this.scale = 1;
|
|
955
|
+
this.scale = input(1, ...(ngDevMode ? [{ debugName: "scale" }] : []));
|
|
1112
956
|
/** When true, lasso interaction is disabled. */
|
|
1113
|
-
this.lassoDisabled = false;
|
|
1114
|
-
/** Emitted on
|
|
1115
|
-
this.lassoStart =
|
|
957
|
+
this.lassoDisabled = input(false, ...(ngDevMode ? [{ debugName: "lassoDisabled" }] : []));
|
|
958
|
+
/** Emitted on pointerdown (before any drag). Use to clear previous selection state. */
|
|
959
|
+
this.lassoStart = output();
|
|
1116
960
|
/**
|
|
1117
|
-
* Emitted on
|
|
961
|
+
* Emitted on pointerup when the drag exceeded the 5 px threshold.
|
|
1118
962
|
* Rect is in viewport (clientX/Y) space — pass directly to getBoundingClientRect comparisons.
|
|
1119
963
|
*/
|
|
1120
|
-
this.lassoCommit =
|
|
964
|
+
this.lassoCommit = output();
|
|
1121
965
|
// -------------------------------------------------------------------------
|
|
1122
966
|
// Internal state
|
|
1123
967
|
// -------------------------------------------------------------------------
|
|
@@ -1150,15 +994,15 @@ class LassoDirective {
|
|
|
1150
994
|
toLocal(vpX, vpY) {
|
|
1151
995
|
const rect = this.host.nativeElement.getBoundingClientRect();
|
|
1152
996
|
return {
|
|
1153
|
-
x: (vpX - rect.left) / this.scale,
|
|
1154
|
-
y: (vpY - rect.top) / this.scale,
|
|
997
|
+
x: (vpX - rect.left) / this.scale(),
|
|
998
|
+
y: (vpY - rect.top) / this.scale(),
|
|
1155
999
|
};
|
|
1156
1000
|
}
|
|
1157
1001
|
// -------------------------------------------------------------------------
|
|
1158
1002
|
// Event handling
|
|
1159
1003
|
// -------------------------------------------------------------------------
|
|
1160
1004
|
onPointerDown(e) {
|
|
1161
|
-
if (this.lassoDisabled)
|
|
1005
|
+
if (this.lassoDisabled())
|
|
1162
1006
|
return;
|
|
1163
1007
|
if (e.target !== e.currentTarget)
|
|
1164
1008
|
return; // ignore clicks on children
|
|
@@ -1208,27 +1052,19 @@ class LassoDirective {
|
|
|
1208
1052
|
}
|
|
1209
1053
|
}
|
|
1210
1054
|
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: "
|
|
1055
|
+
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
1056
|
}
|
|
1213
1057
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: LassoDirective, decorators: [{
|
|
1214
1058
|
type: Directive,
|
|
1215
1059
|
args: [{
|
|
1216
1060
|
selector: '[tftLasso]',
|
|
1217
1061
|
exportAs: 'tftLasso',
|
|
1218
|
-
standalone:
|
|
1062
|
+
standalone: true,
|
|
1219
1063
|
host: {
|
|
1220
|
-
'[style.touch-action]': 'lassoDisabled ? "auto" : "none"',
|
|
1064
|
+
'[style.touch-action]': 'lassoDisabled() ? "auto" : "none"',
|
|
1221
1065
|
},
|
|
1222
1066
|
}]
|
|
1223
|
-
}], propDecorators: { scale: [{
|
|
1224
|
-
type: Input
|
|
1225
|
-
}], lassoDisabled: [{
|
|
1226
|
-
type: Input
|
|
1227
|
-
}], lassoStart: [{
|
|
1228
|
-
type: Output
|
|
1229
|
-
}], lassoCommit: [{
|
|
1230
|
-
type: Output
|
|
1231
|
-
}], onPointerDown: [{
|
|
1067
|
+
}], 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
1068
|
type: HostListener,
|
|
1233
1069
|
args: ['pointerdown', ['$event']]
|
|
1234
1070
|
}], onPointerMove: [{
|
|
@@ -1258,6 +1094,11 @@ const EXPORTS = [
|
|
|
1258
1094
|
LassoDirective,
|
|
1259
1095
|
ArrayOfNPipe,
|
|
1260
1096
|
];
|
|
1097
|
+
/**
|
|
1098
|
+
* @deprecated All directives are now standalone. Import them directly instead of using InteractModule.
|
|
1099
|
+
* InteractModule will be removed in the next major version.
|
|
1100
|
+
* `InteractModule.forRoot()` is still supported for providing InteractService configuration.
|
|
1101
|
+
*/
|
|
1261
1102
|
class InteractModule {
|
|
1262
1103
|
static forRoot(config) {
|
|
1263
1104
|
const defaultConfig = { cssDimensionUnit: 'px' };
|
|
@@ -1265,12 +1106,12 @@ class InteractModule {
|
|
|
1265
1106
|
ngModule: InteractModule,
|
|
1266
1107
|
providers: [
|
|
1267
1108
|
{ provide: INTERACT_ROOT_CONFIG, useValue: { ...defaultConfig, ...config } },
|
|
1268
|
-
InteractService
|
|
1269
|
-
]
|
|
1109
|
+
InteractService,
|
|
1110
|
+
],
|
|
1270
1111
|
};
|
|
1271
1112
|
}
|
|
1272
1113
|
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,
|
|
1114
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.6", ngImport: i0, type: InteractModule, imports: [DraggableDirective,
|
|
1274
1115
|
ResizableDirective,
|
|
1275
1116
|
DropzoneDirective,
|
|
1276
1117
|
GesturableDirective,
|
|
@@ -1280,7 +1121,7 @@ class InteractModule {
|
|
|
1280
1121
|
ApplyScaleDirective,
|
|
1281
1122
|
DragPreviewDirective,
|
|
1282
1123
|
LassoDirective,
|
|
1283
|
-
ArrayOfNPipe],
|
|
1124
|
+
ArrayOfNPipe], exports: [DraggableDirective,
|
|
1284
1125
|
ResizableDirective,
|
|
1285
1126
|
DropzoneDirective,
|
|
1286
1127
|
GesturableDirective,
|
|
@@ -1291,19 +1132,13 @@ class InteractModule {
|
|
|
1291
1132
|
DragPreviewDirective,
|
|
1292
1133
|
LassoDirective,
|
|
1293
1134
|
ArrayOfNPipe] }); }
|
|
1294
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule
|
|
1135
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule }); }
|
|
1295
1136
|
}
|
|
1296
1137
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: InteractModule, decorators: [{
|
|
1297
1138
|
type: NgModule,
|
|
1298
1139
|
args: [{
|
|
1299
|
-
imports: [
|
|
1300
|
-
|
|
1301
|
-
declarations: [
|
|
1302
|
-
...EXPORTS,
|
|
1303
|
-
],
|
|
1304
|
-
exports: [
|
|
1305
|
-
...EXPORTS
|
|
1306
|
-
]
|
|
1140
|
+
imports: [...EXPORTS],
|
|
1141
|
+
exports: [...EXPORTS],
|
|
1307
1142
|
}]
|
|
1308
1143
|
}] });
|
|
1309
1144
|
|