@cruk/chakra-components 4.0.0-dev.31 → 4.0.0-dev.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),n=require("@chakra-ui/react"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),n=require("@chakra-ui/react"),t=require("react"),i=require("../Button/index.js"),r=require("../Button/IconButton.js");require("../Flex/index.js");var s=require("../Heading/index.js");require("../Icon/index.js");var o=require("../List/index.js"),a=require("@chakra-ui/icons");const d=n.forwardRef((d,l)=>{const{children:c,...x}=d,[u,h]=t.useState(!1),[g,j]=t.useState(!1),[p,m]=t.useState(!1),b=t.Children.toArray(c),f=n.useBreakpointValue({base:5,lg:8},{fallback:"md"}),v=b.slice(0,u?b.length:f),w="OnThisPage-container";return t.useEffect(()=>{const e=()=>{const e=document.getElementById(w);e&&j(window.scrollY>e.offsetTop+e.offsetHeight)};e(),window.addEventListener("scroll",e);const n=()=>{const e=document.querySelector('[data-testid="survey-root"]');m(!!e)};n();const t=new MutationObserver(n);return t.observe(document.body,{childList:!0,subtree:!0}),()=>{window.removeEventListener("scroll",e),t.disconnect()}},[]),c?e.jsx(n.Box,{paddingTop:{base:4,md:8,lg:10},ref:l,"data-testid":w,id:w,children:e.jsxs(n.Box,{backgroundColor:"onThisPagePrimaryBg",padding:{base:4,md:6,lg:8},...x,children:[e.jsxs("nav",{children:[e.jsx(s.Heading,{fontSize:{base:"headings.sm",lg:"headings.lg"},lineHeight:{base:"headings.sm",lg:"headings.lg"},display:"flex",pb:4,children:"On this page"}),e.jsx(n.UnorderedList,{marginInlineStart:0,paddingInlineStart:0,sx:{li:{display:"flex",paddingBottom:2,alignItems:"center"}},styleType:"none",children:v.map((n,t)=>e.jsx(o.ArrowDownListItem,{children:n},t))})]}),f&&b.length>f&&e.jsx(n.Flex,{justifyContent:"flex-end",children:e.jsx(i.Button,{mt:4,variant:"linkNoDecoration",rightIcon:u?e.jsx(a.ChevronUpIcon,{boxSize:6}):e.jsx(a.ChevronDownIcon,{boxSize:6}),onClick:()=>h(!u),children:u?"Show less":"Show all"})}),g&&e.jsx(n.Portal,{children:e.jsx(n.Flex,{justifyContent:"center",pointerEvents:"none",children:e.jsx(n.Container,{position:"fixed",bottom:{base:p?16:4,md:20},children:e.jsx(n.Flex,{justifyContent:"end",paddingRight:{base:4,md:8},children:e.jsx(n.Box,{pointerEvents:"auto",zIndex:"sticky",position:"relative",children:e.jsx(n.Link,{href:`#${w}`,children:e.jsx(r.IconButton,{icon:e.jsx(a.ArrowUpIcon,{}),variant:"backToTop","aria-label":"Back to top"})})})})})})})]})}):e.jsx(e.Fragment,{})});exports.OnThisPageHeadings=d;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/OnThisPage/index.tsx"],"sourcesContent":[null],"names":["OnThisPageHeadings","forwardRef","props","ref","children","rest","shouldShowAll","setShouldShowAll","React","useState","showBackToTop","setShowBackToTop","headings","Children","toArray","noOfHeadings","useBreakpointValue","base","lg","fallback","displayHeadings","slice","length","boxId","useEffect","handleScroll","box","document","getElementById","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/OnThisPage/index.tsx"],"sourcesContent":[null],"names":["OnThisPageHeadings","forwardRef","props","ref","children","rest","shouldShowAll","setShouldShowAll","React","useState","showBackToTop","setShowBackToTop","hasHotjarSurvey","setHasHotjarSurvey","headings","Children","toArray","noOfHeadings","useBreakpointValue","base","lg","fallback","displayHeadings","slice","length","boxId","useEffect","handleScroll","box","document","getElementById","window","scrollY","offsetTop","offsetHeight","addEventListener","checkForHotjarSurvey","survey","querySelector","observer","MutationObserver","observe","body","childList","subtree","removeEventListener","disconnect","_jsx","Box","paddingTop","md","id","_jsxs","backgroundColor","padding","Heading","fontSize","lineHeight","display","pb","UnorderedList","marginInlineStart","paddingInlineStart","sx","li","paddingBottom","alignItems","styleType","map","heading","index","ArrowDownListItem","Flex","justifyContent","Button","mt","variant","rightIcon","ChevronUpIcon","boxSize","ChevronDownIcon","onClick","Portal","pointerEvents","Container","position","bottom","paddingRight","zIndex","Link","href","IconButton","icon","ArrowUpIcon"],"mappings":"mUAsBA,MAAMA,EAAqBC,EAAAA,WAAmC,CAACC,EAAOC,KACpE,MAAMC,SAAEA,KAAaC,GAASH,GAEvBI,EAAeC,GAAoBC,EAAMC,UAAS,IAClDC,EAAeC,GAAoBH,EAAMC,UAAS,IAClDG,EAAiBC,GAAsBL,EAAMC,UAAS,GAEvDK,EAAWN,EAAMO,SAASC,QAAQZ,GAElCa,EAAeC,EAAAA,mBACnB,CACEC,KAAM,EACNC,GAAI,GAEN,CAAEC,SAAU,OAGRC,EAAkBR,EAASS,MAC/B,EACAjB,EAAgBQ,EAASU,OAASP,GAI9BQ,EAAQ,uBA+Bd,OA7BAC,EAAAA,UAAU,KACR,MAAMC,EAAe,KACnB,MAAMC,EAAMC,SAASC,eAAeL,GAE/BG,GAELjB,EAAiBoB,OAAOC,QAAUJ,EAAIK,UAAYL,EAAIM,eAKxDP,IACAI,OAAOI,iBAAiB,SAAUR,GAElC,MAAMS,EAAuB,KAC3B,MAAMC,EAASR,SAASS,cAAc,+BACtCzB,IAAqBwB,IAGvBD,IACA,MAAMG,EAAW,IAAIC,iBAAiBJ,GAGtC,OAFAG,EAASE,QAAQZ,SAASa,KAAM,CAAEC,WAAW,EAAMC,SAAS,IAErD,KACLb,OAAOc,oBAAoB,SAAUlB,GACrCY,EAASO,eAEV,IAEE1C,EAKH2C,EAAAA,IAACC,EAAAA,IAAG,CACFC,WAAY,CAAE9B,KAAM,EAAG+B,GAAI,EAAG9B,GAAI,IAClCjB,IAAKA,EAAG,cACKsB,EACb0B,GAAI1B,EAAKrB,SAETgD,EAAAA,KAACJ,EAAAA,IAAG,CACFK,gBAAgB,sBAChBC,QAAS,CAAEnC,KAAM,EAA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OrB,SACrB2C,EAAAA,IAAC4C,EAAAA,WAAU,CACTC,KAAM7C,EAAAA,IAAC8C,EAAAA,YAAW,CAAA,GAClBjB,QAAQ,YAAW,aACR,iCApExB7B,EAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,Fragment as n,jsxs as
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as t}from"react/jsx-runtime";import{forwardRef as i,useBreakpointValue as o,Box as r,UnorderedList as s,Flex as d,Portal as a,Container as l,Link as c}from"@chakra-ui/react";import m,{useEffect as h}from"react";import{Button as g}from"../Button/index.js";import{IconButton as p}from"../Button/IconButton.js";import"../Flex/index.js";import{Heading as f}from"../Heading/index.js";import"../Icon/index.js";import{ArrowDownListItem as u}from"../List/index.js";import{ChevronUpIcon as b,ChevronDownIcon as x,ArrowUpIcon as y}from"@chakra-ui/icons";const v=i((i,v)=>{const{children:j,...S}=i,[k,w]=m.useState(!1),[I,B]=m.useState(!1),[T,C]=m.useState(!1),E=m.Children.toArray(j),L=o({base:5,lg:8},{fallback:"md"}),z=E.slice(0,k?E.length:L),H="OnThisPage-container";return h(()=>{const e=()=>{const e=document.getElementById(H);e&&B(window.scrollY>e.offsetTop+e.offsetHeight)};e(),window.addEventListener("scroll",e);const n=()=>{const e=document.querySelector('[data-testid="survey-root"]');C(!!e)};n();const t=new MutationObserver(n);return t.observe(document.body,{childList:!0,subtree:!0}),()=>{window.removeEventListener("scroll",e),t.disconnect()}},[]),j?e(r,{paddingTop:{base:4,md:8,lg:10},ref:v,"data-testid":H,id:H,children:t(r,{backgroundColor:"onThisPagePrimaryBg",padding:{base:4,md:6,lg:8},...S,children:[t("nav",{children:[e(f,{fontSize:{base:"headings.sm",lg:"headings.lg"},lineHeight:{base:"headings.sm",lg:"headings.lg"},display:"flex",pb:4,children:"On this page"}),e(s,{marginInlineStart:0,paddingInlineStart:0,sx:{li:{display:"flex",paddingBottom:2,alignItems:"center"}},styleType:"none",children:z.map((n,t)=>e(u,{children:n},t))})]}),L&&E.length>L&&e(d,{justifyContent:"flex-end",children:e(g,{mt:4,variant:"linkNoDecoration",rightIcon:e(k?b:x,{boxSize:6}),onClick:()=>w(!k),children:k?"Show less":"Show all"})}),I&&e(a,{children:e(d,{justifyContent:"center",pointerEvents:"none",children:e(l,{position:"fixed",bottom:{base:T?16:4,md:20},children:e(d,{justifyContent:"end",paddingRight:{base:4,md:8},children:e(r,{pointerEvents:"auto",zIndex:"sticky",position:"relative",children:e(c,{href:`#${H}`,children:e(p,{icon:e(y,{}),variant:"backToTop","aria-label":"Back to top"})})})})})})})]})}):e(n,{})});export{v as OnThisPageHeadings};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/OnThisPage/index.tsx"],"sourcesContent":[null],"names":["OnThisPageHeadings","forwardRef","props","ref","children","rest","shouldShowAll","setShouldShowAll","React","useState","showBackToTop","setShowBackToTop","headings","Children","toArray","noOfHeadings","useBreakpointValue","base","lg","fallback","displayHeadings","slice","length","boxId","useEffect","handleScroll","box","document","getElementById","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/OnThisPage/index.tsx"],"sourcesContent":[null],"names":["OnThisPageHeadings","forwardRef","props","ref","children","rest","shouldShowAll","setShouldShowAll","React","useState","showBackToTop","setShowBackToTop","hasHotjarSurvey","setHasHotjarSurvey","headings","Children","toArray","noOfHeadings","useBreakpointValue","base","lg","fallback","displayHeadings","slice","length","boxId","useEffect","handleScroll","box","document","getElementById","window","scrollY","offsetTop","offsetHeight","addEventListener","checkForHotjarSurvey","survey","querySelector","observer","MutationObserver","observe","body","childList","subtree","removeEventListener","disconnect","_jsx","Box","paddingTop","md","id","_jsxs","backgroundColor","padding","Heading","fontSize","lineHeight","display","pb","UnorderedList","marginInlineStart","paddingInlineStart","sx","li","paddingBottom","alignItems","styleType","map","heading","index","ArrowDownListItem","Flex","justifyContent","Button","mt","variant","rightIcon","ChevronUpIcon","ChevronDownIcon","boxSize","onClick","Portal","pointerEvents","Container","position","bottom","paddingRight","zIndex","Link","href","IconButton","icon","ArrowUpIcon"],"mappings":"mkBAsBA,MAAMA,EAAqBC,EAAmC,CAACC,EAAOC,KACpE,MAAMC,SAAEA,KAAaC,GAASH,GAEvBI,EAAeC,GAAoBC,EAAMC,UAAS,IAClDC,EAAeC,GAAoBH,EAAMC,UAAS,IAClDG,EAAiBC,GAAsBL,EAAMC,UAAS,GAEvDK,EAAWN,EAAMO,SAASC,QAAQZ,GAElCa,EAAeC,EACnB,CACEC,KAAM,EACNC,GAAI,GAEN,CAAEC,SAAU,OAGRC,EAAkBR,EAASS,MAC/B,EACAjB,EAAgBQ,EAASU,OAASP,GAI9BQ,EAAQ,uBA+Bd,OA7BAC,EAAU,KACR,MAAMC,EAAe,KACnB,MAAMC,EAAMC,SAASC,eAAeL,GAE/BG,GAELjB,EAAiBoB,OAAOC,QAAUJ,EAAIK,UAAYL,EAAIM,eAKxDP,IACAI,OAAOI,iBAAiB,SAAUR,GAElC,MAAMS,EAAuB,KAC3B,MAAMC,EAASR,SAASS,cAAc,+BACtCzB,IAAqBwB,IAGvBD,IACA,MAAMG,EAAW,IAAIC,iBAAiBJ,GAGtC,OAFAG,EAASE,QAAQZ,SAASa,KAAM,CAAEC,WAAW,EAAMC,SAAS,IAErD,KACLb,OAAOc,oBAAoB,SAAUlB,GACrCY,EAASO,eAEV,IAEE1C,EAKH2C,EAACC,EAAG,CACFC,WAAY,CAAE9B,KAAM,EAAG+B,GAAI,EAAG9B,GAAI,IAClCjB,IAAKA,EAAG,cACKsB,EACb0B,GAAI1B,EAAKrB,SAETgD,EAACJ,EAAG,CACFK,gBAAgB,sBAChBC,QAAS,CAAEnC,KAAM,EAAG+B,GAAI,EAAG9B,GAAI,MAC3Bf,EAAID,SAAA,CAERgD,mBACEL,EAACQ,GACCC,SAAU,CAAErC,KAAM,cAAeC,GAAI,eACrCqC,WAAY,CAAEtC,KAAM,c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