@c-standard/angular-devui-extension
Version:
an extensional components lib for devui
80 lines (75 loc) • 3.97 kB
JavaScript
import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, HostListener, NgModule } from '@angular/core';
import { fadeInOut } from 'ng-devui/utils';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
class ContextMenuComponent {
constructor(ref) {
this.ref = ref;
this.offset = { x: 0, y: 0 };
this.visible = false;
this.visibleChange = new EventEmitter();
this.repaint();
}
clickOut(e) {
if (!this.ref.nativeElement.contains(e.target)) {
this.visibleChange.emit(false);
}
}
ngOnChanges({ offset }) {
if (offset) {
this.repaint();
}
}
repaint() {
this.ref.nativeElement.style.top = this.offset?.y + 'px';
this.ref.nativeElement.style.left = this.offset?.x + 'px';
}
}
ContextMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ContextMenuComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
ContextMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: ContextMenuComponent, selector: "d-context-menu", inputs: { offset: "offset", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "document:click": "clickOut($event)" } }, usesOnChanges: true, ngImport: i0, template: `
<div
*ngIf="visible"
[@fadeInOut]="visible ? 'bottom' : 'void'"
>
<ng-content></ng-content>
</div>
`, isInline: true, styles: [":host{position:absolute;z-index:var(--devui-z-index-dropdown, 1052);margin:10px}\n"], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [fadeInOut] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ContextMenuComponent, decorators: [{
type: Component,
args: [{ selector: 'd-context-menu', template: `
<div
*ngIf="visible"
[@fadeInOut]="visible ? 'bottom' : 'void'"
>
<ng-content></ng-content>
</div>
`, animations: [fadeInOut], styles: [":host{position:absolute;z-index:var(--devui-z-index-dropdown, 1052);margin:10px}\n"] }]
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { offset: [{
type: Input
}], visible: [{
type: Input
}], visibleChange: [{
type: Output
}], clickOut: [{
type: HostListener,
args: ['document:click', ['$event']]
}] } });
class ContextMenuModule {
}
ContextMenuModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ContextMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
ContextMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ContextMenuModule, declarations: [ContextMenuComponent], imports: [CommonModule], exports: [ContextMenuComponent] });
ContextMenuModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ContextMenuModule, imports: [[CommonModule]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ContextMenuModule, decorators: [{
type: NgModule,
args: [{
declarations: [ContextMenuComponent],
imports: [CommonModule],
exports: [ContextMenuComponent],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { ContextMenuComponent, ContextMenuModule };
//# sourceMappingURL=c-standard-angular-devui-extension-context-menu.mjs.map