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

const DEFAULT_HTML: string | null = null;

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

export function DatePicker(props: DatePickerProps) {
  const { as, className, children, onChange, onOpen, onClose, mode, defaultValue, min, max, weekStartsOn, locale, formatLabel, placeholder, closeOnSelect, placement, offset, ...rest } = props;
  const options = { mode, defaultValue, min, max, weekStartsOn, locale, formatLabel, placeholder, closeOnSelect, placement, offset } as DatePickerOptions;

  return (
    <C42
      controller={DatePickerController}
      options={options}
      deps={[mode, defaultValue, min, max, weekStartsOn, locale, formatLabel, placeholder, closeOnSelect, placement, offset]}
      events={{
        'datepicker:change': onChange,
        'datepicker:open': onOpen,
        'datepicker:close': onClose,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-date-picker': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
