/** @jsxImportSource @emotion/react */ import { useUid } from '@/libs/hooks'; import React, { ForwardedRef, forwardRef, useCallback, useState } from 'react'; import FieldContainer from './container/FieldContainer'; const SearchField = forwardRef((props: SearchType, ref: ForwardedRef) => { const { disabled, tab, sizes, themes, placeholder, ...rest } = props; // eslint-disable-next-line react-hooks/rules-of-hooks const id = props?.id ?? useUid(); const [isFocused, setIsFocused] = useState(false); const handleFocus = useCallback(() => setIsFocused(true), [isFocused]); const handleBlur = useCallback(() => setIsFocused(false), [isFocused]); // // numberic const handleInput = (event: React.ChangeEvent) => { if (props.type === 'number') { let { value } = event.target; const newValue = value.replace(/[^0-9]/g, ''); if (props.maxLength && newValue.length > props.maxLength) { event.target.value = newValue.slice(0, props.maxLength); } else event.target.value = newValue; } props.onChange?.(event); }; return (
{ if (e.key === 'Enter') { document.getElementById(`${id}-button`)?.click(); } }} {...rest} />
); }); export { SearchField }; function SearchIcon() { return ( ); } export default SearchField;