katalyst-govuk-formbuilder 1.20.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da004d0b7b5dfcb97af7b01bcfc39b6d647a89b66897c52aa8fb417da4b71212
4
- data.tar.gz: c0d30d770ec308ac665a9aa1ccfd4530d80bfefdb7f73ca676790ba3dfce3334
3
+ metadata.gz: 2820ba79e52ab5755807e8bce90a130259d2cc6ba9efd05099c6333b00d556a3
4
+ data.tar.gz: 9c1c5907e61251301258104b388bc46a7ffe74846aa9154050cb497e9ac61d43
5
5
  SHA512:
6
- metadata.gz: 0bf9760ff7f77cc320cccf4ab7d255c56836632e0172af9a786f3e3b880b5fce229317927e006fd37e526d9de2548c1e16455db5ef6504a391e61d819fbb5857
7
- data.tar.gz: 1b1c07f9d38bebff251543dd4a35f51781cf7aa234b74ae26a87e4555d70a510e5bd8f2e1d75cfe91dcd04ad263e70357a7ca62ee9828ef60fb9a42c01cb512a
6
+ metadata.gz: e26b39e7f6c60ab50986313c59e11c0b2e2af18af73e1487aa9a381e55198091def95e04d31ea737c581c9faf50400658725d4f430e610b762dcd3d0da913873
7
+ data.tar.gz: 3d753a32a8d80c228b1cf7eb36ab83d746f84e17ddabfb24d33acba38bdd332918ceb6049807aadaa42671e6c2185c18b1b691d6d2dc09b8c9ab99b1d5416630
@@ -47,10 +47,13 @@
47
47
 
48
48
 
49
49
  :root {
50
- --govuk-frontend-version: "5.10.2";
51
- --govuk-frontend-breakpoint-mobile: 20rem;
52
- --govuk-frontend-breakpoint-tablet: 40.0625rem;
53
- --govuk-frontend-breakpoint-desktop: 48.0625rem;
50
+ --govuk-frontend-version: "5.11.1";
51
+ --govuk-breakpoint-mobile: 20rem;
52
+ --govuk-frontend-breakpoint-mobile: var(--govuk-breakpoint-mobile);
53
+ --govuk-breakpoint-tablet: 40.0625rem;
54
+ --govuk-frontend-breakpoint-tablet: var(--govuk-breakpoint-tablet);
55
+ --govuk-breakpoint-desktop: 48.0625rem;
56
+ --govuk-frontend-breakpoint-desktop: var(--govuk-breakpoint-desktop);
54
57
  }
55
58
 
56
59
 
@@ -2360,19 +2363,19 @@
2360
2363
  background-color: #ffffff;
2361
2364
  }
2362
2365
  .govuk-file-upload-button:hover {
2363
- background-color: rgb(192.6, 195, 196.6);
2366
+ background-color: #c1c3c5;
2364
2367
  }
2365
2368
  .govuk-file-upload-button:hover .govuk-file-upload-button__pseudo-button {
2366
- background-color: rgb(218.7, 217.8, 216.9);
2369
+ background-color: #dbdad9;
2367
2370
  }
2368
2371
  .govuk-file-upload-button:hover .govuk-file-upload-button__status {
2369
- background-color: rgb(209.8, 226.4, 240.8);
2372
+ background-color: #d2e2f1;
2370
2373
  }
2371
2374
  .govuk-file-upload-button:active, .govuk-file-upload-button:focus {
2372
2375
  border: 2px solid #0b0c0c;
2373
2376
  outline: 3px solid #ffdd00;
2374
2377
  outline-offset: 0;
2375
- background-color: rgb(192.6, 195, 196.6);
2378
+ background-color: #c1c3c5;
2376
2379
  box-shadow: inset 0 0 0 2px;
2377
2380
  }
2378
2381
  .govuk-file-upload-button:active .govuk-file-upload-button__pseudo-button, .govuk-file-upload-button:focus .govuk-file-upload-button__pseudo-button {
@@ -2394,14 +2397,14 @@
2394
2397
  background-color: #f3f2f1;
2395
2398
  }
2396
2399
  .govuk-file-upload-button--empty .govuk-file-upload-button__status {
2397
- color: rgb(11.6, 44.8, 73.6);
2398
- background-color: rgb(187.2, 212.1, 233.7);
2400
+ color: #0c2d4a;
2401
+ background-color: #bbd4ea;
2399
2402
  }
2400
2403
  .govuk-file-upload-button--empty:hover, .govuk-file-upload-button--empty:focus, .govuk-file-upload-button--empty:active {
2401
2404
  background-color: #f3f2f1;
2402
2405
  }
2403
2406
  .govuk-file-upload-button--empty:hover .govuk-file-upload-button__status, .govuk-file-upload-button--empty:focus .govuk-file-upload-button__status, .govuk-file-upload-button--empty:active .govuk-file-upload-button__status {
2404
- background-color: rgb(209.8, 226.4, 240.8);
2407
+ background-color: #d2e2f1;
2405
2408
  }
2406
2409
 
2407
2410
  .govuk-file-upload-button--dragging {
@@ -2409,7 +2412,7 @@
2409
2412
  border-color: #0b0c0c;
2410
2413
  }
2411
2414
  .govuk-file-upload-button--dragging.govuk-file-upload-button {
2412
- background-color: rgb(192.6, 195, 196.6);
2415
+ background-color: #c1c3c5;
2413
2416
  }
2414
2417
  .govuk-file-upload-button--dragging.govuk-file-upload-button--empty {
2415
2418
  background-color: #f3f2f1;
@@ -2418,7 +2421,7 @@
2418
2421
  background-color: #ffffff;
2419
2422
  }
2420
2423
  .govuk-file-upload-button--dragging .govuk-file-upload-button__pseudo-button {
2421
- background-color: rgb(218.7, 217.8, 216.9);
2424
+ background-color: #dbdad9;
2422
2425
  }
2423
2426
 
2424
2427
  .govuk-file-upload-button:disabled {
@@ -2430,7 +2433,7 @@
2430
2433
  background-color: #f3f2f1;
2431
2434
  }
2432
2435
  .govuk-file-upload-button:disabled .govuk-file-upload-button__status {
2433
- background-color: rgb(187.2, 212.1, 233.7);
2436
+ background-color: #bbd4ea;
2434
2437
  }
2435
2438
 
2436
2439
 
@@ -2811,7 +2814,7 @@
2811
2814
  content: " ";
2812
2815
  }
2813
2816
 
2814
- .govuk-visually-hidden-focusable:not(:active):not(:focus) {
2817
+ .govuk-visually-hidden-focusable:not(:active):not(:focus):not(.\:focus) {
2815
2818
  position: absolute !important;
2816
2819
  width: 1px !important;
2817
2820
  height: 1px !important;
@@ -915,6 +915,219 @@ ErrorSummary.schema = Object.freeze({
915
915
  }
916
916
  });
917
917
 
918
+ /**
919
+ * File upload component
920
+ *
921
+ * @preserve
922
+ * @augments ConfigurableComponent<FileUploadConfig>
923
+ */ class FileUpload extends ConfigurableComponent {
924
+ constructor($root, config = {}) {
925
+ super($root, config);
926
+ this.$input = void 0;
927
+ this.$button = void 0;
928
+ this.$status = void 0;
929
+ this.i18n = void 0;
930
+ this.id = void 0;
931
+ this.$announcements = void 0;
932
+ this.enteredAnotherElement = void 0;
933
+ const $input = this.$root.querySelector("input");
934
+ if ($input === null) {
935
+ throw new ElementError({
936
+ component: FileUpload,
937
+ identifier: 'File inputs (`<input type="file">`)'
938
+ });
939
+ }
940
+ if ($input.type !== "file") {
941
+ throw new ElementError(formatErrorMessage(FileUpload, 'File input (`<input type="file">`) attribute (`type`) is not `file`'));
942
+ }
943
+ this.$input = $input;
944
+ this.$input.setAttribute("hidden", "true");
945
+ if (!this.$input.id) {
946
+ throw new ElementError({
947
+ component: FileUpload,
948
+ identifier: 'File input (`<input type="file">`) attribute (`id`)'
949
+ });
950
+ }
951
+ this.id = this.$input.id;
952
+ this.i18n = new I18n(this.config.i18n, {
953
+ locale: closestAttributeValue(this.$root, "lang")
954
+ });
955
+ const $label = this.findLabel();
956
+ if (!$label.id) {
957
+ $label.id = `${this.id}-label`;
958
+ }
959
+ this.$input.id = `${this.id}-input`;
960
+ const $button = document.createElement("button");
961
+ $button.classList.add("govuk-file-upload-button");
962
+ $button.type = "button";
963
+ $button.id = this.id;
964
+ $button.classList.add("govuk-file-upload-button--empty");
965
+ const ariaDescribedBy = this.$input.getAttribute("aria-describedby");
966
+ if (ariaDescribedBy) {
967
+ $button.setAttribute("aria-describedby", ariaDescribedBy);
968
+ }
969
+ const $status = document.createElement("span");
970
+ $status.className = "govuk-body govuk-file-upload-button__status";
971
+ $status.setAttribute("aria-live", "polite");
972
+ $status.innerText = this.i18n.t("noFileChosen");
973
+ $button.appendChild($status);
974
+ const commaSpan = document.createElement("span");
975
+ commaSpan.className = "govuk-visually-hidden";
976
+ commaSpan.innerText = ", ";
977
+ commaSpan.id = `${this.id}-comma`;
978
+ $button.appendChild(commaSpan);
979
+ const containerSpan = document.createElement("span");
980
+ containerSpan.className = "govuk-file-upload-button__pseudo-button-container";
981
+ const buttonSpan = document.createElement("span");
982
+ buttonSpan.className = "govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button";
983
+ buttonSpan.innerText = this.i18n.t("chooseFilesButton");
984
+ containerSpan.appendChild(buttonSpan);
985
+ containerSpan.insertAdjacentText("beforeend", " ");
986
+ const instructionSpan = document.createElement("span");
987
+ instructionSpan.className = "govuk-body govuk-file-upload-button__instruction";
988
+ instructionSpan.innerText = this.i18n.t("dropInstruction");
989
+ containerSpan.appendChild(instructionSpan);
990
+ $button.appendChild(containerSpan);
991
+ $button.setAttribute("aria-labelledby", `${$label.id} ${commaSpan.id} ${$button.id}`);
992
+ $button.addEventListener("click", this.onClick.bind(this));
993
+ $button.addEventListener("dragover", event => {
994
+ event.preventDefault();
995
+ });
996
+ this.$root.insertAdjacentElement("afterbegin", $button);
997
+ this.$input.setAttribute("tabindex", "-1");
998
+ this.$input.setAttribute("aria-hidden", "true");
999
+ this.$button = $button;
1000
+ this.$status = $status;
1001
+ this.$input.addEventListener("change", this.onChange.bind(this));
1002
+ this.updateDisabledState();
1003
+ this.observeDisabledState();
1004
+ this.$announcements = document.createElement("span");
1005
+ this.$announcements.classList.add("govuk-file-upload-announcements");
1006
+ this.$announcements.classList.add("govuk-visually-hidden");
1007
+ this.$announcements.setAttribute("aria-live", "assertive");
1008
+ this.$root.insertAdjacentElement("afterend", this.$announcements);
1009
+ this.$button.addEventListener("drop", this.onDrop.bind(this));
1010
+ document.addEventListener("dragenter", this.updateDropzoneVisibility.bind(this));
1011
+ document.addEventListener("dragenter", () => {
1012
+ this.enteredAnotherElement = true;
1013
+ });
1014
+ document.addEventListener("dragleave", () => {
1015
+ if (!this.enteredAnotherElement && !this.$button.disabled) {
1016
+ this.hideDraggingState();
1017
+ this.$announcements.innerText = this.i18n.t("leftDropZone");
1018
+ }
1019
+ this.enteredAnotherElement = false;
1020
+ });
1021
+ }
1022
+ updateDropzoneVisibility(event) {
1023
+ if (this.$button.disabled) return;
1024
+ if (event.target instanceof Node) {
1025
+ if (this.$root.contains(event.target)) {
1026
+ if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
1027
+ if (!this.$button.classList.contains("govuk-file-upload-button--dragging")) {
1028
+ this.showDraggingState();
1029
+ this.$announcements.innerText = this.i18n.t("enteredDropZone");
1030
+ }
1031
+ }
1032
+ } else {
1033
+ if (this.$button.classList.contains("govuk-file-upload-button--dragging")) {
1034
+ this.hideDraggingState();
1035
+ this.$announcements.innerText = this.i18n.t("leftDropZone");
1036
+ }
1037
+ }
1038
+ }
1039
+ }
1040
+ showDraggingState() {
1041
+ this.$button.classList.add("govuk-file-upload-button--dragging");
1042
+ }
1043
+ hideDraggingState() {
1044
+ this.$button.classList.remove("govuk-file-upload-button--dragging");
1045
+ }
1046
+ onDrop(event) {
1047
+ event.preventDefault();
1048
+ if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
1049
+ this.$input.files = event.dataTransfer.files;
1050
+ this.$input.dispatchEvent(new CustomEvent("change"));
1051
+ this.hideDraggingState();
1052
+ }
1053
+ }
1054
+ onChange() {
1055
+ const fileCount = this.$input.files.length;
1056
+ if (fileCount === 0) {
1057
+ this.$status.innerText = this.i18n.t("noFileChosen");
1058
+ this.$button.classList.add("govuk-file-upload-button--empty");
1059
+ } else {
1060
+ if (fileCount === 1) {
1061
+ this.$status.innerText = this.$input.files[0].name;
1062
+ } else {
1063
+ this.$status.innerText = this.i18n.t("multipleFilesChosen", {
1064
+ count: fileCount
1065
+ });
1066
+ }
1067
+ this.$button.classList.remove("govuk-file-upload-button--empty");
1068
+ }
1069
+ }
1070
+ findLabel() {
1071
+ const $label = document.querySelector(`label[for="${this.$input.id}"]`);
1072
+ if (!$label) {
1073
+ throw new ElementError({
1074
+ component: FileUpload,
1075
+ identifier: `Field label (\`<label for=${this.$input.id}>\`)`
1076
+ });
1077
+ }
1078
+ return $label;
1079
+ }
1080
+ onClick() {
1081
+ this.$input.click();
1082
+ }
1083
+ observeDisabledState() {
1084
+ const observer = new MutationObserver(mutationList => {
1085
+ for (const mutation of mutationList) {
1086
+ if (mutation.type === "attributes" && mutation.attributeName === "disabled") {
1087
+ this.updateDisabledState();
1088
+ }
1089
+ }
1090
+ });
1091
+ observer.observe(this.$input, {
1092
+ attributes: true
1093
+ });
1094
+ }
1095
+ updateDisabledState() {
1096
+ this.$button.disabled = this.$input.disabled;
1097
+ this.$root.classList.toggle("govuk-drop-zone--disabled", this.$button.disabled);
1098
+ }
1099
+ }
1100
+
1101
+ FileUpload.moduleName = "govuk-file-upload";
1102
+
1103
+ FileUpload.defaults = Object.freeze({
1104
+ i18n: {
1105
+ chooseFilesButton: "Choose file",
1106
+ dropInstruction: "or drop file",
1107
+ noFileChosen: "No file chosen",
1108
+ multipleFilesChosen: {
1109
+ one: "%{count} file chosen",
1110
+ other: "%{count} files chosen"
1111
+ },
1112
+ enteredDropZone: "Entered drop zone",
1113
+ leftDropZone: "Left drop zone"
1114
+ }
1115
+ });
1116
+
1117
+ FileUpload.schema = Object.freeze({
1118
+ properties: {
1119
+ i18n: {
1120
+ type: "object"
1121
+ }
1122
+ }
1123
+ });
1124
+
1125
+ function isContainingFiles(dataTransfer) {
1126
+ const hasNoTypesInfo = dataTransfer.types.length === 0;
1127
+ const isDraggingFiles = dataTransfer.types.some(type => type === "Files");
1128
+ return hasNoTypesInfo || isDraggingFiles;
1129
+ }
1130
+
918
1131
  /**
919
1132
  * Password input component
920
1133
  *
@@ -1259,7 +1472,7 @@ function initAll(config) {
1259
1472
  console.log(new SupportError);
1260
1473
  return;
1261
1474
  }
1262
- const components = [ [ Button, config.button ], [ CharacterCount, config.characterCount ], [ Checkboxes ], [ ErrorSummary, config.errorSummary ], [ Radios ], [ PasswordInput, config.passwordInput ] ];
1475
+ const components = [ [ Button, config.button ], [ CharacterCount, config.characterCount ], [ Checkboxes ], [ ErrorSummary, config.errorSummary ], [ FileUpload, config.fileUpload ], [ Radios ], [ PasswordInput, config.passwordInput ] ];
1263
1476
  const $scope = (_config$scope = config.scope) != null ? _config$scope : document;
1264
1477
  components.forEach(([Component, config]) => {
1265
1478
  const $elements = $scope.querySelectorAll(`[data-module="${Component.moduleName}"]`);
@@ -1,11 +1,11 @@
1
- import{Controller as e}from"@hotwired/stimulus";function t(e=document.body){return!!e&&e.classList.contains("govuk-frontend-supported")}function n(e){return!!e&&"object"==typeof e&&!function(e){return Array.isArray(e)}(e)}function s(e,t){return`${e.moduleName}: ${t}`}class i extends Error{constructor(...e){super(...e),this.name="GOVUKFrontendError"}}class o extends i{constructor(e=document.body){const t="noModule"in HTMLScriptElement.prototype?'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet':"GOV.UK Frontend is not supported in this browser";super(e?t:'GOV.UK Frontend initialised without `<script type="module">`'),this.name="SupportError"}}class r extends i{constructor(...e){super(...e),this.name="ConfigError"}}class a extends i{constructor(e){let t="string"==typeof e?e:"";if("object"==typeof e){const{component:n,identifier:i,element:o,expectedType:r}=e;t=i,t+=o?` is not of type ${null!=r?r:"HTMLElement"}`:" not found",t=s(n,t)}super(t),this.name="ElementError"}}class l extends i{constructor(e){super("string"==typeof e?e:s(e,"Root element (`$root`) already initialised")),this.name="InitError"}}class u{get $root(){return this._$root}constructor(e){this._$root=void 0;const t=this.constructor;if("string"!=typeof t.moduleName)throw new l("`moduleName` not defined in component");if(!(e instanceof t.elementType))throw new a({element:e,component:t,identifier:"Root element (`$root`)",expectedType:t.elementType.name});this._$root=e,t.checkSupport(),this.checkInitialised();const n=t.moduleName;this.$root.setAttribute(`data-${n}-init`,"")}checkInitialised(){const e=this.constructor,t=e.moduleName;if(t&&function(e,t){return e instanceof HTMLElement&&e.hasAttribute(`data-${t}-init`)}(this.$root,t))throw new l(e)}static checkSupport(){if(!t())throw new o}}u.elementType=HTMLElement;const c=Symbol.for("configOverride");class h extends u{[c](e){return{}}get config(){return this._config}constructor(e,t){super(e),this._config=void 0;const i=this.constructor;if(!n(i.defaults))throw new r(s(i,"Config passed as parameter into constructor but no defaults defined"));const o=function(e,t){if(!n(e.schema))throw new r(s(e,"Config passed as parameter into constructor but no schema defined"));const i={},o=Object.entries(e.schema.properties);for(const n of o){const[s,o]=n,r=s.toString();r in t&&(i[r]=d(t[r],o)),"object"===(null==o?void 0:o.type)&&(i[r]=m(e.schema,t,s))}return i}(i,this._$root.dataset);this._config=p(i.defaults,null!=t?t:{},this[c](o),o)}}function d(e,t){const n=e?e.trim():"";let s,i=null==t?void 0:t.type;switch(i||(["true","false"].includes(n)&&(i="boolean"),n.length>0&&isFinite(Number(n))&&(i="number")),i){case"boolean":s="true"===n;break;case"number":s=Number(n);break;default:s=e}return s}function p(...e){const t={};for(const s of e)for(const e of Object.keys(s)){const i=t[e],o=s[e];n(i)&&n(o)?t[e]=p(i,o):t[e]=o}return t}function m(e,t,s){const i=e.properties[s];if("object"!==(null==i?void 0:i.type))return;const o={[s]:{}};for(const[e,i]of Object.entries(t)){let t=o;const r=e.split(".");for(const[o,a]of r.entries())n(t)&&(o<r.length-1?(n(t[a])||(t[a]={}),t=t[a]):e!==s&&(t[a]=d(i)))}return o[s]}class f{constructor(e={},t={}){var n;this.translations=void 0,this.locale=void 0,this.translations=e,this.locale=null!=(n=t.locale)?n:document.documentElement.lang||"en"}t(e,t){if(!e)throw new Error("i18n: lookup key missing");let n=this.translations[e];if("number"==typeof(null==t?void 0:t.count)&&"object"==typeof n){const s=n[this.getPluralSuffix(e,t.count)];s&&(n=s)}if("string"==typeof n){if(n.match(/%{(.\S+)}/)){if(!t)throw new Error("i18n: cannot replace placeholders in string if no option data provided");return this.replacePlaceholders(n,t)}return n}return e}replacePlaceholders(e,t){const n=Intl.NumberFormat.supportedLocalesOf(this.locale).length?new Intl.NumberFormat(this.locale):void 0;return e.replace(/%{(.\S+)}/g,function(e,s){if(Object.prototype.hasOwnProperty.call(t,s)){const e=t[s];return!1===e||"number"!=typeof e&&"string"!=typeof e?"":"number"==typeof e?n?n.format(e):`${e}`:e}throw new Error(`i18n: no data found to replace ${e} placeholder in string`)})}hasIntlPluralRulesSupport(){return Boolean("PluralRules"in window.Intl&&Intl.PluralRules.supportedLocalesOf(this.locale).length)}getPluralSuffix(e,t){if(t=Number(t),!isFinite(t))return"other";const n=this.translations[e],s=this.hasIntlPluralRulesSupport()?new Intl.PluralRules(this.locale).select(t):this.selectPluralFormUsingFallbackRules(t);if("object"==typeof n){if(s in n)return s;if("other"in n)return console.warn(`i18n: Missing plural form ".${s}" for "${this.locale}" locale. Falling back to ".other".`),"other"}throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`)}selectPluralFormUsingFallbackRules(e){e=Math.abs(Math.floor(e));const t=this.getPluralRulesForLocale();return t?f.pluralRules[t](e):"other"}getPluralRulesForLocale(){const e=this.locale.split("-")[0];for(const t in f.pluralRulesMap){const n=f.pluralRulesMap[t];if(n.includes(this.locale)||n.includes(e))return t}}}f.pluralRulesMap={arabic:["ar"],chinese:["my","zh","id","ja","jv","ko","ms","th","vi"],french:["hy","bn","fr","gu","hi","fa","pa","zu"],german:["af","sq","az","eu","bg","ca","da","nl","en","et","fi","ka","de","el","hu","lb","no","so","sw","sv","ta","te","tr","ur"],irish:["ga"],russian:["ru","uk"],scottish:["gd"],spanish:["pt-PT","it","es"],welsh:["cy"]},f.pluralRules={arabic:e=>0===e?"zero":1===e?"one":2===e?"two":e%100>=3&&e%100<=10?"few":e%100>=11&&e%100<=99?"many":"other",chinese:()=>"other",french:e=>0===e||1===e?"one":"other",german:e=>1===e?"one":"other",irish:e=>1===e?"one":2===e?"two":e>=3&&e<=6?"few":e>=7&&e<=10?"many":"other",russian(e){const t=e%100,n=t%10;return 1===n&&11!==t?"one":n>=2&&n<=4&&!(t>=12&&t<=14)?"few":0===n||n>=5&&n<=9||t>=11&&t<=14?"many":"other"},scottish:e=>1===e||11===e?"one":2===e||12===e?"two":e>=3&&e<=10||e>=13&&e<=19?"few":"other",spanish:e=>1===e?"one":e%1e6==0&&0!==e?"many":"other",welsh:e=>0===e?"zero":1===e?"one":2===e?"two":3===e?"few":6===e?"many":"other"};
1
+ import{Controller as e}from"@hotwired/stimulus";function t(e=document.body){return!!e&&e.classList.contains("govuk-frontend-supported")}function n(e){return!!e&&"object"==typeof e&&!function(e){return Array.isArray(e)}(e)}function i(e,t){return`${e.moduleName}: ${t}`}class s extends Error{constructor(...e){super(...e),this.name="GOVUKFrontendError"}}class o extends s{constructor(e=document.body){const t="noModule"in HTMLScriptElement.prototype?'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet':"GOV.UK Frontend is not supported in this browser";super(e?t:'GOV.UK Frontend initialised without `<script type="module">`'),this.name="SupportError"}}class r extends s{constructor(...e){super(...e),this.name="ConfigError"}}class a extends s{constructor(e){let t="string"==typeof e?e:"";if("object"==typeof e){const{component:n,identifier:s,element:o,expectedType:r}=e;t=s,t+=o?` is not of type ${null!=r?r:"HTMLElement"}`:" not found",t=i(n,t)}super(t),this.name="ElementError"}}class l extends s{constructor(e){super("string"==typeof e?e:i(e,"Root element (`$root`) already initialised")),this.name="InitError"}}class u{get $root(){return this._$root}constructor(e){this._$root=void 0;const t=this.constructor;if("string"!=typeof t.moduleName)throw new l("`moduleName` not defined in component");if(!(e instanceof t.elementType))throw new a({element:e,component:t,identifier:"Root element (`$root`)",expectedType:t.elementType.name});this._$root=e,t.checkSupport(),this.checkInitialised();const n=t.moduleName;this.$root.setAttribute(`data-${n}-init`,"")}checkInitialised(){const e=this.constructor,t=e.moduleName;if(t&&function(e,t){return e instanceof HTMLElement&&e.hasAttribute(`data-${t}-init`)}(this.$root,t))throw new l(e)}static checkSupport(){if(!t())throw new o}}u.elementType=HTMLElement;const c=Symbol.for("configOverride");class d extends u{[c](e){return{}}get config(){return this._config}constructor(e,t){super(e),this._config=void 0;const s=this.constructor;if(!n(s.defaults))throw new r(i(s,"Config passed as parameter into constructor but no defaults defined"));const o=function(e,t){if(!n(e.schema))throw new r(i(e,"Config passed as parameter into constructor but no schema defined"));const s={},o=Object.entries(e.schema.properties);for(const n of o){const[i,o]=n,r=i.toString();r in t&&(s[r]=h(t[r],o)),"object"===(null==o?void 0:o.type)&&(s[r]=m(e.schema,t,i))}return s}(s,this._$root.dataset);this._config=p(s.defaults,null!=t?t:{},this[c](o),o)}}function h(e,t){const n=e?e.trim():"";let i,s=null==t?void 0:t.type;switch(s||(["true","false"].includes(n)&&(s="boolean"),n.length>0&&isFinite(Number(n))&&(s="number")),s){case"boolean":i="true"===n;break;case"number":i=Number(n);break;default:i=e}return i}function p(...e){const t={};for(const i of e)for(const e of Object.keys(i)){const s=t[e],o=i[e];n(s)&&n(o)?t[e]=p(s,o):t[e]=o}return t}function m(e,t,i){const s=e.properties[i];if("object"!==(null==s?void 0:s.type))return;const o={[i]:{}};for(const[e,s]of Object.entries(t)){let t=o;const r=e.split(".");for(const[o,a]of r.entries())n(t)&&(o<r.length-1?(n(t[a])||(t[a]={}),t=t[a]):e!==i&&(t[a]=h(s)))}return o[i]}class g{constructor(e={},t={}){var n;this.translations=void 0,this.locale=void 0,this.translations=e,this.locale=null!=(n=t.locale)?n:document.documentElement.lang||"en"}t(e,t){if(!e)throw new Error("i18n: lookup key missing");let n=this.translations[e];if("number"==typeof(null==t?void 0:t.count)&&"object"==typeof n){const i=n[this.getPluralSuffix(e,t.count)];i&&(n=i)}if("string"==typeof n){if(n.match(/%{(.\S+)}/)){if(!t)throw new Error("i18n: cannot replace placeholders in string if no option data provided");return this.replacePlaceholders(n,t)}return n}return e}replacePlaceholders(e,t){const n=Intl.NumberFormat.supportedLocalesOf(this.locale).length?new Intl.NumberFormat(this.locale):void 0;return e.replace(/%{(.\S+)}/g,function(e,i){if(Object.prototype.hasOwnProperty.call(t,i)){const e=t[i];return!1===e||"number"!=typeof e&&"string"!=typeof e?"":"number"==typeof e?n?n.format(e):`${e}`:e}throw new Error(`i18n: no data found to replace ${e} placeholder in string`)})}hasIntlPluralRulesSupport(){return Boolean("PluralRules"in window.Intl&&Intl.PluralRules.supportedLocalesOf(this.locale).length)}getPluralSuffix(e,t){if(t=Number(t),!isFinite(t))return"other";const n=this.translations[e],i=this.hasIntlPluralRulesSupport()?new Intl.PluralRules(this.locale).select(t):this.selectPluralFormUsingFallbackRules(t);if("object"==typeof n){if(i in n)return i;if("other"in n)return console.warn(`i18n: Missing plural form ".${i}" for "${this.locale}" locale. Falling back to ".other".`),"other"}throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`)}selectPluralFormUsingFallbackRules(e){e=Math.abs(Math.floor(e));const t=this.getPluralRulesForLocale();return t?g.pluralRules[t](e):"other"}getPluralRulesForLocale(){const e=this.locale.split("-")[0];for(const t in g.pluralRulesMap){const n=g.pluralRulesMap[t];if(n.includes(this.locale)||n.includes(e))return t}}}g.pluralRulesMap={arabic:["ar"],chinese:["my","zh","id","ja","jv","ko","ms","th","vi"],french:["hy","bn","fr","gu","hi","fa","pa","zu"],german:["af","sq","az","eu","bg","ca","da","nl","en","et","fi","ka","de","el","hu","lb","no","so","sw","sv","ta","te","tr","ur"],irish:["ga"],russian:["ru","uk"],scottish:["gd"],spanish:["pt-PT","it","es"],welsh:["cy"]},g.pluralRules={arabic:e=>0===e?"zero":1===e?"one":2===e?"two":e%100>=3&&e%100<=10?"few":e%100>=11&&e%100<=99?"many":"other",chinese:()=>"other",french:e=>0===e||1===e?"one":"other",german:e=>1===e?"one":"other",irish:e=>1===e?"one":2===e?"two":e>=3&&e<=6?"few":e>=7&&e<=10?"many":"other",russian(e){const t=e%100,n=t%10;return 1===n&&11!==t?"one":n>=2&&n<=4&&!(t>=12&&t<=14)?"few":0===n||n>=5&&n<=9||t>=11&&t<=14?"many":"other"},scottish:e=>1===e||11===e?"one":2===e||12===e?"two":e>=3&&e<=10||e>=13&&e<=19?"few":"other",spanish:e=>1===e?"one":e%1e6==0&&0!==e?"many":"other",welsh:e=>0===e?"zero":1===e?"one":2===e?"two":3===e?"few":6===e?"many":"other"};
2
2
  /**
3
3
  * JavaScript enhancements for the Button component
4
4
  *
5
5
  * @preserve
6
6
  * @augments ConfigurableComponent<ButtonConfig>
7
7
  */
8
- class g extends h{constructor(e,t={}){super(e,t),this.debounceFormSubmitTimer=null,this.$root.addEventListener("keydown",e=>this.handleKeyDown(e)),this.$root.addEventListener("click",e=>this.debounce(e))}handleKeyDown(e){const t=e.target;" "===e.key&&t instanceof HTMLElement&&"button"===t.getAttribute("role")&&(e.preventDefault(),t.click())}debounce(e){if(this.config.preventDoubleClick)return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=window.setTimeout(()=>{this.debounceFormSubmitTimer=null},1e3))}}function v(e,t){const n=e.closest(`[${t}]`);return n?n.getAttribute(t):null}
8
+ class f extends d{constructor(e,t={}){super(e,t),this.debounceFormSubmitTimer=null,this.$root.addEventListener("keydown",e=>this.handleKeyDown(e)),this.$root.addEventListener("click",e=>this.debounce(e))}handleKeyDown(e){const t=e.target;" "===e.key&&t instanceof HTMLElement&&"button"===t.getAttribute("role")&&(e.preventDefault(),t.click())}debounce(e){if(this.config.preventDoubleClick)return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=window.setTimeout(()=>{this.debounceFormSubmitTimer=null},1e3))}}function v(e,t){const n=e.closest(`[${t}]`);return n?n.getAttribute(t):null}
9
9
  /**
10
10
  * Character count component
11
11
  *
@@ -18,13 +18,13 @@ class g extends h{constructor(e,t={}){super(e,t),this.debounceFormSubmitTimer=nu
18
18
  *
19
19
  * @preserve
20
20
  * @augments ConfigurableComponent<CharacterCountConfig>
21
- */g.moduleName="govuk-button",g.defaults=Object.freeze({preventDoubleClick:!1}),g.schema=Object.freeze({properties:{preventDoubleClick:{type:"boolean"}}});class w extends h{[c](e){let t={};return("maxwords"in e||"maxlength"in e)&&(t={maxlength:void 0,maxwords:void 0}),t}constructor(e,t={}){var n,i;super(e,t),this.$textarea=void 0,this.$visibleCountMessage=void 0,this.$screenReaderCountMessage=void 0,this.lastInputTimestamp=null,this.lastInputValue="",this.valueChecker=null,this.i18n=void 0,this.maxLength=void 0;const o=this.$root.querySelector(".govuk-js-character-count");if(!(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement))throw new a({component:w,element:o,expectedType:"HTMLTextareaElement or HTMLInputElement",identifier:"Form field (`.govuk-js-character-count`)"});const l=function(e,t){const n=[];for(const[s,i]of Object.entries(e)){const e=[];if(Array.isArray(i)){for(const{required:n,errorMessage:s}of i)n.every(e=>!!t[e])||e.push(s);"anyOf"!==s||i.length-e.length>=1||n.push(...e)}}return n}(w.schema,this.config);if(l[0])throw new r(s(w,l[0]));this.i18n=new f(this.config.i18n,{locale:v(this.$root,"lang")}),this.maxLength=null!=(n=null!=(i=this.config.maxwords)?i:this.config.maxlength)?n:1/0,this.$textarea=o;const u=`${this.$textarea.id}-info`,c=document.getElementById(u);if(!c)throw new a({component:w,element:c,identifier:`Count message (\`id="${u}"\`)`});this.$errorMessage=this.$root.querySelector(".govuk-error-message"),`${c.textContent}`.match(/^\s*$/)&&(c.textContent=this.i18n.t("textareaDescription",{count:this.maxLength})),this.$textarea.insertAdjacentElement("afterend",c);const h=document.createElement("div");h.className="govuk-character-count__sr-status govuk-visually-hidden",h.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=h,c.insertAdjacentElement("afterend",h);const d=document.createElement("div");d.className=c.className,d.classList.add("govuk-character-count__status"),d.setAttribute("aria-hidden","true"),this.$visibleCountMessage=d,c.insertAdjacentElement("afterend",d),c.classList.add("govuk-visually-hidden"),this.$textarea.removeAttribute("maxlength"),this.bindChangeEvents(),window.addEventListener("pageshow",()=>this.updateCountMessage()),this.updateCountMessage()}bindChangeEvents(){this.$textarea.addEventListener("keyup",()=>this.handleKeyUp()),this.$textarea.addEventListener("focus",()=>this.handleFocus()),this.$textarea.addEventListener("blur",()=>this.handleBlur())}handleKeyUp(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}handleFocus(){this.valueChecker=window.setInterval(()=>{(!this.lastInputTimestamp||Date.now()-500>=this.lastInputTimestamp)&&this.updateIfValueChanged()},1e3)}handleBlur(){this.valueChecker&&window.clearInterval(this.valueChecker)}updateIfValueChanged(){this.$textarea.value!==this.lastInputValue&&(this.lastInputValue=this.$textarea.value,this.updateCountMessage())}updateCountMessage(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}updateVisibleCountMessage(){const e=this.maxLength-this.count(this.$textarea.value)<0;this.$visibleCountMessage.classList.toggle("govuk-character-count__message--disabled",!this.isOverThreshold()),this.$errorMessage||this.$textarea.classList.toggle("govuk-textarea--error",e),this.$visibleCountMessage.classList.toggle("govuk-error-message",e),this.$visibleCountMessage.classList.toggle("govuk-hint",!e),this.$visibleCountMessage.textContent=this.getCountMessage()}updateScreenReaderCountMessage(){this.isOverThreshold()?this.$screenReaderCountMessage.removeAttribute("aria-hidden"):this.$screenReaderCountMessage.setAttribute("aria-hidden","true"),this.$screenReaderCountMessage.textContent=this.getCountMessage()}count(e){if(this.config.maxwords){var t;return(null!=(t=e.match(/\S+/g))?t:[]).length}return e.length}getCountMessage(){const e=this.maxLength-this.count(this.$textarea.value),t=this.config.maxwords?"words":"characters";return this.formatCountMessage(e,t)}formatCountMessage(e,t){if(0===e)return this.i18n.t(`${t}AtLimit`);const n=e<0?"OverLimit":"UnderLimit";return this.i18n.t(`${t}${n}`,{count:Math.abs(e)})}isOverThreshold(){if(!this.config.threshold)return!0;const e=this.count(this.$textarea.value);return this.maxLength*this.config.threshold/100<=e}}w.moduleName="govuk-character-count",w.defaults=Object.freeze({threshold:0,i18n:{charactersUnderLimit:{one:"You have %{count} character remaining",other:"You have %{count} characters remaining"},charactersAtLimit:"You have 0 characters remaining",charactersOverLimit:{one:"You have %{count} character too many",other:"You have %{count} characters too many"},wordsUnderLimit:{one:"You have %{count} word remaining",other:"You have %{count} words remaining"},wordsAtLimit:"You have 0 words remaining",wordsOverLimit:{one:"You have %{count} word too many",other:"You have %{count} words too many"},textareaDescription:{other:""}}}),w.schema=Object.freeze({properties:{i18n:{type:"object"},maxwords:{type:"number"},maxlength:{type:"number"},threshold:{type:"number"}},anyOf:[{required:["maxwords"],errorMessage:'Either "maxlength" or "maxwords" must be provided'},{required:["maxlength"],errorMessage:'Either "maxlength" or "maxwords" must be provided'}]});
21
+ */f.moduleName="govuk-button",f.defaults=Object.freeze({preventDoubleClick:!1}),f.schema=Object.freeze({properties:{preventDoubleClick:{type:"boolean"}}});class b extends d{[c](e){let t={};return("maxwords"in e||"maxlength"in e)&&(t={maxlength:void 0,maxwords:void 0}),t}constructor(e,t={}){var n,s;super(e,t),this.$textarea=void 0,this.$visibleCountMessage=void 0,this.$screenReaderCountMessage=void 0,this.lastInputTimestamp=null,this.lastInputValue="",this.valueChecker=null,this.i18n=void 0,this.maxLength=void 0;const o=this.$root.querySelector(".govuk-js-character-count");if(!(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement))throw new a({component:b,element:o,expectedType:"HTMLTextareaElement or HTMLInputElement",identifier:"Form field (`.govuk-js-character-count`)"});const l=function(e,t){const n=[];for(const[i,s]of Object.entries(e)){const e=[];if(Array.isArray(s)){for(const{required:n,errorMessage:i}of s)n.every(e=>!!t[e])||e.push(i);"anyOf"!==i||s.length-e.length>=1||n.push(...e)}}return n}(b.schema,this.config);if(l[0])throw new r(i(b,l[0]));this.i18n=new g(this.config.i18n,{locale:v(this.$root,"lang")}),this.maxLength=null!=(n=null!=(s=this.config.maxwords)?s:this.config.maxlength)?n:1/0,this.$textarea=o;const u=`${this.$textarea.id}-info`,c=document.getElementById(u);if(!c)throw new a({component:b,element:c,identifier:`Count message (\`id="${u}"\`)`});this.$errorMessage=this.$root.querySelector(".govuk-error-message"),`${c.textContent}`.match(/^\s*$/)&&(c.textContent=this.i18n.t("textareaDescription",{count:this.maxLength})),this.$textarea.insertAdjacentElement("afterend",c);const d=document.createElement("div");d.className="govuk-character-count__sr-status govuk-visually-hidden",d.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=d,c.insertAdjacentElement("afterend",d);const h=document.createElement("div");h.className=c.className,h.classList.add("govuk-character-count__status"),h.setAttribute("aria-hidden","true"),this.$visibleCountMessage=h,c.insertAdjacentElement("afterend",h),c.classList.add("govuk-visually-hidden"),this.$textarea.removeAttribute("maxlength"),this.bindChangeEvents(),window.addEventListener("pageshow",()=>this.updateCountMessage()),this.updateCountMessage()}bindChangeEvents(){this.$textarea.addEventListener("keyup",()=>this.handleKeyUp()),this.$textarea.addEventListener("focus",()=>this.handleFocus()),this.$textarea.addEventListener("blur",()=>this.handleBlur())}handleKeyUp(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}handleFocus(){this.valueChecker=window.setInterval(()=>{(!this.lastInputTimestamp||Date.now()-500>=this.lastInputTimestamp)&&this.updateIfValueChanged()},1e3)}handleBlur(){this.valueChecker&&window.clearInterval(this.valueChecker)}updateIfValueChanged(){this.$textarea.value!==this.lastInputValue&&(this.lastInputValue=this.$textarea.value,this.updateCountMessage())}updateCountMessage(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}updateVisibleCountMessage(){const e=this.maxLength-this.count(this.$textarea.value)<0;this.$visibleCountMessage.classList.toggle("govuk-character-count__message--disabled",!this.isOverThreshold()),this.$errorMessage||this.$textarea.classList.toggle("govuk-textarea--error",e),this.$visibleCountMessage.classList.toggle("govuk-error-message",e),this.$visibleCountMessage.classList.toggle("govuk-hint",!e),this.$visibleCountMessage.textContent=this.getCountMessage()}updateScreenReaderCountMessage(){this.isOverThreshold()?this.$screenReaderCountMessage.removeAttribute("aria-hidden"):this.$screenReaderCountMessage.setAttribute("aria-hidden","true"),this.$screenReaderCountMessage.textContent=this.getCountMessage()}count(e){if(this.config.maxwords){var t;return(null!=(t=e.match(/\S+/g))?t:[]).length}return e.length}getCountMessage(){const e=this.maxLength-this.count(this.$textarea.value),t=this.config.maxwords?"words":"characters";return this.formatCountMessage(e,t)}formatCountMessage(e,t){if(0===e)return this.i18n.t(`${t}AtLimit`);const n=e<0?"OverLimit":"UnderLimit";return this.i18n.t(`${t}${n}`,{count:Math.abs(e)})}isOverThreshold(){if(!this.config.threshold)return!0;const e=this.count(this.$textarea.value);return this.maxLength*this.config.threshold/100<=e}}b.moduleName="govuk-character-count",b.defaults=Object.freeze({threshold:0,i18n:{charactersUnderLimit:{one:"You have %{count} character remaining",other:"You have %{count} characters remaining"},charactersAtLimit:"You have 0 characters remaining",charactersOverLimit:{one:"You have %{count} character too many",other:"You have %{count} characters too many"},wordsUnderLimit:{one:"You have %{count} word remaining",other:"You have %{count} words remaining"},wordsAtLimit:"You have 0 words remaining",wordsOverLimit:{one:"You have %{count} word too many",other:"You have %{count} words too many"},textareaDescription:{other:""}}}),b.schema=Object.freeze({properties:{i18n:{type:"object"},maxwords:{type:"number"},maxlength:{type:"number"},threshold:{type:"number"}},anyOf:[{required:["maxwords"],errorMessage:'Either "maxlength" or "maxwords" must be provided'},{required:["maxlength"],errorMessage:'Either "maxlength" or "maxwords" must be provided'}]});
22
22
  /**
23
23
  * Checkboxes component
24
24
  *
25
25
  * @preserve
26
26
  */
27
- class b extends u{constructor(e){super(e),this.$inputs=void 0;const t=this.$root.querySelectorAll('input[type="checkbox"]');if(!t.length)throw new a({component:b,identifier:'Form inputs (`<input type="checkbox">`)'});this.$inputs=t,this.$inputs.forEach(e=>{const t=e.getAttribute("data-aria-controls");if(t){if(!document.getElementById(t))throw new a({component:b,identifier:`Conditional reveal (\`id="${t}"\`)`});e.setAttribute("aria-controls",t),e.removeAttribute("data-aria-controls")}}),window.addEventListener("pageshow",()=>this.syncAllConditionalReveals()),this.syncAllConditionalReveals(),this.$root.addEventListener("click",e=>this.handleClick(e))}syncAllConditionalReveals(){this.$inputs.forEach(e=>this.syncConditionalRevealWithInputState(e))}syncConditionalRevealWithInputState(e){const t=e.getAttribute("aria-controls");if(!t)return;const n=document.getElementById(t);if(null!=n&&n.classList.contains("govuk-checkboxes__conditional")){const t=e.checked;e.setAttribute("aria-expanded",t.toString()),n.classList.toggle("govuk-checkboxes__conditional--hidden",!t)}}unCheckAllInputsExcept(e){document.querySelectorAll(`input[type="checkbox"][name="${e.name}"]`).forEach(t=>{e.form===t.form&&t!==e&&(t.checked=!1,this.syncConditionalRevealWithInputState(t))})}unCheckExclusiveInputs(e){document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${e.name}"]`).forEach(t=>{e.form===t.form&&(t.checked=!1,this.syncConditionalRevealWithInputState(t))})}handleClick(e){const t=e.target;if(!(t instanceof HTMLInputElement)||"checkbox"!==t.type)return;if(t.getAttribute("aria-controls")&&this.syncConditionalRevealWithInputState(t),!t.checked)return;"exclusive"===t.getAttribute("data-behaviour")?this.unCheckAllInputsExcept(t):this.unCheckExclusiveInputs(t)}}b.moduleName="govuk-checkboxes";
27
+ class w extends u{constructor(e){super(e),this.$inputs=void 0;const t=this.$root.querySelectorAll('input[type="checkbox"]');if(!t.length)throw new a({component:w,identifier:'Form inputs (`<input type="checkbox">`)'});this.$inputs=t,this.$inputs.forEach(e=>{const t=e.getAttribute("data-aria-controls");if(t){if(!document.getElementById(t))throw new a({component:w,identifier:`Conditional reveal (\`id="${t}"\`)`});e.setAttribute("aria-controls",t),e.removeAttribute("data-aria-controls")}}),window.addEventListener("pageshow",()=>this.syncAllConditionalReveals()),this.syncAllConditionalReveals(),this.$root.addEventListener("click",e=>this.handleClick(e))}syncAllConditionalReveals(){this.$inputs.forEach(e=>this.syncConditionalRevealWithInputState(e))}syncConditionalRevealWithInputState(e){const t=e.getAttribute("aria-controls");if(!t)return;const n=document.getElementById(t);if(null!=n&&n.classList.contains("govuk-checkboxes__conditional")){const t=e.checked;e.setAttribute("aria-expanded",t.toString()),n.classList.toggle("govuk-checkboxes__conditional--hidden",!t)}}unCheckAllInputsExcept(e){document.querySelectorAll(`input[type="checkbox"][name="${e.name}"]`).forEach(t=>{e.form===t.form&&t!==e&&(t.checked=!1,this.syncConditionalRevealWithInputState(t))})}unCheckExclusiveInputs(e){document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${e.name}"]`).forEach(t=>{e.form===t.form&&(t.checked=!1,this.syncConditionalRevealWithInputState(t))})}handleClick(e){const t=e.target;if(!(t instanceof HTMLInputElement)||"checkbox"!==t.type)return;if(t.getAttribute("aria-controls")&&this.syncConditionalRevealWithInputState(t),!t.checked)return;"exclusive"===t.getAttribute("data-behaviour")?this.unCheckAllInputsExcept(t):this.unCheckExclusiveInputs(t)}}w.moduleName="govuk-checkboxes";
28
28
  /**
29
29
  * Error summary component
30
30
  *
@@ -34,18 +34,24 @@ class b extends u{constructor(e){super(e),this.$inputs=void 0;const t=this.$root
34
34
  * @preserve
35
35
  * @augments ConfigurableComponent<ErrorSummaryConfig>
36
36
  */
37
- class y extends h{constructor(e,t={}){super(e,t),this.config.disableAutoFocus||function(e,t={}){var n;const s=e.getAttribute("tabindex");function i(){var n;null==(n=t.onBlur)||n.call(e),s||e.removeAttribute("tabindex")}s||e.setAttribute("tabindex","-1"),e.addEventListener("focus",function(){e.addEventListener("blur",i,{once:!0})},{once:!0}),null==(n=t.onBeforeFocus)||n.call(e),e.focus()}(this.$root),this.$root.addEventListener("click",e=>this.handleClick(e))}handleClick(e){const t=e.target;t&&this.focusTarget(t)&&e.preventDefault()}focusTarget(e){if(!(e instanceof HTMLAnchorElement))return!1;const t=function(e){if(e.includes("#"))return e.split("#").pop()}(e.href);if(!t)return!1;const n=document.getElementById(t);if(!n)return!1;const s=this.getAssociatedLegendOrLabel(n);return!!s&&(s.scrollIntoView(),n.focus({preventScroll:!0}),!0)}getAssociatedLegendOrLabel(e){var t;const n=e.closest("fieldset");if(n){const t=n.getElementsByTagName("legend");if(t.length){const n=t[0];if(e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type))return n;const s=n.getBoundingClientRect().top,i=e.getBoundingClientRect();if(i.height&&window.innerHeight){if(i.top+i.height-s<window.innerHeight/2)return n}}}return null!=(t=document.querySelector(`label[for='${e.getAttribute("id")}']`))?t:e.closest("label")}}y.moduleName="govuk-error-summary",y.defaults=Object.freeze({disableAutoFocus:!1}),y.schema=Object.freeze({properties:{disableAutoFocus:{type:"boolean"}}});
37
+ class y extends d{constructor(e,t={}){super(e,t),this.config.disableAutoFocus||function(e,t={}){var n;const i=e.getAttribute("tabindex");function s(){var n;null==(n=t.onBlur)||n.call(e),i||e.removeAttribute("tabindex")}i||e.setAttribute("tabindex","-1"),e.addEventListener("focus",function(){e.addEventListener("blur",s,{once:!0})},{once:!0}),null==(n=t.onBeforeFocus)||n.call(e),e.focus()}(this.$root),this.$root.addEventListener("click",e=>this.handleClick(e))}handleClick(e){const t=e.target;t&&this.focusTarget(t)&&e.preventDefault()}focusTarget(e){if(!(e instanceof HTMLAnchorElement))return!1;const t=function(e){if(e.includes("#"))return e.split("#").pop()}(e.href);if(!t)return!1;const n=document.getElementById(t);if(!n)return!1;const i=this.getAssociatedLegendOrLabel(n);return!!i&&(i.scrollIntoView(),n.focus({preventScroll:!0}),!0)}getAssociatedLegendOrLabel(e){var t;const n=e.closest("fieldset");if(n){const t=n.getElementsByTagName("legend");if(t.length){const n=t[0];if(e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type))return n;const i=n.getBoundingClientRect().top,s=e.getBoundingClientRect();if(s.height&&window.innerHeight){if(s.top+s.height-i<window.innerHeight/2)return n}}}return null!=(t=document.querySelector(`label[for='${e.getAttribute("id")}']`))?t:e.closest("label")}}y.moduleName="govuk-error-summary",y.defaults=Object.freeze({disableAutoFocus:!1}),y.schema=Object.freeze({properties:{disableAutoFocus:{type:"boolean"}}});
38
+ /**
39
+ * File upload component
40
+ *
41
+ * @preserve
42
+ * @augments ConfigurableComponent<FileUploadConfig>
43
+ */
44
+ class $ extends d{constructor(e,t={}){super(e,t),this.$input=void 0,this.$button=void 0,this.$status=void 0,this.i18n=void 0,this.id=void 0,this.$announcements=void 0,this.enteredAnotherElement=void 0;const n=this.$root.querySelector("input");if(null===n)throw new a({component:$,identifier:'File inputs (`<input type="file">`)'});if("file"!==n.type)throw new a(i($,'File input (`<input type="file">`) attribute (`type`) is not `file`'));if(this.$input=n,this.$input.setAttribute("hidden","true"),!this.$input.id)throw new a({component:$,identifier:'File input (`<input type="file">`) attribute (`id`)'});this.id=this.$input.id,this.i18n=new g(this.config.i18n,{locale:v(this.$root,"lang")});const s=this.findLabel();s.id||(s.id=`${this.id}-label`),this.$input.id=`${this.id}-input`;const o=document.createElement("button");o.classList.add("govuk-file-upload-button"),o.type="button",o.id=this.id,o.classList.add("govuk-file-upload-button--empty");const r=this.$input.getAttribute("aria-describedby");r&&o.setAttribute("aria-describedby",r);const l=document.createElement("span");l.className="govuk-body govuk-file-upload-button__status",l.setAttribute("aria-live","polite"),l.innerText=this.i18n.t("noFileChosen"),o.appendChild(l);const u=document.createElement("span");u.className="govuk-visually-hidden",u.innerText=", ",u.id=`${this.id}-comma`,o.appendChild(u);const c=document.createElement("span");c.className="govuk-file-upload-button__pseudo-button-container";const d=document.createElement("span");d.className="govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button",d.innerText=this.i18n.t("chooseFilesButton"),c.appendChild(d),c.insertAdjacentText("beforeend"," ");const h=document.createElement("span");h.className="govuk-body govuk-file-upload-button__instruction",h.innerText=this.i18n.t("dropInstruction"),c.appendChild(h),o.appendChild(c),o.setAttribute("aria-labelledby",`${s.id} ${u.id} ${o.id}`),o.addEventListener("click",this.onClick.bind(this)),o.addEventListener("dragover",e=>{e.preventDefault()}),this.$root.insertAdjacentElement("afterbegin",o),this.$input.setAttribute("tabindex","-1"),this.$input.setAttribute("aria-hidden","true"),this.$button=o,this.$status=l,this.$input.addEventListener("change",this.onChange.bind(this)),this.updateDisabledState(),this.observeDisabledState(),this.$announcements=document.createElement("span"),this.$announcements.classList.add("govuk-file-upload-announcements"),this.$announcements.classList.add("govuk-visually-hidden"),this.$announcements.setAttribute("aria-live","assertive"),this.$root.insertAdjacentElement("afterend",this.$announcements),this.$button.addEventListener("drop",this.onDrop.bind(this)),document.addEventListener("dragenter",this.updateDropzoneVisibility.bind(this)),document.addEventListener("dragenter",()=>{this.enteredAnotherElement=!0}),document.addEventListener("dragleave",()=>{this.enteredAnotherElement||this.$button.disabled||(this.hideDraggingState(),this.$announcements.innerText=this.i18n.t("leftDropZone")),this.enteredAnotherElement=!1})}updateDropzoneVisibility(e){this.$button.disabled||e.target instanceof Node&&(this.$root.contains(e.target)?e.dataTransfer&&k(e.dataTransfer)&&(this.$button.classList.contains("govuk-file-upload-button--dragging")||(this.showDraggingState(),this.$announcements.innerText=this.i18n.t("enteredDropZone"))):this.$button.classList.contains("govuk-file-upload-button--dragging")&&(this.hideDraggingState(),this.$announcements.innerText=this.i18n.t("leftDropZone")))}showDraggingState(){this.$button.classList.add("govuk-file-upload-button--dragging")}hideDraggingState(){this.$button.classList.remove("govuk-file-upload-button--dragging")}onDrop(e){e.preventDefault(),e.dataTransfer&&k(e.dataTransfer)&&(this.$input.files=e.dataTransfer.files,this.$input.dispatchEvent(new CustomEvent("change")),this.hideDraggingState())}onChange(){const e=this.$input.files.length;0===e?(this.$status.innerText=this.i18n.t("noFileChosen"),this.$button.classList.add("govuk-file-upload-button--empty")):(this.$status.innerText=1===e?this.$input.files[0].name:this.i18n.t("multipleFilesChosen",{count:e}),this.$button.classList.remove("govuk-file-upload-button--empty"))}findLabel(){const e=document.querySelector(`label[for="${this.$input.id}"]`);if(!e)throw new a({component:$,identifier:`Field label (\`<label for=${this.$input.id}>\`)`});return e}onClick(){this.$input.click()}observeDisabledState(){new MutationObserver(e=>{for(const t of e)"attributes"===t.type&&"disabled"===t.attributeName&&this.updateDisabledState()}).observe(this.$input,{attributes:!0})}updateDisabledState(){this.$button.disabled=this.$input.disabled,this.$root.classList.toggle("govuk-drop-zone--disabled",this.$button.disabled)}}function k(e){const t=0===e.types.length,n=e.types.some(e=>"Files"===e);return t||n}
38
45
  /**
39
46
  * Password input component
40
47
  *
41
48
  * @preserve
42
49
  * @augments ConfigurableComponent<PasswordInputConfig>
43
- */
44
- class $ extends h{constructor(e,t={}){super(e,t),this.i18n=void 0,this.$input=void 0,this.$showHideButton=void 0,this.$screenReaderStatusMessage=void 0;const n=this.$root.querySelector(".govuk-js-password-input-input");if(!(n instanceof HTMLInputElement))throw new a({component:$,element:n,expectedType:"HTMLInputElement",identifier:"Form field (`.govuk-js-password-input-input`)"});if("password"!==n.type)throw new a("Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.");const s=this.$root.querySelector(".govuk-js-password-input-toggle");if(!(s instanceof HTMLButtonElement))throw new a({component:$,element:s,expectedType:"HTMLButtonElement",identifier:"Button (`.govuk-js-password-input-toggle`)"});if("button"!==s.type)throw new a("Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.");this.$input=n,this.$showHideButton=s,this.i18n=new f(this.config.i18n,{locale:v(this.$root,"lang")}),this.$showHideButton.removeAttribute("hidden");const i=document.createElement("div");i.className="govuk-password-input__sr-status govuk-visually-hidden",i.setAttribute("aria-live","polite"),this.$screenReaderStatusMessage=i,this.$input.insertAdjacentElement("afterend",i),this.$showHideButton.addEventListener("click",this.toggle.bind(this)),this.$input.form&&this.$input.form.addEventListener("submit",()=>this.hide()),window.addEventListener("pageshow",e=>{e.persisted&&"password"!==this.$input.type&&this.hide()}),this.hide()}toggle(e){e.preventDefault(),"password"!==this.$input.type?this.hide():this.show()}show(){this.setType("text")}hide(){this.setType("password")}setType(e){if(e===this.$input.type)return;this.$input.setAttribute("type",e);const t="password"===e,n=t?"show":"hide",s=t?"passwordHidden":"passwordShown";this.$showHideButton.innerText=this.i18n.t(`${n}Password`),this.$showHideButton.setAttribute("aria-label",this.i18n.t(`${n}PasswordAriaLabel`)),this.$screenReaderStatusMessage.innerText=this.i18n.t(`${s}Announcement`)}}$.moduleName="govuk-password-input",$.defaults=Object.freeze({i18n:{showPassword:"Show",hidePassword:"Hide",showPasswordAriaLabel:"Show password",hidePasswordAriaLabel:"Hide password",passwordShownAnnouncement:"Your password is visible",passwordHiddenAnnouncement:"Your password is hidden"}}),$.schema=Object.freeze({properties:{i18n:{type:"object"}}});
50
+ */$.moduleName="govuk-file-upload",$.defaults=Object.freeze({i18n:{chooseFilesButton:"Choose file",dropInstruction:"or drop file",noFileChosen:"No file chosen",multipleFilesChosen:{one:"%{count} file chosen",other:"%{count} files chosen"},enteredDropZone:"Entered drop zone",leftDropZone:"Left drop zone"}}),$.schema=Object.freeze({properties:{i18n:{type:"object"}}});class x extends d{constructor(e,t={}){super(e,t),this.i18n=void 0,this.$input=void 0,this.$showHideButton=void 0,this.$screenReaderStatusMessage=void 0;const n=this.$root.querySelector(".govuk-js-password-input-input");if(!(n instanceof HTMLInputElement))throw new a({component:x,element:n,expectedType:"HTMLInputElement",identifier:"Form field (`.govuk-js-password-input-input`)"});if("password"!==n.type)throw new a("Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.");const i=this.$root.querySelector(".govuk-js-password-input-toggle");if(!(i instanceof HTMLButtonElement))throw new a({component:x,element:i,expectedType:"HTMLButtonElement",identifier:"Button (`.govuk-js-password-input-toggle`)"});if("button"!==i.type)throw new a("Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.");this.$input=n,this.$showHideButton=i,this.i18n=new g(this.config.i18n,{locale:v(this.$root,"lang")}),this.$showHideButton.removeAttribute("hidden");const s=document.createElement("div");s.className="govuk-password-input__sr-status govuk-visually-hidden",s.setAttribute("aria-live","polite"),this.$screenReaderStatusMessage=s,this.$input.insertAdjacentElement("afterend",s),this.$showHideButton.addEventListener("click",this.toggle.bind(this)),this.$input.form&&this.$input.form.addEventListener("submit",()=>this.hide()),window.addEventListener("pageshow",e=>{e.persisted&&"password"!==this.$input.type&&this.hide()}),this.hide()}toggle(e){e.preventDefault(),"password"!==this.$input.type?this.hide():this.show()}show(){this.setType("text")}hide(){this.setType("password")}setType(e){if(e===this.$input.type)return;this.$input.setAttribute("type",e);const t="password"===e,n=t?"show":"hide",i=t?"passwordHidden":"passwordShown";this.$showHideButton.innerText=this.i18n.t(`${n}Password`),this.$showHideButton.setAttribute("aria-label",this.i18n.t(`${n}PasswordAriaLabel`)),this.$screenReaderStatusMessage.innerText=this.i18n.t(`${i}Announcement`)}}x.moduleName="govuk-password-input",x.defaults=Object.freeze({i18n:{showPassword:"Show",hidePassword:"Hide",showPasswordAriaLabel:"Show password",hidePasswordAriaLabel:"Hide password",passwordShownAnnouncement:"Your password is visible",passwordHiddenAnnouncement:"Your password is hidden"}}),x.schema=Object.freeze({properties:{i18n:{type:"object"}}});
45
51
  /**
46
52
  * Radios component
47
53
  *
48
54
  * @preserve
49
55
  */
50
- class x extends u{constructor(e){super(e),this.$inputs=void 0;const t=this.$root.querySelectorAll('input[type="radio"]');if(!t.length)throw new a({component:x,identifier:'Form inputs (`<input type="radio">`)'});this.$inputs=t,this.$inputs.forEach(e=>{const t=e.getAttribute("data-aria-controls");if(t){if(!document.getElementById(t))throw new a({component:x,identifier:`Conditional reveal (\`id="${t}"\`)`});e.setAttribute("aria-controls",t),e.removeAttribute("data-aria-controls")}}),window.addEventListener("pageshow",()=>this.syncAllConditionalReveals()),this.syncAllConditionalReveals(),this.$root.addEventListener("click",e=>this.handleClick(e))}syncAllConditionalReveals(){this.$inputs.forEach(e=>this.syncConditionalRevealWithInputState(e))}syncConditionalRevealWithInputState(e){const t=e.getAttribute("aria-controls");if(!t)return;const n=document.getElementById(t);if(null!=n&&n.classList.contains("govuk-radios__conditional")){const t=e.checked;e.setAttribute("aria-expanded",t.toString()),n.classList.toggle("govuk-radios__conditional--hidden",!t)}}handleClick(e){const t=e.target;if(!(t instanceof HTMLInputElement)||"radio"!==t.type)return;const n=document.querySelectorAll('input[type="radio"][aria-controls]'),s=t.form,i=t.name;n.forEach(e=>{const t=e.form===s;e.name===i&&t&&this.syncConditionalRevealWithInputState(e)})}}x.moduleName="govuk-radios";class k extends e{static targets=["preview","destroy"];static values={mimeTypes:Array};connect(){this.counter=0,this.initialPreviewContent=null,this.onUploadFlag=!1}onUpload(e){this.onUploadFlag=!0,this.hasDestroyTarget&&(this.destroyTarget.value=!1),this.previewTarget.removeAttribute("hidden"),this.hasPreviewTarget&&(e.currentTarget.files.length>0?this.showPreview(e.currentTarget.files[0]):this.setPreviewContent(this.initialPreviewContent))}setDestroy(e){e.preventDefault(),this.initialPreviewContent&&this.onUploadFlag?(this.onUploadFlag=!1,this.setPreviewContent(this.initialPreviewContent)):(this.hasDestroyTarget&&(this.destroyTarget.value=!0),this.hasPreviewTarget&&(this.previewTarget.setAttribute("hidden",""),this.setPreviewContent("")),this.previousInput&&this.previousInput.toggleAttribute("disabled",!0)),this.fileInput.value=""}setPreviewContent(e){this.filenameTag&&(this.filenameTag.innerText=text)}drop(e){e.preventDefault();const t=this.fileForEvent(e,this.mimeTypesValue);if(t){const e=new DataTransfer;e.items.add(t),this.fileInput.files=e.files,this.fileInput.dispatchEvent(new Event("change"))}this.counter=0,this.element.classList.remove("droppable")}dragover(e){e.preventDefault()}dragenter(e){e.preventDefault(),0===this.counter&&this.element.classList.add("droppable"),this.counter++}dragleave(e){e.preventDefault(),this.counter--,0===this.counter&&this.element.classList.remove("droppable")}get fileInput(){return this.element.querySelector("input[type='file']")}get previousInput(){return this.element.querySelector(`input[type='hidden'][name='${this.fileInput.name}']`)}get filenameTag(){return this.hasPreviewTarget?this.previewTarget.querySelector("p.preview-filename"):null}showPreview(e){const t=new FileReader;t.onload=t=>{this.filenameTag&&(this.filenameTag.innerText=e.name)},t.readAsDataURL(e)}fileForEvent(e,t){const n=e=>t.indexOf(e.type)>-1;let s;if(e.dataTransfer.items){const t=[...e.dataTransfer.items].find(n);t&&(s=t.getAsFile())}else s=[...e.dataTransfer.files].find(n);return s}}const C=[{identifier:"govuk-document-field",controllerConstructor:class extends k{connect(){super.connect(),this.initialPreviewContent=this.filenameTag.text}setPreviewContent(e){this.filenameTag.innerText=e}showPreview(e){const t=new FileReader;t.onload=t=>{this.filenameTag&&(this.filenameTag.innerText=e.name)},t.readAsDataURL(e)}get filenameTag(){return this.previewTarget.querySelector("p.preview-filename")}}},{identifier:"govuk-image-field",controllerConstructor:class extends k{connect(){super.connect(),this.initialPreviewContent=this.imageTag.getAttribute("src")}setPreviewContent(e){this.imageTag.src=e}showPreview(e){const t=new FileReader;t.onload=e=>{this.imageTag.src=e.target.result},t.readAsDataURL(e)}get imageTag(){return this.previewTarget.querySelector("img")}}}];function T(e){let n;if(e=void 0!==e?e:{},!t())return void console.log(new o);const s=[[g,e.button],[w,e.characterCount],[b],[y,e.errorSummary],[x],[$,e.passwordInput]],i=null!=(n=e.scope)?n:document;s.forEach(([e,t])=>{i.querySelectorAll(`[data-module="${e.moduleName}"]`).forEach(n=>{try{"defaults"in e?new e(n,t):new e(n)}catch(e){console.log(e)}})})}export{g as Button,w as CharacterCount,b as Checkboxes,y as ErrorSummary,$ as PasswordInput,x as Radios,C as default,T as initAll};
56
+ class C extends u{constructor(e){super(e),this.$inputs=void 0;const t=this.$root.querySelectorAll('input[type="radio"]');if(!t.length)throw new a({component:C,identifier:'Form inputs (`<input type="radio">`)'});this.$inputs=t,this.$inputs.forEach(e=>{const t=e.getAttribute("data-aria-controls");if(t){if(!document.getElementById(t))throw new a({component:C,identifier:`Conditional reveal (\`id="${t}"\`)`});e.setAttribute("aria-controls",t),e.removeAttribute("data-aria-controls")}}),window.addEventListener("pageshow",()=>this.syncAllConditionalReveals()),this.syncAllConditionalReveals(),this.$root.addEventListener("click",e=>this.handleClick(e))}syncAllConditionalReveals(){this.$inputs.forEach(e=>this.syncConditionalRevealWithInputState(e))}syncConditionalRevealWithInputState(e){const t=e.getAttribute("aria-controls");if(!t)return;const n=document.getElementById(t);if(null!=n&&n.classList.contains("govuk-radios__conditional")){const t=e.checked;e.setAttribute("aria-expanded",t.toString()),n.classList.toggle("govuk-radios__conditional--hidden",!t)}}handleClick(e){const t=e.target;if(!(t instanceof HTMLInputElement)||"radio"!==t.type)return;const n=document.querySelectorAll('input[type="radio"][aria-controls]'),i=t.form,s=t.name;n.forEach(e=>{const t=e.form===i;e.name===s&&t&&this.syncConditionalRevealWithInputState(e)})}}C.moduleName="govuk-radios";class E extends e{static targets=["preview","destroy"];static values={mimeTypes:Array};connect(){this.counter=0,this.initialPreviewContent=null,this.onUploadFlag=!1}onUpload(e){this.onUploadFlag=!0,this.hasDestroyTarget&&(this.destroyTarget.value=!1),this.previewTarget.removeAttribute("hidden"),this.hasPreviewTarget&&(e.currentTarget.files.length>0?this.showPreview(e.currentTarget.files[0]):this.setPreviewContent(this.initialPreviewContent))}setDestroy(e){e.preventDefault(),this.initialPreviewContent&&this.onUploadFlag?(this.onUploadFlag=!1,this.setPreviewContent(this.initialPreviewContent)):(this.hasDestroyTarget&&(this.destroyTarget.value=!0),this.hasPreviewTarget&&(this.previewTarget.setAttribute("hidden",""),this.setPreviewContent("")),this.previousInput&&this.previousInput.toggleAttribute("disabled",!0)),this.fileInput.value=""}setPreviewContent(e){this.filenameTag&&(this.filenameTag.innerText=text)}drop(e){e.preventDefault();const t=this.fileForEvent(e,this.mimeTypesValue);if(t){const e=new DataTransfer;e.items.add(t),this.fileInput.files=e.files,this.fileInput.dispatchEvent(new Event("change"))}this.counter=0,this.element.classList.remove("droppable")}dragover(e){e.preventDefault()}dragenter(e){e.preventDefault(),0===this.counter&&this.element.classList.add("droppable"),this.counter++}dragleave(e){e.preventDefault(),this.counter--,0===this.counter&&this.element.classList.remove("droppable")}get fileInput(){return this.element.querySelector("input[type='file']")}get previousInput(){return this.element.querySelector(`input[type='hidden'][name='${this.fileInput.name}']`)}get filenameTag(){return this.hasPreviewTarget?this.previewTarget.querySelector("p.preview-filename"):null}showPreview(e){const t=new FileReader;t.onload=t=>{this.filenameTag&&(this.filenameTag.innerText=e.name)},t.readAsDataURL(e)}fileForEvent(e,t){const n=e=>t.indexOf(e.type)>-1;let i;if(e.dataTransfer.items){const t=[...e.dataTransfer.items].find(n);t&&(i=t.getAsFile())}else i=[...e.dataTransfer.files].find(n);return i}}const T=[{identifier:"govuk-document-field",controllerConstructor:class extends E{connect(){super.connect(),this.initialPreviewContent=this.filenameTag.text}setPreviewContent(e){this.filenameTag.innerText=e}showPreview(e){const t=new FileReader;t.onload=t=>{this.filenameTag&&(this.filenameTag.innerText=e.name)},t.readAsDataURL(e)}get filenameTag(){return this.previewTarget.querySelector("p.preview-filename")}}},{identifier:"govuk-image-field",controllerConstructor:class extends E{connect(){super.connect(),this.initialPreviewContent=this.imageTag.getAttribute("src")}setPreviewContent(e){this.imageTag.src=e}showPreview(e){const t=new FileReader;t.onload=e=>{this.imageTag.src=e.target.result},t.readAsDataURL(e)}get imageTag(){return this.previewTarget.querySelector("img")}}}];function L(e){let n;if(e=void 0!==e?e:{},!t())return void console.log(new o);const i=[[f,e.button],[b,e.characterCount],[w],[y,e.errorSummary],[$,e.fileUpload],[C],[x,e.passwordInput]],s=null!=(n=e.scope)?n:document;i.forEach(([e,t])=>{s.querySelectorAll(`[data-module="${e.moduleName}"]`).forEach(n=>{try{"defaults"in e?new e(n,t):new e(n)}catch(e){console.log(e)}})})}export{f as Button,b as CharacterCount,w as Checkboxes,y as ErrorSummary,x as PasswordInput,C as Radios,T as default,L as initAll};
51
57
  //# sourceMappingURL=formbuilder.min.js.map