@nationalarchives/frontend 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nationalarchives/all+analytics.js +1 -1
- package/nationalarchives/all+analytics.js.map +1 -1
- package/nationalarchives/all+analytics.mjs +2 -2
- package/nationalarchives/all.js +1 -1
- package/nationalarchives/all.js.map +1 -1
- package/nationalarchives/all.mjs +7 -5
- package/nationalarchives/components/date-input/date-input.js +1 -1
- package/nationalarchives/components/date-input/date-input.js.map +1 -1
- package/nationalarchives/components/date-input/date-input.mjs +42 -15
- package/nationalarchives/components/date-input/fixtures.json +15 -3
- package/nationalarchives/components/date-input/macro-options.json +5 -5
- package/nationalarchives/components/date-input/template.njk +4 -4
- package/nationalarchives/components/error-summary/error-summary.js +1 -1
- package/nationalarchives/components/error-summary/error-summary.js.map +1 -1
- package/nationalarchives/components/error-summary/error-summary.mjs +108 -0
- package/nationalarchives/components/text-input/fixtures.json +4 -4
- package/nationalarchives/components/textarea/fixtures.json +2 -2
- package/package.json +2 -2
@@ -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={169:(e,t,n)=>{function i(e){return i="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},i(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e)||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.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,p(i.key),i)}}function l(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}n.d(t,{A:()=>f}),window.TNAFrontendCookies=window.TNAFrontendCookies||null,window.TNAFrontendCookieEvents=window.TNAFrontendCookieEvents||null;var d=function(){return l((function e(){if(u(this,e),h(this,"events",{}),h(this,"oneTimeEvents",{}),window.TNAFrontendCookieEvents)return window.TNAFrontendCookieEvents;window.TNAFrontendCookieEvents=this}),[{key:"on",value:function(e,t){Object.hasOwn(this.events,e)||(this.events[e]=[]),this.events[e]=[].concat(s(this.events[e]),[t])}},{key:"once",value:function(e,t){Object.hasOwn(this.oneTimeEvents,e)||(this.oneTimeEvents[e]=[]),this.oneTimeEvents[e]=[].concat(s(this.oneTimeEvents[e]),[t])}},{key:"trigger",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object.hasOwn(this.events,e)&&this.events[e].forEach((function(e){return e.call(t,n)})),Object.hasOwn(this.oneTimeEvents,e))for(var i=this.oneTimeEvents[e].length-1;i>=0;i--)this.oneTimeEvents[e][i].call(this,n),this.oneTimeEvents[e].splice(i,1)}}])}(),y=["usage","settings","marketing","essential"],f=function(){return l((function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),h(this,"defaultDomain",""),h(this,"defaultPath",""),h(this,"secure",!0),h(this,"policiesKey",""),h(this,"events",null),h(this,"defaultAge",null),h(this,"completePoliciesOnInit",!1);var i=n.defaultDomain,o=n.defaultPath,r=n.secure,s=n.policiesKey,a=n.newInstance,c=void 0!==a&&a,l=n.defaultAge,p=n.noInit,f=void 0!==p&&p;if(!c&&window.TNAFrontendCookies)return window.TNAFrontendCookies;this.defaultDomain=void 0===i?document.documentElement.dataset.tnaCookiesDomain||"":i,this.defaultPath=void 0===o?document.documentElement.dataset.tnaCookiesPath||"/":o,this.secure=void 0===r?"true"!==document.documentElement.dataset.tnaCookiesInsecure:r,this.policiesKey=void 0===s?document.documentElement.dataset.tnaCookiesPoliciesKey||"cookies_policy":s,this.defaultAge=void 0===l?parseInt(document.documentElement.dataset.tnaCookiesDefaultAge)||31536e3:l,this.events=new d,this.completePoliciesOnInit=Object.keys(this.policies).length===y.length&&y.every((function(e){return Object.keys(t.policies).includes(e)&&"boolean"==typeof t.policies[e]})),this.completePoliciesOnInit||f||this.init(),window.TNAFrontendCookies=this}),[{key:"init",value:function(){var e=this.policies,t=Object.fromEntries(Object.keys(e).filter((function(e){return y.includes(e)})).map((function(t){return[t,e[t]]})));this.savePolicies(r(r({usage:!1,settings:!1,marketing:!1},t),{},{essential:!0}))}},{key:"destroyInstance",value:function(){window.TNAFrontendCookies=null}},{key:"all",get:function(){var e={};return document.cookie.split("; ").filter((function(e){return e})).forEach((function(t){var n=t.trim().split("=");n[0]&&(e[n[0]]=n[1])})),e}},{key:"policies",get:function(){try{return JSON.parse(this.get(this.policiesKey)||"{}")}catch(e){return{}}}},{key:"exists",value:function(e){return Object.hasOwn(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 n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.maxAge,o=void 0===i?this.defaultAge:i,r=n.sameSite,s=void 0===r?"Lax":r,a=n.domain,u=void 0===a?this.defaultDomain:a,c=n.path,l=void 0===c?this.defaultPath:c,h=n.secure,p=void 0===h?this.secure:h,d=n.session,y=void 0!==d&&d;if(e){var f="".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t),";").concat(u?" domain=".concat(u,"; "):""," samesite=").concat(s,"; path=").concat(l).concat(y?"":"; max-age=".concat(o)).concat(p?"; secure":"");document.cookie=f,this.events.trigger("setCookie",{key:e,value:t,maxAge:o,path:l,sameSite:s,domain:u,secure:p,session:y,cookie:f})}}},{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",r({key:e},t))}},{key:"deleteAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Object.keys(this.all).forEach((function(i){e.delete(i,t,n)})),this.events.trigger("deleteAllCookies",{path:t,domain:n})}},{key:"acceptPolicy",value:function(e){this.setPolicy(e,!0),this.events.trigger("acceptPolicy",e),this.events.trigger("changePolicy",h({},e,!0))}},{key:"rejectPolicy",value:function(e){this.setPolicy(e,!1),this.events.trigger("rejectPolicy",e),this.events.trigger("changePolicy",h({},e,!1))}},{key:"setPolicy",value:function(e,t){"essential"!==e&&(this.savePolicies(r(r({},this.policies),{},h(h({},e,t),"essential",!0))),this.events.trigger("changePolicy",h({},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=r(r({},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.hasOwn(this.policies,e)?!0===this.policies[e]:null}},{key:"on",value:function(e,t){this.events.on(e,t)}},{key:"once",value:function(e,t){this.events.once(e,t)}}])}()}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{Cookies:()=>o.A,DateInput:()=>u});var o=n(169);function r(e){return r="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},r(e)}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,a(i.key),i)}}function a(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}var u=function(){return e=function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$dayWrapper=t&&t.querySelector(".tna-date-input__item--day"),this.$dayInput=this.$dayWrapper&&this.$dayWrapper.querySelector("input"),this.$monthWrapper=t&&t.querySelector(".tna-date-input__item--month"),this.$monthInput=this.$monthWrapper&&this.$monthWrapper.querySelector("input"),this.$yearWrapper=t&&t.querySelector(".tna-date-input__item--year"),this.$yearInput=this.$yearWrapper&&this.$yearWrapper.querySelector("input"),this.$module&&(this.update(),this.$yearInput&&(this.$yearInput.addEventListener("keyup",(function(){return n.update()})),this.$yearInput.addEventListener("change",(function(){return n.update()}))),this.$monthInput&&(this.$monthInput.addEventListener("keyup",(function(){return n.update()})),this.$monthInput.addEventListener("change",(function(){return n.update()}))),this.$dayInput&&(this.$dayInput.addEventListener("keyup",(function(){return n.update()})),this.$dayInput.addEventListener("change",(function(){return n.update()}))))},(t=[{key:"update",value:function(){this.isValidYear()?(this.showMonth(),this.isValidMonth()?this.showDay():this.hideDay()):(this.hideMonth(),this.hideDay())}},{key:"isValidYear",value:function(){if(!this.$yearInput)return!0;var e=parseInt(this.$yearInput.value.trim());return!isNaN(this.$yearInput.value)&&!isNaN(e)&&e>0}},{key:"isValidMonth",value:function(){if(!this.$monthInput)return!0;var e=parseInt(this.$monthInput.value.trim());return!isNaN(this.$monthInput.value)&&!isNaN(e)&&e>0&&e<=12}},{key:"showMonth",value:function(){this.$monthWrapper&&this.$monthWrapper.removeAttribute("hidden")}},{key:"hideMonth",value:function(){this.$monthWrapper&&this.$monthWrapper.setAttribute("hidden","")}},{key:"showDay",value:function(){this.$dayWrapper&&this.$dayWrapper.removeAttribute("hidden")}},{key:"hideDay",value:function(){this.$dayWrapper&&this.$dayWrapper.setAttribute("hidden","")}}])&&s(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();return i})()));
|
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={169:(e,t,n)=>{function i(e){return i="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},i(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e)||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.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,p(i.key),i)}}function l(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}n.d(t,{A:()=>f}),window.TNAFrontendCookies=window.TNAFrontendCookies||null,window.TNAFrontendCookieEvents=window.TNAFrontendCookieEvents||null;var d=function(){return l((function e(){if(u(this,e),h(this,"events",{}),h(this,"oneTimeEvents",{}),window.TNAFrontendCookieEvents)return window.TNAFrontendCookieEvents;window.TNAFrontendCookieEvents=this}),[{key:"on",value:function(e,t){Object.hasOwn(this.events,e)||(this.events[e]=[]),this.events[e]=[].concat(s(this.events[e]),[t])}},{key:"once",value:function(e,t){Object.hasOwn(this.oneTimeEvents,e)||(this.oneTimeEvents[e]=[]),this.oneTimeEvents[e]=[].concat(s(this.oneTimeEvents[e]),[t])}},{key:"trigger",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object.hasOwn(this.events,e)&&this.events[e].forEach((function(e){return e.call(t,n)})),Object.hasOwn(this.oneTimeEvents,e))for(var i=this.oneTimeEvents[e].length-1;i>=0;i--)this.oneTimeEvents[e][i].call(this,n),this.oneTimeEvents[e].splice(i,1)}}])}(),y=["usage","settings","marketing","essential"],f=function(){return l((function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,e),h(this,"defaultDomain",""),h(this,"defaultPath",""),h(this,"secure",!0),h(this,"policiesKey",""),h(this,"events",null),h(this,"defaultAge",null),h(this,"completePoliciesOnInit",!1);var i=n.defaultDomain,o=n.defaultPath,r=n.secure,s=n.policiesKey,a=n.newInstance,c=void 0!==a&&a,l=n.defaultAge,p=n.noInit,f=void 0!==p&&p;if(!c&&window.TNAFrontendCookies)return window.TNAFrontendCookies;this.defaultDomain=void 0===i?document.documentElement.dataset.tnaCookiesDomain||"":i,this.defaultPath=void 0===o?document.documentElement.dataset.tnaCookiesPath||"/":o,this.secure=void 0===r?"true"!==document.documentElement.dataset.tnaCookiesInsecure:r,this.policiesKey=void 0===s?document.documentElement.dataset.tnaCookiesPoliciesKey||"cookies_policy":s,this.defaultAge=void 0===l?parseInt(document.documentElement.dataset.tnaCookiesDefaultAge)||31536e3:l,this.events=new d,this.completePoliciesOnInit=Object.keys(this.policies).length===y.length&&y.every((function(e){return Object.keys(t.policies).includes(e)&&"boolean"==typeof t.policies[e]})),this.completePoliciesOnInit||f||this.init(),window.TNAFrontendCookies=this}),[{key:"init",value:function(){var e=this.policies,t=Object.fromEntries(Object.keys(e).filter((function(e){return y.includes(e)})).map((function(t){return[t,e[t]]})));this.savePolicies(r(r({usage:!1,settings:!1,marketing:!1},t),{},{essential:!0}))}},{key:"destroyInstance",value:function(){window.TNAFrontendCookies=null}},{key:"all",get:function(){var e={};return document.cookie.split("; ").filter((function(e){return e})).forEach((function(t){var n=t.trim().split("=");n[0]&&(e[n[0]]=n[1])})),e}},{key:"policies",get:function(){try{return JSON.parse(this.get(this.policiesKey)||"{}")}catch(e){return{}}}},{key:"exists",value:function(e){return Object.hasOwn(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 n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.maxAge,o=void 0===i?this.defaultAge:i,r=n.sameSite,s=void 0===r?"Lax":r,a=n.domain,u=void 0===a?this.defaultDomain:a,c=n.path,l=void 0===c?this.defaultPath:c,h=n.secure,p=void 0===h?this.secure:h,d=n.session,y=void 0!==d&&d;if(e){var f="".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t),";").concat(u?" domain=".concat(u,"; "):""," samesite=").concat(s,"; path=").concat(l).concat(y?"":"; max-age=".concat(o)).concat(p?"; secure":"");document.cookie=f,this.events.trigger("setCookie",{key:e,value:t,maxAge:o,path:l,sameSite:s,domain:u,secure:p,session:y,cookie:f})}}},{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",r({key:e},t))}},{key:"deleteAll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Object.keys(this.all).forEach((function(i){e.delete(i,t,n)})),this.events.trigger("deleteAllCookies",{path:t,domain:n})}},{key:"acceptPolicy",value:function(e){this.setPolicy(e,!0),this.events.trigger("acceptPolicy",e),this.events.trigger("changePolicy",h({},e,!0))}},{key:"rejectPolicy",value:function(e){this.setPolicy(e,!1),this.events.trigger("rejectPolicy",e),this.events.trigger("changePolicy",h({},e,!1))}},{key:"setPolicy",value:function(e,t){"essential"!==e&&(this.savePolicies(r(r({},this.policies),{},h(h({},e,t),"essential",!0))),this.events.trigger("changePolicy",h({},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=r(r({},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.hasOwn(this.policies,e)?!0===this.policies[e]:null}},{key:"on",value:function(e,t){this.events.on(e,t)}},{key:"once",value:function(e,t){this.events.once(e,t)}}])}()}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{Cookies:()=>o.A,DateInputProgressive:()=>u});var o=n(169);function r(e){return r="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},r(e)}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,a(i.key),i)}}function a(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}var u=function(){return e=function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$yearWrapper=t&&t.querySelector(".tna-date-input__item--year"),this.$yearInput=this.$yearWrapper&&this.$yearWrapper.querySelector("input"),this.$monthWrapper=t&&t.querySelector(".tna-date-input__item--month"),this.$monthInput=this.$monthWrapper&&this.$monthWrapper.querySelector("input"),this.$dayWrapper=t&&t.querySelector(".tna-date-input__item--day"),this.$dayInput=this.$dayWrapper&&this.$dayWrapper.querySelector("input"),this.$module&&(this.update(),window.addEventListener("pageshow",(function(){return n.update()})),this.$yearInput&&(this.$yearInput.addEventListener("keyup",(function(){return n.update()})),this.$yearInput.addEventListener("change",(function(){return n.update()}))),this.$monthInput&&(this.$monthInput.addEventListener("keyup",(function(){return n.update()})),this.$monthInput.addEventListener("change",(function(){return n.update()}))),this.$dayInput&&(this.$dayInput.addEventListener("keyup",(function(){return n.update()})),this.$dayInput.addEventListener("change",(function(){return n.update()}))))},(t=[{key:"update",value:function(){this.isValidYear()?(this.showMonth(),this.isValidMonth()?this.showDay():this.hideDay()):(this.hideMonth(),this.hideDay())}},{key:"isValidYear",value:function(){if(!this.$yearInput)return!0;var e=parseInt(this.$yearInput.value.trim());return!isNaN(this.$yearInput.value)&&!isNaN(e)&&e>0}},{key:"isValidMonth",value:function(){if(!this.$monthInput)return!0;var e=this.$monthInput.value.trim(),t=parseInt(e);return!isNaN(this.$monthInput.value)&&!isNaN(t)&&t>0&&t<=12||["january","february","march","april","may","june","july","august","september","october","november","december","jan","feb","mar","apr","jun","jul","aug","sep","oct","nov","dec"].includes(e.toLowerCase())}},{key:"showMonth",value:function(){this.$monthWrapper&&this.$monthWrapper.removeAttribute("hidden")}},{key:"hideMonth",value:function(){this.$monthWrapper&&this.$monthWrapper.setAttribute("hidden","")}},{key:"showDay",value:function(){this.$dayWrapper&&this.$dayWrapper.removeAttribute("hidden")}},{key:"hideDay",value:function(){this.$dayWrapper&&this.$dayWrapper.setAttribute("hidden","")}}])&&s(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();return i})()));
|
2
2
|
//# sourceMappingURL=date-input.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"components/date-input/date-input.js","mappings":"CAAA,SAA2CA,EAAM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Q,IAC5D3H,KAAKsH,UAAUM,iBAAiB,UAAU,kBAAMjH,EAAKgH,QAAQ,KAEjE,G,EAAC,EAAA1H,IAAA,SAAAC,MAED,WACMF,KAAK6H,eACP7H,KAAK8H,YAED9H,KAAK+H,eACP/H,KAAKgI,UAELhI,KAAKiI,YAGPjI,KAAKkI,YACLlI,KAAKiI,UAET,GAAC,CAAAhI,IAAA,cAAAC,MAED,WACE,IAAKF,KAAK0H,WACR,OAAO,EAET,IAAMS,EAAY1F,SAASzC,KAAK0H,WAAWxH,MAAMiE,QACjD,OAAQiE,MAAMpI,KAAK0H,WAAWxH,SAAWkI,MAAMD,IAAcA,EAAY,CAC3E,GAAC,CAAAlI,IAAA,eAAAC,MAED,WACE,IAAKF,KAAKwH,YACR,OAAO,EAET,IAAMa,EAAa5F,SAASzC,KAAKwH,YAAYtH,MAAMiE,QACnD,OACGiE,MAAMpI,KAAKwH,YAAYtH,SACvBkI,MAAMC,IACPA,EAAa,GACbA,GAAc,EAElB,GAAC,CAAApI,IAAA,YAAAC,MAED,WACMF,KAAKuH,eACPvH,KAAKuH,cAAce,gBAAgB,SAEvC,GAAC,CAAArI,IAAA,YAAAC,MAED,WACMF,KAAKuH,eACPvH,KAAKuH,cAAcgB,aAAa,SAAU,GAE9C,GAAC,CAAAtI,IAAA,UAAAC,MAED,WACMF,KAAKoH,aACPpH,KAAKoH,YAAYkB,gBAAgB,SAErC,GAAC,CAAArI,IAAA,UAAAC,MAED,WACMF,KAAKoH,aACPpH,KAAKoH,YAAYmB,aAAa,SAAU,GAE5C,M,6EAAC,CA9FmB,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/date-input/date-input.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\nconst tnaCookiePolicies = [\"usage\", \"settings\", \"marketing\", \"essential\"];\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 === tnaCookiePolicies.length &&\n tnaCookiePolicies.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 const existingPolicies = this.policies;\n const filteredExistingPolicies = Object.fromEntries(\n Object.keys(existingPolicies)\n .filter((policy) => tnaCookiePolicies.includes(policy))\n .map((policy) => [policy, existingPolicies[policy]]),\n );\n this.savePolicies({\n usage: false,\n settings: false,\n marketing: false,\n ...filteredExistingPolicies,\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 DateInput {\n constructor($module) {\n this.$module = $module;\n this.$dayWrapper =\n $module && $module.querySelector(\".tna-date-input__item--day\");\n this.$dayInput =\n this.$dayWrapper && this.$dayWrapper.querySelector(\"input\");\n this.$monthWrapper =\n $module && $module.querySelector(\".tna-date-input__item--month\");\n this.$monthInput =\n this.$monthWrapper && this.$monthWrapper.querySelector(\"input\");\n this.$yearWrapper =\n $module && $module.querySelector(\".tna-date-input__item--year\");\n this.$yearInput =\n this.$yearWrapper && this.$yearWrapper.querySelector(\"input\");\n\n if (!this.$module) {\n return;\n }\n\n this.update();\n\n if (this.$yearInput) {\n this.$yearInput.addEventListener(\"keyup\", () => this.update());\n this.$yearInput.addEventListener(\"change\", () => this.update());\n }\n if (this.$monthInput) {\n this.$monthInput.addEventListener(\"keyup\", () => this.update());\n this.$monthInput.addEventListener(\"change\", () => this.update());\n }\n if (this.$dayInput) {\n this.$dayInput.addEventListener(\"keyup\", () => this.update());\n this.$dayInput.addEventListener(\"change\", () => this.update());\n }\n }\n\n update() {\n if (this.isValidYear()) {\n this.showMonth();\n\n if (this.isValidMonth()) {\n this.showDay();\n } else {\n this.hideDay();\n }\n } else {\n this.hideMonth();\n this.hideDay();\n }\n }\n\n isValidYear() {\n if (!this.$yearInput) {\n return true;\n }\n const yearValue = parseInt(this.$yearInput.value.trim());\n return !isNaN(this.$yearInput.value) && !isNaN(yearValue) && yearValue > 0;\n }\n\n isValidMonth() {\n if (!this.$monthInput) {\n return true;\n }\n const monthValue = parseInt(this.$monthInput.value.trim());\n return (\n !isNaN(this.$monthInput.value) &&\n !isNaN(monthValue) &&\n monthValue > 0 &&\n monthValue <= 12\n );\n }\n\n showMonth() {\n if (this.$monthWrapper) {\n this.$monthWrapper.removeAttribute(\"hidden\");\n }\n }\n\n hideMonth() {\n if (this.$monthWrapper) {\n this.$monthWrapper.setAttribute(\"hidden\", \"\");\n }\n }\n\n showDay() {\n if (this.$dayWrapper) {\n this.$dayWrapper.removeAttribute(\"hidden\");\n }\n }\n\n hideDay() {\n if (this.$dayWrapper) {\n this.$dayWrapper.setAttribute(\"hidden\", \"\");\n }\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","tnaCookiePolicies","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","existingPolicies","filteredExistingPolicies","fromEntries","filter","map","savePolicies","_objectSpread","usage","settings","marketing","essential","get","deserialised","cookie","split","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","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","DateInput","$module","$dayWrapper","querySelector","$dayInput","$monthWrapper","$monthInput","$yearWrapper","$yearInput","update","addEventListener","isValidYear","showMonth","isValidMonth","showDay","hideDay","hideMonth","yearValue","isNaN","monthValue","removeAttribute","setAttribute"],"sourceRoot":""}
|
1
|
+
{"version":3,"file":"components/date-input/date-input.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,KAAKO,OAAOJ,GAAOa,SAAQ,SAACC,GAAc,OACxCA,EA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gBAAgB,SAErC,GAAC,CAAAtI,IAAA,UAAAC,MAED,WACMF,KAAKyH,aACPzH,KAAKyH,YAAYe,aAAa,SAAU,GAE5C,M,6EAAC,CAzH8B,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/date-input/date-input.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\nconst tnaCookiePolicies = [\"usage\", \"settings\", \"marketing\", \"essential\"];\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 === tnaCookiePolicies.length &&\n tnaCookiePolicies.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 const existingPolicies = this.policies;\n const filteredExistingPolicies = Object.fromEntries(\n Object.keys(existingPolicies)\n .filter((policy) => tnaCookiePolicies.includes(policy))\n .map((policy) => [policy, existingPolicies[policy]]),\n );\n this.savePolicies({\n usage: false,\n settings: false,\n marketing: false,\n ...filteredExistingPolicies,\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 DateInputProgressive {\n constructor($module) {\n this.$module = $module;\n this.$yearWrapper =\n $module && $module.querySelector(\".tna-date-input__item--year\");\n this.$yearInput =\n this.$yearWrapper && this.$yearWrapper.querySelector(\"input\");\n this.$monthWrapper =\n $module && $module.querySelector(\".tna-date-input__item--month\");\n this.$monthInput =\n this.$monthWrapper && this.$monthWrapper.querySelector(\"input\");\n this.$dayWrapper =\n $module && $module.querySelector(\".tna-date-input__item--day\");\n this.$dayInput =\n this.$dayWrapper && this.$dayWrapper.querySelector(\"input\");\n\n if (!this.$module) {\n return;\n }\n\n this.update();\n window.addEventListener(\"pageshow\", () => this.update());\n\n if (this.$yearInput) {\n this.$yearInput.addEventListener(\"keyup\", () => this.update());\n this.$yearInput.addEventListener(\"change\", () => this.update());\n }\n if (this.$monthInput) {\n this.$monthInput.addEventListener(\"keyup\", () => this.update());\n this.$monthInput.addEventListener(\"change\", () => this.update());\n }\n if (this.$dayInput) {\n this.$dayInput.addEventListener(\"keyup\", () => this.update());\n this.$dayInput.addEventListener(\"change\", () => this.update());\n }\n }\n\n update() {\n if (this.isValidYear()) {\n this.showMonth();\n if (this.isValidMonth()) {\n this.showDay();\n } else {\n this.hideDay();\n }\n } else {\n this.hideMonth();\n this.hideDay();\n }\n }\n\n isValidYear() {\n if (!this.$yearInput) {\n return true;\n }\n const yearValue = parseInt(this.$yearInput.value.trim());\n return !isNaN(this.$yearInput.value) && !isNaN(yearValue) && yearValue > 0;\n }\n\n isValidMonth() {\n if (!this.$monthInput) {\n return true;\n }\n const monthRawValue = this.$monthInput.value.trim();\n const monthIntValue = parseInt(monthRawValue);\n const validMonthStrings = [\n \"january\",\n \"february\",\n \"march\",\n \"april\",\n \"may\",\n \"june\",\n \"july\",\n \"august\",\n \"september\",\n \"october\",\n \"november\",\n \"december\",\n \"jan\",\n \"feb\",\n \"mar\",\n \"apr\",\n \"jun\",\n \"jul\",\n \"aug\",\n \"sep\",\n \"oct\",\n \"nov\",\n \"dec\",\n ];\n return (\n (!isNaN(this.$monthInput.value) &&\n !isNaN(monthIntValue) &&\n monthIntValue > 0 &&\n monthIntValue <= 12) ||\n validMonthStrings.includes(monthRawValue.toLowerCase())\n );\n }\n\n showMonth() {\n if (this.$monthWrapper) {\n this.$monthWrapper.removeAttribute(\"hidden\");\n }\n }\n\n hideMonth() {\n if (this.$monthWrapper) {\n this.$monthWrapper.setAttribute(\"hidden\", \"\");\n }\n }\n\n showDay() {\n if (this.$dayWrapper) {\n this.$dayWrapper.removeAttribute(\"hidden\");\n }\n }\n\n hideDay() {\n if (this.$dayWrapper) {\n this.$dayWrapper.setAttribute(\"hidden\", \"\");\n }\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","tnaCookiePolicies","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","existingPolicies","filteredExistingPolicies","fromEntries","filter","map","savePolicies","_objectSpread","usage","settings","marketing","essential","get","deserialised","cookie","split","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","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","DateInputProgressive","$module","$yearWrapper","querySelector","$yearInput","$monthWrapper","$monthInput","$dayWrapper","$dayInput","update","addEventListener","isValidYear","showMonth","isValidMonth","showDay","hideDay","hideMonth","yearValue","isNaN","monthRawValue","monthIntValue","removeAttribute","setAttribute"],"sourceRoot":""}
|
@@ -2,27 +2,28 @@ import Cookies from "../../lib/cookies.mjs";
|
|
2
2
|
|
3
3
|
export { Cookies };
|
4
4
|
|
5
|
-
export class
|
5
|
+
export class DateInputProgressive {
|
6
6
|
constructor($module) {
|
7
7
|
this.$module = $module;
|
8
|
-
this.$dayWrapper =
|
9
|
-
$module && $module.querySelector(".tna-date-input__item--day");
|
10
|
-
this.$dayInput =
|
11
|
-
this.$dayWrapper && this.$dayWrapper.querySelector("input");
|
12
|
-
this.$monthWrapper =
|
13
|
-
$module && $module.querySelector(".tna-date-input__item--month");
|
14
|
-
this.$monthInput =
|
15
|
-
this.$monthWrapper && this.$monthWrapper.querySelector("input");
|
16
8
|
this.$yearWrapper =
|
17
9
|
$module && $module.querySelector(".tna-date-input__item--year");
|
18
10
|
this.$yearInput =
|
19
11
|
this.$yearWrapper && this.$yearWrapper.querySelector("input");
|
12
|
+
this.$monthWrapper =
|
13
|
+
$module && $module.querySelector(".tna-date-input__item--month");
|
14
|
+
this.$monthInput =
|
15
|
+
this.$monthWrapper && this.$monthWrapper.querySelector("input");
|
16
|
+
this.$dayWrapper =
|
17
|
+
$module && $module.querySelector(".tna-date-input__item--day");
|
18
|
+
this.$dayInput =
|
19
|
+
this.$dayWrapper && this.$dayWrapper.querySelector("input");
|
20
20
|
|
21
21
|
if (!this.$module) {
|
22
22
|
return;
|
23
23
|
}
|
24
24
|
|
25
25
|
this.update();
|
26
|
+
window.addEventListener("pageshow", () => this.update());
|
26
27
|
|
27
28
|
if (this.$yearInput) {
|
28
29
|
this.$yearInput.addEventListener("keyup", () => this.update());
|
@@ -41,7 +42,6 @@ export class DateInput {
|
|
41
42
|
update() {
|
42
43
|
if (this.isValidYear()) {
|
43
44
|
this.showMonth();
|
44
|
-
|
45
45
|
if (this.isValidMonth()) {
|
46
46
|
this.showDay();
|
47
47
|
} else {
|
@@ -65,12 +65,39 @@ export class DateInput {
|
|
65
65
|
if (!this.$monthInput) {
|
66
66
|
return true;
|
67
67
|
}
|
68
|
-
const
|
68
|
+
const monthRawValue = this.$monthInput.value.trim();
|
69
|
+
const monthIntValue = parseInt(monthRawValue);
|
70
|
+
const validMonthStrings = [
|
71
|
+
"january",
|
72
|
+
"february",
|
73
|
+
"march",
|
74
|
+
"april",
|
75
|
+
"may",
|
76
|
+
"june",
|
77
|
+
"july",
|
78
|
+
"august",
|
79
|
+
"september",
|
80
|
+
"october",
|
81
|
+
"november",
|
82
|
+
"december",
|
83
|
+
"jan",
|
84
|
+
"feb",
|
85
|
+
"mar",
|
86
|
+
"apr",
|
87
|
+
"jun",
|
88
|
+
"jul",
|
89
|
+
"aug",
|
90
|
+
"sep",
|
91
|
+
"oct",
|
92
|
+
"nov",
|
93
|
+
"dec",
|
94
|
+
];
|
69
95
|
return (
|
70
|
-
!isNaN(this.$monthInput.value) &&
|
71
|
-
|
72
|
-
|
73
|
-
|
96
|
+
(!isNaN(this.$monthInput.value) &&
|
97
|
+
!isNaN(monthIntValue) &&
|
98
|
+
monthIntValue > 0 &&
|
99
|
+
monthIntValue <= 12) ||
|
100
|
+
validMonthStrings.includes(monthRawValue.toLowerCase())
|
74
101
|
);
|
75
102
|
}
|
76
103
|
|
@@ -76,7 +76,19 @@
|
|
76
76
|
"name": "date",
|
77
77
|
"progressive": true
|
78
78
|
},
|
79
|
-
"html": "<div class=\"tna-form__group\" data-module=\"date-input\"><fieldset class=\"tna-form__fieldset\"><legend class=\"tna-form__legend\"><h4 class=\"tna-form__heading tna-form__heading--xs\">Enter a start date</h4></legend><div class=\"tna-date-input\" id=\"date\"><div class=\"tna-date-input__item tna-date-input__item--year\"><label for=\"date-year\" class=\"tna-date-input__item-label\">Year</label><input type=\"text\" id=\"date-year\" value=\"\" name=\"date-year\" class=\"tna-date-input__item-input tna-date-input__item-input--wider\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--month\"><label for=\"date-month\" class=\"tna-date-input__item-label\">Month</label><input type=\"text\" id=\"date-month\" value=\"\" name=\"date-month\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--day\"><label for=\"date-day\" class=\"tna-date-input__item-label\">Day</label><input type=\"text\" id=\"date-day\" value=\"\" name=\"date-day\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div></div></fieldset></div>"
|
79
|
+
"html": "<div class=\"tna-form__group\" data-module=\"date-input-progressive\"><fieldset class=\"tna-form__fieldset\"><legend class=\"tna-form__legend\"><h4 class=\"tna-form__heading tna-form__heading--xs\">Enter a start date</h4></legend><div class=\"tna-date-input\" id=\"date\"><div class=\"tna-date-input__item tna-date-input__item--year\"><label for=\"date-year\" class=\"tna-date-input__item-label\">Year</label><input type=\"text\" id=\"date-year\" value=\"\" name=\"date-year\" class=\"tna-date-input__item-input tna-date-input__item-input--wider\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--month\"><label for=\"date-month\" class=\"tna-date-input__item-label\">Month</label><input type=\"text\" id=\"date-month\" value=\"\" name=\"date-month\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--day\"><label for=\"date-day\" class=\"tna-date-input__item-label\">Day</label><input type=\"text\" id=\"date-day\" value=\"\" name=\"date-day\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div></div></fieldset></div>"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"name": "only day and month",
|
83
|
+
"options": {
|
84
|
+
"label": "Enter a start date",
|
85
|
+
"headingLevel": 4,
|
86
|
+
"headingSize": "xs",
|
87
|
+
"id": "date",
|
88
|
+
"name": "date",
|
89
|
+
"fields": ["d", "m"]
|
90
|
+
},
|
91
|
+
"html": "<div class=\"tna-form__group\"><fieldset class=\"tna-form__fieldset\"><legend class=\"tna-form__legend\"><h4 class=\"tna-form__heading tna-form__heading--xs\">Enter a start date</h4></legend><div class=\"tna-date-input\" id=\"date\"><div class=\"tna-date-input__item tna-date-input__item--day\"><label for=\"date-day\" class=\"tna-date-input__item-label\">Day</label><input type=\"text\" id=\"date-day\" value=\"\" name=\"date-day\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--month\"><label for=\"date-month\" class=\"tna-date-input__item-label\">Month</label><input type=\"text\" id=\"date-month\" value=\"\" name=\"date-month\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div></div></fieldset></div>"
|
80
92
|
},
|
81
93
|
{
|
82
94
|
"name": "only month and year",
|
@@ -98,10 +110,10 @@
|
|
98
110
|
"headingSize": "xs",
|
99
111
|
"id": "date",
|
100
112
|
"name": "date",
|
101
|
-
"fields": ["
|
113
|
+
"fields": ["m", "y"],
|
102
114
|
"progressive": true
|
103
115
|
},
|
104
|
-
"html": "<div class=\"tna-form__group\" data-module=\"date-input\"><fieldset class=\"tna-form__fieldset\"><legend class=\"tna-form__legend\"><h4 class=\"tna-form__heading tna-form__heading--xs\">Enter a start date</h4></legend><div class=\"tna-date-input\" id=\"date\"><div class=\"tna-date-input__item tna-date-input__item--year\"><label for=\"date-year\" class=\"tna-date-input__item-label\">Year</label><input type=\"text\" id=\"date-year\" value=\"\" name=\"date-year\" class=\"tna-date-input__item-input tna-date-input__item-input--wider\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--month\"><label for=\"date-month\" class=\"tna-date-input__item-label\">Month</label><input type=\"text\" id=\"date-month\" value=\"\" name=\"date-month\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div></div></fieldset></div>"
|
116
|
+
"html": "<div class=\"tna-form__group\" data-module=\"date-input-progressive\"><fieldset class=\"tna-form__fieldset\"><legend class=\"tna-form__legend\"><h4 class=\"tna-form__heading tna-form__heading--xs\">Enter a start date</h4></legend><div class=\"tna-date-input\" id=\"date\"><div class=\"tna-date-input__item tna-date-input__item--year\"><label for=\"date-year\" class=\"tna-date-input__item-label\">Year</label><input type=\"text\" id=\"date-year\" value=\"\" name=\"date-year\" class=\"tna-date-input__item-input tna-date-input__item-input--wider\" inputmode=\"numeric\"></div><div class=\"tna-date-input__item tna-date-input__item--month\"><label for=\"date-month\" class=\"tna-date-input__item-label\">Month</label><input type=\"text\" id=\"date-month\" value=\"\" name=\"date-month\" class=\"tna-date-input__item-input\" inputmode=\"numeric\"></div></div></fieldset></div>"
|
105
117
|
},
|
106
118
|
{
|
107
119
|
"name": "autofill date of birth",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"name": "fields",
|
40
40
|
"type": "array",
|
41
41
|
"required": false,
|
42
|
-
"description": ""
|
42
|
+
"description": "An array of fields to display. Can be `d`, `m` or `y`. Order is preserved unless `progressive` is true."
|
43
43
|
},
|
44
44
|
{
|
45
45
|
"name": "value",
|
@@ -51,19 +51,19 @@
|
|
51
51
|
"name": "day",
|
52
52
|
"type": "string",
|
53
53
|
"required": false,
|
54
|
-
"description": ""
|
54
|
+
"description": "The value for the day field."
|
55
55
|
},
|
56
56
|
{
|
57
57
|
"name": "month",
|
58
58
|
"type": "string",
|
59
59
|
"required": false,
|
60
|
-
"description": ""
|
60
|
+
"description": "The value for the month field. Usually a number between 1 and 12, a three character month (jan-dec) or the month name (January-December)."
|
61
61
|
},
|
62
62
|
{
|
63
63
|
"name": "year",
|
64
64
|
"type": "string",
|
65
65
|
"required": false,
|
66
|
-
"description": ""
|
66
|
+
"description": "The value for the year field."
|
67
67
|
}
|
68
68
|
]
|
69
69
|
},
|
@@ -91,7 +91,7 @@
|
|
91
91
|
"name": "progressive",
|
92
92
|
"type": "boolean",
|
93
93
|
"required": false,
|
94
|
-
"description": ""
|
94
|
+
"description": "If true, order the date fields in a year-month-day order and only show the next field when the previous has a valid value."
|
95
95
|
},
|
96
96
|
{
|
97
97
|
"name": "formGroupClasses",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
{%- set inputClassesParams = [params.classes] if params.classes else [] -%}
|
12
12
|
{%- set inputClasses = inputClassesParams | join(' ') -%}
|
13
13
|
|
14
|
-
<div class="tna-form__group{% if params.error %} tna-form__group--error{% endif %}{% if classes %} {{ classes }}{% endif %}"{% if params.progressive %} data-module="date-input"{% endif %}{% for attribute, value in params.formGroupAttributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
|
14
|
+
<div class="tna-form__group{% if params.error %} tna-form__group--error{% endif %}{% if classes %} {{ classes }}{% endif %}"{% if params.progressive %} data-module="date-input-progressive"{% endif %}{% for attribute, value in params.formGroupAttributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
|
15
15
|
<fieldset class="tna-form__fieldset"{%- if params.hint or params.error %} aria-describedby="{%- if params.hint -%}{{ params.id }}-hint{%- endif %} {% if params.error -%}{{ params.id }}-error{%- endif -%}"{%- endif %}>
|
16
16
|
<legend class="tna-form__legend">
|
17
17
|
<h{{ params.headingLevel }} class="tna-form__heading tna-form__heading--{{ params.headingSize or 'm' }}">
|
@@ -34,13 +34,13 @@
|
|
34
34
|
{%- if params.fields %}
|
35
35
|
{%- set fields = [] -%}
|
36
36
|
{% if 'y' in params.fields %}
|
37
|
-
{%- set fields = fields + ['
|
37
|
+
{%- set fields = fields + ['y'] -%}
|
38
38
|
{%- endif %}
|
39
39
|
{% if 'm' in params.fields %}
|
40
|
-
{%- set fields = fields + ['
|
40
|
+
{%- set fields = fields + ['m'] -%}
|
41
41
|
{%- endif %}
|
42
42
|
{% if 'd' in params.fields %}
|
43
|
-
{%- set fields = fields + ['
|
43
|
+
{%- set fields = fields + ['d'] -%}
|
44
44
|
{%- endif %}
|
45
45
|
{%- else %}
|
46
46
|
{%- set fields = ['y', 'm', 'd'] -%}
|
@@ -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={d:(t,
|
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={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){return n="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},n(e)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(e){var t=function(e){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}e.r(t),e.d(t,{ErrorSummary:()=>i});var i=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t},t=[{key:"init",value:function(){var e=this;this.$module&&("true"===this.$module.dataset.disableAutofocus||this.setFocus(this.$module),this.$module.addEventListener("click",(function(t){return e.handleClick(t)})))}},{key:"setFocus",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.getAttribute("tabindex");function o(){var t;null===(t=n.onBlur)||void 0===t||t.call(e),r||e.removeAttribute("tabindex")}r||e.setAttribute("tabindex","-1"),e.addEventListener("focus",(function(){e.addEventListener("blur",o,{once:!0})}),{once:!0}),null===(t=n.onBeforeFocus)||void 0===t||t.call(e),e.focus()}},{key:"handleClick",value:function(e){var t=e.target;t&&this.focusTarget(t)&&e.preventDefault()}},{key:"getFragmentFromUrl",value:function(e){if(e.includes("#"))return e.split("#").pop()}},{key:"focusTarget",value:function(e){if(!(e instanceof HTMLAnchorElement))return!1;var t=this.getFragmentFromUrl(e.href);if(!t)return!1;var n=document.getElementById(t);if(!n)return!1;var r=this.getAssociatedLegendOrLabel(n);return!!r&&(r.scrollIntoView(),n.focus({preventScroll:!0}),!0)}},{key:"getAssociatedLegendOrLabel",value:function(e){var t,n=e.closest("fieldset");if(n){var r=n.getElementsByTagName("legend");if(r.length){var o=r[0];if(e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type))return o;var i=o.getBoundingClientRect().top,u=e.getBoundingClientRect();if(u.height&&window.innerHeight&&u.top+u.height-i<window.innerHeight/2)return o}}return null!==(t=document.querySelector("label[for='".concat(e.getAttribute("id"),"']")))&&void 0!==t?t:e.closest("label")}}],t&&r(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();return t})()));
|
2
2
|
//# sourceMappingURL=error-summary.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"components/error-summary/error-summary.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,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,0sBCLvD,IAAMC,EAAY,WAGtB,O,EAFD,SAAAA,EAAYC,I,4FAASC,CAAA,KAAAF,GACnBG,KAAKF,QAAUA,CACjB,E,EAAC,EAAAf,IAAA,OAAAa,MAED,
|
1
|
+
{"version":3,"file":"components/error-summary/error-summary.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACd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AAQ,QAEnB,I,gFAAC,CA7JsB,G","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","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/error-summary/error-summary.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 ","// The require scope\nvar __webpack_require__ = {};\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};","export class ErrorSummary {\n constructor($module) {\n this.$module = $module;\n }\n\n init() {\n if (!this.$module) {\n return;\n }\n\n const disableAutoFocus =\n this.$module.dataset.disableAutofocus === \"true\" || false;\n\n if (!disableAutoFocus) {\n this.setFocus(this.$module);\n }\n\n this.$module.addEventListener(\"click\", (event) => this.handleClick(event));\n }\n\n setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute(\"tabindex\");\n\n if (!isFocusable) {\n $element.setAttribute(\"tabindex\", \"-1\");\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener(\"blur\", onBlur, { once: true });\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element);\n\n if (!isFocusable) {\n $element.removeAttribute(\"tabindex\");\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener(\"focus\", onFocus, { once: true });\n\n // Focus element\n options.onBeforeFocus?.call($element);\n $element.focus();\n }\n\n handleClick(event) {\n const $target = event.target;\n if ($target && this.focusTarget($target)) {\n event.preventDefault();\n }\n }\n\n getFragmentFromUrl(url) {\n if (!url.includes(\"#\")) {\n return undefined;\n }\n\n return url.split(\"#\").pop();\n }\n\n focusTarget($target) {\n // If the element that was clicked was not a link, return early\n if (!($target instanceof HTMLAnchorElement)) {\n return false;\n }\n\n const inputId = this.getFragmentFromUrl($target.href);\n if (!inputId) {\n return false;\n }\n\n const $input = document.getElementById(inputId);\n if (!$input) {\n return false;\n }\n\n const $legendOrLabel = this.getAssociatedLegendOrLabel($input);\n if (!$legendOrLabel) {\n return false;\n }\n\n // Scroll the legend or label into view *before* calling focus on the input\n // to avoid extra scrolling in browsers that don't support `preventScroll`\n // (which at time of writing is most of them...)\n $legendOrLabel.scrollIntoView();\n $input.focus({ preventScroll: true });\n\n return true;\n }\n\n /**\n * Get associated legend or label\n *\n * Returns the first element that exists from this list:\n *\n * - The `<legend>` associated with the closest `<fieldset>` ancestor, as long\n * as the top of it is no more than half a viewport height away from the\n * bottom of the input\n * - The first `<label>` that is associated with the input using for=\"inputId\"\n * - The closest parent `<label>`\n *\n * @private\n * @param {Element} $input - The input\n * @returns {Element | null} Associated legend or label, or null if no\n * associated legend or label can be found\n */\n getAssociatedLegendOrLabel($input) {\n const $fieldset = $input.closest(\"fieldset\");\n\n if ($fieldset) {\n const $legends = $fieldset.getElementsByTagName(\"legend\");\n\n if ($legends.length) {\n const $candidateLegend = $legends[0];\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (\n $input instanceof HTMLInputElement &&\n ($input.type === \"checkbox\" || $input.type === \"radio\")\n ) {\n return $candidateLegend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = $candidateLegend.getBoundingClientRect().top;\n const inputRect = $input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return $candidateLegend;\n }\n }\n }\n }\n\n return (\n document.querySelector(`label[for='${$input.getAttribute(\"id\")}']`) ??\n $input.closest(\"label\")\n );\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","ErrorSummary","$module","_classCallCheck","this","_this","dataset","disableAutofocus","setFocus","addEventListener","event","handleClick","$element","_options$onBeforeFocu","options","arguments","length","undefined","isFocusable","getAttribute","onBlur","_options$onBlur","removeAttribute","setAttribute","once","onBeforeFocus","focus","$target","target","focusTarget","preventDefault","url","includes","split","pop","HTMLAnchorElement","inputId","getFragmentFromUrl","href","$input","document","getElementById","$legendOrLabel","getAssociatedLegendOrLabel","scrollIntoView","preventScroll","_document$querySelect","$fieldset","closest","$legends","getElementsByTagName","$candidateLegend","HTMLInputElement","type","legendTop","getBoundingClientRect","top","inputRect","height","window","innerHeight","querySelector","concat"],"sourceRoot":""}
|
@@ -14,6 +14,8 @@ export class ErrorSummary {
|
|
14
14
|
if (!disableAutoFocus) {
|
15
15
|
this.setFocus(this.$module);
|
16
16
|
}
|
17
|
+
|
18
|
+
this.$module.addEventListener("click", (event) => this.handleClick(event));
|
17
19
|
}
|
18
20
|
|
19
21
|
setFocus($element, options = {}) {
|
@@ -48,4 +50,110 @@ export class ErrorSummary {
|
|
48
50
|
options.onBeforeFocus?.call($element);
|
49
51
|
$element.focus();
|
50
52
|
}
|
53
|
+
|
54
|
+
handleClick(event) {
|
55
|
+
const $target = event.target;
|
56
|
+
if ($target && this.focusTarget($target)) {
|
57
|
+
event.preventDefault();
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
getFragmentFromUrl(url) {
|
62
|
+
if (!url.includes("#")) {
|
63
|
+
return undefined;
|
64
|
+
}
|
65
|
+
|
66
|
+
return url.split("#").pop();
|
67
|
+
}
|
68
|
+
|
69
|
+
focusTarget($target) {
|
70
|
+
// If the element that was clicked was not a link, return early
|
71
|
+
if (!($target instanceof HTMLAnchorElement)) {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
|
75
|
+
const inputId = this.getFragmentFromUrl($target.href);
|
76
|
+
if (!inputId) {
|
77
|
+
return false;
|
78
|
+
}
|
79
|
+
|
80
|
+
const $input = document.getElementById(inputId);
|
81
|
+
if (!$input) {
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
|
85
|
+
const $legendOrLabel = this.getAssociatedLegendOrLabel($input);
|
86
|
+
if (!$legendOrLabel) {
|
87
|
+
return false;
|
88
|
+
}
|
89
|
+
|
90
|
+
// Scroll the legend or label into view *before* calling focus on the input
|
91
|
+
// to avoid extra scrolling in browsers that don't support `preventScroll`
|
92
|
+
// (which at time of writing is most of them...)
|
93
|
+
$legendOrLabel.scrollIntoView();
|
94
|
+
$input.focus({ preventScroll: true });
|
95
|
+
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Get associated legend or label
|
101
|
+
*
|
102
|
+
* Returns the first element that exists from this list:
|
103
|
+
*
|
104
|
+
* - The `<legend>` associated with the closest `<fieldset>` ancestor, as long
|
105
|
+
* as the top of it is no more than half a viewport height away from the
|
106
|
+
* bottom of the input
|
107
|
+
* - The first `<label>` that is associated with the input using for="inputId"
|
108
|
+
* - The closest parent `<label>`
|
109
|
+
*
|
110
|
+
* @private
|
111
|
+
* @param {Element} $input - The input
|
112
|
+
* @returns {Element | null} Associated legend or label, or null if no
|
113
|
+
* associated legend or label can be found
|
114
|
+
*/
|
115
|
+
getAssociatedLegendOrLabel($input) {
|
116
|
+
const $fieldset = $input.closest("fieldset");
|
117
|
+
|
118
|
+
if ($fieldset) {
|
119
|
+
const $legends = $fieldset.getElementsByTagName("legend");
|
120
|
+
|
121
|
+
if ($legends.length) {
|
122
|
+
const $candidateLegend = $legends[0];
|
123
|
+
|
124
|
+
// If the input type is radio or checkbox, always use the legend if
|
125
|
+
// there is one.
|
126
|
+
if (
|
127
|
+
$input instanceof HTMLInputElement &&
|
128
|
+
($input.type === "checkbox" || $input.type === "radio")
|
129
|
+
) {
|
130
|
+
return $candidateLegend;
|
131
|
+
}
|
132
|
+
|
133
|
+
// For other input types, only scroll to the fieldset’s legend (instead
|
134
|
+
// of the label associated with the input) if the input would end up in
|
135
|
+
// the top half of the screen.
|
136
|
+
//
|
137
|
+
// This should avoid situations where the input either ends up off the
|
138
|
+
// screen, or obscured by a software keyboard.
|
139
|
+
const legendTop = $candidateLegend.getBoundingClientRect().top;
|
140
|
+
const inputRect = $input.getBoundingClientRect();
|
141
|
+
|
142
|
+
// If the browser doesn't support Element.getBoundingClientRect().height
|
143
|
+
// or window.innerHeight (like IE8), bail and just link to the label.
|
144
|
+
if (inputRect.height && window.innerHeight) {
|
145
|
+
const inputBottom = inputRect.top + inputRect.height;
|
146
|
+
|
147
|
+
if (inputBottom - legendTop < window.innerHeight / 2) {
|
148
|
+
return $candidateLegend;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
return (
|
155
|
+
document.querySelector(`label[for='${$input.getAttribute("id")}']`) ??
|
156
|
+
$input.closest("label")
|
157
|
+
);
|
158
|
+
}
|
51
159
|
}
|
@@ -109,7 +109,7 @@
|
|
109
109
|
"id": "text",
|
110
110
|
"name": "text",
|
111
111
|
"size": "m",
|
112
|
-
"spellcheck":
|
112
|
+
"spellcheck": true
|
113
113
|
},
|
114
114
|
"html": "<div class=\"tna-form__group\" data-module=\"tna-text-input\"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"text\">Enter some text</label></h4></div><input id=\"text\" class=\"tna-text-input tna-text-input--m \" name=\"text\" value=\"\" type=\"text\" spellcheck=\"true\" autocapitalize=\"off\" autocorrect=\"off\"></div>"
|
115
115
|
},
|
@@ -122,9 +122,9 @@
|
|
122
122
|
"id": "text",
|
123
123
|
"name": "text",
|
124
124
|
"size": "m",
|
125
|
-
"autocapitalize": "
|
125
|
+
"autocapitalize": "on"
|
126
126
|
},
|
127
|
-
"html": "<div class=\"tna-form__group\" data-module=\"tna-text-input\"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"text\">Enter some text</label></h4></div><input id=\"text\" class=\"tna-text-input tna-text-input--m \" name=\"text\" value=\"\" type=\"text\" spellcheck=\"false\" autocapitalize=\"
|
127
|
+
"html": "<div class=\"tna-form__group\" data-module=\"tna-text-input\"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"text\">Enter some text</label></h4></div><input id=\"text\" class=\"tna-text-input tna-text-input--m \" name=\"text\" value=\"\" type=\"text\" spellcheck=\"false\" autocapitalize=\"on\" autocorrect=\"off\"></div>"
|
128
128
|
},
|
129
129
|
{
|
130
130
|
"name": "autocorrect",
|
@@ -135,7 +135,7 @@
|
|
135
135
|
"id": "text",
|
136
136
|
"name": "text",
|
137
137
|
"size": "m",
|
138
|
-
"autocorrect":
|
138
|
+
"autocorrect": true
|
139
139
|
},
|
140
140
|
"html": "<div class=\"tna-form__group\" data-module=\"tna-text-input\"><div class=\"tna-form__group-contents\"><h4 class=\"tna-form__heading tna-form__heading--m\"><label class=\"tna-form__label\" for=\"text\">Enter some text</label></h4></div><input id=\"text\" class=\"tna-text-input tna-text-input--m \" name=\"text\" value=\"\" type=\"text\" spellcheck=\"false\" autocapitalize=\"off\" autocorrect=\"on\"></div>"
|
141
141
|
},
|