@micromag/core 0.3.708 → 0.3.710
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 +19 -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', {
|
|
@@ -386,6 +390,7 @@ var ConsentProvider = function ConsentProvider(_ref) {
|
|
|
386
390
|
}, {});
|
|
387
391
|
if (typeof gtag === 'function') {
|
|
388
392
|
gtag('consent', initial === true ? 'default' : 'update', tagManagerConsent);
|
|
393
|
+
gtag('event', initial === true ? 'consent_default' : 'consent_update', tagManagerConsent);
|
|
389
394
|
}
|
|
390
395
|
setConsentState(values);
|
|
391
396
|
}, [setConsentState, expiration]);
|
|
@@ -398,9 +403,10 @@ var ConsentProvider = function ConsentProvider(_ref) {
|
|
|
398
403
|
return {
|
|
399
404
|
consent: consent,
|
|
400
405
|
setConsent: setConsent,
|
|
401
|
-
consented: consented
|
|
406
|
+
consented: consented,
|
|
407
|
+
setConsented: setConsented
|
|
402
408
|
};
|
|
403
|
-
}, [consent, setConsent, consented]);
|
|
409
|
+
}, [consent, setConsent, consented, setConsented]);
|
|
404
410
|
return /*#__PURE__*/React.createElement(ConsentContext.Provider, {
|
|
405
411
|
value: value
|
|
406
412
|
}, children);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.710",
|
|
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": "8c6a9c1cbf22450c2e7da81693c6c6464dc4f2e1"
|
|
149
149
|
}
|