{"version":3,"file":"Link.cjs","sources":["../../../../src/components/link/Link.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport React, { useId } from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport type { LinkProps } from \"./types.js\";\n\ntype LinkComponent = <ElementType extends React.ElementType = \"a\">(\n    props: LinkProps<ElementType>,\n) => React.ReactElement | null;\n\nexport const Link = React.forwardRef(function Link<\n    ElementType extends React.ElementType = \"a\",\n>(props: LinkProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n    const {\n        external = false,\n        className = \"\",\n        children,\n        as = \"a\",\n        ...rest\n    } = props;\n    const Component = as;\n\n    const srId = useId();\n\n    return (\n        <Component\n            ref={ref}\n            className={clsx(\"jkl-link\", className, {\n                \"jkl-link--external\": external,\n            })}\n            aria-describedby={external ? srId : undefined}\n            {...rest}\n        >\n            <span className=\"jkl-link__content\">{children}</span>\n            {(external || rest.target === \"_blank\") && (\n                <span hidden={true} id={srId}>\n                    Ekstern lenke\n                </span>\n            )}\n        </Component>\n    );\n}) as LinkComponent;\n"],"names":["Link","React","forwardRef","props","ref","external","className","children","as","rest","Component","srId","useId","jsxs","clsx","jsx","target","hidden","id"],"mappings":"gLASaA,EAAOC,EAAMC,WAAW,SAEnCC,EAA+BC,GAC7B,MACIC,SAAAA,GAAW,EACXC,UAAAA,EAAY,GACZC,SAAAA,EACAC,GAAAA,EAAK,OACFC,GACHN,EACEO,EAAYF,EAEZG,EAAOC,EAAAA,QAEb,OACIC,EAAAA,KAACH,EAAA,CACGN,IAAAA,EACAE,UAAWQ,EAAAA,KAAK,WAAYR,EAAW,CACnC,qBAAsBD,IAE1B,mBAAkBA,EAAWM,OAAO,KAChCF,EAEJF,SAAA,CAAAQ,EAAAA,IAAC,OAAA,CAAKT,UAAU,oBAAqBC,SAAAA,KACnCF,GAA4B,WAAhBI,EAAKO,SACfD,EAAAA,IAAC,QAAKE,QAAQ,EAAMC,GAAIP,EAAMJ,SAAA,oBAM9C"}