import React, { forwardRef, InputHTMLAttributes } from 'react'
import classNames from 'classnames'

export interface COneTimePasswordInputProps extends InputHTMLAttributes<HTMLInputElement> {
  /**
   * A string of all className you want applied to the component.
   */
  className?: string
}

export const COneTimePasswordInput = forwardRef<HTMLInputElement, COneTimePasswordInputProps>(
  ({ className, ...rest }, ref) => {
    return (
      <input
        className={classNames('form-otp-control', className)}
        maxLength={1}
        autoComplete="off"
        ref={ref}
        {...rest}
      />
    )
  }
)

COneTimePasswordInput.displayName = 'COneTimePasswordInput'
