@micromag/consent 0.3.703

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.
@@ -0,0 +1,5 @@
1
+ .micromag-consent-buttons-close-container{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;position:relative}
2
+ .micromag-consent-buttons-pill-container{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;border:1px solid #fff;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;padding:6px 10px;position:relative}.micromag-consent-buttons-pill-container:active,.micromag-consent-buttons-pill-container:hover{background-color:var(--color-primary);color:#fff}
3
+ .micromag-consent-fields-checkbox-container{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:start;align-items:flex-start;line-height:1.2}.micromag-consent-fields-checkbox-container .micromag-consent-fields-checkbox-check{margin-right:6px}.micromag-consent-fields-checkbox-container .micromag-consent-fields-checkbox-input{cursor:pointer;display:block;height:1rem;margin:0 0 5px;width:1rem}.micromag-consent-fields-checkbox-container .micromag-consent-fields-checkbox-label{-ms-flex-positive:1;cursor:pointer;flex-grow:1;font-weight:800}.micromag-consent-fields-checkbox-container:active .micromag-consent-fields-checkbox-label,.micromag-consent-fields-checkbox-container:hover .micromag-consent-fields-checkbox-label{-webkit-text-decoration:underline;text-decoration:underline}
4
+ .micromag-consent-forms-cookies-container{border-radius:10px;bottom:10px;margin-left:10px;margin-top:10px;max-height:calc(100vh - 20px);overflow-y:scroll;padding:15px;position:fixed;right:10px;z-index:99999}.micromag-consent-forms-cookies-container .micromag-consent-forms-cookies-close{position:absolute;right:15px;top:15px}.micromag-consent-forms-cookies-container .micromag-consent-forms-cookies-button{margin:0 5px 5px 0}
5
+ .micromag-consent-container{position:relative}.micromag-consent-container .micromag-consent-close{color:var(--color-primary);cursor:pointer;font-size:1.5rem;position:absolute;right:15px;top:15px}
package/es/index.js ADDED
@@ -0,0 +1,716 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import classNames from 'classnames';
3
+ import PropTypes from 'prop-types';
4
+ import React, { useMemo, useState, useCallback, useRef, useInsertionEffect } from 'react';
5
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
+ import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
7
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
+ import { Button } from '@micromag/core/components';
9
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
10
+ import isString from 'lodash/isString';
11
+ import { defineMessages, FormattedMessage } from 'react-intl';
12
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
13
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
14
+ import JSCookie from 'js-cookie';
15
+
16
+ var styles$4 = {"container":"micromag-consent-buttons-close-container"};
17
+
18
+ var _excluded$3 = ["className"];
19
+ var propTypes$5 = {
20
+ className: PropTypes.string
21
+ };
22
+ var defaultProps$5 = {
23
+ className: null
24
+ };
25
+ var CloseButton = function CloseButton(_ref) {
26
+ var className = _ref.className,
27
+ props = _objectWithoutProperties(_ref, _excluded$3);
28
+ return /*#__PURE__*/React.createElement(Button, Object.assign({
29
+ className: classNames([styles$4.container, _defineProperty({}, className, className !== null)]),
30
+ withoutStyle: true,
31
+ icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
32
+ icon: faTimes,
33
+ className: styles$4.icon
34
+ }),
35
+ iconPosition: "right"
36
+ }, props));
37
+ };
38
+ CloseButton.propTypes = propTypes$5;
39
+ CloseButton.defaultProps = defaultProps$5;
40
+
41
+ var messages = defineMessages({
42
+ functionality_title: {
43
+ id: "consent.functionality_title",
44
+ defaultMessage: [{
45
+ "type": 0,
46
+ "value": "Functionnal"
47
+ }]
48
+ },
49
+ functionality_description: {
50
+ id: "consent.functionality_description",
51
+ defaultMessage: [{
52
+ "type": 0,
53
+ "value": "Cookies required for the site to function properly."
54
+ }]
55
+ },
56
+ analytics_title: {
57
+ id: "consent.analytics_title",
58
+ defaultMessage: [{
59
+ "type": 0,
60
+ "value": "Analytics"
61
+ }]
62
+ },
63
+ analytics_description: {
64
+ id: "consent.analytics_description",
65
+ defaultMessage: [{
66
+ "type": 0,
67
+ "value": "Cookies used to measure user behavior."
68
+ }]
69
+ },
70
+ ad_storage_title: {
71
+ id: "consent.ad_storage_title",
72
+ defaultMessage: [{
73
+ "type": 0,
74
+ "value": "Ad Storage"
75
+ }]
76
+ },
77
+ ad_storage_description: {
78
+ id: "consent.ad_storage_description",
79
+ defaultMessage: [{
80
+ "type": 0,
81
+ "value": "Cookies used for advertising purposes."
82
+ }]
83
+ },
84
+ ad_personalization_title: {
85
+ id: "consent.ad_personalization_title",
86
+ defaultMessage: [{
87
+ "type": 0,
88
+ "value": "Ad Personalization"
89
+ }]
90
+ },
91
+ ad_personalization_description: {
92
+ id: "consent.ad_personalization_description",
93
+ defaultMessage: [{
94
+ "type": 0,
95
+ "value": "Cookies used for ad targeting."
96
+ }]
97
+ },
98
+ ad_user_data_title: {
99
+ id: "consent.ad_user_data_title",
100
+ defaultMessage: [{
101
+ "type": 0,
102
+ "value": "User Ad Data"
103
+ }]
104
+ },
105
+ ad_user_data_description: {
106
+ id: "consent.ad_user_data_description",
107
+ defaultMessage: [{
108
+ "type": 0,
109
+ "value": "Cookies used for user-specific ad data."
110
+ }]
111
+ },
112
+ personalization_storage_title: {
113
+ id: "consent.personalization_storage_title",
114
+ defaultMessage: [{
115
+ "type": 0,
116
+ "value": "Personalization Storage"
117
+ }]
118
+ },
119
+ personalization_storage_description: {
120
+ id: "consent.personalization_storage_description",
121
+ defaultMessage: [{
122
+ "type": 0,
123
+ "value": "Cookies used for personalizing user experience."
124
+ }]
125
+ },
126
+ security_storage_title: {
127
+ id: "consent.security_storage_title",
128
+ defaultMessage: [{
129
+ "type": 0,
130
+ "value": "Security Storage"
131
+ }]
132
+ },
133
+ security_storage_description: {
134
+ id: "consent.security_storage_description",
135
+ defaultMessage: [{
136
+ "type": 0,
137
+ "value": "Cookies used for security purposes."
138
+ }]
139
+ }
140
+ });
141
+ var consent = [{
142
+ id: 'functionality_storage',
143
+ label: messages.functionality_title,
144
+ description: messages.functionality_description,
145
+ value: true,
146
+ disabled: true
147
+ }, {
148
+ id: 'security_storage',
149
+ label: messages.security_storage_title,
150
+ description: messages.security_storage_description,
151
+ value: true
152
+ }, {
153
+ id: 'personalization_storage',
154
+ label: messages.personalization_storage_title,
155
+ description: messages.personalization_storage_description,
156
+ value: true
157
+ }, {
158
+ id: 'analytics_storage',
159
+ label: messages.analytics_title,
160
+ description: messages.analytics_description,
161
+ value: true
162
+ }, {
163
+ id: 'ad_storage',
164
+ label: messages.ad_storage_title,
165
+ description: messages.ad_storage_description,
166
+ value: true
167
+ }, {
168
+ id: 'ad_personalization',
169
+ label: messages.ad_personalization_title,
170
+ description: messages.ad_personalization_description,
171
+ value: true
172
+ }, {
173
+ id: 'ad_user_data',
174
+ label: messages.ad_user_data_title,
175
+ description: messages.ad_user_data_description,
176
+ value: true
177
+ }];
178
+ var useConsent = function useConsent(_ref) {
179
+ var _ref$consent = _ref.consent,
180
+ initialConsent = _ref$consent === void 0 ? null : _ref$consent,
181
+ _ref$onSubmit = _ref.onSubmit,
182
+ onSubmit = _ref$onSubmit === void 0 ? null : _ref$onSubmit,
183
+ _ref$onChange = _ref.onChange,
184
+ onChange = _ref$onChange === void 0 ? null : _ref$onChange,
185
+ _ref$onClose = _ref.onClose,
186
+ onClose = _ref$onClose === void 0 ? null : _ref$onClose,
187
+ _ref$autoClose = _ref.autoClose,
188
+ autoClose = _ref$autoClose === void 0 ? true : _ref$autoClose;
189
+ var baseConsent = useMemo(function () {
190
+ return (initialConsent || consent).map(function (item) {
191
+ if (isString(item)) {
192
+ return consent.find(function (it) {
193
+ return it.id === item;
194
+ }) || null;
195
+ }
196
+ return item || null;
197
+ }).filter(function (it) {
198
+ return it !== null;
199
+ }).map(function (it) {
200
+ return _objectSpread(_objectSpread({}, it), {}, {
201
+ value:
202
+ // eslint-disable-next-line no-nested-ternary
203
+ JSCookie.get(it.id) === 'granted' ? true : JSCookie.get(it.id) === 'denied' ? false : it.value
204
+ });
205
+ });
206
+ }, [initialConsent]);
207
+ var _useState = useState(baseConsent),
208
+ _useState2 = _slicedToArray(_useState, 2),
209
+ choices = _useState2[0],
210
+ setChoices = _useState2[1];
211
+ var onSubmitForm = useCallback(function (values) {
212
+ JSCookie.set('popup_cookies', false, {
213
+ secure: true,
214
+ expires: 182
215
+ });
216
+ if (onSubmit !== null) {
217
+ onSubmit(values || []);
218
+ }
219
+ if (onClose !== null && autoClose) {
220
+ onClose(values || []);
221
+ }
222
+ }, [onSubmit, onClose, autoClose]);
223
+ var onClickChoice = useCallback(function (id, newValue) {
224
+ var newChoices = (choices || []).reduce(function (acc, it) {
225
+ if (it.id === id) {
226
+ return [].concat(_toConsumableArray(acc), [_objectSpread(_objectSpread({}, it), {}, {
227
+ value: newValue
228
+ })]);
229
+ }
230
+ return [].concat(_toConsumableArray(acc), [it]);
231
+ }, []);
232
+ setChoices(newChoices);
233
+ if (onChange !== null) {
234
+ onChange(newChoices || []);
235
+ }
236
+ }, [choices, setChoices]);
237
+ var onClickConfirm = useCallback(function () {
238
+ onSubmitForm(choices);
239
+ }, [choices, onSubmitForm]);
240
+ var onClickAccept = useCallback(function () {
241
+ var items = baseConsent.map(function (it) {
242
+ return _objectSpread(_objectSpread({}, it), {}, {
243
+ value: !it.disabled ? true : it.value
244
+ });
245
+ });
246
+ setChoices(items);
247
+ onSubmitForm(items);
248
+ }, [baseConsent, setChoices, onSubmitForm]);
249
+ var onClickDeny = useCallback(function () {
250
+ var items = baseConsent.map(function (it) {
251
+ return _objectSpread(_objectSpread({}, it), {}, {
252
+ value: !it.disabled ? false : it.value
253
+ });
254
+ });
255
+ setChoices(items);
256
+ onSubmitForm(items);
257
+ }, [baseConsent, setChoices, onSubmitForm]);
258
+ return {
259
+ choices: choices,
260
+ onClickChoice: onClickChoice,
261
+ onClickConfirm: onClickConfirm,
262
+ onClickAccept: onClickAccept,
263
+ onClickDeny: onClickDeny
264
+ };
265
+ };
266
+
267
+ var styles$3 = {"container":"micromag-consent-buttons-pill-container"};
268
+
269
+ var _excluded$2 = ["children", "color", "backgroundColor", "className", "active", "disabled", "invert", "dark"];
270
+ var propTypes$4 = {
271
+ children: PropTypes.node,
272
+ color: PropTypes.string,
273
+ backgroundColor: PropTypes.string,
274
+ active: PropTypes.bool,
275
+ invert: PropTypes.bool,
276
+ disabled: PropTypes.bool,
277
+ dark: PropTypes.bool,
278
+ className: PropTypes.string
279
+ };
280
+ var defaultProps$4 = {
281
+ children: null,
282
+ color: null,
283
+ backgroundColor: null,
284
+ active: false,
285
+ invert: false,
286
+ disabled: false,
287
+ dark: false,
288
+ className: null
289
+ };
290
+ function PillButton(_ref) {
291
+ var children = _ref.children,
292
+ color = _ref.color,
293
+ backgroundColor = _ref.backgroundColor,
294
+ className = _ref.className,
295
+ active = _ref.active,
296
+ disabled = _ref.disabled,
297
+ invert = _ref.invert,
298
+ dark = _ref.dark,
299
+ props = _objectWithoutProperties(_ref, _excluded$2);
300
+ return /*#__PURE__*/React.createElement(Button, Object.assign({
301
+ className: classNames([styles$3.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$3.active, active), styles$3.dark, dark), styles$3.invert, invert), styles$3.disabled, disabled), className, className !== null)])
302
+ }, props, {
303
+ style: {
304
+ color: color,
305
+ backgroundColor: backgroundColor
306
+ },
307
+ disabled: disabled
308
+ }), children);
309
+ }
310
+ PillButton.defaultProps = defaultProps$4;
311
+ PillButton.propTypes = propTypes$4;
312
+
313
+ 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"};
314
+
315
+ var propTypes$3 = {
316
+ name: PropTypes.string,
317
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
318
+ value: PropTypes.string,
319
+ disabled: PropTypes.bool,
320
+ className: PropTypes.string,
321
+ onClick: PropTypes.func,
322
+ onChange: PropTypes.func
323
+ };
324
+ var defaultProps$3 = {
325
+ name: null,
326
+ value: null,
327
+ label: null,
328
+ disabled: false,
329
+ className: null,
330
+ onClick: null,
331
+ onChange: null
332
+ };
333
+ function CheckboxField(_ref) {
334
+ var name = _ref.name,
335
+ label = _ref.label,
336
+ value = _ref.value,
337
+ disabled = _ref.disabled,
338
+ onClick = _ref.onClick,
339
+ onChange = _ref.onChange,
340
+ className = _ref.className;
341
+ var onInputChange = useCallback(function (e) {
342
+ if (onChange !== null) {
343
+ onChange(e.currentTarget.checked);
344
+ }
345
+ }, [onChange]);
346
+ return /*#__PURE__*/React.createElement("label", {
347
+ htmlFor: name,
348
+ className: classNames([styles$2.container, _defineProperty(_defineProperty({}, styles$2.disabled, disabled), className, className !== null)])
349
+ }, /*#__PURE__*/React.createElement("span", {
350
+ className: styles$2.check
351
+ }, /*#__PURE__*/React.createElement("input", {
352
+ type: "checkbox",
353
+ name: name,
354
+ id: name,
355
+ disabled: disabled,
356
+ checked: value || false,
357
+ onChange: onClick || onInputChange,
358
+ className: styles$2.input
359
+ })), /*#__PURE__*/React.createElement("span", {
360
+ className: styles$2.label
361
+ }, isString(label) ? label : /*#__PURE__*/React.createElement(FormattedMessage, label)));
362
+ }
363
+ CheckboxField.propTypes = propTypes$3;
364
+ CheckboxField.defaultProps = defaultProps$3;
365
+
366
+ var _excluded$1 = ["href", "route", "routeParams", "external", "children", "target", "rel", "onClick", "className"];
367
+ var useEvent = function useEvent(fn) {
368
+ var ref = useRef([fn, function () {
369
+ return ref[0].apply(ref, arguments);
370
+ }]).current;
371
+ // Per Dan Abramov: useInsertionEffect executes marginally closer to the
372
+ // correct timing for ref synchronization than useLayoutEffect on React 18.
373
+ // See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
374
+ useInsertionEffect(function () {
375
+ ref[0] = fn;
376
+ });
377
+ return ref[1];
378
+ };
379
+ var propTypes$2 = {
380
+ href: PropTypes.string,
381
+ route: PropTypes.string,
382
+ routeParams: PropTypes.object,
383
+ // eslint-disable-line react/forbid-prop-types
384
+ external: PropTypes.bool,
385
+ target: PropTypes.string,
386
+ children: PropTypes.node,
387
+ rel: PropTypes.string,
388
+ onClick: PropTypes.func,
389
+ className: PropTypes.string
390
+ };
391
+ var defaultProps$2 = {
392
+ href: null,
393
+ route: null,
394
+ routeParams: null,
395
+ external: false,
396
+ target: '_blank',
397
+ rel: 'noopener noreferrer',
398
+ onClick: null,
399
+ children: null,
400
+ className: null
401
+ };
402
+ var LinkPartial = function LinkPartial(_ref) {
403
+ var href = _ref.href;
404
+ _ref.route;
405
+ _ref.routeParams;
406
+ var external = _ref.external,
407
+ children = _ref.children,
408
+ target = _ref.target,
409
+ rel = _ref.rel,
410
+ onClick = _ref.onClick,
411
+ className = _ref.className,
412
+ props = _objectWithoutProperties(_ref, _excluded$1);
413
+ var link = href || null;
414
+ if (link === null) {
415
+ return /*#__PURE__*/React.createElement("span", {
416
+ className: className
417
+ }, children);
418
+ }
419
+ var onClickLink = useCallback(function () {
420
+ if (onClick !== null) {
421
+ onClick.apply(void 0, arguments);
422
+ }
423
+ }, [onClick]);
424
+ var handleClick = useEvent(function (event) {
425
+ // ignores the navigation when clicked using right mouse button or
426
+ // by holding a special modifier key: ctrl, command, win, alt, shift
427
+ if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) {
428
+ return;
429
+ }
430
+ if (onClickLink !== null) {
431
+ onClickLink(event);
432
+ }
433
+ if (!event.defaultPrevented) {
434
+ event.preventDefault();
435
+ }
436
+ });
437
+ return external ? /*#__PURE__*/React.createElement("a", Object.assign({
438
+ className: className,
439
+ href: href,
440
+ target: target,
441
+ rel: rel,
442
+ onClick: onClickLink
443
+ }, props), children) : /*#__PURE__*/React.createElement("a", Object.assign({
444
+ className: className,
445
+ href: href,
446
+ onClick: handleClick
447
+ }, props), children);
448
+ };
449
+ LinkPartial.propTypes = propTypes$2;
450
+ LinkPartial.defaultProps = defaultProps$2;
451
+
452
+ var styles$1 = {"container":"micromag-consent-forms-cookies-container","button":"micromag-consent-forms-cookies-button"};
453
+
454
+ var _excluded = ["consent", "onChange", "onSubmit", "onClose", "onClickLink", "urls", "labels", "className"];
455
+ var propTypes$1 = {
456
+ consent: PropTypes.shape({}),
457
+ urls: PropTypes.shape({
458
+ privacy: PropTypes.string
459
+ }),
460
+ labels: PropTypes.shape({
461
+ title: PropTypes.string,
462
+ description: PropTypes.string,
463
+ privacy: PropTypes.string
464
+ }),
465
+ onChange: PropTypes.func,
466
+ onSubmit: PropTypes.func,
467
+ onClose: PropTypes.func,
468
+ onClickLink: PropTypes.func,
469
+ className: PropTypes.string
470
+ };
471
+ var defaultProps$1 = {
472
+ consent: null,
473
+ urls: null,
474
+ labels: null,
475
+ onChange: null,
476
+ onSubmit: null,
477
+ onClose: null,
478
+ onClickLink: null,
479
+ className: null
480
+ };
481
+ var Cookies = function Cookies(_ref) {
482
+ var consent = _ref.consent,
483
+ onChange = _ref.onChange,
484
+ onSubmit = _ref.onSubmit,
485
+ onClose = _ref.onClose,
486
+ onClickLink = _ref.onClickLink,
487
+ urls = _ref.urls,
488
+ labels = _ref.labels,
489
+ className = _ref.className,
490
+ props = _objectWithoutProperties(_ref, _excluded);
491
+ var _useConsent = useConsent({
492
+ consent: consent,
493
+ onChange: onChange,
494
+ onSubmit: onSubmit,
495
+ onClose: onClose
496
+ }),
497
+ choices = _useConsent.choices,
498
+ onClickChoice = _useConsent.onClickChoice,
499
+ onClickConfirm = _useConsent.onClickConfirm,
500
+ onClickAccept = _useConsent.onClickAccept,
501
+ onClickDeny = _useConsent.onClickDeny;
502
+ var _ref2 = urls || {},
503
+ _ref2$privacy = _ref2.privacy,
504
+ privacyUrl = _ref2$privacy === void 0 ? null : _ref2$privacy,
505
+ _ref2$terms = _ref2.terms,
506
+ termsUrl = _ref2$terms === void 0 ? null : _ref2$terms;
507
+ var _ref3 = labels || {},
508
+ _ref3$title = _ref3.title,
509
+ title = _ref3$title === void 0 ? null : _ref3$title,
510
+ _ref3$description = _ref3.description,
511
+ description = _ref3$description === void 0 ? null : _ref3$description,
512
+ _ref3$privacy = _ref3.privacy,
513
+ privacy = _ref3$privacy === void 0 ? null : _ref3$privacy,
514
+ _ref3$terms = _ref3.terms,
515
+ terms = _ref3$terms === void 0 ? null : _ref3$terms;
516
+ var _useState = useState(false),
517
+ _useState2 = _slicedToArray(_useState, 2),
518
+ showChoices = _useState2[0],
519
+ setShowChoices = _useState2[1];
520
+ var onToggleTerms = useCallback(function () {
521
+ setShowChoices(!showChoices);
522
+ }, [showChoices, setShowChoices]);
523
+ var onClickTerms = useCallback(function () {
524
+ if (onClickLink !== null) {
525
+ onClickLink('terms');
526
+ }
527
+ }, [onClickLink]);
528
+ var onClickPrivacy = useCallback(function () {
529
+ if (onClickLink !== null) {
530
+ onClickLink('privacy');
531
+ }
532
+ }, [onClickLink]);
533
+ return /*#__PURE__*/React.createElement("div", Object.assign({
534
+ className: classNames([styles$1.container, _defineProperty({}, className, className !== null)])
535
+ }, props), /*#__PURE__*/React.createElement("div", {
536
+ className: styles$1.top
537
+ }, /*#__PURE__*/React.createElement("h3", null, title || /*#__PURE__*/React.createElement(FormattedMessage, {
538
+ id: "+Ptk0B",
539
+ defaultMessage: [{
540
+ "type": 0,
541
+ "value": "Your privacy settings"
542
+ }]
543
+ })), /*#__PURE__*/React.createElement("p", {
544
+ className: styles$1.description
545
+ }, description || /*#__PURE__*/React.createElement(FormattedMessage, {
546
+ id: "dsRGuG",
547
+ defaultMessage: [{
548
+ "type": 0,
549
+ "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."
550
+ }]
551
+ }))), showChoices ? choices.map(function (_ref5) {
552
+ var _ref5$id = _ref5.id,
553
+ id = _ref5$id === void 0 ? null : _ref5$id,
554
+ _ref5$label = _ref5.label,
555
+ label = _ref5$label === void 0 ? null : _ref5$label,
556
+ _ref5$value = _ref5.value,
557
+ value = _ref5$value === void 0 ? false : _ref5$value,
558
+ _ref5$description = _ref5.description,
559
+ choiceDescription = _ref5$description === void 0 ? null : _ref5$description,
560
+ _ref5$disabled = _ref5.disabled,
561
+ disabled = _ref5$disabled === void 0 ? false : _ref5$disabled;
562
+ return /*#__PURE__*/React.createElement("div", {
563
+ className: styles$1.choice,
564
+ key: "cookie-".concat(id)
565
+ }, /*#__PURE__*/React.createElement("div", {
566
+ className: styles$1.checkbox
567
+ }, /*#__PURE__*/React.createElement(CheckboxField, {
568
+ value: value,
569
+ disabled: disabled,
570
+ label: label,
571
+ onClick: function onClick() {
572
+ return onClickChoice(id, !value);
573
+ }
574
+ })), /*#__PURE__*/React.createElement("p", {
575
+ className: styles$1.description
576
+ }, isString(choiceDescription) ? choiceDescription : /*#__PURE__*/React.createElement(FormattedMessage, choiceDescription)));
577
+ }) : null, privacyUrl !== null ? /*#__PURE__*/React.createElement("div", {
578
+ className: styles$1.more
579
+ }, /*#__PURE__*/React.createElement("p", {
580
+ className: styles$1.description
581
+ }, /*#__PURE__*/React.createElement(LinkPartial, {
582
+ href: privacyUrl,
583
+ onClick: onClickPrivacy,
584
+ external: privacyUrl.indexOf('http') === 0
585
+ }, privacy || /*#__PURE__*/React.createElement(FormattedMessage, {
586
+ id: "ylHNR3",
587
+ defaultMessage: [{
588
+ "type": 0,
589
+ "value": "Learn more about our privacy policy"
590
+ }]
591
+ })))) : null, termsUrl !== null ? /*#__PURE__*/React.createElement("div", {
592
+ className: styles$1.more
593
+ }, /*#__PURE__*/React.createElement("p", {
594
+ className: styles$1.description
595
+ }, /*#__PURE__*/React.createElement(LinkPartial, {
596
+ href: termsUrl,
597
+ onClick: onClickTerms,
598
+ external: termsUrl.indexOf('http') === 0
599
+ }, terms || /*#__PURE__*/React.createElement(FormattedMessage, {
600
+ id: "lvPGoX",
601
+ defaultMessage: [{
602
+ "type": 0,
603
+ "value": "Our terms and conditions"
604
+ }]
605
+ })))) : null, /*#__PURE__*/React.createElement("div", {
606
+ className: styles$1.buttons
607
+ }, showChoices ? /*#__PURE__*/React.createElement(PillButton, {
608
+ className: styles$1.button,
609
+ onClick: onClickConfirm,
610
+ small: true
611
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
612
+ id: "sHYAUa",
613
+ defaultMessage: [{
614
+ "type": 0,
615
+ "value": "Save my preferences"
616
+ }]
617
+ })) : /*#__PURE__*/React.createElement(PillButton, {
618
+ className: classNames([styles$1.button, styles$1.small]),
619
+ onClick: onToggleTerms,
620
+ small: true
621
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
622
+ id: "8yRYcm",
623
+ defaultMessage: [{
624
+ "type": 0,
625
+ "value": "Edit my settings"
626
+ }]
627
+ }))), /*#__PURE__*/React.createElement("div", {
628
+ className: classNames([styles$1.buttons, styles$1.second])
629
+ }, /*#__PURE__*/React.createElement(PillButton, {
630
+ className: styles$1.button,
631
+ onClick: onClickAccept,
632
+ small: true
633
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
634
+ id: "HxW2pw",
635
+ defaultMessage: [{
636
+ "type": 0,
637
+ "value": "Accept all"
638
+ }]
639
+ })), /*#__PURE__*/React.createElement(PillButton, {
640
+ className: styles$1.button,
641
+ onClick: onClickDeny,
642
+ small: true
643
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
644
+ id: "X9mFEG",
645
+ defaultMessage: [{
646
+ "type": 0,
647
+ "value": "Reject all"
648
+ }]
649
+ }))));
650
+ };
651
+ Cookies.propTypes = propTypes$1;
652
+ Cookies.defaultProps = defaultProps$1;
653
+
654
+ var styles = {"container":"micromag-consent-container","close":"micromag-consent-close"};
655
+
656
+ var propTypes = {
657
+ consent: PropTypes.arrayOf(PropTypes.string),
658
+ urls: PropTypes.shape({
659
+ privacy: PropTypes.string,
660
+ terms: PropTypes.string
661
+ }),
662
+ labels: PropTypes.shape({
663
+ title: PropTypes.string,
664
+ description: PropTypes.string,
665
+ privacy: PropTypes.string,
666
+ terms: PropTypes.string
667
+ }),
668
+ onChange: PropTypes.func,
669
+ onSubmit: PropTypes.func,
670
+ onClose: PropTypes.func,
671
+ withClose: PropTypes.bool,
672
+ className: PropTypes.string,
673
+ children: PropTypes.node
674
+ };
675
+ var defaultProps = {
676
+ consent: ['functionality_storage', 'analytics_storage', 'ad_storage', 'ad_personalization', 'ad_user_data'],
677
+ urls: null,
678
+ labels: null,
679
+ onChange: null,
680
+ onSubmit: null,
681
+ onClose: null,
682
+ withClose: false,
683
+ className: null,
684
+ children: null
685
+ };
686
+ function Consent(_ref) {
687
+ var consent = _ref.consent,
688
+ urls = _ref.urls,
689
+ labels = _ref.labels,
690
+ onChange = _ref.onChange,
691
+ onSubmit = _ref.onSubmit,
692
+ onClose = _ref.onClose,
693
+ withClose = _ref.withClose,
694
+ className = _ref.className,
695
+ children = _ref.children;
696
+ return /*#__PURE__*/React.createElement("div", {
697
+ className: classNames([styles.container, _defineProperty({}, className, className)])
698
+ }, onClose !== null && withClose ? /*#__PURE__*/React.createElement(CloseButton, {
699
+ type: "button",
700
+ className: styles.close,
701
+ onClick: onClose,
702
+ "aria-label": "Close consent form"
703
+ }) : null, children, /*#__PURE__*/React.createElement(Cookies, {
704
+ className: styles.form,
705
+ consent: consent,
706
+ urls: urls,
707
+ labels: labels,
708
+ onChange: onChange,
709
+ onSubmit: onSubmit,
710
+ onClose: onClose
711
+ }));
712
+ }
713
+ Consent.propTypes = propTypes;
714
+ Consent.defaultProps = defaultProps;
715
+
716
+ export { Consent as default };
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@micromag/consent",
3
+ "version": "0.3.703",
4
+ "private": false,
5
+ "description": "",
6
+ "keywords": [
7
+ "javascript"
8
+ ],
9
+ "homepage": "https://github.com/urbania-media/micromag-js",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/urbania-media/micromag-js.git"
13
+ },
14
+ "author": {
15
+ "name": "Folklore",
16
+ "email": "info@folklore.email"
17
+ },
18
+ "contributors": [
19
+ {
20
+ "name": "David Mongeau-Petitpas",
21
+ "email": "dmp@folklore.email"
22
+ },
23
+ {
24
+ "name": "Nicolas Roy-Bourdages",
25
+ "email": "nrb@folklore.email"
26
+ }
27
+ ],
28
+ "license": "ISC",
29
+ "type": "module",
30
+ "module": "es/index.js",
31
+ "exports": {
32
+ ".": {
33
+ "import": "./es/index.js"
34
+ },
35
+ "./scss/styles": "./scss/styles.scss",
36
+ "./scss/styles.scss": "./scss/styles.scss",
37
+ "./assets/css/styles": "./assets/css/styles.css",
38
+ "./assets/css/styles.css": "./assets/css/styles.css"
39
+ },
40
+ "files": [
41
+ "lib",
42
+ "es",
43
+ "assets",
44
+ "scss"
45
+ ],
46
+ "scripts": {
47
+ "clean": "rm -rf es && rm -rf lib && rm -rf assets && rm -rf scss",
48
+ "prepublishOnly": "npm run build",
49
+ "build": "../../scripts/prepare-package.sh --scss"
50
+ },
51
+ "devDependencies": {
52
+ "@panneau/data": "^3.0.163",
53
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
54
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
55
+ },
56
+ "peerDependencies": {
57
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
58
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
59
+ },
60
+ "dependencies": {
61
+ "@babel/runtime": "^7.13.10",
62
+ "@folklore/routes": "^0.2.36",
63
+ "@fortawesome/fontawesome-svg-core": "^6.5.2",
64
+ "@fortawesome/free-solid-svg-icons": "^6.5.2",
65
+ "@fortawesome/react-fontawesome": "^0.2.0",
66
+ "@micromag/core": "^0.3.703",
67
+ "@micromag/data": "^0.3.703",
68
+ "bootstrap": "^5.3.7",
69
+ "classnames": "^2.2.6",
70
+ "js-cookie": "^3.0.5",
71
+ "lodash": "^4.17.21",
72
+ "prop-types": "^15.7.2",
73
+ "react-intl": "^6.6.4",
74
+ "wouter": "^3.0.0"
75
+ },
76
+ "publishConfig": {
77
+ "access": "public",
78
+ "registry": "https://registry.npmjs.org/"
79
+ },
80
+ "gitHead": "15a0df01ed9d05f47a056fb2ff078aded803d33d"
81
+ }
@@ -0,0 +1 @@
1
+ @import '~@micromag/consent/assets/css/styles.css';