import { useState } from 'react'; import type * as React from 'react'; import { AnalyticsOverrideProps, AnalyticsParentDataProps } from '../analytics'; import { Button } from '../Button'; import { Dialog } from '../Dialog'; import { ExternalLinkIcon } from '../Icons'; import { t } from '../i18n'; import classNames from 'classnames'; import useThirdPartyExternalLinkAnalytics from './useThirdPartyExternalLinkAnalytics'; export interface ThirdPartyExternalLinkProps extends AnalyticsOverrideProps, AnalyticsParentDataProps { /** An id of an another element on the page that provides additional descriptive content for the anchor link */ ariaDescribedby?: string; /** External link url. The destination. */ href: string; /** External link text. This text will appear in the button triggering the dialog. */ children: string; /** Additional classes to be applied to the external link button. */ className?: string; /** Specify the URL users should visit to learn more about your application's external link policy. */ learnMoreUrl?: string; /** Text informing the user where they are. This text will appear in both the dialog heading and body. */ origin: string; } /** * For information about how and when to use this component, * [refer to its full documentation page](https://design.cms.gov/components/third-party-external-link/). */ const ThirdPartyExternalLink = (props: ThirdPartyExternalLinkProps) => { const { contentRef, buttonAnalyticsHandler } = useThirdPartyExternalLinkAnalytics(props); const { href, children, className, learnMoreUrl, origin, ariaDescribedby } = props; const [showDialog, setShowDialog] = useState(false); function open(event: React.SyntheticEvent) { event.preventDefault(); setShowDialog(true); } function close() { setShowDialog(false); } return ( <> {children} {t('thirdPartyExternalLink.confirmationButtonText')} , , ]} isOpen={showDialog} >

{t('thirdPartyExternalLink.dialogBody')}

{t('thirdPartyExternalLink.learnMoreText')}.

); }; ThirdPartyExternalLink.defaultProps = {}; export default ThirdPartyExternalLink;