2022-06-05 18:56:42 +00:00
|
|
|
import React, { forwardRef } from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import styles from './styles.module.css';
|
|
|
|
|
2022-07-02 21:24:24 +00:00
|
|
|
enum Variant {
|
|
|
|
Normal,
|
|
|
|
Snug,
|
|
|
|
Loose,
|
|
|
|
}
|
|
|
|
|
|
|
|
interface InputFieldProps extends React.ComponentProps<'input'> {
|
|
|
|
variant?: Variant;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Component = forwardRef<HTMLInputElement, InputFieldProps>(({ className, variant, ...props }, ref) => (
|
|
|
|
<input
|
|
|
|
ref={ref}
|
|
|
|
className={classNames(
|
|
|
|
'form-input',
|
|
|
|
styles.text_input,
|
|
|
|
{ [styles.loose]: variant === Variant.Loose },
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2022-06-05 18:56:42 +00:00
|
|
|
));
|
2022-07-02 21:24:24 +00:00
|
|
|
|
|
|
|
const InputField = Object.assign(Component, { Variants: Variant });
|
|
|
|
|
|
|
|
export default InputField;
|