import type { InputProps } from 'antd'; import { Form, Input } from 'antd'; import type { TextAreaProps } from 'antd/es/input/TextArea'; import { useEffect, useRef, useState } from 'react'; import Wrapper from './components/wrapper'; import SealInputNumber from './input-number'; import SealInputSearch from './input-search'; import SealPassword from './password'; import { SealFormItemProps } from './types'; const SealTextArea: React.FC = (props) => { const { label, placeholder, style, ...rest } = props; const [isFocus, setIsFocus] = useState(false); const inputRef = useRef(null); const { status } = Form.Item.useStatus(); useEffect(() => { if (props.value) { setIsFocus(true); } }, [props.value]); const handleClickWrapper = () => { if (!props.disabled && !isFocus) { inputRef.current?.focus?.(); setIsFocus(true); } }; const handleChange = (e: any) => { props.onChange?.(e); }; const handleOnFocus = (e: any) => { setIsFocus(true); props.onFocus?.(e); }; const handleOnBlur = (e: any) => { if (!inputRef.current?.input?.value) { setIsFocus(false); props.onBlur?.(e); } }; const handleInput = (e: any) => { props.onInput?.(e); }; return ( handleChange(e)} > ); }; const SealInput: React.FC = (props) => { const { label, placeholder, ...rest } = props; const [isFocus, setIsFocus] = useState(false); const inputRef = useRef(null); const { status } = Form.Item.useStatus(); useEffect(() => { if (props.value) { setIsFocus(true); } }, [props.value]); const handleClickWrapper = () => { if (!props.disabled && !isFocus) { inputRef.current?.focus?.(); setIsFocus(true); } }; const handleChange = (e: any) => { props.onChange?.(e); }; const handleOnFocus = (e: any) => { setIsFocus(true); props.onFocus?.(e); }; const handleOnBlur = (e: any) => { if (!inputRef.current?.input?.value) { setIsFocus(false); props.onBlur?.(e); } }; const handleInput = (e: any) => { props.onInput?.(e); }; return ( handleChange(e)} > ); }; export default { TextArea: SealTextArea, Input: SealInput, Password: SealPassword, Number: SealInputNumber, Search: SealInputSearch } as Record>;