@justeattakeaway/pie-cookie-banner 1.6.39 → 1.7.0

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.
@@ -78,7 +78,7 @@
78
78
  "type": {
79
79
  "text": "DefaultProps"
80
80
  },
81
- "default": "{\n hasPrimaryActionsOnly: false,\n defaultPreferences: {},\n country: Country.GREAT_BRITAIN,\n language: Language.ENGLISH,\n cookieStatementLink: '',\n cookieTechnologiesLink: '',\n}"
81
+ "default": "{\n hasPrimaryActionsOnly: false,\n defaultPreferences: {},\n country: Country.GREAT_BRITAIN,\n language: Language.ENGLISH,\n cookieStatementLink: '',\n cookieTechnologiesLink: '',\n openLinksInSameTab: false,\n}"
82
82
  },
83
83
  {
84
84
  "kind": "variable",
@@ -240,6 +240,11 @@
240
240
  "name": "language",
241
241
  "privacy": "public"
242
242
  },
243
+ {
244
+ "kind": "field",
245
+ "name": "openLinksInSameTab",
246
+ "privacy": "public"
247
+ },
243
248
  {
244
249
  "kind": "field",
245
250
  "name": "_preferencesNodes",
@@ -247,6 +252,13 @@
247
252
  "text": "NodeListOf<PieSwitch>"
248
253
  }
249
254
  },
255
+ {
256
+ "kind": "field",
257
+ "name": "_linkTargetAttribute",
258
+ "privacy": "private",
259
+ "description": "Returns the target attribute value for external links based on the openLinksInSameTab prop.\n- false (default): returns '_blank' (new tab)\n- true: returns '_self' (same tab)",
260
+ "readonly": true
261
+ },
250
262
  {
251
263
  "kind": "method",
252
264
  "name": "_setLocaleBasedOnCountryAndLanguage",
@@ -299,7 +311,7 @@
299
311
  "text": "CustomTagEnhancers"
300
312
  },
301
313
  "privacy": "private",
302
- "default": "{\n linkStatement: (tagContent: string) => html`<pie-link href=\"${this.cookieStatementLink}\" variant=\"inverse\" target=\"_blank\" data-test-id=\"cookie-statement-link\">${tagContent}</pie-link>`,\n linkNecessaryOnly: (tagContent: string) => html`<pie-link data-test-id=\"body-necessary-only\" tag=\"button\" variant=\"inverse\" @click=\"${this._onNecessaryOnly}\">${tagContent}</pie-link>`,\n linkManagePreferences: (tagContent: string) => html`<pie-link data-test-id=\"body-manage-prefs\" tag=\"button\" variant=\"inverse\" @click=\"${this._openManagePreferencesModal}\">${tagContent}</pie-link>`,\n linkAcceptAll: (tagContent: string) => html`<pie-link data-test-id=\"body-accept-all\" tag=\"button\" variant=\"inverse\" @click=\"${this._onAcceptAll}\">${tagContent}</pie-link>`,\n linkCookieStatement: (tagContent: string) => html`<pie-link href=\"${this.cookieStatementLink}\" size=\"small\" target=\"_blank\" data-test-id=\"cookie-statement-link\">${tagContent}</pie-link>`,\n linkCookieTechList: (tagContent: string) => html`<pie-link href=\"${this.cookieTechnologiesLink}\" size=\"small\" target=\"_blank\" data-test-id=\"cookie-technology-link\">${tagContent}</pie-link>`,\n }"
314
+ "default": "{\n linkStatement: (tagContent: string) => html`<pie-link href=\"${this.cookieStatementLink}\" variant=\"inverse\" target=\"${this._linkTargetAttribute}\" data-test-id=\"cookie-statement-link\">${tagContent}</pie-link>`,\n linkNecessaryOnly: (tagContent: string) => html`<pie-link data-test-id=\"body-necessary-only\" tag=\"button\" variant=\"inverse\" @click=\"${this._onNecessaryOnly}\">${tagContent}</pie-link>`,\n linkManagePreferences: (tagContent: string) => html`<pie-link data-test-id=\"body-manage-prefs\" tag=\"button\" variant=\"inverse\" @click=\"${this._openManagePreferencesModal}\">${tagContent}</pie-link>`,\n linkAcceptAll: (tagContent: string) => html`<pie-link data-test-id=\"body-accept-all\" tag=\"button\" variant=\"inverse\" @click=\"${this._onAcceptAll}\">${tagContent}</pie-link>`,\n linkCookieStatement: (tagContent: string) => html`<pie-link href=\"${this.cookieStatementLink}\" size=\"small\" target=\"${this._linkTargetAttribute}\" data-test-id=\"cookie-statement-link\">${tagContent}</pie-link>`,\n linkCookieTechList: (tagContent: string) => html`<pie-link href=\"${this.cookieTechnologiesLink}\" size=\"small\" target=\"${this._linkTargetAttribute}\" data-test-id=\"cookie-technology-link\">${tagContent}</pie-link>`,\n }"
303
315
  },
304
316
  {
305
317
  "kind": "method",
package/dist/index.d.ts CHANGED
@@ -78,6 +78,12 @@ export declare interface CookieBannerProps {
78
78
  * or { 'functional': true, 'personalized': true, 'analytical': true }
79
79
  */
80
80
  defaultPreferences?: Partial<Record<PreferenceIds, boolean>>;
81
+ /**
82
+ * When true, external links (Cookie Statement, Cookie Technologies)
83
+ * will open in the same tab (`target="_self"`).
84
+ * When false (default), links open in a new browser tab (`target="_blank"`).
85
+ */
86
+ openLinksInSameTab?: boolean;
81
87
  }
82
88
 
83
89
  export declare const Country: {
@@ -147,7 +153,14 @@ export declare class PieCookieBanner extends PieElement implements CookieBannerP
147
153
  cookieTechnologiesLink: string;
148
154
  country: string;
149
155
  language: string;
156
+ openLinksInSameTab: boolean;
150
157
  _preferencesNodes: NodeListOf<PieSwitch>;
158
+ /**
159
+ * Returns the target attribute value for external links based on the openLinksInSameTab prop.
160
+ * - false (default): returns '_blank' (new tab)
161
+ * - true: returns '_self' (same tab)
162
+ */
163
+ private get _linkTargetAttribute();
151
164
  updated(changedProperties: PropertyValues<this>): Promise<void>;
152
165
  private _setLocaleBasedOnCountryAndLanguage;
153
166
  /**
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { LitElement as x, unsafeCSS as R, html as d, nothing as N } from "lit";
2
- import { state as y, property as u, queryAll as T } from "lit/decorators.js";
3
- import { repeat as C } from "lit/directives/repeat.js";
1
+ import { LitElement as T, unsafeCSS as x, html as p, nothing as N } from "lit";
2
+ import { state as y, property as f, queryAll as I } from "lit/decorators.js";
3
+ import { repeat as R } from "lit/directives/repeat.js";
4
4
  import "@justeattakeaway/pie-button";
5
5
  import "@justeattakeaway/pie-divider";
6
6
  import "@justeattakeaway/pie-icon-button";
7
7
  import "@justeattakeaway/pie-link";
8
8
  import "@justeattakeaway/pie-modal";
9
9
  import "@justeattakeaway/pie-switch";
10
- import { safeCustomElement as w, dispatchCustomEvent as b } from "@justeattakeaway/pie-webc-core";
11
- import E from "@justeattakeaway/pie-cookie-banner/locales/en.js";
12
- const I = (e, t, n) => {
10
+ import { safeCustomElement as C, dispatchCustomEvent as b } from "@justeattakeaway/pie-webc-core";
11
+ import L from "@justeattakeaway/pie-cookie-banner/locales/en.js";
12
+ const w = (e, t, n) => {
13
13
  const a = e[t];
14
14
  return a ? typeof a == "function" ? a() : Promise.resolve(a) : new Promise((o, s) => {
15
15
  (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
@@ -21,12 +21,12 @@ const I = (e, t, n) => {
21
21
  )
22
22
  );
23
23
  });
24
- }, k = class k extends x {
24
+ }, k = class k extends T {
25
25
  willUpdate() {
26
26
  this.getAttribute("v") || this.setAttribute("v", k.v);
27
27
  }
28
28
  };
29
- k.v = "1.6.39";
29
+ k.v = "1.7.0";
30
30
  let A = k;
31
31
  const O = "*,*:after,*:before{box-sizing:inherit}*{margin:0}.c-cookieBanner{--cb-font-family: var(--dt-font-interactive-l-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}@media (prefers-reduced-motion: no-preference){.c-cookieBanner{animation:.5s animate-enter ease-out}@keyframes animate-enter{0%{transform:translate3d(0,75%,0)}to{transform:translateZ(0)}}}.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-start:var(--dt-spacing-e);margin-block-end:var(--dt-spacing-e)}.c-cookieBanner-preference p{margin-block-start:var(--dt-spacing-b)}.c-cookieBanner-preference:last-child{margin-block-end:0}", i = {
32
32
  BULGARIAN: "bg",
@@ -84,13 +84,14 @@ const O = "*,*:after,*:before{box-sizing:inherit}*{margin:0}.c-cookieBanner{--cb
84
84
  id: "personalized",
85
85
  hasDescription: !0
86
86
  }
87
- ], g = {
87
+ ], h = {
88
88
  hasPrimaryActionsOnly: !1,
89
89
  defaultPreferences: {},
90
90
  country: r.GREAT_BRITAIN,
91
91
  language: i.ENGLISH,
92
92
  cookieStatementLink: "",
93
- cookieTechnologiesLink: ""
93
+ cookieTechnologiesLink: "",
94
+ openLinksInSameTab: !1
94
95
  }, m = /* @__PURE__ */ new Set([
95
96
  `${i.BULGARIAN}`,
96
97
  `${i.DANISH}`,
@@ -126,18 +127,18 @@ const O = "*,*:after,*:before{box-sizing:inherit}*{margin:0}.c-cookieBanner{--cb
126
127
  [r.SPAIN, `${i.SPANISH}`],
127
128
  [r.SWITZERLAND, `${i.GERMAN}`]
128
129
  ]);
129
- function L(e) {
130
+ function E(e) {
130
131
  console.error(`[localisation-utils]: ${e}`);
131
132
  }
132
133
  function j(e, t) {
133
- const n = (o) => String.prototype.split.call(t, o).filter(Boolean).reduce((s, c) => s != null && typeof s == "object" ? s[c] : s, e), a = n(/[,[\]]+?/) || n(/[,[\].]+?/);
134
+ const n = (o) => String.prototype.split.call(t, o).filter(Boolean).reduce((s, l) => s != null && typeof s == "object" ? s[l] : s, e), a = n(/[,[\]]+?/) || n(/[,[\].]+?/);
134
135
  return typeof a != "string" ? "" : a;
135
136
  }
136
137
  function S(e, t) {
137
138
  if (!e) throw new Error('"locale" parameter cannot be empty');
138
139
  if (!t) throw new Error('"key" parameter cannot be empty');
139
140
  const n = j(e, t);
140
- return n || (L(`Couldn't find a value for the key "${t}", it will be used as fallback.`), t);
141
+ return n || (E(`Couldn't find a value for the key "${t}", it will be used as fallback.`), t);
141
142
  }
142
143
  function U(e) {
143
144
  const n = e.map((o) => `(<${o}.*>.*</${o}>)`).join("|");
@@ -149,14 +150,14 @@ function F(e, t) {
149
150
  const a = U(n);
150
151
  return e.split(a).filter((o) => !!o).map((o) => {
151
152
  if (!o.match(a)) return o;
152
- const c = o.match(/<(.*)>(.*)<\/.*>/);
153
- if (!c) return o;
154
- const [, h, f] = c;
155
- return [h, f];
153
+ const l = o.match(/<(.*)>(.*)<\/.*>/);
154
+ if (!l) return o;
155
+ const [, g, u] = l;
156
+ return [g, u];
156
157
  }).map((o) => {
157
158
  if (!Array.isArray(o)) return o;
158
- const [c, h] = o, f = t[c];
159
- return f || typeof f == "function" ? f(h) : (L(`Custom tag "${c}" does not have a matching enhancer function`), h);
159
+ const [l, g] = o, u = t[l];
160
+ return u || typeof u == "function" ? u(g) : (E(`Custom tag "${l}" does not have a matching enhancer function`), g);
160
161
  });
161
162
  }
162
163
  function K(e, t, n) {
@@ -166,26 +167,26 @@ function K(e, t, n) {
166
167
  const a = S(e, t);
167
168
  return F(a, n);
168
169
  }
169
- var V = Object.defineProperty, W = Object.getOwnPropertyDescriptor, p = (e, t, n, a) => {
170
- for (var o = a > 1 ? void 0 : a ? W(t, n) : t, s = e.length - 1, c; s >= 0; s--)
171
- (c = e[s]) && (o = (a ? c(t, n, o) : c(o)) || o);
170
+ var V = Object.defineProperty, W = Object.getOwnPropertyDescriptor, d = (e, t, n, a) => {
171
+ for (var o = a > 1 ? void 0 : a ? W(t, n) : t, s = e.length - 1, l; s >= 0; s--)
172
+ (l = e[s]) && (o = (a ? l(t, n, o) : l(o)) || o);
172
173
  return a && o && V(t, n, o), o;
173
174
  };
174
- let l = class extends A {
175
+ let c = class extends A {
175
176
  constructor() {
176
- super(...arguments), this._isCookieBannerHidden = !1, this._isModalOpen = !1, this._locale = E, this.hasPrimaryActionsOnly = g.hasPrimaryActionsOnly, this.defaultPreferences = g.defaultPreferences, this.cookieStatementLink = g.cookieStatementLink, this.cookieTechnologiesLink = g.cookieTechnologiesLink, this.country = g.country, this.language = g.language, this._getLocaleString = (e, t) => {
177
+ super(...arguments), this._isCookieBannerHidden = !1, this._isModalOpen = !1, this._locale = L, this.hasPrimaryActionsOnly = h.hasPrimaryActionsOnly, this.defaultPreferences = h.defaultPreferences, this.cookieStatementLink = h.cookieStatementLink, this.cookieTechnologiesLink = h.cookieTechnologiesLink, this.country = h.country, this.language = h.language, this.openLinksInSameTab = h.openLinksInSameTab, this._getLocaleString = (e, t) => {
177
178
  let n = `${e}-${t}`.toLowerCase();
178
179
  if (m.has(n) || (n = `${e}`.toLowerCase(), m.has(n)))
179
180
  return n;
180
181
  const a = G.get(t.toLowerCase());
181
- return a && m.has(a) ? a : `${g.language}`;
182
+ return a && m.has(a) ? a : `${h.language}`;
182
183
  }, this._customTagEnhancers = {
183
- linkStatement: (e) => d`<pie-link href="${this.cookieStatementLink}" variant="inverse" target="_blank" data-test-id="cookie-statement-link">${e}</pie-link>`,
184
- linkNecessaryOnly: (e) => d`<pie-link data-test-id="body-necessary-only" tag="button" variant="inverse" @click="${this._onNecessaryOnly}">${e}</pie-link>`,
185
- linkManagePreferences: (e) => d`<pie-link data-test-id="body-manage-prefs" tag="button" variant="inverse" @click="${this._openManagePreferencesModal}">${e}</pie-link>`,
186
- linkAcceptAll: (e) => d`<pie-link data-test-id="body-accept-all" tag="button" variant="inverse" @click="${this._onAcceptAll}">${e}</pie-link>`,
187
- linkCookieStatement: (e) => d`<pie-link href="${this.cookieStatementLink}" size="small" target="_blank" data-test-id="cookie-statement-link">${e}</pie-link>`,
188
- linkCookieTechList: (e) => d`<pie-link href="${this.cookieTechnologiesLink}" size="small" target="_blank" data-test-id="cookie-technology-link">${e}</pie-link>`
184
+ linkStatement: (e) => p`<pie-link href="${this.cookieStatementLink}" variant="inverse" target="${this._linkTargetAttribute}" data-test-id="cookie-statement-link">${e}</pie-link>`,
185
+ linkNecessaryOnly: (e) => p`<pie-link data-test-id="body-necessary-only" tag="button" variant="inverse" @click="${this._onNecessaryOnly}">${e}</pie-link>`,
186
+ linkManagePreferences: (e) => p`<pie-link data-test-id="body-manage-prefs" tag="button" variant="inverse" @click="${this._openManagePreferencesModal}">${e}</pie-link>`,
187
+ linkAcceptAll: (e) => p`<pie-link data-test-id="body-accept-all" tag="button" variant="inverse" @click="${this._onAcceptAll}">${e}</pie-link>`,
188
+ linkCookieStatement: (e) => p`<pie-link href="${this.cookieStatementLink}" size="small" target="${this._linkTargetAttribute}" data-test-id="cookie-statement-link">${e}</pie-link>`,
189
+ linkCookieTechList: (e) => p`<pie-link href="${this.cookieTechnologiesLink}" size="small" target="${this._linkTargetAttribute}" data-test-id="cookie-technology-link">${e}</pie-link>`
189
190
  }, this._onNecessaryOnly = () => {
190
191
  b(this, P), this._isCookieBannerHidden = !0;
191
192
  }, this._onAcceptAll = () => {
@@ -203,6 +204,14 @@ let l = class extends A {
203
204
  n.checked = [...this._preferencesNodes].filter(({ id: a }) => a !== "all").every(({ checked: a }) => a);
204
205
  };
205
206
  }
207
+ /**
208
+ * Returns the target attribute value for external links based on the openLinksInSameTab prop.
209
+ * - false (default): returns '_blank' (new tab)
210
+ * - true: returns '_self' (same tab)
211
+ */
212
+ get _linkTargetAttribute() {
213
+ return this.openLinksInSameTab ? "_self" : "_blank";
214
+ }
206
215
  async updated(e) {
207
216
  (e.has("language") || e.has("country")) && await this._setLocaleBasedOnCountryAndLanguage(this.language, this.country);
208
217
  }
@@ -210,9 +219,9 @@ let l = class extends A {
210
219
  async _setLocaleBasedOnCountryAndLanguage(e, t) {
211
220
  try {
212
221
  const n = this._getLocaleString(e, t);
213
- this._locale = (await I(/* @__PURE__ */ Object.assign({ "../locales/bg.js": () => import("./bg-DGJESQ4e.js"), "../locales/ca.js": () => import("./ca-Bcf7sXQS.js"), "../locales/da.js": () => import("./da-zmkmo2qP.js"), "../locales/de.js": () => import("./de-CCDQDaL_.js"), "../locales/en-fr.js": () => import("./en-fr-B3W1OBz4.js"), "../locales/en.js": () => import("./en-Cg12pw29.js"), "../locales/es.js": () => import("./es-BGd5IeE8.js"), "../locales/fr-fr.js": () => import("./fr-fr-Bj0z2tFA.js"), "../locales/fr.js": () => import("./fr-ZJirJTQ1.js"), "../locales/he.js": () => import("./he-CD4nZodw.js"), "../locales/it.js": () => import("./it-C20n5M6-.js"), "../locales/nl.js": () => import("./nl-potC62A2.js"), "../locales/pl.js": () => import("./pl-BZMXvf-W.js"), "../locales/sk.js": () => import("./sk-B2GkzqzB.js") }), `../locales/${n}.js`, 3)).default;
222
+ this._locale = (await w(/* @__PURE__ */ Object.assign({ "../locales/bg.js": () => import("./bg-DGJESQ4e.js"), "../locales/ca.js": () => import("./ca-Bcf7sXQS.js"), "../locales/da.js": () => import("./da-zmkmo2qP.js"), "../locales/de.js": () => import("./de-CCDQDaL_.js"), "../locales/en-fr.js": () => import("./en-fr-B3W1OBz4.js"), "../locales/en.js": () => import("./en-Cg12pw29.js"), "../locales/es.js": () => import("./es-BGd5IeE8.js"), "../locales/fr-fr.js": () => import("./fr-fr-Bj0z2tFA.js"), "../locales/fr.js": () => import("./fr-ZJirJTQ1.js"), "../locales/he.js": () => import("./he-CD4nZodw.js"), "../locales/it.js": () => import("./it-C20n5M6-.js"), "../locales/nl.js": () => import("./nl-potC62A2.js"), "../locales/pl.js": () => import("./pl-BZMXvf-W.js"), "../locales/sk.js": () => import("./sk-B2GkzqzB.js") }), `../locales/${n}.js`, 3)).default;
214
223
  } catch {
215
- this._locale = E;
224
+ this._locale = L;
216
225
  }
217
226
  }
218
227
  _localiseText(e) {
@@ -255,15 +264,15 @@ let l = class extends A {
255
264
  hasDescription: o
256
265
  }) {
257
266
  var _;
258
- const s = this._localiseText(`preferencesManagement.${e}.title`), c = `preferencesManagement.${e}.description`, h = o && this._localiseText(c), v = ["functional", "personalized", "analytical"].every((B) => {
267
+ const s = this._localiseText(`preferencesManagement.${e}.title`), l = `preferencesManagement.${e}.description`, g = o && this._localiseText(l), v = ["functional", "personalized", "analytical"].every((B) => {
259
268
  var $;
260
269
  return (($ = this.defaultPreferences) == null ? void 0 : $[B]) === !0;
261
270
  });
262
- return d`
271
+ return p`
263
272
  <div class="c-cookieBanner-preference">
264
273
  <div>
265
274
  <h3 class="c-cookieBanner-subheading">${s}</h3>
266
- ${h ? d`<p class="c-cookieBanner-description">${h}</p>` : N}
275
+ ${g ? p`<p class="c-cookieBanner-description">${g}</p>` : N}
267
276
  </div>
268
277
  <pie-switch
269
278
  id="${e}"
@@ -272,18 +281,18 @@ let l = class extends A {
272
281
  @change="${this._handleSwitchStates}">
273
282
  </pie-switch>
274
283
  </div>
275
- ${a ? d`<pie-divider></pie-divider>` : N}`;
284
+ ${a ? p`<pie-divider></pie-divider>` : N}`;
276
285
  }
277
286
  /**
278
287
  * Renders the modal content.
279
288
  * @private
280
289
  */
281
290
  renderModalContent() {
282
- return d`
291
+ return p`
283
292
  <p class="c-cookieBanner-description" data-test-id="modal-description">
284
293
  ${this._localiseRichText("preferencesManagement.description")}
285
294
  </p>
286
- ${C(
295
+ ${R(
287
296
  z,
288
297
  ({ id: e }) => e,
289
298
  (e) => this.renderPreference(e)
@@ -294,7 +303,7 @@ let l = class extends A {
294
303
  text: this._localiseText("preferencesManagement.cta.save.label"),
295
304
  ariaLabel: this._localiseText("preferencesManagement.cta.save.label")
296
305
  };
297
- return d`
306
+ return p`
298
307
  <pie-modal
299
308
  .isOpen="${this._isModalOpen}"
300
309
  hasBackButton
@@ -341,40 +350,43 @@ let l = class extends A {
341
350
  </aside>`;
342
351
  }
343
352
  };
344
- l.styles = R(O);
345
- p([
353
+ c.styles = x(O);
354
+ d([
346
355
  y()
347
- ], l.prototype, "_isCookieBannerHidden", 2);
348
- p([
356
+ ], c.prototype, "_isCookieBannerHidden", 2);
357
+ d([
349
358
  y()
350
- ], l.prototype, "_isModalOpen", 2);
351
- p([
359
+ ], c.prototype, "_isModalOpen", 2);
360
+ d([
352
361
  y()
353
- ], l.prototype, "_locale", 2);
354
- p([
355
- u({ type: Boolean })
356
- ], l.prototype, "hasPrimaryActionsOnly", 2);
357
- p([
358
- u({ type: Object })
359
- ], l.prototype, "defaultPreferences", 2);
360
- p([
361
- u({ type: String })
362
- ], l.prototype, "cookieStatementLink", 2);
363
- p([
364
- u({ type: String })
365
- ], l.prototype, "cookieTechnologiesLink", 2);
366
- p([
367
- u({ type: String })
368
- ], l.prototype, "country", 2);
369
- p([
370
- u({ type: String })
371
- ], l.prototype, "language", 2);
372
- p([
373
- T("pie-switch")
374
- ], l.prototype, "_preferencesNodes", 2);
375
- l = p([
376
- w("pie-cookie-banner")
377
- ], l);
362
+ ], c.prototype, "_locale", 2);
363
+ d([
364
+ f({ type: Boolean })
365
+ ], c.prototype, "hasPrimaryActionsOnly", 2);
366
+ d([
367
+ f({ type: Object })
368
+ ], c.prototype, "defaultPreferences", 2);
369
+ d([
370
+ f({ type: String })
371
+ ], c.prototype, "cookieStatementLink", 2);
372
+ d([
373
+ f({ type: String })
374
+ ], c.prototype, "cookieTechnologiesLink", 2);
375
+ d([
376
+ f({ type: String })
377
+ ], c.prototype, "country", 2);
378
+ d([
379
+ f({ type: String })
380
+ ], c.prototype, "language", 2);
381
+ d([
382
+ f({ type: Boolean })
383
+ ], c.prototype, "openLinksInSameTab", 2);
384
+ d([
385
+ I("pie-switch")
386
+ ], c.prototype, "_preferencesNodes", 2);
387
+ c = d([
388
+ C("pie-cookie-banner")
389
+ ], c);
378
390
  export {
379
391
  r as Country,
380
392
  i as Language,
@@ -382,9 +394,9 @@ export {
382
394
  M as ON_COOKIE_BANNER_MANAGE_PREFS,
383
395
  P as ON_COOKIE_BANNER_NECESSARY_ONLY,
384
396
  D as ON_COOKIE_BANNER_PREFS_SAVED,
385
- l as PieCookieBanner,
397
+ c as PieCookieBanner,
386
398
  m as availableLocales,
387
399
  G as defaultLocaleForCountry,
388
- g as defaultProps,
400
+ h as defaultProps,
389
401
  z as preferences
390
402
  };
package/dist/react.d.ts CHANGED
@@ -79,6 +79,12 @@ export declare interface CookieBannerProps {
79
79
  * or { 'functional': true, 'personalized': true, 'analytical': true }
80
80
  */
81
81
  defaultPreferences?: Partial<Record<PreferenceIds, boolean>>;
82
+ /**
83
+ * When true, external links (Cookie Statement, Cookie Technologies)
84
+ * will open in the same tab (`target="_self"`).
85
+ * When false (default), links open in a new browser tab (`target="_blank"`).
86
+ */
87
+ openLinksInSameTab?: boolean;
82
88
  }
83
89
 
84
90
  export declare const Country: {
@@ -150,7 +156,14 @@ declare class PieCookieBanner_2 extends PieElement implements CookieBannerProps
150
156
  cookieTechnologiesLink: string;
151
157
  country: string;
152
158
  language: string;
159
+ openLinksInSameTab: boolean;
153
160
  _preferencesNodes: NodeListOf<PieSwitch>;
161
+ /**
162
+ * Returns the target attribute value for external links based on the openLinksInSameTab prop.
163
+ * - false (default): returns '_blank' (new tab)
164
+ * - true: returns '_self' (same tab)
165
+ */
166
+ private get _linkTargetAttribute();
154
167
  updated(changedProperties: PropertyValues<this>): Promise<void>;
155
168
  private _setLocaleBasedOnCountryAndLanguage;
156
169
  /**
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": "1.6.39",
4
+ "version": "1.7.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -51,19 +51,19 @@
51
51
  "devDependencies": {
52
52
  "@custom-elements-manifest/analyzer": "0.9.0",
53
53
  "@justeattakeaway/pie-components-config": "0.21.0",
54
- "@justeattakeaway/pie-css": "0.26.0",
54
+ "@justeattakeaway/pie-css": "0.26.1",
55
55
  "@justeattakeaway/pie-monorepo-utils": "0.7.0",
56
56
  "@justeattakeaway/pie-wrapper-react": "0.14.3",
57
57
  "cem-plugin-module-file-extensions": "0.0.5"
58
58
  },
59
59
  "dependencies": {
60
- "@justeattakeaway/pie-button": "1.10.1",
61
- "@justeattakeaway/pie-divider": "1.5.6",
62
- "@justeattakeaway/pie-icon-button": "2.3.5",
63
- "@justeattakeaway/pie-link": "1.3.7",
64
- "@justeattakeaway/pie-modal": "1.22.2",
65
- "@justeattakeaway/pie-switch": "2.3.9",
66
- "@justeattakeaway/pie-webc-core": "6.0.0"
60
+ "@justeattakeaway/pie-button": "1.10.2",
61
+ "@justeattakeaway/pie-divider": "1.5.7",
62
+ "@justeattakeaway/pie-icon-button": "2.4.0",
63
+ "@justeattakeaway/pie-link": "1.3.8",
64
+ "@justeattakeaway/pie-modal": "1.22.4",
65
+ "@justeattakeaway/pie-switch": "2.3.10",
66
+ "@justeattakeaway/pie-webc-core": "6.0.1"
67
67
  },
68
68
  "volta": {
69
69
  "extends": "../../../package.json"
package/src/defs.ts CHANGED
@@ -120,6 +120,13 @@ export interface CookieBannerProps {
120
120
  * or { 'functional': true, 'personalized': true, 'analytical': true }
121
121
  */
122
122
  defaultPreferences?: Partial<Record<PreferenceIds, boolean>>;
123
+
124
+ /**
125
+ * When true, external links (Cookie Statement, Cookie Technologies)
126
+ * will open in the same tab (`target="_self"`).
127
+ * When false (default), links open in a new browser tab (`target="_blank"`).
128
+ */
129
+ openLinksInSameTab?: boolean;
123
130
  }
124
131
 
125
132
  /**
@@ -199,6 +206,7 @@ export const defaultProps: DefaultProps = {
199
206
  language: Language.ENGLISH,
200
207
  cookieStatementLink: '',
201
208
  cookieTechnologiesLink: '',
209
+ openLinksInSameTab: false,
202
210
  };
203
211
 
204
212
  // Available locale files
package/src/index.ts CHANGED
@@ -82,9 +82,21 @@ export class PieCookieBanner extends PieElement implements CookieBannerProps {
82
82
  @property({ type: String })
83
83
  public language = defaultProps.language;
84
84
 
85
+ @property({ type: Boolean })
86
+ public openLinksInSameTab = defaultProps.openLinksInSameTab;
87
+
85
88
  @queryAll('pie-switch')
86
89
  _preferencesNodes!: NodeListOf<PieSwitch>;
87
90
 
91
+ /**
92
+ * Returns the target attribute value for external links based on the openLinksInSameTab prop.
93
+ * - false (default): returns '_blank' (new tab)
94
+ * - true: returns '_self' (same tab)
95
+ */
96
+ private get _linkTargetAttribute () {
97
+ return this.openLinksInSameTab ? '_self' : '_blank';
98
+ }
99
+
88
100
  async updated (changedProperties: PropertyValues<this>) {
89
101
  // Re-fetch locale when country or language changes
90
102
  if (changedProperties.has('language') || changedProperties.has('country')) {
@@ -133,12 +145,12 @@ export class PieCookieBanner extends PieElement implements CookieBannerProps {
133
145
  };
134
146
 
135
147
  private _customTagEnhancers: CustomTagEnhancers = {
136
- linkStatement: (tagContent: string) => html`<pie-link href="${this.cookieStatementLink}" variant="inverse" target="_blank" data-test-id="cookie-statement-link">${tagContent}</pie-link>`,
148
+ linkStatement: (tagContent: string) => html`<pie-link href="${this.cookieStatementLink}" variant="inverse" target="${this._linkTargetAttribute}" data-test-id="cookie-statement-link">${tagContent}</pie-link>`,
137
149
  linkNecessaryOnly: (tagContent: string) => html`<pie-link data-test-id="body-necessary-only" tag="button" variant="inverse" @click="${this._onNecessaryOnly}">${tagContent}</pie-link>`,
138
150
  linkManagePreferences: (tagContent: string) => html`<pie-link data-test-id="body-manage-prefs" tag="button" variant="inverse" @click="${this._openManagePreferencesModal}">${tagContent}</pie-link>`,
139
151
  linkAcceptAll: (tagContent: string) => html`<pie-link data-test-id="body-accept-all" tag="button" variant="inverse" @click="${this._onAcceptAll}">${tagContent}</pie-link>`,
140
- linkCookieStatement: (tagContent: string) => html`<pie-link href="${this.cookieStatementLink}" size="small" target="_blank" data-test-id="cookie-statement-link">${tagContent}</pie-link>`,
141
- linkCookieTechList: (tagContent: string) => html`<pie-link href="${this.cookieTechnologiesLink}" size="small" target="_blank" data-test-id="cookie-technology-link">${tagContent}</pie-link>`,
152
+ linkCookieStatement: (tagContent: string) => html`<pie-link href="${this.cookieStatementLink}" size="small" target="${this._linkTargetAttribute}" data-test-id="cookie-statement-link">${tagContent}</pie-link>`,
153
+ linkCookieTechList: (tagContent: string) => html`<pie-link href="${this.cookieTechnologiesLink}" size="small" target="${this._linkTargetAttribute}" data-test-id="cookie-technology-link">${tagContent}</pie-link>`,
142
154
  };
143
155
 
144
156
  private _localiseText (key: string) {