@micromag/consent 0.4.49 → 0.4.51
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/index.js +192 -162
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import
|
|
2
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
4
|
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
|
|
5
5
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
6
|
import { Button } from '@micromag/core/components';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
8
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
8
9
|
import isString from 'lodash/isString';
|
|
10
|
+
import { useCallback, useRef, useInsertionEffect, useState } from 'react';
|
|
9
11
|
import { FormattedMessage } from 'react-intl';
|
|
10
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
11
12
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
12
13
|
import { useConsent } from '@micromag/core/contexts';
|
|
13
14
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
@@ -19,10 +20,10 @@ function CloseButton(_ref) {
|
|
|
19
20
|
var _ref$className = _ref.className,
|
|
20
21
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
21
22
|
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
22
|
-
return /*#__PURE__*/
|
|
23
|
+
return /*#__PURE__*/jsx(Button, _objectSpread({
|
|
23
24
|
className: classNames([styles$4.container, className]),
|
|
24
25
|
withoutStyle: true,
|
|
25
|
-
icon: /*#__PURE__*/
|
|
26
|
+
icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
|
|
26
27
|
icon: faTimes,
|
|
27
28
|
className: styles$4.icon
|
|
28
29
|
}),
|
|
@@ -117,15 +118,16 @@ function PillButton(_ref) {
|
|
|
117
118
|
_ref$dark = _ref.dark,
|
|
118
119
|
dark = _ref$dark === void 0 ? false : _ref$dark,
|
|
119
120
|
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
120
|
-
return /*#__PURE__*/
|
|
121
|
+
return /*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({
|
|
121
122
|
className: classNames([styles$3.container, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$3.active, active), styles$3.dark, dark), styles$3.invert, invert), styles$3.disabled, disabled)])
|
|
122
|
-
}, props, {
|
|
123
|
+
}, props), {}, {
|
|
123
124
|
style: {
|
|
124
125
|
color: color,
|
|
125
126
|
backgroundColor: backgroundColor
|
|
126
127
|
},
|
|
127
|
-
disabled: disabled
|
|
128
|
-
|
|
128
|
+
disabled: disabled,
|
|
129
|
+
children: children
|
|
130
|
+
}));
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
var styles$2 = {"container":"micromag-consent-fields-checkbox-container","check":"micromag-consent-fields-checkbox-check","input":"micromag-consent-fields-checkbox-input","label":"micromag-consent-fields-checkbox-label"};
|
|
@@ -150,22 +152,25 @@ function CheckboxField(_ref) {
|
|
|
150
152
|
onChange(e.currentTarget.checked);
|
|
151
153
|
}
|
|
152
154
|
}, [onChange]);
|
|
153
|
-
return /*#__PURE__*/
|
|
155
|
+
return /*#__PURE__*/jsxs("label", {
|
|
154
156
|
htmlFor: name,
|
|
155
|
-
className: classNames([styles$2.container, className, _defineProperty({}, styles$2.disabled, disabled)])
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
className: classNames([styles$2.container, className, _defineProperty({}, styles$2.disabled, disabled)]),
|
|
158
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
159
|
+
className: styles$2.check,
|
|
160
|
+
children: /*#__PURE__*/jsx("input", {
|
|
161
|
+
type: "checkbox",
|
|
162
|
+
name: name,
|
|
163
|
+
id: name,
|
|
164
|
+
disabled: disabled,
|
|
165
|
+
checked: value || false,
|
|
166
|
+
onChange: onClick || onInputChange,
|
|
167
|
+
className: styles$2.input
|
|
168
|
+
})
|
|
169
|
+
}), /*#__PURE__*/jsx("span", {
|
|
170
|
+
className: styles$2.label,
|
|
171
|
+
children: isString(label) ? label : /*#__PURE__*/jsx(FormattedMessage, _objectSpread({}, label))
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
var _excluded$1 = ["href", "route", "routeParams", "external", "children", "target", "rel", "onClick", "className"];
|
|
@@ -201,9 +206,10 @@ function LinkPartial(_ref) {
|
|
|
201
206
|
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
202
207
|
var link = href || null;
|
|
203
208
|
if (link === null) {
|
|
204
|
-
return /*#__PURE__*/
|
|
205
|
-
className: className
|
|
206
|
-
|
|
209
|
+
return /*#__PURE__*/jsx("span", {
|
|
210
|
+
className: className,
|
|
211
|
+
children: children
|
|
212
|
+
});
|
|
207
213
|
}
|
|
208
214
|
var onClickLink = useCallback(function () {
|
|
209
215
|
if (onClick !== null) {
|
|
@@ -223,17 +229,21 @@ function LinkPartial(_ref) {
|
|
|
223
229
|
event.preventDefault();
|
|
224
230
|
}
|
|
225
231
|
});
|
|
226
|
-
return external ? /*#__PURE__*/
|
|
232
|
+
return external ? /*#__PURE__*/jsx("a", _objectSpread(_objectSpread({
|
|
227
233
|
className: className,
|
|
228
234
|
href: href,
|
|
229
235
|
target: target,
|
|
230
236
|
rel: rel,
|
|
231
237
|
onClick: onClickLink
|
|
232
|
-
}, props),
|
|
238
|
+
}, props), {}, {
|
|
239
|
+
children: children
|
|
240
|
+
})) : /*#__PURE__*/jsx("a", _objectSpread(_objectSpread({
|
|
233
241
|
className: className,
|
|
234
242
|
href: href,
|
|
235
243
|
onClick: handleClick
|
|
236
|
-
}, props),
|
|
244
|
+
}, props), {}, {
|
|
245
|
+
children: children
|
|
246
|
+
}));
|
|
237
247
|
}
|
|
238
248
|
|
|
239
249
|
var styles$1 = {"container":"micromag-consent-forms-cookies-container","title":"micromag-consent-forms-cookies-title","description":"micromag-consent-forms-cookies-description","label":"micromag-consent-forms-cookies-label","button":"micromag-consent-forms-cookies-button"};
|
|
@@ -296,125 +306,144 @@ function Cookies(_ref) {
|
|
|
296
306
|
onClickLink('privacy');
|
|
297
307
|
}
|
|
298
308
|
}, [onClickLink]);
|
|
299
|
-
return /*#__PURE__*/
|
|
309
|
+
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
300
310
|
className: classNames([styles$1.container, className])
|
|
301
|
-
}, props),
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
_ref4$
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
"
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
311
|
+
}, props), {}, {
|
|
312
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
313
|
+
className: styles$1.top,
|
|
314
|
+
children: [/*#__PURE__*/jsx("h3", {
|
|
315
|
+
className: styles$1.title,
|
|
316
|
+
children: title || /*#__PURE__*/jsx(FormattedMessage, {
|
|
317
|
+
id: "+Ptk0B",
|
|
318
|
+
defaultMessage: [{
|
|
319
|
+
"type": 0,
|
|
320
|
+
"value": "Your privacy settings"
|
|
321
|
+
}]
|
|
322
|
+
})
|
|
323
|
+
}), /*#__PURE__*/jsx("p", {
|
|
324
|
+
className: styles$1.description,
|
|
325
|
+
children: description || /*#__PURE__*/jsx(FormattedMessage, {
|
|
326
|
+
id: "dsRGuG",
|
|
327
|
+
defaultMessage: [{
|
|
328
|
+
"type": 0,
|
|
329
|
+
"value": "We use cookies to improve your experience on our site and for marketing purposes. By accepting, you consent to the use of these cookies."
|
|
330
|
+
}]
|
|
331
|
+
})
|
|
332
|
+
})]
|
|
333
|
+
}), showChoices ? (choices || []).map(function (_ref4) {
|
|
334
|
+
var _ref4$id = _ref4.id,
|
|
335
|
+
id = _ref4$id === void 0 ? null : _ref4$id,
|
|
336
|
+
_ref4$label = _ref4.label,
|
|
337
|
+
label = _ref4$label === void 0 ? null : _ref4$label,
|
|
338
|
+
_ref4$value = _ref4.value,
|
|
339
|
+
value = _ref4$value === void 0 ? false : _ref4$value,
|
|
340
|
+
_ref4$description = _ref4.description,
|
|
341
|
+
choiceDescription = _ref4$description === void 0 ? null : _ref4$description,
|
|
342
|
+
_ref4$disabled = _ref4.disabled,
|
|
343
|
+
disabled = _ref4$disabled === void 0 ? false : _ref4$disabled;
|
|
344
|
+
return /*#__PURE__*/jsxs("div", {
|
|
345
|
+
className: styles$1.choice,
|
|
346
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
347
|
+
className: styles$1.checkbox,
|
|
348
|
+
children: /*#__PURE__*/jsx(CheckboxField, {
|
|
349
|
+
value: value,
|
|
350
|
+
disabled: disabled,
|
|
351
|
+
label: label,
|
|
352
|
+
onClick: function onClick() {
|
|
353
|
+
return onClickChoice(id, !value);
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
}), /*#__PURE__*/jsx("p", {
|
|
357
|
+
className: styles$1.label,
|
|
358
|
+
children: isString(choiceDescription) ? choiceDescription : /*#__PURE__*/jsx(FormattedMessage, _objectSpread({}, choiceDescription))
|
|
359
|
+
})]
|
|
360
|
+
}, "cookie-".concat(id));
|
|
361
|
+
}) : null, privacyUrl !== null ? /*#__PURE__*/jsx("div", {
|
|
362
|
+
className: styles$1.more,
|
|
363
|
+
children: /*#__PURE__*/jsx("p", {
|
|
364
|
+
className: styles$1.description,
|
|
365
|
+
children: /*#__PURE__*/jsx(LinkPartial, {
|
|
366
|
+
href: privacyUrl,
|
|
367
|
+
onClick: onClickPrivacy,
|
|
368
|
+
external: privacyUrl.indexOf('http') === 0,
|
|
369
|
+
children: privacy || /*#__PURE__*/jsx(FormattedMessage, {
|
|
370
|
+
id: "ylHNR3",
|
|
371
|
+
defaultMessage: [{
|
|
372
|
+
"type": 0,
|
|
373
|
+
"value": "Learn more about our privacy policy"
|
|
374
|
+
}]
|
|
375
|
+
})
|
|
376
|
+
})
|
|
377
|
+
})
|
|
378
|
+
}) : null, termsUrl !== null ? /*#__PURE__*/jsx("div", {
|
|
379
|
+
className: styles$1.more,
|
|
380
|
+
children: /*#__PURE__*/jsx("p", {
|
|
381
|
+
className: styles$1.description,
|
|
382
|
+
children: /*#__PURE__*/jsx(LinkPartial, {
|
|
383
|
+
href: termsUrl,
|
|
384
|
+
onClick: onClickTerms,
|
|
385
|
+
external: termsUrl.indexOf('http') === 0,
|
|
386
|
+
children: terms || /*#__PURE__*/jsx(FormattedMessage, {
|
|
387
|
+
id: "lvPGoX",
|
|
388
|
+
defaultMessage: [{
|
|
389
|
+
"type": 0,
|
|
390
|
+
"value": "Our terms and conditions"
|
|
391
|
+
}]
|
|
392
|
+
})
|
|
393
|
+
})
|
|
394
|
+
})
|
|
395
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
396
|
+
className: styles$1.buttons,
|
|
397
|
+
children: showChoices ? /*#__PURE__*/jsx(PillButton, {
|
|
398
|
+
className: styles$1.button,
|
|
399
|
+
onClick: onClickConfirm,
|
|
400
|
+
small: true,
|
|
401
|
+
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
402
|
+
id: "sHYAUa",
|
|
403
|
+
defaultMessage: [{
|
|
404
|
+
"type": 0,
|
|
405
|
+
"value": "Save my preferences"
|
|
406
|
+
}]
|
|
407
|
+
})
|
|
408
|
+
}) : /*#__PURE__*/jsx(PillButton, {
|
|
409
|
+
className: classNames([styles$1.button, styles$1.small]),
|
|
410
|
+
onClick: onToggleTerms,
|
|
411
|
+
small: true,
|
|
412
|
+
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
413
|
+
id: "8yRYcm",
|
|
414
|
+
defaultMessage: [{
|
|
415
|
+
"type": 0,
|
|
416
|
+
"value": "Edit my settings"
|
|
417
|
+
}]
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
421
|
+
className: classNames([styles$1.buttons, styles$1.second]),
|
|
422
|
+
children: [/*#__PURE__*/jsx(PillButton, {
|
|
423
|
+
className: styles$1.button,
|
|
424
|
+
onClick: onClickAccept,
|
|
425
|
+
small: true,
|
|
426
|
+
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
427
|
+
id: "HxW2pw",
|
|
428
|
+
defaultMessage: [{
|
|
429
|
+
"type": 0,
|
|
430
|
+
"value": "Accept all"
|
|
431
|
+
}]
|
|
432
|
+
})
|
|
433
|
+
}), /*#__PURE__*/jsx(PillButton, {
|
|
434
|
+
className: styles$1.button,
|
|
435
|
+
onClick: onClickDeny,
|
|
436
|
+
small: true,
|
|
437
|
+
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
438
|
+
id: "X9mFEG",
|
|
439
|
+
defaultMessage: [{
|
|
440
|
+
"type": 0,
|
|
441
|
+
"value": "Reject all"
|
|
442
|
+
}]
|
|
443
|
+
})
|
|
444
|
+
})]
|
|
445
|
+
})]
|
|
446
|
+
}));
|
|
418
447
|
}
|
|
419
448
|
|
|
420
449
|
var styles = {"container":"micromag-consent-container","close":"micromag-consent-close"};
|
|
@@ -436,21 +465,22 @@ function Consent(_ref) {
|
|
|
436
465
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
437
466
|
_ref$children = _ref.children,
|
|
438
467
|
children = _ref$children === void 0 ? null : _ref$children;
|
|
439
|
-
return /*#__PURE__*/
|
|
440
|
-
className: classNames([styles.container, className])
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
468
|
+
return /*#__PURE__*/jsxs("div", {
|
|
469
|
+
className: classNames([styles.container, className]),
|
|
470
|
+
children: [onClose !== null && withClose ? /*#__PURE__*/jsx(CloseButton, {
|
|
471
|
+
type: "button",
|
|
472
|
+
className: styles.close,
|
|
473
|
+
onClick: onClose,
|
|
474
|
+
"aria-label": "Close consent form"
|
|
475
|
+
}) : null, children, /*#__PURE__*/jsx(Cookies, {
|
|
476
|
+
className: styles.form,
|
|
477
|
+
urls: urls,
|
|
478
|
+
labels: labels,
|
|
479
|
+
onChange: onChange,
|
|
480
|
+
onSubmit: onSubmit,
|
|
481
|
+
onClose: onClose
|
|
482
|
+
})]
|
|
483
|
+
});
|
|
454
484
|
}
|
|
455
485
|
|
|
456
486
|
export { Consent as default, useConsentActions as useConsent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/consent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
|
62
62
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
|
63
63
|
"@fortawesome/react-fontawesome": "^3.2.0",
|
|
64
|
-
"@micromag/core": "^0.4.
|
|
65
|
-
"@micromag/data": "^0.4.
|
|
64
|
+
"@micromag/core": "^0.4.51",
|
|
65
|
+
"@micromag/data": "^0.4.51",
|
|
66
66
|
"bootstrap": "^5.3.8",
|
|
67
67
|
"classnames": "^2.2.6",
|
|
68
68
|
"lodash": "^4.17.23",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"access": "public",
|
|
74
74
|
"registry": "https://registry.npmjs.org/"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "985a2370829c9ac8901ea97bf20bfc98ab158439",
|
|
77
77
|
"types": "es/index.d.ts"
|
|
78
78
|
}
|