// TODO: This component will not work with the Next Link component in Next.js 16+ as legacyBehavior as has been deprecated in 15. Need to find a solution. 'use client'; import React, { ForwardedRef, RefObject, forwardRef } from 'react'; import { mergeProps, useFocusRing, useLink } from 'react-aria'; import { ArrowRightIcon } from '../icon/index.js'; import { styles as linkStyles } from './link.styles.js'; import { type LinkProps } from './link.types.js'; export function BaseLink( { className, children, href, iconBefore: IconBefore, iconAfter: IconAfter, iconSize = 'small', target, type = 'standalone', underline = true, ...props }: LinkProps, ref: ForwardedRef, ) { const { linkProps } = useLink({ ...props, elementType: 'a' }, ref as RefObject); const { isFocusVisible, focusProps } = useFocusRing(); const styles = linkStyles({ type, underline, isFocusVisible }); if (type === 'standalone' && !IconBefore && !IconAfter) { IconBefore = ArrowRightIcon; } return ( {IconBefore && } {children} {IconAfter && } ); } export const Link = forwardRef(BaseLink);