// AUTO-GENERATED by scripts/generate-wrappers.mjs — do not edit by hand.
// Source: packages/core/manifest.json (component "choice").
import type { ElementType, ReactNode } from 'react';
import { RadioGroup as RadioGroupController, type RadioGroupOptions } from '@42/core/choice';
import { C42 } from '../C42';

const DEFAULT_HTML: string | null = "<div data-c42-radio data-value=\"a\">A</div>\n  <div data-c42-radio data-value=\"b\">B</div>";

export interface RadioGroupProps extends Partial<RadioGroupOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `radio:change` — detail: `{ value: string | null }` */
  onChange?: (detail: { value: string | null }, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function RadioGroup(props: RadioGroupProps) {
  const { as, className, children, onChange, checked, indeterminate, disabled, ...rest } = props;
  const options = { checked, indeterminate, disabled } as RadioGroupOptions;

  return (
    <C42
      controller={RadioGroupController}
      options={options}
      deps={[checked, indeterminate, disabled]}
      events={{
        'radio:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-radio-group': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
