import * as i0 from '@angular/core'; import { InjectionToken, Signal, Provider } from '@angular/core'; /** * Lifecycle stages of the avatar's image: * - `idle`: no `src` set yet. * - `loading`: `src` set, waiting for the network. * - `loaded`: image rendered successfully. * - `error`: image failed to load. */ type ForAvatarStatus = 'idle' | 'loading' | 'loaded' | 'error'; /** Read surface `[forAvatar]` publishes through {@link FOR_AVATAR_CONTEXT}. */ interface ForAvatarContext { /** Current status of the avatar's image. */ readonly status: Signal; /** * `true` when the consumer should render the fallback. Drives `@if` in * the consumer's template. Honors `fallbackDelayMs` for `idle` / `loading` * states; `error` flips it to `true` immediately. */ readonly shouldShowFallback: Signal; } /** * The avatar's piece-coordination surface: the one call `[forAvatarImage]` * makes so the root can transition its state machine. * * **Not** part of {@link ForAvatarContext} and never exported from * `public-api.ts` — a consumer drives the status by binding `[src]`, never by * reporting a transition into the root. */ interface AvatarPieceContext { /** Reported by `[forAvatarImage]` so the root can transition its state machine. */ reportStatus(status: ForAvatarStatus): void; } /** * The avatar's internal coordination surface: everything * {@link ForAvatarContext} publishes plus the {@link AvatarPieceContext} call. * * Never exported from `public-api.ts`. It is the type the pieces read * {@link FOR_AVATAR_CONTEXT} at, so a consumer who injects that token gets the * read surface while `[forAvatarImage]` gets the transition channel. `ForAvatar` * declares `reportStatus` TS-`private`, which keeps it out of the emitted * `.d.ts` while `useExisting` still satisfies this contract at runtime. */ interface AvatarContext extends ForAvatarContext, AvatarPieceContext { } /** * DI token for the avatar's coordination surface, provided by `[forAvatar]`. * * Publicly typed as the read surface {@link ForAvatarContext}, which is the whole of * what the token promises a consumer. `[forAvatarImage]` reads the same token at an * internal type that adds the status-report channel, so a wrapper re-providing it must * alias it to the root: `{ provide: FOR_AVATAR_CONTEXT, useExisting: MyAvatar }`, where * `MyAvatar` extends `ForAvatar`. A value that merely satisfies the declared type * resolves too, and is rejected in dev mode by the first piece to reach the channel. */ declare const FOR_AVATAR_CONTEXT: InjectionToken; /** * Headless avatar root. Tracks the load lifecycle of an inner * `[forAvatarImage]` and exposes `status` + `shouldShowFallback` so the * consumer can swap the image for fallback content (initials, generic icon) * via `@if`. * * No ARIA role is imposed — avatars are typically presentational. If the * surrounding component conveys identity (a person's name in the header, * a chat bubble), the consumer should provide an `aria-label` on the * relevant ancestor or pair the avatar with visible text. * * @example * ```html * * * @if (a.shouldShowFallback()) { * {{ user.initials }} * } * * ``` */ declare class ForAvatar implements ForAvatarContext { #private; /** * Milliseconds to defer the fallback for fast loads, avoiding a brief * "initials → image" flicker. Set to `0` (default) to show immediately * during `idle` / `loading`, or to e.g. `500` to skip rendering during * quick cached loads. `error` always shows the fallback immediately. * The default is read from `provideForAvatarDefaults` for the * surrounding scope. */ readonly fallbackDelayMs: i0.InputSignalWithTransform; readonly status: i0.Signal; readonly shouldShowFallback: i0.Signal; private reportStatus; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Wraps an `` and reports its load lifecycle to the surrounding * `[forAvatar]`. The native `src` / `alt` bindings are owned by the * consumer — this directive only observes. * * Reflects `data-status` on the image element so the consumer can hide it * via CSS while loading or after an error (e.g. `img[data-status="error"] * { display: none }`). */ declare class ForAvatarImage { #private; /** * Emits whenever the image lifecycle transitions to a new state. Useful * if the consumer wants to log analytics, swap to a different src on * error, etc. */ readonly loadStatusChange: i0.OutputEmitterRef; constructor(); protected status(): ForAvatarStatus; protected onLoad(): void; protected onError(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Marker for the avatar's fallback content (initials, generic icon, …). * Reflects `data-status` from the parent `[forAvatar]` so the consumer can * style for the `error` state separately from `idle` / `loading` if needed. * * The decision of *whether* to render the fallback lives on the root — * drive `@if` with `forAvatar.shouldShowFallback()`. */ declare class ForAvatarFallback { protected readonly parent: AvatarContext; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Defaults inherited by descendant avatars in the surrounding injector * scope. Configure with `provideForAvatarDefaults` either at the * application root or in any component's `providers` array; partial * overrides merge with the parent scope. */ interface ForAvatarDefaults { /** * Milliseconds to defer the fallback for fast loads, avoiding a brief * "initials → image" flicker. Set to `0` to show immediately during * `idle` / `loading`, or to e.g. `500` to skip rendering during quick * cached loads. `error` always shows the fallback immediately. */ fallbackDelayMs: number; } /** Token holding the resolved avatar defaults for the current scope. */ declare const FOR_AVATAR_DEFAULTS: i0.InjectionToken; /** * Configures forty-cdk avatar defaults for this injector scope. Partial * overrides inherit unspecified keys from the parent scope (or library * defaults at the root). */ declare function provideForAvatarDefaults(defaults?: Partial): Provider[]; export { FOR_AVATAR_CONTEXT, FOR_AVATAR_DEFAULTS, ForAvatar, ForAvatarFallback, ForAvatarImage, provideForAvatarDefaults }; export type { ForAvatarContext, ForAvatarDefaults, ForAvatarStatus };