mirror of
https://github.com/Mastermindzh/react-cookie-consent.git
synced 2025-01-20 18:41:44 +01:00
Fix #56 - add acceptedByScrolling to onAccept
Checking the {acceptedByScrolling} boolean property will allow you to determine whether the acceptance was triggered by the user scrolling (if acceptedByScrolling=true) or explicitly clicking the Accept button (if acceptedByScrolling=false).
This commit is contained in:
parent
9980d42af6
commit
7cc1fc3905
14
README.md
14
README.md
@ -64,11 +64,19 @@ You can optionally set some props like this (next chapter will show all props):
|
|||||||
</CookieConsent>
|
</CookieConsent>
|
||||||
```
|
```
|
||||||
|
|
||||||
One of the props (onAccept) is a function, this function will be called after the user has clicked the accept button. You can provide a function like so:
|
One of the props (onAccept) is a function, this function will be called after the user has clicked the accept button. It is called with an object containing a boolean property `acceptedByScrolling` to indicate if the acceptance was triggered by the user scrolling. You can provide a function like so:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
<CookieConsent
|
<CookieConsent
|
||||||
onAccept={() => {alert("yay!")}}
|
acceptOnScroll={true}
|
||||||
|
onAccept={({ acceptedByScrolling }) => {
|
||||||
|
if (acceptedByScrolling) {
|
||||||
|
// triggered if user scrolls past threshold
|
||||||
|
alert("Accept was triggered by user scrolling");
|
||||||
|
} else {
|
||||||
|
alert("Accept was triggered by clicking the Accept button");
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
</CookieConsent>
|
</CookieConsent>
|
||||||
@ -100,7 +108,7 @@ If the decline button is enabled then the (onDecline) prop function can be used,
|
|||||||
| cookieValue | string or boolean or number | true | Value to be saved under the cookieName. |
|
| cookieValue | string or boolean or number | true | Value to be saved under the cookieName. |
|
||||||
| declineCookieValue | string or boolean or number | false | Value to be saved under the cookieName when declined. |
|
| declineCookieValue | string or boolean or number | false | Value to be saved under the cookieName when declined. |
|
||||||
| setDeclineCookie | boolean | true | Whether to set a cookie when the user clicks "decline" |
|
| setDeclineCookie | boolean | true | Whether to set a cookie when the user clicks "decline" |
|
||||||
| onAccept | function | `() => {}` | Function to be called after the accept button has been clicked. |
|
| onAccept | function | `({ acceptedByScrolling }) => {}` | Function to be called after the accept button has been clicked. |
|
||||||
| onDecline | function | `() => {}` | Function to be called after the decline button has been clicked. |
|
| onDecline | function | `() => {}` | Function to be called after the decline button has been clicked. |
|
||||||
| debug | boolean | undefined | Bar will be drawn regardless of cookie for debugging purposes. |
|
| debug | boolean | undefined | Bar will be drawn regardless of cookie for debugging purposes. |
|
||||||
| expires | number | 365 | Number of days before the cookie expires. |
|
| expires | number | 365 | Number of days before the cookie expires. |
|
||||||
|
2
build/index.d.ts
vendored
2
build/index.d.ts
vendored
@ -10,7 +10,7 @@ export interface CookieConsentProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
disableStyles?: boolean;
|
disableStyles?: boolean;
|
||||||
hideOnAccept?: boolean;
|
hideOnAccept?: boolean;
|
||||||
onAccept?: Function;
|
onAccept?: ({ acceptedByScrolling }: { acceptedByScrolling?: boolean }) => void;
|
||||||
onDecline?: Function;
|
onDecline?: Function;
|
||||||
buttonText?: Function | React.ReactNode;
|
buttonText?: Function | React.ReactNode;
|
||||||
declineButtonText?: Function | React.ReactNode;
|
declineButtonText?: Function | React.ReactNode;
|
||||||
|
235
build/index.js
235
build/index.js
@ -296,14 +296,14 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
||||||
* JavaScript Cookie v2.2.0
|
* JavaScript Cookie v2.2.1
|
||||||
* https://github.com/js-cookie/js-cookie
|
* https://github.com/js-cookie/js-cookie
|
||||||
*
|
*
|
||||||
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
||||||
* Released under the MIT license
|
* Released under the MIT license
|
||||||
*/
|
*/
|
||||||
;(function (factory) {
|
;(function (factory) {
|
||||||
var registeredInModuleLoader = false;
|
var registeredInModuleLoader;
|
||||||
if (true) {
|
if (true) {
|
||||||
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
||||||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
||||||
@ -337,126 +337,124 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decode (s) {
|
||||||
|
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
||||||
|
}
|
||||||
|
|
||||||
function init (converter) {
|
function init (converter) {
|
||||||
function api (key, value, attributes) {
|
function api() {}
|
||||||
var result;
|
|
||||||
|
function set (key, value, attributes) {
|
||||||
if (typeof document === 'undefined') {
|
if (typeof document === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write
|
attributes = extend({
|
||||||
|
path: '/'
|
||||||
|
}, api.defaults, attributes);
|
||||||
|
|
||||||
if (arguments.length > 1) {
|
if (typeof attributes.expires === 'number') {
|
||||||
attributes = extend({
|
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
|
||||||
path: '/'
|
|
||||||
}, api.defaults, attributes);
|
|
||||||
|
|
||||||
if (typeof attributes.expires === 'number') {
|
|
||||||
var expires = new Date();
|
|
||||||
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
|
|
||||||
attributes.expires = expires;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're using "expires" because "max-age" is not supported by IE
|
|
||||||
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = JSON.stringify(value);
|
|
||||||
if (/^[\{\[]/.test(result)) {
|
|
||||||
value = result;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (!converter.write) {
|
|
||||||
value = encodeURIComponent(String(value))
|
|
||||||
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
|
||||||
} else {
|
|
||||||
value = converter.write(value, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
key = encodeURIComponent(String(key));
|
|
||||||
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
|
||||||
key = key.replace(/[\(\)]/g, escape);
|
|
||||||
|
|
||||||
var stringifiedAttributes = '';
|
|
||||||
|
|
||||||
for (var attributeName in attributes) {
|
|
||||||
if (!attributes[attributeName]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
stringifiedAttributes += '; ' + attributeName;
|
|
||||||
if (attributes[attributeName] === true) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
stringifiedAttributes += '=' + attributes[attributeName];
|
|
||||||
}
|
|
||||||
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read
|
// We're using "expires" because "max-age" is not supported by IE
|
||||||
|
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
||||||
|
|
||||||
if (!key) {
|
try {
|
||||||
result = {};
|
var result = JSON.stringify(value);
|
||||||
|
if (/^[\{\[]/.test(result)) {
|
||||||
|
value = result;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
value = converter.write ?
|
||||||
|
converter.write(value, key) :
|
||||||
|
encodeURIComponent(String(value))
|
||||||
|
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
||||||
|
|
||||||
|
key = encodeURIComponent(String(key))
|
||||||
|
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
|
||||||
|
.replace(/[\(\)]/g, escape);
|
||||||
|
|
||||||
|
var stringifiedAttributes = '';
|
||||||
|
for (var attributeName in attributes) {
|
||||||
|
if (!attributes[attributeName]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
stringifiedAttributes += '; ' + attributeName;
|
||||||
|
if (attributes[attributeName] === true) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Considers RFC 6265 section 5.2:
|
||||||
|
// ...
|
||||||
|
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
||||||
|
// character:
|
||||||
|
// Consume the characters of the unparsed-attributes up to,
|
||||||
|
// not including, the first %x3B (";") character.
|
||||||
|
// ...
|
||||||
|
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get (key, json) {
|
||||||
|
if (typeof document === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jar = {};
|
||||||
// To prevent the for loop in the first place assign an empty array
|
// To prevent the for loop in the first place assign an empty array
|
||||||
// in case there are no cookies at all. Also prevents odd result when
|
// in case there are no cookies at all.
|
||||||
// calling "get()"
|
|
||||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||||
var rdecode = /(%[0-9A-Z]{2})+/g;
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
for (; i < cookies.length; i++) {
|
for (; i < cookies.length; i++) {
|
||||||
var parts = cookies[i].split('=');
|
var parts = cookies[i].split('=');
|
||||||
var cookie = parts.slice(1).join('=');
|
var cookie = parts.slice(1).join('=');
|
||||||
|
|
||||||
if (!this.json && cookie.charAt(0) === '"') {
|
if (!json && cookie.charAt(0) === '"') {
|
||||||
cookie = cookie.slice(1, -1);
|
cookie = cookie.slice(1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var name = parts[0].replace(rdecode, decodeURIComponent);
|
var name = decode(parts[0]);
|
||||||
cookie = converter.read ?
|
cookie = (converter.read || converter)(cookie, name) ||
|
||||||
converter.read(cookie, name) : converter(cookie, name) ||
|
decode(cookie);
|
||||||
cookie.replace(rdecode, decodeURIComponent);
|
|
||||||
|
|
||||||
if (this.json) {
|
if (json) {
|
||||||
try {
|
try {
|
||||||
cookie = JSON.parse(cookie);
|
cookie = JSON.parse(cookie);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === name) {
|
jar[name] = cookie;
|
||||||
result = cookie;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!key) {
|
if (key === name) {
|
||||||
result[name] = cookie;
|
break;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return key ? jar[key] : jar;
|
||||||
}
|
}
|
||||||
|
|
||||||
api.set = api;
|
api.set = set;
|
||||||
api.get = function (key) {
|
api.get = function (key) {
|
||||||
return api.call(api, key);
|
return get(key, false /* read as raw */);
|
||||||
};
|
};
|
||||||
api.getJSON = function () {
|
api.getJSON = function (key) {
|
||||||
return api.apply({
|
return get(key, true /* read as json */);
|
||||||
json: true
|
|
||||||
}, [].slice.call(arguments));
|
|
||||||
};
|
};
|
||||||
api.defaults = {};
|
|
||||||
|
|
||||||
api.remove = function (key, attributes) {
|
api.remove = function (key, attributes) {
|
||||||
api(key, '', extend(attributes, {
|
set(key, '', extend(attributes, {
|
||||||
expires: -1
|
expires: -1
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
api.defaults = {};
|
||||||
|
|
||||||
api.withConverter = init;
|
api.withConverter = init;
|
||||||
|
|
||||||
return api;
|
return api;
|
||||||
@ -639,7 +637,7 @@ var CookieConsent = function (_Component) {
|
|||||||
var percentage = (rootNode[top] || body[top]) / ((rootNode[height] || body[height]) - rootNode.clientHeight) * 100;
|
var percentage = (rootNode[top] || body[top]) / ((rootNode[height] || body[height]) - rootNode.clientHeight) * 100;
|
||||||
|
|
||||||
if (percentage > this.props.acceptOnScrollPercentage) {
|
if (percentage > this.props.acceptOnScrollPercentage) {
|
||||||
this.accept();
|
this.accept({ acceptedByScrolling: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,7 +647,9 @@ var CookieConsent = function (_Component) {
|
|||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: "accept",
|
key: "accept",
|
||||||
value: function accept() {
|
value: function accept(_ref) {
|
||||||
|
var _ref$acceptedByScroll = _ref.acceptedByScrolling,
|
||||||
|
acceptedByScrolling = _ref$acceptedByScroll === undefined ? false : _ref$acceptedByScroll;
|
||||||
var _props2 = this.props,
|
var _props2 = this.props,
|
||||||
cookieName = _props2.cookieName,
|
cookieName = _props2.cookieName,
|
||||||
cookieValue = _props2.cookieValue,
|
cookieValue = _props2.cookieValue,
|
||||||
@ -660,7 +660,7 @@ var CookieConsent = function (_Component) {
|
|||||||
|
|
||||||
// fire onAccept
|
// fire onAccept
|
||||||
|
|
||||||
onAccept();
|
onAccept({ acceptedByScrolling: acceptedByScrolling });
|
||||||
|
|
||||||
// remove listener if set
|
// remove listener if set
|
||||||
window.removeEventListener("scroll", this.handleScroll);
|
window.removeEventListener("scroll", this.handleScroll);
|
||||||
@ -797,7 +797,7 @@ var CookieConsent = function (_Component) {
|
|||||||
className: buttonClasses,
|
className: buttonClasses,
|
||||||
id: buttonId,
|
id: buttonId,
|
||||||
onClick: function onClick() {
|
onClick: function onClick() {
|
||||||
_this2.accept();
|
_this2.accept({ acceptedByScrolling: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buttonText
|
buttonText
|
||||||
@ -889,9 +889,9 @@ CookieConsent.defaultProps = {
|
|||||||
disableButtonStyles: false,
|
disableButtonStyles: false,
|
||||||
enableDeclineButton: false,
|
enableDeclineButton: false,
|
||||||
flipButtons: false,
|
flipButtons: false,
|
||||||
ButtonComponent: function ButtonComponent(_ref) {
|
ButtonComponent: function ButtonComponent(_ref2) {
|
||||||
var children = _ref.children,
|
var children = _ref2.children,
|
||||||
props = _objectWithoutProperties(_ref, ["children"]);
|
props = _objectWithoutProperties(_ref2, ["children"]);
|
||||||
|
|
||||||
return _react2.default.createElement(
|
return _react2.default.createElement(
|
||||||
"button",
|
"button",
|
||||||
@ -1786,7 +1786,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.8.6
|
/* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.12.0
|
||||||
* react-is.development.js
|
* react-is.development.js
|
||||||
*
|
*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
@ -1808,25 +1808,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|||||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||||
// nor polyfill, then a plain number is used for performance.
|
// nor polyfill, then a plain number is used for performance.
|
||||||
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
||||||
|
|
||||||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
||||||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
||||||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
||||||
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
||||||
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
||||||
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
||||||
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
||||||
|
// (unstable) APIs that have been removed. Can we remove the symbols?
|
||||||
|
|
||||||
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
||||||
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
||||||
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
||||||
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
||||||
|
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
||||||
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
||||||
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
||||||
|
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
||||||
|
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
||||||
|
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
||||||
|
|
||||||
function isValidElementType(type) {
|
function isValidElementType(type) {
|
||||||
return typeof type === 'string' || typeof type === 'function' ||
|
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
||||||
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
|
||||||
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1842,12 +1846,11 @@ function isValidElementType(type) {
|
|||||||
* paths. Removing the logging code for production environments will keep the
|
* paths. Removing the logging code for production environments will keep the
|
||||||
* same logic and follow the same code paths.
|
* same logic and follow the same code paths.
|
||||||
*/
|
*/
|
||||||
|
var lowPriorityWarningWithoutStack = function () {};
|
||||||
var lowPriorityWarning = function () {};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
var printWarning = function (format) {
|
var printWarning = function (format) {
|
||||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||||
args[_key - 1] = arguments[_key];
|
args[_key - 1] = arguments[_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1855,9 +1858,11 @@ var lowPriorityWarning = function () {};
|
|||||||
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
||||||
return args[argIndex++];
|
return args[argIndex++];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof console !== 'undefined') {
|
if (typeof console !== 'undefined') {
|
||||||
console.warn(message);
|
console.warn(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// --- Welcome to debugging React ---
|
// --- Welcome to debugging React ---
|
||||||
// This error was thrown as a convenience so that you can use this stack
|
// This error was thrown as a convenience so that you can use this stack
|
||||||
@ -1866,25 +1871,27 @@ var lowPriorityWarning = function () {};
|
|||||||
} catch (x) {}
|
} catch (x) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
lowPriorityWarning = function (condition, format) {
|
lowPriorityWarningWithoutStack = function (condition, format) {
|
||||||
if (format === undefined) {
|
if (format === undefined) {
|
||||||
throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
||||||
args[_key2 - 2] = arguments[_key2];
|
args[_key2 - 2] = arguments[_key2];
|
||||||
}
|
}
|
||||||
|
|
||||||
printWarning.apply(undefined, [format].concat(args));
|
printWarning.apply(void 0, [format].concat(args));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var lowPriorityWarning$1 = lowPriorityWarning;
|
var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
|
||||||
|
|
||||||
function typeOf(object) {
|
function typeOf(object) {
|
||||||
if (typeof object === 'object' && object !== null) {
|
if (typeof object === 'object' && object !== null) {
|
||||||
var $$typeof = object.$$typeof;
|
var $$typeof = object.$$typeof;
|
||||||
|
|
||||||
switch ($$typeof) {
|
switch ($$typeof) {
|
||||||
case REACT_ELEMENT_TYPE:
|
case REACT_ELEMENT_TYPE:
|
||||||
var type = object.type;
|
var type = object.type;
|
||||||
@ -1897,29 +1904,32 @@ function typeOf(object) {
|
|||||||
case REACT_STRICT_MODE_TYPE:
|
case REACT_STRICT_MODE_TYPE:
|
||||||
case REACT_SUSPENSE_TYPE:
|
case REACT_SUSPENSE_TYPE:
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
var $$typeofType = type && type.$$typeof;
|
var $$typeofType = type && type.$$typeof;
|
||||||
|
|
||||||
switch ($$typeofType) {
|
switch ($$typeofType) {
|
||||||
case REACT_CONTEXT_TYPE:
|
case REACT_CONTEXT_TYPE:
|
||||||
case REACT_FORWARD_REF_TYPE:
|
case REACT_FORWARD_REF_TYPE:
|
||||||
|
case REACT_LAZY_TYPE:
|
||||||
|
case REACT_MEMO_TYPE:
|
||||||
case REACT_PROVIDER_TYPE:
|
case REACT_PROVIDER_TYPE:
|
||||||
return $$typeofType;
|
return $$typeofType;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $$typeof;
|
return $$typeof;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
case REACT_LAZY_TYPE:
|
|
||||||
case REACT_MEMO_TYPE:
|
|
||||||
case REACT_PORTAL_TYPE:
|
case REACT_PORTAL_TYPE:
|
||||||
return $$typeof;
|
return $$typeof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
} // AsyncMode is deprecated along with isAsyncMode
|
||||||
|
|
||||||
// AsyncMode is deprecated along with isAsyncMode
|
|
||||||
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
||||||
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
||||||
var ContextConsumer = REACT_CONTEXT_TYPE;
|
var ContextConsumer = REACT_CONTEXT_TYPE;
|
||||||
@ -1933,17 +1943,16 @@ var Portal = REACT_PORTAL_TYPE;
|
|||||||
var Profiler = REACT_PROFILER_TYPE;
|
var Profiler = REACT_PROFILER_TYPE;
|
||||||
var StrictMode = REACT_STRICT_MODE_TYPE;
|
var StrictMode = REACT_STRICT_MODE_TYPE;
|
||||||
var Suspense = REACT_SUSPENSE_TYPE;
|
var Suspense = REACT_SUSPENSE_TYPE;
|
||||||
|
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
||||||
|
|
||||||
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
|
||||||
|
|
||||||
// AsyncMode should be deprecated
|
|
||||||
function isAsyncMode(object) {
|
function isAsyncMode(object) {
|
||||||
{
|
{
|
||||||
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
||||||
hasWarnedAboutDeprecatedIsAsyncMode = true;
|
hasWarnedAboutDeprecatedIsAsyncMode = true;
|
||||||
lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
lowPriorityWarningWithoutStack$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
||||||
}
|
}
|
||||||
function isConcurrentMode(object) {
|
function isConcurrentMode(object) {
|
||||||
@ -2021,7 +2030,7 @@ exports.isSuspense = isSuspense;
|
|||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/** @license React v16.8.6
|
/** @license React v16.12.0
|
||||||
* react-is.production.min.js
|
* react-is.production.min.js
|
||||||
*
|
*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
@ -2031,11 +2040,11 @@ exports.isSuspense = isSuspense;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Object.defineProperty(exports,"__esModule",{value:!0});
|
Object.defineProperty(exports,"__esModule",{value:!0});
|
||||||
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"):
|
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
|
||||||
60115,r=b?Symbol.for("react.lazy"):60116;function t(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case r:case q:case d:return u}}}function v(a){return t(a)===m}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;
|
60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118,x=b?Symbol.for("react.scope"):60119;function y(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function z(a){return y(a)===m}
|
||||||
exports.Fragment=e;exports.Lazy=r;exports.Memo=q;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||t(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return t(a)===k};
|
exports.typeOf=y;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
|
||||||
exports.isContextProvider=function(a){return t(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===n};exports.isFragment=function(a){return t(a)===e};exports.isLazy=function(a){return t(a)===r};exports.isMemo=function(a){return t(a)===q};exports.isPortal=function(a){return t(a)===d};exports.isProfiler=function(a){return t(a)===g};exports.isStrictMode=function(a){return t(a)===f};
|
exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w||a.$$typeof===x)};exports.isAsyncMode=function(a){return z(a)||y(a)===l};exports.isConcurrentMode=z;exports.isContextConsumer=function(a){return y(a)===k};exports.isContextProvider=function(a){return y(a)===h};
|
||||||
exports.isSuspense=function(a){return t(a)===p};
|
exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return y(a)===n};exports.isFragment=function(a){return y(a)===e};exports.isLazy=function(a){return y(a)===t};exports.isMemo=function(a){return y(a)===r};exports.isPortal=function(a){return y(a)===d};exports.isProfiler=function(a){return y(a)===g};exports.isStrictMode=function(a){return y(a)===f};exports.isSuspense=function(a){return y(a)===p};
|
||||||
|
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
2
src/index.d.ts
vendored
2
src/index.d.ts
vendored
@ -10,7 +10,7 @@ export interface CookieConsentProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
disableStyles?: boolean;
|
disableStyles?: boolean;
|
||||||
hideOnAccept?: boolean;
|
hideOnAccept?: boolean;
|
||||||
onAccept?: Function;
|
onAccept?: ({ acceptedByScrolling }: { acceptedByScrolling?: boolean }) => void;
|
||||||
onDecline?: Function;
|
onDecline?: Function;
|
||||||
buttonText?: Function | React.ReactNode;
|
buttonText?: Function | React.ReactNode;
|
||||||
declineButtonText?: Function | React.ReactNode;
|
declineButtonText?: Function | React.ReactNode;
|
||||||
|
@ -93,14 +93,14 @@ class CookieConsent extends Component {
|
|||||||
100;
|
100;
|
||||||
|
|
||||||
if (percentage > this.props.acceptOnScrollPercentage) {
|
if (percentage > this.props.acceptOnScrollPercentage) {
|
||||||
this.accept();
|
this.accept({ acceptedByScrolling: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a persistent accept cookie
|
* Set a persistent accept cookie
|
||||||
*/
|
*/
|
||||||
accept() {
|
accept({ acceptedByScrolling = false }) {
|
||||||
const {
|
const {
|
||||||
cookieName,
|
cookieName,
|
||||||
cookieValue,
|
cookieValue,
|
||||||
@ -111,7 +111,7 @@ class CookieConsent extends Component {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
// fire onAccept
|
// fire onAccept
|
||||||
onAccept();
|
onAccept({ acceptedByScrolling });
|
||||||
|
|
||||||
// remove listener if set
|
// remove listener if set
|
||||||
window.removeEventListener("scroll", this.handleScroll);
|
window.removeEventListener("scroll", this.handleScroll);
|
||||||
@ -245,7 +245,7 @@ class CookieConsent extends Component {
|
|||||||
className={buttonClasses}
|
className={buttonClasses}
|
||||||
id={buttonId}
|
id={buttonId}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.accept();
|
this.accept({ acceptedByScrolling: false });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{buttonText}
|
{buttonText}
|
||||||
|
Loading…
Reference in New Issue
Block a user