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

const DEFAULT_HTML: string | null = null;

export interface ComboboxProps extends Partial<ComboboxOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `combobox:change` — detail: `(no detail)` */
  onChange?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `combobox:open` — detail: `(no detail)` */
  onOpen?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `combobox:close` — detail: `(no detail)` */
  onClose?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function Combobox(props: ComboboxProps) {
  const { as, className, children, onChange, onOpen, onClose, multiple, filter, defaultValue, ...rest } = props;
  const options = { multiple, filter, defaultValue } as ComboboxOptions;

  return (
    <C42
      controller={ComboboxController}
      options={options}
      deps={[multiple, filter, defaultValue]}
      events={{
        'combobox:change': onChange,
        'combobox:open': onOpen,
        'combobox:close': onClose,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-combobox': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
