UNPKG

@taiga-ui/core

Version:

Core library for creating Angular components and applications using Taiga UI

41 lines (37 loc) 4.09 kB
import { NgIf } from '@angular/common'; import * as i0 from '@angular/core'; import { inject, Component, ChangeDetectionStrategy, Input } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { TuiValidationError } from '@taiga-ui/cdk/classes'; import { TuiAnimated } from '@taiga-ui/cdk/directives/animated'; import { tuiIsString } from '@taiga-ui/cdk/utils/miscellaneous'; import { TUI_ANIMATIONS_SPEED, TUI_DEFAULT_ERROR_MESSAGE } from '@taiga-ui/core/tokens'; import { tuiToAnimationOptions } from '@taiga-ui/core/utils'; import { PolymorpheusOutlet } from '@taiga-ui/polymorpheus'; class TuiError { constructor() { this.options = tuiToAnimationOptions(inject(TUI_ANIMATIONS_SPEED)); this.error = null; this.visible = true; this.default = toSignal(inject(TUI_DEFAULT_ERROR_MESSAGE)); } set errorSetter(error) { this.error = tuiIsString(error) ? new TuiValidationError(error) : error; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiError, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: TuiError, isStandalone: true, selector: "tui-error", inputs: { errorSetter: ["error", "errorSetter"] }, host: { properties: { "class._error": "error" } }, ngImport: i0, template: "<div\n *ngIf=\"error\"\n automation-id=\"tui-error__text\"\n tuiAnimated\n class=\"t-message-text\"\n>\n <ng-container *polymorpheusOutlet=\"error.message || default() as text; context: error.context || {}\">\n {{ text }}\n </ng-container>\n</div>\n", styles: [":host{transition-property:grid-template-rows;transition-duration:var(--tui-duration, .3s);transition-timing-function:ease-in-out;display:grid;font:var(--tui-font-text-s);color:var(--tui-text-negative);overflow-wrap:break-word;grid-template-rows:0fr}:host._error{grid-template-rows:1fr}.t-message-text{white-space:pre-line;grid-row:1 / span 2;overflow:hidden}.t-message-text.tui-enter,.t-message-text.tui-leave{animation-name:tuiFade}.t-message-text:before{content:\"\";line-height:1.5rem;vertical-align:bottom}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: PolymorpheusOutlet, selector: "[polymorpheusOutlet]", inputs: ["polymorpheusOutlet", "polymorpheusOutletContext"] }, { kind: "directive", type: TuiAnimated, selector: "[tuiAnimated]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiError, decorators: [{ type: Component, args: [{ standalone: true, selector: 'tui-error', imports: [NgIf, PolymorpheusOutlet, TuiAnimated], changeDetection: ChangeDetectionStrategy.OnPush, host: { '[class._error]': 'error', }, template: "<div\n *ngIf=\"error\"\n automation-id=\"tui-error__text\"\n tuiAnimated\n class=\"t-message-text\"\n>\n <ng-container *polymorpheusOutlet=\"error.message || default() as text; context: error.context || {}\">\n {{ text }}\n </ng-container>\n</div>\n", styles: [":host{transition-property:grid-template-rows;transition-duration:var(--tui-duration, .3s);transition-timing-function:ease-in-out;display:grid;font:var(--tui-font-text-s);color:var(--tui-text-negative);overflow-wrap:break-word;grid-template-rows:0fr}:host._error{grid-template-rows:1fr}.t-message-text{white-space:pre-line;grid-row:1 / span 2;overflow:hidden}.t-message-text.tui-enter,.t-message-text.tui-leave{animation-name:tuiFade}.t-message-text:before{content:\"\";line-height:1.5rem;vertical-align:bottom}\n"] }] }], propDecorators: { errorSetter: [{ type: Input, args: ['error'] }] } }); /** * Generated bundle index. Do not edit. */ export { TuiError }; //# sourceMappingURL=taiga-ui-core-components-error.mjs.map