@progress/kendo-angular-treelist
Version:
Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.
72 lines (71 loc) • 3.1 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Directive, ElementRef, EventEmitter, Input, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { DragAndDropService } from './drag-and-drop.service';
import { filter } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "./drag-and-drop.service";
/**
* @hidden
*/
export class DropTargetDirective {
element;
service;
context = {};
enter = new EventEmitter();
leave = new EventEmitter();
drop = new EventEmitter();
subscriptions = new Subscription();
constructor(element, service) {
this.element = element;
this.service = service;
}
ngOnInit() {
this.service.add(this);
const changes = this.service.changes.pipe(filter(({ target }) => target === this));
this.subscriptions.add(changes.pipe(filter(({ type }) => type === 'leave'))
.subscribe(e => {
this.leave.next(this.eventArgs(e));
}));
this.subscriptions.add(changes.pipe(filter(({ type }) => type === 'enter'))
.subscribe(e => {
this.enter.next(this.eventArgs(e));
}));
this.subscriptions.add(changes.pipe(filter(({ type }) => type === 'drop'))
.subscribe(e => {
this.drop.next(this.eventArgs(e));
}));
}
ngOnDestroy() {
if (this.subscriptions) {
this.subscriptions.unsubscribe();
}
}
eventArgs(e) {
return {
target: this,
mouseEvent: e.mouseEvent,
draggable: e.draggable
};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DropTargetDirective, deps: [{ token: i0.ElementRef }, { token: i1.DragAndDropService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: DropTargetDirective, isStandalone: true, selector: "[kendoDropTarget]", inputs: { context: "context" }, outputs: { enter: "enter", leave: "leave", drop: "drop" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DropTargetDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoDropTarget]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DragAndDropService }]; }, propDecorators: { context: [{
type: Input
}], enter: [{
type: Output
}], leave: [{
type: Output
}], drop: [{
type: Output
}] } });