release 7.1.0

This commit is contained in:
Rick van Lieshout 2021-12-19 13:30:47 +01:00
parent eaaf6f8797
commit 775ec9db96
4 changed files with 104 additions and 92 deletions

2
build/index.d.ts vendored
View File

@ -42,6 +42,8 @@ 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

@ -48,8 +48,8 @@
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent) .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
.replace(/[\(\)]/g, escape)); .replace(/[\(\)]/g, escape));
var l = ""; var l = "";
for (var a in i) for (var s in i)
i[a] && ((l += "; " + a), !0 !== i[a] && (l += "=" + i[a].split(";")[0])); i[s] && ((l += "; " + s), !0 !== i[s] && (l += "=" + i[s].split(";")[0]));
return (document.cookie = t + "=" + n + l); return (document.cookie = t + "=" + n + l);
} }
} }
@ -61,15 +61,15 @@
c++ c++
) { ) {
var l = i[c].split("="), var l = i[c].split("="),
a = l.slice(1).join("="); s = l.slice(1).join("=");
n || '"' !== a.charAt(0) || (a = a.slice(1, -1)); n || '"' !== s.charAt(0) || (s = s.slice(1, -1));
try { try {
var s = t(l[0]); var a = t(l[0]);
if (((a = (o.read || o)(a, s) || t(a)), n)) if (((s = (o.read || o)(s, a) || t(s)), n))
try { try {
a = JSON.parse(a); s = JSON.parse(s);
} catch (e) {} } catch (e) {}
if (((r[s] = a), e === s)) break; if (((r[a] = s), e === a)) break;
} catch (e) {} } catch (e) {}
} }
return e ? r[e] : r; return e ? r[e] : r;
@ -189,19 +189,19 @@
return l(); return l();
}, },
OPTIONS: function () { OPTIONS: function () {
return m; return h;
}, },
SAME_SITE_OPTIONS: function () { SAME_SITE_OPTIONS: function () {
return g; return g;
}, },
VISIBLE_OPTIONS: function () { VISIBLE_OPTIONS: function () {
return S; return C;
}, },
default: function () { default: function () {
return B; return B;
}, },
getCookieConsentValue: function () { getCookieConsentValue: function () {
return C; return S;
}, },
resetCookieConsentValue: function () { resetCookieConsentValue: function () {
return k; return k;
@ -213,8 +213,8 @@
i = n.n(r), i = n.n(r),
c = n(808), c = n(808),
l = n.n(c); l = n.n(c);
function a(e) { function s(e) {
return (a = return (s =
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
? function (e) { ? function (e) {
return typeof e; return typeof e;
@ -228,7 +228,7 @@
: typeof e; : typeof e;
})(e); })(e);
} }
var s = ["children"]; var a = ["children"];
function u() { function u() {
return (u = return (u =
Object.assign || Object.assign ||
@ -257,7 +257,7 @@
var n = null != arguments[t] ? arguments[t] : {}; var n = null != arguments[t] ? arguments[t] : {};
t % 2 t % 2
? p(Object(n), !0).forEach(function (t) { ? p(Object(n), !0).forEach(function (t) {
h(e, t, n[t]); O(e, t, n[t]);
}) })
: Object.getOwnPropertyDescriptors : Object.getOwnPropertyDescriptors
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n))
@ -267,7 +267,7 @@
} }
return e; return e;
} }
function d(e, t) { function b(e, t) {
for (var n = 0; n < t.length; n++) { for (var n = 0; n < t.length; n++) {
var o = t[n]; var o = t[n];
(o.enumerable = o.enumerable || !1), (o.enumerable = o.enumerable || !1),
@ -276,15 +276,15 @@
Object.defineProperty(e, o.key, o); Object.defineProperty(e, o.key, o);
} }
} }
function b(e, t) { function d(e, t) {
return (b = return (d =
Object.setPrototypeOf || Object.setPrototypeOf ||
function (e, t) { function (e, t) {
return (e.__proto__ = t), e; return (e.__proto__ = t), e;
})(e, t); })(e, t);
} }
function y(e, t) { function y(e, t) {
if (t && ("object" === a(t) || "function" == typeof t)) return t; if (t && ("object" === s(t) || "function" == typeof t)) return t;
if (void 0 !== t) if (void 0 !== t)
throw new TypeError("Derived constructors may only return object or undefined"); throw new TypeError("Derived constructors may only return object or undefined");
return v(e); return v(e);
@ -294,14 +294,14 @@
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return e; return e;
} }
function O(e) { function m(e) {
return (O = Object.setPrototypeOf return (m = Object.setPrototypeOf
? Object.getPrototypeOf ? Object.getPrototypeOf
: function (e) { : function (e) {
return e.__proto__ || Object.getPrototypeOf(e); return e.__proto__ || Object.getPrototypeOf(e);
})(e); })(e);
} }
function h(e, t, n) { function O(e, t, n) {
return ( return (
t in e t in e
? Object.defineProperty(e, t, { ? Object.defineProperty(e, t, {
@ -314,10 +314,10 @@
e e
); );
} }
var m = { TOP: "top", BOTTOM: "bottom", NONE: "none" }, var h = { TOP: "top", BOTTOM: "bottom", NONE: "none" },
g = { STRICT: "strict", LAX: "lax", NONE: "none" }, g = { STRICT: "strict", LAX: "lax", NONE: "none" },
S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" }, C = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
C = function () { S = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j, var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j,
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;
@ -343,14 +343,14 @@
(e.prototype = Object.create(t && t.prototype, { (e.prototype = Object.create(t && t.prototype, {
constructor: { value: e, writable: !0, configurable: !0 }, constructor: { value: e, writable: !0, configurable: !0 },
})), })),
t && b(e, t); t && d(e, t);
})(a, e); })(s, e);
var n, var n,
o, o,
r, r,
i, i,
c = c =
((r = a), ((r = s),
(i = (function () { (i = (function () {
if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
if (Reflect.construct.sham) return !1; if (Reflect.construct.sham) return !1;
@ -368,20 +368,20 @@
})()), })()),
function () { function () {
var e, var e,
t = O(r); t = m(r);
if (i) { if (i) {
var n = O(this).constructor; var n = m(this).constructor;
e = Reflect.construct(t, arguments, n); e = Reflect.construct(t, arguments, n);
} else e = t.apply(this, arguments); } else e = t.apply(this, arguments);
return y(this, e); return y(this, e);
}); });
function a(e) { function s(e) {
var t; var t;
return ( return (
(function (e, t) { (function (e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function"); if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
})(this, a), })(this, s),
h(v((t = c.call(this, e))), "handleScroll", function () { O(v((t = c.call(this, e))), "handleScroll", function () {
var e = t.props.acceptOnScrollPercentage, var e = t.props.acceptOnScrollPercentage,
n = document.documentElement, n = document.documentElement,
o = document.body, o = document.body,
@ -389,7 +389,7 @@
i = "scrollHeight"; i = "scrollHeight";
((n[r] || o[r]) / ((n[i] || o[i]) - n.clientHeight)) * 100 > e && t.accept(!0); ((n[r] || o[r]) / ((n[i] || o[i]) - n.clientHeight)) * 100 > e && t.accept(!0);
}), }),
h(v(t), "removeScrollListener", function () { O(v(t), "removeScrollListener", function () {
t.props.acceptOnScroll && window.removeEventListener("scroll", t.handleScroll); t.props.acceptOnScroll && window.removeEventListener("scroll", t.handleScroll);
}), }),
(t.state = { (t.state = {
@ -443,7 +443,7 @@
); );
} }
return ( return (
(n = a), (n = s),
(o = [ (o = [
{ {
key: "componentDidMount", key: "componentDidMount",
@ -497,15 +497,15 @@
i = n.sameSite, i = n.sameSite,
c = this.props.cookieSecurity; c = this.props.cookieSecurity;
void 0 === c && (c = !location || "https:" === location.protocol); void 0 === c && (c = !location || "https:" === location.protocol);
var a = f(f({ expires: r }, o), {}, { sameSite: i, secure: c }); var s = f(f({ expires: r }, o), {}, { sameSite: i, secure: c });
i === g.NONE && l().set(x(e), t, a), l().set(e, t, a); i === g.NONE && l().set(x(e), t, s), l().set(e, t, s);
}, },
}, },
{ {
key: "getCookieValue", key: "getCookieValue",
value: function () { value: function () {
var e = this.props.cookieName; var e = this.props.cookieName;
return C(e); return S(e);
}, },
}, },
{ {
@ -513,9 +513,9 @@
value: function () { value: function () {
var e = this; var e = this;
switch (this.props.visible) { switch (this.props.visible) {
case S.HIDDEN: case C.HIDDEN:
return null; return null;
case S.BY_COOKIE_VALUE: case C.BY_COOKIE_VALUE:
if (!this.state.visible) return null; if (!this.state.visible) return null;
} }
var n = this.props, var n = this.props,
@ -524,17 +524,17 @@
i = n.buttonStyle, i = n.buttonStyle,
c = n.declineButtonStyle, c = n.declineButtonStyle,
l = n.contentStyle, l = n.contentStyle,
a = n.disableStyles, s = n.disableStyles,
s = n.buttonText, a = n.buttonText,
p = n.declineButtonText, p = n.declineButtonText,
d = n.containerClasses, b = n.containerClasses,
b = n.contentClasses, d = n.contentClasses,
y = n.buttonClasses, y = n.buttonClasses,
v = n.buttonWrapperClasses, v = n.buttonWrapperClasses,
O = n.declineButtonClasses, m = n.declineButtonClasses,
h = n.buttonId, O = n.buttonId,
g = n.declineButtonId, g = n.declineButtonId,
C = n.disableButtonStyles, S = n.disableButtonStyles,
k = n.enableDeclineButton, k = n.enableDeclineButton,
x = n.flipButtons, x = n.flipButtons,
j = n.ButtonComponent, j = n.ButtonComponent,
@ -543,43 +543,45 @@
E = n.overlayStyle, E = n.overlayStyle,
P = n.ariaAcceptLabel, P = n.ariaAcceptLabel,
D = n.ariaDeclineLabel, D = n.ariaDeclineLabel,
I = {}, I = n.customContainerAttributes,
_ = {}, _ = n.customContentAttributes,
A = {},
N = {}, N = {},
R = {}, R = {},
A = {}; L = {},
V = {};
switch ( switch (
(a (s
? ((I = u({}, r)), ? ((A = u({}, r)),
(_ = u({}, i)), (N = u({}, i)),
(N = u({}, c)), (R = u({}, c)),
(R = u({}, l)), (L = u({}, l)),
(A = u({}, E))) (V = u({}, E)))
: ((I = u({}, f(f({}, this.state.style), r))), : ((A = u({}, f(f({}, this.state.style), r))),
(R = u({}, f(f({}, this.state.contentStyle), l))), (L = u({}, f(f({}, this.state.contentStyle), l))),
(A = u({}, f(f({}, this.state.overlayStyle), E))), (V = u({}, f(f({}, this.state.overlayStyle), E))),
C S
? ((_ = u({}, i)), (N = u({}, c))) ? ((N = u({}, i)), (R = u({}, c)))
: ((_ = u({}, f(f({}, this.state.buttonStyle), i))), : ((N = u({}, f(f({}, this.state.buttonStyle), i))),
(N = u({}, f(f({}, this.state.declineButtonStyle), c))))), (R = u({}, f(f({}, this.state.declineButtonStyle), c))))),
o) o)
) { ) {
case m.TOP: case h.TOP:
I.top = "0"; A.top = "0";
break; break;
case m.BOTTOM: case h.BOTTOM:
I.bottom = "0"; A.bottom = "0";
} }
var L = []; var U = [];
return ( return (
k && k &&
L.push( U.push(
t().createElement( t().createElement(
j, j,
{ {
key: "declineButton", key: "declineButton",
style: N, style: R,
className: O, className: m,
id: g, id: g,
"aria-label": D, "aria-label": D,
onClick: function () { onClick: function () {
@ -589,39 +591,43 @@
p p
) )
), ),
L.push( U.push(
t().createElement( t().createElement(
j, j,
{ {
key: "acceptButton", key: "acceptButton",
style: _, style: N,
className: y, className: y,
id: h, id: O,
"aria-label": P, "aria-label": P,
onClick: function () { onClick: function () {
e.accept(); e.accept();
}, },
}, },
s a
) )
), ),
x && L.reverse(), x && U.reverse(),
t().createElement( t().createElement(
w, w,
{ {
condition: T, condition: T,
wrapper: function (e) { wrapper: function (e) {
return t().createElement("div", { style: A, className: B }, e); return t().createElement("div", { style: V, className: B }, e);
}, },
}, },
t().createElement( t().createElement(
"div", "div",
{ className: "".concat(d), style: I }, u({ className: "".concat(b), style: A }, I),
t().createElement("div", { style: R, className: b }, this.props.children), t().createElement(
"div",
u({ style: L, className: d }, _),
this.props.children
),
t().createElement( t().createElement(
"div", "div",
{ className: "".concat(v) }, { className: "".concat(v) },
L.map(function (e) { U.map(function (e) {
return e; return e;
}) })
) )
@ -630,19 +636,19 @@
); );
}, },
}, },
]) && d(n.prototype, o), ]) && b(n.prototype, o),
a s
); );
})(e.Component); })(e.Component);
(T.propTypes = { (T.propTypes = {
location: i().oneOf( location: i().oneOf(
Object.keys(m).map(function (e) { Object.keys(h).map(function (e) {
return m[e]; return h[e];
}) })
), ),
visible: i().oneOf( visible: i().oneOf(
Object.keys(S).map(function (e) { Object.keys(C).map(function (e) {
return S[e]; return C[e];
}) })
), ),
sameSite: i().oneOf( sameSite: i().oneOf(
@ -688,13 +694,15 @@
ariaDeclineLabel: i().string, ariaDeclineLabel: i().string,
acceptOnScroll: i().bool, acceptOnScroll: i().bool,
acceptOnScrollPercentage: i().number, acceptOnScrollPercentage: i().number,
customContentAttributes: i().object,
customContainerAttributes: i().object,
}), }),
(T.defaultProps = { (T.defaultProps = {
disableStyles: !1, disableStyles: !1,
hideOnAccept: !0, hideOnAccept: !0,
hideOnDecline: !0, hideOnDecline: !0,
location: m.BOTTOM, location: h.BOTTOM,
visible: S.BY_COOKIE_VALUE, visible: C.BY_COOKIE_VALUE,
onAccept: function () {}, onAccept: function () {},
onDecline: function () {}, onDecline: function () {},
cookieName: j, cookieName: j,
@ -740,7 +748,7 @@
(Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n])); (Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]));
} }
return r; return r;
})(e, s); })(e, a);
return t().createElement("button", o, n); return t().createElement("button", o, n);
}, },
overlay: !1, overlay: !1,
@ -749,6 +757,8 @@
ariaDeclineLabel: "Decline cookies", ariaDeclineLabel: "Decline cookies",
acceptOnScroll: !1, acceptOnScroll: !1,
acceptOnScrollPercentage: 25, acceptOnScrollPercentage: 25,
customContentAttributes: {},
customContainerAttributes: {},
}); });
const B = T; const B = T;
})(), })(),

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "react-cookie-consent", "name": "react-cookie-consent",
"version": "7.0.1", "version": "7.1.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "7.0.1", "version": "7.1.0",
"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": "7.1.0",
"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",