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

const DEFAULT_HTML: string | null = null;

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

export function FileDropzone(props: FileDropzoneProps) {
  const { as, className, children, onChange, onReject, accept, maxSize, multiple, maxFiles, disabled, validate, previews, ...rest } = props;
  const options = { accept, maxSize, multiple, maxFiles, disabled, validate, previews } as DropzoneOptions;

  return (
    <C42
      controller={FileDropzoneController}
      options={options}
      deps={[accept, maxSize, multiple, maxFiles, disabled, validate, previews]}
      events={{
        'dropzone:change': onChange,
        'dropzone:reject': onReject,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-file-dropzone': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
