/**
 * `<radio-ui>` — Radio button (boolean-semantic form control; group via shared name).
 *
 * @see https://ui-kit.exe.xyz/site/components/radio
 */

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

export interface RadioChangeEventDetail {
  /** Submitted value (the radio's `value` attribute). */
  value: string;
  /** Current checked state. */
  checked: boolean;
}
export type RadioChangeEvent = CustomEvent<RadioChangeEventDetail>;

export class UIRadio extends UIFormElement {
  /** Checked state — reflected; setting `checked=true` deselects siblings in the group. */
  checked: boolean;
  label: string;

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