/**
 * `<inline-edit-ui>` — Click-to-edit text in place. Renders as static text until clicked /
focused + Enter, then becomes editable. Enter or blur commits; Escape
cancels and restores the original value. Form-participating.

Use for editable titles, breadcrumb labels, table-cell text fields,
draft document names — any case where a user expects to edit text
without opening a separate dialog or input. Distinct from `<input-ui>`
(always-editable chrome) and from `<field-ui>` (stacked label + input
composition). inline-edit reads as text in static state.

 *
 * @see https://ui-kit.exe.xyz/site/components/inline-edit
 *
 * Type declarations generated by scripts/build/dts-codegen.mjs from
 * the component's `.a2ui.json` sidecar(s). Edit the source `.yaml`,
 * run `npm run build:components`, then `npm run codegen:dts` to
 * regenerate; or hand-author this file fully if rich event types are
 * needed beyond what the yaml `events:` block can express.
 */

import { UIElement } from '../../core/element.js';

export type InlineEditCancelEvent = CustomEvent<unknown>;
export type InlineEditChangeEvent = CustomEvent<unknown>;
export type InlineEditEditEndEvent = CustomEvent<unknown>;
export type InlineEditEditStartEvent = CustomEvent<unknown>;

export class UIInlineEdit extends UIElement {
  /** When to commit pending edits. `blur` (default) — saves on focusout
or Enter. `enter` — Enter saves, blur cancels (returns to original).
`manual` — only programmatic `commitEdit()` saves.
 */
  commit: 'blur' | 'enter' | 'manual';
  /** Reflected state — `true` when the element is actively being edited.
Toggles automatically on click / Enter / blur / Escape; rarely set
by consumers. Listen to `edit-start` / `edit-end` events instead.
 */
  editing: boolean;
  /** Hint text shown when the value is empty (inline-edit reads this in the static state). */
  placeholder: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIInlineEdit, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'cancel', listener: (ev: InlineEditCancelEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'change', listener: (ev: InlineEditChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'edit-end', listener: (ev: InlineEditEditEndEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'edit-start', listener: (ev: InlineEditEditStartEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
