umwd-components 0.1.574 → 0.1.576
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.
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as o}from"../../../../node_modules/tslib/tslib.es6.js";import e,{useState as
|
|
7
|
+
import{__read as o}from"../../../../node_modules/tslib/tslib.es6.js";import e,{useState as n,useEffect as t,createContext as i,useContext as r}from"react";import{getCookie as s}from"../../../lib/getCookie.js";import{setCookie as c}from"../../../lib/setCookie.js";import{deleteCookie as u}from"../../../lib/deleteCookie.js";var l=i(void 0),m=function(){var o=r(l);if(!o)throw new Error("useCookieConsent must be used within a CookieConsentProvider");return o},f=function(i){var r=i.children,m=o(n(null),2),f=m[0],C=m[1];t((function(){"true"===s("cookieConsent")&&C(!0)}),[]);return e.createElement(l.Provider,{value:{consentGiven:f,giveConsent:function(){c("cookieConsent","true",365),C(!0)},declineConsent:function(){u("cookieConsent"),document.cookie.split(";").forEach((function(o){var e=o.trim().split("=")[0];u(e)})),C(!1)},resetConsent:function(){u("cookieConsent"),C(null)}}},r)};export{f as CookieConsentProvider,m as useCookieConsent};
|