import { TemplateResult } from 'lit';
import { BahtElement } from '../base.js';
import { UploadedFile } from '../../core/types.js';
export interface UploadChangeDetail {
/** The stored URL(s): a string, `string[]` when `multiple`, `null` when empty. */
value: string | string[] | null;
/** One entry per URL in `value`, with what is known about the file behind it. */
files: UploadedFile[];
}
export interface UploadProgressDetail {
file: File;
loaded: number;
total: number;
percent: number;
}
export interface UploadErrorDetail {
file: File;
/** HTTP status, or 0 for a network failure / unusable body. */
status: number;
message: string;
}
/**
* File upload against an HTTP endpoint. Picking (or dropping) a file sends it **immediately**
* as `multipart/form-data` to `url`; the endpoint answers with where it stored the file and
* that URL becomes the value. Nothing waits for a form submit, and no host code is needed:
* the whole contract is attributes.
*
*
*
* Expected response: `2xx` with JSON `{ "url": "…" }` (change the key with `response-key`,
* dotted paths allowed) or a plain-text URL body. Anything else is an upload error the
* user can retry.
*
* el.addEventListener('baht-change', (e) => e.detail.value); // string | string[] | null
*
* Auth: set `headers` (property) and/or `with-credentials`. Progress: `baht-upload-progress`.
* Value is controlled the usual way — feed it back on `baht-change`, or pre-fill with the
* URLs already on record and the chips render from them.
*/
export declare class BahtUpload extends BahtElement {
/** Endpoint that receives the file and returns its stored URL. Required. */
url: string;
/** HTTP method for the upload request. */
method: string;
/** Form-data key the file is sent under. */
fieldName: string;
/** Where the stored URL lives in a JSON response (dotted path). Empty = the body itself. */
responseKey: string;
/** Extra request headers (e.g. Authorization). Property only. */
headers: Record;
/** Send cookies on cross-origin requests. */
withCredentials: boolean;
/** Stored URL(s). `string`, `string[]` when `multiple`, or `null`. Property only. */
value: string | string[] | null;
/** Visible label. */
label: string;
/** Helper text under the control. Defaults to the accept / size limits when set. */
hint: string;
/** Native `accept` filter (`.pdf,image/*`). */
accept?: string;
/** Allow several files; the value becomes an array. */
multiple: boolean;
/** Reject files over this many bytes before sending. */
maxSize?: number;
disabled: boolean;
required: boolean;
/** Validation message to display (marks the control invalid). */
error: string | null;
private pending;
private rejectedNames;
private dragging;
/** What is known about each stored URL (from the upload that produced it). */
private known;
private seq;
private get urls();
private get inputId();
private fileFor;
/** Empty the value (does not delete anything on the server). */
clear(): void;
private emitValue;
private accept_;
private onPick;
private readonly onDragOver;
private readonly onDragLeave;
private readonly onDrop;
private start;
private patch;
private send;
private failed;
private retry;
private dismiss;
private defaultHint;
protected render(): TemplateResult;
private renderLabel;
private renderList;
private renderRejected;
private renderStored;
private renderPending;
}