@micromag/core 0.3.706 → 0.3.707
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 +33 -13
- package/package.json +2 -2
package/es/contexts.js
CHANGED
|
@@ -307,14 +307,30 @@ var useConsent = function useConsent() {
|
|
|
307
307
|
};
|
|
308
308
|
var propTypes$i = {
|
|
309
309
|
children: PropTypes.node.isRequired,
|
|
310
|
-
consent: PropTypes$1.consent
|
|
310
|
+
consent: PropTypes$1.consent,
|
|
311
|
+
consented: PropTypes.bool,
|
|
312
|
+
expiration: PropTypes.number
|
|
311
313
|
};
|
|
312
314
|
var defaultProps$i = {
|
|
313
|
-
consent: ['functionality_storage', 'analytics_storage', 'ad_storage', 'ad_personalization', 'ad_user_data']
|
|
315
|
+
consent: ['functionality_storage', 'analytics_storage', 'ad_storage', 'ad_personalization', 'ad_user_data'],
|
|
316
|
+
consented: false,
|
|
317
|
+
expiration: 182 // Default expiration in days
|
|
314
318
|
};
|
|
315
319
|
var ConsentProvider = function ConsentProvider(_ref) {
|
|
316
320
|
var providedConsent = _ref.consent,
|
|
321
|
+
initialConsented = _ref.consented,
|
|
322
|
+
expiration = _ref.expiration,
|
|
317
323
|
children = _ref.children;
|
|
324
|
+
var cookieConsented = JSCookie.get('has_consented') === 'true';
|
|
325
|
+
var _useState = useState(initialConsented || cookieConsented),
|
|
326
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
327
|
+
consented = _useState2[0],
|
|
328
|
+
setConsented = _useState2[1];
|
|
329
|
+
useEffect(function () {
|
|
330
|
+
if (initialConsented) {
|
|
331
|
+
setConsented(initialConsented);
|
|
332
|
+
}
|
|
333
|
+
}, [initialConsented, setConsented]);
|
|
318
334
|
var baseConsent = useMemo(function () {
|
|
319
335
|
return (providedConsent || consentStates || []).map(function (item) {
|
|
320
336
|
if (isString(item)) {
|
|
@@ -333,43 +349,47 @@ var ConsentProvider = function ConsentProvider(_ref) {
|
|
|
333
349
|
});
|
|
334
350
|
});
|
|
335
351
|
}, [providedConsent]);
|
|
336
|
-
var
|
|
337
|
-
|
|
338
|
-
consent =
|
|
339
|
-
setConsentState =
|
|
352
|
+
var _useState3 = useState(baseConsent),
|
|
353
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
354
|
+
consent = _useState4[0],
|
|
355
|
+
setConsentState = _useState4[1];
|
|
340
356
|
useEffect(function () {
|
|
341
357
|
if (baseConsent) {
|
|
342
358
|
setConsentState(baseConsent);
|
|
343
359
|
}
|
|
344
360
|
}, [baseConsent, setConsentState]);
|
|
345
361
|
var setConsent = useCallback(function (values) {
|
|
346
|
-
|
|
362
|
+
var hasConsented = values !== null && typeof values !== 'undefined';
|
|
363
|
+
JSCookie.set('has_consented', hasConsented, {
|
|
347
364
|
secure: true,
|
|
348
|
-
expires:
|
|
365
|
+
expires: expiration
|
|
349
366
|
});
|
|
367
|
+
setConsented(hasConsented);
|
|
350
368
|
(values || []).forEach(function (it) {
|
|
351
369
|
if (it.value === true) {
|
|
352
370
|
JSCookie.set(it.id, 'granted', {
|
|
353
371
|
secure: true,
|
|
354
|
-
expires:
|
|
372
|
+
expires: expiration
|
|
355
373
|
});
|
|
356
374
|
} else if (it.value === false) {
|
|
357
375
|
JSCookie.set(it.id, 'denied', {
|
|
358
376
|
secure: true,
|
|
359
|
-
expires:
|
|
377
|
+
expires: expiration
|
|
360
378
|
});
|
|
361
379
|
} else {
|
|
362
380
|
JSCookie.remove(it.id);
|
|
363
381
|
}
|
|
364
382
|
});
|
|
365
383
|
setConsentState(values);
|
|
366
|
-
|
|
384
|
+
return values;
|
|
385
|
+
}, [setConsentState, expiration]);
|
|
367
386
|
var value = useMemo(function () {
|
|
368
387
|
return {
|
|
369
388
|
consent: consent,
|
|
370
|
-
setConsent: setConsent
|
|
389
|
+
setConsent: setConsent,
|
|
390
|
+
consented: consented
|
|
371
391
|
};
|
|
372
|
-
}, [consent, setConsent]);
|
|
392
|
+
}, [consent, setConsent, consented]);
|
|
373
393
|
return /*#__PURE__*/React.createElement(ConsentContext.Provider, {
|
|
374
394
|
value: value
|
|
375
395
|
}, children);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.707",
|
|
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": "e3afa5fe973a68bf83383fede41590a5e6428259"
|
|
149
149
|
}
|