@tft/interact 12.4.3 → 12.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/bundles/tft-interact.umd.js +65 -74
  2. package/bundles/tft-interact.umd.js.map +1 -1
  3. package/esm2015/lib/directives/account-for-scale.directive.js +3 -11
  4. package/esm2015/lib/directives/account-for-scale.directive.js.map +1 -1
  5. package/esm2015/lib/directives/account-for-scale.directive.metadata.json +1 -1
  6. package/esm2015/lib/directives/apply-scale.directive.js +4 -13
  7. package/esm2015/lib/directives/apply-scale.directive.js.map +1 -1
  8. package/esm2015/lib/directives/apply-scale.directive.metadata.json +1 -1
  9. package/esm2015/lib/directives/drag-root.directive.js +8 -11
  10. package/esm2015/lib/directives/drag-root.directive.js.map +1 -1
  11. package/esm2015/lib/directives/drag-root.directive.metadata.json +1 -1
  12. package/esm2015/lib/directives/draggable.directive.js +8 -9
  13. package/esm2015/lib/directives/draggable.directive.js.map +1 -1
  14. package/esm2015/lib/directives/draggable.directive.metadata.json +1 -1
  15. package/esm2015/lib/directives/dropzone.directive.js +2 -5
  16. package/esm2015/lib/directives/dropzone.directive.js.map +1 -1
  17. package/esm2015/lib/directives/index.js.map +1 -1
  18. package/esm2015/lib/interact.module.js +13 -0
  19. package/esm2015/lib/interact.module.js.map +1 -1
  20. package/esm2015/lib/interact.module.metadata.json +1 -1
  21. package/esm2015/lib/models/interact.js +2 -0
  22. package/esm2015/lib/models/interact.js.map +1 -1
  23. package/esm2015/lib/models/interact.metadata.json +1 -1
  24. package/esm2015/lib/services/interact.service.js +30 -23
  25. package/esm2015/lib/services/interact.service.js.map +1 -1
  26. package/esm2015/lib/services/interact.service.metadata.json +1 -1
  27. package/fesm2015/tft-interact.js +65 -71
  28. package/fesm2015/tft-interact.js.map +1 -1
  29. package/lib/directives/account-for-scale.directive.d.ts +1 -3
  30. package/lib/directives/apply-scale.directive.d.ts +4 -7
  31. package/lib/directives/drag-root.directive.d.ts +2 -1
  32. package/lib/directives/draggable.directive.d.ts +2 -1
  33. package/lib/directives/dropzone.directive.d.ts +4 -4
  34. package/lib/interact.module.d.ts +3 -0
  35. package/lib/models/interact.d.ts +6 -0
  36. package/lib/services/interact.service.d.ts +4 -5
  37. package/package.json +1 -1
  38. package/tft-interact-12.5.0.tgz +0 -0
  39. package/tft-interact.metadata.json +1 -1
  40. package/tft-interact-12.4.3.tgz +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"interact.service.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/services/interact.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAa,gBAAgB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,eAAe,EAAc,aAAa,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAEL,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAChE,MAAM,WAAW,CAAC;;AAGnB,MAAM,OAAO,eAAe;IAS1B,YACU,eAAiC,EACjC,MAAc;QADd,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAQ;QAThB,uBAAkB,GAAG,CAAC,CAAC;QACvB,mBAAc,GAAG,CAAC,CAAC;QAG3B,gCAAgC;QACvB,uBAAkB,GAA4C,EAAG,CAAC;QAMzE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,kBAAkB,CAAC,KAAY,EAAE,QAAkB;QACjD,OAAO;YACL,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;YAC5B,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;YAC5B,aAAa,EAAE,QAAQ,CAAC,aAAa,IAAI,K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,MAAM,IAAI,CAAC,CAAC;SAC1E;aAAM;YACL,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;YACjE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;SACjE;IACH,CAAC;IACD;;;;;OAKG;IACH,qBAAqB,CAAC,CAAS,EAAE,CAAS;QACxC,OAAO,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAA;IACzC,CAAC;IAED,0BAA0B,CAAC,WAA6B,EAAE,WAA2B,EAAE,KAA8B;QACnH,qGAAqG;QACrG,MAAM,QAAQ,GAAG,WAAW,CAAC,qBAAqB,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,WAAW,CAAC,qBAAqB,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,KAAK;YACpB,CAAC,CAAC;gBACF,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,IAAK,CAAC;gBAClD,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC;aAC9C,CAAC,CAAC,CAAC;YACF,CAAC,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI;YAChC,CAAC,EAAE,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG;SACjC,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;;;;YAjNF,UAAU,SAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;;YARA,gBAAgB;YAAE,MAAM","sourcesContent":["\nimport { Injectable, Renderer2, RendererFactory2, NgZone } from '@angular/core';\nimport { BehaviorSubject, Observable, combineLatest } from 'rxjs';\nimport { tap, map, shareReplay } from 'rxjs/operators';\nimport {\n TftCoords, Delta, Size, Position, InteractableRegistry,\n defaultPosition, defaultSize, defaultDelta, DEFAULT_REGISTRY_ID, TftDragElement, TftResizeElement\n} from '../models';\n\n@Injectable({providedIn: 'root'})\nexport class InteractService {\n\n private _interactableIndex = 0;\n private _dropzoneIndex = 0;\n private renderer: Renderer2;\n\n // TODO: consider using Map here\n readonly dragRegistrySystem: { [key: string]: InteractableRegistry } = { };\n\n constructor(\n private rendererFactory: RendererFactory2,\n private ngZone: NgZone\n ) {\n this.renderer = this.rendererFactory.createRenderer(null, null);\n }\n\n addDeltaToPosition(delta: Delta, position: Position) {\n return {\n x: delta.deltaX + position.x,\n y: delta.deltaY + position.y,\n targetElement: position.targetElement || delta.targetElement\n }\n }\n\n addRegistryToSystem(customRegistryId: string | null = null) {\n const registryId = customRegistryId || this.createDropzoneId(this._dropzoneIndex++);\n this.dragRegistrySystem[registryId] = {};\n return registryId;\n }\n\n addDraggableToRegistry(customRegistryId = null, interactableId: string | null = null ) {\n const registryId = customRegistryId || DEFAULT_REGISTRY_ID;\n // if we pass an id to createInteractableId then it is used when creating the interactable\n // and returned, otherwise a an id is created for the draggable.\n const key = this.createInteractableId(interactableId );\n if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {\n this.dragRegistrySystem[registryId] = {};\n }\n this.dragRegistrySystem[registryId][key] = this.createInteractableState(defaultPosition, defaultSize, defaultDelta);\n return key\n }\n\n destroyInteractable(interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n if(this.dragRegistrySystem[registryId][interactableId]) {\n delete this.dragRegistrySystem[registryId][interactableId];\n }\n }\n\n subscribeToInteractable(interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem[registryId][interactableId];\n }\n\n createInteractableState(initialPosition: Position, initialSize: Size, initialDelta: Delta ) {\n\n const deltas$ = new BehaviorSubject(initialDelta);\n // tracks the size of the element\n const size$ = new BehaviorSubject({...initialSize, ...initialDelta});\n // Stream of positions as they change\n const position$ = new BehaviorSubject(initialPosition);\n\n // All draggable data mapped together\n const interactable$: Observable<TftCoords> = combineLatest([\n size$.pipe(\n // startWith({...initialSize, ...initialDelta}),\n shareReplay(1),\n // filter(resizeEvent => !!resizeEvent.targetElement),\n tap(({deltaX, deltaY, width, height, targetElement}) => {\n this.ngZone.runOutsideAngular(() => {\n this.setElementSize(width, height, targetElement);\n });\n // only reposition if necessary i.e when resizing left or up\n if(deltaX || deltaY) {\n deltas$.next({deltaX, deltaY, targetElement});\n }\n })\n ),\n deltas$.pipe(\n shareReplay(1),\n tap((delta) => {\n const position = position$.value;\n const newPosition = this.addDeltaToPosition(delta, position);\n position$.next(newPosition);\n })\n ),\n position$.pipe(\n shareReplay(1),\n tap( position => {\n this.ngZone.runOutsideAngular(() => {\n this.setElementTransform(position.x, position.y, position);\n })\n })\n )\n ]).pipe(\n shareReplay(1),\n map( ([size, deltas, position]): TftCoords=> {\n return {\n x: position.x,\n y: position.y,\n deltaX: deltas.deltaX,\n deltaY: deltas.deltaY,\n width: size.width,\n height: size.height,\n targetElement: size.targetElement || position.targetElement || deltas.targetElement\n }\n }),\n )\n // TODO: update system to handle only returning interactable$\n return {\n deltas$,\n position$,\n size$,\n interactable$\n }\n }\n\n createInteractableId(customInteractableId: string | null = null) {\n return customInteractableId || `interactable${this._interactableIndex++}`\n }\n\n createDropzoneId(index: number) {\n return `dropzone${index}`\n }\n\n getInteractableState( interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem[registryId][interactableId].interactable$;\n }\n\n updateDeltas(interactId: string, registryId: string, { deltaX, deltaY }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return;\n this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX, deltaY, targetElement })\n }\n\n updatePosition(interactId: string, registryId: string, { x, y }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return;\n this.dragRegistrySystem[registryId][interactId].position$.next({ x, y, targetElement })\n }\n\n updateSize(interactId: string, registryId: string, { deltaX, deltaY, width, height }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return\n this.dragRegistrySystem[registryId][interactId].size$.next({deltaX, deltaY, width, height, targetElement});\n }\n\n interactableExistOnRegistry(interactId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem.hasOwnProperty(registryId)\n && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);\n }\n /**\n * Uses renderer to set width and height of angular component\n * @param width the desired width of component\n * @param height the desired height of component\n * @param target the element to transform\n */\n setElementSize(width: number, height: number, target: TftResizeElement) {\n if(!target) return;\n\n const accountForScaleDirective = target.resizeRef?.account_for_scale_dir\n if (accountForScaleDirective) {\n const { scaleX, scaleY } = accountForScaleDirective\n const scaledWidth = width / scaleX;\n const scaledHeight = height / scaleY;\n this.renderer.setStyle(target, 'width', `${scaledWidth}px`);\n this.renderer.setStyle(target, 'height', `${scaledHeight}px`);\n } else {\n this.renderer.setStyle(target, 'width', `${width}px`);\n this.renderer.setStyle(target, 'height', `${height}px`);\n }\n }\n /**\n * Uses renderer to set position of angular component\n * @param x position on x axis\n * @param y position on y axis\n * @param target the element to transform\n */\n setElementTransform(x: number, y: number, position: Position ) {\n if(!position?.targetElement) return;\n const accountForScaleDirective = position.targetElement?.dragRef?.account_for_scale_dir\n if (accountForScaleDirective) {\n const {scaleX, scaleY} = accountForScaleDirective;\n this.renderer.setStyle(position.targetElement, 'left', `${x / scaleX}px`);\n this.renderer.setStyle(position.targetElement, 'top', `${y / scaleY}px`);\n } else {\n this.renderer.setStyle(position.targetElement, 'left', `${x}px`);\n this.renderer.setStyle(position.targetElement, 'top', `${y}px`);\n }\n }\n /**\n * Generates a translate string for the x and y arguments passed to\n * be passed to css transform\n * @param x the position along the x axis\n * @param y the position along the y axis\n */\n createTransformString(x: number, y: number) {\n return `translate3d(${x}px, ${y}px, 0)`\n }\n\n calculatePositionInElement(zoneElement: Interact.Element, dragElement: TftDragElement, scale?: {x: number, y: number}) {\n // TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements\n const zoneRect = zoneElement.getBoundingClientRect();\n const dragRect = dragElement.getBoundingClientRect();\n const position = scale\n ? {\n x: (dragRect.left - zoneRect.left) / scale.x || 1,\n y: (dragRect.top - zoneRect.top) / scale.y || 1\n } : {\n x: dragRect.left - zoneRect.left,\n y: dragRect.top - zoneRect.top\n };\n return position;\n }\n}\n"]}
1
+ {"version":3,"file":"interact.service.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/services/interact.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAa,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAkB,QAAQ,EAAiB,MAAM,eAAe,CAAC;AACjI,OAAO,EAAE,eAAe,EAAc,aAAa,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAEL,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAoC,oBAAoB,EACxH,MAAM,WAAW,CAAC;;;AAKnB,MAAM,OAAO,eAAe;IAS1B,YACU,eAAiC,EACjC,MAAc,EAC2B,UAAU;QAFnD,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAQ;QAC2B,eAAU,GAAV,UAAU,CAAA;QAVrD,uBAAkB,GAAG,CAAC,CAAC;QACvB,mBAAc,GAAG,CAAC,CAAC;QAG3B,gCAAgC;QACvB,uBAAkB,GAA4C,EAAG,CAAC;QACnE,YAAO,GAAG,IAAI,CAAA;QAMpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO,GAAG,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,gBAAgB,KAAI,IAAI,CAAC;IACtD,CAAC;IAED,k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AQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,IAAK,CAAC;gBAChD,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC;aAC5C,CAAC,CAAC,CAAC;YACF,CAAC,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI;YAChC,CAAC,EAAE,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG;SACjC,CAAC;QACF,oEAAoE;QACpE,OAAO,QAAQ,CAAC;IAClB,CAAC;;;;YApNF,UAAU,SAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;;YAVA,gBAAgB;YAAE,MAAM;4CAuBnD,QAAQ,YAAI,MAAM,SAAC,oBAAoB","sourcesContent":["\nimport { Injectable, Renderer2, RendererFactory2, NgZone, Inject, InjectionToken, Optional, AfterViewInit } from '@angular/core';\nimport { BehaviorSubject, Observable, combineLatest } from 'rxjs';\nimport { tap, map, shareReplay } from 'rxjs/operators';\nimport {\n TftCoords, Delta, Size, Position, InteractableRegistry,\n defaultPosition, defaultSize, defaultDelta, DEFAULT_REGISTRY_ID, TftDragElement, TftResizeElement, INTERACT_ROOT_CONFIG, InteractRootConfig\n} from '../models';\n\n\n\n@Injectable({providedIn: 'root'})\nexport class InteractService {\n\n private _interactableIndex = 0;\n private _dropzoneIndex = 0;\n private renderer: Renderer2;\n\n // TODO: consider using Map here\n readonly dragRegistrySystem: { [key: string]: InteractableRegistry } = { };\n private cssUnit = 'px'\n constructor(\n private rendererFactory: RendererFactory2,\n private ngZone: NgZone,\n @Optional() @Inject(INTERACT_ROOT_CONFIG) public rootConfig\n ) {\n this.renderer = this.rendererFactory.createRenderer(null, null);\n this.cssUnit = rootConfig?.cssDimensionUnit || 'px';\n }\n\n addDeltaToPosition(delta: Delta, position: Position) {\n return {\n x: delta.deltaX + position.x,\n y: delta.deltaY + position.y,\n targetElement: position.targetElement || delta.targetElement\n }\n }\n\n addRegistryToSystem(customRegistryId: string | null = null) {\n const registryId = customRegistryId || this.createDropzoneId(this._dropzoneIndex++);\n this.dragRegistrySystem[registryId] = {};\n return registryId;\n }\n\n addDraggableToRegistry(customRegistryId = null, interactableId: string | null = null ) {\n const registryId = customRegistryId || DEFAULT_REGISTRY_ID;\n // if we pass an id to createInteractableId then it is used when creating the interactable\n // and returned, otherwise a an id is created for the draggable.\n const key = this.createInteractableId(interactableId );\n if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {\n this.dragRegistrySystem[registryId] = {};\n }\n this.dragRegistrySystem[registryId][key] = this.createInteractableState(defaultPosition, defaultSize, defaultDelta);\n return key\n }\n\n destroyInteractable(interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n if(this.dragRegistrySystem[registryId][interactableId]) {\n delete this.dragRegistrySystem[registryId][interactableId];\n }\n }\n\n subscribeToInteractable(interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem[registryId][interactableId];\n }\n\n createInteractableState(initialPosition: Position, initialSize: Size, initialDelta: Delta ) {\n\n const deltas$ = new BehaviorSubject(initialDelta);\n // tracks the size of the element\n const size$ = new BehaviorSubject({...initialSize, ...initialDelta});\n // Stream of positions as they change\n const position$ = new BehaviorSubject(initialPosition);\n\n // All draggable data mapped together\n const interactable$: Observable<TftCoords> = combineLatest([\n size$.pipe(\n // startWith({...initialSize, ...initialDelta}),\n shareReplay(1),\n // filter(resizeEvent => !!resizeEvent.targetElement),\n tap(({deltaX, deltaY, width, height, targetElement}) => {\n this.ngZone.runOutsideAngular(() => {\n this.setElementSize(width, height, targetElement);\n });\n // only reposition if necessary i.e when resizing left or up\n if(deltaX || deltaY) {\n deltas$.next({deltaX, deltaY, targetElement});\n }\n })\n ),\n deltas$.pipe(\n shareReplay(1),\n tap((delta) => {\n const position = position$.value;\n const newPosition = this.addDeltaToPosition(delta, position);\n position$.next(newPosition);\n })\n ),\n position$.pipe(\n shareReplay(1),\n tap( position => {\n this.ngZone.runOutsideAngular(() => {\n this.setElementTransform(position.x, position.y, position);\n })\n })\n )\n ]).pipe(\n shareReplay(1),\n map( ([size, deltas, position]): TftCoords=> {\n return {\n x: position.x,\n y: position.y,\n deltaX: deltas.deltaX,\n deltaY: deltas.deltaY,\n width: size.width,\n height: size.height,\n targetElement: size.targetElement || position.targetElement || deltas.targetElement\n }\n }),\n )\n // TODO: update system to handle only returning interactable$\n return {\n deltas$,\n position$,\n size$,\n interactable$\n }\n }\n\n createInteractableId(customInteractableId: string | null = null) {\n return customInteractableId || `interactable${this._interactableIndex++}`\n }\n\n createDropzoneId(index: number) {\n return `dropzone${index}`\n }\n\n getInteractableState( interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem[registryId][interactableId].interactable$;\n }\n\n updateDeltas(interactId: string, registryId: string, { deltaX, deltaY }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return;\n this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX, deltaY, targetElement })\n }\n\n updatePosition(interactId: string, registryId: string, { x, y }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return;\n this.dragRegistrySystem[registryId][interactId].position$.next({ x, y, targetElement })\n }\n\n updateSize(interactId: string, registryId: string, { deltaX, deltaY, width, height }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return\n this.dragRegistrySystem[registryId][interactId].size$.next({deltaX, deltaY, width, height, targetElement});\n }\n\n interactableExistOnRegistry(interactId: string, registryId = DEFAULT_REGISTRY_ID) {\n // eslint-disable-next-line no-prototype-builtins\n return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);\n }\n /**\n * Uses renderer to set width and height of angular component\n * @param width the desired width of component\n * @param height the desired height of component\n * @param target the element to transform\n */\n setElementSize(width: number, height: number, target: TftResizeElement) {\n if(!target) return;\n const accountForScaleDirective = target.resizeRef?.account_for_scale_dir\n if (accountForScaleDirective) {\n const { scale } = accountForScaleDirective\n const scaledWidth = width / scale;\n const scaledHeight = height / scale;\n this.renderer.setStyle(target, 'width', `${scaledWidth}${this.cssUnit}`);\n this.renderer.setStyle(target, 'height', `${scaledHeight}${this.cssUnit}`);\n } else {\n this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);\n this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);\n }\n }\n /**\n * Uses renderer to set position of angular component\n * @param x position on x axis\n * @param y position on y axis\n * @param target the element to transform\n */\n setElementTransform(x: number, y: number, position: Position ) {\n if(!position?.targetElement) return;\n const dragRef = position.targetElement?.dragRef;\n const accountForScaleDirective = dragRef?.account_for_scale_dir || dragRef?.dragRoot?.account_for_scale_dir\n if (accountForScaleDirective) {\n const {scale} = accountForScaleDirective;\n this.renderer.setStyle(position.targetElement, 'left', `${x / scale}${this.cssUnit}`);\n this.renderer.setStyle(position.targetElement, 'top', `${y / scale}${this.cssUnit}`);\n } else {\n this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);\n this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);\n }\n }\n /**\n * Generates a translate string for the x and y arguments passed to\n * be passed to css transform\n * @param x the position along the x axis\n * @param y the position along the y axis\n */\n createTransformString(x: number, y: number) {\n return `translate3d(${x}${this.cssUnit}, ${y}${this.cssUnit}, 0)`\n }\n\n calculatePositionInElement(zoneElement: Interact.Element, dragElement: TftDragElement, scale?: number) {\n // TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements\n const zoneRect = zoneElement.getBoundingClientRect();\n const dragRect = dragElement.getBoundingClientRect();\n const position = scale\n ? {\n x: (dragRect.left - zoneRect.left) / scale || 1,\n y: (dragRect.top - zoneRect.top) / scale || 1\n } : {\n x: dragRect.left - zoneRect.left,\n y: dragRect.top - zoneRect.top\n };\n // console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})\n return position;\n }\n}\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"InteractService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":9,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"RendererFactory2","line":20,"character":29},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":21,"character":20}]}],"addDeltaToPosition":[{"__symbolic":"method"}],"addRegistryToSystem":[{"__symbolic":"method"}],"addDraggableToRegistry":[{"__symbolic":"method"}],"destroyInteractable":[{"__symbolic":"method"}],"subscribeToInteractable":[{"__symbolic":"method"}],"createInteractableState":[{"__symbolic":"method"}],"createInteractableId":[{"__symbolic":"method"}],"createDropzoneId":[{"__symbolic":"method"}],"getInteractableState":[{"__symbolic":"method"}],"updateDeltas":[{"__symbolic":"method"}],"updatePosition":[{"__symbolic":"method"}],"updateSize":[{"__symbolic":"method"}],"interactableExistOnRegistry":[{"__symbolic":"method"}],"setElementSize":[{"__symbolic":"method"}],"setElementTransform":[{"__symbolic":"method"}],"createTransformString":[{"__symbolic":"method"}],"calculatePositionInElement":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"InteractService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":11,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":24,"character":5}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":24,"character":17},"arguments":[{"__symbolic":"reference","module":"../models","name":"INTERACT_ROOT_CONFIG","line":24,"character":24}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"RendererFactory2","line":22,"character":29},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":23,"character":20},null]}],"addDeltaToPosition":[{"__symbolic":"method"}],"addRegistryToSystem":[{"__symbolic":"method"}],"addDraggableToRegistry":[{"__symbolic":"method"}],"destroyInteractable":[{"__symbolic":"method"}],"subscribeToInteractable":[{"__symbolic":"method"}],"createInteractableState":[{"__symbolic":"method"}],"createInteractableId":[{"__symbolic":"method"}],"createDropzoneId":[{"__symbolic":"method"}],"getInteractableState":[{"__symbolic":"method"}],"updateDeltas":[{"__symbolic":"method"}],"updatePosition":[{"__symbolic":"method"}],"updateSize":[{"__symbolic":"method"}],"interactableExistOnRegistry":[{"__symbolic":"method"}],"setElementSize":[{"__symbolic":"method"}],"setElementTransform":[{"__symbolic":"method"}],"createTransformString":[{"__symbolic":"method"}],"calculatePositionInElement":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}}}]
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Pipe, Injectable, RendererFactory2, NgZone, Directive, ElementRef, Input, EventEmitter, Renderer2, Optional, Output, InjectionToken, TemplateRef, Self, ViewContainerRef, Inject, SkipSelf, ContentChild, HostBinding, NgModule } from '@angular/core';
2
+ import { Pipe, InjectionToken, Injectable, RendererFactory2, NgZone, Optional, Inject, Directive, ElementRef, Input, EventEmitter, Renderer2, Output, TemplateRef, Self, ViewContainerRef, SkipSelf, ContentChild, HostBinding, NgModule } from '@angular/core';
3
3
  import { DOCUMENT, CommonModule } from '@angular/common';
4
4
  import interact from 'interactjs';
5
5
  import { BehaviorSubject, combineLatest } from 'rxjs';
@@ -22,6 +22,7 @@ ArrayOfNPipe.decorators = [
22
22
  },] }
23
23
  ];
24
24
 
25
+ const INTERACT_ROOT_CONFIG = new InjectionToken('INTERACT_ROOT_CONFIG_PARAMS');
25
26
  const DEFAULT_REGISTRY_ID = 'DEFAULT';
26
27
  /**
27
28
  * Default initial value for Delta BehaviorSubject
@@ -49,14 +50,17 @@ const defaultPosition = {
49
50
  };
50
51
 
51
52
  class InteractService {
52
- constructor(rendererFactory, ngZone) {
53
+ constructor(rendererFactory, ngZone, rootConfig) {
53
54
  this.rendererFactory = rendererFactory;
54
55
  this.ngZone = ngZone;
56
+ this.rootConfig = rootConfig;
55
57
  this._interactableIndex = 0;
56
58
  this._dropzoneIndex = 0;
57
59
  // TODO: consider using Map here
58
60
  this.dragRegistrySystem = {};
61
+ this.cssUnit = 'px';
59
62
  this.renderer = this.rendererFactory.createRenderer(null, null);
63
+ this.cssUnit = (rootConfig === null || rootConfig === void 0 ? void 0 : rootConfig.cssDimensionUnit) || 'px';
60
64
  }
61
65
  addDeltaToPosition(delta, position) {
62
66
  return {
@@ -164,8 +168,8 @@ class InteractService {
164
168
  this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX, deltaY, width, height, targetElement });
165
169
  }
166
170
  interactableExistOnRegistry(interactId, registryId = DEFAULT_REGISTRY_ID) {
167
- return this.dragRegistrySystem.hasOwnProperty(registryId)
168
- && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
171
+ // eslint-disable-next-line no-prototype-builtins
172
+ return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
169
173
  }
170
174
  /**
171
175
  * Uses renderer to set width and height of angular component
@@ -179,15 +183,15 @@ class InteractService {
179
183
  return;
180
184
  const accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
181
185
  if (accountForScaleDirective) {
182
- const { scaleX, scaleY } = accountForScaleDirective;
183
- const scaledWidth = width / scaleX;
184
- const scaledHeight = height / scaleY;
185
- this.renderer.setStyle(target, 'width', `${scaledWidth}px`);
186
- this.renderer.setStyle(target, 'height', `${scaledHeight}px`);
186
+ const { scale } = accountForScaleDirective;
187
+ const scaledWidth = width / scale;
188
+ const scaledHeight = height / scale;
189
+ this.renderer.setStyle(target, 'width', `${scaledWidth}${this.cssUnit}`);
190
+ this.renderer.setStyle(target, 'height', `${scaledHeight}${this.cssUnit}`);
187
191
  }
188
192
  else {
189
- this.renderer.setStyle(target, 'width', `${width}px`);
190
- this.renderer.setStyle(target, 'height', `${height}px`);
193
+ this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);
194
+ this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);
191
195
  }
192
196
  }
193
197
  /**
@@ -200,15 +204,16 @@ class InteractService {
200
204
  var _a, _b;
201
205
  if (!(position === null || position === void 0 ? void 0 : position.targetElement))
202
206
  return;
203
- const accountForScaleDirective = (_b = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir;
207
+ const dragRef = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef;
208
+ const accountForScaleDirective = (dragRef === null || dragRef === void 0 ? void 0 : dragRef.account_for_scale_dir) || ((_b = dragRef === null || dragRef === void 0 ? void 0 : dragRef.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir);
204
209
  if (accountForScaleDirective) {
205
- const { scaleX, scaleY } = accountForScaleDirective;
206
- this.renderer.setStyle(position.targetElement, 'left', `${x / scaleX}px`);
207
- this.renderer.setStyle(position.targetElement, 'top', `${y / scaleY}px`);
210
+ const { scale } = accountForScaleDirective;
211
+ this.renderer.setStyle(position.targetElement, 'left', `${x / scale}${this.cssUnit}`);
212
+ this.renderer.setStyle(position.targetElement, 'top', `${y / scale}${this.cssUnit}`);
208
213
  }
209
214
  else {
210
- this.renderer.setStyle(position.targetElement, 'left', `${x}px`);
211
- this.renderer.setStyle(position.targetElement, 'top', `${y}px`);
215
+ this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);
216
+ this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);
212
217
  }
213
218
  }
214
219
  /**
@@ -218,7 +223,7 @@ class InteractService {
218
223
  * @param y the position along the y axis
219
224
  */
220
225
  createTransformString(x, y) {
221
- return `translate3d(${x}px, ${y}px, 0)`;
226
+ return `translate3d(${x}${this.cssUnit}, ${y}${this.cssUnit}, 0)`;
222
227
  }
223
228
  calculatePositionInElement(zoneElement, dragElement, scale) {
224
229
  // TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
@@ -226,22 +231,24 @@ class InteractService {
226
231
  const dragRect = dragElement.getBoundingClientRect();
227
232
  const position = scale
228
233
  ? {
229
- x: (dragRect.left - zoneRect.left) / scale.x || 1,
230
- y: (dragRect.top - zoneRect.top) / scale.y || 1
234
+ x: (dragRect.left - zoneRect.left) / scale || 1,
235
+ y: (dragRect.top - zoneRect.top) / scale || 1
231
236
  } : {
232
237
  x: dragRect.left - zoneRect.left,
233
238
  y: dragRect.top - zoneRect.top
234
239
  };
240
+ // console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
235
241
  return position;
236
242
  }
237
243
  }
238
- InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone)); }, token: InteractService, providedIn: "root" });
244
+ InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(INTERACT_ROOT_CONFIG, 8)); }, token: InteractService, providedIn: "root" });
239
245
  InteractService.decorators = [
240
246
  { type: Injectable, args: [{ providedIn: 'root' },] }
241
247
  ];
242
248
  InteractService.ctorParameters = () => [
243
249
  { type: RendererFactory2 },
244
- { type: NgZone }
250
+ { type: NgZone },
251
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INTERACT_ROOT_CONFIG,] }] }
245
252
  ];
246
253
 
247
254
  /**
@@ -253,15 +260,9 @@ InteractService.ctorParameters = () => [
253
260
  class AccountForScaleDirective {
254
261
  constructor(el) {
255
262
  this.el = el;
256
- this.scaleX = 1;
257
- this.scaleY = 1;
263
+ // this setup allows consumers to set x, y scale independently or just set them both with scale
264
+ this.scale = 1;
258
265
  }
259
- // this setup allows consumers to set x, y scale independently or just set them both with scale
260
- set scale(val) {
261
- this.scaleY = val;
262
- this.scaleX = val;
263
- }
264
- ;
265
266
  }
266
267
  AccountForScaleDirective.decorators = [
267
268
  { type: Directive, args: [{
@@ -272,9 +273,7 @@ AccountForScaleDirective.ctorParameters = () => [
272
273
  { type: ElementRef }
273
274
  ];
274
275
  AccountForScaleDirective.propDecorators = {
275
- scale: [{ type: Input }],
276
- scaleX: [{ type: Input }],
277
- scaleY: [{ type: Input }]
276
+ scale: [{ type: Input }]
278
277
  };
279
278
 
280
279
  class DropzoneDirective {
@@ -332,13 +331,10 @@ class DropzoneDirective {
332
331
  * @param event the drop event emitted by interact, extended with extra fields we added to
333
332
  */
334
333
  mapDropzoneEvent(event) {
335
- var _a, _b;
334
+ var _a, _b, _c;
336
335
  const zoneElement = event.target;
337
336
  const dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
338
- const scale = this.account_for_scale_dir ? {
339
- x: this.account_for_scale_dir.scaleX,
340
- y: this.account_for_scale_dir.scaleY
341
- } : null;
337
+ const scale = ((_c = this.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || null;
342
338
  const positionInDropTarget = zoneElement && dragElement
343
339
  ? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
344
340
  : null;
@@ -435,21 +431,18 @@ function getRootNode(viewRef, _document) {
435
431
  * @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
436
432
  */
437
433
  class DragRootDirective {
438
- constructor(el, account_for_scale_dir) {
434
+ constructor(el,
435
+ // This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
436
+ // 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
437
+ account_for_scale_dir) {
439
438
  this.el = el;
440
- // This accounts for a bug where drag element is misaligned when using a drag root
441
- // with a dropzone inside of it and a drag item inside the dropzone
442
- // e.g <div tftDragRoot> <div tftDropzone> <div tftDraggable</div> </div> </div>
443
- // TODO: This is a band-aid, root cause in misunderstood, it started after switching from
444
- // using `translate3d` to top/left for positioning
445
- if (!account_for_scale_dir) {
446
- el.nativeElement.style.transform = 'scale(1)';
447
- }
439
+ this.account_for_scale_dir = account_for_scale_dir;
448
440
  }
449
441
  }
450
442
  DragRootDirective.decorators = [
451
443
  { type: Directive, args: [{
452
- selector: '[tftDragRoot]'
444
+ selector: '[tftDragRoot]',
445
+ exportAs: 'tftDragRoot'
453
446
  },] }
454
447
  ];
455
448
  DragRootDirective.ctorParameters = () => [
@@ -486,12 +479,12 @@ class DraggableDirective {
486
479
  this.dragEnd = new EventEmitter();
487
480
  }
488
481
  ngOnInit() {
489
- var _a, _b, _c;
482
+ var _a, _b, _c, _d, _e;
490
483
  this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
491
- this.dragRoot = this.dragRoot || ((_b = (_a = this.drag_root_dir) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) || this._document.body;
484
+ this.dragRootEl = (((_b = (_a = this.dragRoot) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) || ((_d = (_c = this.drag_root_dir) === null || _c === void 0 ? void 0 : _c.el) === null || _d === void 0 ? void 0 : _d.nativeElement)) || this._document.body;
492
485
  // register with parent dropzone if it exists, otherwise use default
493
486
  // this gives us a place on the registry to store our drag items that don't have a dropzone
494
- this.registryId = ((_c = this.dropzone_dir) === null || _c === void 0 ? void 0 : _c.dropzoneId) || DEFAULT_REGISTRY_ID;
487
+ this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
495
488
  // add draggable to directory and store its id
496
489
  this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
497
490
  this.alignPositionWithInputs(this.x, this.y);
@@ -547,7 +540,7 @@ class DraggableDirective {
547
540
  setDragStyles(dragElement) {
548
541
  this.renderer.setStyle(dragElement, 'touchAction', 'none');
549
542
  this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
550
- this.renderer.setStyle(dragElement, 'position', 'fixed');
543
+ this.renderer.setStyle(dragElement, 'position', 'absolute');
551
544
  }
552
545
  addDragPropertiesToElement(nativeElement) {
553
546
  this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
@@ -606,8 +599,8 @@ class DraggableDirective {
606
599
  }
607
600
  this.addDragPropertiesToElement(this.previewRef);
608
601
  this.setDragStyles(this.previewRef);
609
- this.dragRoot.prepend(this.previewRef);
610
- const { x, y } = this.interactService.calculatePositionInElement(this.dragRoot, nativeElement);
602
+ this.dragRootEl.prepend(this.previewRef);
603
+ const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement);
611
604
  this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.previewRef);
612
605
  if (!this.showPlaceholder) {
613
606
  this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
@@ -635,10 +628,9 @@ class DraggableDirective {
635
628
  this.renderer.setStyle(this.el.nativeElement, 'display', '');
636
629
  this.dragEnd.emit(mappedEvent);
637
630
  if (this.el.nativeElement !== this.previewRef) {
638
- // we do this in a timeout, so that we don't
639
- // remove before the dropzone can get the boundingElementRect
631
+ // we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
640
632
  setTimeout(() => {
641
- this.dragRoot.removeChild(this.previewRef);
633
+ this.dragRootEl.removeChild(this.previewRef);
642
634
  });
643
635
  }
644
636
  });
@@ -923,20 +915,14 @@ GesturableDirective.propDecorators = {
923
915
  class ApplyScaleDirective {
924
916
  constructor(el) {
925
917
  this.el = el;
926
- this.scaleX = 1;
927
- this.scaleY = 1;
928
- this.transformOrigin = '0 0';
918
+ this._scale = 1;
929
919
  }
930
920
  // this setup allows consumers to set x, y scale independently or just set them both with scale
931
921
  set scale(val) {
932
- this.scaleY = val;
933
- this.scaleX = val;
922
+ this._scale;
923
+ this.fontSize = `${val}px`;
934
924
  }
935
925
  ;
936
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
937
- ngOnChanges(_changes) {
938
- this.transform = `scaleX(${this.scaleX}) scaleY(${this.scaleY})`;
939
- }
940
926
  }
941
927
  ApplyScaleDirective.decorators = [
942
928
  { type: Directive, args: [{
@@ -948,10 +934,7 @@ ApplyScaleDirective.ctorParameters = () => [
948
934
  ];
949
935
  ApplyScaleDirective.propDecorators = {
950
936
  scale: [{ type: Input }],
951
- scaleX: [{ type: Input }],
952
- scaleY: [{ type: Input }],
953
- transform: [{ type: HostBinding, args: ['style.transform',] }],
954
- transformOrigin: [{ type: Input }, { type: HostBinding, args: ['style.transformOrigin',] }]
937
+ fontSize: [{ type: HostBinding, args: ['style.fontSize',] }]
955
938
  };
956
939
 
957
940
  const EXPORTS = [
@@ -966,10 +949,21 @@ const EXPORTS = [
966
949
  ArrayOfNPipe,
967
950
  ];
968
951
  class InteractModule {
952
+ static forRoot(config) {
953
+ const defaultConfig = { cssDimensionUnit: 'px' };
954
+ return {
955
+ ngModule: InteractModule,
956
+ providers: [
957
+ { provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
958
+ InteractService
959
+ ]
960
+ };
961
+ }
969
962
  }
970
963
  InteractModule.decorators = [
971
964
  { type: NgModule, args: [{
972
965
  imports: [CommonModule],
966
+ // providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
973
967
  declarations: [
974
968
  ...EXPORTS,
975
969
  ],
@@ -983,5 +977,5 @@ InteractModule.decorators = [
983
977
  * Generated bundle index. Do not edit.
984
978
  */
985
979
 
986
- export { AccountForScaleDirective, ApplyScaleDirective, ArrayOfNPipe, DEFAULT_REGISTRY_ID, DragPreviewDirective, DragRootDirective, DraggableDirective, DropzoneDirective, GesturableDirective, InteractModule, ResizableDirective, TFT_DRAG_PREVIEW, cloneElement$1 as cloneElement, defaultDelta, defaultPosition, defaultSize, getClosestMatchingAncestor, getRootNode, DraggableDirective as ɵa, ResizableDirective as ɵb, DropzoneDirective as ɵc, GesturableDirective as ɵd, DragRootDirective as ɵe, AccountForScaleDirective as ɵf, ApplyScaleDirective as ɵg, DragPreviewDirective as ɵh, ArrayOfNPipe as ɵi };
980
+ export { AccountForScaleDirective, ApplyScaleDirective, ArrayOfNPipe, DEFAULT_REGISTRY_ID, DragPreviewDirective, DragRootDirective, DraggableDirective, DropzoneDirective, GesturableDirective, INTERACT_ROOT_CONFIG, InteractModule, ResizableDirective, TFT_DRAG_PREVIEW, cloneElement$1 as cloneElement, defaultDelta, defaultPosition, defaultSize, getClosestMatchingAncestor, getRootNode, DraggableDirective as ɵa, ResizableDirective as ɵb, DropzoneDirective as ɵc, GesturableDirective as ɵd, DragRootDirective as ɵe, AccountForScaleDirective as ɵf, ApplyScaleDirective as ɵg, DragPreviewDirective as ɵh, ArrayOfNPipe as ɵi };
987
981
  //# sourceMappingURL=tft-interact.js.map