import { Component, computed, input } from '@angular/core'; import { MatIconModule } from '@angular/material/icon'; import { MatTooltipModule } from '@angular/material/tooltip'; import { FlowStatus } from '../../domain/import-flow'; const PRESENTATION: Record = { loading: { label: 'Leyendo', icon: 'hourglass_top', tone: 'neutral', hint: 'Leyendo la fuente…' }, error: { label: 'Error', icon: 'error', tone: 'error', hint: 'No se pudo leer la fuente' }, incomplete: { label: 'Sin mapear', icon: 'rule', tone: 'warn', hint: 'Faltan campos obligatorios por asignar' }, ready: { label: 'Listo', icon: 'check_circle_outline', tone: 'neutral', hint: 'Mapeo completo, sin validar' }, validating: { label: 'Validando', icon: 'hourglass_top', tone: 'neutral', hint: 'Validando filas…' }, valid: { label: 'Válido', icon: 'verified', tone: 'ok', hint: 'Todas las filas pasan la validación' }, invalid: { label: 'Con errores', icon: 'report', tone: 'warn', hint: 'Algunas filas no pasan la validación y se omitirán' }, loaded: { label: 'Cargado', icon: 'cloud_done', tone: 'ok', hint: 'Escrito en la base de datos' }, }; /** Compact status pill for a flow (canvas cards, editor header, load dialog). */ @Component({ selector: 'app-flow-status', imports: [MatIconModule, MatTooltipModule], template: ` {{ view().label }} `, styles: ` .flow-status { align-items: center; border-radius: 999px; display: inline-flex; font: var(--mat-sys-label-medium); gap: 4px; padding: 2px 10px 2px 6px; white-space: nowrap; background: var(--mat-sys-surface-container-high); color: var(--mat-sys-on-surface-variant); } .flow-status mat-icon { font-size: 16px; height: 16px; width: 16px; } .flow-status[data-tone='ok'] { background: var(--mat-sys-primary-container); color: var(--mat-sys-on-primary-container); } .flow-status[data-tone='warn'] { background: #fff1d6; color: #7a4b00; } .flow-status[data-tone='error'] { background: var(--mat-sys-error-container); color: var(--mat-sys-on-error-container); } `, }) export class FlowStatusChip { readonly status = input.required(); readonly view = computed(() => PRESENTATION[this.status()]); }