@leabankab/component-library 8.9.1 → 8.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.
- package/CHANGELOG.md +15 -0
- package/dist/cookie-consent/copy.d.ts +8 -2
- package/dist/cookie-consent/core.d.ts +18 -3
- package/dist/cookie-consent/react.d.ts +35 -2
- package/dist/cookie-consent-core-BYak3SKZ.cjs +2 -0
- package/dist/cookie-consent-core-BYak3SKZ.cjs.map +1 -0
- package/dist/{cookie-consent-core-lX0QAEAo.mjs → cookie-consent-core-DMnn4IZW.mjs} +25 -15
- package/dist/cookie-consent-core-DMnn4IZW.mjs.map +1 -0
- package/dist/cookie-consent-react.cjs +1 -1
- package/dist/cookie-consent-react.cjs.map +1 -1
- package/dist/cookie-consent-react.mjs +168 -151
- package/dist/cookie-consent-react.mjs.map +1 -1
- package/dist/cookie-consent.cjs +1 -1
- package/dist/cookie-consent.mjs +2 -2
- package/dist/website/alert-banner/alert-banner.d.ts +21 -4
- package/dist/website.cjs +1 -1
- package/dist/website.cjs.map +1 -1
- package/dist/website.css +1 -1
- package/dist/website.mjs +12 -11
- package/dist/website.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/cookie-consent-core-fntGUdFt.cjs +0 -2
- package/dist/cookie-consent-core-fntGUdFt.cjs.map +0 -1
- package/dist/cookie-consent-core-lX0QAEAo.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 8.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0953963: `AlertBanner` in `@leabankab/component-library/website`: the icon is now red by default, where it was the section's text colour, and the new `color` prop sets it to another status (`"warning"`, `"info"`, `"success"`) or back to the section's text colour (`"inherit"`). On a dark section (`surface` `contrast` or `contrast-accent`) the icon takes a lighter step of its colour by itself, so it stays 3:1 or more against the band. The title and the text keep the section's colour. An image passed as `icon` keeps its own colours.
|
|
8
|
+
- 6c907da: `CookieConsentProvider` in `@leabankab/component-library/cookie-consent/react` takes `onConsentChange` and `autoOpen`, and no longer opens the dialog by itself for crawlers. An app that passes neither behaves as before, the cookie and `COOKIE_CONSENT_REVISION` are unchanged, and visitors keep their consent.
|
|
9
|
+
|
|
10
|
+
- `onConsentChange?: (state: ConsentState) => void`: called once after load when there is a valid stored consent, then whenever the choice changes (the first choice, a change, or a step back to necessary only). Never with `null`, and not when the same choice is saved again. Called once per change, also under React StrictMode and when `initCookieConsent` was called elsewhere first. The latest function is the one called, so an inline arrow function is fine. An error thrown in it is reported with `reportError`, and the choice is still saved. Use it for Google Consent Mode, the dataLayer or starting analytics; render the provider through a client component of your own to pass it from a server layout.
|
|
11
|
+
- `autoOpen?: boolean`, default `true`: `false` keeps the dialog from opening by itself while the visitor has yet to choose, for example on the cookie policy page, which the intro's link opens in a new tab. Until then only necessary cookies are used. `openSettings` and `openCookieSettings` still open it, and it still can't be dismissed without a choice. When it turns `true` with no consent yet, the dialog opens.
|
|
12
|
+
- Crawlers and audit tools (a user agent with `bot`, `crawl`, `spider`, `slurp`, `teoma` or `lighthouse`) get the page without the dialog, as they did before 8.1.1. The stored consent is still read for them, and browser automation such as Playwright still gets the dialog.
|
|
13
|
+
- `useCookieConsent().consent` keeps the same object when a save doesn't change the choice, so its consumers don't re-render.
|
|
14
|
+
- `CookieConsentCopy`: `policyLinkLabel` and `policyLinkUrl` are optional and marked unused. The dialog never rendered them; the link to the cookie policy belongs in `intro`. Passing them still compiles.
|
|
15
|
+
|
|
16
|
+
See Docs/Cookie Consent.
|
|
17
|
+
|
|
3
18
|
## 8.9.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -3,9 +3,15 @@ import { StrapiBlocksNode } from './strapi-blocks';
|
|
|
3
3
|
/** Consent copy as resolved by the app from Strapi, fallbacks applied. */
|
|
4
4
|
export interface CookieConsentCopy {
|
|
5
5
|
modalTitle: string;
|
|
6
|
+
/**
|
|
7
|
+
* Rich text above the categories. End it with the link to the cookie policy:
|
|
8
|
+
* the dialog has no link of its own.
|
|
9
|
+
*/
|
|
6
10
|
intro: StrapiBlocksNode[];
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
/** Unused: the dialog has no separate policy link. Put it in `intro`. */
|
|
12
|
+
policyLinkLabel?: string;
|
|
13
|
+
/** Unused, as `policyLinkLabel`. */
|
|
14
|
+
policyLinkUrl?: string;
|
|
9
15
|
btnAcceptAll: string;
|
|
10
16
|
btnAcceptNecessary: string;
|
|
11
17
|
btnSaveSettings: string;
|
|
@@ -3,17 +3,29 @@ export interface InitCookieConsentOptions {
|
|
|
3
3
|
market: Market;
|
|
4
4
|
/**
|
|
5
5
|
* Called with the visitor's choice once the library has loaded, when there
|
|
6
|
-
* is a valid consent, and again whenever the choice changes.
|
|
6
|
+
* is a valid consent, and again whenever the choice changes. Only the first
|
|
7
|
+
* call's function is kept: in React, pass `onConsentChange` to
|
|
8
|
+
* `CookieConsentProvider` instead.
|
|
7
9
|
*/
|
|
8
10
|
onConsentChange?: (state: ConsentState) => void;
|
|
9
11
|
}
|
|
10
12
|
export interface ConsentSnapshot {
|
|
11
13
|
consent: ConsentState | null;
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Whether the settings were asked for with `openCookieSettings`. The
|
|
16
|
+
* provider also opens them by itself while `consent` is `null`.
|
|
17
|
+
*/
|
|
13
18
|
settingsOpen: boolean;
|
|
14
19
|
/** The stored consent has been read and the choice can be changed. */
|
|
15
20
|
ready: boolean;
|
|
16
21
|
}
|
|
22
|
+
/** Whether two choices accept the same categories. */
|
|
23
|
+
export declare function sameConsent(a: ConsentState | null, b: ConsentState | null): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the user agent is a known crawler or audit tool, such as Googlebot
|
|
26
|
+
* or Lighthouse. Browser automation such as Playwright is not one.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCrawler(userAgent: string): boolean;
|
|
17
29
|
/** `null` on the server, before the visitor has chosen, or after a revision bump. */
|
|
18
30
|
export declare function getConsentState(): ConsentState | null;
|
|
19
31
|
/**
|
|
@@ -27,7 +39,10 @@ export declare function initCookieConsent({ market, onConsentChange, }: InitCook
|
|
|
27
39
|
* `initCookieConsent` has read the stored consent.
|
|
28
40
|
*/
|
|
29
41
|
export declare function setConsent(categories: readonly CookieConsentCategory[] | "all"): void;
|
|
30
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Opens the settings dialog of the mounted `CookieConsentProvider`, also
|
|
44
|
+
* where its `autoOpen` is `false`.
|
|
45
|
+
*/
|
|
31
46
|
export declare function openCookieSettings(): void;
|
|
32
47
|
/** Closes the settings dialog, unless the visitor has yet to choose. */
|
|
33
48
|
export declare function closeCookieSettings(): void;
|
|
@@ -12,11 +12,44 @@ export interface CookieConsentProviderProps {
|
|
|
12
12
|
copy: CookieConsentCopy;
|
|
13
13
|
/** Rewrites link URLs in the copy, e.g. to make CMS-relative paths absolute. */
|
|
14
14
|
resolveHref?: ResolveHref;
|
|
15
|
+
/**
|
|
16
|
+
* Called with the visitor's choice, for example to update Google Consent
|
|
17
|
+
* Mode or to start analytics. Called once after load when there is a valid
|
|
18
|
+
* stored consent, then whenever the choice changes: the first choice, a
|
|
19
|
+
* change, or a step back to necessary only.
|
|
20
|
+
*
|
|
21
|
+
* Never called with `null`, nor when the visitor saves the same choice
|
|
22
|
+
* again. Called once per change, also under React StrictMode, and also when
|
|
23
|
+
* `initCookieConsent` was called elsewhere first. The latest function is
|
|
24
|
+
* always the one called, so an inline arrow function is fine. An error
|
|
25
|
+
* thrown in it is passed to `reportError`, and the choice is still saved.
|
|
26
|
+
*
|
|
27
|
+
* A function can't be passed from a server component: render the provider
|
|
28
|
+
* through a client component of your own.
|
|
29
|
+
*/
|
|
30
|
+
onConsentChange?: (state: ConsentState) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the dialog opens by itself while the visitor has yet to choose.
|
|
33
|
+
* Default `true`. Pass `false` on pages the dialog shouldn't cover, such as
|
|
34
|
+
* the cookie policy, which the intro's link opens in a new tab.
|
|
35
|
+
*
|
|
36
|
+
* While it is `false` and there is no consent, the dialog stays closed and
|
|
37
|
+
* only necessary cookies are used. `openSettings` and `openCookieSettings`
|
|
38
|
+
* still open it, and it still can't be dismissed without a choice. It is
|
|
39
|
+
* read on every render: when it turns `true` with no consent yet, the
|
|
40
|
+
* dialog opens.
|
|
41
|
+
*
|
|
42
|
+
* The dialog never opens by itself for crawlers and audit tools (a user
|
|
43
|
+
* agent with `bot`, `crawl`, `spider`, `slurp`, `teoma` or `lighthouse`).
|
|
44
|
+
* Browser automation such as Playwright gets it as visitors do.
|
|
45
|
+
*/
|
|
46
|
+
autoOpen?: boolean;
|
|
15
47
|
children?: ReactNode;
|
|
16
48
|
}
|
|
17
49
|
/**
|
|
18
50
|
* Reads the shared consent after mount and renders the settings dialog, which
|
|
19
|
-
* opens by itself until the visitor has chosen
|
|
51
|
+
* opens by itself until the visitor has chosen, unless `autoOpen` is `false`.
|
|
52
|
+
* `market` is read once.
|
|
20
53
|
*/
|
|
21
|
-
export declare function CookieConsentProvider({ market, copy, resolveHref, children, }: CookieConsentProviderProps): import("react").JSX.Element;
|
|
54
|
+
export declare function CookieConsentProvider({ market, copy, resolveHref, onConsentChange, autoOpen, children, }: CookieConsentProviderProps): import("react").JSX.Element;
|
|
22
55
|
export declare function useCookieConsent(): CookieConsentContextValue;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("vanilla-cookieconsent");c=s(c);var l=3,u=[`necessary`,`preferences`,`analytics`,`marketing`],d={se:`leabank.se`,fi:`leabank.fi`,no:`leabank.no`,es:`leabank.es`},f=`cc_cookie`;function p(e,t){let n=d[t],r=e.toLowerCase();return r===n||r.endsWith(`.${n}`)?n:void 0}function m(){document.cookie=`${f}=; path=/; max-age=0`}var h={consent:null,settingsOpen:!1,ready:!1},g=!1,_=h,v=new Set;function y(e){_={..._,...e},v.forEach(e=>e())}function b(e,t){return e===null||t===null?e===t:u.every(n=>e[n]===t[n])}function x(){let e=w();return b(e,_.consent)?_.consent:e}var S=/bot|crawl|spider|slurp|teoma|lighthouse/i;function C(e){return S.test(e)}function w(){if(typeof window>`u`||!c.validConsent())return null;let e=new Set(c.getUserPreferences().acceptedCategories);return Object.fromEntries(u.map(t=>[t,e.has(t)]))}function T({market:e,onConsentChange:t}){if(typeof window>`u`||g)return;g=!0;let n=p(window.location.hostname,e);n&&m();let r=()=>{let e=x();y({consent:e}),e&&t?.(e)};c.run({root:document.createElement(`div`),autoShow:!1,hideFromBots:!1,language:{default:`en`,translations:{en:{consentModal:{},preferencesModal:{sections:[]}}}},revision:3,cookie:{name:f,sameSite:`Lax`,secure:!0,...n&&{domain:n}},categories:{necessary:{enabled:!0,readOnly:!0},preferences:{enabled:!1,readOnly:!1},analytics:{enabled:!1,readOnly:!1,autoClear:{cookies:[{name:/^(_ga|_gid|_gat)/}]}},marketing:{enabled:!1,readOnly:!1,autoClear:{cookies:[{name:/^(_fbp|_fbc)/},{name:/^(_gcl_)/}]}}},onFirstConsent:r,onChange:r}).then(()=>{let e=x();y({consent:e,ready:!0}),e&&t?.(e)})}function E(e){_.ready&&(c.acceptCategory(e===`all`?`all`:[`necessary`,...e.filter(e=>e!==`necessary`)]),y({consent:x(),settingsOpen:!1}))}function D(){typeof window>`u`||y({settingsOpen:!0})}function O(){_.consent!==null&&y({settingsOpen:!1})}function k(e){return v.add(e),()=>{v.delete(e)}}function A(){return _}function j(){return h}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return k}});
|
|
2
|
+
//# sourceMappingURL=cookie-consent-core-BYak3SKZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-consent-core-BYak3SKZ.cjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes. Only the first\n * call's function is kept: in React, pass `onConsentChange` to\n * `CookieConsentProvider` instead.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /**\n * Whether the settings were asked for with `openCookieSettings`. The\n * provider also opens them by itself while `consent` is `null`.\n */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** Whether two choices accept the same categories. */\nexport function sameConsent(\n a: ConsentState | null,\n b: ConsentState | null,\n): boolean {\n if (a === null || b === null) return a === b;\n return COOKIE_CONSENT_CATEGORIES.every((category) => a[category] === b[category]);\n}\n\n/**\n * The stored consent, as the current object when the choice is the same, so\n * that saving it again doesn't look like a change to `useCookieConsent`.\n */\nfunction readConsent(): ConsentState | null {\n const consent = getConsentState();\n return sameConsent(consent, snapshot.consent) ? snapshot.consent : consent;\n}\n\n/**\n * vanilla-cookieconsent's own bot check, with Lighthouse added and without its\n * `navigator.webdriver` test, so that end-to-end tests still get the dialog.\n */\nconst CRAWLER_USER_AGENT = /bot|crawl|spider|slurp|teoma|lighthouse/i;\n\n/**\n * Whether the user agent is a known crawler or audit tool, such as Googlebot\n * or Lighthouse. Browser automation such as Playwright is not one.\n */\nexport function isCrawler(userAgent: string): boolean {\n return CRAWLER_USER_AGENT.test(userAgent);\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = readConsent();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws. `hideFromBots` is off because its check stops `run`\n // before the stored cookie is read, so browser automation such as Playwright\n // could never see a stored consent. With the UI unused, it hides nothing:\n // the provider keeps the dialog from crawlers with `isCrawler` instead.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n hideFromBots: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = readConsent();\n update({ consent, ready: true });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: readConsent(), settingsOpen: false });\n}\n\n/**\n * Opens the settings dialog of the mounted `CookieConsentProvider`, also\n * where its `autoOpen` is `false`.\n */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnap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ACtB,EAAO,CAAE,aAAc,EAAK,CAAC,CAC/B,CAGA,SAAgB,GAA4B,CACtC,EAAS,UAAY,MACzB,EAAO,CAAE,aAAc,EAAM,CAAC,CAChC,CAEA,SAAgB,EAAU,EAAkC,CAE1D,OADA,EAAU,IAAI,CAAQ,MACT,CACX,EAAU,OAAO,CAAQ,CAC3B,CACF,CAEA,SAAgB,GAA+B,CAC7C,OAAO,CACT,CAEA,SAAgB,GAAqC,CACnD,OAAO,CACT"}
|
|
@@ -33,18 +33,29 @@ function d(e) {
|
|
|
33
33
|
...e
|
|
34
34
|
}, u.forEach((e) => e());
|
|
35
35
|
}
|
|
36
|
-
function f() {
|
|
36
|
+
function f(e, t) {
|
|
37
|
+
return e === null || t === null ? e === t : n.every((n) => e[n] === t[n]);
|
|
38
|
+
}
|
|
39
|
+
function p() {
|
|
40
|
+
let e = g();
|
|
41
|
+
return f(e, l.consent) ? l.consent : e;
|
|
42
|
+
}
|
|
43
|
+
var m = /bot|crawl|spider|slurp|teoma|lighthouse/i;
|
|
44
|
+
function h(e) {
|
|
45
|
+
return m.test(e);
|
|
46
|
+
}
|
|
47
|
+
function g() {
|
|
37
48
|
if (typeof window > "u" || !e.validConsent()) return null;
|
|
38
49
|
let t = new Set(e.getUserPreferences().acceptedCategories);
|
|
39
50
|
return Object.fromEntries(n.map((e) => [e, t.has(e)]));
|
|
40
51
|
}
|
|
41
|
-
function
|
|
52
|
+
function _({ market: t, onConsentChange: n }) {
|
|
42
53
|
if (typeof window > "u" || c) return;
|
|
43
54
|
c = !0;
|
|
44
55
|
let r = a(window.location.hostname, t);
|
|
45
56
|
r && o();
|
|
46
57
|
let s = () => {
|
|
47
|
-
let e =
|
|
58
|
+
let e = p();
|
|
48
59
|
d({ consent: e }), e && n?.(e);
|
|
49
60
|
};
|
|
50
61
|
e.run({
|
|
@@ -88,38 +99,37 @@ function p({ market: t, onConsentChange: n }) {
|
|
|
88
99
|
onFirstConsent: s,
|
|
89
100
|
onChange: s
|
|
90
101
|
}).then(() => {
|
|
91
|
-
let e =
|
|
102
|
+
let e = p();
|
|
92
103
|
d({
|
|
93
104
|
consent: e,
|
|
94
|
-
ready: !0
|
|
95
|
-
settingsOpen: l.settingsOpen || e === null
|
|
105
|
+
ready: !0
|
|
96
106
|
}), e && n?.(e);
|
|
97
107
|
});
|
|
98
108
|
}
|
|
99
|
-
function
|
|
109
|
+
function v(t) {
|
|
100
110
|
l.ready && (e.acceptCategory(t === "all" ? "all" : ["necessary", ...t.filter((e) => e !== "necessary")]), d({
|
|
101
|
-
consent:
|
|
111
|
+
consent: p(),
|
|
102
112
|
settingsOpen: !1
|
|
103
113
|
}));
|
|
104
114
|
}
|
|
105
|
-
function
|
|
115
|
+
function y() {
|
|
106
116
|
typeof window > "u" || d({ settingsOpen: !0 });
|
|
107
117
|
}
|
|
108
|
-
function
|
|
118
|
+
function b() {
|
|
109
119
|
l.consent !== null && d({ settingsOpen: !1 });
|
|
110
120
|
}
|
|
111
|
-
function
|
|
121
|
+
function x(e) {
|
|
112
122
|
return u.add(e), () => {
|
|
113
123
|
u.delete(e);
|
|
114
124
|
};
|
|
115
125
|
}
|
|
116
|
-
function
|
|
126
|
+
function S() {
|
|
117
127
|
return l;
|
|
118
128
|
}
|
|
119
|
-
function
|
|
129
|
+
function C() {
|
|
120
130
|
return s;
|
|
121
131
|
}
|
|
122
132
|
//#endregion
|
|
123
|
-
export {
|
|
133
|
+
export { _ as a, f as c, n as d, t as f, S as i, v as l, g as n, h as o, C as r, y as s, b as t, x as u };
|
|
124
134
|
|
|
125
|
-
//# sourceMappingURL=cookie-consent-core-
|
|
135
|
+
//# sourceMappingURL=cookie-consent-core-DMnn4IZW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-consent-core-DMnn4IZW.mjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes. Only the first\n * call's function is kept: in React, pass `onConsentChange` to\n * `CookieConsentProvider` instead.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /**\n * Whether the settings were asked for with `openCookieSettings`. The\n * provider also opens them by itself while `consent` is `null`.\n */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** Whether two choices accept the same categories. */\nexport function sameConsent(\n a: ConsentState | null,\n b: ConsentState | null,\n): boolean {\n if (a === null || b === null) return a === b;\n return COOKIE_CONSENT_CATEGORIES.every((category) => a[category] === b[category]);\n}\n\n/**\n * The stored consent, as the current object when the choice is the same, so\n * that saving it again doesn't look like a change to `useCookieConsent`.\n */\nfunction readConsent(): ConsentState | null {\n const consent = getConsentState();\n return sameConsent(consent, snapshot.consent) ? snapshot.consent : consent;\n}\n\n/**\n * vanilla-cookieconsent's own bot check, with Lighthouse added and without its\n * `navigator.webdriver` test, so that end-to-end tests still get the dialog.\n */\nconst CRAWLER_USER_AGENT = /bot|crawl|spider|slurp|teoma|lighthouse/i;\n\n/**\n * Whether the user agent is a known crawler or audit tool, such as Googlebot\n * or Lighthouse. Browser automation such as Playwright is not one.\n */\nexport function isCrawler(userAgent: string): boolean {\n return CRAWLER_USER_AGENT.test(userAgent);\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = readConsent();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws. `hideFromBots` is off because its check stops `run`\n // before the stored cookie is read, so browser automation such as Playwright\n // could never see a stored consent. With the UI unused, it hides nothing:\n // the provider keeps the dialog from crawlers with `isCrawler` instead.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n hideFromBots: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = readConsent();\n update({ consent, ready: true });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: readConsent(), settingsOpen: false });\n}\n\n/**\n * Opens the settings dialog of the mounted `CookieConsentProvider`, also\n * where its `autoOpen` is `false`.\n */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnapshot {\n return snapshot;\n}\n\nexport function getServerSnapshot(): ConsentSnapshot {\n return serverSnapshot;\n}\n"],"mappings":";;AAIA,IAAa,IAA0B,GAE1B,IAA4B;CACvC;CACA;CACA;CACA;AACF,GAQa,IAAyC;CACpD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAEa,IAAc;;;AClB3B,SAAgB,EACd,GACA,GACoB;CACpB,IAAM,IAAS,EAAe,IACxB,IAAO,EAAS,YAAY;CAElC,OAAO,MAAS,KAAU,EAAK,SAAS,IAAI,GAAQ,IAAI,IAAS,KAAA;AACnE;AAQA,SAAgB,IAA4B;CAC1C,SAAS,SAAS,GAAG,EAAY;AACnC;;;ACQA,IAAM,IAAkC;CACtC,SAAS;CACT,cAAc;CACd,OAAO;AACT,GAEI,IAAU,IACV,IAAW,GACT,oBAAY,IAAI,IAAgB;AAEtC,SAAS,EAAO,GAAiC;CAE/C,AADA,IAAW;EAAE,GAAG;EAAU,GAAG;CAAM,GACnC,EAAU,SAAS,MAAa,EAAS,CAAC;AAC5C;AAGA,SAAgB,EACd,GACA,GACS;CAET,OADI,MAAM,QAAQ,MAAM,OAAa,MAAM,IACpC,EAA0B,OAAO,MAAa,EAAE,OAAc,EAAE,EAAS;AAClF;AAMA,SAAS,IAAmC;CAC1C,IAAM,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eAAe,GAAG,EAAE,MAAM,WAAW,CAAC,EAC1D;GACF;EACF;EACA,gBAAgB;EAChB,UAAU;CACZ,CAAC,CAAC,CAAC,WAAW;EACZ,IAAM,IAAU,EAAY;EAE5B,AADA,EAAO;GAAE;GAAS,OAAO;EAAK,CAAC,GAC3B,KAAS,IAAkB,CAAO;CACxC,CAAC;AACH;AAMA,SAAgB,EACd,GACM;CACD,EAAS,UAEd,EAAc,eACZ,MAAe,QACX,QACA,CAAC,aAAa,GAAG,EAAW,QAAQ,MAAa,MAAa,WAAW,CAAC,CAChF,GACA,EAAO;EAAE,SAAS,EAAY;EAAG,cAAc;CAAM,CAAC;AACxD;AAMA,SAAgB,IAA2B;CACrC,OAAO,SAAW,OACtB,EAAO,EAAE,cAAc,GAAK,CAAC;AAC/B;AAGA,SAAgB,IAA4B;CACtC,EAAS,YAAY,QACzB,EAAO,EAAE,cAAc,GAAM,CAAC;AAChC;AAEA,SAAgB,EAAU,GAAkC;CAE1D,OADA,EAAU,IAAI,CAAQ,SACT;EACX,EAAU,OAAO,CAAQ;CAC3B;AACF;AAEA,SAAgB,IAA+B;CAC7C,OAAO;AACT;AAEA,SAAgB,IAAqC;CACnD,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});require('./cookie-consent.css');const e=require("./cookie-consent-core-
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});require('./cookie-consent.css');const e=require("./cookie-consent-core-BYak3SKZ.cjs");let t=require("react"),n=require("@base-ui/react/button"),r=require("@base-ui/react/use-render"),i=require("react/jsx-runtime"),a=require("@base-ui/react/dialog"),o=require("lucide-react"),s=require("@base-ui/react/switch"),c=require("@base-ui/react/accordion");var l=(e,t)=>n=>[e,typeof t==`function`?t(n):t].filter(Boolean).join(` `),u={Button:`_Button_dq81c_1`,IconButton:`_IconButton_dq81c_141`,Spinner:`_Spinner_dq81c_172`,"button-spin":`_button-spin_dq81c_1`,SrOnly:`_SrOnly_dq81c_190`},d=e=>(0,t.isValidElement)(e)&&(e.props.href!=null||e.props.to!=null),f=e=>e.preventDefault();function p({loading:e=!1,disabled:t,className:a,render:o,nativeButton:s,focusableWhenDisabled:c,ref:l,...u}){let p=!!(t||e),m=d(o),h={"aria-busy":e||void 0,"data-loading":e||void 0};return(0,r.useRender)({enabled:m,render:m?o:void 0,ref:l,defaultTagName:`a`,props:{...u,...h,"aria-disabled":p||void 0,"data-disabled":p?``:void 0,className:typeof a==`function`?a({disabled:p}):a,onClick:p?f:u.onClick}})||(0,i.jsx)(n.Button,{...u,...h,ref:l,render:o,nativeButton:s,focusableWhenDisabled:c,disabled:p,className:a})}function m({variant:e=`solid`,color:t=`primary`,size:n=`md`,className:r,...a}){return(0,i.jsx)(p,{...a,"data-variant":e,"data-color":t,"data-size":n,className:l(u.Button,r)})}function h({startIcon:e,endIcon:t,loading:n=!1,loadingLabel:r,children:a,...o}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m,{...o,loading:n,"data-start-icon":n||e!=null||void 0,"data-end-icon":t!=null||void 0,children:[n?(0,i.jsx)(`span`,{className:u.Spinner,"aria-hidden":!0}):e,a,t]}),r!=null&&(0,i.jsx)(`span`,{role:`status`,className:u.SrOnly,children:n?r:null})]})}var g={Backdrop:`_Backdrop_1do7v_8`,Viewport:`_Viewport_1do7v_22`,Popup:`_Popup_1do7v_38`,Header:`_Header_1do7v_78`,Title:`_Title_1do7v_88`,Description:`_Description_1do7v_97`,Content:`_Content_1do7v_111`,Footer:`_Footer_1do7v_119`,CloseButton:`_CloseButton_1do7v_135`},_=(0,t.createContext)(`no`),v=()=>(0,t.useContext)(_);function y(e){return function(){let t=v(),n={};return Object.keys(e).forEach(r=>{let i=e[r];n[r]=i[t]??i.no}),n}}var b=y({close:{no:`Lukk`,se:`Stäng`,fi:`Sulje`,es:`Cerrar`}}),x=a.Dialog.Root;a.Dialog.Trigger;var S=a.Dialog.Portal;function C({className:e,...t}){return(0,i.jsx)(a.Dialog.Backdrop,{...t,className:l(g.Backdrop,e)})}function w({className:e,...t}){return(0,i.jsx)(a.Dialog.Viewport,{...t,className:l(g.Viewport,e)})}function T({size:e=`sm`,fullScreenOnMobile:t,className:n,...r}){return(0,i.jsx)(a.Dialog.Popup,{...r,"data-size":e,"data-full-screen-on-mobile":t||void 0,className:l(g.Popup,n)})}function E({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Header,e].filter(Boolean).join(` `)})}function D({className:e,...t}){return(0,i.jsx)(a.Dialog.Title,{...t,className:l(g.Title,e)})}function O({className:e,...t}){return(0,i.jsx)(a.Dialog.Description,{...t,className:l(g.Description,e)})}function k({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Content,e].filter(Boolean).join(` `)})}function A({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Footer,e].filter(Boolean).join(` `)})}a.Dialog.Close;function j({label:e,className:t,...n}){let r=b();return(0,i.jsx)(a.Dialog.Close,{...n,"aria-label":e??r.close,className:l(g.CloseButton,t),children:(0,i.jsx)(o.X,{size:20,"aria-hidden":!0})})}var M={Switch:`_Switch_9c9ji_7`,Thumb:`_Thumb_9c9ji_36`};function N({className:e,...t}){return(0,i.jsx)(s.Switch.Root,{...t,className:l(M.Switch,e),children:(0,i.jsx)(s.Switch.Thumb,{className:M.Thumb})})}var P={Root:`_Root_oibl2_13`,Item:`_Item_oibl2_10`,Header:`_Header_oibl2_10`,Trigger:`_Trigger_oibl2_108`,Label:`_Label_oibl2_149`,Icon:`_Icon_oibl2_153`,Panel:`_Panel_oibl2_171`,Content:`_Content_oibl2_182`};function F({variant:e=`outline`,iconPosition:t=`end`,className:n,...r}){return(0,i.jsx)(c.Accordion.Root,{...r,"data-variant":e,"data-icon-position":t,className:l(P.Root,n)})}function I({className:e,...t}){return(0,i.jsx)(c.Accordion.Item,{...t,className:l(P.Item,e)})}function L({className:e,...t}){return(0,i.jsx)(c.Accordion.Header,{...t,className:l(P.Header,e)})}function R({children:e,className:t,...n}){return(0,i.jsxs)(c.Accordion.Trigger,{...n,className:l(P.Trigger,t),children:[(0,i.jsx)(`span`,{className:P.Label,children:e}),(0,i.jsx)(o.ChevronDown,{className:P.Icon,size:20,"aria-hidden":!0})]})}function z({children:e,className:t,...n}){return(0,i.jsx)(c.Accordion.Panel,{...n,className:l(P.Panel,t),children:(0,i.jsx)(`div`,{className:P.Content,children:e})})}var B={Intro:`_Intro_nxwj4_7`,Categories:`_Categories_nxwj4_39`,CategoryDescription:`_CategoryDescription_nxwj4_43`,Actions:`_Actions_nxwj4_52`,Save:`_Save_nxwj4_63`},V=`https://relative.invalid`;function H(e,t){try{return new URL(e,t)}catch{return null}}function U(e){let t=e.trim();if(!t)return!1;let n=H(t);return n?n.protocol===`https:`||n.protocol===`mailto:`:H(t,V)?.origin===V}function W({href:e,resolveHref:t=e=>e,children:n}){let r=t(e);return!r||!U(r)?(0,i.jsx)(i.Fragment,{children:n}):(0,i.jsx)(`a`,{href:r.trim(),target:`_blank`,rel:`noopener noreferrer`,children:n})}function G({node:e}){let t=e.text;return e.underline&&(t=(0,i.jsx)(`u`,{children:t})),e.italic&&(t=(0,i.jsx)(`em`,{children:t})),e.bold&&(t=(0,i.jsx)(`strong`,{children:t})),(0,i.jsx)(i.Fragment,{children:t})}function K({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:(e??[]).map((e,n)=>e.type===`text`?(0,i.jsx)(G,{node:e},n):e.type===`link`?(0,i.jsx)(W,{href:e.url??``,resolveHref:t,children:(e.children??[]).filter(e=>e.type===`text`).map((e,t)=>(0,i.jsx)(G,{node:e},t))},n):null)})}function q({node:e,resolveHref:t}){let n=e.format===`ordered`?`ol`:`ul`;return(0,i.jsx)(n,{children:(e.children??[]).map((e,n)=>e.type===`list`?(0,i.jsx)(`li`,{children:(0,i.jsx)(q,{node:e,resolveHref:t})},n):e.type===`list-item`?(0,i.jsx)(`li`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n):null)})}function J({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:e.map((e,n)=>{switch(e.type){case`paragraph`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n);case`heading`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(`strong`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})})},n);case`list`:return(0,i.jsx)(q,{node:e,resolveHref:t},n);default:return null}})})}function Y(e){return{necessary:!0,preferences:e?.preferences??!1,analytics:e?.analytics??!1,marketing:e?.marketing??!1}}function X({category:e,copy:n,checked:r,onCheckedChange:a}){let o=(0,t.useId)(),s=(0,t.useId)(),{title:c,description:l}=n.categories[e];return(0,i.jsxs)(I,{value:e,children:[(0,i.jsxs)(L,{children:[(0,i.jsx)(R,{children:(0,i.jsx)(`span`,{id:o,children:c})}),(0,i.jsx)(N,{"aria-labelledby":o,"aria-describedby":l?s:void 0,checked:r,disabled:e===`necessary`,onCheckedChange:a})]}),(0,i.jsx)(z,{keepMounted:!0,children:l&&(0,i.jsx)(`p`,{id:s,className:B.CategoryDescription,children:l})})]})}function Z({open:n,consent:r,copy:a,resolveHref:o,onAcceptAll:s,onAcceptNecessary:c,onSave:l,onClose:u}){let d=r!==null,[f,p]=(0,t.useState)(()=>Y(r)),[m,g]=(0,t.useState)(n);return n!==m&&(g(n),n&&p(Y(r))),(0,i.jsx)(x,{open:n,onOpenChange:e=>{!e&&d&&u()},disablePointerDismissal:!d,children:(0,i.jsxs)(S,{children:[(0,i.jsx)(C,{}),(0,i.jsx)(w,{children:(0,i.jsxs)(T,{fullScreenOnMobile:!0,size:`md`,children:[(0,i.jsxs)(E,{children:[(0,i.jsx)(D,{children:a.modalTitle}),d&&(0,i.jsx)(j,{label:a.closeIconLabel})]}),(0,i.jsxs)(k,{children:[(0,i.jsx)(O,{render:(0,i.jsx)(`div`,{}),className:B.Intro,children:(0,i.jsx)(J,{nodes:a.intro,resolveHref:o})}),(0,i.jsx)(F,{variant:`solid`,iconPosition:`start`,multiple:!0,className:B.Categories,children:e.d.map(e=>(0,i.jsx)(X,{category:e,copy:a,checked:f[e],onCheckedChange:t=>p(n=>({...n,[e]:t}))},e))})]}),(0,i.jsxs)(A,{className:B.Actions,children:[(0,i.jsx)(h,{onClick:s,color:`secondary`,size:`sm`,children:a.btnAcceptAll}),(0,i.jsx)(h,{onClick:c,color:`secondary`,size:`sm`,children:a.btnAcceptNecessary}),(0,i.jsx)(h,{variant:`outline`,color:`secondary`,size:`sm`,className:B.Save,onClick:()=>l(e.d.filter(e=>f[e])),children:a.btnSaveSettings})]})]})})]})})}var Q=typeof document>`u`?t.useEffect:t.useLayoutEffect,$=(0,t.createContext)(null);function ee({market:n,copy:r,resolveHref:a,onConsentChange:o,autoOpen:s=!0,children:c}){let{consent:l,settingsOpen:u,ready:d}=(0,t.useSyncExternalStore)(e.u,e.i,e.r),f=(0,t.useRef)(o);Q(()=>{f.current=o});let p=(0,t.useRef)(null);(0,t.useEffect)(()=>{let t=()=>{let{consent:t}=e.i();if(!(t===null||e.c(t,p.current))){p.current=t;try{f.current?.(t)}catch(e){reportError(e)}}};return t(),e.u(t)},[]),(0,t.useEffect)(()=>{e.a({market:n})},[]);let m=(0,t.useMemo)(()=>({consent:l,openSettings:e.s}),[l]),h=d&&(u||l===null&&s&&!e.o(navigator.userAgent));return(0,i.jsxs)($.Provider,{value:m,children:[c,d&&(0,i.jsx)(Z,{open:h,consent:l,copy:r,resolveHref:a,onAcceptAll:()=>e.l(`all`),onAcceptNecessary:()=>e.l([]),onSave:e.l,onClose:e.t})]})}function te(){let e=(0,t.useContext)($);if(!e)throw Error(`useCookieConsent must be used inside a CookieConsentProvider.`);return e}exports.CookieConsentProvider=ee,exports.useCookieConsent=te;
|
|
2
2
|
//# sourceMappingURL=cookie-consent-react.cjs.map
|