import { booleanAttribute, ChangeDetectionStrategy, Component, computed, inject, input, output, } from '@angular/core'; import { AfricaniesIconComponent } from '@africanies/africanies-icons'; import { ButtonComponent } from '../button/button.component'; import { AfricaniesUiI18n } from '../i18n/africanies-ui-i18n'; /** * Blocking empty state when a fetch succeeded but produced no rows / value. * * Retry is **always** present because "no results" often changes after a * filter reset or fresh fetch. Omitting a `(retry)` handler is a misuse of * this component, not a supported configuration. * * @example * ```html * * ``` */ @Component({ selector: 'africanies-empty-state', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [AfricaniesIconComponent, ButtonComponent], template: `

{{ resolvedMessage() }}

`, }) /** * Blocking empty state when a fetch succeeded but produced no rows / value. */ export class EmptyStateComponent { private readonly i18n = inject(AfricaniesUiI18n); /** * Empty-copy. Defaults to a generic phrase; override for filter-specific help. */ readonly message = input(undefined); /** * Background refetch in flight — spins the refresh icon and disables Retry. */ readonly refreshing = input(false, { transform: booleanAttribute }); /** * Emitted when the user activates Retry. * * Always wire a handler — omitting `(retry)` is a misuse, not a valid * "static empty illustration" mode. */ readonly retry = output(); protected readonly resolvedMessage = computed( () => this.message() ?? this.i18n.t('africaniesUi.feedback.empty', 'No results found.'), ); protected readonly retryLabel = computed(() => this.i18n.t('africaniesUi.feedback.retry', 'Retry'), ); }