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

const DEFAULT_HTML: string | null = "<div data-c42-skeleton-placeholder>\n    <span data-c42-skeleton data-variant=\"text\"></span>\n    <span data-c42-skeleton data-variant=\"circle\"></span>\n  </div>\n  <div data-c42-skeleton-content hidden>real content</div>";

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

export function Skeleton(props: SkeletonProps) {
  const { as, className, children, onChange, loading, ...rest } = props;
  const options = { loading } as SkeletonOptions;

  return (
    <C42
      controller={SkeletonController}
      options={options}
      deps={[loading]}
      events={{
        'skeleton:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-skeleton-region': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
