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

const DEFAULT_HTML: string | null = null;

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

export function ColorPicker(props: ColorPickerProps) {
  const { as, className, children, onChange, onOpen, onClose, defaultValue, placement, offset, ...rest } = props;
  const options = { defaultValue, placement, offset } as ColorPickerOptions;

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