UNPKG

@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>

47 lines (43 loc) 3.53 kB
import * as i0 from '@angular/core'; import { inject, ChangeDetectionStrategy, Component } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { NgDocInputHost } from '@ng-doc/ui-kit/classes/input-host'; import { NgDocButtonIconComponent } from '@ng-doc/ui-kit/components/button-icon'; import { NgDocIconComponent } from '@ng-doc/ui-kit/components/icon'; import { NgDocFocusableDirective } from '@ng-doc/ui-kit/directives/focusable'; import { DIControl, injectHostControl } from 'di-controls'; class NgDocClearControlComponent extends DIControl { constructor() { super({ host: injectHostControl(), }); this.inputHost = inject(NgDocInputHost, { optional: true, }); } ngAfterContentInit() { if (this.inputHost?.inputControl) { this.inputHost.inputControl.changes .pipe(takeUntilDestroyed(this['destroyRef'])) .subscribe(() => this.changeDetectorRef.detectChanges()); } } get isVisible() { return this.inputHost?.inputControl?.hasValue || this.hasValue; } clear() { this.inputHost?.inputControl?.writeValueFromHost(null); this.updateModel(null); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocClearControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.3", type: NgDocClearControlComponent, isStandalone: true, selector: "ng-doc-clear-control", usesInheritance: true, ngImport: i0, template: "@if (isVisible) {\n <button\n ng-doc-button-icon-transparent\n size=\"large\"\n [ngDocFocusable]=\"false\"\n [disabled]=\"disabled\"\n [rounded]=\"false\"\n (click)=\"clear()\"\n (focusout)=\"touch()\">\n <ng-doc-icon icon=\"x\"></ng-doc-icon>\n </button>\n}\n", styles: [":host{display:inline-block}\n"], dependencies: [{ kind: "component", type: NgDocButtonIconComponent, selector: "button[ng-doc-button-icon], a[ng-doc-button-icon], button[ng-doc-button-icon-raised], a[ng-doc-button-icon-raised], button[ng-doc-button-icon-transparent], a[ng-doc-button-icon-transparent]", inputs: ["size", "rounded"] }, { kind: "directive", type: NgDocFocusableDirective, selector: "[ngDocFocusable]", inputs: ["ngDocFocusable"], exportAs: ["ngDocFocusable"] }, { kind: "component", type: NgDocIconComponent, selector: "ng-doc-icon", inputs: ["icon", "customIcon", "size"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocClearControlComponent, decorators: [{ type: Component, args: [{ selector: 'ng-doc-clear-control', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgDocButtonIconComponent, NgDocFocusableDirective, NgDocIconComponent], template: "@if (isVisible) {\n <button\n ng-doc-button-icon-transparent\n size=\"large\"\n [ngDocFocusable]=\"false\"\n [disabled]=\"disabled\"\n [rounded]=\"false\"\n (click)=\"clear()\"\n (focusout)=\"touch()\">\n <ng-doc-icon icon=\"x\"></ng-doc-icon>\n </button>\n}\n", styles: [":host{display:inline-block}\n"] }] }], ctorParameters: () => [] }); /** * Generated bundle index. Do not edit. */ export { NgDocClearControlComponent }; //# sourceMappingURL=ng-doc-ui-kit-components-clear-control.mjs.map