@justeattakeaway/pie-cookie-banner 0.11.5 → 0.11.7
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/dist/index.js +45 -47
- package/dist/react.js +11 -10
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -7,9 +7,7 @@ import "@justeattakeaway/pie-icon-button";
|
|
|
7
7
|
import "@justeattakeaway/pie-link";
|
|
8
8
|
import "@justeattakeaway/pie-modal";
|
|
9
9
|
import "@justeattakeaway/pie-switch";
|
|
10
|
-
|
|
11
|
-
customElements.get(i) ? console.warn(`PIE Web Component: "${i}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(i, e);
|
|
12
|
-
}
|
|
10
|
+
import { defineCustomElement as _ } from "@justeattakeaway/pie-webc-core";
|
|
13
11
|
const w = `*{margin:0}.c-cookieBanner{--cb-font-family: var(--dt-font-interactive-m-family);--cb-font-size: calc(var(--dt-font-body-l-size) * 1px);--cb-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--cb-font-weight: var(--dt-font-body-l-weight);--cb-padding-inline: var(--dt-spacing-d);--cb-padding-block: var(--dt-spacing-d);--cb-offset: 0;color-scheme:only dark;background-color:var(--dt-color-background-dark);color:var(--dt-color-content-inverse);font-family:var(--cb-font-family);font-size:var(--cb-font-size);line-height:var(--cb-line-height);font-weight:var(--cb-font-weight);padding-block-start:var(--cb-padding-block);padding-block-end:var(--cb-padding-block);max-height:432px;position:fixed;bottom:var(--cb-offset);left:var(--cb-offset);right:var(--cb-offset);border-top-left-radius:var(--dt-radius-rounded-c);border-top-right-radius:var(--dt-radius-rounded-c);z-index:var(--dt-z-index-cookie-banner)}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner{--cb-padding-inline: var(--dt-spacing-f);--cb-offset: var(--dt-spacing-d);max-height:90%;border-bottom-left-radius:var(--dt-radius-rounded-c);border-bottom-right-radius:var(--dt-radius-rounded-c)}}.c-cookieBanner[isCookieBannerHidden]{display:none}.c-cookieBanner-title,.c-cookieBanner-body,.c-cookieBanner-actions{padding-inline-start:var(--cb-padding-inline);padding-inline-end:var(--cb-padding-inline)}.c-cookieBanner-title{--cb-title-font-size: var(--dt-font-heading-s-size--narrow);--cb-title-line-height: var(--dt-font-heading-s-line-height--narrow);font-size:calc(var(--cb-title-font-size) * 1px);font-weight:var(--dt-font-heading-s-weight);line-height:calc(var(--cb-title-line-height) * 1px)}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-title{--cb-title-font-size: var(--dt-font-heading-s-size--wide);--cb-title-line-height: var(--dt-font-heading-s-line-height--wide)}}.c-cookieBanner-body{--cb-scroll-shadow-color: var(--dt-color-black);margin-block-start:var(--dt-spacing-a);max-height:200px;overflow-y:auto;background:linear-gradient(to bottom,transparent,var(--dt-color-background-dark) 75%) center bottom,linear-gradient(transparent,var(--cb-scroll-shadow-color)) center bottom;background-repeat:no-repeat;background-size:100% 48px,100% 8px;background-attachment:local,scroll}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-body{max-height:150px}}.c-cookieBanner-actions{--cb-actions-flex-dir: column;margin-block-start:var(--dt-spacing-d);display:flex;gap:var(--dt-spacing-d);flex-direction:var(--cb-actions-flex-dir)}.c-cookieBanner-actions>pie-link{text-align:center;align-self:center}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-actions{--cb-actions-flex-dir: row-reverse;justify-content:flex-start;align-items:center}}.c-cookieBanner-subheading{--cb-subheading-font-size: var(--dt-font-heading-s-size--narrow);--cb-subheading-line-height: var(--dt-font-heading-s-line-height--narrow);font-size:calc(var(--cb-subheading-font-size) * 1px);font-weight:var(--dt-font-heading-s-weight);line-height:calc(var(--cb-subheading-line-height) * 1px)}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-subheading{--cb-subheading-font-size: var(--dt-font-heading-s-size--wide);--cb-subheading-line-height: var(--dt-font-heading-s-line-height--wide)}}.c-cookieBanner-description{font-size:calc(var(--dt-font-body-s-size) * 1px);line-height:calc(var(--dt-font-body-s-line-height) * 1px)}.c-cookieBanner-preference{display:flex;gap:var(--dt-spacing-d);justify-content:space-between;margin-block:var(--dt-spacing-e)}.c-cookieBanner-preference p{margin-block-start:var(--dt-spacing-b)}.c-cookieBanner-preference:last-child{margin-block-end:0}
|
|
14
12
|
`, x = "pie-cookie-banner-accept-all", C = "pie-cookie-banner-necessary-only", B = "pie-cookie-banner-manage-prefs", $ = "pie-cookie-banner-prefs-saved", A = [
|
|
15
13
|
{
|
|
@@ -36,54 +34,54 @@ const w = `*{margin:0}.c-cookieBanner{--cb-font-family: var(--dt-font-interactiv
|
|
|
36
34
|
hasDescription: !0
|
|
37
35
|
}
|
|
38
36
|
];
|
|
39
|
-
function u(
|
|
40
|
-
console.error(`[localisation-utils]: ${
|
|
37
|
+
function u(a) {
|
|
38
|
+
console.error(`[localisation-utils]: ${a}`);
|
|
41
39
|
}
|
|
42
|
-
function
|
|
43
|
-
const n = (t) => String.prototype.split.call(e, t).filter(Boolean).reduce((
|
|
44
|
-
return typeof
|
|
40
|
+
function O(a, e) {
|
|
41
|
+
const n = (t) => String.prototype.split.call(e, t).filter(Boolean).reduce((r, o) => r != null && typeof r == "object" ? r[o] : r, a), i = n(/[,[\]]+?/) || n(/[,[\].]+?/);
|
|
42
|
+
return typeof i != "string" ? "" : i;
|
|
45
43
|
}
|
|
46
|
-
function b(
|
|
47
|
-
if (!
|
|
44
|
+
function b(a, e) {
|
|
45
|
+
if (!a)
|
|
48
46
|
throw new Error('"locale" parameter cannot be empty');
|
|
49
47
|
if (!e)
|
|
50
48
|
throw new Error('"key" parameter cannot be empty');
|
|
51
|
-
const n =
|
|
49
|
+
const n = O(a, e);
|
|
52
50
|
return n || (u(`Couldn't find a value for the key "${e}", it will be used as fallback.`), e);
|
|
53
51
|
}
|
|
54
|
-
function
|
|
55
|
-
const n =
|
|
52
|
+
function E(a) {
|
|
53
|
+
const n = a.map((t) => `(<${t}.*>.*</${t}>)`).join("|");
|
|
56
54
|
return new RegExp(n, "igm");
|
|
57
55
|
}
|
|
58
|
-
function T(
|
|
56
|
+
function T(a, e) {
|
|
59
57
|
const n = Object.keys(e);
|
|
60
58
|
if (n.length === 0)
|
|
61
|
-
return [
|
|
62
|
-
const
|
|
63
|
-
return
|
|
64
|
-
if (!t.match(
|
|
59
|
+
return [a];
|
|
60
|
+
const i = E(n);
|
|
61
|
+
return a.split(i).filter((t) => !!t).map((t) => {
|
|
62
|
+
if (!t.match(i))
|
|
65
63
|
return t;
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
64
|
+
const o = t.match(/<(.*)>(.*)<\/.*>/);
|
|
65
|
+
if (!o)
|
|
68
66
|
return t;
|
|
69
|
-
const [, d, c] =
|
|
67
|
+
const [, d, c] = o;
|
|
70
68
|
return [d, c];
|
|
71
69
|
}).map((t) => {
|
|
72
70
|
if (!Array.isArray(t))
|
|
73
71
|
return t;
|
|
74
|
-
const [
|
|
75
|
-
return c || typeof c == "function" ? c(d) : (u(`Custom tag "${
|
|
72
|
+
const [o, d] = t, c = e[o];
|
|
73
|
+
return c || typeof c == "function" ? c(d) : (u(`Custom tag "${o}" does not have a matching enhancer function`), d);
|
|
76
74
|
});
|
|
77
75
|
}
|
|
78
|
-
function M(
|
|
79
|
-
if (!
|
|
76
|
+
function M(a, e, n) {
|
|
77
|
+
if (!a)
|
|
80
78
|
throw new Error('"locale" parameter cannot be empty');
|
|
81
79
|
if (!e)
|
|
82
80
|
throw new Error('"key" parameter cannot be empty');
|
|
83
81
|
if (!n)
|
|
84
82
|
throw new Error('"customTagEnhancers" parameter cannot be empty');
|
|
85
|
-
const
|
|
86
|
-
return T(
|
|
83
|
+
const i = b(a, e);
|
|
84
|
+
return T(i, n);
|
|
87
85
|
}
|
|
88
86
|
const N = {
|
|
89
87
|
title: "Cookies",
|
|
@@ -93,7 +91,7 @@ const N = {
|
|
|
93
91
|
necessaryOnly: "Necessary only",
|
|
94
92
|
acceptAll: "Accept all"
|
|
95
93
|
}
|
|
96
|
-
},
|
|
94
|
+
}, S = {
|
|
97
95
|
title: "Manage your preferences",
|
|
98
96
|
description: "You can find all the information in the <linkCookieStatement>Cookie Statement</linkCookieStatement> and <linkCookieTechList>Cookie technology list</linkCookieTechList>.",
|
|
99
97
|
all: {
|
|
@@ -123,12 +121,12 @@ const N = {
|
|
|
123
121
|
}
|
|
124
122
|
}, z = {
|
|
125
123
|
banner: N,
|
|
126
|
-
preferencesManagement:
|
|
124
|
+
preferencesManagement: S
|
|
127
125
|
};
|
|
128
|
-
var
|
|
129
|
-
for (var t =
|
|
130
|
-
(
|
|
131
|
-
return
|
|
126
|
+
var P = Object.defineProperty, R = Object.getOwnPropertyDescriptor, p = (a, e, n, i) => {
|
|
127
|
+
for (var t = i > 1 ? void 0 : i ? R(e, n) : e, r = a.length - 1, o; r >= 0; r--)
|
|
128
|
+
(o = a[r]) && (t = (i ? o(e, n, t) : o(t)) || t);
|
|
129
|
+
return i && t && P(e, n, t), t;
|
|
132
130
|
};
|
|
133
131
|
const D = "pie-cookie-banner";
|
|
134
132
|
class l extends m {
|
|
@@ -141,12 +139,12 @@ class l extends m {
|
|
|
141
139
|
linkCookieStatement: (e) => s`<pie-link href="#" size="small" target="_blank">${e}</pie-link>`,
|
|
142
140
|
linkCookieTechList: (e) => s`<pie-link href="#" size="small" target="_blank">${e}</pie-link>`
|
|
143
141
|
}, this._dispatchCookieBannerCustomEvent = (e, n) => {
|
|
144
|
-
const
|
|
142
|
+
const i = new CustomEvent(e, {
|
|
145
143
|
bubbles: !0,
|
|
146
144
|
composed: !0,
|
|
147
145
|
detail: n
|
|
148
146
|
});
|
|
149
|
-
this.dispatchEvent(
|
|
147
|
+
this.dispatchEvent(i);
|
|
150
148
|
}, this._onNecessaryOnly = () => {
|
|
151
149
|
this._dispatchCookieBannerCustomEvent(C), this._isCookieBannerHidden = !0;
|
|
152
150
|
}, this._onAcceptAll = () => {
|
|
@@ -154,14 +152,14 @@ class l extends m {
|
|
|
154
152
|
}, this._openManagePreferencesModal = () => {
|
|
155
153
|
this._isCookieBannerHidden = !0, this._dispatchCookieBannerCustomEvent(B), this._isModalOpen = !0;
|
|
156
154
|
}, this._handleSwitchStates = (e) => {
|
|
157
|
-
const { id: n } = e == null ? void 0 : e.currentTarget,
|
|
158
|
-
if (n ===
|
|
155
|
+
const { id: n } = e == null ? void 0 : e.currentTarget, i = [...this._preferencesNodes].find(({ id: t }) => t === "all");
|
|
156
|
+
if (n === i.id) {
|
|
159
157
|
const t = e.detail;
|
|
160
|
-
this._preferencesNodes.forEach((
|
|
161
|
-
|
|
158
|
+
this._preferencesNodes.forEach((r) => {
|
|
159
|
+
r.isChecked = r.isDisabled ? r.isChecked : t;
|
|
162
160
|
});
|
|
163
161
|
} else
|
|
164
|
-
|
|
162
|
+
i.isChecked = [...this._preferencesNodes].filter(({ id: t }) => t !== "all").every(({ isChecked: t }) => t);
|
|
165
163
|
};
|
|
166
164
|
}
|
|
167
165
|
_localiseText(e) {
|
|
@@ -188,8 +186,8 @@ class l extends m {
|
|
|
188
186
|
*/
|
|
189
187
|
_handlePreferencesSaved() {
|
|
190
188
|
let e = {};
|
|
191
|
-
[...this._preferencesNodes].filter(({ id: n }) => n !== "all").forEach(({ id: n, isChecked:
|
|
192
|
-
e = { ...e, [n]:
|
|
189
|
+
[...this._preferencesNodes].filter(({ id: n }) => n !== "all").forEach(({ id: n, isChecked: i }) => {
|
|
190
|
+
e = { ...e, [n]: i };
|
|
193
191
|
}), this._dispatchCookieBannerCustomEvent($, e), this._isModalOpen = !1, this._isCookieBannerHidden = !0;
|
|
194
192
|
}
|
|
195
193
|
/**
|
|
@@ -199,21 +197,21 @@ class l extends m {
|
|
|
199
197
|
renderPreference({
|
|
200
198
|
id: e,
|
|
201
199
|
isChecked: n,
|
|
202
|
-
isDisabled:
|
|
200
|
+
isDisabled: i,
|
|
203
201
|
hasDivider: t,
|
|
204
|
-
hasDescription:
|
|
202
|
+
hasDescription: r
|
|
205
203
|
}) {
|
|
206
|
-
const
|
|
204
|
+
const o = this._localiseText(`preferencesManagement.${e}.title`), d = `preferencesManagement.${e}.description`, c = r && this._localiseText(d);
|
|
207
205
|
return s`
|
|
208
206
|
<div class="c-cookieBanner-preference">
|
|
209
207
|
<div>
|
|
210
|
-
<h3 class="c-cookieBanner-subheading">${
|
|
208
|
+
<h3 class="c-cookieBanner-subheading">${o}</h3>
|
|
211
209
|
${c ? s`<p class="c-cookieBanner-description">${c}</p>` : h}
|
|
212
210
|
</div>
|
|
213
211
|
<pie-switch
|
|
214
212
|
id="${e}"
|
|
215
213
|
?isChecked="${n}"
|
|
216
|
-
?isDisabled="${
|
|
214
|
+
?isDisabled="${i}"
|
|
217
215
|
@pie-switch-changed="${this._handleSwitchStates}">
|
|
218
216
|
</pie-switch>
|
|
219
217
|
</div>
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as o } from "@lit/react";
|
|
3
|
-
import { PieCookieBanner as
|
|
4
|
-
import { ON_COOKIE_BANNER_ACCEPT_ALL as
|
|
3
|
+
import { PieCookieBanner as r } from "./index.js";
|
|
4
|
+
import { ON_COOKIE_BANNER_ACCEPT_ALL as A, ON_COOKIE_BANNER_MANAGE_PREFS as B, ON_COOKIE_BANNER_NECESSARY_ONLY as f, ON_COOKIE_BANNER_PREFS_SAVED as l, preferences as R } from "./index.js";
|
|
5
5
|
import "lit";
|
|
6
6
|
import "lit/decorators.js";
|
|
7
7
|
import "lit/directives/repeat.js";
|
|
@@ -11,9 +11,10 @@ import "@justeattakeaway/pie-icon-button";
|
|
|
11
11
|
import "@justeattakeaway/pie-link";
|
|
12
12
|
import "@justeattakeaway/pie-modal";
|
|
13
13
|
import "@justeattakeaway/pie-switch";
|
|
14
|
-
|
|
14
|
+
import "@justeattakeaway/pie-webc-core";
|
|
15
|
+
const O = o({
|
|
15
16
|
displayName: "PieCookieBanner",
|
|
16
|
-
elementClass:
|
|
17
|
+
elementClass: r,
|
|
17
18
|
react: e,
|
|
18
19
|
tagName: "pie-cookie-banner",
|
|
19
20
|
events: {
|
|
@@ -28,10 +29,10 @@ const E = o({
|
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
31
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
A as ON_COOKIE_BANNER_ACCEPT_ALL,
|
|
33
|
+
B as ON_COOKIE_BANNER_MANAGE_PREFS,
|
|
34
|
+
f as ON_COOKIE_BANNER_NECESSARY_ONLY,
|
|
35
|
+
l as ON_COOKIE_BANNER_PREFS_SAVED,
|
|
36
|
+
O as PieCookieBanner,
|
|
37
|
+
R as preferences
|
|
37
38
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-cookie-banner",
|
|
3
3
|
"description": "PIE Design System Cookie Banner built using Web Components",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
"license": "Apache-2.0",
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@justeat/pie-design-tokens": "5.9.0",
|
|
33
|
-
"@justeattakeaway/pie-components-config": "0.6.
|
|
33
|
+
"@justeattakeaway/pie-components-config": "0.6.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@justeattakeaway/pie-button": "0.40.
|
|
37
|
-
"@justeattakeaway/pie-divider": "0.9.
|
|
38
|
-
"@justeattakeaway/pie-icon-button": "0.
|
|
39
|
-
"@justeattakeaway/pie-link": "0.11.
|
|
40
|
-
"@justeattakeaway/pie-modal": "0.
|
|
41
|
-
"@justeattakeaway/pie-switch": "0.18.
|
|
42
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
36
|
+
"@justeattakeaway/pie-button": "0.40.1",
|
|
37
|
+
"@justeattakeaway/pie-divider": "0.9.3",
|
|
38
|
+
"@justeattakeaway/pie-icon-button": "0.24.0",
|
|
39
|
+
"@justeattakeaway/pie-link": "0.11.3",
|
|
40
|
+
"@justeattakeaway/pie-modal": "0.35.0",
|
|
41
|
+
"@justeattakeaway/pie-switch": "0.18.1",
|
|
42
|
+
"@justeattakeaway/pie-webc-core": "0.13.0"
|
|
43
43
|
},
|
|
44
44
|
"volta": {
|
|
45
45
|
"extends": "../../../package.json"
|