diff --git a/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/scripts/app.ts b/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/scripts/app.ts index c40ce04b2..9e0696f58 100644 --- a/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/scripts/app.ts +++ b/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/scripts/app.ts @@ -1,4 +1,4 @@ -export { }; +export {}; declare const accessibleAutocomplete: any; declare global { @@ -61,7 +61,7 @@ function setupLanguageAutocompleteWhenAddAnother(element: HTMLElement) { const languageSelects = element.querySelectorAll("select[id^='language-']") as NodeListOf; -/* console.log('enhancing ' + languageSelects.length + ' language selects');*/ + /* console.log('enhancing ' + languageSelects.length + ' language selects');*/ // work around accessible-autocomplete not handling errors or using standard govuk styling classes // there's a discussion about handling errors here... @@ -117,7 +117,7 @@ function setupLanguageAutocompleteWhenAddAnother(element: HTMLElement) { } }); - domObserver.observe(element, { childList: true, subtree: true, attributes: true }); + domObserver.observe(element, {childList: true, subtree: true, attributes: true}); languageSelects.forEach(function (select) { accessibleAutocomplete.enhanceSelectElement({ @@ -141,18 +141,18 @@ function addGovUkClasses(input: HTMLInputElement, errorState: boolean) { /** * This function is used to update the "Remove" button text in the "Add another" component * and update the label text for each item in the "Add another" component when adding a new language item to the DOM. - * + * * NOTE: Adding of DOM elements is done in the familyhubs-frontend FamilyHubsFrontend.AddAnother.prototype list. * Doing this UI update here as it makes sense being that it's only for the language page. */ -function handleUpdatingLanguageAddAnother(){ +function handleUpdatingLanguageAddAnother() { function updateAllRemoveButtonText() { const items = document.querySelectorAll('.fh-add-another__item'); items.forEach((item, index) => { const button = item.querySelector('.fh-add-another__remove-button') as HTMLButtonElement; if (button) { - button.textContent = `Remove ${(index + 1)}`; + button.textContent = `Remove language ${(index + 1)}`; } }); } @@ -162,28 +162,28 @@ function handleUpdatingLanguageAddAnother(){ items.forEach((item, index) => { const label = item.querySelector('label'); - if(label) { + if (label) { label.textContent = `Enter language ${(index + 1)}`; } }); } - // Observe DOM changes to react to new items being added + // Observe DOM changes to react to new items being added/removed const observer = new MutationObserver((mutationsList, observer) => { for (const mutation of mutationsList) { - if (mutation.type === 'childList') - { - updateAllRemoveButtonText(); + const mixedNodes = Array.from(mutation.addedNodes).concat(Array.from(mutation.removedNodes)); + if (mutation.type === 'childList' && (mixedNodes.some(node => node.nodeName === 'FIELDSET'))) { + updateAllLanguageLabelText(); + updateAllRemoveButtonText(); } } }); const container = document.getElementById('fh-add-another-id'); - if(container) { - observer.observe(container, { childList: true, subtree: true}); + if (container) { + observer.observe(container, {childList: true, subtree: true}); } - } //todo: this is a hack - we want setupLanguageAutocompleteWhenAddAnother to be in the generated js file. diff --git a/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js b/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js index cfe258098..e63bea081 100644 --- a/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js +++ b/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js @@ -1,2 +1,2 @@ -function fhgov(){this.init=function(){e(),t()};let e=function(){const e=document.querySelector("[data-conditional-active]");e instanceof HTMLElement&&e.click()},t=function(){const e=document.getElementById("modelLaOrganisationName");e&&accessibleAutocomplete.enhanceSelectElement({defaultValue:e.value,name:"LaOrganisationName",selectElement:document.querySelector("#LaOrganisationName")});const t=document.getElementById("modelVcsOrganisationName");t&&accessibleAutocomplete.enhanceSelectElement({defaultValue:t.value,name:"VcsOrganisationName",selectElement:document.querySelector("#VcsOrganisationName")})}}function setupLanguageAutocompleteWhenAddAnother(e){if(!(e instanceof HTMLElement))return;const t=e.querySelectorAll("select[id^='language-']");new MutationObserver(((e,n)=>{const o=e.some((e=>"childList"===e.type&&e.addedNodes.length>0)),a=e.some((e=>{if("attributes"===e.type&&"class"===e.attributeName){const t=e.target;return"input"===t.tagName.toLowerCase()&&"text"===t.getAttribute("type")}return!1}));(o||a)&&t.forEach((function(e){const t=document.getElementById(e.id.replace("-select",""));if(!t)return;addGovUkClasses(t,e.classList.contains("govuk-select--error"))}))})).observe(e,{childList:!0,subtree:!0,attributes:!0}),t.forEach((function(e){accessibleAutocomplete.enhanceSelectElement({name:"languageName",defaultValue:"",selectElement:e})}))}function addGovUkClasses(e,t){e.classList.contains("govuk-input")||e.classList.add("govuk-input"),t&&!e.classList.contains("govuk-input--error")&&e.classList.add("govuk-input--error")}function handleUpdatingLanguageAddAnother(){const e=new MutationObserver(((e,t)=>{for(const t of e)"childList"===t.type&&(document.querySelectorAll(".fh-add-another__item").forEach(((e,t)=>{const n=e.querySelector(".fh-add-another__remove-button");n&&(n.textContent=`Remove ${t+1}`)})),document.querySelectorAll(".fh-add-another__item").forEach(((e,t)=>{const n=e.querySelector("label");n&&(n.textContent=`Enter language ${t+1}`)})))})),t=document.getElementById("fh-add-another-id");t&&e.observe(t,{childList:!0,subtree:!0})}window.fhgov=new fhgov,document.addEventListener("DOMContentLoaded",(function(){window.fhgov.init()})),setupLanguageAutocompleteWhenAddAnother(null),handleUpdatingLanguageAddAnother(); +function fhgov(){this.init=function(){e(),t()};let e=function(){const e=document.querySelector("[data-conditional-active]");e instanceof HTMLElement&&e.click()},t=function(){const e=document.getElementById("modelLaOrganisationName");e&&accessibleAutocomplete.enhanceSelectElement({defaultValue:e.value,name:"LaOrganisationName",selectElement:document.querySelector("#LaOrganisationName")});const t=document.getElementById("modelVcsOrganisationName");t&&accessibleAutocomplete.enhanceSelectElement({defaultValue:t.value,name:"VcsOrganisationName",selectElement:document.querySelector("#VcsOrganisationName")})}}function setupLanguageAutocompleteWhenAddAnother(e){if(!(e instanceof HTMLElement))return;const t=e.querySelectorAll("select[id^='language-']");new MutationObserver(((e,n)=>{const o=e.some((e=>"childList"===e.type&&e.addedNodes.length>0)),a=e.some((e=>{if("attributes"===e.type&&"class"===e.attributeName){const t=e.target;return"input"===t.tagName.toLowerCase()&&"text"===t.getAttribute("type")}return!1}));(o||a)&&t.forEach((function(e){const t=document.getElementById(e.id.replace("-select",""));if(!t)return;addGovUkClasses(t,e.classList.contains("govuk-select--error"))}))})).observe(e,{childList:!0,subtree:!0,attributes:!0}),t.forEach((function(e){accessibleAutocomplete.enhanceSelectElement({name:"languageName",defaultValue:"",selectElement:e})}))}function addGovUkClasses(e,t){e.classList.contains("govuk-input")||e.classList.add("govuk-input"),t&&!e.classList.contains("govuk-input--error")&&e.classList.add("govuk-input--error")}function handleUpdatingLanguageAddAnother(){const e=new MutationObserver(((e,t)=>{for(const t of e){const e=Array.from(t.addedNodes).concat(Array.from(t.removedNodes));"childList"===t.type&&e.some((e=>"FIELDSET"===e.nodeName))&&(document.querySelectorAll(".fh-add-another__item").forEach(((e,t)=>{const n=e.querySelector("label");n&&(n.textContent=`Enter language ${t+1}`)})),document.querySelectorAll(".fh-add-another__item").forEach(((e,t)=>{const n=e.querySelector(".fh-add-another__remove-button");n&&(n.textContent=`Remove language ${t+1}`)})))}})),t=document.getElementById("fh-add-another-id");t&&e.observe(t,{childList:!0,subtree:!0})}window.fhgov=new fhgov,document.addEventListener("DOMContentLoaded",(function(){window.fhgov.init()})),setupLanguageAutocompleteWhenAddAnother(null),handleUpdatingLanguageAddAnother(); //# sourceMappingURL=app.js.map diff --git a/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js.map b/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js.map index 4208d9479..dd7ef2e30 100644 --- a/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js.map +++ b/src/ui/manage-ui/src/FamilyHubs.ServiceDirectory.Admin.Web/wwwroot/js/app.js.map @@ -1 +1 @@ -{"version":3,"sources":["tmp/js/app.js"],"names":["fhgov","this","init","restoreConditionalInputs","enhanceAccessibleAutocomplete","element","document","querySelector","HTMLElement","click","modelLaOrganisationName","getElementById","accessibleAutocomplete","enhanceSelectElement","defaultValue","value","name","selectElement","modelVcsOrganisationName","setupLanguageAutocompleteWhenAddAnother","languageSelects","querySelectorAll","MutationObserver","mutationsList","observer","childListMutation","some","mutation","type","addedNodes","length","attributesMutation","attributeName","targetElement","target","tagName","toLowerCase","getAttribute","forEach","select","input","id","replace","addGovUkClasses","classList","contains","observe","childList","subtree","attributes","errorState","add","handleUpdatingLanguageAddAnother","item","index","button","textContent","label","container","window","addEventListener"],"mappings":"AAAA,SAASA,QACLC,KAAKC,KAAO,WACRC,IACAC,GACR,EACI,IAAID,EAA2B,WAC3B,MAAME,EAAUC,SAASC,cAAc,6BACnCF,aAAmBG,aACnBH,EAAQI,OAEpB,EAEQL,EAAgC,WAEhC,MAAMM,EAA0BJ,SAASK,eAAe,2BACpDD,GACAE,uBAAuBC,qBAAqB,CACxCC,aAAcJ,EAAwBK,MACtCC,KAAM,qBACNC,cAAeX,SAASC,cAAc,yBAI9C,MAAMW,EAA2BZ,SAASK,eAAe,4BACrDO,GACAN,uBAAuBC,qBAAqB,CACxCC,aAAcI,EAAyBH,MACvCC,KAAM,sBACNC,cAAeX,SAASC,cAAc,yBAGtD,CACA,CAKA,SAASY,wCAAwCd,GAC7C,KAAMA,aAAmBG,aACrB,OAEJ,MAAMY,EAAkBf,EAAQgB,iBAAiB,2BAkB7B,IAAIC,kBAAiB,CAACC,EAAeC,KACrD,MAAMC,EAAoBF,EAAcG,MAAKC,GAA8B,cAAlBA,EAASC,MAAwBD,EAASE,WAAWC,OAAS,IACjHC,EAAqBR,EAAcG,MAAKC,IAC1C,GAAsB,eAAlBA,EAASC,MAAoD,UAA3BD,EAASK,cAA2B,CACtE,MAAMC,EAAgBN,EAASO,OAC/B,MAA+C,UAAxCD,EAAcE,QAAQC,eAAoE,SAAvCH,EAAcI,aAAa,OACrG,CACY,OAAO,CAAK,KAQZZ,GAAqBM,IAErBX,EAAgBkB,SAAQ,SAAUC,GAC9B,MAAMC,EAAQlC,SAASK,eAAe4B,EAAOE,GAAGC,QAAQ,UAAW,KAEnE,IAAKF,EACD,OAGJG,gBAAgBH,EADGD,EAAOK,UAAUC,SAAS,uBAE7D,GACA,IAEgBC,QAAQzC,EAAS,CAAE0C,WAAW,EAAMC,SAAS,EAAMC,YAAY,IAC3E7B,EAAgBkB,SAAQ,SAAUC,GAC9B3B,uBAAuBC,qBAAqB,CACxCG,KAAM,eACNF,aAAc,GACdG,cAAesB,GAE3B,GACA,CACA,SAASI,gBAAgBH,EAAOU,GACvBV,EAAMI,UAAUC,SAAS,gBAC1BL,EAAMI,UAAUO,IAAI,eAEpBD,IAAeV,EAAMI,UAAUC,SAAS,uBACxCL,EAAMI,UAAUO,IAAI,qBAE5B,CAQA,SAASC,mCAoBL,MAAM5B,EAAW,IAAIF,kBAAiB,CAACC,EAAeC,KAClD,IAAK,MAAMG,KAAYJ,EACG,cAAlBI,EAASC,OApBHtB,SAASe,iBAAiB,yBAClCiB,SAAQ,CAACe,EAAMC,KACjB,MAAMC,EAASF,EAAK9C,cAAc,kCAC9BgD,IACAA,EAAOC,YAAc,UAAWF,EAAQ,IACxD,IAIsBhD,SAASe,iBAAiB,yBAClCiB,SAAQ,CAACe,EAAMC,KACjB,MAAMG,EAAQJ,EAAK9C,cAAc,SAC7BkD,IACAA,EAAMD,YAAc,kBAAmBF,EAAQ,IAC/D,IAUA,IAEUI,EAAYpD,SAASK,eAAe,qBACtC+C,GACAlC,EAASsB,QAAQY,EAAW,CAAEX,WAAW,EAAMC,SAAS,GAEhE,CA9GAW,OAAO3D,MAAQ,IAAIA,MACnBM,SAASsD,iBAAiB,oBAAoB,WAC1CD,OAAO3D,MAAME,MACjB,IAgHAiB,wCAAwC,MACxCiC","file":"app.js","sourcesContent":["function fhgov() {\n this.init = function () {\n restoreConditionalInputs();\n enhanceAccessibleAutocomplete();\n };\n let restoreConditionalInputs = function () {\n const element = document.querySelector(\"[data-conditional-active]\");\n if (element instanceof HTMLElement) {\n element.click();\n }\n };\n //todo: replace these with the new full page autocomplete component\n let enhanceAccessibleAutocomplete = function () {\n //WhichLocalAuthority.cshtml && AddOrganisationWhichLocalAuthority.cshtml\n const modelLaOrganisationName = document.getElementById('modelLaOrganisationName');\n if (modelLaOrganisationName) {\n accessibleAutocomplete.enhanceSelectElement({\n defaultValue: modelLaOrganisationName.value,\n name: 'LaOrganisationName',\n selectElement: document.querySelector('#LaOrganisationName')\n });\n }\n //WhichVcsOrganisation.cshtml\n const modelVcsOrganisationName = document.getElementById('modelVcsOrganisationName');\n if (modelVcsOrganisationName) {\n accessibleAutocomplete.enhanceSelectElement({\n defaultValue: modelVcsOrganisationName.value,\n name: 'VcsOrganisationName',\n selectElement: document.querySelector('#VcsOrganisationName')\n });\n }\n };\n}\nwindow.fhgov = new fhgov();\ndocument.addEventListener('DOMContentLoaded', function () {\n window.fhgov.init();\n});\nfunction setupLanguageAutocompleteWhenAddAnother(element) {\n if (!(element instanceof HTMLElement)) {\n return;\n }\n const languageSelects = element.querySelectorAll(\"select[id^='language-']\");\n /* console.log('enhancing ' + languageSelects.length + ' language selects');*/\n // work around accessible-autocomplete not handling errors or using standard govuk styling classes\n // there's a discussion about handling errors here...\n // https://github.com/alphagov/accessible-autocomplete/issues/428\n // but we've had to implement our own (hacky) solution by using MutationObserver\n // and adding extra classes (with custom css) to the input element.\n // we are observing the DOM for changes because enhanceSelectElement() ultimately\n // calls render in Peact, which schedules an update to the DOM, rather than immediately updating the DOM.\n // (if we forked the accessible-autocomplete component, we could use componentDidMount or useEffect instead).\n // we also observe any changes to the class attribute of the text input elements,\n // as any changes we make to the input element's class attribute will be overwritten by the component (on focus etc.).\n // I was going to either package up this code into an exported function to ease reuse and maintanence,\n // or fork the accessible-autocomplete preact component,\n // but someone is adding official support today (2024-01-12) so we should be able to remove this soon!\n // https://github.com/alphagov/accessible-autocomplete/pull/602\n //todo: fix aria-describedBy on the input too\n // see https://github.com/alphagov/accessible-autocomplete/issues/589\n const domObserver = new MutationObserver((mutationsList, observer) => {\n const childListMutation = mutationsList.some(mutation => mutation.type === 'childList' && mutation.addedNodes.length > 0);\n const attributesMutation = mutationsList.some(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName === 'class') {\n const targetElement = mutation.target;\n return targetElement.tagName.toLowerCase() === 'input' && targetElement.getAttribute('type') === 'text';\n }\n return false;\n });\n //if (childListMutation) {\n // console.log('childListMutation');\n //}\n //if (attributesMutation) {\n // console.log('attributesMutation');\n //}\n if (childListMutation || attributesMutation) {\n /*todo: create list of input ids outside of observer? */\n languageSelects.forEach(function (select) {\n const input = document.getElementById(select.id.replace('-select', ''));\n // input should never be null now we're observing the DOM for changes, but we check it for extra safety\n if (!input) {\n return;\n }\n const errorState = select.classList.contains('govuk-select--error');\n addGovUkClasses(input, errorState);\n });\n }\n });\n domObserver.observe(element, { childList: true, subtree: true, attributes: true });\n languageSelects.forEach(function (select) {\n accessibleAutocomplete.enhanceSelectElement({\n name: 'languageName',\n defaultValue: '',\n selectElement: select\n });\n });\n}\nfunction addGovUkClasses(input, errorState) {\n if (!input.classList.contains('govuk-input')) {\n input.classList.add('govuk-input');\n }\n if (errorState && !input.classList.contains('govuk-input--error')) {\n input.classList.add('govuk-input--error');\n }\n}\n/**\n * This function is used to update the \"Remove\" button text in the \"Add another\" component\n * and update the label text for each item in the \"Add another\" component when adding a new language item to the DOM.\n *\n * NOTE: Adding of DOM elements is done in the familyhubs-frontend FamilyHubsFrontend.AddAnother.prototype list.\n * Doing this UI update here as it makes sense being that it's only for the language page.\n */\nfunction handleUpdatingLanguageAddAnother() {\n function updateAllRemoveButtonText() {\n const items = document.querySelectorAll('.fh-add-another__item');\n items.forEach((item, index) => {\n const button = item.querySelector('.fh-add-another__remove-button');\n if (button) {\n button.textContent = `Remove ${(index + 1)}`;\n }\n });\n }\n function updateAllLanguageLabelText() {\n const items = document.querySelectorAll('.fh-add-another__item');\n items.forEach((item, index) => {\n const label = item.querySelector('label');\n if (label) {\n label.textContent = `Enter language ${(index + 1)}`;\n }\n });\n }\n // Observe DOM changes to react to new items being added\n const observer = new MutationObserver((mutationsList, observer) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'childList') {\n updateAllRemoveButtonText();\n updateAllLanguageLabelText();\n }\n }\n });\n const container = document.getElementById('fh-add-another-id');\n if (container) {\n observer.observe(container, { childList: true, subtree: true });\n }\n}\n//todo: this is a hack - we want setupLanguageAutocompleteWhenAddAnother to be in the generated js file.\n// if we export it, it includes the export keyword in the generated js file\n// (but we use export in the other ts files, without the js containing export!)\n// so as a workaround we call it where it no-ops\nsetupLanguageAutocompleteWhenAddAnother(null);\nhandleUpdatingLanguageAddAnother();\nexport {};\n\n//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFTQSxTQUFTLEtBQUs7SUFDVixJQUFJLENBQUMsSUFBSSxHQUFHO1FBQ1Isd0JBQXdCLEVBQUUsQ0FBQztRQUMzQiw2QkFBNkIsRUFBRSxDQUFDO0lBQ3BDLENBQUMsQ0FBQztJQUVGLElBQUksd0JBQXdCLEdBQUc7UUFDM0IsTUFBTSxPQUFPLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQywyQkFBMkIsQ0FBQyxDQUFDO1FBQ3BFLElBQUksT0FBTyxZQUFZLFdBQVcsRUFBRSxDQUFDO1lBQ2pDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNuQixDQUFDO0lBRUwsQ0FBQyxDQUFBO0lBRUQsbUVBQW1FO0lBRW5FLElBQUksNkJBQTZCLEdBQUc7UUFFaEMseUVBQXlFO1FBQ3pFLE1BQU0sdUJBQXVCLEdBQUcsUUFBUSxDQUFDLGNBQWMsQ0FBQyx5QkFBeUIsQ0FBcUIsQ0FBQztRQUN2RyxJQUFJLHVCQUF1QixFQUFFLENBQUM7WUFDMUIsc0JBQXNCLENBQUMsb0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7XG4gICAgfVxuICAgIFxufVxuXG4vL3RvZG86IHRoaXMgaXMgYSBoYWNrIC0gd2Ugd2FudCBzZXR1cExhbmd1YWdlQXV0b2NvbXBsZXRlV2hlbkFkZEFub3RoZXIgdG8gYmUgaW4gdGhlIGdlbmVyYXRlZCBqcyBmaWxlLlxuLy8gaWYgd2UgZXhwb3J0IGl0LCBpdCBpbmNsdWRlcyB0aGUgZXhwb3J0IGtleXdvcmQgaW4gdGhlIGdlbmVyYXRlZCBqcyBmaWxlXG4vLyAoYnV0IHdlIHVzZSBleHBvcnQgaW4gdGhlIG90aGVyIHRzIGZpbGVzLCB3aXRob3V0IHRoZSBqcyBjb250YWluaW5nIGV4cG9ydCEpXG4vLyBzbyBhcyBhIHdvcmthcm91bmQgd2UgY2FsbCBpdCB3aGVyZSBpdCBuby1vcHNcbnNldHVwTGFuZ3VhZ2VBdXRvY29tcGxldGVXaGVuQWRkQW5vdGhlcihudWxsKTtcbmhhbmRsZVVwZGF0aW5nTGFuZ3VhZ2VBZGRBbm90aGVyKCk7XG4iXX0=\n"]} \ No newline at end of file +{"version":3,"sources":["tmp/js/app.js"],"names":["fhgov","this","init","restoreConditionalInputs","enhanceAccessibleAutocomplete","element","document","querySelector","HTMLElement","click","modelLaOrganisationName","getElementById","accessibleAutocomplete","enhanceSelectElement","defaultValue","value","name","selectElement","modelVcsOrganisationName","setupLanguageAutocompleteWhenAddAnother","languageSelects","querySelectorAll","MutationObserver","mutationsList","observer","childListMutation","some","mutation","type","addedNodes","length","attributesMutation","attributeName","targetElement","target","tagName","toLowerCase","getAttribute","forEach","select","input","id","replace","addGovUkClasses","classList","contains","observe","childList","subtree","attributes","errorState","add","handleUpdatingLanguageAddAnother","addRemoveNodes","Array","from","concat","removedNodes","node","nodeName","item","index","label","textContent","button","container","window","addEventListener"],"mappings":"AAAA,SAASA,QACLC,KAAKC,KAAO,WACRC,IACAC,GACR,EACI,IAAID,EAA2B,WAC3B,MAAME,EAAUC,SAASC,cAAc,6BAC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uBACxCL,EAAMI,UAAUO,IAAI,qBAE5B,CAQA,SAASC,mCAoBL,MAAM5B,EAAW,IAAIF,kBAAiB,CAACC,EAAeC,KAClD,IAAK,MAAMG,KAAYJ,EAAe,CAClC,MAAM8B,EAAiBC,MAAMC,KAAK5B,EAASE,YAAY2B,OAAOF,MAAMC,KAAK5B,EAAS8B,eAC5D,cAAlB9B,EAASC,MAAyByB,EAAe3B,MAAKgC,GAA0B,aAAlBA,EAAKC,aAZ7DrD,SAASe,iBAAiB,yBAClCiB,SAAQ,CAACsB,EAAMC,KACjB,MAAMC,EAAQF,EAAKrD,cAAc,SAC7BuD,IACAA,EAAMC,YAAc,kBAAmBF,EAAQ,IAC/D,IAdsBvD,SAASe,iBAAiB,yBAClCiB,SAAQ,CAACsB,EAAMC,KACjB,MAAMG,EAASJ,EAAKrD,cAAc,kCAC9ByD,IACAA,EAAOD,YAAc,mBAAoBF,EAAQ,IACjE,IAoBA,KAEUI,EAAY3D,SAASK,eAAe,qBACtCsD,GACAzC,EAASsB,QAAQmB,EAAW,CAAElB,WAAW,EAAMC,SAAS,GAEhE,CA/GAkB,OAAOlE,MAAQ,IAAIA,MACnBM,SAAS6D,iBAAiB,oBAAoB,WAC1CD,OAAOlE,MAAME,MACjB,IAiHAiB,wCAAwC,MACxCiC","file":"app.js","sourcesContent":["function fhgov() {\n this.init = function () {\n restoreConditionalInputs();\n enhanceAccessibleAutocomplete();\n };\n let restoreConditionalInputs = function () {\n const element = document.querySelector(\"[data-conditional-active]\");\n if (element instanceof HTMLElement) {\n element.click();\n }\n };\n //todo: replace these with the new full page autocomplete component\n let enhanceAccessibleAutocomplete = function () {\n //WhichLocalAuthority.cshtml && AddOrganisationWhichLocalAuthority.cshtml\n const modelLaOrganisationName = document.getElementById('modelLaOrganisationName');\n if (modelLaOrganisationName) {\n accessibleAutocomplete.enhanceSelectElement({\n defaultValue: modelLaOrganisationName.value,\n name: 'LaOrganisationName',\n selectElement: document.querySelector('#LaOrganisationName')\n });\n }\n //WhichVcsOrganisation.cshtml\n const modelVcsOrganisationName = document.getElementById('modelVcsOrganisationName');\n if (modelVcsOrganisationName) {\n accessibleAutocomplete.enhanceSelectElement({\n defaultValue: modelVcsOrganisationName.value,\n name: 'VcsOrganisationName',\n selectElement: document.querySelector('#VcsOrganisationName')\n });\n }\n };\n}\nwindow.fhgov = new fhgov();\ndocument.addEventListener('DOMContentLoaded', function () {\n window.fhgov.init();\n});\nfunction setupLanguageAutocompleteWhenAddAnother(element) {\n if (!(element instanceof HTMLElement)) {\n return;\n }\n const languageSelects = element.querySelectorAll(\"select[id^='language-']\");\n /* console.log('enhancing ' + languageSelects.length + ' language selects');*/\n // work around accessible-autocomplete not handling errors or using standard govuk styling classes\n // there's a discussion about handling errors here...\n // https://github.com/alphagov/accessible-autocomplete/issues/428\n // but we've had to implement our own (hacky) solution by using MutationObserver\n // and adding extra classes (with custom css) to the input element.\n // we are observing the DOM for changes because enhanceSelectElement() ultimately\n // calls render in Peact, which schedules an update to the DOM, rather than immediately updating the DOM.\n // (if we forked the accessible-autocomplete component, we could use componentDidMount or useEffect instead).\n // we also observe any changes to the class attribute of the text input elements,\n // as any changes we make to the input element's class attribute will be overwritten by the component (on focus etc.).\n // I was going to either package up this code into an exported function to ease reuse and maintanence,\n // or fork the accessible-autocomplete preact component,\n // but someone is adding official support today (2024-01-12) so we should be able to remove this soon!\n // https://github.com/alphagov/accessible-autocomplete/pull/602\n //todo: fix aria-describedBy on the input too\n // see https://github.com/alphagov/accessible-autocomplete/issues/589\n const domObserver = new MutationObserver((mutationsList, observer) => {\n const childListMutation = mutationsList.some(mutation => mutation.type === 'childList' && mutation.addedNodes.length > 0);\n const attributesMutation = mutationsList.some(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName === 'class') {\n const targetElement = mutation.target;\n return targetElement.tagName.toLowerCase() === 'input' && targetElement.getAttribute('type') === 'text';\n }\n return false;\n });\n //if (childListMutation) {\n // console.log('childListMutation');\n //}\n //if (attributesMutation) {\n // console.log('attributesMutation');\n //}\n if (childListMutation || attributesMutation) {\n /*todo: create list of input ids outside of observer? */\n languageSelects.forEach(function (select) {\n const input = document.getElementById(select.id.replace('-select', ''));\n // input should never be null now we're observing the DOM for changes, but we check it for extra safety\n if (!input) {\n return;\n }\n const errorState = select.classList.contains('govuk-select--error');\n addGovUkClasses(input, errorState);\n });\n }\n });\n domObserver.observe(element, { childList: true, subtree: true, attributes: true });\n languageSelects.forEach(function (select) {\n accessibleAutocomplete.enhanceSelectElement({\n name: 'languageName',\n defaultValue: '',\n selectElement: select\n });\n });\n}\nfunction addGovUkClasses(input, errorState) {\n if (!input.classList.contains('govuk-input')) {\n input.classList.add('govuk-input');\n }\n if (errorState && !input.classList.contains('govuk-input--error')) {\n input.classList.add('govuk-input--error');\n }\n}\n/**\n * This function is used to update the \"Remove\" button text in the \"Add another\" component\n * and update the label text for each item in the \"Add another\" component when adding a new language item to the DOM.\n *\n * NOTE: Adding of DOM elements is done in the familyhubs-frontend FamilyHubsFrontend.AddAnother.prototype list.\n * Doing this UI update here as it makes sense being that it's only for the language page.\n */\nfunction handleUpdatingLanguageAddAnother() {\n function updateAllRemoveButtonText() {\n const items = document.querySelectorAll('.fh-add-another__item');\n items.forEach((item, index) => {\n const button = item.querySelector('.fh-add-another__remove-button');\n if (button) {\n button.textContent = `Remove language ${(index + 1)}`;\n }\n });\n }\n function updateAllLanguageLabelText() {\n const items = document.querySelectorAll('.fh-add-another__item');\n items.forEach((item, index) => {\n const label = item.querySelector('label');\n if (label) {\n label.textContent = `Enter language ${(index + 1)}`;\n }\n });\n }\n // Observe DOM changes to react to new items being added/removed\n const observer = new MutationObserver((mutationsList, observer) => {\n for (const mutation of mutationsList) {\n const addRemoveNodes = Array.from(mutation.addedNodes).concat(Array.from(mutation.removedNodes));\n if (mutation.type === 'childList' && (addRemoveNodes.some(node => node.nodeName === 'FIELDSET'))) {\n updateAllLanguageLabelText();\n updateAllRemoveButtonText();\n }\n }\n });\n const container = document.getElementById('fh-add-another-id');\n if (container) {\n observer.observe(container, { childList: true, subtree: true });\n }\n}\n//todo: this is a hack - we want setupLanguageAutocompleteWhenAddAnother to be in the generated js file.\n// if we export it, it includes the export keyword in the generated js file\n// (but we use export in the other ts files, without the js containing export!)\n// so as a workaround we call it where it no-ops\nsetupLanguageAutocompleteWhenAddAnother(null);\nhandleUpdatingLanguageAddAnother();\nexport {};\n\n//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFTQSxTQUFTLEtBQUs7SUFDVixJQUFJLENBQUMsSUFBSSxHQUFHO1FBQ1Isd0JBQXdCLEVBQUUsQ0FBQztRQUMzQiw2QkFBNkIsRUFBRSxDQUFDO0lBQ3BDLENBQUMsQ0FBQztJQUVGLElBQUksd0JBQXdCLEdBQUc7UUFDM0IsTUFBTSxPQUFPLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQywyQkFBMkIsQ0FBQyxDQUFDO1FBQ3BFLElBQUksT0FBTyxZQUFZLFdBQVcsRUFBRSxDQUFDO1lBQ2pDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNuQixDQUFDO0lBRUwsQ0FBQyxDQUFBO0lBRUQsbUVBQW1FO0lBRW5FLElBQUksNkJBQTZCLEdBQUc7UUFFaEMseUVBQXlFO1FBQ3pFLE1BQU0sdUJBQXVCLEdBQUcsUUFBUSxDQUFDLGNBQWMsQ0FBQyx5QkFBeUIsQ0FBcUIsQ0FBQztRQUN2RyxJQUFJLHVCQUF1QixFQUFFLENBQUM7WUFDMUIsc0JBQXNCLENBQUMsb0JBQW9CLENBQUM7Z0JBQ3hDLFlBQVksRUFBRSx1QkFBdUIsQ0FBQyxLQUFLO2dCQUMzQyxJQUFJLEVBQUUsb0JBQW9CO2dCQUMxQixhQUFhLEVBQUUsUUFBUSxDQUFDLGFBQWEsQ0FBQyxxQkFBcUI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