UNPKG

ngx-ui-builder

Version:

Angular - Render component ui with configurations

83 lines (76 loc) 3.91 kB
import * as i0 from '@angular/core'; import { EventEmitter, Directive, Input, Output, HostListener, NgModule } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil, debounceTime, distinctUntilChanged, tap } from 'rxjs/operators'; class AbstractDebounceDirective { constructor() { this.debounceTime = 500; this.event = new EventEmitter(); this.emitEvent$ = new Subject(); this.subscription$ = new Subject(); } ngOnInit() { this.emitEvent$ .pipe(takeUntil(this.subscription$), debounceTime(this.debounceTime), distinctUntilChanged(), tap(value => this.emitChange(value))) .subscribe(); } emitChange(value) { this.event.emit(value); } ngOnDestroy() { this.subscription$.next(); this.subscription$.complete(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AbstractDebounceDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: AbstractDebounceDirective, inputs: { debounceTime: "debounceTime" }, outputs: { event: "event" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AbstractDebounceDirective, decorators: [{ type: Directive }], ctorParameters: function () { return []; }, propDecorators: { debounceTime: [{ type: Input }], event: [{ type: Output }] } }); class NubDebounceKeyupDirective extends AbstractDebounceDirective { constructor() { super(); } onKeyUp(event) { event.preventDefault(); this.emitEvent$.next(event); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: NubDebounceKeyupDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: NubDebounceKeyupDirective, selector: "[nubDebounceKeyUp]", host: { listeners: { "keyup": "onKeyUp($event)" } }, usesInheritance: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: NubDebounceKeyupDirective, decorators: [{ type: Directive, args: [{ selector: '[nubDebounceKeyUp]' }] }], ctorParameters: function () { return []; }, propDecorators: { onKeyUp: [{ type: HostListener, args: ['keyup', ['$event']] }] } }); class NubUtilsModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: NubUtilsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: NubUtilsModule, declarations: [NubDebounceKeyupDirective], exports: [NubDebounceKeyupDirective] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: NubUtilsModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: NubUtilsModule, decorators: [{ type: NgModule, args: [{ declarations: [ NubDebounceKeyupDirective, ], imports: [], exports: [ NubDebounceKeyupDirective, ] }] }] }); // Directives /** * Generated bundle index. Do not edit. */ export { NubDebounceKeyupDirective, NubUtilsModule }; //# sourceMappingURL=ngx-ui-builder-utils.mjs.map