From d8993bead28fbacf363fa801b3ae2d903f2e5b49 Mon Sep 17 00:00:00 2001 From: Mastermindzh Date: Sat, 18 Jun 2022 14:30:02 +0200 Subject: [PATCH] release 7.5.0 --- build/index.d.ts | 1 + build/index.js | 2 +- example | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build/index.d.ts b/build/index.d.ts index 4f3fcb8..f493a8f 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -48,6 +48,7 @@ export interface CookieConsentProps { customContentAttributes?: object; customContainerAttributes?: object; customButtonProps?: object; + customDeclineButtonProps?: object; } export default class CookieConsent extends React.Component {} diff --git a/build/index.js b/build/index.js index 0d63e83..78089e7 100644 --- a/build/index.js +++ b/build/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactCookieConsent=t():e.ReactCookieConsent=t()}("undefined"!=typeof self?self:this,(function(){return function(){var e={808:function(e,t,n){var o,r,i;void 0===(r="function"==typeof(o=i=function(){function e(){for(var e=0,t={};e0&&void 0!==arguments[0]?arguments[0]:j,t=l().get(e);return void 0===t?l().get(x(e)):t},k=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:j;l().remove(e)},x=function(e){return"".concat(e,"-legacy")},j="CookieConsent",w=function(e){var t=e.condition,n=e.wrapper,o=e.children;return t?n(o):o},B=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}(s,e);var n,o,r,i,c=(r=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=O(r);if(i){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return d(this,e)});function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),m(v(t=c.call(this,e)),"handleScroll",(function(){var e=t.props.acceptOnScrollPercentage,n=document.documentElement,o=document.body,r="scrollTop",i="scrollHeight";(n[r]||o[r])/((n[i]||o[i])-n.clientHeight)*100>e&&t.accept(!0)})),m(v(t),"removeScrollListener",(function(){t.props.acceptOnScroll&&window.removeEventListener("scroll",t.handleScroll)})),t.state={visible:!1,style:{alignItems:"baseline",background:"#353535",color:"white",display:"flex",flexWrap:"wrap",justifyContent:"space-between",left:"0",position:"fixed",width:"100%",zIndex:"999"},buttonStyle:{background:"#ffd42d",border:"0",borderRadius:"0px",boxShadow:"none",color:"black",cursor:"pointer",flex:"0 0 auto",padding:"5px 10px",margin:"15px"},declineButtonStyle:{background:"#c12a2a",border:"0",borderRadius:"0px",boxShadow:"none",color:"#e5e5e5",cursor:"pointer",flex:"0 0 auto",padding:"5px 10px",margin:"15px"},contentStyle:{flex:"1 0 300px",margin:"15px"},overlayStyle:{position:"fixed",left:0,top:0,width:"100%",height:"100%",zIndex:"999",backgroundColor:"rgba(0,0,0,0.3)"}},t}return n=s,(o=[{key:"componentDidMount",value:function(){var e=this.props.debug;(void 0===this.getCookieValue()||e)&&(this.setState({visible:!0}),this.props.acceptOnScroll&&window.addEventListener("scroll",this.handleScroll,{passive:!0}))}},{key:"componentWillUnmount",value:function(){this.removeScrollListener()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.props,n=t.cookieName,o=t.cookieValue,r=t.hideOnAccept,i=t.onAccept;this.setCookie(n,o),i(null!=e&&e),r&&(this.setState({visible:!1}),this.removeScrollListener())}},{key:"overlayClick",value:function(){var e=this.props,t=e.acceptOnOverlayClick,n=e.onOverlayClick;t&&this.accept(),n()}},{key:"decline",value:function(){var e=this.props,t=e.cookieName,n=e.declineCookieValue,o=e.hideOnDecline,r=e.onDecline;e.setDeclineCookie&&this.setCookie(t,n),r(),o&&this.setState({visible:!1})}},{key:"setCookie",value:function(e,t){var n=this.props,o=n.extraCookieOptions,r=n.expires,i=n.sameSite,c=this.props.cookieSecurity;void 0===c&&(c=!location||"https:"===location.protocol);var s=f(f({expires:r},o),{},{sameSite:i,secure:c});i===C.NONE&&l().set(x(e),t,s),l().set(e,t,s)}},{key:"getCookieValue",value:function(){var e=this.props.cookieName;return S(e)}},{key:"render",value:function(){var e=this;switch(this.props.visible){case g.HIDDEN:return null;case g.BY_COOKIE_VALUE:if(!this.state.visible)return null}var n=this.props,o=n.location,r=n.style,i=n.buttonStyle,c=n.declineButtonStyle,l=n.contentStyle,s=n.disableStyles,a=n.buttonText,p=n.declineButtonText,b=n.containerClasses,y=n.contentClasses,d=n.buttonClasses,v=n.buttonWrapperClasses,O=n.declineButtonClasses,m=n.buttonId,C=n.declineButtonId,S=n.disableButtonStyles,k=n.enableDeclineButton,x=n.flipButtons,j=n.ButtonComponent,B=n.overlay,T=n.overlayClasses,P=n.overlayStyle,E=n.ariaAcceptLabel,D=n.ariaDeclineLabel,I=n.customContainerAttributes,_=n.customContentAttributes,A=n.customButtonProps,N={},R={},L={},V={},U={};switch(s?(N=u({},r),R=u({},i),L=u({},c),V=u({},l),U=u({},P)):(N=u({},f(f({},this.state.style),r)),V=u({},f(f({},this.state.contentStyle),l)),U=u({},f(f({},this.state.overlayStyle),P)),S?(R=u({},i),L=u({},c)):(R=u({},f(f({},this.state.buttonStyle),i)),L=u({},f(f({},this.state.declineButtonStyle),c)))),o){case h.TOP:N.top="0";break;case h.BOTTOM:N.bottom="0"}var W=[];return k&&W.push(t().createElement(j,{key:"declineButton",style:L,className:O,id:C,"aria-label":D,onClick:function(){e.decline()}},p)),W.push(t().createElement(j,u({},A,{key:"acceptButton",style:R,className:d,id:m,"aria-label":E,onClick:function(){e.accept()}}),a)),x&&W.reverse(),t().createElement(w,{condition:B,wrapper:function(n){return t().createElement("div",{style:U,className:T,onClick:function(){e.overlayClick()}},n)}},t().createElement("div",u({className:"".concat(b),style:N},I),t().createElement("div",u({style:V,className:y},_),this.props.children),t().createElement("div",{className:"".concat(v)},W.map((function(e){return e})))))}}])&&b(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),s}(e.Component);B.propTypes={location:i().oneOf(Object.keys(h).map((function(e){return h[e]}))),visible:i().oneOf(Object.keys(g).map((function(e){return g[e]}))),sameSite:i().oneOf(Object.keys(C).map((function(e){return C[e]}))),style:i().object,buttonStyle:i().object,declineButtonStyle:i().object,contentStyle:i().object,children:i().any,disableStyles:i().bool,hideOnAccept:i().bool,hideOnDecline:i().bool,onAccept:i().func,onDecline:i().func,buttonText:i().oneOfType([i().string,i().func,i().element]),declineButtonText:i().oneOfType([i().string,i().func,i().element]),cookieName:i().string,cookieValue:i().oneOfType([i().string,i().bool,i().number]),declineCookieValue:i().oneOfType([i().string,i().bool,i().number]),setDeclineCookie:i().bool,debug:i().bool,expires:i().number,containerClasses:i().string,contentClasses:i().string,buttonClasses:i().string,buttonWrapperClasses:i().string,declineButtonClasses:i().string,buttonId:i().string,declineButtonId:i().string,extraCookieOptions:i().object,disableButtonStyles:i().bool,enableDeclineButton:i().bool,flipButtons:i().bool,ButtonComponent:i().elementType,cookieSecurity:i().bool,overlay:i().bool,overlayClasses:i().string,overlayStyle:i().object,onOverlayClick:i().func,acceptOnOverlayClick:i().bool,ariaAcceptLabel:i().string,ariaDeclineLabel:i().string,acceptOnScroll:i().bool,acceptOnScrollPercentage:i().number,customContentAttributes:i().object,customContainerAttributes:i().object,customButtonProps:i().object},B.defaultProps={disableStyles:!1,hideOnAccept:!0,hideOnDecline:!0,location:h.BOTTOM,visible:g.BY_COOKIE_VALUE,onAccept:function(){},onDecline:function(){},cookieName:j,cookieValue:!0,declineCookieValue:!1,setDeclineCookie:!0,buttonText:"I understand",declineButtonText:"I decline",debug:!1,expires:365,containerClasses:"CookieConsent",contentClasses:"",buttonClasses:"",buttonWrapperClasses:"",declineButtonClasses:"",buttonId:"rcc-confirm-button",declineButtonId:"rcc-decline-button",extraCookieOptions:{},disableButtonStyles:!1,enableDeclineButton:!1,flipButtons:!1,sameSite:C.LAX,ButtonComponent:function(e){var n=e.children,o=function(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(e,a);return t().createElement("button",o,n)},overlay:!1,overlayClasses:"",onOverlayClick:function(){},acceptOnOverlayClick:!1,ariaAcceptLabel:"Accept cookies",ariaDeclineLabel:"Decline cookies",acceptOnScroll:!1,acceptOnScrollPercentage:25,customContentAttributes:{},customContainerAttributes:{},customButtonProps:{}};const T=B}(),o}()})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactCookieConsent=t():e.ReactCookieConsent=t()}("undefined"!=typeof self?self:this,(function(){return function(){var e={808:function(e,t,n){var o,r,i;void 0===(r="function"==typeof(o=i=function(){function e(){for(var e=0,t={};e0&&void 0!==arguments[0]?arguments[0]:j,t=l().get(e);return void 0===t?l().get(x(e)):t},k=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:j;l().remove(e)},x=function(e){return"".concat(e,"-legacy")},j="CookieConsent",B=function(e){var t=e.condition,n=e.wrapper,o=e.children;return t?n(o):o},w=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}(s,e);var n,o,r,i,c=(r=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=O(r);if(i){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return d(this,e)});function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),m(v(t=c.call(this,e)),"handleScroll",(function(){var e=t.props.acceptOnScrollPercentage,n=document.documentElement,o=document.body,r="scrollTop",i="scrollHeight";(n[r]||o[r])/((n[i]||o[i])-n.clientHeight)*100>e&&t.accept(!0)})),m(v(t),"removeScrollListener",(function(){t.props.acceptOnScroll&&window.removeEventListener("scroll",t.handleScroll)})),t.state={visible:!1,style:{alignItems:"baseline",background:"#353535",color:"white",display:"flex",flexWrap:"wrap",justifyContent:"space-between",left:"0",position:"fixed",width:"100%",zIndex:"999"},buttonStyle:{background:"#ffd42d",border:"0",borderRadius:"0px",boxShadow:"none",color:"black",cursor:"pointer",flex:"0 0 auto",padding:"5px 10px",margin:"15px"},declineButtonStyle:{background:"#c12a2a",border:"0",borderRadius:"0px",boxShadow:"none",color:"#e5e5e5",cursor:"pointer",flex:"0 0 auto",padding:"5px 10px",margin:"15px"},contentStyle:{flex:"1 0 300px",margin:"15px"},overlayStyle:{position:"fixed",left:0,top:0,width:"100%",height:"100%",zIndex:"999",backgroundColor:"rgba(0,0,0,0.3)"}},t}return n=s,(o=[{key:"componentDidMount",value:function(){var e=this.props.debug;(void 0===this.getCookieValue()||e)&&(this.setState({visible:!0}),this.props.acceptOnScroll&&window.addEventListener("scroll",this.handleScroll,{passive:!0}))}},{key:"componentWillUnmount",value:function(){this.removeScrollListener()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.props,n=t.cookieName,o=t.cookieValue,r=t.hideOnAccept,i=t.onAccept;this.setCookie(n,o),i(null!=e&&e),r&&(this.setState({visible:!1}),this.removeScrollListener())}},{key:"overlayClick",value:function(){var e=this.props,t=e.acceptOnOverlayClick,n=e.onOverlayClick;t&&this.accept(),n()}},{key:"decline",value:function(){var e=this.props,t=e.cookieName,n=e.declineCookieValue,o=e.hideOnDecline,r=e.onDecline;e.setDeclineCookie&&this.setCookie(t,n),r(),o&&this.setState({visible:!1})}},{key:"setCookie",value:function(e,t){var n=this.props,o=n.extraCookieOptions,r=n.expires,i=n.sameSite,c=this.props.cookieSecurity;void 0===c&&(c=!location||"https:"===location.protocol);var s=f(f({expires:r},o),{},{sameSite:i,secure:c});i===C.NONE&&l().set(x(e),t,s),l().set(e,t,s)}},{key:"getCookieValue",value:function(){var e=this.props.cookieName;return S(e)}},{key:"render",value:function(){var e=this;switch(this.props.visible){case g.HIDDEN:return null;case g.BY_COOKIE_VALUE:if(!this.state.visible)return null}var n=this.props,o=n.location,r=n.style,i=n.buttonStyle,c=n.declineButtonStyle,l=n.contentStyle,s=n.disableStyles,a=n.buttonText,p=n.declineButtonText,b=n.containerClasses,y=n.contentClasses,d=n.buttonClasses,v=n.buttonWrapperClasses,O=n.declineButtonClasses,m=n.buttonId,C=n.declineButtonId,S=n.disableButtonStyles,k=n.enableDeclineButton,x=n.flipButtons,j=n.ButtonComponent,w=n.overlay,P=n.overlayClasses,T=n.overlayStyle,E=n.ariaAcceptLabel,D=n.ariaDeclineLabel,I=n.customContainerAttributes,_=n.customContentAttributes,A=n.customButtonProps,N=n.customDeclineButtonProps,R={},L={},V={},U={},W={};switch(s?(R=u({},r),L=u({},i),V=u({},c),U=u({},l),W=u({},T)):(R=u({},f(f({},this.state.style),r)),U=u({},f(f({},this.state.contentStyle),l)),W=u({},f(f({},this.state.overlayStyle),T)),S?(L=u({},i),V=u({},c)):(L=u({},f(f({},this.state.buttonStyle),i)),V=u({},f(f({},this.state.declineButtonStyle),c)))),o){case h.TOP:R.top="0";break;case h.BOTTOM:R.bottom="0"}var M=[];return k&&M.push(t().createElement(j,u({key:"declineButton",style:V,className:O,id:C,"aria-label":D,onClick:function(){e.decline()}},N),p)),M.push(t().createElement(j,u({key:"acceptButton",style:L,className:d,id:m,"aria-label":E,onClick:function(){e.accept()}},A),a)),x&&M.reverse(),t().createElement(B,{condition:w,wrapper:function(n){return t().createElement("div",{style:W,className:P,onClick:function(){e.overlayClick()}},n)}},t().createElement("div",u({className:"".concat(b),style:R},I),t().createElement("div",u({style:U,className:y},_),this.props.children),t().createElement("div",{className:"".concat(v)},M.map((function(e){return e})))))}}])&&b(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),s}(e.Component);w.propTypes={location:i().oneOf(Object.keys(h).map((function(e){return h[e]}))),visible:i().oneOf(Object.keys(g).map((function(e){return g[e]}))),sameSite:i().oneOf(Object.keys(C).map((function(e){return C[e]}))),style:i().object,buttonStyle:i().object,declineButtonStyle:i().object,contentStyle:i().object,children:i().any,disableStyles:i().bool,hideOnAccept:i().bool,hideOnDecline:i().bool,onAccept:i().func,onDecline:i().func,buttonText:i().oneOfType([i().string,i().func,i().element]),declineButtonText:i().oneOfType([i().string,i().func,i().element]),cookieName:i().string,cookieValue:i().oneOfType([i().string,i().bool,i().number]),declineCookieValue:i().oneOfType([i().string,i().bool,i().number]),setDeclineCookie:i().bool,debug:i().bool,expires:i().number,containerClasses:i().string,contentClasses:i().string,buttonClasses:i().string,buttonWrapperClasses:i().string,declineButtonClasses:i().string,buttonId:i().string,declineButtonId:i().string,extraCookieOptions:i().object,disableButtonStyles:i().bool,enableDeclineButton:i().bool,flipButtons:i().bool,ButtonComponent:i().elementType,cookieSecurity:i().bool,overlay:i().bool,overlayClasses:i().string,overlayStyle:i().object,onOverlayClick:i().func,acceptOnOverlayClick:i().bool,ariaAcceptLabel:i().string,ariaDeclineLabel:i().string,acceptOnScroll:i().bool,acceptOnScrollPercentage:i().number,customContentAttributes:i().object,customContainerAttributes:i().object,customButtonProps:i().object,customDeclineButtonProps:i().object},w.defaultProps={disableStyles:!1,hideOnAccept:!0,hideOnDecline:!0,location:h.BOTTOM,visible:g.BY_COOKIE_VALUE,onAccept:function(){},onDecline:function(){},cookieName:j,cookieValue:!0,declineCookieValue:!1,setDeclineCookie:!0,buttonText:"I understand",declineButtonText:"I decline",debug:!1,expires:365,containerClasses:"CookieConsent",contentClasses:"",buttonClasses:"",buttonWrapperClasses:"",declineButtonClasses:"",buttonId:"rcc-confirm-button",declineButtonId:"rcc-decline-button",extraCookieOptions:{},disableButtonStyles:!1,enableDeclineButton:!1,flipButtons:!1,sameSite:C.LAX,ButtonComponent:function(e){var n=e.children,o=function(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(e,a);return t().createElement("button",o,n)},overlay:!1,overlayClasses:"",onOverlayClick:function(){},acceptOnOverlayClick:!1,ariaAcceptLabel:"Accept cookies",ariaDeclineLabel:"Decline cookies",acceptOnScroll:!1,acceptOnScrollPercentage:25,customContentAttributes:{},customContainerAttributes:{},customButtonProps:{},customDeclineButtonProps:{}};const P=w}(),o}()})); \ No newline at end of file diff --git a/example b/example index bff8dd7..8f1152c 160000 --- a/example +++ b/example @@ -1 +1 @@ -Subproject commit bff8dd76c5c13a0bf38a555b2d551e11540d30f0 +Subproject commit 8f1152c04d7bc70ba098783db2b752379ed7ec0f diff --git a/package-lock.json b/package-lock.json index fb0add4..e23d37d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-cookie-consent", - "version": "7.4.1", + "version": "7.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-cookie-consent", - "version": "7.4.1", + "version": "7.5.0", "license": "MIT", "dependencies": { "js-cookie": "^2.2.1", diff --git a/package.json b/package.json index bb21b91..537284e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "name": "Rick van Lieshout", "email": "info@rickvanlieshout.com" }, - "version": "7.4.1", + "version": "7.5.0", "description": "A small, simple and customizable cookie consent bar for use in React applications.", "main": "build/index.js", "types": "build/index.d.ts",