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

const DEFAULT_HTML: string | null = null;

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

export function NestedSelect(props: NestedSelectProps) {
  const { as, className, children, onChange, onOpen, onClose, defaultValue, filter, placeholder, placement, offset, ...rest } = props;
  const options = { defaultValue, filter, placeholder, placement, offset } as NestedSelectOptions;

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