@nationalarchives/frontend 0.11.0 → 0.11.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"components/cookie-banner/cookie-banner.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,MAAM,I,+zECTTC,OAAOC,mBAAqBD,OAAOC,oBAAsB,KACzDD,OAAOE,wBAA0BF,OAAOE,yBAA2B,KAE5D,IAAMC,EAAkB,WAW7B,OAAAC,GAPA,SAAAD,IACE,GADYE,EAAA,KAAAF,GAAAG,EAAA,cAHL,CAAC,GAACA,EAAA,qBACK,CAAC,GAGXN,OAAOE,wBACT,OAAOF,OAAOE,wBAEhBF,OAAOE,wBAA0BK,IACnC,GAEA,EAAAC,IAAA,KAAAC,MAKA,SAAGC,EAAOC,GACHC,OAAOC,OAAON,KAAKO,OAAQJ,KAC9BH,KAAKO,OAAOJ,GAAS,IAEvBH,KAAKO,OAAOJ,GAAS,GAAHK,OAAAC,EAAOT,KAAKO,OAAOJ,IAAM,CAAEC,GAC/C,GAAC,CAAAH,IAAA,OAAAC,MAED,SAAKC,EAAOC,GACLC,OAAOC,OAAON,KAAKU,cAAeP,KACrCH,KAAKU,cAAcP,GAAS,IAE9BH,KAAKU,cAAcP,GAAS,GAAHK,OAAAC,EAAOT,KAAKU,cAAcP,IAAM,CAAEC,GAC7D,GAEA,CAAAH,IAAA,UAAAC,MACA,SAAQC,GAAkB,IAAAQ,EAAA,KAAXC,EAAIC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAC,EAMrB,GALIR,OAAOC,OAAON,KAAKO,OAAQJ,IAC7BH,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gH,QAAQa,gBAAgB,UAE7B7H,KAAKiH,cAAca,iBAAiB,SAAS,kBAAMnH,EAAKoH,QAAQ,IAChE/H,KAAKmH,cAAcW,iBAAiB,SAAS,kBAAMnH,EAAKqH,QAAQ,KAEpE,G,EAAC,EAAA/H,IAAA,SAAAC,MAED,WACEF,KAAKoH,QAAQa,aAAa,SAAU,IACpCjI,KAAKkI,WACLlI,KAAKqH,iBAAiBQ,gBAAgB,UACtC7H,KAAKqH,iBAAiBc,QACtBnI,KAAKqH,iBAAiBY,aAAa,WAAY,MAC/CjI,KAAKyH,QAAQW,mBACf,GAAC,CAAAnI,IAAA,SAAAC,MAED,WACEF,KAAKoH,QAAQa,aAAa,SAAU,IACpCjI,KAAKkI,WACLlI,KAAKsH,iBAAiBO,gBAAgB,UACtC7H,KAAKsH,iBAAiBa,QACtBnI,KAAKsH,iBAAiBW,aAAa,WAAY,MAC/CjI,KAAKyH,QAAQY,mBACf,GAAC,CAAApI,IAAA,WAAAC,MAED,WAAW,IAAAoB,EAAA,KACTtB,KAAKyH,QAAQvC,IAAIlF,KAAK0H,yBAAyB,GAC/C1H,KAAKuH,cAAcvG,SAAQ,SAACsH,GAC1BA,EAAaR,iBAAiB,SAAS,kBAAMxG,EAAKiH,OAAO,GAC3D,GACF,GAAC,CAAAtI,IAAA,QAAAC,MAED,WACEF,KAAKgH,QAAQiB,aAAa,SAAU,GACtC,M,6EAAC,CAvEsB,G","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","webpack://TNAFrontend/./src/nationalarchives/lib/cookies.mjs","webpack://TNAFrontend/webpack/bootstrap","webpack://TNAFrontend/webpack/runtime/define property getters","webpack://TNAFrontend/webpack/runtime/hasOwnProperty shorthand","webpack://TNAFrontend/webpack/runtime/make namespace object","webpack://TNAFrontend/./src/nationalarchives/components/cookie-banner/cookie-banner.mjs"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"TNAFrontend\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TNAFrontend\"] = factory();\n\telse\n\t\troot[\"TNAFrontend\"] = factory();\n})(self, () => {\nreturn ","window.TNAFrontendCookies = window.TNAFrontendCookies || null;\nwindow.TNAFrontendCookieEvents = window.TNAFrontendCookieEvents || null;\n\nexport class CookieEventHandler {\n events = {};\n oneTimeEvents = {};\n\n constructor() {\n if (window.TNAFrontendCookieEvents) {\n return window.TNAFrontendCookieEvents;\n }\n window.TNAFrontendCookieEvents = this;\n }\n\n /**\n * Add an event listener.\n * @param {String} event - The event to add a listener for.\n * @param {Function} callback - The callback function to call when the event is triggered.\n */\n on(event, callback) {\n if (!Object.hasOwn(this.events, event)) {\n this.events[event] = [];\n }\n this.events[event] = [...this.events[event], callback];\n }\n\n once(event, callback) {\n if (!Object.hasOwn(this.oneTimeEvents, event)) {\n this.oneTimeEvents[event] = [];\n }\n this.oneTimeEvents[event] = [...this.oneTimeEvents[event], callback];\n }\n\n /** @protected */\n trigger(event, data = {}) {\n if (Object.hasOwn(this.events, event)) {\n this.events[event].forEach((eventToTrigger) =>\n eventToTrigger.call(this, data),\n );\n }\n if (Object.hasOwn(this.oneTimeEvents, event)) {\n for (let i = this.oneTimeEvents[event].length - 1; i >= 0; i--) {\n const eventToTrigger = this.oneTimeEvents[event][i];\n eventToTrigger.call(this, data);\n this.oneTimeEvents[event].splice(i, 1);\n }\n }\n }\n}\n\n/**\n * Class to handle cookies.\n * @class Cookies\n * @constructor\n * @public\n */\nexport default class Cookies {\n /** @protected */\n defaultDomain = \"\";\n /** @protected */\n defaultPath = \"\";\n /** @protected */\n secure = true;\n /** @protected */\n policiesKey = \"\";\n /** @protected */\n events = null;\n /** @protected */\n defaultAge = null;\n /** @protected */\n completePoliciesOnInit = false;\n\n /**\n * Create a cookie handler.\n * @param {String} [options.defaultDomain] - The domain to register the cookie with.\n * @param {String} [options.path] - The domain to register the cookie with.\n * @param {Boolean} [options.secure] - Only set cookie in HTTPS environments.\n * @param {String} [options.policiesKey] - The name of the cookie.\n * @param {String} [options.newInstance=false] - Create a fresh instance of the cookie class.\n * @param {Number} [options.defaultAge] - The default age of non-session cookies.\n * @param {Boolean} [options.noInit=false] - Don't initialise a blank cookie policy.\n */\n constructor(options = {}) {\n const {\n defaultDomain,\n defaultPath,\n secure,\n policiesKey,\n newInstance = false,\n defaultAge,\n noInit = false,\n } = options;\n if (!newInstance && window.TNAFrontendCookies) {\n return window.TNAFrontendCookies;\n }\n if (defaultDomain === undefined) {\n this.defaultDomain =\n document.documentElement.dataset.tnaCookiesDomain || \"\";\n } else {\n this.defaultDomain = defaultDomain;\n }\n if (defaultPath === undefined) {\n this.defaultPath = document.documentElement.dataset.tnaCookiesPath || \"/\";\n } else {\n this.defaultPath = defaultPath;\n }\n if (secure === undefined) {\n this.secure =\n document.documentElement.dataset.tnaCookiesInsecure !== \"true\";\n } else {\n this.secure = secure;\n }\n if (policiesKey === undefined) {\n this.policiesKey =\n document.documentElement.dataset.tnaCookiesPoliciesKey ||\n \"cookies_policy\";\n } else {\n this.policiesKey = policiesKey;\n }\n if (defaultAge === undefined) {\n this.defaultAge =\n parseInt(document.documentElement.dataset.tnaCookiesDefaultAge) ||\n 31536000; // 365 days;\n } else {\n this.defaultAge = defaultAge;\n }\n this.events = new CookieEventHandler();\n this.completePoliciesOnInit =\n Object.keys(this.policies).length === 4 &&\n [\"usage\", \"settings\", \"marketing\", \"essential\"].every(\n (policy) =>\n Object.keys(this.policies).includes(policy) &&\n typeof this.policies[policy] === \"boolean\",\n );\n if (!this.completePoliciesOnInit && !noInit) {\n this.init();\n }\n window.TNAFrontendCookies = this;\n }\n\n /** @protected */\n init() {\n this.savePolicies({\n usage: false,\n settings: false,\n marketing: false,\n ...this.policies,\n essential: true,\n });\n }\n\n destroyInstance() {\n window.TNAFrontendCookies = null;\n }\n\n /** @protected */\n get all() {\n const deserialised = {};\n document.cookie\n .split(\"; \")\n .filter((x) => x)\n .forEach((cookie) => {\n const parts = cookie.trim().split(\"=\");\n if (parts[0]) {\n deserialised[parts[0]] = parts[1];\n }\n });\n return deserialised;\n }\n\n /** @protected */\n get policies() {\n try {\n return JSON.parse(this.get(this.policiesKey) || \"{}\");\n } catch (e) {\n return {};\n }\n }\n\n /**\n * Check to see whether a cookie exists or not.\n * @param {String} key - The cookie name.\n * @returns {Boolean}\n */\n exists(key) {\n return Object.hasOwn(this.all, key);\n }\n\n /**\n * Check to see whether a cookie has a particular value.\n * @param {String} key - The cookie name.\n * @param {String|Number|Boolean} value - The value to check against.\n * @returns\n */\n hasValue(key, value) {\n return this.get(key) == value;\n }\n\n /**\n * Get a cookie.\n * @param {String} key - The cookie name.\n * @returns {String|Number|Boolean}\n */\n get(key) {\n return this.exists(key) ? decodeURIComponent(this.all[key]) : null;\n }\n\n /**\n * Set a cookie.\n * @param {String} key - The cookie name.\n * @param {String|Number|Boolean} value - The cookie value.\n * @param {Object} options\n * @param {Number} [options.maxAge=this.defaultAge] - The maximum age of the cookie in seconds.\n * @param {String} [options.path=/] - The path to register the cookie for.\n * @param {String} [options.sameSite=Lax] - The sameSite attribute.\n * @param {String} [options.domain=this.defaultDomain] - The domain to register the cookie with.\n * @param {String} [options.path=this.defaultPath] - The path to register the cookie with.\n * @param {String} [options.secure=this.secure] - Only set cookie in HTTPS environments.\n * @param {String} [options.session=false] - Set a session cookie.\n */\n set(key, value, options = {}) {\n const {\n maxAge = this.defaultAge,\n sameSite = \"Lax\",\n domain = this.defaultDomain,\n path = this.defaultPath,\n secure = this.secure,\n session = false,\n } = options;\n if (!key) {\n return;\n }\n const cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)};${\n domain ? ` domain=${domain}; ` : \"\"\n } samesite=${sameSite}; path=${path}${!session ? `; max-age=${maxAge}` : \"\"}${\n secure ? \"; secure\" : \"\"\n }`;\n document.cookie = cookie;\n this.events.trigger(\"setCookie\", {\n key,\n value,\n maxAge,\n path,\n sameSite,\n domain,\n secure,\n session,\n cookie,\n });\n }\n\n /**\n * Delete a cookie.\n * @param {String} key - The cookie name.\n * @param {String} [path=/] - The path to the cookie is registered on.\n */\n delete(key, path = \"/\", domain = null) {\n const options = { maxAge: -1, path, domain: domain || undefined };\n this.set(key, \"\", options);\n this.events.trigger(\"deleteCookie\", { key, ...options });\n }\n\n /**\n * Delete all cookies.\n */\n deleteAll(path = \"/\", domain = null) {\n Object.keys(this.all).forEach((cookie) => {\n this.delete(cookie, path, domain);\n });\n this.events.trigger(\"deleteAllCookies\", { path, domain });\n }\n\n /**\n * Accept a policy.\n * @param {String} policy - The name of the policy.\n */\n acceptPolicy(policy) {\n this.setPolicy(policy, true);\n this.events.trigger(\"acceptPolicy\", policy);\n this.events.trigger(\"changePolicy\", { [policy]: true });\n }\n\n /**\n * Reject a policy.\n * @param {String} policy - The name of the policy.\n */\n rejectPolicy(policy) {\n this.setPolicy(policy, false);\n this.events.trigger(\"rejectPolicy\", policy);\n this.events.trigger(\"changePolicy\", { [policy]: false });\n }\n\n /**\n * Set a policy.\n * @param {String} policy - The name of the policy.\n * @param {Boolean} accepted - Whether the policy is accepted or not.\n */\n setPolicy(policy, accepted) {\n if (policy === \"essential\") {\n return;\n }\n this.savePolicies({\n ...this.policies,\n [policy]: accepted,\n essential: true,\n });\n this.events.trigger(\"changePolicy\", { [policy]: accepted });\n }\n\n /**\n * Accept all the cookie policies.\n */\n acceptAllPolicies() {\n const allPolicies = Object.fromEntries(\n Object.keys(this.policies).map((k) => [k.toLowerCase(), true]),\n );\n this.savePolicies(allPolicies);\n this.events.trigger(\"acceptAllPolicies\");\n this.events.trigger(\"changePolicy\", allPolicies);\n }\n\n /**\n * Reject all the cookie policies.\n */\n rejectAllPolicies() {\n const allPolicies = {\n ...Object.fromEntries(\n Object.keys(this.policies).map((k) => [k.toLowerCase(), false]),\n ),\n essential: true,\n };\n this.savePolicies(allPolicies);\n this.events.trigger(\"rejectAllPolicies\");\n this.events.trigger(\"changePolicy\", allPolicies);\n }\n\n /**\n * Commit policy preferences to the browser.\n * @param {object} policies - The policies to commit.\n */\n savePolicies(policies) {\n this.set(this.policiesKey, JSON.stringify(policies));\n }\n\n /**\n * Get the acceptance status of a policy.\n * @param {String} policy - The name of the policy.\n * @returns {Boolean}\n */\n isPolicyAccepted(policy) {\n return Object.hasOwn(this.policies, policy)\n ? this.policies[policy] === true\n : null;\n }\n\n /**\n * Add an event listener.\n * @param {String} event - The event to add a listener for.\n * @param {Function} callback - The callback function to call when the event is triggered.\n */\n on(event, callback) {\n this.events.on(event, callback);\n }\n\n /**\n * Add a one-time event listener.\n * @param {String} event - The event to add a listener for.\n * @param {Function} callback - The callback function to call when the event is triggered.\n */\n once(event, callback) {\n this.events.once(event, callback);\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import Cookies from \"../../lib/cookies.mjs\";\n\nexport { Cookies };\n\nexport class CookieBanner {\n constructor($module) {\n this.$module = $module;\n this.$acceptButton = $module && $module.querySelector('[value=\"accept\"]');\n this.$rejectButton = $module && $module.querySelector('[value=\"reject\"]');\n this.$prompt =\n $module && $module.querySelector(\".tna-cookie-banner__message--prompt\");\n this.$acceptedMessage =\n $module && $module.querySelector(\".tna-cookie-banner__message--accepted\");\n this.$rejectedMessage =\n $module && $module.querySelector(\".tna-cookie-banner__message--rejected\");\n this.$closeButtons = $module && $module.querySelectorAll('[value=\"close\"]');\n\n if (\n !this.$module ||\n !this.$acceptButton ||\n !this.$rejectButton ||\n !this.$prompt ||\n !this.$acceptedMessage ||\n !this.$rejectedMessage ||\n !this.$closeButtons\n ) {\n return;\n }\n\n this.cookies = new Cookies({ newInstance: true });\n\n this.cookiePreferencesSetKey =\n this.$module.dataset.preferencesKey || \"cookie_preferences_set\";\n\n if (!this.cookies.completePoliciesOnInit) {\n this.cookies.set(this.cookiePreferencesSetKey, false);\n } else if (!this.cookies.exists(this.cookiePreferencesSetKey)) {\n this.cookies.set(this.cookiePreferencesSetKey, true);\n }\n\n if (!this.cookies.hasValue(this.cookiePreferencesSetKey, \"true\")) {\n this.$module.removeAttribute(\"hidden\");\n\n this.$acceptButton.addEventListener(\"click\", () => this.accept());\n this.$rejectButton.addEventListener(\"click\", () => this.reject());\n }\n }\n\n accept() {\n this.$prompt.setAttribute(\"hidden\", \"\");\n this.complete();\n this.$acceptedMessage.removeAttribute(\"hidden\");\n this.$acceptedMessage.focus();\n this.$acceptedMessage.setAttribute(\"tabindex\", \"-1\");\n this.cookies.acceptAllPolicies();\n }\n\n reject() {\n this.$prompt.setAttribute(\"hidden\", \"\");\n this.complete();\n this.$rejectedMessage.removeAttribute(\"hidden\");\n this.$rejectedMessage.focus();\n this.$rejectedMessage.setAttribute(\"tabindex\", \"-1\");\n this.cookies.rejectAllPolicies();\n }\n\n complete() {\n this.cookies.set(this.cookiePreferencesSetKey, true);\n this.$closeButtons.forEach(($closeButton) => {\n $closeButton.addEventListener(\"click\", () => this.close());\n });\n }\n\n close() {\n this.$module.setAttribute(\"hidden\", \"\");\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","window","TNAFrontendCookies","TNAFrontendCookieEvents","CookieEventHandler","_createClass","_classCallCheck","_defineProperty","this","key","value","event","callback","Object","hasOwn","events","concat","_toConsumableArray","oneTimeEvents","_this","data","arguments","length","undefined","forEach","eventToTrigger","call","i","splice","Cookies","_this2","options","defaultDomain","defaultPath","secure","policiesKey","_options$newInstance","newInstance","defaultAge","_options$noInit","noInit","document","documentElement","dataset","tnaCookiesDomain","tnaCookiesPath","tnaCookiesInsecure","tnaCookiesPoliciesKey","parseInt","tnaCookiesDefaultAge","completePoliciesOnInit","keys","policies","every","policy","includes","init","savePolicies","_objectSpread","usage","settings","marketing","essential","get","deserialised","cookie","split","filter","x","parts","trim","JSON","parse","e","all","exists","decodeURIComponent","_options$maxAge","maxAge","_options$sameSite","sameSite","_options$domain","domain","_options$path","path","_options$secure","_options$session","session","encodeURIComponent","trigger","set","_this3","setPolicy","accepted","allPolicies","fromEntries","map","k","toLowerCase","stringify","on","once","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","d","definition","o","defineProperty","enumerable","obj","prop","prototype","hasOwnProperty","r","Symbol","toStringTag","CookieBanner","$module","$acceptButton","querySelector","$rejectButton","$prompt","$acceptedMessage","$rejectedMessage","$closeButtons","querySelectorAll","cookies","cookiePreferencesSetKey","preferencesKey","hasValue","removeAttribute","addEventListener","accept","reject","setAttribute","complete","focus","acceptAllPolicies","rejectAllPolicies","$closeButton","close"],"sourceRoot":""}
1
+ {"version":3,"file":"components/cookie-banner/cookie-banner.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,Q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CAAAnI,IAAA,SAAAC,MAED,WACEF,KAAKoH,QAAQa,aAAa,SAAU,IACpCjI,KAAKkI,WACLlI,KAAKsH,iBAAiBO,gBAAgB,UACtC7H,KAAKsH,iBAAiBa,QACtBnI,KAAKsH,iBAAiBW,aAAa,WAAY,MAC/CjI,KAAKyH,QAAQY,mBACf,GAAC,CAAApI,IAAA,WAAAC,MAED,WAAW,IAAAoB,EAAA,KACTtB,KAAKyH,QAAQvC,IAAIlF,KAAK0H,yBAAyB,GAC/C1H,KAAKuH,cAAcvG,SAAQ,SAACsH,GAC1BA,EAAaR,iBAAiB,SAAS,kBAAMxG,EAAKiH,OAAO,GAC3D,GACF,GAAC,CAAAtI,IAAA,QAAAC,MAED,WACEF,KAAKgH,QAAQiB,aAAa,SAAU,GACtC,M,6EAAC,CAxEsB,G","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","webpack://TNAFrontend/./src/nationalarchives/lib/cookies.mjs","webpack://TNAFrontend/webpack/bootstrap","webpack://TNAFrontend/webpack/runtime/define property getters","webpack://TNAFrontend/webpack/runtime/hasOwnProperty shorthand","webpack://TNAFrontend/webpack/runtime/make namespace object","webpack://TNAFrontend/./src/nationalarchives/components/cookie-banner/cookie-banner.mjs"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"TNAFrontend\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TNAFrontend\"] = factory();\n\telse\n\t\troot[\"TNAFrontend\"] = factory();\n})(self, () => {\nreturn ","window.TNAFrontendCookies = window.TNAFrontendCookies || null;\nwindow.TNAFrontendCookieEvents = window.TNAFrontendCookieEvents || null;\n\nexport class CookieEventHandler {\n events = {};\n oneTimeEvents = {};\n\n constructor() {\n if (window.TNAFrontendCookieEvents) {\n return window.TNAFrontendCookieEvents;\n }\n window.TNAFrontendCookieEvents = this;\n }\n\n /**\n * Add an event listener.\n * @param {String} event - The event to add a listener for.\n * @param {Function} callback - The callback function to call when the event is triggered.\n */\n on(event, callback) {\n if (!Object.hasOwn(this.events, event)) {\n this.events[event] = [];\n }\n this.events[event] = [...this.events[event], callback];\n }\n\n once(event, callback) {\n if (!Object.hasOwn(this.oneTimeEvents, event)) {\n this.oneTimeEvents[event] = [];\n }\n this.oneTimeEvents[event] = [...this.oneTimeEvents[event], callback];\n }\n\n /** @protected */\n trigger(event, data = {}) {\n if (Object.hasOwn(this.events, event)) {\n this.events[event].forEach((eventToTrigger) =>\n eventToTrigger.call(this, data),\n );\n }\n if (Object.hasOwn(this.oneTimeEvents, event)) {\n for (let i = this.oneTimeEvents[event].length - 1; i >= 0; i--) {\n const eventToTrigger = this.oneTimeEvents[event][i];\n eventToTrigger.call(this, data);\n this.oneTimeEvents[event].splice(i, 1);\n }\n }\n }\n}\n\n/**\n * Class to handle cookies.\n * @class Cookies\n * @constructor\n * @public\n */\nexport default class Cookies {\n /** @protected */\n defaultDomain = \"\";\n /** @protected */\n defaultPath = \"\";\n /** @protected */\n secure = true;\n /** @protected */\n policiesKey = \"\";\n /** @protected */\n events = null;\n /** @protected */\n defaultAge = null;\n /** @protected */\n completePoliciesOnInit = false;\n\n /**\n * Create a cookie handler.\n * @param {String} [options.defaultDomain] - The domain to register the cookie with.\n * @param {String} [options.path] - The domain to register the cookie with.\n * @param {Boolean} [options.secure] - Only set cookie in HTTPS environments.\n * @param {String} [options.policiesKey] - The name of the cookie.\n * @param {String} [options.newInstance=false] - Create a fresh instance of the cookie class.\n * @param {Number} [options.defaultAge] - The default age of non-session cookies.\n * @param {Boolean} [options.noInit=false] - Don't initialise a blank cookie policy.\n */\n constructor(options = {}) {\n const {\n defaultDomain,\n defaultPath,\n secure,\n policiesKey,\n newInstance = false,\n defaultAge,\n noInit = false,\n } = options;\n if (!newInstance && window.TNAFrontendCookies) {\n return window.TNAFrontendCookies;\n }\n if (defaultDomain === undefined) {\n this.defaultDomain =\n document.documentElement.dataset.tnaCookiesDomain || \"\";\n } else {\n this.defaultDomain = defaultDomain;\n }\n if (defaultPath === undefined) {\n this.defaultPath = document.documentElement.dataset.tnaCookiesPath || \"/\";\n } else {\n this.defaultPath = defaultPath;\n }\n if (secure === undefined) {\n this.secure =\n document.documentElement.dataset.tnaCookiesInsecure !== \"true\";\n } else {\n this.secure = secure;\n }\n if (policiesKey === undefined) {\n this.policiesKey =\n document.documentElement.dataset.tnaCookiesPoliciesKey ||\n \"cookies_policy\";\n } else {\n this.policiesKey = policiesKey;\n }\n if (defaultAge === undefined) {\n this.defaultAge =\n parseInt(document.documentElement.dataset.tnaCookiesDefaultAge) ||\n 31536000; // 365 days;\n } else {\n this.defaultAge = defaultAge;\n }\n this.events = new CookieEventHandler();\n this.completePoliciesOnInit =\n Object.keys(this.policies).length === 4 &&\n [\"usage\", \"settings\", \"marketing\", \"essential\"].every(\n (policy) =>\n Object.keys(this.policies).includes(policy) &&\n typeof this.policies[policy] === \"boolean\",\n );\n if (!this.completePoliciesOnInit && !noInit) {\n this.init();\n }\n window.TNAFrontendCookies = this;\n }\n\n /** @protected */\n init() {\n this.savePolicies({\n usage: false,\n settings: false,\n marketing: false,\n ...this.policies,\n essential: true,\n });\n }\n\n destroyInstance() {\n window.TNAFrontendCookies = null;\n }\n\n /** @protected */\n get all() {\n const deserialised = {};\n document.cookie\n .split(\"; \")\n .filter((x) => x)\n .forEach((cookie) => {\n const parts = cookie.trim().split(\"=\");\n if (parts[0]) {\n deserialised[parts[0]] = parts[1];\n }\n });\n return deserialised;\n }\n\n /** @protected */\n get policies() {\n try {\n return JSON.parse(this.get(this.policiesKey) || \"{}\");\n } catch (e) {\n return {};\n }\n }\n\n /**\n * Check to see whether a cookie exists or not.\n * @param {String} key - The cookie name.\n * @returns {Boolean}\n */\n exists(key) {\n return Object.hasOwn(this.all, key);\n }\n\n /**\n * Check to see whether a cookie has a particular value.\n * @param {String} key - The cookie name.\n * @param {String|Number|Boolean} value - The value to check against.\n * @returns\n */\n hasValue(key, value) {\n return this.get(key) == value;\n }\n\n /**\n * Get a cookie.\n * @param {String} key - The cookie name.\n * @returns {String|Number|Boolean}\n */\n get(key) {\n return this.exists(key) ? decodeURIComponent(this.all[key]) : null;\n }\n\n /**\n * Set a cookie.\n * @param {String} key - The cookie name.\n * @param {String|Number|Boolean} value - The cookie value.\n * @param {Object} options\n * @param {Number} [options.maxAge=this.defaultAge] - The maximum age of the cookie in seconds.\n * @param {String} [options.path=/] - The path to register the cookie for.\n * @param {String} [options.sameSite=Lax] - The sameSite attribute.\n * @param {String} [options.domain=this.defaultDomain] - The domain to register the cookie with.\n * @param {String} [options.path=this.defaultPath] - The path to register the cookie with.\n * @param {String} [options.secure=this.secure] - Only set cookie in HTTPS environments.\n * @param {String} [options.session=false] - Set a session cookie.\n */\n set(key, value, options = {}) {\n const {\n maxAge = this.defaultAge,\n sameSite = \"Lax\",\n domain = this.defaultDomain,\n path = this.defaultPath,\n secure = this.secure,\n session = false,\n } = options;\n if (!key) {\n return;\n }\n const cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)};${\n domain ? ` domain=${domain}; ` : \"\"\n } samesite=${sameSite}; path=${path}${!session ? `; max-age=${maxAge}` : \"\"}${\n secure ? \"; secure\" : \"\"\n }`;\n document.cookie = cookie;\n this.events.trigger(\"setCookie\", {\n key,\n value,\n maxAge,\n path,\n sameSite,\n domain,\n secure,\n session,\n cookie,\n });\n }\n\n /**\n * Delete a cookie.\n * @param {String} key - The cookie name.\n * @param {String} [path=/] - The path to the cookie is registered on.\n */\n delete(key, path = \"/\", domain = null) {\n const options = { maxAge: -1, path, domain: domain || undefined };\n this.set(key, \"\", options);\n this.events.trigger(\"deleteCookie\", { key, ...options });\n }\n\n /**\n * Delete all cookies.\n */\n deleteAll(path = \"/\", domain = null) {\n Object.keys(this.all).forEach((cookie) => {\n this.delete(cookie, path, domain);\n });\n this.events.trigger(\"deleteAllCookies\", { path, domain });\n }\n\n /**\n * Accept a policy.\n * @param {String} policy - The name of the policy.\n */\n acceptPolicy(policy) {\n this.setPolicy(policy, true);\n this.events.trigger(\"acceptPolicy\", policy);\n this.events.trigger(\"changePolicy\", { [policy]: true });\n }\n\n /**\n * Reject a policy.\n * @param {String} policy - The name of the policy.\n */\n rejectPolicy(policy) {\n this.setPolicy(policy, false);\n this.events.trigger(\"rejectPolicy\", policy);\n this.events.trigger(\"changePolicy\", { [policy]: false });\n }\n\n /**\n * Set a policy.\n * @param {String} policy - The name of the policy.\n * @param {Boolean} accepted - Whether the policy is accepted or not.\n */\n setPolicy(policy, accepted) {\n if (policy === \"essential\") {\n return;\n }\n this.savePolicies({\n ...this.policies,\n [policy]: accepted,\n essential: true,\n });\n this.events.trigger(\"changePolicy\", { [policy]: accepted });\n }\n\n /**\n * Accept all the cookie policies.\n */\n acceptAllPolicies() {\n const allPolicies = Object.fromEntries(\n Object.keys(this.policies).map((k) => [k.toLowerCase(), true]),\n );\n this.savePolicies(allPolicies);\n this.events.trigger(\"acceptAllPolicies\");\n this.events.trigger(\"changePolicy\", allPolicies);\n }\n\n /**\n * Reject all the cookie policies.\n */\n rejectAllPolicies() {\n const allPolicies = {\n ...Object.fromEntries(\n Object.keys(this.policies).map((k) => [k.toLowerCase(), false]),\n ),\n essential: true,\n };\n this.savePolicies(allPolicies);\n this.events.trigger(\"rejectAllPolicies\");\n this.events.trigger(\"changePolicy\", allPolicies);\n }\n\n /**\n * Commit policy preferences to the browser.\n * @param {object} policies - The policies to commit.\n */\n savePolicies(policies) {\n this.set(this.policiesKey, JSON.stringify(policies));\n }\n\n /**\n * Get the acceptance status of a policy.\n * @param {String} policy - The name of the policy.\n * @returns {Boolean}\n */\n isPolicyAccepted(policy) {\n return Object.hasOwn(this.policies, policy)\n ? this.policies[policy] === true\n : null;\n }\n\n /**\n * Add an event listener.\n * @param {String} event - The event to add a listener for.\n * @param {Function} callback - The callback function to call when the event is triggered.\n */\n on(event, callback) {\n this.events.on(event, callback);\n }\n\n /**\n * Add a one-time event listener.\n * @param {String} event - The event to add a listener for.\n * @param {Function} callback - The callback function to call when the event is triggered.\n */\n once(event, callback) {\n this.events.once(event, callback);\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import Cookies from \"../../lib/cookies.mjs\";\n\nexport { Cookies };\n\nexport class CookieBanner {\n constructor($module) {\n this.$module = $module;\n this.$acceptButton = $module && $module.querySelector('[value=\"accept\"]');\n this.$rejectButton = $module && $module.querySelector('[value=\"reject\"]');\n this.$prompt =\n $module && $module.querySelector(\".tna-cookie-banner__message--prompt\");\n this.$acceptedMessage =\n $module && $module.querySelector(\".tna-cookie-banner__message--accepted\");\n this.$rejectedMessage =\n $module && $module.querySelector(\".tna-cookie-banner__message--rejected\");\n this.$closeButtons = $module && $module.querySelectorAll('[value=\"close\"]');\n\n if (\n !this.$module ||\n !this.$acceptButton ||\n !this.$rejectButton ||\n !this.$prompt ||\n !this.$acceptedMessage ||\n !this.$rejectedMessage ||\n !this.$closeButtons\n ) {\n return;\n }\n\n this.cookies = new Cookies({ newInstance: true });\n\n this.cookiePreferencesSetKey =\n this.$module.dataset.preferencesKey || \"cookie_preferences_set\";\n\n if (!this.cookies.completePoliciesOnInit) {\n this.cookies.set(this.cookiePreferencesSetKey, false);\n }\n\n if (\n !this.cookies.exists(this.cookiePreferencesSetKey) ||\n !this.cookies.hasValue(this.cookiePreferencesSetKey, \"true\")\n ) {\n this.$module.removeAttribute(\"hidden\");\n\n this.$acceptButton.addEventListener(\"click\", () => this.accept());\n this.$rejectButton.addEventListener(\"click\", () => this.reject());\n }\n }\n\n accept() {\n this.$prompt.setAttribute(\"hidden\", \"\");\n this.complete();\n this.$acceptedMessage.removeAttribute(\"hidden\");\n this.$acceptedMessage.focus();\n this.$acceptedMessage.setAttribute(\"tabindex\", \"-1\");\n this.cookies.acceptAllPolicies();\n }\n\n reject() {\n this.$prompt.setAttribute(\"hidden\", \"\");\n this.complete();\n this.$rejectedMessage.removeAttribute(\"hidden\");\n this.$rejectedMessage.focus();\n this.$rejectedMessage.setAttribute(\"tabindex\", \"-1\");\n this.cookies.rejectAllPolicies();\n }\n\n complete() {\n this.cookies.set(this.cookiePreferencesSetKey, true);\n this.$closeButtons.forEach(($closeButton) => {\n $closeButton.addEventListener(\"click\", () => this.close());\n });\n }\n\n close() {\n this.$module.setAttribute(\"hidden\", \"\");\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","window","TNAFrontendCookies","TNAFrontendCookieEvents","CookieEventHandler","_createClass","_classCallCheck","_defineProperty","this","key","value","event","callback","Object","hasOwn","events","concat","_toConsumableArray","oneTimeEvents","_this","data","arguments","length","undefined","forEach","eventToTrigger","call","i","splice","Cookies","_this2","options","defaultDomain","defaultPath","secure","policiesKey","_options$newInstance","newInstance","defaultAge","_options$noInit","noInit","document","documentElement","dataset","tnaCookiesDomain","tnaCookiesPath","tnaCookiesInsecure","tnaCookiesPoliciesKey","parseInt","tnaCookiesDefaultAge","completePoliciesOnInit","keys","policies","every","policy","includes","init","savePolicies","_objectSpread","usage","settings","marketing","essential","get","deserialised","cookie","split","filter","x","parts","trim","JSON","parse","e","all","exists","decodeURIComponent","_options$maxAge","maxAge","_options$sameSite","sameSite","_options$domain","domain","_options$path","path","_options$secure","_options$session","session","encodeURIComponent","trigger","set","_this3","setPolicy","accepted","allPolicies","fromEntries","map","k","toLowerCase","stringify","on","once","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","d","definition","o","defineProperty","enumerable","obj","prop","prototype","hasOwnProperty","r","Symbol","toStringTag","CookieBanner","$module","$acceptButton","querySelector","$rejectButton","$prompt","$acceptedMessage","$rejectedMessage","$closeButtons","querySelectorAll","cookies","cookiePreferencesSetKey","preferencesKey","hasValue","removeAttribute","addEventListener","accept","reject","setAttribute","complete","focus","acceptAllPolicies","rejectAllPolicies","$closeButton","close"],"sourceRoot":""}
@@ -34,11 +34,12 @@ export class CookieBanner {
34
34
 
35
35
  if (!this.cookies.completePoliciesOnInit) {
36
36
  this.cookies.set(this.cookiePreferencesSetKey, false);
37
- } else if (!this.cookies.exists(this.cookiePreferencesSetKey)) {
38
- this.cookies.set(this.cookiePreferencesSetKey, true);
39
37
  }
40
38
 
41
- if (!this.cookies.hasValue(this.cookiePreferencesSetKey, "true")) {
39
+ if (
40
+ !this.cookies.exists(this.cookiePreferencesSetKey) ||
41
+ !this.cookies.hasValue(this.cookiePreferencesSetKey, "true")
42
+ ) {
42
43
  this.$module.removeAttribute("hidden");
43
44
 
44
45
  this.$acceptButton.addEventListener("click", () => this.accept());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nationalarchives/frontend",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "The National Archives frontend styles",
5
5
  "scripts": {
6
6
  "start": "storybook dev -p 6006",