1 Commits
7.1.0 ... 7.0.0

Author SHA1 Message Date
Peter Krieg
d6c751860c Switch Library Type from CommonJs2 => UMD (#134) 2021-12-08 17:32:57 +01:00
8 changed files with 729 additions and 769 deletions

View File

@@ -5,18 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [[7.1.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.1.0)]
- Added custom attribute props for content and container
## [[7.0.1](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.0.1)]
- Configured webpack to remove self from build artefact. Should now work in Nextjs and Gatsby (only tested those..)
## [[7.0.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.0.0)]
- Switched from CommonJS to UMD module
## [[6.4.1](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1))] ## [[6.4.1](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1))]
- Added missing typing - Added missing typing

View File

@@ -174,16 +174,12 @@ That option would be interesting if you want to allow user to change their conse
| flipButtons | boolean | false | If enabled the accept and decline buttons will be flipped | | flipButtons | boolean | false | If enabled the accept and decline buttons will be flipped |
| ButtonComponent | React component | button | React Component to render as a button. | | ButtonComponent | React component | button | React Component to render as a button. |
| sameSite | string, "strict", "lax" or "none" | none | Cookies sameSite attribute value | | sameSite | string, "strict", "lax" or "none" | none | Cookies sameSite attribute value |
| cookieSecurity | boolean ¡ | undefined | Cookie security level. Defaults to true unless running on http. | | cookieSecurity | boolean ¡| undefined | Cookie security level. Defaults to true unless running on http. |
| ariaAcceptLabel | string | Accept cookies | Aria label to set on the accept button | | ariaAcceptLabel | string | Accept cookies | Aria label to set on the accept button |
| ariaDeclineLabel | string | Decline cookies | Aria label to set on the decline button | | ariaDeclineLabel | string | Decline cookies | Aria label to set on the decline button |
| acceptOnScroll | boolean | false | Defines whether "accept" should be fired after the user scrolls a certain distance (see acceptOnScrollPercentage) | | acceptOnScroll | boolean | false | Defines whether "accept" should be fired after the user scrolls a certain distance (see acceptOnScrollPercentage) |
| acceptOnScrollPercentage | number | 25 | Percentage of the page height the user has to scroll to trigger the accept function if acceptOnScroll is enabled | | acceptOnScrollPercentage | number | 25 | Percentage of the page height the user has to scroll to trigger the accept function if acceptOnScroll is enabled |
| customContentAttributes
| object | {} | Allows you to set custom (data) attributes on the content div |
| customContainerAttributes | object | {} | Allows you to set custom (data) attributes on the container div |
## Debugging it ## Debugging it
Because the cookie consent bar will be hidden once accepted, you will have to set the prop `debug={true}` to evaluate styling changes: Because the cookie consent bar will be hidden once accepted, you will have to set the prop `debug={true}` to evaluate styling changes:

View File

@@ -1,14 +1,5 @@
/*! For license information please see index.js.LICENSE.txt */ /*! For license information please see index.js.LICENSE.txt */
!(function (e, t) { !(function () {
"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 = { var e = {
808: function (e, t, n) { 808: function (e, t, n) {
var o, r, i; var o, r, i;
@@ -180,8 +171,7 @@
Object.defineProperty(e, "__esModule", { value: !0 }); Object.defineProperty(e, "__esModule", { value: !0 });
}); });
var o = {}; var o = {};
return ( !(function () {
(function () {
"use strict"; "use strict";
n.r(o), n.r(o),
n.d(o, { n.d(o, {
@@ -318,19 +308,19 @@
g = { STRICT: "strict", LAX: "lax", NONE: "none" }, g = { STRICT: "strict", LAX: "lax", NONE: "none" },
S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" }, S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
C = function () { C = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j, var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : w,
t = l().get(e); t = l().get(e);
return void 0 === t && (t = l().get(x(e))), t; return void 0 === t && (t = l().get(x(e))), t;
}, },
k = function () { k = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j; var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : w;
l().remove(e); l().remove(e);
}, },
x = function (e) { x = function (e) {
return "".concat(e, "-legacy"); return "".concat(e, "-legacy");
}, },
j = "CookieConsent", w = "CookieConsent",
w = function (e) { j = function (e) {
var t = e.condition, var t = e.condition,
n = e.wrapper, n = e.wrapper,
o = e.children; o = e.children;
@@ -357,10 +347,7 @@
if ("function" == typeof Proxy) return !0; if ("function" == typeof Proxy) return !0;
try { try {
return ( return (
Boolean.prototype.valueOf.call( Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0
Reflect.construct(Boolean, [], function () {})
),
!0
); );
} catch (e) { } catch (e) {
return !1; return !1;
@@ -537,7 +524,7 @@
C = n.disableButtonStyles, C = n.disableButtonStyles,
k = n.enableDeclineButton, k = n.enableDeclineButton,
x = n.flipButtons, x = n.flipButtons,
j = n.ButtonComponent, w = n.ButtonComponent,
T = n.overlay, T = n.overlay,
B = n.overlayClasses, B = n.overlayClasses,
E = n.overlayStyle, E = n.overlayStyle,
@@ -546,18 +533,18 @@
I = {}, I = {},
_ = {}, _ = {},
N = {}, N = {},
R = {}, A = {},
A = {}; L = {};
switch ( switch (
(a (a
? ((I = u({}, r)), ? ((I = u({}, r)),
(_ = u({}, i)), (_ = u({}, i)),
(N = u({}, c)), (N = u({}, c)),
(R = u({}, l)), (A = u({}, l)),
(A = u({}, E))) (L = u({}, E)))
: ((I = u({}, f(f({}, this.state.style), r))), : ((I = u({}, f(f({}, this.state.style), r))),
(R = u({}, f(f({}, this.state.contentStyle), l))), (A = u({}, f(f({}, this.state.contentStyle), l))),
(A = u({}, f(f({}, this.state.overlayStyle), E))), (L = u({}, f(f({}, this.state.overlayStyle), E))),
C C
? ((_ = u({}, i)), (N = u({}, c))) ? ((_ = u({}, i)), (N = u({}, c)))
: ((_ = u({}, f(f({}, this.state.buttonStyle), i))), : ((_ = u({}, f(f({}, this.state.buttonStyle), i))),
@@ -570,12 +557,12 @@
case m.BOTTOM: case m.BOTTOM:
I.bottom = "0"; I.bottom = "0";
} }
var L = []; var R = [];
return ( return (
k && k &&
L.push( R.push(
t().createElement( t().createElement(
j, w,
{ {
key: "declineButton", key: "declineButton",
style: N, style: N,
@@ -589,9 +576,9 @@
p p
) )
), ),
L.push( R.push(
t().createElement( t().createElement(
j, w,
{ {
key: "acceptButton", key: "acceptButton",
style: _, style: _,
@@ -605,23 +592,23 @@
s s
) )
), ),
x && L.reverse(), x && R.reverse(),
t().createElement( t().createElement(
w, j,
{ {
condition: T, condition: T,
wrapper: function (e) { wrapper: function (e) {
return t().createElement("div", { style: A, className: B }, e); return t().createElement("div", { style: L, className: B }, e);
}, },
}, },
t().createElement( t().createElement(
"div", "div",
{ className: "".concat(d), style: I }, { className: "".concat(d), style: I },
t().createElement("div", { style: R, className: b }, this.props.children), t().createElement("div", { style: A, className: b }, this.props.children),
t().createElement( t().createElement(
"div", "div",
{ className: "".concat(v) }, { className: "".concat(v) },
L.map(function (e) { R.map(function (e) {
return e; return e;
}) })
) )
@@ -697,7 +684,7 @@
visible: S.BY_COOKIE_VALUE, visible: S.BY_COOKIE_VALUE,
onAccept: function () {}, onAccept: function () {},
onDecline: function () {}, onDecline: function () {},
cookieName: j, cookieName: w,
cookieValue: !0, cookieValue: !0,
declineCookieValue: !1, declineCookieValue: !1,
setDeclineCookie: !0, setDeclineCookie: !0,
@@ -752,7 +739,5 @@
}); });
const B = T; const B = T;
})(), })(),
o (module.exports = o);
); })();
})();
});

4
package-lock.json generated
View File

@@ -1,11 +1,11 @@
{ {
"name": "react-cookie-consent", "name": "react-cookie-consent",
"version": "7.0.1", "version": "6.4.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "7.0.1", "version": "6.4.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",

View File

@@ -4,7 +4,7 @@
"name": "Rick van Lieshout", "name": "Rick van Lieshout",
"email": "info@rickvanlieshout.com" "email": "info@rickvanlieshout.com"
}, },
"version": "7.0.1", "version": "6.4.1",
"description": "A small, simple and customizable cookie consent bar for use in React applications.", "description": "A small, simple and customizable cookie consent bar for use in React applications.",
"main": "build/index.js", "main": "build/index.js",
"types": "build/index.d.ts", "types": "build/index.d.ts",

2
src/index.d.ts vendored
View File

@@ -42,8 +42,6 @@ export interface CookieConsentProps {
ariaDeclineLabel?: string; ariaDeclineLabel?: string;
acceptOnScroll?: boolean; acceptOnScroll?: boolean;
acceptOnScrollPercentage?: number; acceptOnScrollPercentage?: number;
customContentAttributes: object;
customContainerAttributes: object;
} }
export default class CookieConsent extends React.Component<CookieConsentProps, {}> {} export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}

View File

@@ -15,10 +15,10 @@ export const SAME_SITE_OPTIONS = {
}; };
export const VISIBLE_OPTIONS = { export const VISIBLE_OPTIONS = {
HIDDEN: "hidden", HIDDEN: 'hidden',
SHOW: "show", SHOW: 'show',
BY_COOKIE_VALUE: "byCookieValue", BY_COOKIE_VALUE: 'byCookieValue'
}; }
/** /**
* Returns the value of the consent cookie * Returns the value of the consent cookie
@@ -279,8 +279,6 @@ class CookieConsent extends Component {
overlayStyle, overlayStyle,
ariaAcceptLabel, ariaAcceptLabel,
ariaDeclineLabel, ariaDeclineLabel,
customContainerAttributes,
customContentAttributes,
} = this.props; } = this.props;
let myStyle = {}; let myStyle = {};
@@ -374,8 +372,8 @@ class CookieConsent extends Component {
</div> </div>
)} )}
> >
<div className={`${containerClasses}`} style={myStyle} {...customContainerAttributes}> <div className={`${containerClasses}`} style={myStyle}>
<div style={myContentStyle} className={contentClasses} {...customContentAttributes}> <div style={myContentStyle} className={contentClasses}>
{this.props.children} {this.props.children}
</div> </div>
<div className={`${buttonWrapperClasses}`}> <div className={`${buttonWrapperClasses}`}>
@@ -431,8 +429,6 @@ CookieConsent.propTypes = {
ariaDeclineLabel: PropTypes.string, ariaDeclineLabel: PropTypes.string,
acceptOnScroll: PropTypes.bool, acceptOnScroll: PropTypes.bool,
acceptOnScrollPercentage: PropTypes.number, acceptOnScrollPercentage: PropTypes.number,
customContentAttributes: PropTypes.object,
customContainerAttributes: PropTypes.object,
}; };
CookieConsent.defaultProps = { CookieConsent.defaultProps = {
@@ -470,8 +466,6 @@ CookieConsent.defaultProps = {
ariaDeclineLabel: "Decline cookies", ariaDeclineLabel: "Decline cookies",
acceptOnScroll: false, acceptOnScroll: false,
acceptOnScrollPercentage: 25, acceptOnScrollPercentage: 25,
customContentAttributes: {},
customContainerAttributes: {},
}; };
export default CookieConsent; export default CookieConsent;

View File

@@ -13,7 +13,6 @@ module.exports = {
environment: { environment: {
arrowFunction: false, // the generated runtime-code should not use arrow functions arrowFunction: false, // the generated runtime-code should not use arrow functions
}, },
globalObject: `typeof self !== 'undefined' ? self : this`,
}, },
module: { module: {
rules: [ rules: [