import React, { ChangeEvent, forwardRef, InputHTMLAttributes, useRef } from 'react' import classNames from 'classnames' import SVGCloseCircle from '../../svg/close-circle.svg' import { findDOMNode } from 'react-dom' import Input, { InputProps } from './input' interface InputCloseProps extends Omit, 'onChange'> { onChange?(value: string): void } const InputClose = forwardRef((props, ref) => { const { value, onChange, disabled, className, style, ...rest } = props const refWrap = useRef(null) const handleClose = () => { onChange && onChange('') const dom = findDOMNode(refWrap.current) as Element if (dom) { const input = dom.querySelector('input') if (input) { input.focus() } } } const handleChange = (e: ChangeEvent) => { onChange && onChange(e.target.value) } return (
{value && }
) }) export default InputClose export type { InputCloseProps }