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

const DEFAULT_HTML: string | null = "<div data-c42-slider-track>\n    <div data-c42-slider-range></div>\n    <div data-c42-slider-thumb aria-label=\"Value\"></div>\n  </div>";

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

export function Slider(props: SliderProps) {
  const { as, className, children, onChange, min, max, step, value, orientation, label, ...rest } = props;
  const options = { min, max, step, value, orientation, label } as SliderOptions;

  return (
    <C42
      controller={SliderController}
      options={options}
      deps={[min, max, step, value, orientation, label]}
      events={{
        'slider:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-slider': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
