/**
 * Type definitions for React components
 * FE-TYPE-013: Add type safety for components
 *
 * This file provides common prop types and utilities for components
 * to ensure full type safety across the application.
 */

import type { ReactNode, CSSProperties } from 'react';

/**
 * Common props for all components
 */
export interface BaseComponentProps {
  className?: string;
  style?: CSSProperties;
  children?: ReactNode;
  'data-testid'?: string;
}

/**
 * Props for components that can be disabled
 */
export interface DisableableProps {
  disabled?: boolean;
}

/**
 * Props for components that can be loading
 */
export interface LoadableProps {
  loading?: boolean;
}

/**
 * Props for components that can show errors
 */
export interface ErrorableProps {
  error?: string | Error | null;
}

/**
 * Props for components with optional callbacks
 */
export interface CallbackProps {
  onClick?: () => void;
  onClose?: () => void;
  onSubmit?: () => void;
  onCancel?: () => void;
}

/**
 * Props for components that accept an ID
 */
export interface IdentifiableProps {
  id?: string;
}

/**
 * Props for components with size variants
 */
export type ComponentSize = 'sm' | 'md' | 'lg' | 'xl';

export interface SizableProps {
  size?: ComponentSize;
}

/**
 * Props for components with variant styles
 */
export interface VariantProps {
  variant?:
    | 'default'
    | 'primary'
    | 'secondary'
    | 'success'
    | 'warning'
    | 'error'
    | 'info';
}

/**
 * Utility type to extract component props
 */
export type ComponentProps<T> =
  T extends React.ComponentType<infer P> ? P : never;

/**
 * Utility type for forwardRef components
 */
export type ForwardRefComponent<T, P> = React.ForwardRefExoticComponent<
  React.PropsWithoutRef<P> & React.RefAttributes<T>
>;
