import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { Link } from 'react-router-dom'; import { ReactComponent as ArrowRightAltIcon } from '@material-symbols/svg-600/outlined/arrow_right_alt.svg'; import { ReactComponent as ContentCopyIcon } from '@material-symbols/svg-600/outlined/content_copy.svg'; import SwipeableViews from 'react-swipeable-views'; import { ColumnBackButton } from 'flavours/glitch/components/column_back_button'; import { Icon } from 'flavours/glitch/components/icon'; import { me, domain } from 'flavours/glitch/initial_state'; import { useAppSelector } from 'flavours/glitch/store'; const messages = defineMessages({ shareableMessage: { id: 'onboarding.share.message', defaultMessage: 'I\'m {username} on #Mastodon! Come follow me at {url}' }, }); class CopyPasteText extends PureComponent { static propTypes = { value: PropTypes.string, }; state = { copied: false, focused: false, }; setRef = c => { this.input = c; }; handleInputClick = () => { this.setState({ copied: false }); this.input.focus(); this.input.select(); this.input.setSelectionRange(0, this.props.value.length); }; handleButtonClick = e => { e.stopPropagation(); const { value } = this.props; navigator.clipboard.writeText(value); this.input.blur(); this.setState({ copied: true }); this.timeout = setTimeout(() => this.setState({ copied: false }), 700); }; handleFocus = () => { this.setState({ focused: true }); }; handleBlur = () => { this.setState({ focused: false }); }; componentWillUnmount () { if (this.timeout) clearTimeout(this.timeout); } render () { const { value } = this.props; const { copied, focused } = this.state; return (