{"version":3,"sources":["components/SubNavRelatedLinks/index.module.scss","components/SubNavRelatedLinks/index.tsx","react/RoutableLink/index.js","ts/enums.ts","ts/handleAnchorOffset.ts"],"names":["module","exports","withSitecoreContext","props","_fields$children","_fields$heading","fields","sitecoreContext","isEditing","pageEditing","subNavContainerRef","useRef","pathname","useLocation","links","children","filter","x","_x$fields","_x$fields$link","_x$fields2","link","value","href","linkText","useEffect","current","handleAnchorOffset","heading","length","React","createElement","className","css","subNavContainer","ref","Text","field","tag","title","innerContainer","list","map","index","key","listItem","Fragment","Link","RoutableLink","listItemLink","data-chevron","data-color","Colors","GREY","_props$field","_props$field$value","_props$field2","_props$field3","_props$field3$value","_props$field4","_props$field4$value","_props$field6","hasValidHref","editable","target","linktype","ariaLabelObj","ariaLabel","_props$field5","_value$href","newProps","_objectWithoutProperties","startsWith","RouterLink","Object","assign","to","text","linkProps","_objectSpread","Sizes","Themes","urlHistory","getOffsetFromTopOfPage","el","rect","getBoundingClientRect","scrollTop","window","pageYOffset","document","documentElement","top","performOffset","e","_document","_document$body","_document2","_document2$body","preventDefault","header","body","querySelector","anchor","closest","hash","anchorPosition","offsetAmount","offsetHeight","scrollIntoView","behavior","block","inline","scrollTo","push","handleAnchorOffsetUrlHash","setTimeout","_document3","_document4","_document4$body","location","test","container","history","anchorLinks","querySelectorAll","forEach","addEventListener"],"mappings":"4FACAA,EAAOC,QAAU,CAAC,gBAAkB,4CAA4C,MAAQ,kCAAkC,eAAiB,2CAA2C,KAAO,iCAAiC,SAAW,qCAAqC,aAAe,2C,kCCD7R,yFAsDeC,2CA9CY,SAACC,GAAW,IAADC,EAAAC,EAC5BC,EAA4BH,EAA5BG,OAAQC,EAAoBJ,EAApBI,gBACVC,EAA2B,OAAfD,QAAe,IAAfA,OAAe,EAAfA,EAAiBE,YAC7BC,EAAqBC,mBACnBC,EAAaC,cAAbD,SAEFE,EAAc,OAANR,QAAM,IAANA,GAAgB,QAAVF,EAANE,EAAQS,gBAAQ,IAAAX,OAAV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,QAANC,EAARD,EAAUI,YAAI,IAAAH,OAAN,EAARA,EAAgBI,cAAcR,EAAE9B,OAAOwC,QAAQ,KAAKC,MAC7DC,EAAiBvB,EAAuBoB,GACxCI,EAAeP,EAAOQ,aAAe,GAMzC,OALAL,EAAOM,eAAe,CAACC,SAAU,SAAUC,MAAO,QAASC,OAAQ,YACnExB,OAAOyB,SAAS,CAACrB,IAAKc,EAAiBC,EAAcG,SAAU,WAC3D5B,GACAA,EAAWgC,KAAKpB,EAAE9B,OAAOwC,QAAQ,KAAKC,OAEnC,EAGJ,SAASU,IAEZC,YAAW,WAAW,IAADC,EAAAC,EAAAC,EACbd,EAAOjB,OAAOgC,SAASf,KAC3B,GAAW,gBAARA,GACe,GAAfA,EAAK5E,QAAiB,2BAA4B4F,KAAKhB,GAA1D,CACA,IAAIF,EAAiB,QAAXc,EAAG3B,gBAAQ,IAAA2B,OAAA,EAARA,EAAUhB,KAAKC,cAAcG,GAE1C,GAAIF,EAAJ,CACA,IAAIH,EAAiB,QAAXkB,EAAG5B,gBAAQ,IAAA4B,GAAM,QAANC,EAARD,EAAUjB,YAAI,IAAAkB,OAAN,EAARA,EAAgBjB,cAAc,UACvCI,EAAiBvB,EAAuBoB,GACxCI,EAAeP,EAAOQ,aAAe,GACzCL,EAAOM,eAAe,CAACC,SAAU,SAAUC,MAAO,QAASC,OAAQ,YACnExB,OAAOyB,SAAS,CAACrB,IAAKc,EAAiBC,EAAcG,SAAU,eACjE,GAGC,SAASnF,EAAmB+F,EAAWC,GAC1C,IAAMC,EAAuB,OAATF,QAAS,IAATA,OAAS,EAATA,EAAWG,iBAAiB,gBAChD3C,EAAayC,EACbC,EAAYE,SAAQ,SAACzG,GACjBA,EAAK0G,iBAAiB,QAASlC,GAAe,MA3CtD","file":"static/js/SubNavRelatedLinks.8986a550.chunk.js","sourcesContent":["// extracted by mini-css-extract-plugin\nmodule.exports = {\"subNavContainer\":\"SubNavRelatedLinks_subNavContainer__1_j9C\",\"title\":\"SubNavRelatedLinks_title__2FIct\",\"innerContainer\":\"SubNavRelatedLinks_innerContainer__2A0O2\",\"list\":\"SubNavRelatedLinks_list__1--us\",\"listItem\":\"SubNavRelatedLinks_listItem__3uKS8\",\"listItemLink\":\"SubNavRelatedLinks_listItemLink__2jP3F\"};","import React, { useRef, useEffect } from 'react';\r\nimport { Link, Text, withSitecoreContext } from '@sitecore-jss/sitecore-jss-react';\r\nimport { RoutableLink } from '../../react/RoutableLink';\r\nimport { Colors, Targets } from '../../ts/enums';\r\nimport { useLocation } from \"react-router-dom\";\r\nimport { handleAnchorOffset } from '../../ts/handleAnchorOffset'\r\nimport css from './index.module.scss';\r\n\r\nconst SubNavRelatedLinks = (props) => {\r\n const { fields, sitecoreContext } = props;\r\n const isEditing = sitecoreContext?.pageEditing;\r\n const subNavContainerRef = useRef();\r\n const { pathname } = useLocation();\r\n\r\n const links = fields?.children?.filter(x => isEditing || x.fields?.link?.value.href && x.fields?.linkText.value)\r\n\r\n useEffect(() => {\r\n if (!subNavContainerRef.current) return;\r\n if(!isEditing) {\r\n handleAnchorOffset(subNavContainerRef.current);\r\n }\r\n },[pathname]);\r\n\r\n return (\r\n isEditing || fields?.heading?.value && links?.length > 0 ?\r\n \r\n\r\n \r\n\r\n \r\n
\r\n {\r\n links?.map((link, index) =>\r\n - \r\n {\r\n isEditing ?\r\n <>\r\n \r\n \r\n >\r\n : \r\n \r\n \r\n }\r\n
\r\n )\r\n }\r\n
\r\n
\r\n \r\n : null\r\n );\r\n}\r\n\r\nexport default withSitecoreContext()(SubNavRelatedLinks);","import React from 'react';\r\nimport { Link } from '@sitecore-jss/sitecore-jss-react';\r\n// note we're aliasing the router's link component name, since it conflicts with JSS' link component\r\nimport { Link as RouterLink } from 'react-router-dom';\r\n\r\n/** React component that turns Sitecore link values that start with / into react-router route links */\r\nconst RoutableLink = (props) => {\r\n const hasValidHref = props.field?.value?.href;\r\n const isEditing = props?.editable && props?.field?.editable;\r\n const target = props?.field?.value?.linktype == \"external\" ? \"_blank\" : props.field?.value?.target || \"_self\";\r\n\r\n // only want to apply the routing link if not editing (if editing, need to render editable link value)\r\n\r\n var ariaLabelObj = {};\r\n if(props?.ariaLabel && props?.ariaLabel.length > 0){\r\n ariaLabelObj[\"aria-label\"] = props?.ariaLabel;\r\n }\r\n if (hasValidHref && !isEditing) {\r\n\r\n const value = props?.field?.value;\r\n var { field, editable, ariaLabel, ...newProps } = props;\r\n\r\n // determine if a link is a route or not. This logic may not be appropriate for all usages.\r\n if (value?.href?.startsWith('/')) {\r\n return (\r\n \r\n {\r\n \r\n {props?.children || value?.text || value?.href}\r\n \r\n }\r\n \r\n );\r\n }\r\n }\r\n var linkProps = { ...props, field: { value: { ...props?.field?.value, target: target } } };\r\n var {ariaLabel,...newProps} = linkProps;\r\n return {props?.children};\r\n};\r\n\r\n// usage - drop-in replacement for JSS' Link component\r\nexport { RoutableLink }","export enum Colors {\r\n RED = 'red',\r\n TERRACOTTA = 'terracotta',\r\n VIOLET = 'violet',\r\n DARKVIOLET = 'darkviolet',\r\n YELLOW = 'yellow',\r\n LAKE = 'lake',\r\n DARKLAKE = 'darklake',\r\n GREY = 'grey',\r\n WHITE = 'white' \r\n};\r\n\r\nexport enum Sizes {\r\n SMALL = 'small',\r\n MEDIUM = 'medium',\r\n LARGE = 'large'\r\n};\r\n\r\nexport enum Targets {\r\n SELF = '_self',\r\n BLANK = '_blank',\r\n};\r\n\r\nexport enum Themes {\r\n DARK = 'dark',\r\n LIGHT = 'light',\r\n WHITE = 'white'\r\n}","var urlHistory;\r\n\r\nfunction getOffsetFromTopOfPage(el) {\r\n let rect = el.getBoundingClientRect(),\r\n scrollTop = window.pageYOffset || document.documentElement.scrollTop;\r\n return rect.top + scrollTop;\r\n}\r\n\r\nfunction performOffset(e){\r\n e.preventDefault();\r\n let header = document?.body?.querySelector('header');\r\n let anchor = document?.body?.querySelector(e.target.closest('a').hash);\r\n let anchorPosition = getOffsetFromTopOfPage(anchor);\r\n let offsetAmount = header.offsetHeight + 15;\r\n anchor.scrollIntoView({behavior: \"smooth\", block: 'start', inline: 'nearest'});\r\n window.scrollTo({top: anchorPosition - offsetAmount, behavior: 'smooth'});\r\n if (urlHistory) {\r\n urlHistory.push(e.target.closest('a').hash);\r\n }\r\n return false;\r\n}\r\n\r\nexport function handleAnchorOffsetUrlHash(){\r\n //timeout of zero to wait for dom load\r\n setTimeout(function(){\r\n let hash = window.location.hash;\r\n if(hash == \"#maincontent\") return;\r\n if(hash.length == 0 || !(/^[A-Za-z\\#]+[\\w\\-\\:\\.]*$/).test(hash)) return;\r\n let anchor = document?.body.querySelector(hash);\r\n\r\n if(!anchor) return;\r\n let header = document?.body?.querySelector('header');\r\n let anchorPosition = getOffsetFromTopOfPage(anchor);\r\n let offsetAmount = header.offsetHeight + 15;\r\n anchor.scrollIntoView({behavior: \"smooth\", block: 'start', inline: 'nearest'});\r\n window.scrollTo({top: anchorPosition - offsetAmount, behavior: 'smooth'});\r\n },0);\r\n}\r\n\r\nexport function handleAnchorOffset(container, history?) {\r\n const anchorLinks = container?.querySelectorAll('a[href^=\"#\"]');\r\n urlHistory = history;\r\n anchorLinks.forEach((link) => {\r\n link.addEventListener('click', performOffset, false);\r\n });\r\n}"],"sourceRoot":""}