@micromag/core 0.3.708 → 0.3.709
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/contexts.js +18 -13
- package/package.json +2 -2
package/es/contexts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import isString from 'lodash/isString';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import React, { useContext, useMemo, useState,
|
|
4
|
+
import React, { useContext, useMemo, useState, useCallback, useEffect, useRef } from 'react';
|
|
5
5
|
import { ComponentsManager, PropTypes as PropTypes$1, FieldsManager, ScreensManager, ColorsParser, Tracking } from '@micromag/core';
|
|
6
6
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
7
|
import JSCookie from 'js-cookie';
|
|
@@ -322,13 +322,23 @@ var ConsentProvider = function ConsentProvider(_ref) {
|
|
|
322
322
|
expiration = _ref.expiration,
|
|
323
323
|
children = _ref.children;
|
|
324
324
|
// Has consented or not to cookies
|
|
325
|
-
var
|
|
326
|
-
var
|
|
325
|
+
var initialCookieConsented = JSCookie.get('has_consented') === 'true';
|
|
326
|
+
var baseConsented = initialConsented || initialCookieConsented;
|
|
327
|
+
var _useState = useState(baseConsented),
|
|
327
328
|
_useState2 = _slicedToArray(_useState, 2),
|
|
328
329
|
consented = _useState2[0],
|
|
329
|
-
|
|
330
|
+
setConsentedState = _useState2[1];
|
|
331
|
+
var setConsented = useCallback(function () {
|
|
332
|
+
var accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
333
|
+
var hasConsented = accept || false;
|
|
334
|
+
JSCookie.set('has_consented', hasConsented, {
|
|
335
|
+
secure: true,
|
|
336
|
+
expires: expiration
|
|
337
|
+
});
|
|
338
|
+
setConsentedState(hasConsented);
|
|
339
|
+
}, [expiration, setConsentedState]);
|
|
330
340
|
useEffect(function () {
|
|
331
|
-
if (initialConsented) {
|
|
341
|
+
if (initialConsented === true || initialConsented === false) {
|
|
332
342
|
setConsented(initialConsented);
|
|
333
343
|
}
|
|
334
344
|
}, [initialConsented, setConsented]);
|
|
@@ -359,12 +369,6 @@ var ConsentProvider = function ConsentProvider(_ref) {
|
|
|
359
369
|
var setConsent = useCallback(function () {
|
|
360
370
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
361
371
|
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
362
|
-
var hasConsented = values !== null && typeof values !== 'undefined';
|
|
363
|
-
JSCookie.set('has_consented', hasConsented, {
|
|
364
|
-
secure: true,
|
|
365
|
-
expires: expiration
|
|
366
|
-
});
|
|
367
|
-
setConsented(hasConsented);
|
|
368
372
|
var tagManagerConsent = (values || []).reduce(function (acc, it) {
|
|
369
373
|
if (it.value === true) {
|
|
370
374
|
JSCookie.set(it.id, 'granted', {
|
|
@@ -398,9 +402,10 @@ var ConsentProvider = function ConsentProvider(_ref) {
|
|
|
398
402
|
return {
|
|
399
403
|
consent: consent,
|
|
400
404
|
setConsent: setConsent,
|
|
401
|
-
consented: consented
|
|
405
|
+
consented: consented,
|
|
406
|
+
setConsented: setConsented
|
|
402
407
|
};
|
|
403
|
-
}, [consent, setConsent, consented]);
|
|
408
|
+
}, [consent, setConsent, consented, setConsented]);
|
|
404
409
|
return /*#__PURE__*/React.createElement(ConsentContext.Provider, {
|
|
405
410
|
value: value
|
|
406
411
|
}, children);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.709",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -145,5 +145,5 @@
|
|
|
145
145
|
"access": "public",
|
|
146
146
|
"registry": "https://registry.npmjs.org/"
|
|
147
147
|
},
|
|
148
|
-
"gitHead": "
|
|
148
|
+
"gitHead": "367f9fd8ecf298da947c017e9a0434e34c90e248"
|
|
149
149
|
}
|