@fremtind/jokul 1.6.0 → 2.0.0
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.
- package/build/build-stats.html +1 -1
- package/build/cjs/components/cookie-consent/CookieConsent.cjs +1 -1
- package/build/cjs/components/cookie-consent/CookieConsent.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/CookieConsent.d.cts +2 -6
- package/build/cjs/components/cookie-consent/CookieConsentContext.cjs +1 -1
- package/build/cjs/components/cookie-consent/CookieConsentContext.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/cookieConsentUtils.cjs +1 -1
- package/build/cjs/components/cookie-consent/cookieConsentUtils.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/cookieConsentUtils.d.cts +1 -2
- package/build/cjs/components/cookie-consent/index.d.cts +2 -2
- package/build/cjs/components/cookie-consent/types.d.cts +8 -1
- package/build/es/components/cookie-consent/CookieConsent.d.ts +2 -6
- package/build/es/components/cookie-consent/CookieConsent.js +1 -1
- package/build/es/components/cookie-consent/CookieConsent.js.map +1 -1
- package/build/es/components/cookie-consent/CookieConsentContext.js +1 -1
- package/build/es/components/cookie-consent/CookieConsentContext.js.map +1 -1
- package/build/es/components/cookie-consent/cookieConsentUtils.d.ts +1 -2
- package/build/es/components/cookie-consent/cookieConsentUtils.js +1 -1
- package/build/es/components/cookie-consent/cookieConsentUtils.js.map +1 -1
- package/build/es/components/cookie-consent/index.d.ts +2 -2
- package/build/es/components/cookie-consent/types.d.ts +8 -1
- package/package.json +1 -1
- package/styles/components/checkbox/checkbox.css +4 -4
- package/styles/components/checkbox/checkbox.min.css +1 -1
- package/styles/components/checkbox-panel/checkbox-panel.css +2 -2
- package/styles/components/checkbox-panel/checkbox-panel.min.css +1 -1
- package/styles/components/countdown/countdown.css +2 -2
- package/styles/components/countdown/countdown.min.css +1 -1
- package/styles/components/feedback/feedback.css +2 -2
- package/styles/components/feedback/feedback.min.css +1 -1
- package/styles/components/file-input/file-input.css +11 -11
- package/styles/components/file-input/file-input.min.css +1 -1
- package/styles/components/input-group/input-group.css +2 -2
- package/styles/components/input-group/input-group.min.css +1 -1
- package/styles/components/loader/loader.css +6 -6
- package/styles/components/loader/loader.min.css +1 -1
- package/styles/components/loader/skeleton-loader.css +5 -5
- package/styles/components/loader/skeleton-loader.min.css +1 -1
- package/styles/components/message/message.css +2 -2
- package/styles/components/message/message.min.css +1 -1
- package/styles/components/modal/modal.css +1 -1
- package/styles/components/modal/modal.min.css +1 -1
- package/styles/components/modal/modal.scss +1 -1
- package/styles/components/progress-bar/progress-bar.css +1 -1
- package/styles/components/progress-bar/progress-bar.min.css +1 -1
- package/styles/components/radio-button/radio-button.css +2 -2
- package/styles/components/radio-button/radio-button.min.css +1 -1
- package/styles/components/radio-panel/radio-panel.css +2 -2
- package/styles/components/radio-panel/radio-panel.min.css +1 -1
- package/styles/components/segmented-control/segmented-control.css +4 -4
- package/styles/components/segmented-control/segmented-control.min.css +1 -1
- package/styles/components/system-message/system-message.css +2 -2
- package/styles/components/system-message/system-message.min.css +1 -1
- package/styles/components/toast/toast.css +4 -4
- package/styles/components/toast/toast.min.css +1 -1
- package/styles/styles.css +37 -37
- package/styles/styles.min.css +2 -2
- package/build/cjs/components/cookie-consent/RequirementCheckbox.cjs +0 -2
- package/build/cjs/components/cookie-consent/RequirementCheckbox.cjs.map +0 -1
- package/build/cjs/components/cookie-consent/RequirementCheckbox.d.cts +0 -9
- package/build/es/components/cookie-consent/RequirementCheckbox.d.ts +0 -9
- package/build/es/components/cookie-consent/RequirementCheckbox.js +0 -2
- package/build/es/components/cookie-consent/RequirementCheckbox.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom"),o=require("../button/Button.cjs"),i=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom"),o=require("../button/Button.cjs"),r=require("../flex/Flex.cjs"),i=require("../link/Link.cjs"),s=require("../modal/Modal.cjs"),a=require("../modal/useModal.cjs"),l=require("./CookieConsentContext.cjs"),c=require("./cookieConsentUtils.cjs");exports.CookieConsent=({blocking:d,onAccept:u,aboutPage:j="https://www.fremtind.no/informasjonskapsler",...k})=>{const{currentConsent:m,cookieName:f,cookieDomain:h,cookiePath:p,requirement:g,isOpen:b,setIsOpen:x,updateCurrentConsents:v}=l.useInternalState(),[C,y]=a.useModal({id:`jkl-cookie-modal-${t.useId()}`,role:d?"alertdialog":"dialog",title:"Informasjonskapsler"});if(t.useEffect((()=>{b?C?.show():C?.hide()}),[C,b]),t.useEffect((()=>{const e=()=>x(!1);return C?.on("hide",e),()=>{C?.off("hide",e)}}),[C,x]),typeof document>"u")return null;if(typeof navigator<"u"&&!navigator.cookieEnabled)return u&&u({functional:"denied",statistics:"denied"}),null;const q=(e=c.convertBooleanConsentObjectToConsentObject({functional:!0,statistics:!0},g))=>{const t=Object.fromEntries(Object.entries(e).filter((([,e])=>typeof e<"u"))),n={...m,...t};c.setConsentCookie({consent:n,name:f,domain:h,path:p}),v(),u?.(n),C?.hide()};return n.createPortal(e.jsxs(s.ModalContainer,{...y.container,...k,"data-cookie-consent-open":b,children:[e.jsx(s.ModalOverlay,{...y.overlay}),e.jsx(s.Modal,{component:"form",...y.modal,onSubmit:e=>{e.preventDefault();const t=new FormData(e.currentTarget),n=c.convertBooleanConsentObjectToConsentObject({functional:"true"===t.get("functional"),statistics:"true"===t.get("statistics")},g);q(n)},children:e.jsxs("form",{children:[e.jsx(s.ModalHeader,{children:e.jsx(s.ModalTitle,{...y.title,children:"Får vi bruke valgfrie informasjonskapsler?"})}),e.jsx(s.ModalBody,{children:e.jsxs(r.Flex,{direction:"column",gap:24,children:[e.jsx("p",{children:"Vi ønsker å samle anonym statistikk for å forstå hvordan nettsidene våre brukes. Det hjelper oss til å gjøre innhold og løsninger bedre og mer brukervennlige."}),e.jsxs("p",{children:[e.jsx(i.Link,{href:j,target:"_blank",children:"Les mer om hvilke informasjonskapsler vi lagrer her"}),"."]})]})}),e.jsxs(s.ModalActions,{children:[e.jsx(o.Button,{variant:"secondary","data-testid":"jkl-cookie-consent-godta-alle",type:"button",onClick:()=>q(),children:"Ja, det er greit"}),e.jsx(o.Button,{variant:"secondary","data-testid":"jkl-cookie-consent-godta",type:"submit",children:"Nei takk"})]})]})})]}),document.body)};
|
|
2
2
|
//# sourceMappingURL=CookieConsent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsent.cjs","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { type FormEventHandler, useEffect, useId } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Button } from \"../button/Button.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalContainer,\n ModalHeader,\n ModalOverlay,\n ModalTitle,\n} from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { useInternalState } from \"./CookieConsentContext.js\";\nimport { RequirementCheckbox } from \"./RequirementCheckbox.js\";\nimport {\n convertBooleanConsentObjectToConsentObject,\n setConsentCookie,\n} from \"./cookieConsentUtils.js\";\nimport type { AcceptConsentCallback, Consent } from \"./types.js\";\n\nexport interface CookieConsentProps {\n blocking?: boolean;\n onAccept?: AcceptConsentCallback;\n}\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const {\n currentConsent,\n cookieName,\n cookieDomain,\n cookiePath,\n requirement,\n isOpen,\n setIsOpen,\n updateCurrentConsents,\n } = useInternalState();\n\n const [instance, modalConfig] = useModal({\n id: `jkl-cookie-modal-${useId()}`,\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: blocking ? \"alertdialog\" : \"dialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n\n useEffect(() => {\n if (isOpen) {\n instance?.show();\n } else {\n instance?.hide();\n }\n }, [instance, isOpen]);\n\n useEffect(() => {\n const onHide = () => setIsOpen(false);\n instance?.on(\"hide\", onHide);\n return () => {\n instance?.off(\"hide\", onHide);\n };\n }, [instance, setIsOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n marketing: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const accept = (\n selection = convertBooleanConsentObjectToConsentObject(\n {\n functional: true,\n statistics: true,\n marketing: true,\n },\n requirement,\n ),\n ) => {\n const selectionWithoutEmptyValues = Object.fromEntries(\n Object.entries(selection).filter(\n ([, value]) => typeof value !== \"undefined\",\n ),\n );\n\n const updatedConsent: Consent = {\n ...currentConsent,\n ...selectionWithoutEmptyValues,\n };\n\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n path: cookiePath,\n });\n\n updateCurrentConsents();\n\n onAccept?.(updatedConsent);\n\n instance?.hide();\n };\n\n const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n\n const formData = new FormData(e.currentTarget);\n\n const newConsents = convertBooleanConsentObjectToConsentObject(\n {\n functional: formData.get(\"functional\") === \"true\",\n statistics: formData.get(\"statistics\") === \"true\",\n marketing: formData.get(\"marketing\") === \"true\",\n },\n requirement,\n );\n\n accept(newConsents);\n };\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...modalConfig.container}\n {...rest}\n data-cookie-consent-open={isOpen}\n >\n <ModalOverlay {...modalConfig.overlay} />\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Velg informasjonskapsler\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <p>\n For at nettsidene skal fungere må vi bruke tekniske\n informasjonskaplser. Disse lagres derfor uten samtykke.\n </p>\n {requirement.functional && (\n <RequirementCheckbox\n name=\"functional\"\n label=\"Tillat funksjonelle\"\n defaultChecked={\n currentConsent.functional === \"accepted\"\n }\n key={`functional-${currentConsent.functional}`}\n >\n Funksjonelle informasjonskapsler lagrer opplysninger\n om din bruk av nettsidene og hvilke innstillinger du\n har gjort, slik at du kan få funksjonalitet\n tilpasset deg.\n </RequirementCheckbox>\n )}\n {requirement.statistics && (\n <RequirementCheckbox\n name=\"statistics\"\n label=\"Tillat statistikk\"\n defaultChecked={\n currentConsent.statistics === \"accepted\"\n }\n key={`statistics-${currentConsent.statistics}`}\n >\n Informasjonskapslene lagrer statistikk som hjelper\n oss med å forstå hvordan nettsidene blir brukt, slik\n at vi kan gjøre dem bedre og enklere å bruke.\n </RequirementCheckbox>\n )}\n {requirement.marketing && (\n <RequirementCheckbox\n name=\"marketing\"\n label=\"Tillat personlig markedsføring\"\n defaultChecked={\n currentConsent.marketing === \"accepted\"\n }\n key={`marketing-${currentConsent.marketing}`}\n >\n Dette gjør at vi kan gi deg mer relevant og\n tilpasset markedsføring, også gjennom våre\n samarbeidspartnere, på for eksempel nettsider,\n annonser og i sosiale medier.\n </RequirementCheckbox>\n )}\n </ModalBody>\n <ModalActions>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta\"\n type=\"submit\"\n >\n Godta mine valg\n </Button>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta-alle\"\n type=\"button\"\n onClick={() => accept()}\n >\n Godta alle\n </Button>\n </ModalActions>\n </Modal>\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["blocking","onAccept","rest","currentConsent","cookieName","cookieDomain","cookiePath","requirement","isOpen","setIsOpen","updateCurrentConsents","useInternalState","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","onHide","on","off","document","navigator","cookieEnabled","functional","marketing","statistics","accept","selection","convertBooleanConsentObjectToConsentObject","selectionWithoutEmptyValues","Object","fromEntries","entries","filter","value","updatedConsent","setConsentCookie","consent","name","domain","path","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","Modal","component","modal","onSubmit","e","preventDefault","formData","FormData","currentTarget","newConsents","get","ModalHeader","ModalTitle","ModalBody","RequirementCheckbox","label","defaultChecked","ModalActions","Button","variant","type","onClick","body"],"mappings":"+YA0B6B,EACzBA,SAAAA,EACAC,SAAAA,KACGC,MAEG,MACFC,eAAAA,EACAC,WAAAA,EACAC,aAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,sBAAAA,GACAC,sBAEGC,EAAUC,GAAeC,WAAS,CACrCC,GAAI,oBAAoBC,EAAAA,UAIxBC,KAAMjB,EAAW,cAAgB,SAGjCkB,MAAO,wBAmBP,GAhBJC,EAAAA,WAAU,KACFX,EACAI,GAAUQ,OAEVR,GAAUS,MAAK,GAEpB,CAACT,EAAUJ,IAEdW,EAAAA,WAAU,KACA,MAAAG,EAAS,IAAMb,GAAU,GACrB,OAAAG,GAAAW,GAAG,OAAQD,GACd,KACOV,GAAAY,IAAI,OAAQF,EAAM,CAChC,GACD,CAACV,EAAUH,WAEHgB,SAAa,IACb,OAAA,KAIX,UAAWC,UAAc,MAAgBA,UAAUC,cAC/C,OAAI1B,GACSA,EAAA,CACL2B,WAAY,SACZC,UAAW,SACXC,WAAY,WAIb,KAGL,MAAAC,EAAS,CACXC,EAAYC,EAAAA,2CACR,CACIL,YAAY,EACZE,YAAY,EACZD,WAAW,GAEftB,MAGJ,MAAM2B,EAA8BC,OAAOC,YACvCD,OAAOE,QAAQL,GAAWM,QACtB,EAAI,CAAAC,YAAkBA,EAAU,OAIlCC,EAA0B,IACzBrC,KACA+B,GAGUO,mBAAA,CACbC,QAASF,EACTG,KAAMvC,EACNwC,OAAQvC,EACRwC,KAAMvC,IAGYI,IAEtBT,IAAWuC,GAEX5B,GAAUS,MAAK,EAoBnB,OAAOyB,EAASC,aACZC,EAAAA,KAACC,EAAAA,eAAA,IACOpC,EAAYqC,aACZhD,EACJ,2BAA0BM,EAE1B2C,SAAA,CAACC,EAAAA,IAAAC,EAAAA,aAAA,IAAiBxC,EAAYyC,UAC9BN,EAAAA,KAACO,EAAMA,MAAA,CAAAC,UAAU,UAAW3C,EAAY4C,MAAaC,SAxBRC,IACjDA,EAAEC,iBAEF,MAAMC,EAAW,IAAIC,SAASH,EAAEI,eAE1BC,EAAc/B,EAAAA,2CAChB,CACIL,WAA2C,SAA/BiC,EAASI,IAAI,cACzBnC,WAA2C,SAA/B+B,EAASI,IAAI,cACzBpC,UAAyC,SAA9BgC,EAASI,IAAI,cAE5B1D,GAGJwB,EAAOiC,EAAW,EAWVb,SAAA,CAAAC,EAAAA,IAACc,eACGf,SAACC,EAAAA,IAAAe,EAAAA,WAAA,IAAetD,EAAYK,MAAOiC,+CAItCiB,EAAAA,UACG,CAAAjB,SAAA,CAAAC,EAAAA,IAAC,KAAED,SAGH,gHACC5C,EAAYqB,YACTwB,EAAAA,IAACiB,EAAAA,oBAAA,CACG1B,KAAK,aACL2B,MAAM,sBACNC,eACkC,aAA9BpE,EAAeyB,WAGtBuB,SAAA,wKADQ,cAAchD,EAAeyB,cAQzCrB,EAAYuB,YACTsB,EAAAA,IAACiB,EAAAA,oBAAA,CACG1B,KAAK,aACL2B,MAAM,oBACNC,eACkC,aAA9BpE,EAAe2B,WAGtBqB,SAAA,yJADQ,cAAchD,EAAe2B,cAOzCvB,EAAYsB,WACTuB,EAAAA,IAACiB,EAAAA,oBAAA,CACG1B,KAAK,YACL2B,MAAM,iCACNC,eACiC,aAA7BpE,EAAe0B,UAGtBsB,SAAA,uKADQ,aAAahD,EAAe0B,uBAS5C2C,EAAAA,aACG,CAAArB,SAAA,CAAAC,EAAAA,IAACqB,EAAAA,OAAA,CACGC,QAAQ,YACR,cAAY,2BACZC,KAAK,SACRxB,SAAA,oBAGDC,EAAAA,IAACqB,EAAAA,OAAA,CACGC,QAAQ,YACR,cAAY,gCACZC,KAAK,SACLC,QAAS,IAAM7C,IAClBoB,SAAA,wBAMb1B,SAASoD,KACb"}
|
|
1
|
+
{"version":3,"file":"CookieConsent.cjs","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { type FormEventHandler, useEffect, useId } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Button } from \"../button/Button.js\";\nimport { Flex } from \"../flex/index.js\";\nimport { Link } from \"../link/index.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalContainer,\n ModalHeader,\n ModalOverlay,\n ModalTitle,\n} from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { useInternalState } from \"./CookieConsentContext.js\";\nimport {\n convertBooleanConsentObjectToConsentObject,\n setConsentCookie,\n} from \"./cookieConsentUtils.js\";\nimport type { Consent, CookieConsentProps } from \"./types.js\";\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n aboutPage = \"https://www.fremtind.no/informasjonskapsler\",\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const {\n currentConsent,\n cookieName,\n cookieDomain,\n cookiePath,\n requirement,\n isOpen,\n setIsOpen,\n updateCurrentConsents,\n } = useInternalState();\n\n const [instance, modalConfig] = useModal({\n id: `jkl-cookie-modal-${useId()}`,\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: blocking ? \"alertdialog\" : \"dialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n useEffect(() => {\n if (isOpen) {\n instance?.show();\n } else {\n instance?.hide();\n }\n }, [instance, isOpen]);\n\n useEffect(() => {\n const onHide = () => setIsOpen(false);\n instance?.on(\"hide\", onHide);\n return () => {\n instance?.off(\"hide\", onHide);\n };\n }, [instance, setIsOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const accept = (\n selection = convertBooleanConsentObjectToConsentObject(\n {\n functional: true,\n statistics: true,\n },\n requirement,\n ),\n ) => {\n const selectionWithoutEmptyValues = Object.fromEntries(\n Object.entries(selection).filter(\n ([, value]) => typeof value !== \"undefined\",\n ),\n );\n\n const updatedConsent: Consent = {\n ...currentConsent,\n ...selectionWithoutEmptyValues,\n };\n\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n path: cookiePath,\n });\n\n updateCurrentConsents();\n\n onAccept?.(updatedConsent);\n\n instance?.hide();\n };\n\n const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n\n const formData = new FormData(e.currentTarget);\n\n const newConsents = convertBooleanConsentObjectToConsentObject(\n {\n functional: formData.get(\"functional\") === \"true\",\n statistics: formData.get(\"statistics\") === \"true\",\n },\n requirement,\n );\n\n accept(newConsents);\n };\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...modalConfig.container}\n {...rest}\n data-cookie-consent-open={isOpen}\n >\n <ModalOverlay {...modalConfig.overlay} />\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <form>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Får vi bruke valgfrie informasjonskapsler?\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <Flex direction=\"column\" gap={24}>\n <p>\n Vi ønsker å samle anonym statistikk for å forstå\n hvordan nettsidene våre brukes. Det hjelper oss\n til å gjøre innhold og løsninger bedre og mer\n brukervennlige.\n </p>\n <p>\n <Link href={aboutPage} target=\"_blank\">\n Les mer om hvilke informasjonskapsler vi\n lagrer her\n </Link>\n .\n </p>\n </Flex>\n </ModalBody>\n <ModalActions>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta-alle\"\n type=\"button\"\n onClick={() => accept()}\n >\n Ja, det er greit\n </Button>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta\"\n type=\"submit\"\n >\n Nei takk\n </Button>\n </ModalActions>\n </form>\n </Modal>\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["blocking","onAccept","aboutPage","rest","currentConsent","cookieName","cookieDomain","cookiePath","requirement","isOpen","setIsOpen","updateCurrentConsents","useInternalState","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","onHide","on","off","document","navigator","cookieEnabled","functional","statistics","accept","selection","convertBooleanConsentObjectToConsentObject","selectionWithoutEmptyValues","Object","fromEntries","entries","filter","value","updatedConsent","setConsentCookie","consent","name","domain","path","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","Modal","component","modal","onSubmit","e","preventDefault","formData","FormData","currentTarget","newConsents","get","ModalHeader","ModalTitle","ModalBody","Flex","direction","gap","Link","href","target","ModalActions","Button","variant","type","onClick","body"],"mappings":"oaAsB6B,EACzBA,SAAAA,EACAC,SAAAA,EACAC,UAAAA,EAAY,iDACTC,MAEG,MACFC,eAAAA,EACAC,WAAAA,EACAC,aAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,sBAAAA,GACAC,sBAEGC,EAAUC,GAAeC,WAAS,CACrCC,GAAI,oBAAoBC,EAAAA,UAIxBC,KAAMlB,EAAW,cAAgB,SAGjCmB,MAAO,wBAkBP,GAhBJC,EAAAA,WAAU,KACFX,EACAI,GAAUQ,OAEVR,GAAUS,MAAK,GAEpB,CAACT,EAAUJ,IAEdW,EAAAA,WAAU,KACA,MAAAG,EAAS,IAAMb,GAAU,GACrB,OAAAG,GAAAW,GAAG,OAAQD,GACd,KACOV,GAAAY,IAAI,OAAQF,EAAM,CAChC,GACD,CAACV,EAAUH,WAEHgB,SAAa,IACb,OAAA,KAIX,UAAWC,UAAc,MAAgBA,UAAUC,cAC/C,OAAI3B,GACSA,EAAA,CACL4B,WAAY,SACZC,WAAY,WAIb,KAGL,MAAAC,EAAS,CACXC,EAAYC,EAAAA,2CACR,CACIJ,YAAY,EACZC,YAAY,GAEhBtB,MAGJ,MAAM0B,EAA8BC,OAAOC,YACvCD,OAAOE,QAAQL,GAAWM,QACtB,EAAI,CAAAC,YAAkBA,EAAU,OAIlCC,EAA0B,IACzBpC,KACA8B,GAGUO,mBAAA,CACbC,QAASF,EACTG,KAAMtC,EACNuC,OAAQtC,EACRuC,KAAMtC,IAGYI,IAEtBV,IAAWuC,GAEX3B,GAAUS,MAAK,EAmBnB,OAAOwB,EAASC,aACZC,EAAAA,KAACC,EAAAA,eAAA,IACOnC,EAAYoC,aACZ/C,EACJ,2BAA0BM,EAE1B0C,SAAA,CAACC,EAAAA,IAAAC,EAAAA,aAAA,IAAiBvC,EAAYwC,UAC7BF,EAAAA,IAAAG,EAAAA,MAAA,CAAMC,UAAU,UAAW1C,EAAY2C,MAAaC,SAvBRC,IACjDA,EAAEC,iBAEF,MAAMC,EAAW,IAAIC,SAASH,EAAEI,eAE1BC,EAAc/B,EAAAA,2CAChB,CACIJ,WAA2C,SAA/BgC,EAASI,IAAI,cACzBnC,WAA2C,SAA/B+B,EAASI,IAAI,eAE7BzD,GAGJuB,EAAOiC,EAAW,EAWVb,SAAAH,EAAAA,KAAC,OACG,CAAAG,SAAA,CAAAC,EAAAA,IAACc,eACGf,SAACC,EAAAA,IAAAe,EAAAA,WAAA,IAAerD,EAAYK,MAAOgC,gEAItCiB,EACGA,UAAA,CAAAjB,SAAAH,OAACqB,EAAAA,MAAKC,UAAU,SAASC,IAAK,GAC1BpB,SAAA,CAAAC,EAAAA,IAAC,KAAED,SAKH,0KACC,IACG,CAAAA,SAAA,CAAAC,MAACoB,EAAAA,KAAK,CAAAC,KAAMvE,EAAWwE,OAAO,SAASvB,SAGvC,wDAAO,mBAKlBwB,EAAAA,aACG,CAAAxB,SAAA,CAAAC,EAAAA,IAACwB,EAAAA,OAAA,CACGC,QAAQ,YACR,cAAY,gCACZC,KAAK,SACLC,QAAS,IAAMhD,IAClBoB,SAAA,qBAGDC,EAAAA,IAACwB,EAAAA,OAAA,CACGC,QAAQ,YACR,cAAY,2BACZC,KAAK,SACR3B,SAAA,wBAOjBzB,SAASsD,KACb"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
blocking?: boolean;
|
|
4
|
-
onAccept?: AcceptConsentCallback;
|
|
5
|
-
}
|
|
6
|
-
export declare const CookieConsent: ({ blocking, onAccept, ...rest }: CookieConsentProps) => JSX.Element | null;
|
|
1
|
+
import { CookieConsentProps } from './types.cjs';
|
|
2
|
+
export declare const CookieConsent: ({ blocking, onAccept, aboutPage, ...rest }: CookieConsentProps) => JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),t=require("./cookieConsentUtils.cjs"),n="fremtind-cookie-consent",s=o.createContext(void 0);exports.CookieConsentProvider=({children:i,cookieAdapter:r,functional:u,statistics:a,cookieName:c=n,cookieDomain:C,cookiePath:d})=>{const[l,k]=o.useState((()=>Date.now())),m=o.useMemo((()=>t.buildRequirementsObject({functional:u,statistics:a})),[u,a]),p=o.useMemo((()=>t.getConsentCookie({adapter:r,name:c})??{functional:null,statistics:null}),[r,c,l]),[h,x]=o.useState((()=>t.shouldShowConsentDialog(m,p)));return e.jsx(s.Provider,{value:{isOpen:h,setIsOpen:x,updateCurrentConsents:()=>k(Date.now()),requirement:m,currentConsent:p,cookieName:c,cookieDomain:C,cookiePath:d},children:i})},exports.DEFAULT_COOKIE_NAME=n,exports.useCookieConsent=()=>{const e=o.useContext(s);if(void 0===e)throw new Error("useCookieConsent must be used within a CookieConsentProvider");return{openConsentModal:()=>{e.setIsOpen(!0)},consents:e.currentConsent}},exports.useInternalState=()=>{const e=o.useContext(s);if(void 0===e)throw new Error("CookieConsent must be used within a CookieConsentProvider");return e};
|
|
2
2
|
//# sourceMappingURL=CookieConsentContext.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsentContext.cjs","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport type {\n Consent,\n CookieConsentProviderProps,\n InternalContext,\n} from \"./types.js\";\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst Context = React.createContext<InternalContext | undefined>(undefined);\n\nexport const CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n
|
|
1
|
+
{"version":3,"file":"CookieConsentContext.cjs","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport type {\n Consent,\n CookieConsentProviderProps,\n InternalContext,\n} from \"./types.js\";\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst Context = React.createContext<InternalContext | undefined>(undefined);\n\nexport const CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n functional,\n statistics,\n cookieName = DEFAULT_COOKIE_NAME,\n cookieDomain,\n cookiePath,\n}) => {\n const [timestamp, setTimestamp] = useState(() => Date.now());\n\n const requirement = useMemo(\n () => buildRequirementsObject({ functional, statistics }),\n [functional, statistics],\n );\n\n /* Use timestamp as a dependency to be able to force re-reading of cookie */\n // biome-ignore lint/correctness/useExhaustiveDependencies:\n const consentCookie = useMemo(() => {\n return (\n getConsentCookie({ adapter: cookieAdapter, name: cookieName }) ?? {\n functional: null,\n statistics: null,\n }\n );\n }, [cookieAdapter, cookieName, timestamp]);\n\n const [isOpen, setIsOpen] = useState(() => {\n return shouldShowConsentDialog(requirement, consentCookie);\n });\n\n return (\n <Context.Provider\n value={{\n isOpen,\n setIsOpen,\n updateCurrentConsents: () => setTimestamp(Date.now()),\n requirement,\n currentConsent: consentCookie,\n cookieName,\n cookieDomain,\n cookiePath,\n }}\n >\n {children}\n </Context.Provider>\n );\n};\n\nexport const useInternalState = () => {\n const context = React.useContext(Context);\n if (context === undefined) {\n throw new Error(\n \"CookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n return context;\n};\n\ntype UseCookieConsent = {\n openConsentModal: () => void;\n consents: Consent;\n};\n\nexport const useCookieConsent = (): UseCookieConsent => {\n const context = useContext(Context);\n\n if (context === undefined) {\n throw new Error(\n \"useCookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n const openConsentModal = () => {\n context.setIsOpen(true);\n };\n\n const consents = context.currentConsent;\n\n return { openConsentModal, consents };\n};\n"],"names":["DEFAULT_COOKIE_NAME","Context","React","createContext","children","cookieAdapter","functional","statistics","cookieName","cookieDomain","cookiePath","timestamp","setTimestamp","useState","Date","now","requirement","useMemo","buildRequirementsObject","consentCookie","getConsentCookie","adapter","name","isOpen","setIsOpen","shouldShowConsentDialog","jsx","Provider","value","updateCurrentConsents","currentConsent","context","useContext","Error","openConsentModal","consents"],"mappings":"8KAYaA,EAAsB,0BAE7BC,EAAUC,EAAMC,mBAA2C,iCAEU,EACvEC,SAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,WAAAA,EACAC,WAAAA,EAAaR,EACbS,aAAAA,EACAC,WAAAA,MAEM,MAACC,EAAWC,GAAgBC,YAAS,IAAMC,KAAKC,QAEhDC,EAAcC,EAAAA,SAChB,IAAMC,0BAAwB,CAAEZ,WAAAA,EAAYC,WAAAA,KAC5C,CAACD,EAAYC,IAKXY,EAAgBF,EAAAA,SAAQ,IAEtBG,EAAAA,iBAAiB,CAAEC,QAAShB,EAAeiB,KAAMd,KAAiB,CAC9DF,WAAY,KACZC,WAAY,OAGrB,CAACF,EAAeG,EAAYG,KAExBY,EAAQC,GAAaX,YAAS,IAC1BY,EAAAA,wBAAwBT,EAAaG,KAI5C,OAAAO,EAAAA,IAACzB,EAAQ0B,SAAR,CACGC,MAAO,CACHL,OAAAA,EACAC,UAAAA,EACAK,sBAAuB,IAAMjB,EAAaE,KAAKC,OAC/CC,YAAAA,EACAc,eAAgBX,EAChBX,WAAAA,EACAC,aAAAA,EACAC,WAAAA,GAGHN,SAAAA,GACL,yDAoBwB,KACtB,MAAA2B,EAAUC,aAAW/B,GAE3B,QAAgB,IAAZ8B,EACA,MAAM,IAAIE,MACN,gEAUD,MAAA,CAAEC,iBANgB,KACrBH,EAAQP,WAAU,EAAI,EAKCW,SAFVJ,EAAQD,eAEW,2BA/BR,KACtB,MAAAC,EAAU7B,EAAM8B,WAAW/B,GACjC,QAAgB,IAAZ8B,EACA,MAAM,IAAIE,MACN,6DAID,OAAAF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=t=>typeof t>"u"?null:!1===t||"false"===String(t).toLowerCase()?"denied":"accepted";exports.buildRequirementsObject=({
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=t=>typeof t>"u"?null:!1===t||"false"===String(t).toLowerCase()?"denied":"accepted";exports.buildRequirementsObject=({functional:t,statistics:e})=>({...t&&{functional:t},...e&&{statistics:e}}),exports.convertBooleanConsentObjectToConsentObject=(e,o)=>({functional:o.functional?t(e.functional):void 0,statistics:o.statistics?t(e.statistics):void 0}),exports.convertBooleanToConsentValue=t,exports.getConsentCookie=({adapter:t,name:e})=>{const o=(t=>{if(typeof document>"u")return;const e=document.cookie.split(";").map((t=>t.trim().split("="))).find((e=>e[0]===t));return e||void 0})(e);return o?JSON.parse(o[1]):t?t():void 0},exports.setConsentCookie=({consent:t,maxAge:e=10368e3,name:o,domain:n,path:s})=>{document.cookie=[`${o}=${JSON.stringify(t)}`,`max-age=${e}`,"SameSite=Lax",!!n&&`domain=${n}`,!!s&&`path=${s}`].filter((t=>t)).join(";")},exports.shouldShowConsentDialog=(t,e)=>{if(!e)return Object.values(t).some((t=>t));const o=new Map(Object.entries(e)),n=Object.entries(t);for(const[t,e]of n)if(e&&null===o.get(t))return!0;return!1};
|
|
2
2
|
//# sourceMappingURL=cookieConsentUtils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookieConsentUtils.cjs","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n path,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n path?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n \"SameSite=Lax\",\n !!domain && `domain=${domain}`,\n !!path && `path=${path}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n }\n\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n requirement: ConsentRequirement,\n): Consent => {\n return {\n functional: requirement.functional\n ? convertBooleanToConsentValue(consent.functional)\n : undefined,\n statistics: requirement.statistics\n ? convertBooleanToConsentValue(consent.statistics)\n : undefined,\n
|
|
1
|
+
{"version":3,"file":"cookieConsentUtils.cjs","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n path,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n path?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n \"SameSite=Lax\",\n !!domain && `domain=${domain}`,\n !!path && `path=${path}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n }\n\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n requirement: ConsentRequirement,\n): Consent => {\n return {\n functional: requirement.functional\n ? convertBooleanToConsentValue(consent.functional)\n : undefined,\n statistics: requirement.statistics\n ? convertBooleanToConsentValue(consent.statistics)\n : undefined,\n };\n};\n\nexport const buildRequirementsObject = ({\n functional,\n statistics,\n}: ConsentRequirement) => {\n return {\n ...(functional && { functional }),\n ...(statistics && { statistics }),\n };\n};\n"],"names":["convertBooleanToConsentValue","formValue","String","toLowerCase","functional","statistics","consent","requirement","adapter","name","cookie","document","split","map","s","trim","find","c","getCookie","JSON","parse","maxAge","domain","path","stringify","filter","f","join","Object","values","some","requirementValue","consentMap","Map","entries","requirementEntries","required","get"],"mappings":"gFAEA,MAqGaA,EACTC,UAEWA,EAAc,IACd,MAGO,IAAdA,GAA2D,UAApCC,OAAOD,GAAWE,cAClC,SAGJ,2CAiB4B,EACnCC,WAAAA,EACAC,WAAAA,MAEO,IACCD,GAAc,CAAEA,WAAAA,MAChBC,GAAc,CAAEA,WAAAA,wDApB8B,CACtDC,EACAC,KAEO,CACHH,WAAYG,EAAYH,WAClBJ,EAA6BM,EAAQF,iBACrC,EACNC,WAAYE,EAAYF,WAClBL,EAA6BM,EAAQD,iBACrC,oEAzGkB,EAC5BG,QAAAA,EACAC,KAAAA,MAKM,MAAAC,EA3BSD,KACX,UAAOE,SAAa,IACb,OAGL,MAAAD,EAASC,SAASD,OAEnBE,MAAM,KAENC,KAAKC,GAAMA,EAAEC,OAAOH,MAAM,OAE1BI,MAAMC,GAAMA,EAAE,KAAOR,IAE1B,OAAKC,QAAL,CAIOA,EAUQQ,CAAUT,GAEzB,OAAIC,EACgBS,KAAKC,MAAMV,EAAO,IAKlCF,EACOA,SADX,CACmB,2BASS,EAC5BF,QAAAA,EACAe,OAAAA,EAJoB,QAKpBZ,KAAAA,EACAa,OAAAA,EACAC,KAAAA,MAQAZ,SAASD,OAAS,CACd,GAAGD,KAAQU,KAAKK,UAAUlB,KAC1B,WAAWe,IACX,iBACEC,GAAU,UAAUA,MACpBC,GAAQ,QAAQA,KAEjBE,QAAQC,GAAMA,IACdC,KAAK,IAAG,kCAGsB,CACnCpB,EACAD,KAEA,IAAKA,EAEM,OAAAsB,OAAOC,OAAOtB,GAAauB,MAC7BC,GAAqBA,IAK9B,MAAMC,EAAa,IAAIC,IAAIL,OAAOM,QAAQ5B,IAGpC6B,EAAqBP,OAAOM,QAAQ3B,GAE1C,IAAA,MAAYE,EAAM2B,KAAaD,EAE3B,GAAKC,GAKwB,OAAzBJ,EAAWK,IAAI5B,GACR,OAAA,EAIR,OAAA,CAAA"}
|
|
@@ -13,8 +13,7 @@ export declare const setConsentCookie: ({ consent, maxAge, name, domain, path, }
|
|
|
13
13
|
export declare const shouldShowConsentDialog: (requirement: ConsentRequirement, consent: Consent | undefined) => boolean;
|
|
14
14
|
export declare const convertBooleanToConsentValue: (formValue: boolean | undefined) => ConsentState;
|
|
15
15
|
export declare const convertBooleanConsentObjectToConsentObject: (consent: Partial<Record<keyof Consent, boolean | undefined>>, requirement: ConsentRequirement) => Consent;
|
|
16
|
-
export declare const buildRequirementsObject: ({
|
|
16
|
+
export declare const buildRequirementsObject: ({ functional, statistics, }: ConsentRequirement) => {
|
|
17
17
|
statistics?: true | undefined;
|
|
18
18
|
functional?: true | undefined;
|
|
19
|
-
marketing?: true | undefined;
|
|
20
19
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CookieConsent
|
|
1
|
+
export { CookieConsent } from './CookieConsent.cjs';
|
|
2
2
|
export { CookieConsentProvider, useCookieConsent, } from './CookieConsentContext.cjs';
|
|
3
|
-
export type { AcceptConsentCallback, Consent, ConsentState, CookieConsentProviderProps, } from './types.cjs';
|
|
3
|
+
export type { AcceptConsentCallback, Consent, ConsentState, CookieConsentProviderProps, CookieConsentProps, } from './types.cjs';
|
|
@@ -2,10 +2,17 @@ import { WithChildren } from '../../core/types.cjs';
|
|
|
2
2
|
export type ConsentState = null | "denied" | "accepted";
|
|
3
3
|
export type ConsentRequirement = Partial<Record<keyof Consent, boolean>>;
|
|
4
4
|
export type Consent = {
|
|
5
|
-
marketing?: ConsentState;
|
|
6
5
|
functional?: ConsentState;
|
|
7
6
|
statistics?: ConsentState;
|
|
8
7
|
};
|
|
8
|
+
export interface CookieConsentProps {
|
|
9
|
+
blocking?: boolean;
|
|
10
|
+
onAccept?: AcceptConsentCallback;
|
|
11
|
+
/**
|
|
12
|
+
* Lenke til informasjonssiden til cookiene i løsningen din.
|
|
13
|
+
*/
|
|
14
|
+
aboutPage: string;
|
|
15
|
+
}
|
|
9
16
|
export type AcceptConsentCallback = (consent: Consent) => void;
|
|
10
17
|
export type ConsentComponentBaseProps = {
|
|
11
18
|
className?: string;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
blocking?: boolean;
|
|
4
|
-
onAccept?: AcceptConsentCallback;
|
|
5
|
-
}
|
|
6
|
-
export declare const CookieConsent: ({ blocking, onAccept, ...rest }: CookieConsentProps) => JSX.Element | null;
|
|
1
|
+
import { CookieConsentProps } from './types.js';
|
|
2
|
+
export declare const CookieConsent: ({ blocking, onAccept, aboutPage, ...rest }: CookieConsentProps) => JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useId as t,useEffect as n}from"react";import r from"react-dom";import{Button as a}from"../button/Button.js";import{Flex as i}from"../flex/Flex.js";import{Link as s}from"../link/Link.js";import{ModalContainer as l,ModalOverlay as c,Modal as d,ModalHeader as m,ModalTitle as u,ModalBody as f,ModalActions as k}from"../modal/Modal.js";import{useModal as p}from"../modal/useModal.js";import{useInternalState as h}from"./CookieConsentContext.js";import{convertBooleanConsentObjectToConsentObject as j,setConsentCookie as g}from"./cookieConsentUtils.js";const b=({blocking:b,onAccept:v,aboutPage:C="https://www.fremtind.no/informasjonskapsler",...y})=>{const{currentConsent:M,cookieName:x,cookieDomain:O,cookiePath:w,requirement:B,isOpen:D,setIsOpen:F,updateCurrentConsents:I}=h(),[E,L]=p({id:`jkl-cookie-modal-${t()}`,role:b?"alertdialog":"dialog",title:"Informasjonskapsler"});if(n((()=>{D?E?.show():E?.hide()}),[E,D]),n((()=>{const e=()=>F(!1);return E?.on("hide",e),()=>{E?.off("hide",e)}}),[E,F]),typeof document>"u")return null;if(typeof navigator<"u"&&!navigator.cookieEnabled)return v&&v({functional:"denied",statistics:"denied"}),null;const P=(e=j({functional:!0,statistics:!0},B))=>{const o=Object.fromEntries(Object.entries(e).filter((([,e])=>typeof e<"u"))),t={...M,...o};g({consent:t,name:x,domain:O,path:w}),I(),v?.(t),E?.hide()};return r.createPortal(e(l,{...L.container,...y,"data-cookie-consent-open":D,children:[o(c,{...L.overlay}),o(d,{component:"form",...L.modal,onSubmit:e=>{e.preventDefault();const o=new FormData(e.currentTarget),t=j({functional:"true"===o.get("functional"),statistics:"true"===o.get("statistics")},B);P(t)},children:e("form",{children:[o(m,{children:o(u,{...L.title,children:"Får vi bruke valgfrie informasjonskapsler?"})}),o(f,{children:e(i,{direction:"column",gap:24,children:[o("p",{children:"Vi ønsker å samle anonym statistikk for å forstå hvordan nettsidene våre brukes. Det hjelper oss til å gjøre innhold og løsninger bedre og mer brukervennlige."}),e("p",{children:[o(s,{href:C,target:"_blank",children:"Les mer om hvilke informasjonskapsler vi lagrer her"}),"."]})]})}),e(k,{children:[o(a,{variant:"secondary","data-testid":"jkl-cookie-consent-godta-alle",type:"button",onClick:()=>P(),children:"Ja, det er greit"}),o(a,{variant:"secondary","data-testid":"jkl-cookie-consent-godta",type:"submit",children:"Nei takk"})]})]})})]}),document.body)};export{b as CookieConsent};
|
|
2
2
|
//# sourceMappingURL=CookieConsent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsent.js","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { type FormEventHandler, useEffect, useId } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Button } from \"../button/Button.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalContainer,\n ModalHeader,\n ModalOverlay,\n ModalTitle,\n} from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { useInternalState } from \"./CookieConsentContext.js\";\nimport { RequirementCheckbox } from \"./RequirementCheckbox.js\";\nimport {\n convertBooleanConsentObjectToConsentObject,\n setConsentCookie,\n} from \"./cookieConsentUtils.js\";\nimport type { AcceptConsentCallback, Consent } from \"./types.js\";\n\nexport interface CookieConsentProps {\n blocking?: boolean;\n onAccept?: AcceptConsentCallback;\n}\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const {\n currentConsent,\n cookieName,\n cookieDomain,\n cookiePath,\n requirement,\n isOpen,\n setIsOpen,\n updateCurrentConsents,\n } = useInternalState();\n\n const [instance, modalConfig] = useModal({\n id: `jkl-cookie-modal-${useId()}`,\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: blocking ? \"alertdialog\" : \"dialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n\n useEffect(() => {\n if (isOpen) {\n instance?.show();\n } else {\n instance?.hide();\n }\n }, [instance, isOpen]);\n\n useEffect(() => {\n const onHide = () => setIsOpen(false);\n instance?.on(\"hide\", onHide);\n return () => {\n instance?.off(\"hide\", onHide);\n };\n }, [instance, setIsOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n marketing: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const accept = (\n selection = convertBooleanConsentObjectToConsentObject(\n {\n functional: true,\n statistics: true,\n marketing: true,\n },\n requirement,\n ),\n ) => {\n const selectionWithoutEmptyValues = Object.fromEntries(\n Object.entries(selection).filter(\n ([, value]) => typeof value !== \"undefined\",\n ),\n );\n\n const updatedConsent: Consent = {\n ...currentConsent,\n ...selectionWithoutEmptyValues,\n };\n\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n path: cookiePath,\n });\n\n updateCurrentConsents();\n\n onAccept?.(updatedConsent);\n\n instance?.hide();\n };\n\n const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n\n const formData = new FormData(e.currentTarget);\n\n const newConsents = convertBooleanConsentObjectToConsentObject(\n {\n functional: formData.get(\"functional\") === \"true\",\n statistics: formData.get(\"statistics\") === \"true\",\n marketing: formData.get(\"marketing\") === \"true\",\n },\n requirement,\n );\n\n accept(newConsents);\n };\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...modalConfig.container}\n {...rest}\n data-cookie-consent-open={isOpen}\n >\n <ModalOverlay {...modalConfig.overlay} />\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Velg informasjonskapsler\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <p>\n For at nettsidene skal fungere må vi bruke tekniske\n informasjonskaplser. Disse lagres derfor uten samtykke.\n </p>\n {requirement.functional && (\n <RequirementCheckbox\n name=\"functional\"\n label=\"Tillat funksjonelle\"\n defaultChecked={\n currentConsent.functional === \"accepted\"\n }\n key={`functional-${currentConsent.functional}`}\n >\n Funksjonelle informasjonskapsler lagrer opplysninger\n om din bruk av nettsidene og hvilke innstillinger du\n har gjort, slik at du kan få funksjonalitet\n tilpasset deg.\n </RequirementCheckbox>\n )}\n {requirement.statistics && (\n <RequirementCheckbox\n name=\"statistics\"\n label=\"Tillat statistikk\"\n defaultChecked={\n currentConsent.statistics === \"accepted\"\n }\n key={`statistics-${currentConsent.statistics}`}\n >\n Informasjonskapslene lagrer statistikk som hjelper\n oss med å forstå hvordan nettsidene blir brukt, slik\n at vi kan gjøre dem bedre og enklere å bruke.\n </RequirementCheckbox>\n )}\n {requirement.marketing && (\n <RequirementCheckbox\n name=\"marketing\"\n label=\"Tillat personlig markedsføring\"\n defaultChecked={\n currentConsent.marketing === \"accepted\"\n }\n key={`marketing-${currentConsent.marketing}`}\n >\n Dette gjør at vi kan gi deg mer relevant og\n tilpasset markedsføring, også gjennom våre\n samarbeidspartnere, på for eksempel nettsider,\n annonser og i sosiale medier.\n </RequirementCheckbox>\n )}\n </ModalBody>\n <ModalActions>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta\"\n type=\"submit\"\n >\n Godta mine valg\n </Button>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta-alle\"\n type=\"button\"\n onClick={() => accept()}\n >\n Godta alle\n </Button>\n </ModalActions>\n </Modal>\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["CookieConsent","blocking","onAccept","rest","currentConsent","cookieName","cookieDomain","cookiePath","requirement","isOpen","setIsOpen","updateCurrentConsents","useInternalState","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","onHide","on","off","document","navigator","cookieEnabled","functional","marketing","statistics","accept","selection","convertBooleanConsentObjectToConsentObject","selectionWithoutEmptyValues","Object","fromEntries","entries","filter","value","updatedConsent","setConsentCookie","consent","name","domain","path","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","Modal","component","modal","onSubmit","e","preventDefault","formData","FormData","currentTarget","newConsents","get","ModalHeader","ModalTitle","ModalBody","RequirementCheckbox","label","defaultChecked","ModalActions","Button","variant","type","onClick","body"],"mappings":"8kBA0BO,MAAMA,EAAgB,EACzBC,SAAAA,EACAC,SAAAA,KACGC,MAEG,MACFC,eAAAA,EACAC,WAAAA,EACAC,aAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,sBAAAA,GACAC,KAEGC,EAAUC,GAAeC,EAAS,CACrCC,GAAI,oBAAoBC,MAIxBC,KAAMjB,EAAW,cAAgB,SAGjCkB,MAAO,wBAmBP,GAhBJC,GAAU,KACFX,EACAI,GAAUQ,OAEVR,GAAUS,MAAK,GAEpB,CAACT,EAAUJ,IAEdW,GAAU,KACAG,MAAAA,EAAS,IAAMb,GAAU,GACrB,OAAAG,GAAAW,GAAG,OAAQD,GACd,KACOV,GAAAY,IAAI,OAAQF,EAAM,CAChC,GACD,CAACV,EAAUH,WAEHgB,SAAa,IACb,OAAA,KAIX,UAAWC,UAAc,MAAgBA,UAAUC,cAC/C,OAAI1B,GACSA,EAAA,CACL2B,WAAY,SACZC,UAAW,SACXC,WAAY,WAIb,KAGLC,MAAAA,EAAS,CACXC,EAAYC,EACR,CACIL,YAAY,EACZE,YAAY,EACZD,WAAW,GAEftB,MAGJ,MAAM2B,EAA8BC,OAAOC,YACvCD,OAAOE,QAAQL,GAAWM,QACtB,EAAI,CAAAC,YAAkBA,EAAU,OAIlCC,EAA0B,IACzBrC,KACA+B,GAGUO,EAAA,CACbC,QAASF,EACTG,KAAMvC,EACNwC,OAAQvC,EACRwC,KAAMvC,IAGYI,IAEtBT,IAAWuC,GAEX5B,GAAUS,MAAK,EAoBnB,OAAOyB,EAASC,aACZC,EAACC,EAAA,IACOpC,EAAYqC,aACZhD,EACJ,2BAA0BM,EAE1B2C,SAAA,CAACC,EAAAC,EAAA,IAAiBxC,EAAYyC,UAC9BN,EAACO,EAAM,CAAAC,UAAU,UAAW3C,EAAY4C,MAAaC,SAxBRC,IACjDA,EAAEC,iBAEF,MAAMC,EAAW,IAAIC,SAASH,EAAEI,eAE1BC,EAAc/B,EAChB,CACIL,WAA2C,SAA/BiC,EAASI,IAAI,cACzBnC,WAA2C,SAA/B+B,EAASI,IAAI,cACzBpC,UAAyC,SAA9BgC,EAASI,IAAI,cAE5B1D,GAGJwB,EAAOiC,EAAW,EAWVb,SAAA,CAAAC,EAACc,GACGf,SAACC,EAAAe,EAAA,IAAetD,EAAYK,MAAOiC,0CAItCiB,EACG,CAAAjB,SAAA,CAAAC,EAAC,KAAED,SAGH,gHACC5C,EAAYqB,YACTwB,EAACiB,EAAA,CACG1B,KAAK,aACL2B,MAAM,sBACNC,eACkC,aAA9BpE,EAAeyB,WAGtBuB,SAAA,wKADQ,cAAchD,EAAeyB,cAQzCrB,EAAYuB,YACTsB,EAACiB,EAAA,CACG1B,KAAK,aACL2B,MAAM,oBACNC,eACkC,aAA9BpE,EAAe2B,WAGtBqB,SAAA,yJADQ,cAAchD,EAAe2B,cAOzCvB,EAAYsB,WACTuB,EAACiB,EAAA,CACG1B,KAAK,YACL2B,MAAM,iCACNC,eACiC,aAA7BpE,EAAe0B,UAGtBsB,SAAA,uKADQ,aAAahD,EAAe0B,kBAS5C2C,EACG,CAAArB,SAAA,CAAAC,EAACqB,EAAA,CACGC,QAAQ,YACR,cAAY,2BACZC,KAAK,SACRxB,SAAA,oBAGDC,EAACqB,EAAA,CACGC,QAAQ,YACR,cAAY,gCACZC,KAAK,SACLC,QAAS,IAAM7C,IAClBoB,SAAA,wBAMb1B,SAASoD,KACb"}
|
|
1
|
+
{"version":3,"file":"CookieConsent.js","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { type FormEventHandler, useEffect, useId } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Button } from \"../button/Button.js\";\nimport { Flex } from \"../flex/index.js\";\nimport { Link } from \"../link/index.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalContainer,\n ModalHeader,\n ModalOverlay,\n ModalTitle,\n} from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { useInternalState } from \"./CookieConsentContext.js\";\nimport {\n convertBooleanConsentObjectToConsentObject,\n setConsentCookie,\n} from \"./cookieConsentUtils.js\";\nimport type { Consent, CookieConsentProps } from \"./types.js\";\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n aboutPage = \"https://www.fremtind.no/informasjonskapsler\",\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const {\n currentConsent,\n cookieName,\n cookieDomain,\n cookiePath,\n requirement,\n isOpen,\n setIsOpen,\n updateCurrentConsents,\n } = useInternalState();\n\n const [instance, modalConfig] = useModal({\n id: `jkl-cookie-modal-${useId()}`,\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: blocking ? \"alertdialog\" : \"dialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n useEffect(() => {\n if (isOpen) {\n instance?.show();\n } else {\n instance?.hide();\n }\n }, [instance, isOpen]);\n\n useEffect(() => {\n const onHide = () => setIsOpen(false);\n instance?.on(\"hide\", onHide);\n return () => {\n instance?.off(\"hide\", onHide);\n };\n }, [instance, setIsOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const accept = (\n selection = convertBooleanConsentObjectToConsentObject(\n {\n functional: true,\n statistics: true,\n },\n requirement,\n ),\n ) => {\n const selectionWithoutEmptyValues = Object.fromEntries(\n Object.entries(selection).filter(\n ([, value]) => typeof value !== \"undefined\",\n ),\n );\n\n const updatedConsent: Consent = {\n ...currentConsent,\n ...selectionWithoutEmptyValues,\n };\n\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n path: cookiePath,\n });\n\n updateCurrentConsents();\n\n onAccept?.(updatedConsent);\n\n instance?.hide();\n };\n\n const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n\n const formData = new FormData(e.currentTarget);\n\n const newConsents = convertBooleanConsentObjectToConsentObject(\n {\n functional: formData.get(\"functional\") === \"true\",\n statistics: formData.get(\"statistics\") === \"true\",\n },\n requirement,\n );\n\n accept(newConsents);\n };\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...modalConfig.container}\n {...rest}\n data-cookie-consent-open={isOpen}\n >\n <ModalOverlay {...modalConfig.overlay} />\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <form>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Får vi bruke valgfrie informasjonskapsler?\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <Flex direction=\"column\" gap={24}>\n <p>\n Vi ønsker å samle anonym statistikk for å forstå\n hvordan nettsidene våre brukes. Det hjelper oss\n til å gjøre innhold og løsninger bedre og mer\n brukervennlige.\n </p>\n <p>\n <Link href={aboutPage} target=\"_blank\">\n Les mer om hvilke informasjonskapsler vi\n lagrer her\n </Link>\n .\n </p>\n </Flex>\n </ModalBody>\n <ModalActions>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta-alle\"\n type=\"button\"\n onClick={() => accept()}\n >\n Ja, det er greit\n </Button>\n <Button\n variant=\"secondary\"\n data-testid=\"jkl-cookie-consent-godta\"\n type=\"submit\"\n >\n Nei takk\n </Button>\n </ModalActions>\n </form>\n </Modal>\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["CookieConsent","blocking","onAccept","aboutPage","rest","currentConsent","cookieName","cookieDomain","cookiePath","requirement","isOpen","setIsOpen","updateCurrentConsents","useInternalState","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","onHide","on","off","document","navigator","cookieEnabled","functional","statistics","accept","selection","convertBooleanConsentObjectToConsentObject","selectionWithoutEmptyValues","Object","fromEntries","entries","filter","value","updatedConsent","setConsentCookie","consent","name","domain","path","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","Modal","component","modal","onSubmit","e","preventDefault","formData","FormData","currentTarget","newConsents","get","ModalHeader","ModalTitle","ModalBody","Flex","direction","gap","Link","href","target","ModalActions","Button","variant","type","onClick","body"],"mappings":"6lBAsBO,MAAMA,EAAgB,EACzBC,SAAAA,EACAC,SAAAA,EACAC,UAAAA,EAAY,iDACTC,MAEG,MACFC,eAAAA,EACAC,WAAAA,EACAC,aAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,sBAAAA,GACAC,KAEGC,EAAUC,GAAeC,EAAS,CACrCC,GAAI,oBAAoBC,MAIxBC,KAAMlB,EAAW,cAAgB,SAGjCmB,MAAO,wBAkBP,GAhBJC,GAAU,KACFX,EACAI,GAAUQ,OAEVR,GAAUS,MAAK,GAEpB,CAACT,EAAUJ,IAEdW,GAAU,KACAG,MAAAA,EAAS,IAAMb,GAAU,GACrB,OAAAG,GAAAW,GAAG,OAAQD,GACd,KACOV,GAAAY,IAAI,OAAQF,EAAM,CAChC,GACD,CAACV,EAAUH,WAEHgB,SAAa,IACb,OAAA,KAIX,UAAWC,UAAc,MAAgBA,UAAUC,cAC/C,OAAI3B,GACSA,EAAA,CACL4B,WAAY,SACZC,WAAY,WAIb,KAGLC,MAAAA,EAAS,CACXC,EAAYC,EACR,CACIJ,YAAY,EACZC,YAAY,GAEhBtB,MAGJ,MAAM0B,EAA8BC,OAAOC,YACvCD,OAAOE,QAAQL,GAAWM,QACtB,EAAI,CAAAC,YAAkBA,EAAU,OAIlCC,EAA0B,IACzBpC,KACA8B,GAGUO,EAAA,CACbC,QAASF,EACTG,KAAMtC,EACNuC,OAAQtC,EACRuC,KAAMtC,IAGYI,IAEtBV,IAAWuC,GAEX3B,GAAUS,MAAK,EAmBnB,OAAOwB,EAASC,aACZC,EAACC,EAAA,IACOnC,EAAYoC,aACZ/C,EACJ,2BAA0BM,EAE1B0C,SAAA,CAACC,EAAAC,EAAA,IAAiBvC,EAAYwC,UAC7BF,EAAAG,EAAA,CAAMC,UAAU,UAAW1C,EAAY2C,MAAaC,SAvBRC,IACjDA,EAAEC,iBAEF,MAAMC,EAAW,IAAIC,SAASH,EAAEI,eAE1BC,EAAc/B,EAChB,CACIJ,WAA2C,SAA/BgC,EAASI,IAAI,cACzBnC,WAA2C,SAA/B+B,EAASI,IAAI,eAE7BzD,GAGJuB,EAAOiC,EAAW,EAWVb,SAAAH,EAAC,OACG,CAAAG,SAAA,CAAAC,EAACc,GACGf,SAACC,EAAAe,EAAA,IAAerD,EAAYK,MAAOgC,4DAItCiB,EACG,CAAAjB,SAAAH,EAACqB,GAAKC,UAAU,SAASC,IAAK,GAC1BpB,SAAA,CAAAC,EAAC,KAAED,SAKH,qKACC,IACG,CAAAA,SAAA,CAAAC,EAACoB,EAAK,CAAAC,KAAMvE,EAAWwE,OAAO,SAASvB,SAGvC,wDAAO,cAKlBwB,EACG,CAAAxB,SAAA,CAAAC,EAACwB,EAAA,CACGC,QAAQ,YACR,cAAY,gCACZC,KAAK,SACLC,QAAS,IAAMhD,IAClBoB,SAAA,qBAGDC,EAACwB,EAAA,CACGC,QAAQ,YACR,cAAY,2BACZC,KAAK,SACR3B,SAAA,wBAOjBzB,SAASsD,KACb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import o,{useState as t,useMemo as n,useContext as s}from"react";import{buildRequirementsObject as i,getConsentCookie as r,shouldShowConsentDialog as a}from"./cookieConsentUtils.js";const
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import o,{useState as t,useMemo as n,useContext as s}from"react";import{buildRequirementsObject as i,getConsentCookie as r,shouldShowConsentDialog as a}from"./cookieConsentUtils.js";const c="fremtind-cookie-consent",u=o.createContext(void 0),C=({children:o,cookieAdapter:s,functional:C,statistics:d,cookieName:m=c,cookieDomain:k,cookiePath:l})=>{const[p,h]=t((()=>Date.now())),f=n((()=>i({functional:C,statistics:d})),[C,d]),w=n((()=>r({adapter:s,name:m})??{functional:null,statistics:null}),[s,m,p]),[v,x]=t((()=>a(f,w)));return e(u.Provider,{value:{isOpen:v,setIsOpen:x,updateCurrentConsents:()=>h(Date.now()),requirement:f,currentConsent:w,cookieName:m,cookieDomain:k,cookiePath:l},children:o})},d=()=>{const e=o.useContext(u);if(void 0===e)throw new Error("CookieConsent must be used within a CookieConsentProvider");return e},m=()=>{const e=s(u);if(void 0===e)throw new Error("useCookieConsent must be used within a CookieConsentProvider");return{openConsentModal:()=>{e.setIsOpen(!0)},consents:e.currentConsent}};export{C as CookieConsentProvider,c as DEFAULT_COOKIE_NAME,m as useCookieConsent,d as useInternalState};
|
|
2
2
|
//# sourceMappingURL=CookieConsentContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsentContext.js","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport type {\n Consent,\n CookieConsentProviderProps,\n InternalContext,\n} from \"./types.js\";\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst Context = React.createContext<InternalContext | undefined>(undefined);\n\nexport const CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n
|
|
1
|
+
{"version":3,"file":"CookieConsentContext.js","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport type {\n Consent,\n CookieConsentProviderProps,\n InternalContext,\n} from \"./types.js\";\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst Context = React.createContext<InternalContext | undefined>(undefined);\n\nexport const CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n functional,\n statistics,\n cookieName = DEFAULT_COOKIE_NAME,\n cookieDomain,\n cookiePath,\n}) => {\n const [timestamp, setTimestamp] = useState(() => Date.now());\n\n const requirement = useMemo(\n () => buildRequirementsObject({ functional, statistics }),\n [functional, statistics],\n );\n\n /* Use timestamp as a dependency to be able to force re-reading of cookie */\n // biome-ignore lint/correctness/useExhaustiveDependencies:\n const consentCookie = useMemo(() => {\n return (\n getConsentCookie({ adapter: cookieAdapter, name: cookieName }) ?? {\n functional: null,\n statistics: null,\n }\n );\n }, [cookieAdapter, cookieName, timestamp]);\n\n const [isOpen, setIsOpen] = useState(() => {\n return shouldShowConsentDialog(requirement, consentCookie);\n });\n\n return (\n <Context.Provider\n value={{\n isOpen,\n setIsOpen,\n updateCurrentConsents: () => setTimestamp(Date.now()),\n requirement,\n currentConsent: consentCookie,\n cookieName,\n cookieDomain,\n cookiePath,\n }}\n >\n {children}\n </Context.Provider>\n );\n};\n\nexport const useInternalState = () => {\n const context = React.useContext(Context);\n if (context === undefined) {\n throw new Error(\n \"CookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n return context;\n};\n\ntype UseCookieConsent = {\n openConsentModal: () => void;\n consents: Consent;\n};\n\nexport const useCookieConsent = (): UseCookieConsent => {\n const context = useContext(Context);\n\n if (context === undefined) {\n throw new Error(\n \"useCookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n const openConsentModal = () => {\n context.setIsOpen(true);\n };\n\n const consents = context.currentConsent;\n\n return { openConsentModal, consents };\n};\n"],"names":["DEFAULT_COOKIE_NAME","Context","React","createContext","CookieConsentProvider","children","cookieAdapter","functional","statistics","cookieName","cookieDomain","cookiePath","timestamp","setTimestamp","useState","Date","now","requirement","useMemo","buildRequirementsObject","consentCookie","getConsentCookie","adapter","name","isOpen","setIsOpen","shouldShowConsentDialog","jsx","Provider","value","updateCurrentConsents","currentConsent","useInternalState","context","useContext","Error","useCookieConsent","openConsentModal","consents"],"mappings":"8NAYO,MAAMA,EAAsB,0BAE7BC,EAAUC,EAAMC,mBAA2C,GAEpDC,EAA8D,EACvEC,SAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,WAAAA,EACAC,WAAAA,EAAaT,EACbU,aAAAA,EACAC,WAAAA,MAEM,MAACC,EAAWC,GAAgBC,GAAS,IAAMC,KAAKC,QAEhDC,EAAcC,GAChB,IAAMC,EAAwB,CAAEZ,WAAAA,EAAYC,WAAAA,KAC5C,CAACD,EAAYC,IAKXY,EAAgBF,GAAQ,IAEtBG,EAAiB,CAAEC,QAAShB,EAAeiB,KAAMd,KAAiB,CAC9DF,WAAY,KACZC,WAAY,OAGrB,CAACF,EAAeG,EAAYG,KAExBY,EAAQC,GAAaX,GAAS,IAC1BY,EAAwBT,EAAaG,KAI5C,OAAAO,EAAC1B,EAAQ2B,SAAR,CACGC,MAAO,CACHL,OAAAA,EACAC,UAAAA,EACAK,sBAAuB,IAAMjB,EAAaE,KAAKC,OAC/CC,YAAAA,EACAc,eAAgBX,EAChBX,WAAAA,EACAC,aAAAA,EACAC,WAAAA,GAGHN,SAAAA,GACL,EAIK2B,EAAmB,KACtBC,MAAAA,EAAU/B,EAAMgC,WAAWjC,GACjC,QAAgB,IAAZgC,EACA,MAAM,IAAIE,MACN,6DAIDF,OAAAA,CAAAA,EAQEG,EAAmB,KACtBH,MAAAA,EAAUC,EAAWjC,GAE3B,QAAgB,IAAZgC,EACA,MAAM,IAAIE,MACN,gEAUD,MAAA,CAAEE,iBANgB,KACrBJ,EAAQR,WAAU,EAAI,EAKCa,SAFVL,EAAQF,eAEW"}
|
|
@@ -13,8 +13,7 @@ export declare const setConsentCookie: ({ consent, maxAge, name, domain, path, }
|
|
|
13
13
|
export declare const shouldShowConsentDialog: (requirement: ConsentRequirement, consent: Consent | undefined) => boolean;
|
|
14
14
|
export declare const convertBooleanToConsentValue: (formValue: boolean | undefined) => ConsentState;
|
|
15
15
|
export declare const convertBooleanConsentObjectToConsentObject: (consent: Partial<Record<keyof Consent, boolean | undefined>>, requirement: ConsentRequirement) => Consent;
|
|
16
|
-
export declare const buildRequirementsObject: ({
|
|
16
|
+
export declare const buildRequirementsObject: ({ functional, statistics, }: ConsentRequirement) => {
|
|
17
17
|
statistics?: true | undefined;
|
|
18
18
|
functional?: true | undefined;
|
|
19
|
-
marketing?: true | undefined;
|
|
20
19
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t=({adapter:t,name:e})=>{const n=(t=>{if(typeof document>"u")return;const e=document.cookie.split(";").map((t=>t.trim().split("="))).find((e=>e[0]===t));return e||void 0})(e);return n?JSON.parse(n[1]):t?t():void 0},e=({consent:t,maxAge:e=10368e3,name:n,domain:o,path:
|
|
1
|
+
const t=({adapter:t,name:e})=>{const n=(t=>{if(typeof document>"u")return;const e=document.cookie.split(";").map((t=>t.trim().split("="))).find((e=>e[0]===t));return e||void 0})(e);return n?JSON.parse(n[1]):t?t():void 0},e=({consent:t,maxAge:e=10368e3,name:n,domain:o,path:s})=>{document.cookie=[`${n}=${JSON.stringify(t)}`,`max-age=${e}`,"SameSite=Lax",!!o&&`domain=${o}`,!!s&&`path=${s}`].filter((t=>t)).join(";")},n=(t,e)=>{if(!e)return Object.values(t).some((t=>t));const n=new Map(Object.entries(e)),o=Object.entries(t);for(const[t,e]of o)if(e&&null===n.get(t))return!0;return!1},o=t=>typeof t>"u"?null:!1===t||"false"===String(t).toLowerCase()?"denied":"accepted",s=(t,e)=>({functional:e.functional?o(t.functional):void 0,statistics:e.statistics?o(t.statistics):void 0}),i=({functional:t,statistics:e})=>({...t&&{functional:t},...e&&{statistics:e}});export{i as buildRequirementsObject,s as convertBooleanConsentObjectToConsentObject,o as convertBooleanToConsentValue,t as getConsentCookie,e as setConsentCookie,n as shouldShowConsentDialog};
|
|
2
2
|
//# sourceMappingURL=cookieConsentUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookieConsentUtils.js","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n path,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n path?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n \"SameSite=Lax\",\n !!domain && `domain=${domain}`,\n !!path && `path=${path}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n }\n\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n requirement: ConsentRequirement,\n): Consent => {\n return {\n functional: requirement.functional\n ? convertBooleanToConsentValue(consent.functional)\n : undefined,\n statistics: requirement.statistics\n ? convertBooleanToConsentValue(consent.statistics)\n : undefined,\n
|
|
1
|
+
{"version":3,"file":"cookieConsentUtils.js","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n path,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n path?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n \"SameSite=Lax\",\n !!domain && `domain=${domain}`,\n !!path && `path=${path}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n }\n\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n requirement: ConsentRequirement,\n): Consent => {\n return {\n functional: requirement.functional\n ? convertBooleanToConsentValue(consent.functional)\n : undefined,\n statistics: requirement.statistics\n ? convertBooleanToConsentValue(consent.statistics)\n : undefined,\n };\n};\n\nexport const buildRequirementsObject = ({\n functional,\n statistics,\n}: ConsentRequirement) => {\n return {\n ...(functional && { functional }),\n ...(statistics && { statistics }),\n };\n};\n"],"names":["getConsentCookie","adapter","name","cookie","document","split","map","s","trim","find","c","getCookie","JSON","parse","setConsentCookie","consent","maxAge","domain","path","stringify","filter","f","join","shouldShowConsentDialog","requirement","Object","values","some","requirementValue","consentMap","Map","entries","requirementEntries","required","get","convertBooleanToConsentValue","formValue","String","toLowerCase","convertBooleanConsentObjectToConsentObject","functional","statistics","buildRequirementsObject"],"mappings":"AAEA,MAoBaA,EAAmB,EAC5BC,QAAAA,EACAC,KAAAA,MAKMC,MAAAA,EA3BQ,CAACD,IACX,UAAOE,SAAa,IACb,OAGLD,MAAAA,EAASC,SAASD,OAEnBE,MAAM,KAENC,KAAKC,GAAMA,EAAEC,OAAOH,MAAM,OAE1BI,MAAMC,GAAMA,EAAE,KAAOR,IAErBC,OAAAA,QAAAA,CAIEA,EAUQQ,CAAUT,GAErBC,OAAAA,EACgBS,KAAKC,MAAMV,EAAO,IAKlCF,EACOA,SADPA,CACe,EASVa,EAAmB,EAC5BC,QAAAA,EACAC,OAAAA,EAAS,QACTd,KAAAA,EACAe,OAAAA,EACAC,KAAAA,MAQAd,SAASD,OAAS,CACd,GAAGD,KAAQU,KAAKO,UAAUJ,KAC1B,WAAWC,IACX,iBACEC,GAAU,UAAUA,MACpBC,GAAQ,QAAQA,KAEjBE,QAAQC,GAAMA,IACdC,KAAK,IAAG,EAGJC,EAA0B,CACnCC,EACAT,KAEA,IAAKA,EAEM,OAAAU,OAAOC,OAAOF,GAAaG,MAC7BC,GAAqBA,IAKxBC,MAAAA,EAAa,IAAIC,IAAIL,OAAOM,QAAQhB,IAGpCiB,EAAqBP,OAAOM,QAAQP,GAE/B,IAAA,MAACtB,EAAM+B,KAAaD,EAE3B,GAAKC,GAKwB,OAAzBJ,EAAWK,IAAIhC,GACR,OAAA,EAIR,OAAA,CAAA,EAGEiC,EACTC,UAEWA,EAAc,IACd,MAGO,IAAdA,GAA2D,UAApCC,OAAOD,GAAWE,cAClC,SAGJ,WAGEC,EAA6C,CACtDxB,EACAS,KAEO,CACHgB,WAAYhB,EAAYgB,WAClBL,EAA6BpB,EAAQyB,iBACrC,EACNC,WAAYjB,EAAYiB,WAClBN,EAA6BpB,EAAQ0B,iBACrC,IAIDC,EAA0B,EACnCF,WAAAA,EACAC,WAAAA,MAEO,IACCD,GAAc,CAAEA,WAAAA,MAChBC,GAAc,CAAEA,WAAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CookieConsent
|
|
1
|
+
export { CookieConsent } from './CookieConsent.js';
|
|
2
2
|
export { CookieConsentProvider, useCookieConsent, } from './CookieConsentContext.js';
|
|
3
|
-
export type { AcceptConsentCallback, Consent, ConsentState, CookieConsentProviderProps, } from './types.js';
|
|
3
|
+
export type { AcceptConsentCallback, Consent, ConsentState, CookieConsentProviderProps, CookieConsentProps, } from './types.js';
|
|
@@ -2,10 +2,17 @@ import { WithChildren } from '../../core/types.js';
|
|
|
2
2
|
export type ConsentState = null | "denied" | "accepted";
|
|
3
3
|
export type ConsentRequirement = Partial<Record<keyof Consent, boolean>>;
|
|
4
4
|
export type Consent = {
|
|
5
|
-
marketing?: ConsentState;
|
|
6
5
|
functional?: ConsentState;
|
|
7
6
|
statistics?: ConsentState;
|
|
8
7
|
};
|
|
8
|
+
export interface CookieConsentProps {
|
|
9
|
+
blocking?: boolean;
|
|
10
|
+
onAccept?: AcceptConsentCallback;
|
|
11
|
+
/**
|
|
12
|
+
* Lenke til informasjonssiden til cookiene i løsningen din.
|
|
13
|
+
*/
|
|
14
|
+
aboutPage: string;
|
|
15
|
+
}
|
|
9
16
|
export type AcceptConsentCallback = (consent: Consent) => void;
|
|
10
17
|
export type ConsentComponentBaseProps = {
|
|
11
18
|
className?: string;
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
--jkl-checkbox-box-size: 1.125rem;
|
|
34
34
|
--jkl-checkbox-line-height: 1.5rem;
|
|
35
35
|
}
|
|
36
|
-
@keyframes jkl-checkbox-checked-
|
|
36
|
+
@keyframes jkl-checkbox-checked-u7tmd5v {
|
|
37
37
|
0% {
|
|
38
38
|
width: 0;
|
|
39
39
|
height: 0;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
height: 58%;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
@keyframes jkl-checkbox-indeterminate-
|
|
50
|
+
@keyframes jkl-checkbox-indeterminate-u7tmd62 {
|
|
51
51
|
0% {
|
|
52
52
|
width: 0;
|
|
53
53
|
}
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
left: calc(-0.5 * var(--jkl-checkbox-box-size));
|
|
77
77
|
}
|
|
78
78
|
.jkl-checkbox__input:checked + .jkl-checkbox__label .jkl-checkbox__check-mark::after {
|
|
79
|
-
animation: jkl-checkbox-checked-
|
|
79
|
+
animation: jkl-checkbox-checked-u7tmd5v 150ms ease-in-out forwards;
|
|
80
80
|
opacity: 1;
|
|
81
81
|
}
|
|
82
82
|
.jkl-checkbox__input:indeterminate:not(:checked) + .jkl-checkbox__label .jkl-checkbox__indeterminate-mark::after {
|
|
83
|
-
animation: jkl-checkbox-indeterminate-
|
|
83
|
+
animation: jkl-checkbox-indeterminate-u7tmd62 150ms ease-in-out forwards;
|
|
84
84
|
opacity: 1;
|
|
85
85
|
}
|
|
86
86
|
.jkl-checkbox__input:focus-visible + .jkl-checkbox__label {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer jokul.components{:root,[data-density=comfortable],[data-layout-density=comfortable]{--jkl-checkbox-font-size:var(--jkl-body-font-size);--jkl-checkbox-line-height:var(--jkl-body-line-height);--jkl-checkbox-font-weight:var(--jkl-body-font-weight);--jkl-checkbox-height:3rem;--jkl-checkbox-box-size:1.5rem;--jkl-checkbox-line-height:2rem}@media (width >= 0) and (max-width:679px){:root,[data-density=comfortable],[data-layout-density=comfortable]{--jkl-checkbox-height:2.5rem;--jkl-checkbox-box-size:1.5rem;--jkl-checkbox-line-height:1.75rem}}[data-density=compact],[data-layout-density=compact]{--jkl-checkbox-font-size:var(--jkl-small-font-size);--jkl-checkbox-line-height:var(--jkl-small-line-height);--jkl-checkbox-font-weight:var(--jkl-small-font-weight);--jkl-checkbox-height:1.75rem;--jkl-checkbox-box-size:1.125rem;--jkl-checkbox-line-height:1.5rem}@keyframes jkl-checkbox-checked-
|
|
1
|
+
@layer jokul.components{:root,[data-density=comfortable],[data-layout-density=comfortable]{--jkl-checkbox-font-size:var(--jkl-body-font-size);--jkl-checkbox-line-height:var(--jkl-body-line-height);--jkl-checkbox-font-weight:var(--jkl-body-font-weight);--jkl-checkbox-height:3rem;--jkl-checkbox-box-size:1.5rem;--jkl-checkbox-line-height:2rem}@media (width >= 0) and (max-width:679px){:root,[data-density=comfortable],[data-layout-density=comfortable]{--jkl-checkbox-height:2.5rem;--jkl-checkbox-box-size:1.5rem;--jkl-checkbox-line-height:1.75rem}}[data-density=compact],[data-layout-density=compact]{--jkl-checkbox-font-size:var(--jkl-small-font-size);--jkl-checkbox-line-height:var(--jkl-small-line-height);--jkl-checkbox-font-weight:var(--jkl-small-font-weight);--jkl-checkbox-height:1.75rem;--jkl-checkbox-box-size:1.125rem;--jkl-checkbox-line-height:1.5rem}@keyframes jkl-checkbox-checked-u7tmd5v{0%{height:0;width:0}40%{height:0;width:18%}to{height:58%;width:18%}}@keyframes jkl-checkbox-indeterminate-u7tmd62{0%{width:0}to{width:66%}}.jkl-checkbox{--box-color:var(--jkl-color-border-action);--check-color:var(--jkl-color-border-action);--text-color:var(--jkl-color-text-default);--background-color:#0000;color:var(--text-color);display:flex;flex-wrap:wrap;font-size:var(--jkl-checkbox-font-size);font-weight:var(--jkl-checkbox-font-weight);line-height:var(--jkl-checkbox-line-height);min-height:var(--jkl-checkbox-height);position:relative}.jkl-checkbox__input{left:calc(var(--jkl-checkbox-box-size)*-.5);opacity:0;position:absolute;top:var(--jkl-checkbox-box-size)}.jkl-checkbox__input:checked+.jkl-checkbox__label .jkl-checkbox__check-mark:after{animation:jkl-checkbox-checked-u7tmd5v .15s ease-in-out forwards;opacity:1}.jkl-checkbox__input:indeterminate:not(:checked)+.jkl-checkbox__label .jkl-checkbox__indeterminate-mark:after{animation:jkl-checkbox-indeterminate-u7tmd62 .15s ease-in-out forwards;opacity:1}.jkl-checkbox__input:focus-visible+.jkl-checkbox__label{color:var(--jkl-checkbox-focus-color)}.jkl-checkbox__input:focus-visible+.jkl-checkbox__label>.jkl-checkbox__mark{outline:3px solid var(--jkl-color-border-action);outline-offset:3px}.jkl-checkbox__input:disabled+.jkl-checkbox__label{color:var(--jkl-checkbox-disabled-color)}.jkl-checkbox__input:active{--background-color:var(--jkl-color-background-input-focus)}.jkl-checkbox__label{cursor:pointer;display:flex;flex-shrink:0;max-width:100%;min-width:0}.jkl-checkbox__label:active .jkl-checkbox__mark,.jkl-checkbox__label:hover .jkl-checkbox__mark{outline:1px solid var(--box-color)}.jkl-checkbox__text{margin:calc((var(--jkl-checkbox-height) - var(--jkl-checkbox-line-height))*.5) 0;transition-duration:.15s;transition-property:color;transition-timing-function:ease;translate:0 .0625rem}.jkl-checkbox__mark{box-sizing:border-box;height:var(--jkl-checkbox-box-size);margin-block:calc((var(--jkl-checkbox-height) - var(--jkl-checkbox-box-size))*.5);position:relative;width:var(--jkl-checkbox-box-size);-webkit-margin-end:var(--jkl-unit-10);align-self:flex-start;background-color:var(--background-color);border:1px solid;border-color:var(--box-color);border-radius:0;flex-shrink:0;margin-inline-end:var(--jkl-unit-10);outline:none;transition-duration:.15s;transition-property:background-color;transition-timing-function:ease}@media screen and (forced-colors:active){.jkl-checkbox__mark{border:1px solid ButtonText;outline:revert}}.jkl-checkbox__check-mark:after{border-bottom:.125rem solid var(--check-color);border-left-width:.125rem;border-left:0 solid var(--check-color);border-right:.125rem solid var(--check-color);border-top-width:.125rem;border-top:0 solid var(--check-color);bottom:42%;content:"";display:block;height:58%;left:18%;opacity:0;position:absolute;transform:rotate(45deg);transform-origin:bottom left;transition-duration:.15s;transition-property:opacity,border-color;transition-timing-function:ease;width:18%}@media screen and (forced-colors:active){.jkl-checkbox__check-mark:after{border-color:ButtonText}}.jkl-checkbox__indeterminate-mark:after{--width:66%;--thickness:0.125rem;border-bottom:solid var(--thickness) var(--check-color);bottom:calc(50% - var(--thickness)/2);content:"";display:block;left:calc((100% - var(--width))/2);opacity:0;position:absolute;transition-duration:.15s;transition-property:opacity,border-color;transition-timing-function:ease;width:var(--width)}@media screen and (forced-colors:active){.jkl-checkbox__indeterminate-mark:after{border-color:ButtonText}}.jkl-checkbox--inline{display:inline-flex}.jkl-checkbox--inline:not(:last-of-type){margin-right:calc(var(--jkl-unit-10)*3)}.jkl-checkbox--error{--background-color:var(--jkl-color-background-alert-error);--check-color:var(--jkl-color-text-on-alert)}}
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
--outer-border-thickness: 0.125rem;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
@keyframes jkl-checkbox-checked-
|
|
67
|
+
@keyframes jkl-checkbox-checked-ubvyxo1 {
|
|
68
68
|
0% {
|
|
69
69
|
width: 0;
|
|
70
70
|
height: 0;
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
.jkl-checkbox-panel:has(:checked) .jkl-checkbox-panel__decorator::after {
|
|
131
|
-
animation: jkl-checkbox-checked-
|
|
131
|
+
animation: jkl-checkbox-checked-ubvyxo1 150ms ease-in-out forwards;
|
|
132
132
|
opacity: 1;
|
|
133
133
|
}
|
|
134
134
|
.jkl-checkbox-panel:has([aria-invalid=true]) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.jkl-input-panel{--outer-border-color:var(--jkl-color-border-input);--outer-border-thickness:0.0625rem;--background-color:#0000;background-color:var(--background-color);border-radius:4px;box-shadow:inset 0 0 0 var(--outer-border-thickness) var(--outer-border-color);cursor:pointer;padding-left:1rem}.jkl-input-panel__input{opacity:0;position:absolute;top:-6px}.jkl-input-panel__label{align-items:center;cursor:pointer;display:grid;gap:.5rem;grid-template-columns:-webkit-min-content fit-content(30%) 1fr;grid-template-columns:min-content fit-content(30%) 1fr}.jkl-input-panel__main-label{padding-block:1.5rem}.jkl-input-panel__extra-label{align-self:stretch;margin-left:1rem;margin-right:1rem}.jkl-input-panel__extra-label>:first-child{padding-right:1rem}.jkl-input-panel__extra-label--text{align-items:center;display:flex;height:100%}.jkl-input-panel__content{cursor:default;height:0;overflow:hidden;padding-right:1.5rem}.jkl-input-panel:has([aria-expanded=true]) .jkl-input-panel__content,.jkl-input-panel__content[data-alwaysopen=true]{height:auto;padding-bottom:24px}.jkl-input-panel:has(:focus-visible){outline:3px solid var(--jkl-color-border-action);outline-offset:3px}.jkl-input-panel:has(:checked){--background-color:var(--jkl-color-background-container-high)}.jkl-input-panel:hover{--outer-border-color:var(--jkl-color-border-separator-hover);--outer-border-thickness:0.125rem}@keyframes jkl-checkbox-checked-
|
|
1
|
+
.jkl-input-panel{--outer-border-color:var(--jkl-color-border-input);--outer-border-thickness:0.0625rem;--background-color:#0000;background-color:var(--background-color);border-radius:4px;box-shadow:inset 0 0 0 var(--outer-border-thickness) var(--outer-border-color);cursor:pointer;padding-left:1rem}.jkl-input-panel__input{opacity:0;position:absolute;top:-6px}.jkl-input-panel__label{align-items:center;cursor:pointer;display:grid;gap:.5rem;grid-template-columns:-webkit-min-content fit-content(30%) 1fr;grid-template-columns:min-content fit-content(30%) 1fr}.jkl-input-panel__main-label{padding-block:1.5rem}.jkl-input-panel__extra-label{align-self:stretch;margin-left:1rem;margin-right:1rem}.jkl-input-panel__extra-label>:first-child{padding-right:1rem}.jkl-input-panel__extra-label--text{align-items:center;display:flex;height:100%}.jkl-input-panel__content{cursor:default;height:0;overflow:hidden;padding-right:1.5rem}.jkl-input-panel:has([aria-expanded=true]) .jkl-input-panel__content,.jkl-input-panel__content[data-alwaysopen=true]{height:auto;padding-bottom:24px}.jkl-input-panel:has(:focus-visible){outline:3px solid var(--jkl-color-border-action);outline-offset:3px}.jkl-input-panel:has(:checked){--background-color:var(--jkl-color-background-container-high)}.jkl-input-panel:hover{--outer-border-color:var(--jkl-color-border-separator-hover);--outer-border-thickness:0.125rem}@keyframes jkl-checkbox-checked-ubvyxo1{0%{height:0;width:0}40%{height:0;width:18%}to{height:58%;width:18%}}@layer jokul.components{.jkl-checkbox-panel{--checkbox-background-color:#0000;--checkbox-box-color:var(--jkl-color-border-action);--checkbox-check-color:var(--jkl-color-border-action)}.jkl-checkbox-panel__decorator{background-color:var(--checkbox-background-color);border:1px solid;border-color:var(--checkbox-box-color);border-radius:0;box-sizing:border-box;height:var(--jkl-checkbox-box-size);outline:none;position:relative;transition-duration:.15s;transition-property:background-color;transition-timing-function:ease;width:var(--jkl-checkbox-box-size)}@media screen and (forced-colors:active){.jkl-checkbox-panel__decorator{border:1px solid ButtonText;outline:revert}}.jkl-checkbox-panel__decorator:after{border-bottom:.125rem solid var(--checkbox-check-color);border-left-width:.125rem;border-left:0 solid var(--checkbox-check-color);border-right:.125rem solid var(--checkbox-check-color);border-top-width:.125rem;border-top:0 solid var(--checkbox-check-color);bottom:42%;content:"";display:block;height:58%;left:18%;opacity:0;position:absolute;transform:rotate(45deg);transform-origin:bottom left;transition-duration:.15s;transition-property:opacity,border-color;transition-timing-function:ease;width:18%}@media screen and (forced-colors:active){.jkl-checkbox-panel__decorator:after{border-color:ButtonText}}.jkl-checkbox-panel:has(:checked) .jkl-checkbox-panel__decorator:after{animation:jkl-checkbox-checked-ubvyxo1 .15s ease-in-out forwards;opacity:1}.jkl-checkbox-panel:has([aria-invalid=true]){--checkbox-background-color:var(
|
|
2
2
|
--jkl-color-background-alert-error
|
|
3
3
|
);--checkbox-check-color:var(--jkl-color-text-on-alert)}}
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
.jkl-countdown__tracker {
|
|
32
|
-
animation: jkl-downcount-
|
|
32
|
+
animation: jkl-downcount-uryl1lv var(--duration) linear forwards;
|
|
33
33
|
animation-play-state: var(--play-state, running);
|
|
34
34
|
}
|
|
35
|
-
@keyframes jkl-downcount-
|
|
35
|
+
@keyframes jkl-downcount-uryl1lv {
|
|
36
36
|
from {
|
|
37
37
|
width: 100%;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer jokul.components{.jkl-countdown{--track-color:var(--jkl-color-border-separator);--bar-color:var(--jkl-color-border-input-focus);--bar-height:0.25rem;background-color:var(--track-color);border-radius:6.25rem;height:var(--bar-height);overflow:hidden;width:100%}.jkl-countdown__tracker{background-color:var(--bar-color);display:block;height:var(--bar-height)}@media screen and (forced-colors:active){.jkl-countdown{background-color:Canvas}.jkl-countdown__tracker{background-color:CanvasText}}.jkl-countdown__tracker{animation:jkl-downcount-
|
|
1
|
+
@layer jokul.components{.jkl-countdown{--track-color:var(--jkl-color-border-separator);--bar-color:var(--jkl-color-border-input-focus);--bar-height:0.25rem;background-color:var(--track-color);border-radius:6.25rem;height:var(--bar-height);overflow:hidden;width:100%}.jkl-countdown__tracker{background-color:var(--bar-color);display:block;height:var(--bar-height)}@media screen and (forced-colors:active){.jkl-countdown{background-color:Canvas}.jkl-countdown__tracker{background-color:CanvasText}}.jkl-countdown__tracker{animation:jkl-downcount-uryl1lv var(--duration) linear forwards;animation-play-state:var(--play-state,running)}@keyframes jkl-downcount-uryl1lv{0%{width:100%}to{width:0}}}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Do not edit directly, this file was auto-generated.
|
|
6
6
|
*/
|
|
7
|
-
@keyframes jkl-show-
|
|
7
|
+
@keyframes jkl-show-us7jwqy {
|
|
8
8
|
from {
|
|
9
9
|
transform: translate3d(0, 0.5rem, 0);
|
|
10
10
|
opacity: 0;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
.jkl-feedback__fade-in {
|
|
42
|
-
animation: jkl-show-
|
|
42
|
+
animation: jkl-show-us7jwqy 0.25s ease-out;
|
|
43
43
|
}
|
|
44
44
|
.jkl-feedback__buttons {
|
|
45
45
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@keyframes jkl-show-
|
|
1
|
+
@keyframes jkl-show-us7jwqy{0%{opacity:0;transform:translate3d(0,.5rem,0)}}.jkl-feedback{max-width:34.375rem}.jkl-feedback__submit-wrapper{transition-duration:.25s;transition-property:height;transition-timing-function:ease;width:100%}.jkl-feedback__submit-wrapper--hidden{display:none}.jkl-feedback__step-counter{color:var(--jkl-color-text-subdued);font-size:1.125rem;font-weight:400;line-height:1.75rem;margin-bottom:calc(var(--jkl-unit-10)*2);--jkl-icon-weight:300}@media (min-width:680px){.jkl-feedback__step-counter{font-size:1.25rem;font-weight:400;line-height:2rem;--jkl-icon-weight:300}}.jkl-feedback__fade-in{animation:jkl-show-us7jwqy .25s ease-out}.jkl-feedback__buttons{display:flex}.jkl-feedback-smileys{display:flex;flex-wrap:nowrap;gap:.75rem;justify-content:space-between;margin-top:.5rem;max-width:22.5rem;width:100%}.jkl-feedback-smiley-option{color:var(--jkl-color-text-subdued);cursor:pointer;display:inline-block;height:2.5rem;position:relative;transform:translateZ(0);transition-duration:.15s;transition-property:transform,color;transition-timing-function:ease;width:2.5rem}@media screen and (forced-colors:active){.jkl-feedback-smiley-option,.jkl-feedback-smiley-option path,.jkl-feedback-smiley-option svg{stroke:ButtonFace;fill:ButtonText}}.jkl-feedback-smiley-option:after,.jkl-feedback-smiley-option:before{border-radius:50%;content:"";opacity:0;position:absolute;transition-duration:.15s;transition-property:opacity;transition-timing-function:ease}.jkl-feedback-smiley-option:after{box-shadow:0 0 0 .125rem currentColor;inset:-.125rem -.125rem -.125rem -.125rem}.jkl-feedback-smiley-option:before{box-shadow:0 .125rem 1.875rem #0000001a;inset:0}.jkl-feedback-smiley-option:hover{color:var(--jkl-color-text-default)}input:checked+.jkl-feedback-smiley-option{color:var(--jkl-color-text-default);transform:translate3d(0,-20%,0)}html:not([data-mousenavigation]):not([data-touchnavigation]) input:focus+.jkl-feedback-smiley-option:after,input:checked+.jkl-feedback-smiley-option:before{opacity:1}
|