4 Commits
7.2.1 ... 7.2.0

Author SHA1 Message Date
2e205f8081 added onOverlayClick and acceptOnOverlayClick 2021-12-20 17:48:43 +01:00
086558f463 release 7.1.1 2021-12-20 17:35:57 +01:00
Souchet Céline
712adf9c5b Fix the README.md (#142) 2021-12-20 17:33:35 +01:00
Souchet Céline
ab046db1e8 Fix the TypeScript definition of some properties (#143) 2021-12-20 17:33:12 +01:00
5 changed files with 65 additions and 91 deletions

2
build/index.d.ts vendored
View File

@@ -38,8 +38,6 @@ export interface CookieConsentProps {
overlay?: boolean;
overlayClasses?: string;
overlayStyle?: object;
onOverlayClick?: () => void;
acceptOnOverlayClick?: boolean;
ariaAcceptLabel?: string;
ariaDeclineLabel?: string;
acceptOnScroll?: boolean;

View File

@@ -48,8 +48,8 @@
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
.replace(/[\(\)]/g, escape));
var l = "";
for (var a in i)
i[a] && ((l += "; " + a), !0 !== i[a] && (l += "=" + i[a].split(";")[0]));
for (var s in i)
i[s] && ((l += "; " + s), !0 !== i[s] && (l += "=" + i[s].split(";")[0]));
return (document.cookie = t + "=" + n + l);
}
}
@@ -61,15 +61,15 @@
c++
) {
var l = i[c].split("="),
a = l.slice(1).join("=");
n || '"' !== a.charAt(0) || (a = a.slice(1, -1));
s = l.slice(1).join("=");
n || '"' !== s.charAt(0) || (s = s.slice(1, -1));
try {
var s = t(l[0]);
if (((a = (o.read || o)(a, s) || t(a)), n))
var a = t(l[0]);
if (((s = (o.read || o)(s, a) || t(s)), n))
try {
a = JSON.parse(a);
s = JSON.parse(s);
} catch (e) {}
if (((r[s] = a), e === s)) break;
if (((r[a] = s), e === a)) break;
} catch (e) {}
}
return e ? r[e] : r;
@@ -192,10 +192,10 @@
return h;
},
SAME_SITE_OPTIONS: function () {
return C;
return g;
},
VISIBLE_OPTIONS: function () {
return g;
return C;
},
default: function () {
return B;
@@ -213,8 +213,8 @@
i = n.n(r),
c = n(808),
l = n.n(c);
function a(e) {
return (a =
function s(e) {
return (s =
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator
? function (e) {
return typeof e;
@@ -228,7 +228,7 @@
: typeof e;
})(e);
}
var s = ["children"];
var a = ["children"];
function u() {
return (u =
Object.assign ||
@@ -257,7 +257,7 @@
var n = null != arguments[t] ? arguments[t] : {};
t % 2
? p(Object(n), !0).forEach(function (t) {
m(e, t, n[t]);
O(e, t, n[t]);
})
: Object.getOwnPropertyDescriptors
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n))
@@ -276,15 +276,15 @@
Object.defineProperty(e, o.key, o);
}
}
function y(e, t) {
return (y =
function d(e, t) {
return (d =
Object.setPrototypeOf ||
function (e, t) {
return (e.__proto__ = t), e;
})(e, t);
}
function d(e, t) {
if (t && ("object" === a(t) || "function" == typeof t)) return t;
function y(e, t) {
if (t && ("object" === s(t) || "function" == typeof t)) return t;
if (void 0 !== t)
throw new TypeError("Derived constructors may only return object or undefined");
return v(e);
@@ -294,14 +294,14 @@
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return e;
}
function O(e) {
return (O = Object.setPrototypeOf
function m(e) {
return (m = Object.setPrototypeOf
? Object.getPrototypeOf
: function (e) {
return e.__proto__ || Object.getPrototypeOf(e);
})(e);
}
function m(e, t, n) {
function O(e, t, n) {
return (
t in e
? Object.defineProperty(e, t, {
@@ -315,8 +315,8 @@
);
}
var h = { TOP: "top", BOTTOM: "bottom", NONE: "none" },
C = { STRICT: "strict", LAX: "lax", NONE: "none" },
g = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
g = { STRICT: "strict", LAX: "lax", NONE: "none" },
C = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
S = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j,
t = l().get(e);
@@ -343,14 +343,14 @@
(e.prototype = Object.create(t && t.prototype, {
constructor: { value: e, writable: !0, configurable: !0 },
})),
t && y(e, t);
})(a, e);
t && d(e, t);
})(s, e);
var n,
o,
r,
i,
c =
((r = a),
((r = s),
(i = (function () {
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
if (Reflect.construct.sham) return !1;
@@ -368,20 +368,20 @@
})()),
function () {
var e,
t = O(r);
t = m(r);
if (i) {
var n = O(this).constructor;
var n = m(this).constructor;
e = Reflect.construct(t, arguments, n);
} else e = t.apply(this, arguments);
return d(this, e);
return y(this, e);
});
function a(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, a),
m(v((t = c.call(this, e))), "handleScroll", function () {
})(this, s),
O(v((t = c.call(this, e))), "handleScroll", function () {
var e = t.props.acceptOnScrollPercentage,
n = document.documentElement,
o = document.body,
@@ -389,7 +389,7 @@
i = "scrollHeight";
((n[r] || o[r]) / ((n[i] || o[i]) - n.clientHeight)) * 100 > e && t.accept(!0);
}),
m(v(t), "removeScrollListener", function () {
O(v(t), "removeScrollListener", function () {
t.props.acceptOnScroll && window.removeEventListener("scroll", t.handleScroll);
}),
(t.state = {
@@ -443,7 +443,7 @@
);
}
return (
(n = a),
(n = s),
(o = [
{
key: "componentDidMount",
@@ -475,15 +475,6 @@
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 () {
@@ -506,8 +497,8 @@
i = n.sameSite,
c = this.props.cookieSecurity;
void 0 === c && (c = !location || "https:" === location.protocol);
var a = f(f({ expires: r }, o), {}, { sameSite: i, secure: c });
i === C.NONE && l().set(x(e), t, a), l().set(e, t, a);
var s = f(f({ expires: r }, o), {}, { sameSite: i, secure: c });
i === g.NONE && l().set(x(e), t, s), l().set(e, t, s);
},
},
{
@@ -522,9 +513,9 @@
value: function () {
var e = this;
switch (this.props.visible) {
case g.HIDDEN:
case C.HIDDEN:
return null;
case g.BY_COOKIE_VALUE:
case C.BY_COOKIE_VALUE:
if (!this.state.visible) return null;
}
var n = this.props,
@@ -533,16 +524,16 @@
i = n.buttonStyle,
c = n.declineButtonStyle,
l = n.contentStyle,
a = n.disableStyles,
s = n.buttonText,
s = n.disableStyles,
a = n.buttonText,
p = n.declineButtonText,
b = n.containerClasses,
y = n.contentClasses,
d = n.buttonClasses,
d = n.contentClasses,
y = n.buttonClasses,
v = n.buttonWrapperClasses,
O = n.declineButtonClasses,
m = n.buttonId,
C = n.declineButtonId,
m = n.declineButtonClasses,
O = n.buttonId,
g = n.declineButtonId,
S = n.disableButtonStyles,
k = n.enableDeclineButton,
x = n.flipButtons,
@@ -560,7 +551,7 @@
L = {},
V = {};
switch (
(a
(s
? ((A = u({}, r)),
(N = u({}, i)),
(R = u({}, c)),
@@ -590,8 +581,8 @@
{
key: "declineButton",
style: R,
className: O,
id: C,
className: m,
id: g,
"aria-label": D,
onClick: function () {
e.decline();
@@ -606,14 +597,14 @@
{
key: "acceptButton",
style: N,
className: d,
id: m,
className: y,
id: O,
"aria-label": P,
onClick: function () {
e.accept();
},
},
s
a
)
),
x && U.reverse(),
@@ -621,18 +612,8 @@
w,
{
condition: T,
wrapper: function (n) {
return t().createElement(
"div",
{
style: V,
className: B,
onClick: function () {
e.overlayClick();
},
},
n
);
wrapper: function (e) {
return t().createElement("div", { style: V, className: B }, e);
},
},
t().createElement(
@@ -640,7 +621,7 @@
u({ className: "".concat(b), style: A }, I),
t().createElement(
"div",
u({ style: L, className: y }, _),
u({ style: L, className: d }, _),
this.props.children
),
t().createElement(
@@ -656,7 +637,7 @@
},
},
]) && b(n.prototype, o),
a
s
);
})(e.Component);
(T.propTypes = {
@@ -666,13 +647,13 @@
})
),
visible: i().oneOf(
Object.keys(g).map(function (e) {
return g[e];
Object.keys(C).map(function (e) {
return C[e];
})
),
sameSite: i().oneOf(
Object.keys(C).map(function (e) {
return C[e];
Object.keys(g).map(function (e) {
return g[e];
})
),
style: i().object,
@@ -709,8 +690,6 @@
overlay: i().bool,
overlayClasses: i().string,
overlayStyle: i().object,
onOverlayClick: i().func,
acceptOnOverlayClick: i().bool,
ariaAcceptLabel: i().string,
ariaDeclineLabel: i().string,
acceptOnScroll: i().bool,
@@ -723,7 +702,7 @@
hideOnAccept: !0,
hideOnDecline: !0,
location: h.BOTTOM,
visible: g.BY_COOKIE_VALUE,
visible: C.BY_COOKIE_VALUE,
onAccept: function () {},
onDecline: function () {},
cookieName: j,
@@ -745,7 +724,7 @@
disableButtonStyles: !1,
enableDeclineButton: !1,
flipButtons: !1,
sameSite: C.LAX,
sameSite: g.LAX,
ButtonComponent: function (e) {
var n = e.children,
o = (function (e, t) {
@@ -769,13 +748,11 @@
(Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]));
}
return r;
})(e, s);
})(e, a);
return t().createElement("button", o, n);
},
overlay: !1,
overlayClasses: "",
onOverlayClick: function () {},
acceptOnOverlayClick: !1,
ariaAcceptLabel: "Accept cookies",
ariaDeclineLabel: "Decline cookies",
acceptOnScroll: !1,

4
package-lock.json generated
View File

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

View File

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

1
src/index.d.ts vendored
View File

@@ -13,7 +13,6 @@ export interface CookieConsentProps {
children?: React.ReactNode;
disableStyles?: boolean;
hideOnAccept?: boolean;
hideOnDecline?: boolean;
onAccept?: (acceptedByScrolling?: boolean) => void;
onDecline?: Function;
buttonText?: Function | React.ReactNode;