@justeattakeaway/pie-cookie-banner 1.9.0 → 1.10.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": "{ hasPrimaryActionsOnly: false, defaultPreferences: {}, country: Country.GREAT_BRITAIN, language: Language.ENGLISH, cookieStatementLink: '', cookieTechnologiesLink: '', openLinksInSameTab: false, }"
81
+ "default": "{ hasPrimaryActionsOnly: false, defaultPreferences: {}, country: Country.GREAT_BRITAIN, language: Language.ENGLISH, cookieStatementLink: '', personalizedLabel: '', personalizedDescription: '', cookieTechnologiesLink: '', openLinksInSameTab: false, }"
82
82
  },
83
83
  {
84
84
  "kind": "variable",
@@ -228,6 +228,18 @@
228
228
  "privacy": "public",
229
229
  "attribute": "cookieStatementLink"
230
230
  },
231
+ {
232
+ "kind": "field",
233
+ "name": "personalizedLabel",
234
+ "privacy": "public",
235
+ "attribute": "personalizedLabel"
236
+ },
237
+ {
238
+ "kind": "field",
239
+ "name": "personalizedDescription",
240
+ "privacy": "public",
241
+ "attribute": "personalizedDescription"
242
+ },
231
243
  {
232
244
  "kind": "field",
233
245
  "name": "cookieTechnologiesLink",
@@ -346,6 +358,40 @@
346
358
  }
347
359
  ]
348
360
  },
361
+ {
362
+ "kind": "method",
363
+ "name": "_renderPreferenceLabel",
364
+ "privacy": "private",
365
+ "parameters": [
366
+ {
367
+ "name": "id",
368
+ "type": {
369
+ "text": "PreferenceIds"
370
+ }
371
+ }
372
+ ],
373
+ "description": "Renders a preference label.\nFor the personalised preference, uses the consumer-supplied `personalizedLabel`\nprop when provided as plain text, and falls back to the built-in locale string otherwise."
374
+ },
375
+ {
376
+ "kind": "method",
377
+ "name": "_renderPreferenceDescription",
378
+ "privacy": "private",
379
+ "parameters": [
380
+ {
381
+ "name": "id",
382
+ "type": {
383
+ "text": "PreferenceIds"
384
+ }
385
+ },
386
+ {
387
+ "name": "description",
388
+ "type": {
389
+ "text": "string"
390
+ }
391
+ }
392
+ ],
393
+ "description": "Renders a preference description.\nFor the personalised preference, uses the consumer-supplied `personalizedDescription`\nprop when provided (allowing consumers to embed their own privacy policy link using\nplain HTML `<a>` or `<pie-link>` tags), and falls back to the built-in locale string otherwise.\nAll other preferences use the plain locale text with HTML sanitisation."
394
+ },
349
395
  {
350
396
  "kind": "method",
351
397
  "name": "_displayCookieBanner",
@@ -456,6 +502,14 @@
456
502
  "name": "cookieStatementLink",
457
503
  "fieldName": "cookieStatementLink"
458
504
  },
505
+ {
506
+ "name": "personalizedLabel",
507
+ "fieldName": "personalizedLabel"
508
+ },
509
+ {
510
+ "name": "personalizedDescription",
511
+ "fieldName": "personalizedDescription"
512
+ },
459
513
  {
460
514
  "name": "cookieTechnologiesLink",
461
515
  "fieldName": "cookieTechnologiesLink"
@@ -550,7 +604,7 @@
550
604
  "default": "'_blank'"
551
605
  }
552
606
  ],
553
- "description": "Sanitises an HTML string to allow only safe <a> tags, and normalises anchor\nattributes to respect the component's link-target behaviour.\n\nUses DOMPurify for the core sanitisation:\n- Strips all non-<a> elements (keeping their text content).\n- Removes unsafe href protocols (javascript:, data:, vbscript:).\n- Removes non-allowlisted attributes (only href, rel, target survive).\n\nA post-sanitisation hook then enforces target/rel:\n- Sets target to linkTarget (overrides any existing target).\n- Ensures rel contains \"noopener noreferrer\" when target=\"_blank\"\n (prevents reverse-tabnabbing).\n\nIn SSR / non-browser environments (no `window`), all HTML is stripped and\nonly the text content is returned — the client will re-render with the full\nsanitisation pass after hydration."
607
+ "description": "Sanitises an HTML string to allow only safe <a> and <pie-link> tags, and normalises link\nattributes to respect the component's link-target behaviour.\n\nUses DOMPurify for the core sanitisation:\n- Strips all non-link elements (keeping their text content).\n- Removes unsafe href protocols (javascript:, data:, vbscript:).\n- Removes non-allowlisted attributes (only href, rel, target survive).\n\nA post-sanitisation hook then enforces target/rel:\n- Sets target to linkTarget (overrides any existing target).\n- Ensures rel contains \"noopener noreferrer\" when target=\"_blank\"\n (prevents reverse-tabnabbing).\n\nIn SSR / non-browser environments (no `window`), all HTML is stripped and\nonly the text content is returned — the client will re-render with the full\nsanitisation pass after hydration."
554
608
  },
555
609
  {
556
610
  "kind": "function",
package/dist/index.d.ts CHANGED
@@ -58,6 +58,23 @@ export declare interface CookieBannerProps {
58
58
  * The URL of the cookie statement page the banner should link to.
59
59
  */
60
60
  cookieStatementLink: string;
61
+ /**
62
+ * An optional override for the personalised preference label rendered in the
63
+ * "Manage preferences" modal. When provided, this string replaces the locale-defined
64
+ * label for the personalised preference. Consumers can include plain text.
65
+ * When omitted or set to an empty string, the built-in locale string is used.
66
+ */
67
+ personalizedLabel?: string;
68
+ /**
69
+ * An optional override for the personalised preference description rendered in the
70
+ * "Manage preferences" modal. When provided, this string replaces the locale-defined
71
+ * description for the personalised preference. Consumers can include plain text,
72
+ * HTML anchor tags (e.g. `<a href="...">Privacy Policy</a>`), or `<pie-link>` tags
73
+ * to embed a privacy policy link. The HTML is sanitised, so only the allowed link
74
+ * attributes are preserved and any others are stripped or normalised. When omitted or
75
+ * set to an empty string, the built-in locale string is used.
76
+ */
77
+ personalizedDescription?: string;
61
78
  /**
62
79
  * The URL for the cookie technology link.
63
80
  */
@@ -150,6 +167,8 @@ export declare class PieCookieBanner extends PieElement implements CookieBannerP
150
167
  hasPrimaryActionsOnly: boolean;
151
168
  defaultPreferences: Partial<Record<PreferenceIds, boolean>>;
152
169
  cookieStatementLink: string;
170
+ personalizedLabel: string;
171
+ personalizedDescription: string;
153
172
  cookieTechnologiesLink: string;
154
173
  country: string;
155
174
  language: string;
@@ -174,6 +193,20 @@ export declare class PieCookieBanner extends PieElement implements CookieBannerP
174
193
  private _customTagEnhancers;
175
194
  private _localiseText;
176
195
  private _localiseRichText;
196
+ /**
197
+ * Renders a preference label.
198
+ * For the personalised preference, uses the consumer-supplied `personalizedLabel`
199
+ * prop when provided as plain text, and falls back to the built-in locale string otherwise.
200
+ */
201
+ private _renderPreferenceLabel;
202
+ /**
203
+ * Renders a preference description.
204
+ * For the personalised preference, uses the consumer-supplied `personalizedDescription`
205
+ * prop when provided (allowing consumers to embed their own privacy policy link using
206
+ * plain HTML `<a>` or `<pie-link>` tags), and falls back to the built-in locale string otherwise.
207
+ * All other preferences use the plain locale text with HTML sanitisation.
208
+ */
209
+ private _renderPreferenceDescription;
177
210
  /**
178
211
  * Handles closing the modal and re-displaying the cookie banner
179
212
  * and making the cookie banner visible