{"version":3,"sources":["../src/components/link.tsx"],"sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport { ComponentProps, forwardRef, ForwardRefExoticComponent } from \"react\";\nimport { cva, VariantProps } from \"class-variance-authority\";\n\ninterface LinkProps extends ComponentProps<\"a\">, VariantProps<typeof link_cva> {\n  asChild?: boolean;\n  newTab?: boolean;\n}\n\nconst link_cva = cva(\"transition-colors\", {\n  variants: {\n    underline: {\n      always: \"underline\",\n      hover: \"no-underline hover:underline\",\n      none: \"no-underline\",\n    },\n    primary: {\n      true: \"text-txt-primary\",\n      false: \"text-inherit decoration-inherit\",\n    },\n  },\n});\n\n/**\n * The Link component extends the `<a>` element, customised according to the MYDS theme.\n * @example\n * <Link href=\"https://design.digital.gov.my\" newTab primary underline=\"always\">MYDS</Link>\n * @see {@link https://design.digital.gov.my/?path=/docs/myds-react-link--docs}\n */\nconst Link: ForwardRefExoticComponent<LinkProps> = forwardRef(\n  (\n    {\n      asChild,\n      children,\n      className,\n      href,\n      newTab = false,\n      primary = false,\n      underline = \"always\",\n      ...props\n    },\n    ref,\n  ) => {\n    const Comp = asChild ? Slot : \"a\";\n\n    return (\n      <Comp\n        ref={ref}\n        href={href}\n        className={link_cva({ primary, underline, className })}\n        target={newTab ? \"_blank\" : \"_self\"}\n        {...props}\n      >\n        {children}\n      </Comp>\n    );\n  },\n);\nLink.displayName = \"Link\";\n\nexport { Link };\n"],"mappings":"uDAAA,OAAS,QAAAA,MAAY,uBACrB,OAAyB,cAAAC,MAA6C,QACtE,OAAS,OAAAC,MAAyB,2BA4C5B,cAAAC,MAAA,oBArCN,IAAMC,EAAWC,EAAI,oBAAqB,CACxC,SAAU,CACR,UAAW,CACT,OAAQ,YACR,MAAO,+BACP,KAAM,cACR,EACA,QAAS,CACP,KAAM,mBACN,MAAO,iCACT,CACF,CACF,CAAC,EAQKC,EAA6CC,EACjD,CACEC,EAUAC,IACG,CAXH,IAAAC,EAAAF,EACE,SAAAG,EACA,SAAAC,EACA,UAAAC,EACA,KAAAC,EACA,OAAAC,EAAS,GACT,QAAAC,EAAU,GACV,UAAAC,EAAY,QAtClB,EA+BIP,EAQKQ,EAAAC,EARLT,EAQK,CAPH,UACA,WACA,YACA,OACA,SACA,UACA,cAOF,OACEP,EAHWQ,EAAUS,EAAO,IAG3BC,EAAAC,EAAA,CACC,IAAKb,EACL,KAAMK,EACN,UAAWV,EAAS,CAAE,QAAAY,EAAS,UAAAC,EAAW,UAAAJ,CAAU,CAAC,EACrD,OAAQE,EAAS,SAAW,SACxBG,GALL,CAOE,SAAAN,GACH,CAEJ,CACF,EACAN,EAAK,YAAc","names":["Slot","forwardRef","cva","jsx","link_cva","cva","Link","forwardRef","_a","ref","_b","asChild","children","className","href","newTab","primary","underline","props","__objRest","Slot","__spreadProps","__spreadValues"]}