/**
 * `<textarea-ui>` — Multi-line text input with Enter-submit semantic.
 *
 * @see https://ui-kit.exe.xyz/site/components/textarea
 */

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

export interface TextareaChangeEventDetail {
  value: string;
}
export type TextareaChangeEvent = CustomEvent<TextareaChangeEventDetail>;
export type TextareaInputEvent = CustomEvent<TextareaChangeEventDetail>;

export class UITextarea extends UIFormElement {
  placeholder: string;
  label: string;
  rows: number;
  /** CSS `resize` value — `none` / `vertical` (default) / `horizontal` / `both`. */
  resize: 'none' | 'vertical' | 'horizontal' | 'both';

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UITextarea, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'change', listener: (ev: TextareaChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'input', listener: (ev: TextareaInputEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  /** Fired on Enter without Shift; user can `e.preventDefault()` to insert newline. */
  addEventListener(type: 'submit', listener: (ev: Event) => unknown, options?: boolean | AddEventListenerOptions): void;
}
