import { UiElement } from '../shared/element.js'; import { type FileStatus } from '../../core/file-uploader.js'; import type { FileUploaderSize } from './file-uploader-shared.js'; import '../progress-bar/progress-bar.js'; /** * Carbon `FileUploaderItem`: one selected file. `status="edit"` shows a remove button * (click, Enter or Space fire `ui-delete`), `"uploading"` a spinner, `"complete"` a check mark. * `invalid` outlines the row in red and shows `error-subject` / `error-body` as an alert. * Used by `` and on its own for server-side lists. * * Beyond Carbon: `progress` (0–100) while uploading swaps the spinner for the percentage, a * small progress bar under the row (the `progressbar` screen readers query; the percentage isn't * announced as it changes) and a remove button that cancels the upload. `retryable` on an invalid * row (a failed upload; "Upload failed" when there is no `error-subject`) adds a retry button that * fires `ui-retry`. `file-size` (bytes) shows the size in the page language ("1.2 MB"). * * @fires ui-delete - detail: { uuid, name } when the user removes the file * @fires ui-retry - detail: { uuid, name } when the user retries a failed upload * @csspart base - The row * @csspart name - File name * @csspart size - The file size (`file-size`) * @csspart percent - The upload percentage (`progress`) * @csspart progress - The `` under the row (`progress`) * @csspart retry-button - The retry button (`retryable` invalid row) * @csspart delete-button - The × button (edit status, or uploading with `progress`) * @csspart error - The error block (invalid) * @cssprop --ui-file-item-radius - Corners of the row (default 0; Kanok: 6px); `--ui-file-item-edge` its box-shadow edge (default none; Kanok: a hairline) * @cssprop --ui-icon-control-radius - Corners of its small icon buttons, their hover fill and ring (default 0; Kanok: round) * @cssprop --ui-focus-offset - `outline-offset` of its focus ring (default -2px: inside; Kanok: 2px outside) */ export declare class UiFileUploaderItem extends UiElement { /** `el.focus()` lands on the control inside. */ static readonly shadowRootOptions: ShadowRootInit; static readonly styles: import("lit").CSSResult[]; name: string; /** Identifies the file in `ui-delete`; defaults to `name`. */ uuid: string; status: FileStatus; invalid: boolean; errorSubject: string; errorBody: string; size: FileUploaderSize; disabled: boolean; /** Describes the state icon / remove button: "Remove file", "Uploading", "Uploaded" (Carbon `iconDescription`); with `progress`, the bar. */ iconLabel: string; /** Upload progress 0–100, shown while `status` is uploading (percentage, bar, cancel button) instead of the spinner. */ progress?: number; /** On an invalid row: a retry button (`ui-retry`) for a failed upload. */ retryable: boolean; /** Bytes; shows the size in the row ("1.2 MB"). */ fileSize?: number; private readonly ids; private readonly localize; /** Set when an upload finishes, so the status region announces it (a spinner turning into a check mark is silent). */ private announcement; /** The retry button had focus before this update: if it goes (the upload restarts), focus the remove button, else the row. */ private retryFocused; protected willUpdate(changed: Map): void; protected updated(): void; /** The upload percentage when it shows (uploading with a `progress`), else undefined. */ private get percent(); /** The row has a remove button (edit, or uploading with `progress`) and isn't disabled. */ get removable(): boolean; /** `error-subject`, else "Upload failed" on a retryable invalid row. */ private get errorText(); private get defaultIconLabel(); /** Ask the owner to remove this file (fires `ui-delete`). */ requestDelete(): void; /** Ask the owner to upload this file again (fires `ui-retry`). */ requestRetry(): void; private renderState; /** The size and the upload percentage between the name and the state (the bar carries the percentage for screen readers). */ private renderMeta; private renderError; /** The small bar under the row while an upload shows its progress, named "Uploading - name". */ private renderProgress; render(): import("lit-html").TemplateResult<1>; } export interface FileItemDeleteDetail { uuid: string; name: string; } /** The item's `ui-retry` detail: the same as its `ui-delete`. */ export type FileItemRetryDetail = FileItemDeleteDetail; export interface UiFileUploaderItemEventMap extends HTMLElementEventMap { 'ui-delete': CustomEvent; 'ui-retry': CustomEvent; } /** Typed listeners for UiFileUploaderItem's events (declaration merging with the class). */ export interface UiFileUploaderItem { addEventListener(type: K, listener: (this: UiFileUploaderItem, event: UiFileUploaderItemEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: UiFileUploaderItem, event: UiFileUploaderItemEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare global { interface HTMLElementTagNameMap { 'ui-file-uploader-item': UiFileUploaderItem; } }