import React, { type ReactElement } from 'react'
import { makeClassName } from '@/utils'
import { type ILabelProps } from '@/Types/InputTypes'

export default function Label({
  label,
  children,
  defaultClassName = 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
  className,
  disabled = false
}: ILabelProps): ReactElement {
  return (
    <>{label !== undefined
      ? <span className={makeClassName({
        defaultClassName,
        className,
        extras: [
          disabled ? 'cursor-not-allowed text-slate-400' : undefined
        ]
      })}>{children !== undefined ? children : label}</span>
      : ''}</>
  )
}
