/**
 * `<upload-ui>` — File upload dropzone + picker.
 *
 * @see https://ui-kit.exe.xyz/site/components/upload
 */

import { UIFormElement } from '../../core/form.js';

export interface UploadChangeEventDetail {
  /** Form value — comma-joined filenames (FormData carries the actual files). */
  value: string;
  /** Selected files as a FileList. */
  files: FileList | File[];
}
export type UploadChangeEvent = CustomEvent<UploadChangeEventDetail>;

export class UIUpload extends UIFormElement {
  /** Files currently selected. */
  readonly files: FileList | File[];
  /** §207 (v0.5.7): label rendered above the dropzone. */
  label: string;
  /** §207 (v0.5.7): MIME-type accept filter (e.g. `"image/*"` or `".pdf,.txt"`). */
  accept: string;
  /** §207 (v0.5.7): allow multi-file selection. */
  multiple: boolean;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIUpload, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'change', listener: (ev: UploadChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
