@yelon/abc
Version:
Common business components of ng-yunzai.
56 lines (51 loc) • 2.7 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, ElementRef, NgZone, Input, Directive, NgModule } from '@angular/core';
import { Platform } from '@angular/cdk/platform';
import { install, uninstall } from '@github/hotkey';
class HotkeyDirective {
el = inject(ElementRef).nativeElement;
ngZone = inject(NgZone);
platform = inject(Platform);
/**
* Specify [hotkey format](https://github.com/github/hotkey#hotkey-string-format), you can get the code through [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html)
*
* 指定[热键格式](https://github.com/github/hotkey#hotkey-string-format),可以通过 [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html) 来获取代码。
*/
set hotkey(key) {
if (!this.platform.isBrowser)
return;
this.ngZone.runOutsideAngular(() => install(this.el, key));
}
ngOnDestroy() {
if (!this.platform.isBrowser)
return;
this.ngZone.runOutsideAngular(() => uninstall(this.el));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: HotkeyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.3", type: HotkeyDirective, isStandalone: true, selector: "[hotkey]", inputs: { hotkey: "hotkey" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: HotkeyDirective, decorators: [{
type: Directive,
args: [{ selector: '[hotkey]' }]
}], propDecorators: { hotkey: [{
type: Input,
args: ['hotkey']
}] } });
const DIRECTIVES = [HotkeyDirective];
class HotkeyModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: HotkeyModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: HotkeyModule, imports: [HotkeyDirective], exports: [HotkeyDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: HotkeyModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: HotkeyModule, decorators: [{
type: NgModule,
args: [{
imports: DIRECTIVES,
exports: DIRECTIVES
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { HotkeyDirective, HotkeyModule };
//# sourceMappingURL=hotkey.mjs.map