@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>
60 lines (56 loc) • 2.3 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, ElementRef, DOCUMENT, HostBinding, Directive } from '@angular/core';
import { DIControl, injectHostControl } from 'di-controls';
import { Subject } from 'rxjs';
class NgDocBaseInput extends DIControl {
constructor(config) {
super({
host: injectHostControl({ optional: true }),
...config,
});
this.elementRef = inject(ElementRef);
this.changes = new Subject();
this.document = inject(DOCUMENT);
}
get hostClasses() {
return 'ng-doc-input';
}
get placeholder() {
return this.elementRef.nativeElement.placeholder || '';
}
get isFocused() {
return this.document.activeElement === this.elementRef.nativeElement;
}
get isReadonly() {
return this.elementRef.nativeElement.readOnly;
}
get value() {
return this.elementRef.nativeElement.value;
}
focus() {
this.elementRef.nativeElement.focus();
}
blink() {
this.renderer.removeClass(this.elementRef.nativeElement, '-blink');
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this.elementRef.nativeElement.offsetWidth;
this.renderer.addClass(this.elementRef.nativeElement, '-blink');
}
updateModel(value) {
super.updateModel(value);
this.changes.next();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgDocBaseInput, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: NgDocBaseInput, isStandalone: true, host: { properties: { "class": "this.hostClasses" } }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgDocBaseInput, decorators: [{
type: Directive
}], ctorParameters: () => [{ type: undefined }], propDecorators: { hostClasses: [{
type: HostBinding,
args: ['class']
}] } });
/**
* Generated bundle index. Do not edit.
*/
export { NgDocBaseInput };
//# sourceMappingURL=ng-doc-ui-kit-classes-base-input.mjs.map