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

const DEFAULT_HTML: string | null = "<textarea data-c42-textarea-emoji-input rows=\"3\" placeholder=\"Write...\"></textarea>\n  <div>\n    <button data-c42-textarea-emoji-trigger>😀</button>\n    <span data-c42-textarea-emoji-counter></span>\n  </div>\n  <div data-c42-textarea-emoji-picker></div>";

export interface TextareaEmojiProps extends Partial<TextareaEmojiOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `textarea-emoji:input` — detail: `(no detail)` */
  onInput?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `textarea-emoji:emoji` — detail: `(no detail)` */
  onEmoji?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function TextareaEmoji(props: TextareaEmojiProps) {
  const { as, className, children, onInput, onEmoji, maxLength, emojis, renderPicker, ...rest } = props;
  const options = { maxLength, emojis, renderPicker } as TextareaEmojiOptions;

  return (
    <C42
      controller={TextareaEmojiController}
      options={options}
      deps={[maxLength, emojis, renderPicker]}
      events={{
        'textarea-emoji:input': onInput,
        'textarea-emoji:emoji': onEmoji,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-textarea-emoji': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
