@ng-doc/ui-kit
Version:
<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>
38 lines (34 loc) • 1.61 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, ElementRef, Input, Directive } from '@angular/core';
import { NgDocFocusUtils } from '@ng-doc/ui-kit/utils';
class NgDocAutofocusDirective {
constructor() {
this.elementRef = inject(ElementRef);
this.selectAll = false;
}
ngOnInit() {
const element = this.elementRef.nativeElement;
if (NgDocFocusUtils.isNativeKeyboardFocusable(element)) {
element.focus();
}
if (this.selectAll && element instanceof HTMLInputElement) {
Promise.resolve().then(() => element.select());
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocAutofocusDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.3", type: NgDocAutofocusDirective, isStandalone: true, selector: "[ngDocAutofocus]", inputs: { selectAll: "selectAll" }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocAutofocusDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngDocAutofocus]',
standalone: true,
}]
}], ctorParameters: () => [], propDecorators: { selectAll: [{
type: Input
}] } });
/**
* Generated bundle index. Do not edit.
*/
export { NgDocAutofocusDirective };
//# sourceMappingURL=ng-doc-ui-kit-directives-autofocus.mjs.map