@nationalarchives/frontend 0.1.24-prerelease → 0.1.26-prerelease
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/README.md +22 -0
- package/govuk-prototype-kit.config.json +4 -12
- package/nationalarchives/all.css +2 -2
- package/nationalarchives/all.css.map +1 -1
- package/nationalarchives/all.js +1 -1
- package/nationalarchives/all.js.map +1 -1
- package/nationalarchives/all.mjs +0 -11
- package/nationalarchives/components/_index.scss +8 -0
- package/nationalarchives/components/breadcrumbs/breadcrumbs.css +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.js +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.js.map +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.mjs +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.scss +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +1 -1
- package/nationalarchives/components/button/_button-group.scss +4 -0
- package/nationalarchives/components/button/button.css +1 -1
- package/nationalarchives/components/button/button.css.map +1 -1
- package/nationalarchives/components/button/button.scss +89 -26
- package/nationalarchives/components/button/button.stories.js +52 -5
- package/nationalarchives/components/button/macro-options.json +18 -0
- package/nationalarchives/components/button/template.njk +15 -6
- package/nationalarchives/components/card/card.css +1 -1
- package/nationalarchives/components/card/card.css.map +1 -1
- package/nationalarchives/components/card/card.scss +7 -37
- package/nationalarchives/components/card/card.stories.js +6 -78
- package/nationalarchives/components/card/fixtures.json +17 -17
- package/nationalarchives/components/card/macro-options.json +41 -17
- package/nationalarchives/components/card/template.njk +51 -48
- package/nationalarchives/components/checkboxes/_index.scss +1 -0
- package/nationalarchives/components/checkboxes/checkboxes.css +1 -0
- package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -0
- package/nationalarchives/components/checkboxes/checkboxes.scss +143 -0
- package/nationalarchives/components/checkboxes/checkboxes.stories.js +238 -0
- package/nationalarchives/components/checkboxes/fixtures.json +4 -0
- package/nationalarchives/components/checkboxes/macro-options.json +102 -0
- package/nationalarchives/components/checkboxes/macro.njk +3 -0
- package/nationalarchives/components/checkboxes/template.njk +35 -0
- package/nationalarchives/components/cookie-banner/cookie-banner.css +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.css.map +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.js +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.js.map +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.mjs +19 -16
- package/nationalarchives/components/cookie-banner/cookie-banner.stories.js +103 -42
- package/nationalarchives/components/cookie-banner/fixtures.json +54 -8
- package/nationalarchives/components/cookie-banner/macro-options.json +19 -1
- package/nationalarchives/components/cookie-banner/template.njk +1 -1
- package/nationalarchives/components/date-input/_index.scss +1 -0
- package/nationalarchives/components/date-input/date-input.css +1 -0
- package/nationalarchives/components/date-input/date-input.css.map +1 -0
- package/nationalarchives/components/date-input/date-input.scss +48 -0
- package/nationalarchives/components/date-input/date-input.stories.js +116 -0
- package/nationalarchives/components/date-input/fixtures.json +4 -0
- package/nationalarchives/components/date-input/macro-options.json +96 -0
- package/nationalarchives/components/date-input/macro.njk +3 -0
- package/nationalarchives/components/date-input/template.njk +45 -0
- package/nationalarchives/components/date-search/_index.scss +1 -0
- package/nationalarchives/components/date-search/date-search.css +1 -0
- package/nationalarchives/components/date-search/date-search.css.map +1 -0
- package/nationalarchives/components/date-search/date-search.scss +27 -0
- package/nationalarchives/components/date-search/date-search.stories.js +121 -0
- package/nationalarchives/components/date-search/fixtures.json +4 -0
- package/nationalarchives/components/date-search/macro-options.json +94 -0
- package/nationalarchives/components/date-search/macro.njk +3 -0
- package/nationalarchives/components/date-search/template.njk +27 -0
- package/nationalarchives/components/featured-records/featured-records.css +1 -1
- package/nationalarchives/components/featured-records/featured-records.css.map +1 -1
- package/nationalarchives/components/filters/filters.css +1 -1
- package/nationalarchives/components/filters/filters.css.map +1 -1
- package/nationalarchives/components/filters/filters.scss +0 -8
- package/nationalarchives/components/filters/template.njk +2 -2
- package/nationalarchives/components/footer/footer.css +1 -1
- package/nationalarchives/components/footer/footer.css.map +1 -1
- package/nationalarchives/components/footer/footer.scss +3 -5
- package/nationalarchives/components/footer/footer.stories.js +1 -1
- package/nationalarchives/components/footer/template.njk +13 -9
- package/nationalarchives/components/gallery/gallery.css +1 -1
- package/nationalarchives/components/gallery/gallery.css.map +1 -1
- package/nationalarchives/components/gallery/gallery.scss +0 -11
- package/nationalarchives/components/gallery/gallery.stories.js +8 -10
- package/nationalarchives/components/gallery/template.njk +1 -1
- package/nationalarchives/components/grid/grid.css +1 -1
- package/nationalarchives/components/grid/grid.css.map +1 -1
- package/nationalarchives/components/grid/grid.scss +12 -0
- package/nationalarchives/components/grid/grid.stories.js +12 -0
- package/nationalarchives/components/header/header.css +1 -1
- package/nationalarchives/components/header/header.css.map +1 -1
- package/nationalarchives/components/header/header.scss +36 -41
- package/nationalarchives/components/header/header.stories.js +0 -41
- package/nationalarchives/components/header/template.njk +3 -3
- package/nationalarchives/components/hero/hero.css +1 -1
- package/nationalarchives/components/hero/hero.css.map +1 -1
- package/nationalarchives/components/hero/hero.scss +3 -7
- package/nationalarchives/components/hero/hero.stories.js +6 -0
- package/nationalarchives/components/index-grid/fixtures.json +324 -1
- package/nationalarchives/components/index-grid/index-grid.css +1 -1
- package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
- package/nationalarchives/components/index-grid/index-grid.scss +13 -10
- package/nationalarchives/components/index-grid/index-grid.stories.js +27 -14
- package/nationalarchives/components/index-grid/macro-options.json +34 -29
- package/nationalarchives/components/index-grid/template.njk +13 -8
- package/nationalarchives/components/message/message.css +1 -1
- package/nationalarchives/components/message/message.css.map +1 -1
- package/nationalarchives/components/message/message.scss +1 -6
- package/nationalarchives/components/message/template.njk +1 -1
- package/nationalarchives/components/pagination/macro-options.json +6 -0
- package/nationalarchives/components/pagination/pagination.css +1 -1
- package/nationalarchives/components/pagination/pagination.css.map +1 -1
- package/nationalarchives/components/pagination/pagination.scss +4 -0
- package/nationalarchives/components/pagination/pagination.stories.js +63 -2
- package/nationalarchives/components/pagination/template.njk +39 -17
- package/nationalarchives/components/phase-banner/phase-banner.css +1 -1
- package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
- package/nationalarchives/components/phase-banner/phase-banner.scss +2 -3
- package/nationalarchives/components/picture/picture.css +1 -1
- package/nationalarchives/components/picture/picture.css.map +1 -1
- package/nationalarchives/components/picture/picture.js.map +1 -1
- package/nationalarchives/components/picture/picture.mjs +0 -4
- package/nationalarchives/components/picture/picture.scss +1 -1
- package/nationalarchives/components/picture/template.njk +1 -1
- package/nationalarchives/components/radios/_index.scss +1 -0
- package/nationalarchives/components/radios/fixtures.json +4 -0
- package/nationalarchives/components/radios/macro-options.json +102 -0
- package/nationalarchives/components/radios/macro.njk +3 -0
- package/nationalarchives/components/radios/radios.css +1 -0
- package/nationalarchives/components/radios/radios.css.map +1 -0
- package/nationalarchives/components/radios/radios.scss +131 -0
- package/nationalarchives/components/radios/radios.stories.js +241 -0
- package/nationalarchives/components/radios/template.njk +35 -0
- package/nationalarchives/components/search-field/_index.scss +1 -0
- package/nationalarchives/components/search-field/fixtures.json +4 -0
- package/nationalarchives/components/search-field/macro-options.json +68 -0
- package/nationalarchives/components/search-field/macro.njk +3 -0
- package/nationalarchives/components/search-field/search-field.css +1 -0
- package/nationalarchives/components/search-field/search-field.css.map +1 -0
- package/nationalarchives/components/search-field/search-field.scss +32 -0
- package/nationalarchives/components/search-field/search-field.stories.js +88 -0
- package/nationalarchives/components/search-field/template.njk +32 -0
- package/nationalarchives/components/select/_index.scss +1 -0
- package/nationalarchives/components/select/fixtures.json +4 -0
- package/nationalarchives/components/select/macro-options.json +114 -0
- package/nationalarchives/components/select/macro.njk +3 -0
- package/nationalarchives/components/select/select.css +1 -0
- package/nationalarchives/components/select/select.css.map +1 -0
- package/nationalarchives/components/select/select.scss +51 -0
- package/nationalarchives/components/select/select.stories.js +194 -0
- package/nationalarchives/components/select/template.njk +29 -0
- package/nationalarchives/components/sensitive-image/sensitive-image.css +1 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.css.map +1 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +3 -0
- package/nationalarchives/components/sensitive-image/template.njk +1 -1
- package/nationalarchives/components/skip-link/skip-link.css +1 -1
- package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
- package/nationalarchives/components/skip-link/skip-link.stories.js +4 -1
- package/nationalarchives/components/skip-link/template.njk +1 -1
- package/nationalarchives/components/tabs/tabs.css +1 -1
- package/nationalarchives/components/tabs/tabs.css.map +1 -1
- package/nationalarchives/components/tabs/tabs.js +1 -1
- package/nationalarchives/components/tabs/tabs.js.map +1 -1
- package/nationalarchives/components/tabs/tabs.mjs +1 -1
- package/nationalarchives/components/tabs/tabs.scss +11 -1
- package/nationalarchives/components/tabs/tabs.stories.js +6 -3
- package/nationalarchives/components/tabs/template.njk +1 -1
- package/nationalarchives/components/text-input/_index.scss +1 -0
- package/nationalarchives/components/text-input/fixtures.json +4 -0
- package/nationalarchives/components/text-input/macro-options.json +118 -0
- package/nationalarchives/components/text-input/macro.njk +3 -0
- package/nationalarchives/components/text-input/template.njk +30 -0
- package/nationalarchives/components/text-input/text-input.css +1 -0
- package/nationalarchives/components/text-input/text-input.css.map +1 -0
- package/nationalarchives/components/text-input/text-input.scss +44 -0
- package/nationalarchives/components/text-input/text-input.stories.js +188 -0
- package/nationalarchives/components/textarea/_index.scss +1 -0
- package/nationalarchives/components/textarea/fixtures.json +4 -0
- package/nationalarchives/components/textarea/macro-options.json +106 -0
- package/nationalarchives/components/textarea/macro.njk +3 -0
- package/nationalarchives/components/textarea/template.njk +27 -0
- package/nationalarchives/components/textarea/textarea.css +1 -0
- package/nationalarchives/components/textarea/textarea.css.map +1 -0
- package/nationalarchives/components/textarea/textarea.scss +45 -0
- package/nationalarchives/components/textarea/textarea.stories.js +127 -0
- package/nationalarchives/lib/cookies.mjs +172 -63
- package/nationalarchives/prototype-kit.css +2 -2
- package/nationalarchives/prototype-kit.css.map +1 -1
- package/nationalarchives/prototype-kit.scss +0 -8
- package/nationalarchives/stories/utilities/colour-schemes/colour-schemes.stories.js +449 -91
- package/nationalarchives/stories/utilities/forms/forms.mdx +117 -0
- package/nationalarchives/stories/utilities/overrides/overrides.stories.js +1 -0
- package/nationalarchives/stories/utilities/tables/tables.mdx +8 -0
- package/nationalarchives/stories/utilities/tables/tables.stories.js +45 -0
- package/nationalarchives/stories/utilities/typography/heading-groups.stories.js +59 -19
- package/nationalarchives/stories/utilities/typography/typography.stories.js +0 -6
- package/nationalarchives/templates/layouts/_generic.njk +1 -1
- package/nationalarchives/templates/layouts/_prototype-kit.njk +2 -0
- package/nationalarchives/tests/cookies.test.js +427 -0
- package/nationalarchives/tests/uuid.test.js +17 -0
- package/nationalarchives/tools/_colour.scss +50 -27
- package/nationalarchives/tools/_typography.scss +0 -1
- package/nationalarchives/utilities/_a11y.scss +6 -2
- package/nationalarchives/utilities/_colour.scss +10 -6
- package/nationalarchives/utilities/_debug.scss +3 -4
- package/nationalarchives/utilities/_forms.scss +93 -0
- package/nationalarchives/utilities/_index.scss +2 -0
- package/nationalarchives/utilities/_lists.scss +6 -1
- package/nationalarchives/utilities/_overrides.scss +1 -1
- package/nationalarchives/utilities/_tables.scss +86 -0
- package/nationalarchives/utilities/_typography.scss +71 -77
- package/nationalarchives/variables/_colour.scss +15 -10
- package/nationalarchives/variables/_forms.scss +2 -0
- package/nationalarchives/variables/_index.scss +1 -0
- package/nationalarchives/variables/_typography.scss +2 -2
- package/package.json +19 -19
- package/nationalarchives/stories/utilities/overrides/overrides.mdx +0 -53
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TNAFrontend",[],t):"object"==typeof exports?exports.TNAFrontend=t():e.TNAFrontend=t()}(self,(()=>(()=>{"use strict";var e={774:(e,t,i)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function n(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)}return i}function r(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(Object(i),!0).forEach((function(t){c(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function c(e,t,i){return(t=a(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e,t){for(var i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,a(o.key),o)}}function a(e){var t=function(e,t){if("object"!==o(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,"string");if("object"!==o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===o(t)?t:String(t)}function l(e,t){u(e,t),t.add(e)}function u(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function p(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return i}function f(e,t,i){return function(e,t,i){if(t.set)t.set.call(e,i);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=i}}(e,y(e,t,"set"),i),i}function h(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,y(e,t,"get"))}function y(e,t,i){if(!t.has(e))throw new TypeError("attempted to "+i+" private field on non-instance");return t.get(e)}i.d(t,{Z:()=>m});var d=new WeakMap,v=new WeakSet,b=new WeakSet,m=function(){function e(){var t,i,o=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["usage","settings"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"cookies_policy";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,b),l(this,v),i={writable:!0,value:{}},u(this,t=d),t.set(this,i),this.cookiesPolicyKey=r,n.forEach((function(e){h(o,d)[e.toLowerCase()]=!1})),h(this,d).essential=!0}var t,i;return t=e,i=[{key:"policies",get:function(){return this.exists(this.cookiesPolicyKey)?f(this,d,r(r({},h(this,d)),this.allPolicies)):h(this,d)},set:function(e){f(this,d,e)}},{key:"all",get:function(){return p(this,v,g).call(this,document.cookie)}},{key:"exists",value:function(e){return Object.prototype.hasOwnProperty.call(this.all,e)}},{key:"hasValue",value:function(e,t){return this.get(e)==t}},{key:"get",value:function(e){return this.exists(e)?decodeURIComponent(this.all[e]):null}},{key:"set",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.maxAge,n=void 0===o?31536e3:o,r=i.path,c=void 0===r?"/":r,s=i.sameSite,a=void 0===s?"Lax":s;document.cookie="".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t),"; SameSite=").concat(a,"; path=").concat(c,"; max-age=").concat(n,"; Secure")}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";this.set(e,"",0,t)}},{key:"allPolicies",get:function(){return JSON.parse(this.get(this.cookiesPolicyKey)||"{}")}},{key:"acceptPolicy",value:function(e){p(this,b,k).call(this,e,!0),this.savePolicies()}},{key:"rejectPolicy",value:function(e){"essential"!==e&&(p(this,b,k).call(this,e,!1),this.savePolicies())}},{key:"savePolicies",value:function(){this.set(this.cookiesPolicyKey,JSON.stringify(this.policies))}},{key:"acceptAllPolicies",value:function(){var e=this;Object.keys(this.policies).forEach((function(t){return p(e,b,k).call(e,t,!0)})),this.savePolicies()}},{key:"rejectAllPolicies",value:function(){var e=this;Object.keys(this.policies).forEach((function(t){return p(e,b,k).call(e,t,!1)})),this.savePolicies()}},{key:"isPolicyAccepted",value:function(e){return Object.prototype.hasOwnProperty.call(this.policies,e)?!0===this.policies[e]:null}}],i&&s(t.prototype,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function g(e){var t={};return e.split(";").forEach((function(e){var i=e.trim().split("=");t[i[0]]=i[1]})),t}function k(e,t){var i;this.policies=r(r({},this.policies),{},(c(i={},e,t),c(i,"essential",!0),i))}}},t={};function i(o){var n=t[o];if(void 0!==n)return n.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{CookieBanner:()=>r});var e=i(774);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,i){for(var o=0;o<i.length;o++){var n=i[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(void 0,r=function(e,i){if("object"!==t(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,"string");if("object"!==t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key),"symbol"===t(r)?r:String(r)),n)}var r}var r=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.$module=e,this.$acceptButton=e&&e.querySelector('[value="accept"]'),this.$rejectButton=e&&e.querySelector('[value="reject"]'),this.$prompt=e&&e.querySelector(".tna-cookie-banner__message--prompt"),this.$acceptedMessage=e&&e.querySelector(".tna-cookie-banner__message--accepted"),this.$rejectedMessage=e&&e.querySelector(".tna-cookie-banner__message--rejected"),this.$closeButtons=e&&e.querySelectorAll('[value="close"]')}var i,o;return i=t,(o=[{key:"init",value:function(){var t=this;if(this.$module&&this.$acceptButton&&this.$rejectButton&&this.$prompt&&this.$acceptedMessage&&this.$rejectedMessage&&this.$closeButtons){var i=this.$module.getAttribute("data-policies");i&&(this.cookies=new e.Z(i.split(",").map((function(e){return e.trim()}))),this.loadScriptsOnAccept=this.$module.getAttribute("data-acceptscripts"),this.cookiePreferencesSet=this.$module.getAttribute("data-preferenceskey")||"cookies_preferences_set",this.cookies.hasValue(this.cookiePreferencesSet,"true")||(this.$module.removeAttribute("hidden"),this.$acceptButton.addEventListener("click",(function(){return t.accept()})),this.$rejectButton.addEventListener("click",(function(){return t.reject()}))))}}},{key:"accept",value:function(){this.$prompt.setAttribute("hidden",!0),this.complete(),this.$acceptedMessage.removeAttribute("hidden"),this.$acceptedMessage.focus(),this.$acceptedMessage.setAttribute("tabindex","-1"),this.cookies.acceptAllPolicies(),this.loadScriptsOnAccept&&this.loadScriptsOnAccept.split(",").forEach((function(e){var t=document.createElement("script");t.src=e,document.head.appendChild(t)}))}},{key:"reject",value:function(){this.$prompt.setAttribute("hidden",!0),this.complete(),this.$rejectedMessage.removeAttribute("hidden"),this.$rejectedMessage.focus(),this.$rejectedMessage.setAttribute("tabindex","-1"),this.cookies.rejectAllPolicies()}},{key:"complete",value:function(){var e=this;this.cookies.set(this.cookiePreferencesSet,!0),this.$closeButtons.forEach((function(t){t.addEventListener("click",(function(){return e.close()}))}))}},{key:"close",value:function(){this.$module.setAttribute("hidden",!0)}}])&&n(i.prototype,o),Object.defineProperty(i,"prototype",{writable:!1}),t}()})(),o})()));
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TNAFrontend",[],t):"object"==typeof exports?exports.TNAFrontend=t():e.TNAFrontend=t()}(self,(()=>(()=>{"use strict";var e={774:(e,t,i)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)}return i}function n(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){u(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=new Array(t);i<t;i++)o[i]=e[i];return o}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,h(o.key),o)}}function l(e,t,i){return t&&a(e.prototype,t),i&&a(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,i){return(t=h(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function h(e){var t=function(e,t){if("object"!==o(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,"string");if("object"!==o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===o(t)?t:String(t)}i.d(t,{Z:()=>p});var f=function(){function e(){if(s(this,e),u(this,"events",{}),e._instance)return e._instance;e._instance=this}return l(e,[{key:"on",value:function(e,t){var i;Object.prototype.hasOwnProperty.call(this.events,e)||(this.events[e]=[]),this.events[e]=[].concat(function(e){if(Array.isArray(e))return c(e)}(i=this.events[e])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?c(e,t):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[t])}},{key:"trigger",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object.prototype.hasOwnProperty.call(this.events,e)&&this.events[e].forEach((function(e){return e.call(t,i)}))}}]),e}(),p=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,e),u(this,"extraPolicies",[]),u(this,"domain",""),u(this,"path",""),u(this,"secure",!0),u(this,"policiesKey","");var o=i.domain,r=void 0===o?"":o,n=i.path,c=void 0===n?"/":n,a=i.secure,l=void 0===a||a,h=i.policiesKey,p=void 0===h?"cookies_policy":h;this.extraPolicies=t,this.domain=r,this.path=c,this.secure=l,this.policiesKey=p,this.events=new f,this.init()}return l(e,[{key:"init",value:function(){this.savePolicies(n(n(n({},Object.fromEntries(this.extraPolicies.map((function(e){return[e.toLowerCase(),!1]})))),{},{usage:!1,settings:!1},this.policies),{},{essential:!0}))}},{key:"all",get:function(){var e={};return document.cookie.split("; ").filter((function(e){return e})).forEach((function(t){var i=t.trim().split("=");i[0]&&(e[i[0]]=i[1])})),e}},{key:"policies",get:function(){try{return JSON.parse(this.get(this.policiesKey)||"{}")}catch(e){return{}}}},{key:"exists",value:function(e){return Object.prototype.hasOwnProperty.call(this.all,e)}},{key:"hasValue",value:function(e,t){return this.get(e)==t}},{key:"get",value:function(e){return this.exists(e)?decodeURIComponent(this.all[e]):null}},{key:"set",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i.maxAge,r=void 0===o?31536e3:o,n=i.sameSite,c=void 0===n?"Lax":n,s=i.domain,a=void 0===s?this.domain:s,l=i.path,u=void 0===l?this.path:l,h=i.secure,f=void 0===h?this.secure:h;if(e){var p="".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t),";").concat(a?" domain=".concat(a,"; "):""," samesite=").concat(c,"; path=").concat(u,"; max-age=").concat(r).concat(f?"; secure":"");document.cookie=p,this.events.trigger("setCookie",{key:e,value:t,maxAge:r,path:u,sameSite:c,domain:a,secure:f,cookie:p})}}},{key:"delete",value:function(e){var t={maxAge:-1,path:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",domain:(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||void 0};this.set(e,"",t),this.events.trigger("deleteCookie",n({key:e},t))}},{key:"deleteAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Object.keys(this.all).forEach((function(o){e.delete(o,t,i)})),this.events.trigger("deleteAllCookies",{path:t,domain:i})}},{key:"acceptPolicy",value:function(e){this.setPolicy(e,!0),this.events.trigger("acceptPolicy",e),this.events.trigger("changePolicy",u({},e,!0))}},{key:"rejectPolicy",value:function(e){this.setPolicy(e,!1),this.events.trigger("rejectPolicy",e),this.events.trigger("changePolicy",u({},e,!1))}},{key:"setPolicy",value:function(e,t){"essential"!==e&&(this.savePolicies(n(n({},this.policies),{},u(u({},e,t),"essential",!0))),this.events.trigger("changePolicy",u({},e,t)))}},{key:"acceptAllPolicies",value:function(){var e=Object.fromEntries(Object.keys(this.policies).map((function(e){return[e.toLowerCase(),!0]})));this.savePolicies(e),this.events.trigger("acceptAllPolicies"),this.events.trigger("changePolicy",e)}},{key:"rejectAllPolicies",value:function(){var e=n(n({},Object.fromEntries(Object.keys(this.policies).map((function(e){return[e.toLowerCase(),!1]})))),{},{essential:!0});this.savePolicies(e),this.events.trigger("rejectAllPolicies"),this.events.trigger("changePolicy",e)}},{key:"savePolicies",value:function(e){this.set(this.policiesKey,JSON.stringify(e))}},{key:"isPolicyAccepted",value:function(e){return Object.prototype.hasOwnProperty.call(this.policies,e)?!0===this.policies[e]:null}},{key:"on",value:function(e,t){this.events.on(e,t)}}]),e}()}},t={};function i(o){var r=t[o];if(void 0!==r)return r.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,i),n.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{CookieBanner:()=>n});var e=i(774);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,i){for(var o=0;o<i.length;o++){var r=i[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(void 0,n=function(e,i){if("object"!==t(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var r=o.call(e,"string");if("object"!==t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===t(n)?n:String(n)),r)}var n}var n=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.$module=e,this.$acceptButton=e&&e.querySelector('[value="accept"]'),this.$rejectButton=e&&e.querySelector('[value="reject"]'),this.$prompt=e&&e.querySelector(".tna-cookie-banner__message--prompt"),this.$acceptedMessage=e&&e.querySelector(".tna-cookie-banner__message--accepted"),this.$rejectedMessage=e&&e.querySelector(".tna-cookie-banner__message--rejected"),this.$closeButtons=e&&e.querySelectorAll('[value="close"]')}var i,o;return i=t,(o=[{key:"init",value:function(){var t,i=this;if(this.$module&&this.$acceptButton&&this.$rejectButton&&this.$prompt&&this.$acceptedMessage&&this.$rejectedMessage&&this.$closeButtons){var o=this.$module.getAttribute("data-policies")||"",r=this.$module.getAttribute("data-domain")||void 0,n=this.$module.getAttribute("data-path")||void 0,c=this.$module.getAttribute("data-secure")||void 0,s=this.$module.getAttribute("data-policies-key")||void 0;this.cookies=new((null===(t=window.TNAFrontend)||void 0===t?void 0:t.Cookies)||e.Z)(o.split(",").filter((function(e){return e})).map((function(e){return e.trim()})),{domain:r,path:n,secure:c,policiesKey:s}),this.cookiePreferencesSet=this.$module.getAttribute("data-preferenceskey")||"cookie_preferences_set",this.cookies.hasValue(this.cookiePreferencesSet,"true")||(this.$module.removeAttribute("hidden"),this.$acceptButton.addEventListener("click",(function(){return i.accept()})),this.$rejectButton.addEventListener("click",(function(){return i.reject()})))}}},{key:"accept",value:function(){this.$prompt.setAttribute("hidden",!0),this.complete(),this.$acceptedMessage.removeAttribute("hidden"),this.$acceptedMessage.focus(),this.$acceptedMessage.setAttribute("tabindex","-1"),this.cookies.acceptAllPolicies()}},{key:"reject",value:function(){this.$prompt.setAttribute("hidden",!0),this.complete(),this.$rejectedMessage.removeAttribute("hidden"),this.$rejectedMessage.focus(),this.$rejectedMessage.setAttribute("tabindex","-1"),this.cookies.rejectAllPolicies()}},{key:"complete",value:function(){var e=this;this.cookies.set(this.cookiePreferencesSet,!0),this.$closeButtons.forEach((function(t){t.addEventListener("click",(function(){return e.close()}))}))}},{key:"close",value:function(){this.$module.setAttribute("hidden",!0)}}])&&r(i.prototype,o),Object.defineProperty(i,"prototype",{writable:!1}),t}()})(),o})()));
|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AQmB,aAAa,UAAU,EACtC,M,oEAACpB,CAAA,CAvFsB,E","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 ","/**\n * Class to handle cookies.\n * @class Cookies\n * @constructor\n * @public\n */\nexport default class Cookies {\n /** @protected */\n #policies = {};\n\n /**\n * Create a cookie handler.\n * @param {string[]} [policies=usage,settings] - The cookie policies to manage.\n * @param {string} [cookiesPolicyKey=cookies_policy] - The name of the cookie.\n */\n constructor(\n policies = [\"usage\", \"settings\"],\n cookiesPolicyKey = \"cookies_policy\",\n ) {\n this.cookiesPolicyKey = cookiesPolicyKey;\n policies.forEach((policy) => {\n this.#policies[policy.toLowerCase()] = false;\n });\n this.#policies.essential = true;\n }\n\n get policies() {\n return this.exists(this.cookiesPolicyKey)\n ? (this.#policies = {\n ...this.#policies,\n ...this.allPolicies,\n })\n : this.#policies;\n }\n\n set policies(newPolicyValues) {\n this.#policies = newPolicyValues;\n }\n\n /** @protected */\n #deserialise(cookieString) {\n const deserialised = {};\n cookieString.split(\";\").forEach((cookie) => {\n const parts = cookie.trim().split(\"=\");\n deserialised[parts[0]] = parts[1];\n });\n return deserialised;\n }\n\n get all() {\n return this.#deserialise(document.cookie);\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.prototype.hasOwnProperty.call(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=31536000] - 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 */\n set(key, value, options = {}) {\n const {\n maxAge = 60 * 60 * 24 * 365,\n path = \"/\",\n sameSite = \"Lax\",\n } = options;\n document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(\n value,\n )}; SameSite=${sameSite}; path=${path}; max-age=${maxAge}; Secure`;\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 = \"/\") {\n this.set(key, \"\", 0, path);\n }\n\n get allPolicies() {\n return JSON.parse(this.get(this.cookiesPolicyKey) || \"{}\");\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.savePolicies();\n }\n\n /**\n * Reject a policy.\n * @param {string} policy - The name of the policy.\n */\n rejectPolicy(policy) {\n if (policy === \"essential\") {\n return;\n }\n this.#setPolicy(policy, false);\n this.savePolicies();\n }\n\n /** @protected */\n #setPolicy(policy, accepted) {\n this.policies = {\n ...this.policies,\n [policy]: accepted,\n essential: true,\n };\n }\n\n /**\n * Commit the policy preferences to the browser.\n */\n savePolicies() {\n this.set(this.cookiesPolicyKey, JSON.stringify(this.policies));\n }\n\n /**\n * Accept all the cookie policies.\n */\n acceptAllPolicies() {\n Object.keys(this.policies).forEach((policy) =>\n this.#setPolicy(policy, true),\n );\n this.savePolicies();\n }\n\n /**\n * Reject all the cookie policies.\n */\n rejectAllPolicies() {\n Object.keys(this.policies).forEach((policy) =>\n this.#setPolicy(policy, false),\n );\n this.savePolicies();\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.prototype.hasOwnProperty.call(this.policies, policy)\n ? this.policies[policy] === true\n : null;\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 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\n init() {\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 const policies = this.$module.getAttribute(\"data-policies\");\n if (!policies) {\n return;\n }\n this.cookies = new Cookies(\n policies.split(\",\").map((policy) => policy.trim()),\n );\n\n this.loadScriptsOnAccept = this.$module.getAttribute(\"data-acceptscripts\");\n\n this.cookiePreferencesSet =\n this.$module.getAttribute(\"data-preferenceskey\") ||\n \"cookies_preferences_set\";\n const cookiePreferencesSet = this.cookies.hasValue(\n this.cookiePreferencesSet,\n \"true\",\n );\n\n if (!cookiePreferencesSet) {\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\", true);\n this.complete();\n this.$acceptedMessage.removeAttribute(\"hidden\");\n this.$acceptedMessage.focus();\n this.$acceptedMessage.setAttribute(\"tabindex\", \"-1\");\n this.cookies.acceptAllPolicies();\n if (this.loadScriptsOnAccept) {\n this.loadScriptsOnAccept.split(\",\").forEach((script) => {\n const $script = document.createElement(\"script\");\n $script.src = script;\n document.head.appendChild($script);\n });\n }\n }\n\n reject() {\n this.$prompt.setAttribute(\"hidden\", true);\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.cookiePreferencesSet, true);\n this.$closeButtons.forEach(($closeButton) => {\n $closeButton.addEventListener(\"click\", () => this.close());\n });\n }\n\n close() {\n this.$module.setAttribute(\"hidden\", true);\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","Cookies","_this","policies","arguments","length","undefined","cookiesPolicyKey","_classCallCheck","_classPrivateMethodInitSpec","_setPolicy","_deserialise","writable","value","_policies","this","forEach","policy","_classPrivateFieldGet","toLowerCase","essential","key","get","exists","_classPrivateFieldSet","_objectSpread","allPolicies","set","newPolicyValues","_classPrivateMethodGet","_deserialise2","call","document","cookie","Object","prototype","hasOwnProperty","all","decodeURIComponent","options","_options$maxAge","maxAge","_options$path","path","_options$sameSite","sameSite","concat","encodeURIComponent","JSON","parse","_setPolicy2","savePolicies","stringify","_this2","keys","_this3","cookieString","deserialised","split","parts","trim","accepted","_objectSpread2","_defineProperty","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","d","definition","o","defineProperty","enumerable","obj","prop","r","Symbol","toStringTag","CookieBanner","$module","$acceptButton","querySelector","$rejectButton","$prompt","$acceptedMessage","$rejectedMessage","$closeButtons","querySelectorAll","getAttribute","cookies","map","loadScriptsOnAccept","cookiePreferencesSet","hasValue","removeAttribute","addEventListener","accept","reject","setAttribute","complete","focus","acceptAllPolicies","script","$script","createElement","src","head","appendChild","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,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,MAAM,I,2tDCTF,IAAMC,EAAkB,WAG7B,SAAAA,IACE,GADYC,EAAA,KAAAD,GAAAE,EAAA,cAFL,C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EAAKgG,QAAQ,IAChE5G,KAAK6F,cAAcc,iBAAiB,SAAS,kBAAM/F,EAAKiG,QAAQ,IAlClE,CAoCF,GAAC,CAAA3G,IAAA,SAAAC,MAED,WACEH,KAAK8F,QAAQgB,aAAa,UAAU,GACpC9G,KAAK+G,WACL/G,KAAK+F,iBAAiBW,gBAAgB,UACtC1G,KAAK+F,iBAAiBiB,QACtBhH,KAAK+F,iBAAiBe,aAAa,WAAY,MAC/C9G,KAAKqG,QAAQY,mBACf,GAAC,CAAA/G,IAAA,SAAAC,MAED,WACEH,KAAK8F,QAAQgB,aAAa,UAAU,GACpC9G,KAAK+G,WACL/G,KAAKgG,iBAAiBU,gBAAgB,UACtC1G,KAAKgG,iBAAiBgB,QACtBhH,KAAKgG,iBAAiBc,aAAa,WAAY,MAC/C9G,KAAKqG,QAAQa,mBACf,GAAC,CAAAhH,IAAA,WAAAC,MAED,WAAW,IAAA+D,EAAA,KACTlE,KAAKqG,QAAQpC,IAAIjE,KAAKwG,sBAAsB,GAC5CxG,KAAKiG,cAAchF,SAAQ,SAACkG,GAC1BA,EAAaR,iBAAiB,SAAS,kBAAMzC,EAAKkD,OAAO,GAC3D,GACF,GAAC,CAAAlH,IAAA,QAAAC,MAED,WACEH,KAAK0F,QAAQoB,aAAa,UAAU,EACtC,M,oEAACrB,CAAA,CA1FsB,E","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 ","export class CookieEventHandler {\n events = {};\n\n constructor() {\n if (CookieEventHandler._instance) {\n return CookieEventHandler._instance;\n }\n CookieEventHandler._instance = 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.prototype.hasOwnProperty.call(this.events, event)) {\n this.events[event] = [];\n }\n this.events[event] = [...this.events[event], callback];\n }\n\n /** @protected */\n trigger(event, data = {}) {\n if (Object.prototype.hasOwnProperty.call(this.events, event)) {\n this.events[event].forEach((eventToTrigger) =>\n eventToTrigger.call(this, data),\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 extraPolicies = [];\n /** @protected */\n domain = \"\";\n /** @protected */\n path = \"\";\n /** @protected */\n secure = true;\n /** @protected */\n policiesKey = \"\";\n\n /**\n * Create a cookie handler.\n * @param {string[]} [extraPolicies=[]] - The extra cookie policies to manage in addition to essential, settings and usage.\n * @param {string} [options.domain=\"\"] - The domain to register the cookie with.\n * @param {string} [options.path=\"\"] - The domain to register the cookie with.\n * @param {string} [options.secure=true] - Only set cookie in HTTPS environments.\n * @param {string} [options.policiesKey=cookies_policy] - The name of the cookie.\n */\n constructor(extraPolicies = [], options = {}) {\n const {\n domain = \"\",\n path = \"/\",\n secure = true,\n policiesKey = \"cookies_policy\",\n } = options;\n this.extraPolicies = extraPolicies;\n this.domain = domain;\n this.path = path;\n this.secure = secure;\n this.policiesKey = policiesKey;\n this.events = new CookieEventHandler();\n this.init();\n }\n\n /** @protected */\n init() {\n this.savePolicies({\n ...Object.fromEntries(\n this.extraPolicies.map((k) => [k.toLowerCase(), false]),\n ),\n usage: false,\n settings: false,\n ...this.policies,\n essential: true,\n });\n }\n\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 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.prototype.hasOwnProperty.call(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=31536000] - 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.domain] - The domain to register the cookie with.\n * @param {string} [options.path=this.path] - The path to register the cookie with.\n * @param {string} [options.secure=this.secure] - Only set cookie in HTTPS environments.\n */\n set(key, value, options = {}) {\n const {\n maxAge = 60 * 60 * 24 * 365,\n sameSite = \"Lax\",\n domain = this.domain,\n path = this.path,\n secure = this.secure,\n } = options;\n if (!key) {\n return;\n }\n const cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)};${\n domain ? ` domain=${domain}; ` : \"\"\n } samesite=${sameSite}; path=${path}; 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 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.prototype.hasOwnProperty.call(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","// 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 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\n init() {\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 const policies = this.$module.getAttribute(\"data-policies\") || \"\";\n const domain = this.$module.getAttribute(\"data-domain\") || undefined;\n const path = this.$module.getAttribute(\"data-path\") || undefined;\n const secure = this.$module.getAttribute(\"data-secure\") || undefined;\n const policiesKey =\n this.$module.getAttribute(\"data-policies-key\") || undefined;\n\n this.cookies = new (window.TNAFrontend?.Cookies || Cookies)(\n policies\n .split(\",\")\n .filter((x) => x)\n .map((policy) => policy.trim()),\n {\n domain,\n path,\n secure,\n policiesKey,\n },\n );\n\n this.cookiePreferencesSet =\n this.$module.getAttribute(\"data-preferenceskey\") ||\n \"cookie_preferences_set\";\n const cookiePreferencesSet = this.cookies.hasValue(\n this.cookiePreferencesSet,\n \"true\",\n );\n\n if (!cookiePreferencesSet) {\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\", true);\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\", true);\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.cookiePreferencesSet, true);\n this.$closeButtons.forEach(($closeButton) => {\n $closeButton.addEventListener(\"click\", () => this.close());\n });\n }\n\n close() {\n this.$module.setAttribute(\"hidden\", true);\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","CookieEventHandler","_classCallCheck","_defineProperty","_instance","this","_createClass","key","value","event","callback","Object","prototype","hasOwnProperty","call","events","concat","_this","data","arguments","length","undefined","forEach","eventToTrigger","Cookies","extraPolicies","options","_options$domain","domain","_options$path","path","_options$secure","secure","_options$policiesKey","policiesKey","init","savePolicies","_objectSpread","fromEntries","map","k","toLowerCase","usage","settings","policies","essential","get","deserialised","document","cookie","split","filter","x","parts","trim","JSON","parse","e","all","exists","decodeURIComponent","_options$maxAge","maxAge","_options$sameSite","sameSite","_options$domain2","_options$path2","_options$secure2","encodeURIComponent","trigger","set","_this2","keys","policy","setPolicy","accepted","allPolicies","stringify","on","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","d","definition","o","defineProperty","enumerable","obj","prop","r","Symbol","toStringTag","CookieBanner","$module","$acceptButton","querySelector","$rejectButton","$prompt","$acceptedMessage","$rejectedMessage","$closeButtons","querySelectorAll","_window$TNAFrontend","getAttribute","cookies","window","TNAFrontend","cookiePreferencesSet","hasValue","removeAttribute","addEventListener","accept","reject","setAttribute","complete","focus","acceptAllPolicies","rejectAllPolicies","$closeButton","close"],"sourceRoot":""}
|
@@ -27,19 +27,29 @@ export class CookieBanner {
|
|
27
27
|
return;
|
28
28
|
}
|
29
29
|
|
30
|
-
const policies = this.$module.getAttribute("data-policies");
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
);
|
30
|
+
const policies = this.$module.getAttribute("data-policies") || "";
|
31
|
+
const domain = this.$module.getAttribute("data-domain") || undefined;
|
32
|
+
const path = this.$module.getAttribute("data-path") || undefined;
|
33
|
+
const secure = this.$module.getAttribute("data-secure") || undefined;
|
34
|
+
const policiesKey =
|
35
|
+
this.$module.getAttribute("data-policies-key") || undefined;
|
37
36
|
|
38
|
-
this.
|
37
|
+
this.cookies = new (window.TNAFrontend?.Cookies || Cookies)(
|
38
|
+
policies
|
39
|
+
.split(",")
|
40
|
+
.filter((x) => x)
|
41
|
+
.map((policy) => policy.trim()),
|
42
|
+
{
|
43
|
+
domain,
|
44
|
+
path,
|
45
|
+
secure,
|
46
|
+
policiesKey,
|
47
|
+
},
|
48
|
+
);
|
39
49
|
|
40
50
|
this.cookiePreferencesSet =
|
41
51
|
this.$module.getAttribute("data-preferenceskey") ||
|
42
|
-
"
|
52
|
+
"cookie_preferences_set";
|
43
53
|
const cookiePreferencesSet = this.cookies.hasValue(
|
44
54
|
this.cookiePreferencesSet,
|
45
55
|
"true",
|
@@ -60,13 +70,6 @@ export class CookieBanner {
|
|
60
70
|
this.$acceptedMessage.focus();
|
61
71
|
this.$acceptedMessage.setAttribute("tabindex", "-1");
|
62
72
|
this.cookies.acceptAllPolicies();
|
63
|
-
if (this.loadScriptsOnAccept) {
|
64
|
-
this.loadScriptsOnAccept.split(",").forEach((script) => {
|
65
|
-
const $script = document.createElement("script");
|
66
|
-
$script.src = script;
|
67
|
-
document.head.appendChild($script);
|
68
|
-
});
|
69
|
-
}
|
70
73
|
}
|
71
74
|
|
72
75
|
reject() {
|
@@ -5,10 +5,14 @@ import { within, userEvent } from "@storybook/testing-library";
|
|
5
5
|
import Cookies from "../../lib/cookies.mjs";
|
6
6
|
|
7
7
|
const argTypes = {
|
8
|
+
serviceName: { control: "text" },
|
8
9
|
cookiesUrl: { control: "text" },
|
9
10
|
policies: { control: "text" },
|
10
|
-
|
11
|
-
|
11
|
+
policiesKey: { control: "text" },
|
12
|
+
preferencesSetKey: { control: "text" },
|
13
|
+
cookiesDomain: { control: "text" },
|
14
|
+
cookiesPath: { control: "text" },
|
15
|
+
allowInsecure: { control: "boolean" },
|
12
16
|
classes: { control: "text" },
|
13
17
|
attributes: { control: "object" },
|
14
18
|
};
|
@@ -25,19 +29,27 @@ export default {
|
|
25
29
|
};
|
26
30
|
|
27
31
|
const Template = ({
|
32
|
+
serviceName,
|
28
33
|
cookiesUrl,
|
29
34
|
policies,
|
30
|
-
|
31
|
-
|
35
|
+
policiesKey,
|
36
|
+
preferencesSetKey,
|
37
|
+
cookiesDomain,
|
38
|
+
cookiesPath,
|
39
|
+
allowInsecure,
|
32
40
|
classes,
|
33
41
|
attributes,
|
34
42
|
}) =>
|
35
43
|
CookieBanner({
|
36
44
|
params: {
|
45
|
+
serviceName,
|
37
46
|
cookiesUrl,
|
38
47
|
policies,
|
39
|
-
|
40
|
-
|
48
|
+
policiesKey,
|
49
|
+
preferencesSetKey,
|
50
|
+
cookiesDomain,
|
51
|
+
cookiesPath,
|
52
|
+
allowInsecure,
|
41
53
|
classes,
|
42
54
|
attributes,
|
43
55
|
},
|
@@ -49,23 +61,20 @@ Standard.args = {
|
|
49
61
|
classes: "tna-cookie-banner--demo",
|
50
62
|
};
|
51
63
|
|
52
|
-
const deleteAllCookies = (cookies) => {
|
53
|
-
Object.keys(cookies.all).forEach((cookie) => cookies.delete(cookie));
|
54
|
-
};
|
55
|
-
|
56
64
|
export const Accept = Template.bind({});
|
57
65
|
Accept.args = {
|
66
|
+
serviceName: "My service",
|
58
67
|
cookiesUrl: "#",
|
68
|
+
allowInsecure: true,
|
59
69
|
classes: "tna-cookie-banner--demo",
|
60
70
|
};
|
61
71
|
Accept.play = async ({ canvasElement }) => {
|
62
|
-
const cookies = new Cookies();
|
63
|
-
deleteAllCookies(cookies);
|
64
|
-
|
72
|
+
const cookies = new window.TNAFrontend.Cookies();
|
65
73
|
await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
|
66
74
|
await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
|
67
75
|
await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
|
68
76
|
await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
|
77
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(false);
|
69
78
|
|
70
79
|
const canvas = within(canvasElement);
|
71
80
|
const acceptButton = canvas.getByText("Accept cookies");
|
@@ -78,6 +87,11 @@ Accept.play = async ({ canvasElement }) => {
|
|
78
87
|
await expect(cookies.isPolicyAccepted("usage")).toEqual(true);
|
79
88
|
await expect(cookies.isPolicyAccepted("settings")).toEqual(true);
|
80
89
|
await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
|
90
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
|
91
|
+
await expect(cookies.get("cookie_preferences_set")).toEqual("true");
|
92
|
+
await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
|
93
|
+
true,
|
94
|
+
);
|
81
95
|
await expect(acceptButton).not.toBeVisible();
|
82
96
|
await expect(rejectButton).not.toBeVisible();
|
83
97
|
|
@@ -86,23 +100,21 @@ Accept.play = async ({ canvasElement }) => {
|
|
86
100
|
// await userEvent.click(closeButton);
|
87
101
|
|
88
102
|
// await expect(closeButton).not.toBeVisible();
|
89
|
-
|
90
|
-
deleteAllCookies(cookies);
|
91
103
|
};
|
92
104
|
|
93
105
|
export const Reject = Template.bind({});
|
94
106
|
Reject.args = {
|
107
|
+
serviceName: "My service",
|
95
108
|
cookiesUrl: "#",
|
96
109
|
classes: "tna-cookie-banner--demo",
|
97
110
|
};
|
98
111
|
Reject.play = async ({ canvasElement }) => {
|
99
112
|
const cookies = new Cookies();
|
100
|
-
deleteAllCookies(cookies);
|
101
|
-
|
102
113
|
await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
|
103
114
|
await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
|
104
115
|
await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
|
105
116
|
await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
|
117
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(false);
|
106
118
|
|
107
119
|
const canvas = within(canvasElement);
|
108
120
|
const acceptButton = canvas.getByText("Accept cookies");
|
@@ -115,63 +127,112 @@ Reject.play = async ({ canvasElement }) => {
|
|
115
127
|
await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
|
116
128
|
await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
|
117
129
|
await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
|
130
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
|
131
|
+
await expect(cookies.get("cookie_preferences_set")).toEqual("true");
|
132
|
+
await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
|
133
|
+
true,
|
134
|
+
);
|
118
135
|
await expect(acceptButton).not.toBeVisible();
|
119
136
|
await expect(rejectButton).not.toBeVisible();
|
120
137
|
|
121
|
-
|
138
|
+
await cookies.deleteAll();
|
122
139
|
};
|
123
140
|
|
124
141
|
export const CustomPolicies = Template.bind({});
|
125
142
|
CustomPolicies.args = {
|
143
|
+
serviceName: "My service",
|
126
144
|
cookiesUrl: "#",
|
127
145
|
policies: "custom",
|
128
146
|
classes: "tna-cookie-banner--demo",
|
129
147
|
};
|
148
|
+
CustomPolicies.parameters = {
|
149
|
+
chromatic: { disableSnapshot: true },
|
150
|
+
};
|
130
151
|
CustomPolicies.play = async ({ args, canvasElement }) => {
|
131
152
|
const cookies = new Cookies(args.policies.split(","));
|
132
|
-
deleteAllCookies(cookies);
|
133
|
-
|
134
153
|
await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
|
135
|
-
await expect(cookies.isPolicyAccepted("usage")).toEqual(
|
136
|
-
await expect(cookies.isPolicyAccepted("settings")).toEqual(
|
154
|
+
await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
|
155
|
+
await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
|
137
156
|
await expect(cookies.isPolicyAccepted("custom")).toEqual(false);
|
157
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(false);
|
138
158
|
|
139
159
|
const canvas = within(canvasElement);
|
140
160
|
const acceptButton = canvas.getByText("Accept cookies");
|
141
161
|
await userEvent.click(acceptButton);
|
142
162
|
|
143
163
|
await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
|
144
|
-
await expect(cookies.isPolicyAccepted("usage")).toEqual(
|
145
|
-
await expect(cookies.isPolicyAccepted("settings")).toEqual(
|
164
|
+
await expect(cookies.isPolicyAccepted("usage")).toEqual(true);
|
165
|
+
await expect(cookies.isPolicyAccepted("settings")).toEqual(true);
|
146
166
|
await expect(cookies.isPolicyAccepted("custom")).toEqual(true);
|
167
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
|
168
|
+
await expect(cookies.get("cookie_preferences_set")).toEqual("true");
|
169
|
+
await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
|
170
|
+
true,
|
171
|
+
);
|
147
172
|
|
148
|
-
|
173
|
+
await cookies.deleteAll();
|
149
174
|
};
|
150
175
|
|
151
|
-
export const
|
152
|
-
|
176
|
+
export const Existing = Template.bind({});
|
177
|
+
Existing.args = {
|
178
|
+
serviceName: "My service",
|
153
179
|
cookiesUrl: "#",
|
154
|
-
|
180
|
+
allowInsecure: true,
|
155
181
|
classes: "tna-cookie-banner--demo",
|
156
182
|
};
|
157
|
-
|
183
|
+
Existing.decorators = [
|
184
|
+
(Story) => {
|
185
|
+
const cookies = new Cookies();
|
186
|
+
cookies.set("cookie_preferences_set", true);
|
187
|
+
return Story();
|
188
|
+
},
|
189
|
+
];
|
190
|
+
Existing.play = async ({ canvasElement }) => {
|
158
191
|
const cookies = new Cookies();
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
192
|
+
await expect(cookies.isPolicyAccepted("essential")).toEqual(true);
|
193
|
+
await expect(cookies.isPolicyAccepted("usage")).toEqual(false);
|
194
|
+
await expect(cookies.isPolicyAccepted("settings")).toEqual(false);
|
195
|
+
await expect(cookies.isPolicyAccepted("unknown")).toEqual(null);
|
196
|
+
await expect(cookies.exists("cookie_preferences_set")).toEqual(true);
|
197
|
+
await expect(cookies.get("cookie_preferences_set")).toEqual("true");
|
198
|
+
await expect(cookies.hasValue("cookie_preferences_set", "true")).toEqual(
|
199
|
+
true,
|
163
200
|
);
|
164
|
-
await expect(noScript).toEqual(null);
|
165
201
|
|
166
202
|
const canvas = within(canvasElement);
|
167
203
|
const acceptButton = canvas.getByText("Accept cookies");
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
`script[src="${args.loadScriptsOnAccept}"]`,
|
172
|
-
);
|
173
|
-
await expect(script).toBeTruthy();
|
204
|
+
const rejectButton = canvas.getByText("Reject cookies");
|
205
|
+
await expect(acceptButton).not.toBeVisible();
|
206
|
+
await expect(rejectButton).not.toBeVisible();
|
174
207
|
|
175
|
-
|
176
|
-
script.remove();
|
208
|
+
await cookies.deleteAll();
|
177
209
|
};
|
210
|
+
|
211
|
+
// export const EventHandling = Template.bind({});
|
212
|
+
// EventHandling.args = {
|
213
|
+
// serviceName: "My service",
|
214
|
+
// cookiesUrl: "#",
|
215
|
+
// policies: "custom",
|
216
|
+
// classes: "tna-cookie-banner--demo",
|
217
|
+
// };
|
218
|
+
// EventHandling.play = async ({ args, canvasElement }) => {
|
219
|
+
// deleteAllCookies();
|
220
|
+
|
221
|
+
// const cookies = new Cookies();
|
222
|
+
|
223
|
+
// const onChangePolicy = jest.fn(data => {
|
224
|
+
// console.log(data)
|
225
|
+
// })
|
226
|
+
// cookies.on("changePolicy", onChangePolicy)
|
227
|
+
|
228
|
+
// const canvas = within(canvasElement);
|
229
|
+
// const acceptButton = canvas.getByText("Accept cookies");
|
230
|
+
// await userEvent.click(acceptButton);
|
231
|
+
|
232
|
+
// await expect(onChangePolicy.mock).toHaveBeenCalledTimes(1);
|
233
|
+
// await expect(onChangePolicy.mock.calls).toHaveLength(1);
|
234
|
+
// await expect(onChangePolicy.mock.results[0].value).toHaveProperty("custom");
|
235
|
+
// await expect(onChangePolicy.mock.results[0].value.custom).toEqual(true);
|
236
|
+
|
237
|
+
// deleteAllCookies();
|
238
|
+
// };
|