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

const DEFAULT_HTML: string | null = null;

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

export function DataView(props: DataViewProps) {
  const { as, className, children, onChange, onRowAction, pageSize, defaultSort, defaultQuery, total, loading, visibleColumns, ...rest } = props;
  const options = { pageSize, defaultSort, defaultQuery, total, loading, visibleColumns } as DataViewOptions;

  return (
    <C42
      controller={DataViewController}
      options={options}
      deps={[pageSize, defaultSort, defaultQuery, total, loading, visibleColumns]}
      events={{
        'dataview:change': onChange,
        'dataview:row-action': onRowAction,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-data-view': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
