design-react-kit
Version:
Componenti React per Bootstrap 5
1 lines • 1.76 kB
Source Map (JSON)
{"version":3,"sources":["../../src/Forward/Forward.tsx"],"sourcesContent":["import React, { FC, AnchorHTMLAttributes } from 'react';\nimport classNames from 'classnames';\n\nexport interface ForwardProps extends AnchorHTMLAttributes<HTMLAnchorElement> {\n /** Classi aggiuntive da usare per il componente Forward */\n className?: string;\n /** Riferimento al nodo a cui scorrere quando premuto */\n // scrollToRef: MutableRefObject<Element | null>;\n testId?: string;\n}\n\nexport const Forward: FC<ForwardProps> = ({ className, children, testId, ...attributes }) => {\n const classes = classNames(className, 'forward');\n return (\n <a\n className={classes}\n onClick={(e) => {\n e.preventDefault();\n if (attributes.href) {\n const scrollToRef = document.querySelector(attributes.href);\n if (scrollToRef) {\n scrollToRef.scrollIntoView({\n behavior: 'smooth',\n block: 'start'\n });\n }\n }\n }}\n data-testid={testId}\n {...attributes}\n >\n {children}\n </a>\n );\n};\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgD,sBAChDC,EAAuB,2BAUVH,EAA4B,CAAC,CAAE,UAAAI,EAAW,SAAAC,EAAU,OAAAC,EAAQ,GAAGC,CAAW,IAAM,CAC3F,IAAMC,KAAU,EAAAC,SAAWL,EAAW,SAAS,EAC/C,OACE,EAAAM,QAAA,cAAC,KACC,UAAWF,EACX,QAAUG,GAAM,CAEd,GADAA,EAAE,eAAe,EACbJ,EAAW,KAAM,CACnB,IAAMK,EAAc,SAAS,cAAcL,EAAW,IAAI,EACtDK,GACFA,EAAY,eAAe,CACzB,SAAU,SACV,MAAO,OACT,CAAC,CAEL,CACF,EACA,cAAaN,EACZ,GAAGC,GAEHF,CACH,CAEJ","names":["Forward_exports","__export","Forward","__toCommonJS","import_react","import_classnames","className","children","testId","attributes","classes","classNames","React","e","scrollToRef"]}