@consent-manager/core
Advanced tools
Comparing version 0.0.1-next.3 to 0.0.1-next.4
# @consent-manager/core | ||
## 0.0.1-next.4 | ||
### Patch Changes | ||
- Introduce Algolia integration and fix rerendering bugs | ||
## 0.0.1-next.3 | ||
@@ -4,0 +10,0 @@ |
@@ -228,9 +228,4 @@ 'use strict'; | ||
return setIsMounted(true); | ||
}, [setIsMounted]); // Do not render the interface on SSR. | ||
if (!isMounted) { | ||
return React__default.createElement(React__default.Fragment, null, children); | ||
} | ||
return React__default.createElement(Wrapper, null, children); | ||
}, [setIsMounted]); | ||
return React__default.createElement(React__default.Fragment, null, children, isMounted && React__default.createElement(Wrapper, null, null)); | ||
}; | ||
@@ -237,0 +232,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),r=e(require("react-use/esm/useSet")),o=require("wcag-contrast");function i(){return(i=Object.assign||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;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){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.")}return(t=e[Symbol.iterator]()).next.bind(t)}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=d().decisions,t=n.useState(e),r=t[0],o=t[1],a=f()[1];n.useEffect((function(){r!==e&&o((function(){return e}))}),[e,r,o,a]);var u=n.useCallback((function(e){var n="function"==typeof e?e(r):e;a((function(e){return i({},e,{decisions:n})}))}),[r,a]);return[r,u]}var p=function(e){var r,o,i=e.children,a=(r=e.config,o=m()[0],n.useMemo((function(){return function(e){var n=e.children;return r.integrations.filter((function(e){return!0===o[e.id]})).filter((function(e){return Boolean(e.WrapperComponent)})).reverse().reduce((function(e,n){return t.createElement(n.WrapperComponent,null,e)}),n)}}),[r.integrations,o])),u=n.useState(!1),l=u[0],c=u[1];return n.useEffect((function(){return c(!0)}),[c]),t.createElement(l?a:t.Fragment,null,i)},g=function(e){var r=e.integrationId,o=e.fallbackUrl,i=a(e,["integrationId","fallbackUrl"]),u=b(r),l=h(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 v(){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 b(e){return s().find((function(n){return n.id===e}))}var y=function(e){var o=e.integrations,i=e.onSubmit,a=r(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"))};function h(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 E(){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?g:r,config:n,store:e.store}},t.createElement(p,{config:n},e.children))},exports.ConsentManagerForm=function(e){var r=e.formComponent,o=a(e,["formComponent"]),i=v(),u=i[0],l=i[1],f=n.useContext(c).config.integrations,s=r||y,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,["id","children"]),i=h(n)[0],u=E();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,["color"]);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=h,exports.useEnabledIntegrations=v,exports.useFallbackComponent=E,exports.useIntegration=b,exports.useIntegrations=s,exports.usePageViewEventTrigger=function(e){var t=h(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";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),r=e(require("react-use/esm/useSet")),o=require("wcag-contrast");function i(){return(i=Object.assign||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;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){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.")}return(t=e[Symbol.iterator]()).next.bind(t)}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=d().decisions,t=n.useState(e),r=t[0],o=t[1],a=f()[1];n.useEffect((function(){r!==e&&o((function(){return e}))}),[e,r,o,a]);var u=n.useCallback((function(e){var n="function"==typeof e?e(r):e;a((function(e){return i({},e,{decisions:n})}))}),[r,a]);return[r,u]}var p=function(e){var r,o,i=e.children,a=(r=e.config,o=m()[0],n.useMemo((function(){return function(e){var n=e.children;return r.integrations.filter((function(e){return!0===o[e.id]})).filter((function(e){return Boolean(e.WrapperComponent)})).reverse().reduce((function(e,n){return t.createElement(n.WrapperComponent,null,e)}),n)}}),[r.integrations,o])),u=n.useState(!1),l=u[0],c=u[1];return n.useEffect((function(){return c(!0)}),[c]),t.createElement(t.Fragment,null,i,l&&t.createElement(a,null,null))},g=function(e){var r=e.integrationId,o=e.fallbackUrl,i=a(e,["integrationId","fallbackUrl"]),u=b(r),l=h(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 v(){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 b(e){return s().find((function(n){return n.id===e}))}var y=function(e){var o=e.integrations,i=e.onSubmit,a=r(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"))};function h(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 E(){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?g:r,config:n,store:e.store}},t.createElement(p,{config:n},e.children))},exports.ConsentManagerForm=function(e){var r=e.formComponent,o=a(e,["formComponent"]),i=v(),u=i[0],l=i[1],f=n.useContext(c).config.integrations,s=r||y,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,["id","children"]),i=h(n)[0],u=E();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,["color"]);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=h,exports.useEnabledIntegrations=v,exports.useFallbackComponent=E,exports.useIntegration=b,exports.useIntegrations=s,exports.usePageViewEventTrigger=function(e){var t=h(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 |
@@ -221,9 +221,4 @@ import React, { useContext, createContext, useState, useEffect, useCallback, useMemo } from 'react'; | ||
return setIsMounted(true); | ||
}, [setIsMounted]); // Do not render the interface on SSR. | ||
if (!isMounted) { | ||
return React.createElement(React.Fragment, null, children); | ||
} | ||
return React.createElement(Wrapper, null, children); | ||
}, [setIsMounted]); | ||
return React.createElement(React.Fragment, null, children, isMounted && React.createElement(Wrapper, null, null)); | ||
}; | ||
@@ -230,0 +225,0 @@ |
{ | ||
"name": "@consent-manager/core", | ||
"version": "0.0.1-next.3", | ||
"version": "0.0.1-next.4", | ||
"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
124443
23
1027