import { Input, Modal } from 'antd'; import style from './index.less'; import { useState } from 'react'; import { useIntl } from 'umi'; import React from 'react'; type OneKeyCopyProps = { callback: () => void; children: React.ReactNode; }; const OneKeyCopyModal: React.FC = ({ callback, children }) => { const [value, setValue] = useState(''); const [isShowErrorTip, setIsShowErrorTip] = useState(false); const [open, setOpen] = useState(false); const { formatMessage } = useIntl(); const compareValue = () => { if (value === formatMessage({ id: 'component.oneKeyCopy.confirmOperation' })) { setIsShowErrorTip(false); setOpen(false); setValue(''); callback(); } else { setIsShowErrorTip(true); } }; const triggerRender = () => { if (!React.isValidElement(children)) { return setOpen(true)}>{children}; } return React.cloneElement(children as React.ReactElement, { onClick: () => { setOpen(true); }, }); }; return (
event.stopPropagation()}> { setOpen(false); setIsShowErrorTip(false); setValue(''); }} >
{formatMessage({ id: 'component.oneKeyCopy.content' })}
setValue(e.target.value)} /> setValue(formatMessage({ id: 'component.oneKeyCopy.confirmOperation' })) } > {formatMessage({ id: 'component.oneKeyCopy.oneKey' })}
{isShowErrorTip && (

{formatMessage({ id: 'component.oneKeyCopy.tip' })}

)}
{triggerRender()}
); }; export default OneKeyCopyModal;