Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zengenti-react-cookie-control

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zengenti-react-cookie-control - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

14

dist/cjs/index.js

@@ -134,3 +134,2 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("styled-components");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=o(e),l=o(t);const i=e.createContext({analytics:!1,defaultCookiePreferences:{analytics:!1,functional:!1,marketing:!1},functional:!1,marketing:!1,set:()=>{},showCookieControl:!1,showUpdatePreferences:!1,toggleShowUpdatePreferences:()=>{}}),a=()=>{const t=e.useContext(i),[o,n]=e.useState(t.analytics),[l,a]=e.useState(t.functional),[c,r]=e.useState(t.marketing),[d,s]=e.useState(!1),u=()=>{s(!0)};return e.useEffect((()=>{n(t.analytics),a(t.functional),r(t.marketing)}),[t]),e.useEffect((()=>{d&&(t.set({analytics:o,functional:l,marketing:c}),s(!1))}),[o,t,l,c,d]),e.useMemo((()=>({acceptAll:()=>{n(!0),a(!0),r(!0),u()},analytics:o,declineAll:()=>{n(!1),a(!1),r(!1),u()},defaultCookiePreferences:t.defaultCookiePreferences,functional:l,marketing:c,setAnalytics:n,setFunctional:a,setMarketing:r,showUpdatePreferences:t.showUpdatePreferences,showCookieControl:t.showCookieControl,toggleShowUpdatePreferences:t.toggleShowUpdatePreferences,updatePreferences:u})),[o,t,l,c])},c=l.default.button``,r=e=>{const t=(()=>{var e;if("undefined"==typeof window)return{};const t=null===(e=document.cookie)||void 0===e?void 0:e.trim();return t.length>0?t.split(";").reduce(((e,t)=>{const o=t.split("="),n=o[0].trim(),l=o[1].trim();return Object.assign(Object.assign({},e),{[n]:l})}),{}):{}})();return t[e]},d=(e,t,o)=>{if("undefined"!=typeof window&&navigator.cookieEnabled)if(0===o)document.cookie=`${e} = ${t}`;else{const n=new Date;n.setTime(n.getTime()+24*(o||1)*60*60*1e3);const l="expires="+n.toUTCString();document.cookie=`${e} = ${t}; ${l}`}};const s={background:"#fff",button:{borderRadius:"2px",borderWidth:"1px",borderColor:"#1d5fc2",color:"#1d5fc2",fontSize:"16px",lineHeight:"24px",padding:"16px 24px",solid:{background:"#1d5c90",color:"#fff",hover:{background:"#00304d",color:"#fff"}}},containerWidth:"1280px",divideColor:"#ddd",heading:{color:"#002033",fontFamily:"Poppins, Arial, sans-serif",fontSize:"20px",fontWeight:"500",lineHeight:"24px"},iconColor:"#444",linkColor:"#1d5fc2",text:{color:"#444",fontFamily:"Poppins, Arial, sans-serif",fontSize:"16px",fontWeight:"400",lineHeight:"24px"},toggle:{off:{background:"#ccc",hover:"#999"},on:{background:"#1d5c90",hover:"#00304d"}}},u=l.default.div`

border-radius: 20px;
box-shadow: rgba(0, 0, 0, 0.5) 1px 1px 3px 0 inset;
height: 24px;

@@ -146,3 +145,2 @@ left: 0;

border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.9) 1px 1px 3px 0;
height: 16px;

@@ -183,3 +181,3 @@ left: 4px;

`,p=({id:e,isChecked:t,label:o,onClick:l})=>n.default.createElement(f,{className:"zen-cc-toggle "+(t?"checked":"")},n.default.createElement("input",{checked:t,className:"zen-cc-toggle__checkbox",id:e,onChange:e=>l(),type:"checkbox"}),n.default.createElement("label",{className:"zen-cc-toggle__label",htmlFor:e},o)),v=l.default.button`
${({theme:e})=>{var o,n,l,i,a,c,r,d,s,u,f,p,v,m,g,h,x,b;return e.button.customStyles?t.css`
${({theme:e})=>{var o,n,l,i,a,c,r,d,s,u,f,p,v,m,g,h,b,x;return e.button.customStyles?t.css`
${e.button.customStyles}

@@ -210,3 +208,3 @@ `:t.css`

background: ${null===(m=null===(v=null===(p=null==e?void 0:e.button)||void 0===p?void 0:p.solid)||void 0===v?void 0:v.hover)||void 0===m?void 0:m.background};
color: ${null===(x=null===(h=null===(g=null==e?void 0:e.button)||void 0===g?void 0:g.solid)||void 0===h?void 0:h.hover)||void 0===x?void 0:x.color};
color: ${null===(b=null===(h=null===(g=null==e?void 0:e.button)||void 0===g?void 0:g.solid)||void 0===h?void 0:h.hover)||void 0===b?void 0:b.color};
}

@@ -216,3 +214,3 @@ }

&:hover {
box-shadow: ${null===(b=null==e?void 0:e.button)||void 0===b?void 0:b.borderColor} 0px 0px 0px 1px inset;
box-shadow: ${null===(x=null==e?void 0:e.button)||void 0===x?void 0:x.borderColor} 0px 0px 0px 1px inset;
}

@@ -242,3 +240,3 @@ }

}
`,h=({onClick:e})=>n.default.createElement(g,{onClick:e},n.default.createElement("svg",{width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n.default.createElement("path",{d:"M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.997.997 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.997.997 0 0 0 1.41 1.41L12 13.41l4.89 4.89a.997.997 0 0 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z",fill:"#002033"})),n.default.createElement("span",{className:"sr-only"},"Close cookie banner")),x=({content:t})=>{const{acceptAll:o,analytics:l,declineAll:i,defaultCookiePreferences:c,functional:r,marketing:d,setAnalytics:s,setFunctional:f,setMarketing:v,showCookieControl:g,updatePreferences:x}=a();return e.useEffect((()=>{g&&(s(c.analytics),f(c.functional),v(c.marketing))}),[g]),g?n.default.createElement(u,{className:"zen-cc-cc","data-nosnippet":!0},n.default.createElement("h2",{className:"sr-only"},"Cookie control banner"),n.default.createElement("div",{className:"zen-cc-cc__inner"},n.default.createElement("div",{className:"zen-cc-cc__close"},n.default.createElement(h,{onClick:()=>x()})),n.default.createElement("div",{className:"zen-cc-cc__flex"},n.default.createElement("div",null,t&&n.default.createElement("div",{className:"zen-cc-cc__content",dangerouslySetInnerHTML:{__html:t}}),n.default.createElement("div",{className:"zen-cc-cc__toggles"},n.default.createElement(p,{id:"cc-marketing",isChecked:d,label:"Marketing",onClick:()=>v((e=>!e))}),n.default.createElement(p,{id:"cc-functional",isChecked:r,label:"Functional",onClick:()=>f((e=>!e))}),n.default.createElement(p,{id:"cc-analytics",isChecked:l,label:"Analytics",onClick:()=>s((e=>!e))}))),n.default.createElement("div",{className:"zen-cc-cc__buttons"},n.default.createElement("div",{className:"zen-cc-cc__button-wrap"},n.default.createElement(m,{label:"Accept all",onClick:()=>o(),type:"hollow"})),n.default.createElement("div",{className:"zen-cc-cc__button-wrap"},n.default.createElement(m,{label:"Decline all",onClick:()=>i(),type:"hollow"})),n.default.createElement("div",{className:"zen-cc-cc__button-wrap"},n.default.createElement(m,{label:"Save preferences",onClick:()=>x()})))))):null},b=l.default.div`
`,h=({onClick:e})=>n.default.createElement(g,{onClick:e},n.default.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n.default.createElement("path",{d:"M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.997.997 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.997.997 0 0 0 1.41 1.41L12 13.41l4.89 4.89a.997.997 0 0 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z",fill:"#002033"})),n.default.createElement("span",{className:"sr-only"},"Close cookie banner")),b=({content:t})=>{const{acceptAll:o,analytics:l,declineAll:i,defaultCookiePreferences:c,functional:r,marketing:d,setAnalytics:s,setFunctional:f,setMarketing:v,showCookieControl:g,updatePreferences:b}=a();return e.useEffect((()=>{g&&(s(c.analytics),f(c.functional),v(c.marketing))}),[g]),g?n.default.createElement(u,{className:"zen-cc-cc","data-nosnippet":!0},n.default.createElement("h2",{className:"sr-only"},"Cookie control banner"),n.default.createElement("div",{className:"zen-cc-cc__inner"},n.default.createElement("div",{className:"zen-cc-cc__close"},n.default.createElement(h,{onClick:()=>b()})),n.default.createElement("div",{className:"zen-cc-cc__flex"},n.default.createElement("div",null,t&&n.default.createElement("div",{className:"zen-cc-cc__content",dangerouslySetInnerHTML:{__html:t}}),n.default.createElement("div",{className:"zen-cc-cc__toggles"},n.default.createElement(p,{id:"cc-marketing",isChecked:d,label:"Marketing",onClick:()=>v((e=>!e))}),n.default.createElement(p,{id:"cc-functional",isChecked:r,label:"Functional",onClick:()=>f((e=>!e))}),n.default.createElement(p,{id:"cc-analytics",isChecked:l,label:"Analytics",onClick:()=>s((e=>!e))}))),n.default.createElement("div",{className:"zen-cc-cc__buttons"},n.default.createElement("div",{className:"zen-cc-cc__button-wrap"},n.default.createElement(m,{label:"Accept all",onClick:()=>o(),type:"hollow"})),n.default.createElement("div",{className:"zen-cc-cc__button-wrap"},n.default.createElement(m,{label:"Decline all",onClick:()=>i(),type:"hollow"})),n.default.createElement("div",{className:"zen-cc-cc__button-wrap"},n.default.createElement(m,{label:"Save preferences",onClick:()=>b()})))))):null},x=l.default.div`
${({theme:e})=>{var o,n,l,i,a,c,r,d,s,u;return t.css`

@@ -334,3 +332,3 @@ .zen-cc-up__modal {

`}}
`,k=({isChecked:e,label:t,onClick:o,summary:l,title:i,cookies:a})=>l||t?n.default.createElement("div",{className:"zen-cc-up__section"},n.default.createElement("div",{className:"zen-cc-up__title"},i),l&&n.default.createElement("div",{className:"zen-cc-up__summary",dangerouslySetInnerHTML:{__html:l}}),t&&o&&n.default.createElement(p,{id:`cp-${t.toLowerCase().replace(/ /g,"-")}`,isChecked:!!e,label:t,onClick:o}),a):null,y=t=>{var o,l,i,c,r,d,s,u;const{analytics:f,marketing:p,functional:v,setAnalytics:g,setMarketing:x,setFunctional:y,showUpdatePreferences:w,toggleShowUpdatePreferences:_,updatePreferences:C}=a(),E=e.useRef(null);return e.useEffect((()=>{const e=window.getComputedStyle(document.body).overflow,t=e=>E.current&&!E.current.contains(e.target)&&w&&_();return w?(window.scrollTo({top:0,behavior:"smooth"}),document.body.style.overflow="hidden",setTimeout((()=>document.addEventListener("click",t,!1)),100)):document.removeEventListener("click",t,!1),()=>{document.body.style.overflow=e,document.removeEventListener("click",t,!1)}}),[w,_]),w?n.default.createElement(b,{"data-nosnippet":!0,className:"zen-cc-up "+(w?"open":"closed")},n.default.createElement("h2",{className:"sr-only"},"Cookie control banner"),n.default.createElement("div",{className:"zen-cc-up__modal",ref:E},n.default.createElement("div",{className:"zen-cc-up__inner"},n.default.createElement("div",{className:"zen-cc-up__close"},n.default.createElement(h,{onClick:()=>_()})),t.content&&n.default.createElement("div",{className:"zen-cc-up__section",dangerouslySetInnerHTML:{__html:t.content}}),n.default.createElement(k,{summary:null===(o=t.necessary)||void 0===o?void 0:o.summary,cookies:null===(l=t.necessary)||void 0===l?void 0:l.cookies,title:"Necessary Cookies"}),n.default.createElement(k,{isChecked:v,label:"Functional",onClick:()=>y(!v),summary:null===(i=t.functional)||void 0===i?void 0:i.summary,cookies:null===(c=t.functional)||void 0===c?void 0:c.cookies,title:"Functional Cookies"}),n.default.createElement(k,{isChecked:f,label:"Analytics",onClick:()=>g(!f),summary:null===(r=t.analytics)||void 0===r?void 0:r.summary,cookies:null===(d=t.analytics)||void 0===d?void 0:d.cookies,title:"Analytical Cookies"}),n.default.createElement(k,{isChecked:p,label:"Marketing",onClick:()=>x(!p),summary:null===(s=t.marketing)||void 0===s?void 0:s.summary,cookies:null===(u=t.marketing)||void 0===u?void 0:u.cookies,title:"Marketing Cookies"}),n.default.createElement("div",{className:"zen-cc-up__save"},n.default.createElement(m,{label:"Save Preferences",onClick:()=>{C(),_()}}))))):null};exports.ToggleUpdatePreferences=({className:e,label:t="Cookie Preferences"})=>{const{showCookieControl:o,toggleShowUpdatePreferences:l}=a();return o?null:n.default.createElement(c,{className:e,onClick:()=>l()},t)},exports.getCookieValue=r,exports.setCookieValue=d,exports.useCookieControl=a,exports.withCookieProvider=({cookieControl:o,defaultCookiePreferences:l,updatePreferences:a,theme:c})=>u=>f=>{var p=
`,k=({isChecked:e,label:t,onClick:o,summary:l,title:i,cookies:a})=>t?n.default.createElement("div",{className:"zen-cc-up__section"},n.default.createElement("div",{className:"zen-cc-up__title"},i),o&&n.default.createElement(p,{id:`cp-${t.toLowerCase().replace(/ /g,"-")}`,isChecked:!!e,label:t,onClick:o}),l&&n.default.createElement("div",{className:"zen-cc-up__summary",dangerouslySetInnerHTML:{__html:l}}),a):null,y=t=>{var o,l,i,c,r,d,s,u;const{analytics:f,marketing:p,functional:v,setAnalytics:g,setMarketing:b,setFunctional:y,showUpdatePreferences:w,toggleShowUpdatePreferences:_,updatePreferences:C}=a(),E=e.useRef(null);return e.useEffect((()=>{const e=window.getComputedStyle(document.body).overflow,t=e=>E.current&&!E.current.contains(e.target)&&w&&_();return w?(window.scrollTo({top:0,behavior:"smooth"}),document.body.style.overflow="hidden",setTimeout((()=>document.addEventListener("click",t,!1)),100)):document.removeEventListener("click",t,!1),()=>{document.body.style.overflow=e,document.removeEventListener("click",t,!1)}}),[w,_]),w?n.default.createElement(x,{"data-nosnippet":!0,className:"zen-cc-up "+(w?"open":"closed")},n.default.createElement("h2",{className:"sr-only"},"Cookie control banner"),n.default.createElement("div",{className:"zen-cc-up__modal",ref:E},n.default.createElement("div",{className:"zen-cc-up__inner"},n.default.createElement("div",{className:"zen-cc-up__close"},n.default.createElement(h,{onClick:()=>_()})),t.content&&n.default.createElement("div",{className:"zen-cc-up__section",dangerouslySetInnerHTML:{__html:t.content}}),n.default.createElement(k,{isChecked:!0,label:"Necessary",summary:null===(o=t.necessary)||void 0===o?void 0:o.summary,cookies:null===(l=t.necessary)||void 0===l?void 0:l.cookies,title:"Necessary Cookies"}),n.default.createElement(k,{isChecked:v,label:"Functional",onClick:()=>y(!v),summary:null===(i=t.functional)||void 0===i?void 0:i.summary,cookies:null===(c=t.functional)||void 0===c?void 0:c.cookies,title:"Functional Cookies"}),n.default.createElement(k,{isChecked:f,label:"Analytics",onClick:()=>g(!f),summary:null===(r=t.analytics)||void 0===r?void 0:r.summary,cookies:null===(d=t.analytics)||void 0===d?void 0:d.cookies,title:"Analytical Cookies"}),n.default.createElement(k,{isChecked:p,label:"Marketing",onClick:()=>b(!p),summary:null===(s=t.marketing)||void 0===s?void 0:s.summary,cookies:null===(u=t.marketing)||void 0===u?void 0:u.cookies,title:"Marketing Cookies"}),n.default.createElement("div",{className:"zen-cc-up__save"},n.default.createElement(m,{label:"Save Preferences",onClick:()=>{C(),_()}}))))):null};exports.ToggleUpdatePreferences=({className:e,label:t="Cookie Preferences"})=>{const{showCookieControl:o,toggleShowUpdatePreferences:l}=a();return o?null:n.default.createElement(c,{className:e,onClick:()=>l()},t)},exports.getCookieValue=r,exports.setCookieValue=d,exports.useCookieControl=a,exports.withCookieProvider=({cookieControl:o,defaultCookiePreferences:l,updatePreferences:a,theme:c})=>u=>f=>{var p=
/*! *****************************************************************************

@@ -350,3 +348,3 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)t.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(e,n[l])&&(o[n[l]]=e[n[l]])}return o}(f,[]);const[v,m]=e.useState(!1),[g,h]=e.useState(!1),[b,k]=e.useState(!1),[w,_]=e.useState(!1),[C,E]=e.useState(!1),[z,$]=e.useState([]);e.useEffect((()=>{const e=r("zen-cc");if(e){const{analytics:t,functional:o,marketing:n}=JSON.parse(e);m(!!t),h(!!o),k(!!n)}else _(!0)}),[]),e.useEffect((()=>{if("undefined"!=typeof window&&2===z.length){const e=z[0],t=z[1];z&&Object.keys(e).some((o=>e[o]&&!t[o]))&&window.location.reload(),$((e=>[...e.slice(1)]))}}),[z]);const S=e.useMemo((()=>({analytics:v,defaultCookiePreferences:l,marketing:b,functional:g,set:({analytics:e,functional:t,marketing:o})=>{m(e),h(t),k(o),_(!1),d("zen-cc",JSON.stringify({analytics:e,functional:t,marketing:o}),90),$((n=>[...n,{analytics:e,functional:t,marketing:o}]))},showCookieControl:w,showUpdatePreferences:C,toggleShowUpdatePreferences:()=>E((e=>!e))})),[v,g,b,w,C]);return n.default.createElement(i.Provider,{value:S},n.default.createElement(t.ThemeProvider,{theme:Object.assign(Object.assign({},s),c)},n.default.createElement(x,Object.assign({},o)),n.default.createElement(y,Object.assign({},a))),n.default.createElement(u,Object.assign({},p)))};
function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)t.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(e,n[l])&&(o[n[l]]=e[n[l]])}return o}(f,[]);const[v,m]=e.useState(!1),[g,h]=e.useState(!1),[x,k]=e.useState(!1),[w,_]=e.useState(!1),[C,E]=e.useState(!1),[z,$]=e.useState([]);e.useEffect((()=>{const e=r("zen-cc");if(e){const{analytics:t,functional:o,marketing:n}=JSON.parse(e);m(!!t),h(!!o),k(!!n)}else _(!0)}),[]),e.useEffect((()=>{if("undefined"!=typeof window&&2===z.length){const e=z[0],t=z[1];z&&Object.keys(e).some((o=>e[o]&&!t[o]))&&window.location.reload(),$((e=>[...e.slice(1)]))}}),[z]);const S=e.useMemo((()=>({analytics:v,defaultCookiePreferences:l,marketing:x,functional:g,set:({analytics:e,functional:t,marketing:o})=>{m(e),h(t),k(o),_(!1),d("zen-cc",JSON.stringify({analytics:e,functional:t,marketing:o}),90),$((n=>[...n,{analytics:e,functional:t,marketing:o}]))},showCookieControl:w,showUpdatePreferences:C,toggleShowUpdatePreferences:()=>E((e=>!e))})),[v,g,x,w,C]);return n.default.createElement(i.Provider,{value:S},n.default.createElement(t.ThemeProvider,{theme:Object.assign(Object.assign({},s),c)},n.default.createElement(b,Object.assign({},o)),n.default.createElement(y,Object.assign({},a))),n.default.createElement(u,Object.assign({},p)))};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import e,{createContext as o,useContext as n,useState as t,useEffect as l,useMemo as i,useRef as c}from"react";import a,{css as r,ThemeProvider as d}from"styled-components";const s=o({analytics:!1,defaultCookiePreferences:{analytics:!1,functional:!1,marketing:!1},functional:!1,marketing:!1,set:()=>{},showCookieControl:!1,showUpdatePreferences:!1,toggleShowUpdatePreferences:()=>{}}),u=()=>{const e=n(s),[o,c]=t(e.analytics),[a,r]=t(e.functional),[d,u]=t(e.marketing),[p,m]=t(!1),v=()=>{m(!0)};return l((()=>{c(e.analytics),r(e.functional),u(e.marketing)}),[e]),l((()=>{p&&(e.set({analytics:o,functional:a,marketing:d}),m(!1))}),[o,e,a,d,p]),i((()=>({acceptAll:()=>{c(!0),r(!0),u(!0),v()},analytics:o,declineAll:()=>{c(!1),r(!1),u(!1),v()},defaultCookiePreferences:e.defaultCookiePreferences,functional:a,marketing:d,setAnalytics:c,setFunctional:r,setMarketing:u,showUpdatePreferences:e.showUpdatePreferences,showCookieControl:e.showCookieControl,toggleShowUpdatePreferences:e.toggleShowUpdatePreferences,updatePreferences:v})),[o,e,a,d])},p=a.button``,m=({className:o,label:n="Cookie Preferences"})=>{const{showCookieControl:t,toggleShowUpdatePreferences:l}=u();return t?null:e.createElement(p,{className:o,onClick:()=>l()},n)},v=e=>{const o=(()=>{var e;if("undefined"==typeof window)return{};const o=null===(e=document.cookie)||void 0===e?void 0:e.trim();return o.length>0?o.split(";").reduce(((e,o)=>{const n=o.split("="),t=n[0].trim(),l=n[1].trim();return Object.assign(Object.assign({},e),{[t]:l})}),{}):{}})();return o[e]},f=(e,o,n)=>{if("undefined"!=typeof window&&navigator.cookieEnabled)if(0===n)document.cookie=`${e} = ${o}`;else{const t=new Date;t.setTime(t.getTime()+24*(n||1)*60*60*1e3);const l="expires="+t.toUTCString();document.cookie=`${e} = ${o}; ${l}`}};const g={background:"#fff",button:{borderRadius:"2px",borderWidth:"1px",borderColor:"#1d5fc2",color:"#1d5fc2",fontSize:"16px",lineHeight:"24px",padding:"16px 24px",solid:{background:"#1d5c90",color:"#fff",hover:{background:"#00304d",color:"#fff"}}},containerWidth:"1280px",divideColor:"#ddd",heading:{color:"#002033",fontFamily:"Poppins, Arial, sans-serif",fontSize:"20px",fontWeight:"500",lineHeight:"24px"},iconColor:"#444",linkColor:"#1d5fc2",text:{color:"#444",fontFamily:"Poppins, Arial, sans-serif",fontSize:"16px",fontWeight:"400",lineHeight:"24px"},toggle:{off:{background:"#ccc",hover:"#999"},on:{background:"#1d5c90",hover:"#00304d"}}},h=a.div`
import e,{createContext as o,useContext as n,useState as t,useEffect as l,useMemo as i,useRef as c}from"react";import a,{css as r,ThemeProvider as d}from"styled-components";const s=o({analytics:!1,defaultCookiePreferences:{analytics:!1,functional:!1,marketing:!1},functional:!1,marketing:!1,set:()=>{},showCookieControl:!1,showUpdatePreferences:!1,toggleShowUpdatePreferences:()=>{}}),u=()=>{const e=n(s),[o,c]=t(e.analytics),[a,r]=t(e.functional),[d,u]=t(e.marketing),[p,v]=t(!1),m=()=>{v(!0)};return l((()=>{c(e.analytics),r(e.functional),u(e.marketing)}),[e]),l((()=>{p&&(e.set({analytics:o,functional:a,marketing:d}),v(!1))}),[o,e,a,d,p]),i((()=>({acceptAll:()=>{c(!0),r(!0),u(!0),m()},analytics:o,declineAll:()=>{c(!1),r(!1),u(!1),m()},defaultCookiePreferences:e.defaultCookiePreferences,functional:a,marketing:d,setAnalytics:c,setFunctional:r,setMarketing:u,showUpdatePreferences:e.showUpdatePreferences,showCookieControl:e.showCookieControl,toggleShowUpdatePreferences:e.toggleShowUpdatePreferences,updatePreferences:m})),[o,e,a,d])},p=a.button``,v=({className:o,label:n="Cookie Preferences"})=>{const{showCookieControl:t,toggleShowUpdatePreferences:l}=u();return t?null:e.createElement(p,{className:o,onClick:()=>l()},n)},m=e=>{const o=(()=>{var e;if("undefined"==typeof window)return{};const o=null===(e=document.cookie)||void 0===e?void 0:e.trim();return o.length>0?o.split(";").reduce(((e,o)=>{const n=o.split("="),t=n[0].trim(),l=n[1].trim();return Object.assign(Object.assign({},e),{[t]:l})}),{}):{}})();return o[e]},f=(e,o,n)=>{if("undefined"!=typeof window&&navigator.cookieEnabled)if(0===n)document.cookie=`${e} = ${o}`;else{const t=new Date;t.setTime(t.getTime()+24*(n||1)*60*60*1e3);const l="expires="+t.toUTCString();document.cookie=`${e} = ${o}; ${l}`}};const g={background:"#fff",button:{borderRadius:"2px",borderWidth:"1px",borderColor:"#1d5fc2",color:"#1d5fc2",fontSize:"16px",lineHeight:"24px",padding:"16px 24px",solid:{background:"#1d5c90",color:"#fff",hover:{background:"#00304d",color:"#fff"}}},containerWidth:"1280px",divideColor:"#ddd",heading:{color:"#002033",fontFamily:"Poppins, Arial, sans-serif",fontSize:"20px",fontWeight:"500",lineHeight:"24px"},iconColor:"#444",linkColor:"#1d5fc2",text:{color:"#444",fontFamily:"Poppins, Arial, sans-serif",fontSize:"16px",fontWeight:"400",lineHeight:"24px"},toggle:{off:{background:"#ccc",hover:"#999"},on:{background:"#1d5c90",hover:"#00304d"}}},h=a.div`
${({theme:e})=>{var o,n,t,l,i;return r`

@@ -134,3 +134,2 @@ background: ${null==e?void 0:e.background};

border-radius: 20px;
box-shadow: rgba(0, 0, 0, 0.5) 1px 1px 3px 0 inset;
height: 24px;

@@ -146,3 +145,2 @@ left: 0;

border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.9) 1px 1px 3px 0;
height: 16px;

@@ -183,3 +181,3 @@ left: 4px;

`,x=({id:o,isChecked:n,label:t,onClick:l})=>e.createElement(b,{className:"zen-cc-toggle "+(n?"checked":"")},e.createElement("input",{checked:n,className:"zen-cc-toggle__checkbox",id:o,onChange:e=>l(),type:"checkbox"}),e.createElement("label",{className:"zen-cc-toggle__label",htmlFor:o},t)),k=a.button`
${({theme:e})=>{var o,n,t,l,i,c,a,d,s,u,p,m,v,f,g,h,b,x;return e.button.customStyles?r`
${({theme:e})=>{var o,n,t,l,i,c,a,d,s,u,p,v,m,f,g,h,b,x;return e.button.customStyles?r`
${e.button.customStyles}

@@ -209,3 +207,3 @@ `:r`

&:hover {
background: ${null===(f=null===(v=null===(m=null==e?void 0:e.button)||void 0===m?void 0:m.solid)||void 0===v?void 0:v.hover)||void 0===f?void 0:f.background};
background: ${null===(f=null===(m=null===(v=null==e?void 0:e.button)||void 0===v?void 0:v.solid)||void 0===m?void 0:m.hover)||void 0===f?void 0:f.background};
color: ${null===(b=null===(h=null===(g=null==e?void 0:e.button)||void 0===g?void 0:g.solid)||void 0===h?void 0:h.hover)||void 0===b?void 0:b.color};

@@ -241,3 +239,3 @@ }

}
`,_=({onClick:o})=>e.createElement(w,{onClick:o},e.createElement("svg",{width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.997.997 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.997.997 0 0 0 1.41 1.41L12 13.41l4.89 4.89a.997.997 0 0 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z",fill:"#002033"})),e.createElement("span",{className:"sr-only"},"Close cookie banner")),C=({content:o})=>{const{acceptAll:n,analytics:t,declineAll:i,defaultCookiePreferences:c,functional:a,marketing:r,setAnalytics:d,setFunctional:s,setMarketing:p,showCookieControl:m,updatePreferences:v}=u();return l((()=>{m&&(d(c.analytics),s(c.functional),p(c.marketing))}),[m]),m?e.createElement(h,{className:"zen-cc-cc","data-nosnippet":!0},e.createElement("h2",{className:"sr-only"},"Cookie control banner"),e.createElement("div",{className:"zen-cc-cc__inner"},e.createElement("div",{className:"zen-cc-cc__close"},e.createElement(_,{onClick:()=>v()})),e.createElement("div",{className:"zen-cc-cc__flex"},e.createElement("div",null,o&&e.createElement("div",{className:"zen-cc-cc__content",dangerouslySetInnerHTML:{__html:o}}),e.createElement("div",{className:"zen-cc-cc__toggles"},e.createElement(x,{id:"cc-marketing",isChecked:r,label:"Marketing",onClick:()=>p((e=>!e))}),e.createElement(x,{id:"cc-functional",isChecked:a,label:"Functional",onClick:()=>s((e=>!e))}),e.createElement(x,{id:"cc-analytics",isChecked:t,label:"Analytics",onClick:()=>d((e=>!e))}))),e.createElement("div",{className:"zen-cc-cc__buttons"},e.createElement("div",{className:"zen-cc-cc__button-wrap"},e.createElement(y,{label:"Accept all",onClick:()=>n(),type:"hollow"})),e.createElement("div",{className:"zen-cc-cc__button-wrap"},e.createElement(y,{label:"Decline all",onClick:()=>i(),type:"hollow"})),e.createElement("div",{className:"zen-cc-cc__button-wrap"},e.createElement(y,{label:"Save preferences",onClick:()=>v()})))))):null},z=a.div`
`,_=({onClick:o})=>e.createElement(w,{onClick:o},e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.997.997 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.997.997 0 0 0 1.41 1.41L12 13.41l4.89 4.89a.997.997 0 0 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z",fill:"#002033"})),e.createElement("span",{className:"sr-only"},"Close cookie banner")),C=({content:o})=>{const{acceptAll:n,analytics:t,declineAll:i,defaultCookiePreferences:c,functional:a,marketing:r,setAnalytics:d,setFunctional:s,setMarketing:p,showCookieControl:v,updatePreferences:m}=u();return l((()=>{v&&(d(c.analytics),s(c.functional),p(c.marketing))}),[v]),v?e.createElement(h,{className:"zen-cc-cc","data-nosnippet":!0},e.createElement("h2",{className:"sr-only"},"Cookie control banner"),e.createElement("div",{className:"zen-cc-cc__inner"},e.createElement("div",{className:"zen-cc-cc__close"},e.createElement(_,{onClick:()=>m()})),e.createElement("div",{className:"zen-cc-cc__flex"},e.createElement("div",null,o&&e.createElement("div",{className:"zen-cc-cc__content",dangerouslySetInnerHTML:{__html:o}}),e.createElement("div",{className:"zen-cc-cc__toggles"},e.createElement(x,{id:"cc-marketing",isChecked:r,label:"Marketing",onClick:()=>p((e=>!e))}),e.createElement(x,{id:"cc-functional",isChecked:a,label:"Functional",onClick:()=>s((e=>!e))}),e.createElement(x,{id:"cc-analytics",isChecked:t,label:"Analytics",onClick:()=>d((e=>!e))}))),e.createElement("div",{className:"zen-cc-cc__buttons"},e.createElement("div",{className:"zen-cc-cc__button-wrap"},e.createElement(y,{label:"Accept all",onClick:()=>n(),type:"hollow"})),e.createElement("div",{className:"zen-cc-cc__button-wrap"},e.createElement(y,{label:"Decline all",onClick:()=>i(),type:"hollow"})),e.createElement("div",{className:"zen-cc-cc__button-wrap"},e.createElement(y,{label:"Save preferences",onClick:()=>m()})))))):null},z=a.div`
${({theme:e})=>{var o,n,t,l,i,c,a,d,s,u;return r`

@@ -333,3 +331,3 @@ .zen-cc-up__modal {

`}}
`,E=({isChecked:o,label:n,onClick:t,summary:l,title:i,cookies:c})=>l||n?e.createElement("div",{className:"zen-cc-up__section"},e.createElement("div",{className:"zen-cc-up__title"},i),l&&e.createElement("div",{className:"zen-cc-up__summary",dangerouslySetInnerHTML:{__html:l}}),n&&t&&e.createElement(x,{id:`cp-${n.toLowerCase().replace(/ /g,"-")}`,isChecked:!!o,label:n,onClick:t}),c):null,$=o=>{var n,t,i,a,r,d,s,p;const{analytics:m,marketing:v,functional:f,setAnalytics:g,setMarketing:h,setFunctional:b,showUpdatePreferences:x,toggleShowUpdatePreferences:k,updatePreferences:w}=u(),C=c(null);return l((()=>{const e=window.getComputedStyle(document.body).overflow,o=e=>C.current&&!C.current.contains(e.target)&&x&&k();return x?(window.scrollTo({top:0,behavior:"smooth"}),document.body.style.overflow="hidden",setTimeout((()=>document.addEventListener("click",o,!1)),100)):document.removeEventListener("click",o,!1),()=>{document.body.style.overflow=e,document.removeEventListener("click",o,!1)}}),[x,k]),x?e.createElement(z,{"data-nosnippet":!0,className:"zen-cc-up "+(x?"open":"closed")},e.createElement("h2",{className:"sr-only"},"Cookie control banner"),e.createElement("div",{className:"zen-cc-up__modal",ref:C},e.createElement("div",{className:"zen-cc-up__inner"},e.createElement("div",{className:"zen-cc-up__close"},e.createElement(_,{onClick:()=>k()})),o.content&&e.createElement("div",{className:"zen-cc-up__section",dangerouslySetInnerHTML:{__html:o.content}}),e.createElement(E,{summary:null===(n=o.necessary)||void 0===n?void 0:n.summary,cookies:null===(t=o.necessary)||void 0===t?void 0:t.cookies,title:"Necessary Cookies"}),e.createElement(E,{isChecked:f,label:"Functional",onClick:()=>b(!f),summary:null===(i=o.functional)||void 0===i?void 0:i.summary,cookies:null===(a=o.functional)||void 0===a?void 0:a.cookies,title:"Functional Cookies"}),e.createElement(E,{isChecked:m,label:"Analytics",onClick:()=>g(!m),summary:null===(r=o.analytics)||void 0===r?void 0:r.summary,cookies:null===(d=o.analytics)||void 0===d?void 0:d.cookies,title:"Analytical Cookies"}),e.createElement(E,{isChecked:v,label:"Marketing",onClick:()=>h(!v),summary:null===(s=o.marketing)||void 0===s?void 0:s.summary,cookies:null===(p=o.marketing)||void 0===p?void 0:p.cookies,title:"Marketing Cookies"}),e.createElement("div",{className:"zen-cc-up__save"},e.createElement(y,{label:"Save Preferences",onClick:()=>{w(),k()}}))))):null},N=({cookieControl:o,defaultCookiePreferences:n,updatePreferences:c,theme:a})=>r=>u=>{var p=
`,E=({isChecked:o,label:n,onClick:t,summary:l,title:i,cookies:c})=>n?e.createElement("div",{className:"zen-cc-up__section"},e.createElement("div",{className:"zen-cc-up__title"},i),t&&e.createElement(x,{id:`cp-${n.toLowerCase().replace(/ /g,"-")}`,isChecked:!!o,label:n,onClick:t}),l&&e.createElement("div",{className:"zen-cc-up__summary",dangerouslySetInnerHTML:{__html:l}}),c):null,$=o=>{var n,t,i,a,r,d,s,p;const{analytics:v,marketing:m,functional:f,setAnalytics:g,setMarketing:h,setFunctional:b,showUpdatePreferences:x,toggleShowUpdatePreferences:k,updatePreferences:w}=u(),C=c(null);return l((()=>{const e=window.getComputedStyle(document.body).overflow,o=e=>C.current&&!C.current.contains(e.target)&&x&&k();return x?(window.scrollTo({top:0,behavior:"smooth"}),document.body.style.overflow="hidden",setTimeout((()=>document.addEventListener("click",o,!1)),100)):document.removeEventListener("click",o,!1),()=>{document.body.style.overflow=e,document.removeEventListener("click",o,!1)}}),[x,k]),x?e.createElement(z,{"data-nosnippet":!0,className:"zen-cc-up "+(x?"open":"closed")},e.createElement("h2",{className:"sr-only"},"Cookie control banner"),e.createElement("div",{className:"zen-cc-up__modal",ref:C},e.createElement("div",{className:"zen-cc-up__inner"},e.createElement("div",{className:"zen-cc-up__close"},e.createElement(_,{onClick:()=>k()})),o.content&&e.createElement("div",{className:"zen-cc-up__section",dangerouslySetInnerHTML:{__html:o.content}}),e.createElement(E,{isChecked:!0,label:"Necessary",summary:null===(n=o.necessary)||void 0===n?void 0:n.summary,cookies:null===(t=o.necessary)||void 0===t?void 0:t.cookies,title:"Necessary Cookies"}),e.createElement(E,{isChecked:f,label:"Functional",onClick:()=>b(!f),summary:null===(i=o.functional)||void 0===i?void 0:i.summary,cookies:null===(a=o.functional)||void 0===a?void 0:a.cookies,title:"Functional Cookies"}),e.createElement(E,{isChecked:v,label:"Analytics",onClick:()=>g(!v),summary:null===(r=o.analytics)||void 0===r?void 0:r.summary,cookies:null===(d=o.analytics)||void 0===d?void 0:d.cookies,title:"Analytical Cookies"}),e.createElement(E,{isChecked:m,label:"Marketing",onClick:()=>h(!m),summary:null===(s=o.marketing)||void 0===s?void 0:s.summary,cookies:null===(p=o.marketing)||void 0===p?void 0:p.cookies,title:"Marketing Cookies"}),e.createElement("div",{className:"zen-cc-up__save"},e.createElement(y,{label:"Save Preferences",onClick:()=>{w(),k()}}))))):null},N=({cookieControl:o,defaultCookiePreferences:n,updatePreferences:c,theme:a})=>r=>u=>{var p=
/*! *****************************************************************************

@@ -349,3 +347,3 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
function(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(t=Object.getOwnPropertySymbols(e);l<t.length;l++)o.indexOf(t[l])<0&&Object.prototype.propertyIsEnumerable.call(e,t[l])&&(n[t[l]]=e[t[l]])}return n}(u,[]);const[m,h]=t(!1),[b,x]=t(!1),[k,y]=t(!1),[w,_]=t(!1),[z,E]=t(!1),[N,P]=t([]);l((()=>{const e=v("zen-cc");if(e){const{analytics:o,functional:n,marketing:t}=JSON.parse(e);h(!!o),x(!!n),y(!!t)}else _(!0)}),[]),l((()=>{if("undefined"!=typeof window&&2===N.length){const e=N[0],o=N[1];N&&Object.keys(e).some((n=>e[n]&&!o[n]))&&window.location.reload(),P((e=>[...e.slice(1)]))}}),[N]);const S=i((()=>({analytics:m,defaultCookiePreferences:n,marketing:k,functional:b,set:({analytics:e,functional:o,marketing:n})=>{h(e),x(o),y(n),_(!1),f("zen-cc",JSON.stringify({analytics:e,functional:o,marketing:n}),90),P((t=>[...t,{analytics:e,functional:o,marketing:n}]))},showCookieControl:w,showUpdatePreferences:z,toggleShowUpdatePreferences:()=>E((e=>!e))})),[m,b,k,w,z]);return e.createElement(s.Provider,{value:S},e.createElement(d,{theme:Object.assign(Object.assign({},g),a)},e.createElement(C,Object.assign({},o)),e.createElement($,Object.assign({},c))),e.createElement(r,Object.assign({},p)))};export{m as ToggleUpdatePreferences,v as getCookieValue,f as setCookieValue,u as useCookieControl,N as withCookieProvider};
function(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(t=Object.getOwnPropertySymbols(e);l<t.length;l++)o.indexOf(t[l])<0&&Object.prototype.propertyIsEnumerable.call(e,t[l])&&(n[t[l]]=e[t[l]])}return n}(u,[]);const[v,h]=t(!1),[b,x]=t(!1),[k,y]=t(!1),[w,_]=t(!1),[z,E]=t(!1),[N,P]=t([]);l((()=>{const e=m("zen-cc");if(e){const{analytics:o,functional:n,marketing:t}=JSON.parse(e);h(!!o),x(!!n),y(!!t)}else _(!0)}),[]),l((()=>{if("undefined"!=typeof window&&2===N.length){const e=N[0],o=N[1];N&&Object.keys(e).some((n=>e[n]&&!o[n]))&&window.location.reload(),P((e=>[...e.slice(1)]))}}),[N]);const S=i((()=>({analytics:v,defaultCookiePreferences:n,marketing:k,functional:b,set:({analytics:e,functional:o,marketing:n})=>{h(e),x(o),y(n),_(!1),f("zen-cc",JSON.stringify({analytics:e,functional:o,marketing:n}),90),P((t=>[...t,{analytics:e,functional:o,marketing:n}]))},showCookieControl:w,showUpdatePreferences:z,toggleShowUpdatePreferences:()=>E((e=>!e))})),[v,b,k,w,z]);return e.createElement(s.Provider,{value:S},e.createElement(d,{theme:Object.assign(Object.assign({},g),a)},e.createElement(C,Object.assign({},o)),e.createElement($,Object.assign({},c))),e.createElement(r,Object.assign({},p)))};export{v as ToggleUpdatePreferences,m as getCookieValue,f as setCookieValue,u as useCookieControl,N as withCookieProvider};
//# sourceMappingURL=index.js.map
{
"name": "zengenti-react-cookie-control",
"version": "1.0.5",
"version": "1.0.6",
"description": "A react cookie control",

@@ -5,0 +5,0 @@ "repository": "https://github.com/zengenti/zengenti-react-cookie-control",

@@ -37,3 +37,2 @@ import styled, { css } from 'styled-components';

border-radius: 20px;
box-shadow: rgba(0, 0, 0, 0.5) 1px 1px 3px 0 inset;
height: 24px;

@@ -49,3 +48,2 @@ left: 0;

border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.9) 1px 1px 3px 0;
height: 16px;

@@ -52,0 +50,0 @@ left: 4px;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc