1 | {"version":3,"file":"primeng-dragdrop.mjs","sources":["../../src/app/components/dragdrop/dragdrop.ts","../../src/app/components/dragdrop/primeng-dragdrop.ts"],"sourcesContent":["import {NgModule,Directive,OnDestroy,AfterViewInit,ElementRef,HostListener,Input,Output,EventEmitter,NgZone} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\n\n@Directive({\n selector: '[pDraggable]',\n host: {\n 'class': 'p-element'\n }\n})\nexport class Draggable implements AfterViewInit, OnDestroy {\n\n @Input('pDraggable') scope: string;\n\n @Input() dragEffect: string;\n\n @Input() dragHandle: string;\n\n @Output() onDragStart: EventEmitter<any> = new EventEmitter();\n\n @Output() onDragEnd: EventEmitter<any> = new EventEmitter();\n\n @Output() onDrag: EventEmitter<any> = new EventEmitter();\n\n handle: any;\n\n dragListener: any;\n\n mouseDownListener: any;\n\n mouseUpListener: any;\n\n _pDraggableDisabled: boolean;\n\n constructor(public el: ElementRef, public zone: NgZone) {}\n\n @Input() get pDraggableDisabled(): boolean {\n return this._pDraggableDisabled;\n }\n set pDraggableDisabled(_pDraggableDisabled:boolean) {\n this._pDraggableDisabled = _pDraggableDisabled;\n\n if (this._pDraggableDisabled) {\n this.unbindMouseListeners();\n }\n else {\n this.el.nativeElement.draggable = true;\n this.bindMouseListeners();\n }\n }\n\n ngAfterViewInit() {\n if (!this.pDraggableDisabled) {\n this.el.nativeElement.draggable = true;\n this.bindMouseListeners();\n }\n }\n\n bindDragListener() {\n if (!this.dragListener) {\n this.zone.runOutsideAngular(() => {\n this.dragListener = this.drag.bind(this);\n this.el.nativeElement.addEventListener('drag', this.dragListener);\n });\n }\n }\n\n unbindDragListener() {\n if (this.dragListener) {\n this.zone.runOutsideAngular(() => {\n this.el.nativeElement.removeEventListener('drag', this.dragListener);\n this.dragListener = null;\n });\n }\n }\n\n bindMouseListeners() {\n if (!this.mouseDownListener && !this.mouseUpListener) {\n this.zone.runOutsideAngular(() => {\n this.mouseDownListener = this.mousedown.bind(this);\n this.mouseUpListener = this.mouseup.bind(this);\n this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);\n this.el.nativeElement.addEventListener('mouseup', this.mouseUpListener);\n });\n }\n }\n\n unbindMouseListeners() {\n if (this.mouseDownListener && this.mouseUpListener) {\n this.zone.runOutsideAngular(() => {\n this.el.nativeElement.removeEventListener('mousedown', this.mouseDownListener);\n this.el.nativeElement.removeEventListener('mouseup', this.mouseUpListener);\n this.mouseDownListener = null;\n this.mouseUpListener = null;\n });\n }\n }\n\n drag(event) {\n this.onDrag.emit(event);\n }\n\n @HostListener('dragstart', ['$event'])\n dragStart(event) {\n if (this.allowDrag() && !this.pDraggableDisabled) {\n if (this.dragEffect) {\n event.dataTransfer.effectAllowed = this.dragEffect;\n }\n event.dataTransfer.setData('text', this.scope);\n\n this.onDragStart.emit(event);\n\n this.bindDragListener();\n }\n else {\n event.preventDefault();\n }\n }\n\n @HostListener('dragend', ['$event'])\n dragEnd(event) {\n this.onDragEnd.emit(event);\n this.unbindDragListener();\n }\n\n mousedown(event) {\n this.handle = event.target;\n }\n\n mouseup(event) {\n this.handle = null;\n }\n\n allowDrag() : boolean {\n if (this.dragHandle && this.handle)\n return DomHandler.matches(this.handle, this.dragHandle);\n else\n return true;\n }\n\n ngOnDestroy() {\n this.unbindDragListener();\n this.unbindMouseListeners();\n }\n\n}\n\n@Directive({\n selector: '[pDroppable]',\n host: {\n 'class': 'p-element'\n }\n})\nexport class Droppable implements AfterViewInit, OnDestroy {\n\n @Input('pDroppable') scope: string|string[];\n\n @Input() pDroppableDisabled: boolean;\n\n @Input() dropEffect: string;\n\n @Output() onDragEnter: EventEmitter<any> = new EventEmitter();\n\n @Output() onDragLeave: EventEmitter<any> = new EventEmitter();\n\n @Output() onDrop: EventEmitter<any> = new EventEmitter();\n\n constructor(public el: ElementRef, public zone: NgZone) {}\n\n dragOverListener: any;\n\n ngAfterViewInit() {\n if (!this.pDroppableDisabled) {\n this.bindDragOverListener();\n }\n }\n\n bindDragOverListener() {\n if (!this.dragOverListener) {\n this.zone.runOutsideAngular(() => {\n this.dragOverListener = this.dragOver.bind(this);\n this.el.nativeElement.addEventListener('dragover', this.dragOverListener);\n });\n }\n }\n\n unbindDragOverListener() {\n if (this.dragOverListener) {\n this.zone.runOutsideAngular(() => {\n this.el.nativeElement.removeEventListener('dragover', this.dragOverListener);\n this.dragOverListener = null;\n });\n }\n }\n\n dragOver(event) {\n event.preventDefault();\n }\n\n @HostListener('drop', ['$event'])\n drop(event) {\n if (this.allowDrop(event)) {\n DomHandler.removeClass(this.el.nativeElement, 'p-draggable-enter');\n event.preventDefault();\n this.onDrop.emit(event);\n }\n }\n\n @HostListener('dragenter', ['$event'])\n dragEnter(event) {\n event.preventDefault();\n\n if (this.dropEffect) {\n event.dataTransfer.dropEffect = this.dropEffect;\n }\n\n DomHandler.addClass(this.el.nativeElement, 'p-draggable-enter');\n this.onDragEnter.emit(event);\n }\n\n @HostListener('dragleave', ['$event'])\n dragLeave(event) {\n event.preventDefault();\n\n DomHandler.removeClass(this.el.nativeElement, 'p-draggable-enter');\n this.onDragLeave.emit(event);\n }\n\n allowDrop(event): boolean {\n let dragScope = event.dataTransfer.getData('text');\n if (typeof (this.scope) == \"string\" && dragScope == this.scope) {\n return true;\n }\n else if (this.scope instanceof Array) {\n for(let j = 0; j < this.scope.length; j++) {\n if (dragScope == this.scope[j]) {\n return true;\n }\n }\n }\n return false;\n }\n\n ngOnDestroy() {\n this.unbindDragOverListener();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Draggable,Droppable],\n declarations: [Draggable,Droppable]\n})\nexport class DragDropModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;MAUa,SAAS;IAwBlB,YAAmB,EAAc,EAAS,IAAY;QAAnC,OAAE,GAAF,EAAE,CAAY;QAAS,SAAI,GAAJ,IAAI,CAAQ;QAhB5C,gBAAW,GAAsB,IAAI,YAAY,EAAE,CAAC;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