@consent-manager/core
Advanced tools
Comparing version 2.0.0-next.2 to 2.0.0-next.3
@@ -418,6 +418,12 @@ 'use strict'; | ||
props = _objectWithoutPropertiesLoose(_ref2, _excluded$3); | ||
var _useState = React.useState(true), | ||
isSSR = _useState[0], | ||
setIsSSR = _useState[1]; | ||
var _useDecision = useDecision(id), | ||
decision = _useDecision[0]; | ||
var DefaultFallbackComponent = useFallbackComponent(); | ||
if (decision) { | ||
React.useEffect(function () { | ||
return setIsSSR(false); | ||
}); | ||
if (!isSSR && decision) { | ||
return React__default.createElement(React__default.Fragment, null, children); | ||
@@ -424,0 +430,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-use"),o=require("wcag-contrast");function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function l(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return u(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c=n.createContext({fallbackComponent:function(){return null},config:{integrations:[]},store:[{decisions:{}},function(){}]});function f(){return n.useContext(c).store}function s(){return n.useContext(c).config.integrations}function d(){var e=f(),t=s();return n.useMemo((function(){return function(e,n){for(var t,r,o=n[0],i=null!=(t=null==o?void 0:o.decisions)?t:{},a={},u=[],c=l(e);!(r=c()).done;){var f=r.value,s=i[f.id],d=s||void 0===s&&f.enabledByDefault;void 0===d&&u.push(f.id),a[f.id]=Boolean(d)}return{decisions:a,pending:u}}(t,e)}),[t,e])}function m(){var e=n.useContext(c).config.onChangeDecision,t=d().decisions,r=n.useState(t),o=r[0],a=r[1],u=f()[1];n.useEffect((function(){o!==t&&a((function(){return t}))}),[t,o,a,u]);var l=n.useCallback((function(n){var t="function"==typeof n?n(o):n;e&&e(o,t),u((function(e){return i({},e,{decisions:t})}))}),[o,e,u]);return[o,l]}var p=function(e){var r=e.config,o=e.children,i=m()[0],a=n.useState(!1),u=a[0],l=a[1];n.useEffect((function(){return l(!0)}),[l]);var c=n.useMemo((function(){return u?r.integrations.filter((function(e){return!0===i[e.id]})).filter((function(e){return Boolean(e.WrapperComponent)})).map((function(e){return t.createElement(e.WrapperComponent,{key:e.id})})):null}),[r,i,u]);return t.createElement(t.Fragment,null,o,c)},g=["integrationId","fallbackUrl"],v=function(e){var r=e.integrationId,o=e.fallbackUrl,i=a(e,g),u=y(r),l=k(r)[1],c=n.useCallback((function(){l(!0)}),[l]);if(!u)throw new Error('No integration found for "'+r+'"');var f=u.title,s=u.privacyPolicyUrl,d=u.Icon,m=u.description,p=u.color;return t.createElement("section",Object.assign({style:{backgroundColor:"#ddd",padding:"1rem 2rem",border:"4px solid #222"}},i),t.createElement("h1",{style:{display:"flex",alignItems:"center"}},d&&t.createElement(d,{"aria-hidden":"true",color:p,style:{width:"2rem",marginRight:"1rem"}}),f),m&&t.createElement("p",null,m),s&&t.createElement("p",null,t.createElement("a",{href:s,target:"_blank",rel:"noreferrer"},"Privacy policy of ",f)),t.createElement("button",{onClick:function(){return c()},style:{display:"block",margin:"0 auto"}},"Enable ",u.title),o&&t.createElement("p",null,"Alternative:",t.createElement("br",null),"Visit"," ",t.createElement("a",{href:o,target:"_blank",rel:"noreferrer"},o)))};function b(){var e=s(),t=m(),r=t[0],o=t[1],i=n.useMemo((function(){return e.filter((function(e){return Boolean(r[e.id])})).map((function(e){return e.id}))}),[e,r]),a=n.useCallback((function(n){for(var t,r="function"==typeof n?n(i):n,a={},u=l(e);!(t=u()).done;){var c=t.value,f=r.includes(c.id);a[c.id]=f}o(a)}),[i,e,o]);return[i,a]}function y(e){return s().find((function(n){return n.id===e}))}var h=function(e){var o=e.integrations,i=e.onSubmit,a=r.useSet(new Set(e.initialValues.enabled)),u=a[0],l=a[1],c=l.toggle,f=l.has,s=n.useCallback((function(e){c(e.target.value)}),[c]),d=n.useCallback((function(e){e.preventDefault();var n=Array.from(u.values());i({enabled:n})}),[u,i]);return t.createElement("form",{onSubmit:d},o.map((function(e){var n=e.id,r=e.title;return t.createElement("label",{key:n},t.createElement("input",{name:"enabled",type:"checkbox",value:n,onChange:s,checked:f(n)})," ",r)})),t.createElement("button",{type:"submit"},"Submit"))},C=["formComponent"],E=["color"],x=["id","children"];function k(e){var n,t=m(),r=t[1],o=null!=(n=t[0][e])&&n;return[o,function(n){var t="function"==typeof n?n(o):n;r((function(n){var r;return i({},n,((r={})[e]=t,r))}))}]}function w(){return n.useContext(c).fallbackComponent||function(){return null}}exports.ConsentManager=function(e){var n=e.config,r=e.fallbackComponent;return t.createElement(c.Provider,{value:{fallbackComponent:void 0===r?v:r,config:n,store:e.store}},t.createElement(p,{config:n},e.children))},exports.ConsentManagerForm=function(e){var r=e.formComponent,o=a(e,C),i=b(),u=i[0],l=i[1],f=n.useContext(c).config.integrations,s=r||h,d=n.useCallback((function(e){l((function(){return e.enabled}))}),[l]);return t.createElement(s,Object.assign({integrations:f,initialValues:{enabled:u},onSubmit:d},o))},exports.PrivacyShield=function(e){var n=e.id,r=e.children,o=a(e,x),i=k(n)[0],u=w();return i?t.createElement(t.Fragment,null,r):t.createElement(u,Object.assign({integrationId:n},o))},exports.createIconComponentFromSimpleIconsSvgPath=function(e,n){return function(r){var o=r.color,i=void 0===o?"currentColor":o,u=a(r,E);return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:i,viewBox:"0 0 24 24",height:"100%",width:"100%"},u),t.createElement("title",null,e),t.createElement("path",{d:n}))}},exports.getForegroundColor=function(e){return o.hex(e,"#000")>=7?"#000":"#fff"},exports.useConsentFormVisible=function(){return 0!==(e=d().pending,null!=e?e:[]).length;var e},exports.useDecision=k,exports.useDecisions=m,exports.useEnabledIntegrations=b,exports.useFallbackComponent=w,exports.useIntegration=y,exports.useIntegrations=s,exports.usePageViewEventTrigger=function(e){var t=k(e)[0],r=n.useContext(c).config.integrations.find((function(n){return n.id===e}));return t&&r&&"function"==typeof r.pageViewEventHandler?r.pageViewEventHandler:function(){}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-use"),o=require("wcag-contrast");function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function l(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return u(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c=n.createContext({fallbackComponent:function(){return null},config:{integrations:[]},store:[{decisions:{}},function(){}]});function f(){return n.useContext(c).store}function s(){return n.useContext(c).config.integrations}function d(){var e=f(),t=s();return n.useMemo((function(){return function(e,n){for(var t,r,o=n[0],i=null!=(t=null==o?void 0:o.decisions)?t:{},a={},u=[],c=l(e);!(r=c()).done;){var f=r.value,s=i[f.id],d=s||void 0===s&&f.enabledByDefault;void 0===d&&u.push(f.id),a[f.id]=Boolean(d)}return{decisions:a,pending:u}}(t,e)}),[t,e])}function m(){var e=n.useContext(c).config.onChangeDecision,t=d().decisions,r=n.useState(t),o=r[0],a=r[1],u=f()[1];n.useEffect((function(){o!==t&&a((function(){return t}))}),[t,o,a,u]);var l=n.useCallback((function(n){var t="function"==typeof n?n(o):n;e&&e(o,t),u((function(e){return i({},e,{decisions:t})}))}),[o,e,u]);return[o,l]}var p=function(e){var r=e.config,o=e.children,i=m()[0],a=n.useState(!1),u=a[0],l=a[1];n.useEffect((function(){return l(!0)}),[l]);var c=n.useMemo((function(){return u?r.integrations.filter((function(e){return!0===i[e.id]})).filter((function(e){return Boolean(e.WrapperComponent)})).map((function(e){return t.createElement(e.WrapperComponent,{key:e.id})})):null}),[r,i,u]);return t.createElement(t.Fragment,null,o,c)},g=["integrationId","fallbackUrl"],v=function(e){var r=e.integrationId,o=e.fallbackUrl,i=a(e,g),u=y(r),l=k(r)[1],c=n.useCallback((function(){l(!0)}),[l]);if(!u)throw new Error('No integration found for "'+r+'"');var f=u.title,s=u.privacyPolicyUrl,d=u.Icon,m=u.description,p=u.color;return t.createElement("section",Object.assign({style:{backgroundColor:"#ddd",padding:"1rem 2rem",border:"4px solid #222"}},i),t.createElement("h1",{style:{display:"flex",alignItems:"center"}},d&&t.createElement(d,{"aria-hidden":"true",color:p,style:{width:"2rem",marginRight:"1rem"}}),f),m&&t.createElement("p",null,m),s&&t.createElement("p",null,t.createElement("a",{href:s,target:"_blank",rel:"noreferrer"},"Privacy policy of ",f)),t.createElement("button",{onClick:function(){return c()},style:{display:"block",margin:"0 auto"}},"Enable ",u.title),o&&t.createElement("p",null,"Alternative:",t.createElement("br",null),"Visit"," ",t.createElement("a",{href:o,target:"_blank",rel:"noreferrer"},o)))};function b(){var e=s(),t=m(),r=t[0],o=t[1],i=n.useMemo((function(){return e.filter((function(e){return Boolean(r[e.id])})).map((function(e){return e.id}))}),[e,r]),a=n.useCallback((function(n){for(var t,r="function"==typeof n?n(i):n,a={},u=l(e);!(t=u()).done;){var c=t.value,f=r.includes(c.id);a[c.id]=f}o(a)}),[i,e,o]);return[i,a]}function y(e){return s().find((function(n){return n.id===e}))}var h=function(e){var o=e.integrations,i=e.onSubmit,a=r.useSet(new Set(e.initialValues.enabled)),u=a[0],l=a[1],c=l.toggle,f=l.has,s=n.useCallback((function(e){c(e.target.value)}),[c]),d=n.useCallback((function(e){e.preventDefault();var n=Array.from(u.values());i({enabled:n})}),[u,i]);return t.createElement("form",{onSubmit:d},o.map((function(e){var n=e.id,r=e.title;return t.createElement("label",{key:n},t.createElement("input",{name:"enabled",type:"checkbox",value:n,onChange:s,checked:f(n)})," ",r)})),t.createElement("button",{type:"submit"},"Submit"))},E=["formComponent"],C=["color"],x=["id","children"];function k(e){var n,t=m(),r=t[1],o=null!=(n=t[0][e])&&n;return[o,function(n){var t="function"==typeof n?n(o):n;r((function(n){var r;return i({},n,((r={})[e]=t,r))}))}]}function w(){return n.useContext(c).fallbackComponent||function(){return null}}exports.ConsentManager=function(e){var n=e.config,r=e.fallbackComponent;return t.createElement(c.Provider,{value:{fallbackComponent:void 0===r?v:r,config:n,store:e.store}},t.createElement(p,{config:n},e.children))},exports.ConsentManagerForm=function(e){var r=e.formComponent,o=a(e,E),i=b(),u=i[0],l=i[1],f=n.useContext(c).config.integrations,s=r||h,d=n.useCallback((function(e){l((function(){return e.enabled}))}),[l]);return t.createElement(s,Object.assign({integrations:f,initialValues:{enabled:u},onSubmit:d},o))},exports.PrivacyShield=function(e){var r=e.id,o=e.children,i=a(e,x),u=n.useState(!0),l=u[0],c=u[1],f=k(r)[0],s=w();return n.useEffect((function(){return c(!1)})),!l&&f?t.createElement(t.Fragment,null,o):t.createElement(s,Object.assign({integrationId:r},i))},exports.createIconComponentFromSimpleIconsSvgPath=function(e,n){return function(r){var o=r.color,i=void 0===o?"currentColor":o,u=a(r,C);return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:i,viewBox:"0 0 24 24",height:"100%",width:"100%"},u),t.createElement("title",null,e),t.createElement("path",{d:n}))}},exports.getForegroundColor=function(e){return o.hex(e,"#000")>=7?"#000":"#fff"},exports.useConsentFormVisible=function(){return 0!==(e=d().pending,null!=e?e:[]).length;var e},exports.useDecision=k,exports.useDecisions=m,exports.useEnabledIntegrations=b,exports.useFallbackComponent=w,exports.useIntegration=y,exports.useIntegrations=s,exports.usePageViewEventTrigger=function(e){var t=k(e)[0],r=n.useContext(c).config.integrations.find((function(n){return n.id===e}));return t&&r&&"function"==typeof r.pageViewEventHandler?r.pageViewEventHandler:function(){}}; | ||
//# sourceMappingURL=core.cjs.production.min.js.map |
@@ -411,6 +411,12 @@ import React, { useContext, createContext, useState, useEffect, useCallback, useMemo } from 'react'; | ||
props = _objectWithoutPropertiesLoose(_ref2, _excluded$3); | ||
var _useState = useState(true), | ||
isSSR = _useState[0], | ||
setIsSSR = _useState[1]; | ||
var _useDecision = useDecision(id), | ||
decision = _useDecision[0]; | ||
var DefaultFallbackComponent = useFallbackComponent(); | ||
if (decision) { | ||
useEffect(function () { | ||
return setIsSSR(false); | ||
}); | ||
if (!isSSR && decision) { | ||
return React.createElement(React.Fragment, null, children); | ||
@@ -417,0 +423,0 @@ } |
{ | ||
"name": "@consent-manager/core", | ||
"version": "2.0.0-next.2", | ||
"version": "2.0.0-next.3", | ||
"description": "Get proper consent before tracking and processing data of your visitors via consent-manager. Supports you to get your website GDPR and CCPA compliant.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130198
1055