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

const DEFAULT_HTML: string | null = "<div data-c42-tabs-list>\n    <button data-c42-tabs-trigger data-value=\"a\">A</button>\n    <button data-c42-tabs-trigger data-value=\"b\">B</button>\n  </div>\n  <div data-c42-tabs-panel data-value=\"a\">Panel A</div>\n  <div data-c42-tabs-panel data-value=\"b\">Panel B</div>";

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

export function Tabs(props: TabsProps) {
  const { as, className, children, onChange, defaultValue, orientation, activationMode, ...rest } = props;
  const options = { defaultValue, orientation, activationMode } as TabsOptions;

  return (
    <C42
      controller={TabsController}
      options={options}
      deps={[defaultValue, orientation, activationMode]}
      events={{
        'tabs:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-tabs': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
