mirror of
https://github.com/Mastermindzh/react-cookie-consent.git
synced 2025-08-23 09:35:04 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
413abc7fd8 | ||
2a1e52b24a | |||
775ec9db96 | |||
eaaf6f8797 | |||
8c86599f24 |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -5,7 +5,24 @@ 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.0.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1)]
|
## [[7.2.0]](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.2.0)
|
||||||
|
|
||||||
|
- Added `onOverlayClick` which allows you to react to a click on the overlay
|
||||||
|
- Added `acceptOnOverlayClick` which accepts the cookies when the overlay is clicked and runs `onOverlayClick`
|
||||||
|
|
||||||
|
## [[7.1.1]](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.1.1)
|
||||||
|
|
||||||
|
- `customContentAttributes` and `customContainerAttributes` are now optional in the typing file as they should be
|
||||||
|
|
||||||
|
## [[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
|
- Switched from CommonJS to UMD module
|
||||||
|
|
||||||
|
@@ -138,7 +138,7 @@ That option would be interesting if you want to allow user to change their conse
|
|||||||
## Props
|
## Props
|
||||||
|
|
||||||
| Prop | Type | Default value | Description |
|
| Prop | Type | Default value | Description |
|
||||||
| ------------------------ | :-----------------------------------------: | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------- | :-----------------------------------------: | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| location | string, "top", "bottom" or "none" | "bottom" | Syntactic sugar to easily enable you to place the bar at the top or the bottom of the browser window. Use "none" to disable. |
|
| location | string, "top", "bottom" or "none" | "bottom" | Syntactic sugar to easily enable you to place the bar at the top or the bottom of the browser window. Use "none" to disable. |
|
||||||
| visible | string, "show", "hidden" or "byCookieValue" | "byCookieValue" | Force the consent bar visibility. If "byCookieValue", visibility are defined by cookie consent existence. |
|
| visible | string, "show", "hidden" or "byCookieValue" | "byCookieValue" | Force the consent bar visibility. If "byCookieValue", visibility are defined by cookie consent existence. |
|
||||||
| children | string or React component | | Content to appear inside the bar |
|
| children | string or React component | | Content to appear inside the bar |
|
||||||
@@ -174,11 +174,15 @@ 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 |
|
||||||
|
| onOverlayClick | function | `() => {}` | allows you to react to a click on the overlay |
|
||||||
|
| acceptOnOverlayClick | boolean | false | Determines whether the cookies should be accepted after clicking on the overlay |
|
||||||
|
|
||||||
## Debugging it
|
## Debugging it
|
||||||
|
|
||||||
|
4
build/index.d.ts
vendored
4
build/index.d.ts
vendored
@@ -38,10 +38,14 @@ export interface CookieConsentProps {
|
|||||||
overlay?: boolean;
|
overlay?: boolean;
|
||||||
overlayClasses?: string;
|
overlayClasses?: string;
|
||||||
overlayStyle?: object;
|
overlayStyle?: object;
|
||||||
|
onOverlayClick?: () => void;
|
||||||
|
acceptOnOverlayClick?: boolean;
|
||||||
ariaAcceptLabel?: string;
|
ariaAcceptLabel?: string;
|
||||||
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, {}> {}
|
||||||
|
177
build/index.js
177
build/index.js
@@ -7,7 +7,7 @@
|
|||||||
: "object" == typeof exports
|
: "object" == typeof exports
|
||||||
? (exports.ReactCookieConsent = t())
|
? (exports.ReactCookieConsent = t())
|
||||||
: (e.ReactCookieConsent = t());
|
: (e.ReactCookieConsent = t());
|
||||||
})(self, function () {
|
})("undefined" != typeof self ? self : this, function () {
|
||||||
return (function () {
|
return (function () {
|
||||||
var e = {
|
var e = {
|
||||||
808: function (e, t, n) {
|
808: function (e, t, n) {
|
||||||
@@ -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 C;
|
||||||
},
|
},
|
||||||
VISIBLE_OPTIONS: function () {
|
VISIBLE_OPTIONS: function () {
|
||||||
return S;
|
return g;
|
||||||
},
|
},
|
||||||
default: function () {
|
default: function () {
|
||||||
return B;
|
return B;
|
||||||
},
|
},
|
||||||
getCookieConsentValue: function () {
|
getCookieConsentValue: function () {
|
||||||
return C;
|
return S;
|
||||||
},
|
},
|
||||||
resetCookieConsentValue: function () {
|
resetCookieConsentValue: function () {
|
||||||
return k;
|
return k;
|
||||||
@@ -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]);
|
m(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,14 +276,14 @@
|
|||||||
Object.defineProperty(e, o.key, o);
|
Object.defineProperty(e, o.key, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function b(e, t) {
|
function y(e, t) {
|
||||||
return (b =
|
return (y =
|
||||||
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 d(e, t) {
|
||||||
if (t && ("object" === a(t) || "function" == typeof t)) return t;
|
if (t && ("object" === a(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");
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
return e.__proto__ || Object.getPrototypeOf(e);
|
return e.__proto__ || Object.getPrototypeOf(e);
|
||||||
})(e);
|
})(e);
|
||||||
}
|
}
|
||||||
function h(e, t, n) {
|
function m(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" },
|
C = { STRICT: "strict", LAX: "lax", NONE: "none" },
|
||||||
S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
|
g = { 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,7 +343,7 @@
|
|||||||
(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 && y(e, t);
|
||||||
})(a, e);
|
})(a, e);
|
||||||
var n,
|
var n,
|
||||||
o,
|
o,
|
||||||
@@ -373,7 +373,7 @@
|
|||||||
var n = O(this).constructor;
|
var n = O(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 d(this, e);
|
||||||
});
|
});
|
||||||
function a(e) {
|
function a(e) {
|
||||||
var t;
|
var t;
|
||||||
@@ -381,7 +381,7 @@
|
|||||||
(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, a),
|
||||||
h(v((t = c.call(this, e))), "handleScroll", function () {
|
m(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 () {
|
m(v(t), "removeScrollListener", function () {
|
||||||
t.props.acceptOnScroll && window.removeEventListener("scroll", t.handleScroll);
|
t.props.acceptOnScroll && window.removeEventListener("scroll", t.handleScroll);
|
||||||
}),
|
}),
|
||||||
(t.state = {
|
(t.state = {
|
||||||
@@ -475,6 +475,15 @@
|
|||||||
r && (this.setState({ visible: !1 }), this.removeScrollListener());
|
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",
|
key: "decline",
|
||||||
value: function () {
|
value: function () {
|
||||||
@@ -498,14 +507,14 @@
|
|||||||
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 a = f(f({ expires: r }, o), {}, { sameSite: i, secure: c });
|
||||||
i === g.NONE && l().set(x(e), t, a), l().set(e, t, a);
|
i === C.NONE && l().set(x(e), t, a), l().set(e, t, a);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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 +522,9 @@
|
|||||||
value: function () {
|
value: function () {
|
||||||
var e = this;
|
var e = this;
|
||||||
switch (this.props.visible) {
|
switch (this.props.visible) {
|
||||||
case S.HIDDEN:
|
case g.HIDDEN:
|
||||||
return null;
|
return null;
|
||||||
case S.BY_COOKIE_VALUE:
|
case g.BY_COOKIE_VALUE:
|
||||||
if (!this.state.visible) return null;
|
if (!this.state.visible) return null;
|
||||||
}
|
}
|
||||||
var n = this.props,
|
var n = this.props,
|
||||||
@@ -527,14 +536,14 @@
|
|||||||
a = n.disableStyles,
|
a = n.disableStyles,
|
||||||
s = n.buttonText,
|
s = n.buttonText,
|
||||||
p = n.declineButtonText,
|
p = n.declineButtonText,
|
||||||
d = n.containerClasses,
|
b = n.containerClasses,
|
||||||
b = n.contentClasses,
|
y = n.contentClasses,
|
||||||
y = n.buttonClasses,
|
d = n.buttonClasses,
|
||||||
v = n.buttonWrapperClasses,
|
v = n.buttonWrapperClasses,
|
||||||
O = n.declineButtonClasses,
|
O = n.declineButtonClasses,
|
||||||
h = n.buttonId,
|
m = n.buttonId,
|
||||||
g = n.declineButtonId,
|
C = 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,44 +552,46 @@
|
|||||||
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
|
(a
|
||||||
? ((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: O,
|
||||||
id: g,
|
id: C,
|
||||||
"aria-label": D,
|
"aria-label": D,
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
e.decline();
|
e.decline();
|
||||||
@@ -589,14 +600,14 @@
|
|||||||
p
|
p
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
L.push(
|
U.push(
|
||||||
t().createElement(
|
t().createElement(
|
||||||
j,
|
j,
|
||||||
{
|
{
|
||||||
key: "acceptButton",
|
key: "acceptButton",
|
||||||
style: _,
|
style: N,
|
||||||
className: y,
|
className: d,
|
||||||
id: h,
|
id: m,
|
||||||
"aria-label": P,
|
"aria-label": P,
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
e.accept();
|
e.accept();
|
||||||
@@ -605,23 +616,37 @@
|
|||||||
s
|
s
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
x && L.reverse(),
|
x && U.reverse(),
|
||||||
t().createElement(
|
t().createElement(
|
||||||
w,
|
w,
|
||||||
{
|
{
|
||||||
condition: T,
|
condition: T,
|
||||||
wrapper: function (e) {
|
wrapper: function (n) {
|
||||||
return t().createElement("div", { style: A, className: B }, e);
|
return t().createElement(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
style: V,
|
||||||
|
className: B,
|
||||||
|
onClick: function () {
|
||||||
|
e.overlayClick();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
n
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
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: y }, _),
|
||||||
|
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,24 +655,24 @@
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]) && d(n.prototype, o),
|
]) && b(n.prototype, o),
|
||||||
a
|
a
|
||||||
);
|
);
|
||||||
})(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(g).map(function (e) {
|
||||||
return S[e];
|
return g[e];
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
sameSite: i().oneOf(
|
sameSite: i().oneOf(
|
||||||
Object.keys(g).map(function (e) {
|
Object.keys(C).map(function (e) {
|
||||||
return g[e];
|
return C[e];
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
style: i().object,
|
style: i().object,
|
||||||
@@ -684,17 +709,21 @@
|
|||||||
overlay: i().bool,
|
overlay: i().bool,
|
||||||
overlayClasses: i().string,
|
overlayClasses: i().string,
|
||||||
overlayStyle: i().object,
|
overlayStyle: i().object,
|
||||||
|
onOverlayClick: i().func,
|
||||||
|
acceptOnOverlayClick: i().bool,
|
||||||
ariaAcceptLabel: i().string,
|
ariaAcceptLabel: i().string,
|
||||||
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: g.BY_COOKIE_VALUE,
|
||||||
onAccept: function () {},
|
onAccept: function () {},
|
||||||
onDecline: function () {},
|
onDecline: function () {},
|
||||||
cookieName: j,
|
cookieName: j,
|
||||||
@@ -716,7 +745,7 @@
|
|||||||
disableButtonStyles: !1,
|
disableButtonStyles: !1,
|
||||||
enableDeclineButton: !1,
|
enableDeclineButton: !1,
|
||||||
flipButtons: !1,
|
flipButtons: !1,
|
||||||
sameSite: g.LAX,
|
sameSite: C.LAX,
|
||||||
ButtonComponent: function (e) {
|
ButtonComponent: function (e) {
|
||||||
var n = e.children,
|
var n = e.children,
|
||||||
o = (function (e, t) {
|
o = (function (e, t) {
|
||||||
@@ -745,10 +774,14 @@
|
|||||||
},
|
},
|
||||||
overlay: !1,
|
overlay: !1,
|
||||||
overlayClasses: "",
|
overlayClasses: "",
|
||||||
|
onOverlayClick: function () {},
|
||||||
|
acceptOnOverlayClick: !1,
|
||||||
ariaAcceptLabel: "Accept cookies",
|
ariaAcceptLabel: "Accept cookies",
|
||||||
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
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "react-cookie-consent",
|
"name": "react-cookie-consent",
|
||||||
"version": "7.0.0",
|
"version": "7.2.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "7.0.0",
|
"version": "7.2.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"js-cookie": "^2.2.1",
|
"js-cookie": "^2.2.1",
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"name": "Rick van Lieshout",
|
"name": "Rick van Lieshout",
|
||||||
"email": "info@rickvanlieshout.com"
|
"email": "info@rickvanlieshout.com"
|
||||||
},
|
},
|
||||||
"version": "7.0.0",
|
"version": "7.2.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",
|
||||||
|
5
src/index.d.ts
vendored
5
src/index.d.ts
vendored
@@ -13,6 +13,7 @@ export interface CookieConsentProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
disableStyles?: boolean;
|
disableStyles?: boolean;
|
||||||
hideOnAccept?: boolean;
|
hideOnAccept?: boolean;
|
||||||
|
hideOnDecline?: boolean;
|
||||||
onAccept?: (acceptedByScrolling?: boolean) => void;
|
onAccept?: (acceptedByScrolling?: boolean) => void;
|
||||||
onDecline?: Function;
|
onDecline?: Function;
|
||||||
buttonText?: Function | React.ReactNode;
|
buttonText?: Function | React.ReactNode;
|
||||||
@@ -38,10 +39,14 @@ export interface CookieConsentProps {
|
|||||||
overlay?: boolean;
|
overlay?: boolean;
|
||||||
overlayClasses?: string;
|
overlayClasses?: string;
|
||||||
overlayStyle?: object;
|
overlayStyle?: object;
|
||||||
|
onOverlayClick?: () => void;
|
||||||
|
acceptOnOverlayClick?: boolean;
|
||||||
ariaAcceptLabel?: string;
|
ariaAcceptLabel?: string;
|
||||||
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, {}> {}
|
||||||
|
41
src/index.js
41
src/index.js
@@ -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
|
||||||
@@ -159,6 +159,17 @@ class CookieConsent extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a click on the overlay
|
||||||
|
*/
|
||||||
|
overlayClick() {
|
||||||
|
const { acceptOnOverlayClick, onOverlayClick } = this.props;
|
||||||
|
if (acceptOnOverlayClick) {
|
||||||
|
this.accept();
|
||||||
|
}
|
||||||
|
onOverlayClick();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a persistent decline cookie
|
* Set a persistent decline cookie
|
||||||
*/
|
*/
|
||||||
@@ -279,6 +290,8 @@ class CookieConsent extends Component {
|
|||||||
overlayStyle,
|
overlayStyle,
|
||||||
ariaAcceptLabel,
|
ariaAcceptLabel,
|
||||||
ariaDeclineLabel,
|
ariaDeclineLabel,
|
||||||
|
customContainerAttributes,
|
||||||
|
customContentAttributes,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let myStyle = {};
|
let myStyle = {};
|
||||||
@@ -367,13 +380,19 @@ class CookieConsent extends Component {
|
|||||||
<ConditionalWrapper
|
<ConditionalWrapper
|
||||||
condition={overlay}
|
condition={overlay}
|
||||||
wrapper={(children) => (
|
wrapper={(children) => (
|
||||||
<div style={myOverlayStyle} className={overlayClasses}>
|
<div
|
||||||
|
style={myOverlayStyle}
|
||||||
|
className={overlayClasses}
|
||||||
|
onClick={() => {
|
||||||
|
this.overlayClick();
|
||||||
|
}}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className={`${containerClasses}`} style={myStyle}>
|
<div className={`${containerClasses}`} style={myStyle} {...customContainerAttributes}>
|
||||||
<div style={myContentStyle} className={contentClasses}>
|
<div style={myContentStyle} className={contentClasses} {...customContentAttributes}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
<div className={`${buttonWrapperClasses}`}>
|
<div className={`${buttonWrapperClasses}`}>
|
||||||
@@ -425,10 +444,14 @@ CookieConsent.propTypes = {
|
|||||||
overlay: PropTypes.bool,
|
overlay: PropTypes.bool,
|
||||||
overlayClasses: PropTypes.string,
|
overlayClasses: PropTypes.string,
|
||||||
overlayStyle: PropTypes.object,
|
overlayStyle: PropTypes.object,
|
||||||
|
onOverlayClick: PropTypes.func,
|
||||||
|
acceptOnOverlayClick: PropTypes.bool,
|
||||||
ariaAcceptLabel: PropTypes.string,
|
ariaAcceptLabel: PropTypes.string,
|
||||||
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 = {
|
||||||
@@ -462,10 +485,14 @@ CookieConsent.defaultProps = {
|
|||||||
ButtonComponent: ({ children, ...props }) => <button {...props}>{children}</button>,
|
ButtonComponent: ({ children, ...props }) => <button {...props}>{children}</button>,
|
||||||
overlay: false,
|
overlay: false,
|
||||||
overlayClasses: "",
|
overlayClasses: "",
|
||||||
|
onOverlayClick: () => {},
|
||||||
|
acceptOnOverlayClick: false,
|
||||||
ariaAcceptLabel: "Accept cookies",
|
ariaAcceptLabel: "Accept cookies",
|
||||||
ariaDeclineLabel: "Decline cookies",
|
ariaDeclineLabel: "Decline cookies",
|
||||||
acceptOnScroll: false,
|
acceptOnScroll: false,
|
||||||
acceptOnScrollPercentage: 25,
|
acceptOnScrollPercentage: 25,
|
||||||
|
customContentAttributes: {},
|
||||||
|
customContainerAttributes: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CookieConsent;
|
export default CookieConsent;
|
||||||
|
@@ -13,6 +13,7 @@ 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: [
|
||||||
|
Reference in New Issue
Block a user