import React from 'react'; import { RegisterOptions, useFormContext } from 'react-hook-form'; import SearchIcon from 'components/common/Icons/SearchIcon'; import * as S from './Input.styled'; export interface InputProps extends React.InputHTMLAttributes, Omit { name?: string; hookFormOptions?: RegisterOptions; search?: boolean; } const Input: React.FC = ({ name, hookFormOptions, search, inputSize = 'L', type, ...rest }) => { const methods = useFormContext(); return ( {search && } {name ? ( { if (type === 'number') { if (e.key === 'e') { e.preventDefault(); } } }} onPaste={(e) => { if (type === 'number') { e.preventDefault(); const value = e.clipboardData.getData('Text'); methods.setValue(name, value.replace(/[^\d.]/g, '')); } }} /> ) : ( )} ); }; export default Input;