@ministryofjustice/frontend 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/moj/all.jquery.min.js +1 -1
- package/moj/all.js +81 -81
- package/moj/all.mjs +3 -3
- package/moj/components/add-another/add-another.js +10 -10
- package/moj/components/add-another/add-another.mjs +10 -10
- package/moj/components/filter-toggle-button/filter-toggle-button.js +8 -8
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs +8 -8
- package/moj/components/form-validator/form-validator.js +4 -4
- package/moj/components/form-validator/form-validator.mjs +4 -4
- package/moj/components/multi-file-upload/multi-file-upload.js +23 -23
- package/moj/components/multi-file-upload/multi-file-upload.mjs +23 -23
- package/moj/components/multi-select/multi-select.js +7 -7
- package/moj/components/multi-select/multi-select.mjs +7 -7
- package/moj/components/password-reveal/password-reveal.js +4 -4
- package/moj/components/password-reveal/password-reveal.mjs +4 -4
- package/moj/components/rich-text-editor/rich-text-editor.js +6 -6
- package/moj/components/rich-text-editor/rich-text-editor.mjs +6 -6
- package/moj/components/search-toggle/search-toggle.js +8 -8
- package/moj/components/search-toggle/search-toggle.mjs +8 -8
- package/moj/components/sortable-table/sortable-table.js +11 -11
- package/moj/components/sortable-table/sortable-table.mjs +11 -11
- package/moj/moj-frontend.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function SearchToggle(options) {
|
|
2
2
|
this.options = options;
|
|
3
|
-
this.container =
|
|
4
|
-
this.toggleButtonContainer =
|
|
3
|
+
this.container = $(this.options.search.container);
|
|
4
|
+
this.toggleButtonContainer = $(this.options.toggleButton.container);
|
|
5
5
|
|
|
6
6
|
if (this.container.data('moj-search-toggle-initialised')) {
|
|
7
7
|
return
|
|
@@ -12,15 +12,15 @@ function SearchToggle(options) {
|
|
|
12
12
|
const svg =
|
|
13
13
|
'<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>';
|
|
14
14
|
|
|
15
|
-
this.toggleButton =
|
|
15
|
+
this.toggleButton = $(
|
|
16
16
|
`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
|
|
17
17
|
${this.options.toggleButton.text} ${svg}
|
|
18
18
|
</button>`
|
|
19
19
|
);
|
|
20
|
-
this.toggleButton.on('click',
|
|
20
|
+
this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'));
|
|
21
21
|
this.toggleButtonContainer.append(this.toggleButton);
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
$(document).on('click', this.onDocumentClick.bind(this));
|
|
23
|
+
$(document).on('focusin', this.onDocumentClick.bind(this));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
SearchToggle.prototype.showMenu = function () {
|
|
@@ -44,8 +44,8 @@ SearchToggle.prototype.onToggleButtonClick = function () {
|
|
|
44
44
|
|
|
45
45
|
SearchToggle.prototype.onDocumentClick = function (e) {
|
|
46
46
|
if (
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
!$.contains(this.toggleButtonContainer[0], e.target) &&
|
|
48
|
+
!$.contains(this.container[0], e.target)
|
|
49
49
|
) {
|
|
50
50
|
this.hideMenu();
|
|
51
51
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function SortableTable(params) {
|
|
8
|
-
this.table =
|
|
8
|
+
this.table = $(params.table);
|
|
9
9
|
|
|
10
10
|
if (this.table.data('moj-search-toggle-initialised')) {
|
|
11
11
|
return
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
this.createHeadingButtons();
|
|
19
19
|
this.createStatusBox();
|
|
20
20
|
this.initialiseSortedColumn();
|
|
21
|
-
this.table.on('click', 'th button',
|
|
21
|
+
this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
SortableTable.prototype.setupOptions = function (params) {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
const headings = this.table.find('thead th');
|
|
33
33
|
let heading;
|
|
34
34
|
for (let i = 0; i < headings.length; i++) {
|
|
35
|
-
heading =
|
|
35
|
+
heading = $(headings[i]);
|
|
36
36
|
if (heading.attr('aria-sort')) {
|
|
37
37
|
this.createHeadingButton(heading, i);
|
|
38
38
|
}
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
|
|
42
42
|
SortableTable.prototype.createHeadingButton = function (heading, i) {
|
|
43
43
|
const text = heading.text();
|
|
44
|
-
const button =
|
|
44
|
+
const button = $(`<button type="button" data-index="${i}">${text}</button>`);
|
|
45
45
|
heading.text('');
|
|
46
46
|
heading.append(button);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
SortableTable.prototype.createStatusBox = function () {
|
|
50
|
-
this.status =
|
|
50
|
+
this.status = $(
|
|
51
51
|
'<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'
|
|
52
52
|
);
|
|
53
53
|
this.table.parent().append(this.status);
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
|
|
62
62
|
.first()
|
|
63
63
|
.each((index, el) => {
|
|
64
|
-
const sortDirection =
|
|
65
|
-
const columnNumber =
|
|
64
|
+
const sortDirection = $(el).attr('aria-sort');
|
|
65
|
+
const columnNumber = $(el).find('button').attr('data-index');
|
|
66
66
|
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
67
67
|
this.addRows(sortedRows);
|
|
68
68
|
});
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
72
72
|
const columnNumber = e.currentTarget.getAttribute('data-index');
|
|
73
|
-
const sortDirection =
|
|
73
|
+
const sortDirection = $(e.currentTarget).parent().attr('aria-sort');
|
|
74
74
|
let newSortDirection;
|
|
75
75
|
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
76
76
|
newSortDirection = 'ascending';
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
82
82
|
this.addRows(sortedRows);
|
|
83
83
|
this.removeButtonStates();
|
|
84
|
-
this.updateButtonState(
|
|
84
|
+
this.updateButtonState($(e.currentTarget), newSortDirection);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
SortableTable.prototype.sort = function (rows, columnNumber, sortDirection) {
|
|
115
115
|
const newRows = rows.sort(
|
|
116
116
|
function (rowA, rowB) {
|
|
117
|
-
const tdA =
|
|
118
|
-
const tdB =
|
|
117
|
+
const tdA = $(rowA).find('td,th').eq(columnNumber);
|
|
118
|
+
const tdB = $(rowB).find('td,th').eq(columnNumber);
|
|
119
119
|
|
|
120
120
|
const valueA =
|
|
121
121
|
sortDirection === 'ascending'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function SortableTable(params) {
|
|
2
|
-
this.table =
|
|
2
|
+
this.table = $(params.table);
|
|
3
3
|
|
|
4
4
|
if (this.table.data('moj-search-toggle-initialised')) {
|
|
5
5
|
return
|
|
@@ -12,7 +12,7 @@ function SortableTable(params) {
|
|
|
12
12
|
this.createHeadingButtons();
|
|
13
13
|
this.createStatusBox();
|
|
14
14
|
this.initialiseSortedColumn();
|
|
15
|
-
this.table.on('click', 'th button',
|
|
15
|
+
this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
SortableTable.prototype.setupOptions = function (params) {
|
|
@@ -26,7 +26,7 @@ SortableTable.prototype.createHeadingButtons = function () {
|
|
|
26
26
|
const headings = this.table.find('thead th');
|
|
27
27
|
let heading;
|
|
28
28
|
for (let i = 0; i < headings.length; i++) {
|
|
29
|
-
heading =
|
|
29
|
+
heading = $(headings[i]);
|
|
30
30
|
if (heading.attr('aria-sort')) {
|
|
31
31
|
this.createHeadingButton(heading, i);
|
|
32
32
|
}
|
|
@@ -35,13 +35,13 @@ SortableTable.prototype.createHeadingButtons = function () {
|
|
|
35
35
|
|
|
36
36
|
SortableTable.prototype.createHeadingButton = function (heading, i) {
|
|
37
37
|
const text = heading.text();
|
|
38
|
-
const button =
|
|
38
|
+
const button = $(`<button type="button" data-index="${i}">${text}</button>`);
|
|
39
39
|
heading.text('');
|
|
40
40
|
heading.append(button);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
SortableTable.prototype.createStatusBox = function () {
|
|
44
|
-
this.status =
|
|
44
|
+
this.status = $(
|
|
45
45
|
'<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'
|
|
46
46
|
);
|
|
47
47
|
this.table.parent().append(this.status);
|
|
@@ -55,8 +55,8 @@ SortableTable.prototype.initialiseSortedColumn = function () {
|
|
|
55
55
|
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
|
|
56
56
|
.first()
|
|
57
57
|
.each((index, el) => {
|
|
58
|
-
const sortDirection =
|
|
59
|
-
const columnNumber =
|
|
58
|
+
const sortDirection = $(el).attr('aria-sort');
|
|
59
|
+
const columnNumber = $(el).find('button').attr('data-index');
|
|
60
60
|
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
61
61
|
this.addRows(sortedRows);
|
|
62
62
|
});
|
|
@@ -64,7 +64,7 @@ SortableTable.prototype.initialiseSortedColumn = function () {
|
|
|
64
64
|
|
|
65
65
|
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
66
66
|
const columnNumber = e.currentTarget.getAttribute('data-index');
|
|
67
|
-
const sortDirection =
|
|
67
|
+
const sortDirection = $(e.currentTarget).parent().attr('aria-sort');
|
|
68
68
|
let newSortDirection;
|
|
69
69
|
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
70
70
|
newSortDirection = 'ascending';
|
|
@@ -75,7 +75,7 @@ SortableTable.prototype.onSortButtonClick = function (e) {
|
|
|
75
75
|
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
76
76
|
this.addRows(sortedRows);
|
|
77
77
|
this.removeButtonStates();
|
|
78
|
-
this.updateButtonState(
|
|
78
|
+
this.updateButtonState($(e.currentTarget), newSortDirection);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
@@ -108,8 +108,8 @@ SortableTable.prototype.getTableRowsArray = function () {
|
|
|
108
108
|
SortableTable.prototype.sort = function (rows, columnNumber, sortDirection) {
|
|
109
109
|
const newRows = rows.sort(
|
|
110
110
|
function (rowA, rowB) {
|
|
111
|
-
const tdA =
|
|
112
|
-
const tdB =
|
|
111
|
+
const tdA = $(rowA).find('td,th').eq(columnNumber);
|
|
112
|
+
const tdB = $(rowB).find('td,th').eq(columnNumber);
|
|
113
113
|
|
|
114
114
|
const valueA =
|
|
115
115
|
sortDirection === 'ascending'
|
package/moj/moj-frontend.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MOJFrontend=t.MOJFrontend||{})}(this,(function(t){"use strict";function e(t){this.container=window.jQuery(t),this.container.data("moj-add-another-initialised")||(this.container.data("moj-add-another-initialised",!0),this.container.on("click",".moj-add-another__remove-button",window.jQuery.proxy(this,"onRemoveButtonClick")),this.container.on("click",".moj-add-another__add-button",window.jQuery.proxy(this,"onAddButtonClick")),this.container.find(".moj-add-another__add-button, moj-add-another__remove-button").prop("type","button"))}function o(t,e){if(window.NodeList.prototype.forEach)return t.forEach(e);for(let o=0;o<t.length;o++)e.call(window,t[o],o,t)}function n(t,e={}){const o=t.getAttribute("tabindex");function n(){e.onBlur&&e.onBlur.call(t),o||t.removeAttribute("tabindex")}o||t.setAttribute("tabindex","-1"),t.addEventListener("focus",(function(){t.addEventListener("blur",n,{once:!0})}),{once:!0}),e.onBeforeFocus&&e.onBeforeFocus.call(t),t.focus()}function i(t,e={}){if(!t)return this;const o=Object.freeze({properties:{dismissible:{type:"boolean"},dismissText:{type:"string"},disableAutoFocus:{type:"boolean"},focusOnDismissSelector:{type:"string"}}});this.config=this.mergeConfigs({dismissible:!1,dismissText:"Dismiss",disableAutoFocus:!1},e,this.parseDataset(o,t.dataset)),this.$module=t}function s(t,e={}){if(!t)return this;const o=Object.freeze({properties:{buttonText:{type:"string"},buttonClasses:{type:"string"},alignMenu:{type:"string"}}});this.config=this.mergeConfigs({buttonText:"Actions",alignMenu:"left",buttonClasses:""},e,this.parseDataset(o,t.dataset)),this.$module=t}function a(t,e={}){if(!t)return this;const o=Object.freeze({properties:{excludedDates:{type:"string"},excludedDays:{type:"string"},leadingZeros:{type:"string"},maxDate:{type:"string"},minDate:{type:"string"},weekStartDay:{type:"string"}}});this.config=this.mergeConfigs({leadingZeros:!1,weekStartDay:"monday"},e,this.parseDataset(o,t.dataset)),this.dayLabels=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],this.monthLabels=["January","February","March","April","May","June","July","August","September","October","November","December"],this.currentDate=new Date,this.currentDate.setHours(0,0,0,0),this.calendarDays=[],this.excludedDates=[],this.excludedDays=[],this.buttonClass="moj-datepicker__button",this.selectedDayButtonClass="moj-datepicker__button--selected",this.currentDayButtonClass="moj-datepicker__button--current",this.todayButtonClass="moj-datepicker__button--today",this.$module=t,this.$input=t.querySelector(".moj-js-datepicker-input")}function r(t,e,o,n,i){this.index=e,this.row=o,this.column=n,this.button=t,this.picker=i,this.date=new Date}function u(t){this.options=t,this.container=window.jQuery(this.options.toggleButton.container),this.filterContainer=window.jQuery(this.options.filter.container),this.createToggleButton(),this.setupResponsiveChecks(),this.filterContainer.attr("tabindex","-1"),this.options.startHidden&&this.hideMenu()}function l(t){void 0!==document.createElement("div").ondrop&&"function"==typeof FormData&&function(){const t=document.createElement("input");return t.type="file",void 0!==t.files}()&&(this.defaultParams={uploadFileEntryHook:window.jQuery.noop,uploadFileExitHook:window.jQuery.noop,uploadFileErrorHook:window.jQuery.noop,fileDeleteHook:window.jQuery.noop,uploadStatusText:"Uploading files, please wait",dropzoneHintText:"Drag and drop files here or",dropzoneButtonText:"Choose files"},this.params=window.jQuery.extend({},this.defaultParams,t),this.container=window.jQuery(this.params.container),this.container.addClass("moj-multi-file-upload--enhanced"),this.feedbackContainer=this.container.find(".moj-multi-file__uploaded-files"),this.setupFileInput(),this.setupDropzone(),this.setupLabel(),this.setupStatusBox(),this.container.on("click",".moj-multi-file-upload__delete",window.jQuery.proxy(this,"onFileDeleteClick")))}function c(t){if(this.container=window.jQuery(t.container),this.container.data("moj-multi-select-initialised"))return;this.container.data("moj-multi-select-initialised",!0);const e=t.id_prefix;let o="checkboxes-all";void 0!==e&&(o=`${e}checkboxes-all`),this.toggle=window.jQuery(this.getToggleHtml(o)),this.toggleButton=this.toggle.find("input"),this.toggleButton.on("click",window.jQuery.proxy(this,"onButtonClick")),this.container.append(this.toggle),this.checkboxes=window.jQuery(t.checkboxes),this.checkboxes.on("click",window.jQuery.proxy(this,"onCheckboxClick")),this.checked=t.checked||!1}function d(t){this.el=t;const e=window.jQuery(this.el);e.data("moj-password-reveal-initialised")||(e.data("moj-password-reveal-initialised",!0),e.attr("spellcheck","false"),e.wrap('<div class="moj-password-reveal"></div>'),this.container=window.jQuery(this.el).parent(),this.createButton())}function h(t){"contentEditable"in document.documentElement&&(this.options=t,this.options.toolbar=this.options.toolbar||{bold:!1,italic:!1,underline:!1,bullets:!0,numbers:!0},this.textarea=this.options.textarea,this.container=window.jQuery(this.textarea).parent(),this.container.data("moj-rich-text-editor-initialised")||(this.container.data("moj-rich-text-editor-initialised",!0),this.createToolbar(),this.hideDefault(),this.configureToolbar(),this.keys={left:37,right:39,up:38,down:40},this.container.on("click",".moj-rich-text-editor__toolbar-button",window.jQuery.proxy(this,"onButtonClick")),this.container.find(".moj-rich-text-editor__content").on("input",window.jQuery.proxy(this,"onEditorInput")),this.container.find("label").on("click",window.jQuery.proxy(this,"onLabelClick")),this.toolbar.on("keydown",window.jQuery.proxy(this,"onToolbarKeydown"))))}function p(t){if(this.options=t,this.container=window.jQuery(this.options.search.container),this.toggleButtonContainer=window.jQuery(this.options.toggleButton.container),this.container.data("moj-search-toggle-initialised"))return;this.container.data("moj-search-toggle-initialised",!0);this.toggleButton=window.jQuery(`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">\n ${this.options.toggleButton.text} <svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>\n </button>`),this.toggleButton.on("click",window.jQuery.proxy(this,"onToggleButtonClick")),this.toggleButtonContainer.append(this.toggleButton),window.jQuery(document).on("click",this.onDocumentClick.bind(this)),window.jQuery(document).on("focusin",this.onDocumentClick.bind(this))}function f(t){this.table=window.jQuery(t.table),this.table.data("moj-search-toggle-initialised")||(this.table.data("moj-search-toggle-initialised",!0),this.setupOptions(t),this.body=this.table.find("tbody"),this.createHeadingButtons(),this.createStatusBox(),this.initialiseSortedColumn(),this.table.on("click","th button",window.jQuery.proxy(this,"onSortButtonClick")))}e.prototype.onAddButtonClick=function(t){const e=this.getNewItem();this.updateAttributes(this.getItems().length,e),this.resetItem(e);const o=this.getItems().first();this.hasRemoveButton(o)||this.createRemoveButton(o),this.getItems().last().after(e),e.find("input, textarea, select").first().focus()},e.prototype.hasRemoveButton=function(t){return t.find(".moj-add-another__remove-button").length},e.prototype.getItems=function(){return this.container.find(".moj-add-another__item")},e.prototype.getNewItem=function(){const t=this.getItems().first().clone();return this.hasRemoveButton(t)||this.createRemoveButton(t),t},e.prototype.updateAttributes=function(t,e){e.find("[data-name]").each((function(o,n){const i=n.id;n.name=window.jQuery(n).attr("data-name").replace(/%index%/,t),n.id=window.jQuery(n).attr("data-id").replace(/%index%/,t);(window.jQuery(n).siblings("label")[0]||window.jQuery(n).parents("label")[0]||e.find(`[for="${i}"]`)[0]).htmlFor=n.id}))},e.prototype.createRemoveButton=function(t){t.append('<button type="button" class="govuk-button govuk-button--secondary moj-add-another__remove-button">Remove</button>')},e.prototype.resetItem=function(t){t.find("[data-name], [data-id]").each((function(t,e){"checkbox"===e.type||"radio"===e.type?e.checked=!1:e.value=""}))},e.prototype.onRemoveButtonClick=function(t){window.jQuery(t.currentTarget).parents(".moj-add-another__item").remove();const e=this.getItems();1===e.length&&e.find(".moj-add-another__remove-button").remove(),e.each(window.jQuery.proxy((function(t,e){this.updateAttributes(t,window.jQuery(e))}),this)),this.focusHeading()},e.prototype.focusHeading=function(){this.container.find(".moj-add-another__heading").get(0).focus()},i.prototype.init=function(){"alert"!==this.$module.getAttribute("role")||this.config.disableAutoFocus||n(this.$module),this.$dismissButton=this.$module.querySelector(".moj-alert__dismiss"),this.config.dismissible&&this.$dismissButton&&(this.$dismissButton.innerHTML=this.config.dismissText,this.$dismissButton.removeAttribute("hidden"),this.$module.addEventListener("click",(t=>{this.$dismissButton.contains(t.target)&&this.dimiss()})))},i.prototype.dimiss=function(){let t;if(this.config.focusOnDismissSelector&&(t=document.querySelector(this.config.focusOnDismissSelector)),!t){const e=this.$module.nextElementSibling;e&&e.matches(".moj-alert")&&(t=e)}t||(t=function(t,e){if(!t)return;let o=t.previousElementSibling;for(;o;){if(o.matches(e))return o;o=o.previousElementSibling}}(this.$module,".moj-alert, h1, h2, h3, h4, h5, h6")),t||(t=function(t,e){if(!t)return;let o=t;for(;o;){if(o.matches(e))return o;let t=o.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}o=o.parentElement}}(this.$module,"h1, h2, h3, h4, h5, h6, main, body")),t&&n(t),this.$module.remove()},i.prototype.normaliseString=function(t,e){const o=t?t.trim():"";let n,i;switch(e&&e.type&&(i=e.type),i||(["true","false"].includes(o)&&(i="boolean"),o.length>0&&isFinite(Number(o))&&(i="number")),i){case"boolean":n="true"===o;break;case"number":n=Number(o);break;default:n=t}return n},i.prototype.parseDataset=function(t,e){const o={};for(const[n,i]of Object.entries(t.properties))n in e&&e[n]&&(o[n]=this.normaliseString(e[n],i));return o},i.prototype.mergeConfigs=function(...t){const e={};for(const o of t)for(const t of Object.keys(o)){const n=e[t],i=o[t];e[t]="object"==typeof n&&"object"==typeof i?this.mergeConfigs(n,i):i}return e},s.prototype.init=function(){if(1===this.$module.children.length){const t=this.$module.children[0];t.classList.forEach((e=>{e.startsWith("govuk-button-")&&t.classList.remove(e),t.classList.remove("moj-button-menu__item")})),this.config.buttonClasses&&t.classList.add(...this.config.buttonClasses.split(" "))}this.$module.children.length>1&&this.initMenu()},s.prototype.initMenu=function(){this.$menu=this.createMenu(),this.$module.insertAdjacentHTML("afterbegin",this.toggleTemplate()),this.setupMenuItems(),this.$menuToggle=this.$module.querySelector(":scope > button"),this.items=this.$menu.querySelectorAll("a, button"),this.$menuToggle.addEventListener("click",(t=>{this.toggleMenu(t)})),this.$module.addEventListener("keydown",(t=>{this.handleKeyDown(t)})),document.addEventListener("click",(t=>{this.$module.contains(t.target)||this.closeMenu(!1)}))},s.prototype.createMenu=function(){const t=document.createElement("ul");for(t.setAttribute("role","list"),t.hidden=!0,t.classList.add("moj-button-menu__wrapper"),"right"===this.config.alignMenu&&t.classList.add("moj-button-menu__wrapper--right"),this.$module.appendChild(t);this.$module.firstChild!==t;)t.appendChild(this.$module.firstChild);return t},s.prototype.setupMenuItems=function(){Array.from(this.$menu.children).forEach((t=>{const e=document.createElement("li");this.$menu.insertBefore(e,t),e.appendChild(t),t.setAttribute("tabindex",-1),"BUTTON"===t.tagName&&t.setAttribute("type","button"),t.classList.forEach((e=>{e.startsWith("govuk-button")&&t.classList.remove(e)})),t.addEventListener("click",(t=>{setTimeout((()=>{this.closeMenu(!1)}),50)}))}))},s.prototype.toggleTemplate=function(){return`\n <button type="button" class="govuk-button moj-button-menu__toggle-button ${this.config.buttonClasses||""}" aria-haspopup="true" aria-expanded="false">\n <span>\n ${this.config.buttonText}\n <svg width="11" height="5" viewBox="0 0 11 5" xmlns="http://www.w3.org/2000/svg">\n <path d="M5.5 0L11 5L0 5L5.5 0Z" fill="currentColor"/>\n </svg>\n </span>\n </button>`},s.prototype.isOpen=function(){return"true"===this.$menuToggle.getAttribute("aria-expanded")},s.prototype.toggleMenu=function(t){t.preventDefault();const e=0===t.detail?0:-1;this.isOpen()?this.closeMenu():this.openMenu(e)},s.prototype.openMenu=function(t=0){this.$menu.hidden=!1,this.$menuToggle.setAttribute("aria-expanded","true"),-1!==t&&this.focusItem(t)},s.prototype.closeMenu=function(t=!0){this.$menu.hidden=!0,this.$menuToggle.setAttribute("aria-expanded","false"),t&&this.$menuToggle.focus()},s.prototype.focusItem=function(t){t>=this.items.length&&(t=0),t<0&&(t=this.items.length-1);const e=this.items.item(t);e&&e.focus()},s.prototype.currentFocusIndex=function(){const t=document.activeElement;return Array.from(this.items).indexOf(t)},s.prototype.handleKeyDown=function(t){if(t.target===this.$menuToggle)switch(t.key){case"ArrowDown":t.preventDefault(),this.openMenu();break;case"ArrowUp":t.preventDefault(),this.openMenu(this.items.length-1)}if(this.$menu.contains(t.target)&&this.isOpen())switch(t.key){case"ArrowDown":t.preventDefault(),-1!==this.currentFocusIndex()&&this.focusItem(this.currentFocusIndex()+1);break;case"ArrowUp":t.preventDefault(),-1!==this.currentFocusIndex()&&this.focusItem(this.currentFocusIndex()-1);break;case"Home":t.preventDefault(),this.focusItem(0);break;case"End":t.preventDefault(),this.focusItem(this.items.length-1)}"Escape"===t.key&&this.isOpen()&&this.closeMenu(),"Tab"===t.key&&this.isOpen()&&this.closeMenu(!1)},s.prototype.parseDataset=function(t,e){const o={};for(const[n,,]of Object.entries(t.properties))n in e&&e[n]&&(o[n]=e[n]);return o},s.prototype.mergeConfigs=function(...t){const e={};for(const o of t)for(const t of Object.keys(o)){const n=e[t],i=o[t];e[t]="object"==typeof n&&"object"==typeof i?this.mergeConfigs(n,i):i}return e},a.prototype.init=function(){this.$input&&(this.$module.dataset.initialized||(this.setOptions(),this.initControls(),this.$module.setAttribute("data-initialized","true")))},a.prototype.initControls=function(){this.id=`datepicker-${this.$input.id}`,this.$dialog=this.createDialog(),this.createCalendarHeaders();const t=document.createElement("div"),e=document.createElement("div");t.classList.add("moj-datepicker__wrapper"),e.classList.add("govuk-input__wrapper"),this.$input.parentNode.insertBefore(t,this.$input),t.appendChild(e),e.appendChild(this.$input),e.insertAdjacentHTML("beforeend",this.toggleTemplate()),t.insertAdjacentElement("beforeend",this.$dialog),this.$calendarButton=this.$module.querySelector(".moj-js-datepicker-toggle"),this.$dialogTitle=this.$dialog.querySelector(".moj-js-datepicker-month-year"),this.createCalendar(),this.$prevMonthButton=this.$dialog.querySelector(".moj-js-datepicker-prev-month"),this.$prevYearButton=this.$dialog.querySelector(".moj-js-datepicker-prev-year"),this.$nextMonthButton=this.$dialog.querySelector(".moj-js-datepicker-next-month"),this.$nextYearButton=this.$dialog.querySelector(".moj-js-datepicker-next-year"),this.$cancelButton=this.$dialog.querySelector(".moj-js-datepicker-cancel"),this.$okButton=this.$dialog.querySelector(".moj-js-datepicker-ok"),this.$prevMonthButton.addEventListener("click",(t=>this.focusPreviousMonth(t,!1))),this.$prevYearButton.addEventListener("click",(t=>this.focusPreviousYear(t,!1))),this.$nextMonthButton.addEventListener("click",(t=>this.focusNextMonth(t,!1))),this.$nextYearButton.addEventListener("click",(t=>this.focusNextYear(t,!1))),this.$cancelButton.addEventListener("click",(t=>{t.preventDefault(),this.closeDialog(t)})),this.$okButton.addEventListener("click",(()=>{this.selectDate(this.currentDate)}));const o=this.$dialog.querySelectorAll('button:not([disabled="true"])');this.$firstButtonInDialog=o[0],this.$lastButtonInDialog=o[o.length-1],this.$firstButtonInDialog.addEventListener("keydown",(t=>this.firstButtonKeydown(t))),this.$lastButtonInDialog.addEventListener("keydown",(t=>this.lastButtonKeydown(t))),this.$calendarButton.addEventListener("click",(t=>this.toggleDialog(t))),this.$dialog.addEventListener("keydown",(t=>{"Escape"===t.key&&(this.closeDialog(),t.preventDefault(),t.stopPropagation())})),document.body.addEventListener("mouseup",(t=>this.backgroundClick(t))),this.updateCalendar()},a.prototype.createDialog=function(){const t=`datepicker-title-${this.$input.id}`,e=document.createElement("div");return e.id=this.id,e.setAttribute("class","moj-datepicker__dialog"),e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-labelledby",t),e.innerHTML=this.dialogTemplate(t),e.hidden=!0,e},a.prototype.createCalendar=function(){const t=this.$dialog.querySelector("tbody");let e=0;for(let o=0;o<6;o++){const n=t.insertRow(o);for(let t=0;t<7;t++){const i=document.createElement("td"),s=document.createElement("button");i.appendChild(s),n.appendChild(i);const a=new r(s,e,o,t,this);a.init(),this.calendarDays.push(a),e++}}},a.prototype.toggleTemplate=function(){return`<button class="moj-datepicker__toggle moj-js-datepicker-toggle" type="button" aria-haspopup="dialog" aria-controls="${this.id}" aria-expanded="false">\n <span class="govuk-visually-hidden">Choose date</span>\n <svg width="32" height="24" focusable="false" class="moj-datepicker-icon" aria-hidden="true" role="img" viewBox="0 0 22 22">\n <path\n fill="currentColor"\n fill-rule="evenodd"\n clip-rule="evenodd"\n d="M16.1333 2.93333H5.86668V4.4C5.86668 5.21002 5.21003 5.86667 4.40002 5.86667C3.59 5.86667 2.93335 5.21002 2.93335 4.4V2.93333H2C0.895431 2.93333 0 3.82877 0 4.93334V19.2667C0 20.3712 0.89543 21.2667 2 21.2667H20C21.1046 21.2667 22 20.3712 22 19.2667V4.93333C22 3.82876 21.1046 2.93333 20 2.93333H19.0667V4.4C19.0667 5.21002 18.41 5.86667 17.6 5.86667C16.79 5.86667 16.1333 5.21002 16.1333 4.4V2.93333ZM20.5333 8.06667H1.46665V18.8C1.46665 19.3523 1.91436 19.8 2.46665 19.8H19.5333C20.0856 19.8 20.5333 19.3523 20.5333 18.8V8.06667Z"\n ></path>\n <rect x="3.66669" width="1.46667" height="5.13333" rx="0.733333" fill="currentColor"></rect>\n <rect x="16.8667" width="1.46667" height="5.13333" rx="0.733333" fill="currentColor"></rect>\n </svg>\n </button>`},a.prototype.dialogTemplate=function(t){return`<div class="moj-datepicker__dialog-header">\n <div class="moj-datepicker__dialog-navbuttons">\n <button class="moj-datepicker__button moj-js-datepicker-prev-year">\n <span class="govuk-visually-hidden">Previous year</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1643 20L28.9572 14.2071L27.5429 12.7929L20.3358 20L27.5429 27.2071L28.9572 25.7929L23.1643 20Z" fill="currentColor"/>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M17.1643 20L22.9572 14.2071L21.5429 12.7929L14.3358 20L21.5429 27.2071L22.9572 25.7929L17.1643 20Z" fill="currentColor"/>\n </svg>\n </button>\n\n <button class="moj-datepicker__button moj-js-datepicker-prev-month">\n <span class="govuk-visually-hidden">Previous month</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M20.5729 20L25.7865 14.2071L24.5137 12.7929L18.0273 20L24.5137 27.2071L25.7865 25.7929L20.5729 20Z" fill="currentColor"/>\n </svg>\n </button>\n </div>\n\n <h2 id="${t}" class="moj-datepicker__dialog-title moj-js-datepicker-month-year" aria-live="polite">June 2020</h2>\n\n <div class="moj-datepicker__dialog-navbuttons">\n <button class="moj-datepicker__button moj-js-datepicker-next-month">\n <span class="govuk-visually-hidden">Next month</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M23.4271 20L18.2135 14.2071L19.4863 12.7929L25.9727 20L19.4863 27.2071L18.2135 25.7929L23.4271 20Z" fill="currentColor"/>\n </svg>\n </button>\n\n <button class="moj-datepicker__button moj-js-datepicker-next-year">\n <span class="govuk-visually-hidden">Next year</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M20.8357 20L15.0428 14.2071L16.4571 12.7929L23.6642 20L16.4571 27.2071L15.0428 25.7929L20.8357 20Z" fill="currentColor"/>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M26.8357 20L21.0428 14.2071L22.4571 12.7929L29.6642 20L22.4571 27.2071L21.0428 25.7929L26.8357 20Z" fill="currentColor"/>\n </svg>\n </button>\n </div>\n </div>\n\n <table class="moj-datepicker__calendar moj-js-datepicker-grid" role="grid" aria-labelledby="${t}">\n <thead>\n <tr></tr>\n </thead>\n\n <tbody></tbody>\n </table>\n\n <div class="govuk-button-group">\n <button type="button" class="govuk-button moj-js-datepicker-ok">Select</button>\n <button type="button" class="govuk-button govuk-button--secondary moj-js-datepicker-cancel">Close</button>\n </div>`},a.prototype.createCalendarHeaders=function(){this.dayLabels.forEach((t=>{const e=`<th scope="col"><span aria-hidden="true">${t.substring(0,3)}</span><span class="govuk-visually-hidden">${t}</span></th>`;this.$dialog.querySelector("thead > tr").insertAdjacentHTML("beforeend",e)}))},a.prototype.leadingZeros=function(t,e=2){let o=t.toString();for(;o.length<e;)o=`0${o}`;return o},a.prototype.setOptions=function(){this.setMinAndMaxDatesOnCalendar(),this.setExcludedDates(),this.setExcludedDays(),this.setLeadingZeros(),this.setWeekStartDay()},a.prototype.setMinAndMaxDatesOnCalendar=function(){this.config.minDate&&(this.minDate=this.formattedDateFromString(this.config.minDate,null),this.minDate&&this.currentDate<this.minDate&&(this.currentDate=this.minDate)),this.config.maxDate&&(this.maxDate=this.formattedDateFromString(this.config.maxDate,null),this.maxDate&&this.currentDate>this.maxDate&&(this.currentDate=this.maxDate))},a.prototype.setExcludedDates=function(){this.config.excludedDates&&(this.excludedDates=this.config.excludedDates.replace(/\s+/," ").split(" ").map((t=>t.includes("-")?this.parseDateRangeString(t):this.formattedDateFromString(t))).flat().filter((t=>t)))},a.prototype.parseDateRangeString=function(t){const e=[],[o,n]=t.split("-").map((t=>this.formattedDateFromString(t,null)));if(o&&n){const t=new Date(o.getTime());for(;t<=n;)e.push(new Date(t)),t.setDate(t.getDate()+1)}return e},a.prototype.setExcludedDays=function(){if(this.config.excludedDays){const t=this.dayLabels.map((t=>t.toLowerCase()));"monday"===this.config.weekStartDay&&t.unshift(t.pop()),this.excludedDays=this.config.excludedDays.replace(/\s+/," ").toLowerCase().split(" ").map((e=>t.indexOf(e))).filter((t=>-1!==t))}},a.prototype.setLeadingZeros=function(){if("boolean"!=typeof this.config.leadingZeros){if("true"===this.config.leadingZeros.toLowerCase())return void(this.config.leadingZeros=!0);"false"===this.config.leadingZeros.toLowerCase()&&(this.config.leadingZeros=!1)}},a.prototype.setWeekStartDay=function(){const t=this.config.weekStartDay;t&&"sunday"===t.toLowerCase()?(this.config.weekStartDay="sunday",this.dayLabels.unshift(this.dayLabels.pop())):this.config.weekStartDay="monday"},a.prototype.isExcludedDate=function(t){if(this.minDate&&this.minDate>t)return!0;if(this.maxDate&&this.maxDate<t)return!0;for(const e of this.excludedDates)if(t.toDateString()===e.toDateString())return!0;return!!this.excludedDays.includes(t.getDay())},a.prototype.formattedDateFromString=function(t,e=new Date){let o=null;const n=/(\d{1,2})([-/,. ])(\d{1,2})\2(\d{4})/;if(!n.test(t))return e;const i=t.match(n),s=i[1],a=i[3],r=i[4];return o=new Date(`${r}-${a}-${s}`),o instanceof Date&&!isNaN(o)?o:e},a.prototype.formattedDateFromDate=function(t){return this.config.leadingZeros?`${this.leadingZeros(t.getDate())}/${this.leadingZeros(t.getMonth()+1)}/${t.getFullYear()}`:`${t.getDate()}/${t.getMonth()+1}/${t.getFullYear()}`},a.prototype.formattedDateHuman=function(t){return`${this.dayLabels[(t.getDay()+6)%7]} ${t.getDate()} ${this.monthLabels[t.getMonth()]} ${t.getFullYear()}`},a.prototype.backgroundClick=function(t){!this.isOpen()||this.$dialog.contains(t.target)||this.$input.contains(t.target)||this.$calendarButton.contains(t.target)||(t.preventDefault(),this.closeDialog())},a.prototype.firstButtonKeydown=function(t){"Tab"===t.key&&t.shiftKey&&(this.$lastButtonInDialog.focus(),t.preventDefault())},a.prototype.lastButtonKeydown=function(t){"Tab"!==t.key||t.shiftKey||(this.$firstButtonInDialog.focus(),t.preventDefault())},a.prototype.updateCalendar=function(){this.$dialogTitle.innerHTML=`${this.monthLabels[this.currentDate.getMonth()]} ${this.currentDate.getFullYear()}`;const t=this.currentDate,e=new Date(t.getFullYear(),t.getMonth(),1);let o;o="monday"===this.config.weekStartDay?0===e.getDay()?6:e.getDay()-1:e.getDay(),e.setDate(e.getDate()-o);const n=new Date(e);for(let i=0;i<this.calendarDays.length;i++){const e=n.getMonth()!==t.getMonth(),o=this.isExcludedDate(n);this.calendarDays[i].update(n,e,o),n.setDate(n.getDate()+1)}},a.prototype.setCurrentDate=function(t=!0){const{currentDate:e}=this;if(this.calendarDays.forEach((o=>{o.button.classList.add("moj-datepicker__button"),o.button.classList.add("moj-datepicker__calendar-day"),o.button.setAttribute("tabindex",-1),o.button.classList.remove(this.selectedDayButtonClass);const n=o.date;n.setHours(0,0,0,0);const i=new Date;i.setHours(0,0,0,0),n.getTime()===e.getTime()&&t&&(o.button.setAttribute("tabindex",0),o.button.focus(),o.button.classList.add(this.selectedDayButtonClass)),this.inputDate&&n.getTime()===this.inputDate.getTime()?(o.button.classList.add(this.currentDayButtonClass),o.button.setAttribute("aria-current","date")):(o.button.classList.remove(this.currentDayButtonClass),o.button.removeAttribute("aria-current")),n.getTime()===i.getTime()?o.button.classList.add(this.todayButtonClass):o.button.classList.remove(this.todayButtonClass)})),!t){const t=this.calendarDays.filter((t=>"block"===window.getComputedStyle(t.button).display&&!t.button.disabled));t[0].button.setAttribute("tabindex",0),this.currentDate=t[0].date}},a.prototype.selectDate=function(t){if(this.isExcludedDate(t))return;this.$calendarButton.querySelector("span").innerText=`Choose date. Selected date is ${this.formattedDateHuman(t)}`,this.$input.value=this.formattedDateFromDate(t);const e=new Event("change",{bubbles:!0,cancelable:!0});this.$input.dispatchEvent(e),this.closeDialog()},a.prototype.isOpen=function(){return this.$dialog.classList.contains("moj-datepicker__dialog--open")},a.prototype.toggleDialog=function(t){t.preventDefault(),this.isOpen()?this.closeDialog():(this.setMinAndMaxDatesOnCalendar(),this.openDialog())},a.prototype.openDialog=function(){this.$dialog.hidden=!1,this.$dialog.classList.add("moj-datepicker__dialog--open"),this.$calendarButton.setAttribute("aria-expanded","true"),this.$input.offsetWidth>this.$dialog.offsetWidth&&(this.$dialog.style.right="0px"),this.$dialog.style.top=`${this.$input.offsetHeight+3}px`,this.inputDate=this.formattedDateFromString(this.$input.value),this.currentDate=this.inputDate,this.currentDate.setHours(0,0,0,0),this.updateCalendar(),this.setCurrentDate()},a.prototype.closeDialog=function(){this.$dialog.hidden=!0,this.$dialog.classList.remove("moj-datepicker__dialog--open"),this.$calendarButton.setAttribute("aria-expanded","false"),this.$calendarButton.focus()},a.prototype.goToDate=function(t,e){const o=this.currentDate;this.currentDate=t,o.getMonth()===this.currentDate.getMonth()&&o.getFullYear()===this.currentDate.getFullYear()||this.updateCalendar(),this.setCurrentDate(e)},a.prototype.focusNextDay=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()+1),this.goToDate(t)},a.prototype.focusPreviousDay=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()-1),this.goToDate(t)},a.prototype.focusNextWeek=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()+7),this.goToDate(t)},a.prototype.focusPreviousWeek=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()-7),this.goToDate(t)},a.prototype.focusFirstDayOfWeek=function(){const t=new Date(this.currentDate),e="sunday"===this.config.weekStartDay?0:1,o=t.getDay(),n=o>=e?o-e:6-o;t.setDate(t.getDate()-n),t.setHours(0,0,0,0),this.goToDate(t)},a.prototype.focusLastDayOfWeek=function(){const t=new Date(this.currentDate),e="sunday"===this.config.weekStartDay?6:0,o=t.getDay(),n=o<=e?e-o:7-o;t.setDate(t.getDate()+n),t.setHours(0,0,0,0),this.goToDate(t)},a.prototype.focusNextMonth=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setMonth(o.getMonth()+1,1),this.goToDate(o,e)},a.prototype.focusPreviousMonth=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setMonth(o.getMonth()-1,1),this.goToDate(o,e)},a.prototype.focusNextYear=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setFullYear(o.getFullYear()+1,o.getMonth(),1),this.goToDate(o,e)},a.prototype.focusPreviousYear=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setFullYear(o.getFullYear()-1,o.getMonth(),1),this.goToDate(o,e)},a.prototype.parseDataset=function(t,e){const o={};for(const[n,,]of Object.entries(t.properties))n in e&&(o[n]=e[n]);return o},a.prototype.mergeConfigs=function(...t){const e={};for(const o of t)for(const t of Object.keys(o)){const n=e[t],i=o[t];e[t]="object"==typeof n&&"object"==typeof i?this.mergeConfigs(n,i):i}return e},r.prototype.init=function(){this.button.addEventListener("keydown",this.keyPress.bind(this)),this.button.addEventListener("click",this.click.bind(this))},r.prototype.update=function(t,e,o){const n=t.getDate();let i=this.picker.formattedDateHuman(t);o?(this.button.setAttribute("aria-disabled",!0),i=`Excluded date, ${i}`):this.button.removeAttribute("aria-disabled"),this.button.style.display=e?"none":"block",this.button.setAttribute("data-testid",this.picker.formattedDateFromDate(t)),this.button.innerHTML=`<span class="govuk-visually-hidden">${i}</span><span aria-hidden="true">${n}</span>`,this.date=new Date(t)},r.prototype.click=function(t){this.picker.goToDate(this.date),this.picker.selectDate(this.date),t.stopPropagation(),t.preventDefault()},r.prototype.keyPress=function(t){let e=!0;switch(t.key){case"ArrowLeft":this.picker.focusPreviousDay();break;case"ArrowRight":this.picker.focusNextDay();break;case"ArrowUp":this.picker.focusPreviousWeek();break;case"ArrowDown":this.picker.focusNextWeek();break;case"Home":this.picker.focusFirstDayOfWeek();break;case"End":this.picker.focusLastDayOfWeek();break;case"PageUp":t.shiftKey?this.picker.focusPreviousYear(t):this.picker.focusPreviousMonth(t);break;case"PageDown":t.shiftKey?this.picker.focusNextYear(t):this.picker.focusNextMonth(t);break;default:e=!1}e&&(t.preventDefault(),t.stopPropagation())},u.prototype.setupResponsiveChecks=function(){this.mq=window.matchMedia(this.options.bigModeMediaQuery),this.mq.addListener(window.jQuery.proxy(this,"checkMode")),this.checkMode(this.mq)},u.prototype.createToggleButton=function(){this.menuButton=window.jQuery(`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`),this.menuButton.on("click",window.jQuery.proxy(this,"onMenuButtonClick")),this.container.append(this.menuButton)},u.prototype.checkMode=function(t){t.matches?this.enableBigMode():this.enableSmallMode()},u.prototype.enableBigMode=function(){this.showMenu(),this.removeCloseButton()},u.prototype.enableSmallMode=function(){this.hideMenu(),this.addCloseButton()},u.prototype.addCloseButton=function(){this.options.closeButton&&(this.closeButton=window.jQuery(`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`),this.closeButton.on("click",window.jQuery.proxy(this,"onCloseClick")),window.jQuery(this.options.closeButton.container).append(this.closeButton))},u.prototype.onCloseClick=function(){this.hideMenu(),this.menuButton.focus()},u.prototype.removeCloseButton=function(){this.closeButton&&(this.closeButton.remove(),this.closeButton=null)},u.prototype.hideMenu=function(){this.menuButton.attr("aria-expanded","false"),this.filterContainer.addClass("moj-js-hidden"),this.menuButton.text(this.options.toggleButton.showText)},u.prototype.showMenu=function(){this.menuButton.attr("aria-expanded","true"),this.filterContainer.removeClass("moj-js-hidden"),this.menuButton.text(this.options.toggleButton.hideText)},u.prototype.onMenuButtonClick=function(){this.toggle()},u.prototype.toggle=function(){"false"===this.menuButton.attr("aria-expanded")?(this.showMenu(),this.filterContainer.get(0).focus()):this.hideMenu()},l.prototype.setupDropzone=function(){this.fileInput.wrap('<div class="moj-multi-file-upload__dropzone" />'),this.dropzone=this.container.find(".moj-multi-file-upload__dropzone"),this.dropzone.on("dragover",window.jQuery.proxy(this,"onDragOver")),this.dropzone.on("dragleave",window.jQuery.proxy(this,"onDragLeave")),this.dropzone.on("drop",window.jQuery.proxy(this,"onDrop"))},l.prototype.setupLabel=function(){this.label=window.jQuery(`<label for="${this.fileInput[0].id}" class="govuk-button govuk-button--secondary">${this.params.dropzoneButtonText}</label>`),this.dropzone.append(`<p class="govuk-body">${this.params.dropzoneHintText}</p>`),this.dropzone.append(this.label)},l.prototype.setupFileInput=function(){this.fileInput=this.container.find(".moj-multi-file-upload__input"),this.fileInput.on("change",window.jQuery.proxy(this,"onFileChange")),this.fileInput.on("focus",window.jQuery.proxy(this,"onFileFocus")),this.fileInput.on("blur",window.jQuery.proxy(this,"onFileBlur"))},l.prototype.setupStatusBox=function(){this.status=window.jQuery('<div aria-live="polite" role="status" class="govuk-visually-hidden" />'),this.dropzone.append(this.status)},l.prototype.onDragOver=function(t){t.preventDefault(),this.dropzone.addClass("moj-multi-file-upload--dragover")},l.prototype.onDragLeave=function(){this.dropzone.removeClass("moj-multi-file-upload--dragover")},l.prototype.onDrop=function(t){t.preventDefault(),this.dropzone.removeClass("moj-multi-file-upload--dragover"),this.feedbackContainer.removeClass("moj-hidden"),this.status.html(this.params.uploadStatusText),this.uploadFiles(t.originalEvent.dataTransfer.files)},l.prototype.uploadFiles=function(t){for(let e=0;e<t.length;e++)this.uploadFile(t[e])},l.prototype.onFileChange=function(t){this.feedbackContainer.removeClass("moj-hidden"),this.status.html(this.params.uploadStatusText),this.uploadFiles(t.currentTarget.files),this.fileInput.replaceWith(window.jQuery(t.currentTarget).val("").clone(!0)),this.setupFileInput(),this.fileInput.get(0).focus()},l.prototype.onFileFocus=function(t){this.label.addClass("moj-multi-file-upload--focused")},l.prototype.onFileBlur=function(t){this.label.removeClass("moj-multi-file-upload--focused")},l.prototype.getSuccessHtml=function(t){return`<span class="moj-multi-file-upload__success"> <svg class="moj-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25"><path d="M25,6.2L8.7,23.2L0,14.1l4-4.2l4.7,4.9L21,2L25,6.2z"/></svg>${t.messageHtml}</span>`},l.prototype.getErrorHtml=function(t){return`<span class="moj-multi-file-upload__error"> <svg class="moj-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25"><path d="M13.6,15.4h-2.3v-4.5h2.3V15.4z M13.6,19.8h-2.3v-2.2h2.3V19.8z M0,23.2h25L12.5,2L0,23.2z"/></svg>${t.message}</span>`},l.prototype.getFileRowHtml=function(t){return`\n <div class="govuk-summary-list__row moj-multi-file-upload__row">;\n <div class="govuk-summary-list__value moj-multi-file-upload__message">;\n <span class="moj-multi-file-upload__filename">${t.name}</span>;\n <span class="moj-multi-file-upload__progress">0%</span>;\n </div>';\n <div class="govuk-summary-list__actions moj-multi-file-upload__actions"></div>;\n </div>`},l.prototype.getDeleteButtonHtml=function(t){return`<button class="moj-multi-file-upload__delete govuk-button govuk-button--secondary govuk-!-margin-bottom-0" type="button" name="delete" value="${t.filename}">\n Delete <span class="govuk-visually-hidden">${t.originalname}</span>\n </button>`},l.prototype.uploadFile=function(t){this.params.uploadFileEntryHook(this,t);const e=window.jQuery(this.getFileRowHtml(t)),o=new FormData;o.append("documents",t),this.feedbackContainer.find(".moj-multi-file-upload__list").append(e),window.jQuery.ajax({url:this.params.uploadUrl,type:"post",data:o,processData:!1,contentType:!1,success:window.jQuery.proxy((function(o){o.error?(e.find(".moj-multi-file-upload__message").html(this.getErrorHtml(o.error)),this.status.html(o.error.message)):(e.find(".moj-multi-file-upload__message").html(this.getSuccessHtml(o.success)),this.status.html(o.success.messageText)),e.find(".moj-multi-file-upload__actions").append(this.getDeleteButtonHtml(o.file)),this.params.uploadFileExitHook(this,t,o)}),this),error:window.jQuery.proxy((function(e,o,n){this.params.uploadFileErrorHook(this,t,e,o,n)}),this),xhr:function(){const t=new XMLHttpRequest;return t.upload.addEventListener("progress",(function(t){if(t.lengthComputable){let o=t.loaded/t.total;o=parseInt(100*o,10),e.find(".moj-multi-file-upload__progress").text(` ${o}%`)}}),!1),t}})},l.prototype.onFileDeleteClick=function(t){t.preventDefault();const e=window.jQuery(t.currentTarget),o={};o[e[0].name]=e[0].value,window.jQuery.ajax({url:this.params.deleteUrl,type:"post",dataType:"json",data:o,success:window.jQuery.proxy((function(t){t.error||(e.parents(".moj-multi-file-upload__row").remove(),0===this.feedbackContainer.find(".moj-multi-file-upload__row").length&&this.feedbackContainer.addClass("moj-hidden")),this.params.fileDeleteHook(this,t)}),this)})},c.prototype.getToggleHtml=function(t){let e="";return e+='<div class="govuk-checkboxes__item govuk-checkboxes--small moj-multi-select__checkbox">',e+=` <input type="checkbox" class="govuk-checkboxes__input" id="${t}">`,e+=` <label class="govuk-label govuk-checkboxes__label moj-multi-select__toggle-label" for="${t}">`,e+=' <span class="govuk-visually-hidden">Select all</span>',e+=" </label>",e+="</div>",e},c.prototype.onButtonClick=function(t){this.checked?(this.uncheckAll(),this.toggleButton[0].checked=!1):(this.checkAll(),this.toggleButton[0].checked=!0)},c.prototype.checkAll=function(){this.checkboxes.each(window.jQuery.proxy((function(t,e){e.checked=!0}),this)),this.checked=!0},c.prototype.uncheckAll=function(){this.checkboxes.each(window.jQuery.proxy((function(t,e){e.checked=!1}),this)),this.checked=!1},c.prototype.onCheckboxClick=function(t){t.target.checked?this.checkboxes.filter(":checked").length===this.checkboxes.length&&(this.toggleButton[0].checked=!0,this.checked=!0):(this.toggleButton[0].checked=!1,this.checked=!1)},d.prototype.createButton=function(){this.button=window.jQuery('<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'),this.container.append(this.button),this.button.on("click",window.jQuery.proxy(this,"onButtonClick"))},d.prototype.onButtonClick=function(){"password"===this.el.type?(this.el.type="text",this.button.html('Hide <span class="govuk-visually-hidden">password</span>')):(this.el.type="password",this.button.html('Show <span class="govuk-visually-hidden">password</span>'))},h.prototype.onToolbarKeydown=function(t){let e;switch(t.keyCode){case this.keys.right:case this.keys.down:{e=this.toolbar.find("button[tabindex=0]");const t=e.next("button");t[0]&&(t.focus(),e.attr("tabindex","-1"),t.attr("tabindex","0"));break}case this.keys.left:case this.keys.up:{e=this.toolbar.find("button[tabindex=0]");const t=e.prev("button");t[0]&&(t.focus(),e.attr("tabindex","-1"),t.attr("tabindex","0"));break}}},h.prototype.getToolbarHtml=function(){let t="";return t+='<div class="moj-rich-text-editor__toolbar" role="toolbar">',this.options.toolbar.bold&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>'),this.options.toolbar.italic&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>'),this.options.toolbar.underline&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>'),this.options.toolbar.bullets&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>'),this.options.toolbar.numbers&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>'),t+="</div>",t},h.prototype.getEnhancedHtml=function(t){return`${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`},h.prototype.hideDefault=function(){this.textarea=this.container.find("textarea"),this.textarea.addClass("govuk-visually-hidden"),this.textarea.attr("aria-hidden",!0),this.textarea.attr("tabindex","-1")},h.prototype.createToolbar=function(){this.toolbar=document.createElement("div"),this.toolbar.className="moj-rich-text-editor",this.toolbar.innerHTML=this.getEnhancedHtml(),this.container.append(this.toolbar),this.toolbar=this.container.find(".moj-rich-text-editor__toolbar"),this.container.find(".moj-rich-text-editor__content").html(this.textarea.val())},h.prototype.configureToolbar=function(){this.buttons=this.container.find(".moj-rich-text-editor__toolbar-button"),this.buttons.prop("tabindex","-1");this.buttons.first().prop("tabindex","0")},h.prototype.onButtonClick=function(t){document.execCommand(window.jQuery(t.currentTarget).data("command"),!1,null)},h.prototype.getContent=function(){return this.container.find(".moj-rich-text-editor__content").html()},h.prototype.onEditorInput=function(t){this.updateTextarea()},h.prototype.updateTextarea=function(){document.execCommand("defaultParagraphSeparator",!1,"p"),this.textarea.val(this.getContent())},h.prototype.onLabelClick=function(t){t.preventDefault(),this.container.find(".moj-rich-text-editor__content").focus()},p.prototype.showMenu=function(){this.toggleButton.attr("aria-expanded","true"),this.container.removeClass("moj-js-hidden"),this.container.find("input").first().get(0).focus()},p.prototype.hideMenu=function(){this.container.addClass("moj-js-hidden"),this.toggleButton.attr("aria-expanded","false")},p.prototype.onToggleButtonClick=function(){"false"===this.toggleButton.attr("aria-expanded")?this.showMenu():this.hideMenu()},p.prototype.onDocumentClick=function(t){window.jQuery.contains(this.toggleButtonContainer[0],t.target)||window.jQuery.contains(this.container[0],t.target)||this.hideMenu()},f.prototype.setupOptions=function(t){t=t||{},this.statusMessage=t.statusMessage||"Sort by %heading% (%direction%)",this.ascendingText=t.ascendingText||"ascending",this.descendingText=t.descendingText||"descending"},f.prototype.createHeadingButtons=function(){const t=this.table.find("thead th");let e;for(let o=0;o<t.length;o++)e=window.jQuery(t[o]),e.attr("aria-sort")&&this.createHeadingButton(e,o)},f.prototype.createHeadingButton=function(t,e){const o=t.text(),n=window.jQuery(`<button type="button" data-index="${e}">${o}</button>`);t.text(""),t.append(n)},f.prototype.createStatusBox=function(){this.status=window.jQuery('<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'),this.table.parent().append(this.status)},f.prototype.initialiseSortedColumn=function(){const t=this.getTableRowsArray();this.table.find("th").filter('[aria-sort="ascending"], [aria-sort="descending"]').first().each(((e,o)=>{const n=window.jQuery(o).attr("aria-sort"),i=window.jQuery(o).find("button").attr("data-index"),s=this.sort(t,i,n);this.addRows(s)}))},f.prototype.onSortButtonClick=function(t){const e=t.currentTarget.getAttribute("data-index"),o=window.jQuery(t.currentTarget).parent().attr("aria-sort");let n;n="none"===o||"descending"===o?"ascending":"descending";const i=this.getTableRowsArray(),s=this.sort(i,e,n);this.addRows(s),this.removeButtonStates(),this.updateButtonState(window.jQuery(t.currentTarget),n)},f.prototype.updateButtonState=function(t,e){t.parent().attr("aria-sort",e);let o=this.statusMessage;o=o.replace(/%heading%/,t.text()),o=o.replace(/%direction%/,this[`${e}Text`]),this.status.text(o)},f.prototype.removeButtonStates=function(){this.table.find("thead th").attr("aria-sort","none")},f.prototype.addRows=function(t){for(let e=0;e<t.length;e++)this.body.append(t[e])},f.prototype.getTableRowsArray=function(){const t=[],e=this.body.find("tr");for(let o=0;o<e.length;o++)t.push(e[o]);return t},f.prototype.sort=function(t,e,o){return t.sort(function(t,n){const i=window.jQuery(t).find("td,th").eq(e),s=window.jQuery(n).find("td,th").eq(e),a="ascending"===o?this.getCellValue(i):this.getCellValue(s),r="ascending"===o?this.getCellValue(s):this.getCellValue(i);return"string"==typeof a||"string"==typeof r?a.toString().localeCompare(r.toString()):a-r}.bind(this))},f.prototype.getCellValue=function(t){const e=t.attr("data-sort-value")||t.html(),o=Number(e);return isNaN(o)?e:o};t.AddAnother=e,t.Alert=i,t.ButtonMenu=s,t.DatePicker=a,t.FilterToggleButton=u,t.MultiFileUpload=l,t.MultiSelect=c,t.PasswordReveal=d,t.RichTextEditor=h,t.SearchToggle=p,t.SortableTable=f,t.initAll=function(t){const n=void 0!==(t=void 0!==t?t:{}).scope?t.scope:document;o(n.querySelectorAll('[data-module="moj-add-another"]'),(function(t){new e(t)})),o(n.querySelectorAll('[data-module="moj-multi-select"]'),(function(t){new c({container:t.querySelector(t.getAttribute("data-multi-select-checkbox")),checkboxes:t.querySelectorAll("tbody .govuk-checkboxes__input"),id_prefix:t.getAttribute("data-multi-select-idprefix")})})),o(n.querySelectorAll('[data-module="moj-password-reveal"]'),(function(t){new d(t)})),o(n.querySelectorAll('[data-module="moj-rich-text-editor"]'),(function(t){const e={textarea:window.jQuery(t)},o=t.getAttribute("data-moj-rich-text-editor-toolbar");if(o){const t=o.split(",");e.toolbar={};for(const o in t)e.toolbar[t[o]]=!0}new h(e)})),o(n.querySelectorAll('[data-module="moj-search-toggle"]'),(function(t){new p({toggleButton:{container:window.jQuery(t.querySelector(".moj-search-toggle__toggle")),text:t.getAttribute("data-moj-search-toggle-text")},search:{container:window.jQuery(t.querySelector(".moj-search"))}})})),o(n.querySelectorAll('[data-module="moj-sortable-table"]'),(function(t){new f({table:t})})),o(n.querySelectorAll('[data-module="moj-date-picker"]'),(function(t){new a(t,{}).init()})),o(n.querySelectorAll('[data-module="moj-button-menu"]'),(function(t){new s(t,{}).init()})),o(n.querySelectorAll('[data-module="moj-alert"]'),(function(t){new i(t,{}).init()}))},t.version="0.0.0-development"}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MOJFrontend=t.MOJFrontend||{})}(this,(function(t){"use strict";function e(t){this.container=$(t),this.container.data("moj-add-another-initialised")||(this.container.data("moj-add-another-initialised",!0),this.container.on("click",".moj-add-another__remove-button",$.proxy(this,"onRemoveButtonClick")),this.container.on("click",".moj-add-another__add-button",$.proxy(this,"onAddButtonClick")),this.container.find(".moj-add-another__add-button, moj-add-another__remove-button").prop("type","button"))}function o(t,e){if(window.NodeList.prototype.forEach)return t.forEach(e);for(let o=0;o<t.length;o++)e.call(window,t[o],o,t)}function n(t,e={}){const o=t.getAttribute("tabindex");function n(){e.onBlur&&e.onBlur.call(t),o||t.removeAttribute("tabindex")}o||t.setAttribute("tabindex","-1"),t.addEventListener("focus",(function(){t.addEventListener("blur",n,{once:!0})}),{once:!0}),e.onBeforeFocus&&e.onBeforeFocus.call(t),t.focus()}function i(t,e={}){if(!t)return this;const o=Object.freeze({properties:{dismissible:{type:"boolean"},dismissText:{type:"string"},disableAutoFocus:{type:"boolean"},focusOnDismissSelector:{type:"string"}}});this.config=this.mergeConfigs({dismissible:!1,dismissText:"Dismiss",disableAutoFocus:!1},e,this.parseDataset(o,t.dataset)),this.$module=t}function s(t,e={}){if(!t)return this;const o=Object.freeze({properties:{buttonText:{type:"string"},buttonClasses:{type:"string"},alignMenu:{type:"string"}}});this.config=this.mergeConfigs({buttonText:"Actions",alignMenu:"left",buttonClasses:""},e,this.parseDataset(o,t.dataset)),this.$module=t}function a(t,e={}){if(!t)return this;const o=Object.freeze({properties:{excludedDates:{type:"string"},excludedDays:{type:"string"},leadingZeros:{type:"string"},maxDate:{type:"string"},minDate:{type:"string"},weekStartDay:{type:"string"}}});this.config=this.mergeConfigs({leadingZeros:!1,weekStartDay:"monday"},e,this.parseDataset(o,t.dataset)),this.dayLabels=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],this.monthLabels=["January","February","March","April","May","June","July","August","September","October","November","December"],this.currentDate=new Date,this.currentDate.setHours(0,0,0,0),this.calendarDays=[],this.excludedDates=[],this.excludedDays=[],this.buttonClass="moj-datepicker__button",this.selectedDayButtonClass="moj-datepicker__button--selected",this.currentDayButtonClass="moj-datepicker__button--current",this.todayButtonClass="moj-datepicker__button--today",this.$module=t,this.$input=t.querySelector(".moj-js-datepicker-input")}function r(t,e,o,n,i){this.index=e,this.row=o,this.column=n,this.button=t,this.picker=i,this.date=new Date}function l(t){this.options=t,this.container=$(this.options.toggleButton.container),this.filterContainer=$(this.options.filter.container),this.createToggleButton(),this.setupResponsiveChecks(),this.filterContainer.attr("tabindex","-1"),this.options.startHidden&&this.hideMenu()}function u(t){void 0!==document.createElement("div").ondrop&&"function"==typeof FormData&&function(){const t=document.createElement("input");return t.type="file",void 0!==t.files}()&&(this.defaultParams={uploadFileEntryHook:$.noop,uploadFileExitHook:$.noop,uploadFileErrorHook:$.noop,fileDeleteHook:$.noop,uploadStatusText:"Uploading files, please wait",dropzoneHintText:"Drag and drop files here or",dropzoneButtonText:"Choose files"},this.params=$.extend({},this.defaultParams,t),this.container=$(this.params.container),this.container.addClass("moj-multi-file-upload--enhanced"),this.feedbackContainer=this.container.find(".moj-multi-file__uploaded-files"),this.setupFileInput(),this.setupDropzone(),this.setupLabel(),this.setupStatusBox(),this.container.on("click",".moj-multi-file-upload__delete",$.proxy(this,"onFileDeleteClick")))}function c(t){if(this.container=$(t.container),this.container.data("moj-multi-select-initialised"))return;this.container.data("moj-multi-select-initialised",!0);const e=t.id_prefix;let o="checkboxes-all";void 0!==e&&(o=`${e}checkboxes-all`),this.toggle=$(this.getToggleHtml(o)),this.toggleButton=this.toggle.find("input"),this.toggleButton.on("click",$.proxy(this,"onButtonClick")),this.container.append(this.toggle),this.checkboxes=$(t.checkboxes),this.checkboxes.on("click",$.proxy(this,"onCheckboxClick")),this.checked=t.checked||!1}function d(t){this.el=t;const e=$(this.el);e.data("moj-password-reveal-initialised")||(e.data("moj-password-reveal-initialised",!0),e.attr("spellcheck","false"),e.wrap('<div class="moj-password-reveal"></div>'),this.container=$(this.el).parent(),this.createButton())}function h(t){"contentEditable"in document.documentElement&&(this.options=t,this.options.toolbar=this.options.toolbar||{bold:!1,italic:!1,underline:!1,bullets:!0,numbers:!0},this.textarea=this.options.textarea,this.container=$(this.textarea).parent(),this.container.data("moj-rich-text-editor-initialised")||(this.container.data("moj-rich-text-editor-initialised",!0),this.createToolbar(),this.hideDefault(),this.configureToolbar(),this.keys={left:37,right:39,up:38,down:40},this.container.on("click",".moj-rich-text-editor__toolbar-button",$.proxy(this,"onButtonClick")),this.container.find(".moj-rich-text-editor__content").on("input",$.proxy(this,"onEditorInput")),this.container.find("label").on("click",$.proxy(this,"onLabelClick")),this.toolbar.on("keydown",$.proxy(this,"onToolbarKeydown"))))}function p(t){if(this.options=t,this.container=$(this.options.search.container),this.toggleButtonContainer=$(this.options.toggleButton.container),this.container.data("moj-search-toggle-initialised"))return;this.container.data("moj-search-toggle-initialised",!0);this.toggleButton=$(`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">\n ${this.options.toggleButton.text} <svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>\n </button>`),this.toggleButton.on("click",$.proxy(this,"onToggleButtonClick")),this.toggleButtonContainer.append(this.toggleButton),$(document).on("click",this.onDocumentClick.bind(this)),$(document).on("focusin",this.onDocumentClick.bind(this))}function f(t){this.table=$(t.table),this.table.data("moj-search-toggle-initialised")||(this.table.data("moj-search-toggle-initialised",!0),this.setupOptions(t),this.body=this.table.find("tbody"),this.createHeadingButtons(),this.createStatusBox(),this.initialiseSortedColumn(),this.table.on("click","th button",$.proxy(this,"onSortButtonClick")))}e.prototype.onAddButtonClick=function(t){const e=this.getNewItem();this.updateAttributes(this.getItems().length,e),this.resetItem(e);const o=this.getItems().first();this.hasRemoveButton(o)||this.createRemoveButton(o),this.getItems().last().after(e),e.find("input, textarea, select").first().focus()},e.prototype.hasRemoveButton=function(t){return t.find(".moj-add-another__remove-button").length},e.prototype.getItems=function(){return this.container.find(".moj-add-another__item")},e.prototype.getNewItem=function(){const t=this.getItems().first().clone();return this.hasRemoveButton(t)||this.createRemoveButton(t),t},e.prototype.updateAttributes=function(t,e){e.find("[data-name]").each((function(o,n){const i=n.id;n.name=$(n).attr("data-name").replace(/%index%/,t),n.id=$(n).attr("data-id").replace(/%index%/,t);($(n).siblings("label")[0]||$(n).parents("label")[0]||e.find(`[for="${i}"]`)[0]).htmlFor=n.id}))},e.prototype.createRemoveButton=function(t){t.append('<button type="button" class="govuk-button govuk-button--secondary moj-add-another__remove-button">Remove</button>')},e.prototype.resetItem=function(t){t.find("[data-name], [data-id]").each((function(t,e){"checkbox"===e.type||"radio"===e.type?e.checked=!1:e.value=""}))},e.prototype.onRemoveButtonClick=function(t){$(t.currentTarget).parents(".moj-add-another__item").remove();const e=this.getItems();1===e.length&&e.find(".moj-add-another__remove-button").remove(),e.each($.proxy((function(t,e){this.updateAttributes(t,$(e))}),this)),this.focusHeading()},e.prototype.focusHeading=function(){this.container.find(".moj-add-another__heading").get(0).focus()},i.prototype.init=function(){"alert"!==this.$module.getAttribute("role")||this.config.disableAutoFocus||n(this.$module),this.$dismissButton=this.$module.querySelector(".moj-alert__dismiss"),this.config.dismissible&&this.$dismissButton&&(this.$dismissButton.innerHTML=this.config.dismissText,this.$dismissButton.removeAttribute("hidden"),this.$module.addEventListener("click",(t=>{this.$dismissButton.contains(t.target)&&this.dimiss()})))},i.prototype.dimiss=function(){let t;if(this.config.focusOnDismissSelector&&(t=document.querySelector(this.config.focusOnDismissSelector)),!t){const e=this.$module.nextElementSibling;e&&e.matches(".moj-alert")&&(t=e)}t||(t=function(t,e){if(!t)return;let o=t.previousElementSibling;for(;o;){if(o.matches(e))return o;o=o.previousElementSibling}}(this.$module,".moj-alert, h1, h2, h3, h4, h5, h6")),t||(t=function(t,e){if(!t)return;let o=t;for(;o;){if(o.matches(e))return o;let t=o.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}o=o.parentElement}}(this.$module,"h1, h2, h3, h4, h5, h6, main, body")),t&&n(t),this.$module.remove()},i.prototype.normaliseString=function(t,e){const o=t?t.trim():"";let n,i;switch(e&&e.type&&(i=e.type),i||(["true","false"].includes(o)&&(i="boolean"),o.length>0&&isFinite(Number(o))&&(i="number")),i){case"boolean":n="true"===o;break;case"number":n=Number(o);break;default:n=t}return n},i.prototype.parseDataset=function(t,e){const o={};for(const[n,i]of Object.entries(t.properties))n in e&&e[n]&&(o[n]=this.normaliseString(e[n],i));return o},i.prototype.mergeConfigs=function(...t){const e={};for(const o of t)for(const t of Object.keys(o)){const n=e[t],i=o[t];e[t]="object"==typeof n&&"object"==typeof i?this.mergeConfigs(n,i):i}return e},s.prototype.init=function(){if(1===this.$module.children.length){const t=this.$module.children[0];t.classList.forEach((e=>{e.startsWith("govuk-button-")&&t.classList.remove(e),t.classList.remove("moj-button-menu__item")})),this.config.buttonClasses&&t.classList.add(...this.config.buttonClasses.split(" "))}this.$module.children.length>1&&this.initMenu()},s.prototype.initMenu=function(){this.$menu=this.createMenu(),this.$module.insertAdjacentHTML("afterbegin",this.toggleTemplate()),this.setupMenuItems(),this.$menuToggle=this.$module.querySelector(":scope > button"),this.items=this.$menu.querySelectorAll("a, button"),this.$menuToggle.addEventListener("click",(t=>{this.toggleMenu(t)})),this.$module.addEventListener("keydown",(t=>{this.handleKeyDown(t)})),document.addEventListener("click",(t=>{this.$module.contains(t.target)||this.closeMenu(!1)}))},s.prototype.createMenu=function(){const t=document.createElement("ul");for(t.setAttribute("role","list"),t.hidden=!0,t.classList.add("moj-button-menu__wrapper"),"right"===this.config.alignMenu&&t.classList.add("moj-button-menu__wrapper--right"),this.$module.appendChild(t);this.$module.firstChild!==t;)t.appendChild(this.$module.firstChild);return t},s.prototype.setupMenuItems=function(){Array.from(this.$menu.children).forEach((t=>{const e=document.createElement("li");this.$menu.insertBefore(e,t),e.appendChild(t),t.setAttribute("tabindex",-1),"BUTTON"===t.tagName&&t.setAttribute("type","button"),t.classList.forEach((e=>{e.startsWith("govuk-button")&&t.classList.remove(e)})),t.addEventListener("click",(t=>{setTimeout((()=>{this.closeMenu(!1)}),50)}))}))},s.prototype.toggleTemplate=function(){return`\n <button type="button" class="govuk-button moj-button-menu__toggle-button ${this.config.buttonClasses||""}" aria-haspopup="true" aria-expanded="false">\n <span>\n ${this.config.buttonText}\n <svg width="11" height="5" viewBox="0 0 11 5" xmlns="http://www.w3.org/2000/svg">\n <path d="M5.5 0L11 5L0 5L5.5 0Z" fill="currentColor"/>\n </svg>\n </span>\n </button>`},s.prototype.isOpen=function(){return"true"===this.$menuToggle.getAttribute("aria-expanded")},s.prototype.toggleMenu=function(t){t.preventDefault();const e=0===t.detail?0:-1;this.isOpen()?this.closeMenu():this.openMenu(e)},s.prototype.openMenu=function(t=0){this.$menu.hidden=!1,this.$menuToggle.setAttribute("aria-expanded","true"),-1!==t&&this.focusItem(t)},s.prototype.closeMenu=function(t=!0){this.$menu.hidden=!0,this.$menuToggle.setAttribute("aria-expanded","false"),t&&this.$menuToggle.focus()},s.prototype.focusItem=function(t){t>=this.items.length&&(t=0),t<0&&(t=this.items.length-1);const e=this.items.item(t);e&&e.focus()},s.prototype.currentFocusIndex=function(){const t=document.activeElement;return Array.from(this.items).indexOf(t)},s.prototype.handleKeyDown=function(t){if(t.target===this.$menuToggle)switch(t.key){case"ArrowDown":t.preventDefault(),this.openMenu();break;case"ArrowUp":t.preventDefault(),this.openMenu(this.items.length-1)}if(this.$menu.contains(t.target)&&this.isOpen())switch(t.key){case"ArrowDown":t.preventDefault(),-1!==this.currentFocusIndex()&&this.focusItem(this.currentFocusIndex()+1);break;case"ArrowUp":t.preventDefault(),-1!==this.currentFocusIndex()&&this.focusItem(this.currentFocusIndex()-1);break;case"Home":t.preventDefault(),this.focusItem(0);break;case"End":t.preventDefault(),this.focusItem(this.items.length-1)}"Escape"===t.key&&this.isOpen()&&this.closeMenu(),"Tab"===t.key&&this.isOpen()&&this.closeMenu(!1)},s.prototype.parseDataset=function(t,e){const o={};for(const[n,,]of Object.entries(t.properties))n in e&&e[n]&&(o[n]=e[n]);return o},s.prototype.mergeConfigs=function(...t){const e={};for(const o of t)for(const t of Object.keys(o)){const n=e[t],i=o[t];e[t]="object"==typeof n&&"object"==typeof i?this.mergeConfigs(n,i):i}return e},a.prototype.init=function(){this.$input&&(this.$module.dataset.initialized||(this.setOptions(),this.initControls(),this.$module.setAttribute("data-initialized","true")))},a.prototype.initControls=function(){this.id=`datepicker-${this.$input.id}`,this.$dialog=this.createDialog(),this.createCalendarHeaders();const t=document.createElement("div"),e=document.createElement("div");t.classList.add("moj-datepicker__wrapper"),e.classList.add("govuk-input__wrapper"),this.$input.parentNode.insertBefore(t,this.$input),t.appendChild(e),e.appendChild(this.$input),e.insertAdjacentHTML("beforeend",this.toggleTemplate()),t.insertAdjacentElement("beforeend",this.$dialog),this.$calendarButton=this.$module.querySelector(".moj-js-datepicker-toggle"),this.$dialogTitle=this.$dialog.querySelector(".moj-js-datepicker-month-year"),this.createCalendar(),this.$prevMonthButton=this.$dialog.querySelector(".moj-js-datepicker-prev-month"),this.$prevYearButton=this.$dialog.querySelector(".moj-js-datepicker-prev-year"),this.$nextMonthButton=this.$dialog.querySelector(".moj-js-datepicker-next-month"),this.$nextYearButton=this.$dialog.querySelector(".moj-js-datepicker-next-year"),this.$cancelButton=this.$dialog.querySelector(".moj-js-datepicker-cancel"),this.$okButton=this.$dialog.querySelector(".moj-js-datepicker-ok"),this.$prevMonthButton.addEventListener("click",(t=>this.focusPreviousMonth(t,!1))),this.$prevYearButton.addEventListener("click",(t=>this.focusPreviousYear(t,!1))),this.$nextMonthButton.addEventListener("click",(t=>this.focusNextMonth(t,!1))),this.$nextYearButton.addEventListener("click",(t=>this.focusNextYear(t,!1))),this.$cancelButton.addEventListener("click",(t=>{t.preventDefault(),this.closeDialog(t)})),this.$okButton.addEventListener("click",(()=>{this.selectDate(this.currentDate)}));const o=this.$dialog.querySelectorAll('button:not([disabled="true"])');this.$firstButtonInDialog=o[0],this.$lastButtonInDialog=o[o.length-1],this.$firstButtonInDialog.addEventListener("keydown",(t=>this.firstButtonKeydown(t))),this.$lastButtonInDialog.addEventListener("keydown",(t=>this.lastButtonKeydown(t))),this.$calendarButton.addEventListener("click",(t=>this.toggleDialog(t))),this.$dialog.addEventListener("keydown",(t=>{"Escape"===t.key&&(this.closeDialog(),t.preventDefault(),t.stopPropagation())})),document.body.addEventListener("mouseup",(t=>this.backgroundClick(t))),this.updateCalendar()},a.prototype.createDialog=function(){const t=`datepicker-title-${this.$input.id}`,e=document.createElement("div");return e.id=this.id,e.setAttribute("class","moj-datepicker__dialog"),e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-labelledby",t),e.innerHTML=this.dialogTemplate(t),e.hidden=!0,e},a.prototype.createCalendar=function(){const t=this.$dialog.querySelector("tbody");let e=0;for(let o=0;o<6;o++){const n=t.insertRow(o);for(let t=0;t<7;t++){const i=document.createElement("td"),s=document.createElement("button");i.appendChild(s),n.appendChild(i);const a=new r(s,e,o,t,this);a.init(),this.calendarDays.push(a),e++}}},a.prototype.toggleTemplate=function(){return`<button class="moj-datepicker__toggle moj-js-datepicker-toggle" type="button" aria-haspopup="dialog" aria-controls="${this.id}" aria-expanded="false">\n <span class="govuk-visually-hidden">Choose date</span>\n <svg width="32" height="24" focusable="false" class="moj-datepicker-icon" aria-hidden="true" role="img" viewBox="0 0 22 22">\n <path\n fill="currentColor"\n fill-rule="evenodd"\n clip-rule="evenodd"\n d="M16.1333 2.93333H5.86668V4.4C5.86668 5.21002 5.21003 5.86667 4.40002 5.86667C3.59 5.86667 2.93335 5.21002 2.93335 4.4V2.93333H2C0.895431 2.93333 0 3.82877 0 4.93334V19.2667C0 20.3712 0.89543 21.2667 2 21.2667H20C21.1046 21.2667 22 20.3712 22 19.2667V4.93333C22 3.82876 21.1046 2.93333 20 2.93333H19.0667V4.4C19.0667 5.21002 18.41 5.86667 17.6 5.86667C16.79 5.86667 16.1333 5.21002 16.1333 4.4V2.93333ZM20.5333 8.06667H1.46665V18.8C1.46665 19.3523 1.91436 19.8 2.46665 19.8H19.5333C20.0856 19.8 20.5333 19.3523 20.5333 18.8V8.06667Z"\n ></path>\n <rect x="3.66669" width="1.46667" height="5.13333" rx="0.733333" fill="currentColor"></rect>\n <rect x="16.8667" width="1.46667" height="5.13333" rx="0.733333" fill="currentColor"></rect>\n </svg>\n </button>`},a.prototype.dialogTemplate=function(t){return`<div class="moj-datepicker__dialog-header">\n <div class="moj-datepicker__dialog-navbuttons">\n <button class="moj-datepicker__button moj-js-datepicker-prev-year">\n <span class="govuk-visually-hidden">Previous year</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1643 20L28.9572 14.2071L27.5429 12.7929L20.3358 20L27.5429 27.2071L28.9572 25.7929L23.1643 20Z" fill="currentColor"/>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M17.1643 20L22.9572 14.2071L21.5429 12.7929L14.3358 20L21.5429 27.2071L22.9572 25.7929L17.1643 20Z" fill="currentColor"/>\n </svg>\n </button>\n\n <button class="moj-datepicker__button moj-js-datepicker-prev-month">\n <span class="govuk-visually-hidden">Previous month</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M20.5729 20L25.7865 14.2071L24.5137 12.7929L18.0273 20L24.5137 27.2071L25.7865 25.7929L20.5729 20Z" fill="currentColor"/>\n </svg>\n </button>\n </div>\n\n <h2 id="${t}" class="moj-datepicker__dialog-title moj-js-datepicker-month-year" aria-live="polite">June 2020</h2>\n\n <div class="moj-datepicker__dialog-navbuttons">\n <button class="moj-datepicker__button moj-js-datepicker-next-month">\n <span class="govuk-visually-hidden">Next month</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M23.4271 20L18.2135 14.2071L19.4863 12.7929L25.9727 20L19.4863 27.2071L18.2135 25.7929L23.4271 20Z" fill="currentColor"/>\n </svg>\n </button>\n\n <button class="moj-datepicker__button moj-js-datepicker-next-year">\n <span class="govuk-visually-hidden">Next year</span>\n <svg width="44" height="40" viewBox="0 0 44 40" fill="none" fill="none" focusable="false" aria-hidden="true" role="img">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M20.8357 20L15.0428 14.2071L16.4571 12.7929L23.6642 20L16.4571 27.2071L15.0428 25.7929L20.8357 20Z" fill="currentColor"/>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M26.8357 20L21.0428 14.2071L22.4571 12.7929L29.6642 20L22.4571 27.2071L21.0428 25.7929L26.8357 20Z" fill="currentColor"/>\n </svg>\n </button>\n </div>\n </div>\n\n <table class="moj-datepicker__calendar moj-js-datepicker-grid" role="grid" aria-labelledby="${t}">\n <thead>\n <tr></tr>\n </thead>\n\n <tbody></tbody>\n </table>\n\n <div class="govuk-button-group">\n <button type="button" class="govuk-button moj-js-datepicker-ok">Select</button>\n <button type="button" class="govuk-button govuk-button--secondary moj-js-datepicker-cancel">Close</button>\n </div>`},a.prototype.createCalendarHeaders=function(){this.dayLabels.forEach((t=>{const e=`<th scope="col"><span aria-hidden="true">${t.substring(0,3)}</span><span class="govuk-visually-hidden">${t}</span></th>`;this.$dialog.querySelector("thead > tr").insertAdjacentHTML("beforeend",e)}))},a.prototype.leadingZeros=function(t,e=2){let o=t.toString();for(;o.length<e;)o=`0${o}`;return o},a.prototype.setOptions=function(){this.setMinAndMaxDatesOnCalendar(),this.setExcludedDates(),this.setExcludedDays(),this.setLeadingZeros(),this.setWeekStartDay()},a.prototype.setMinAndMaxDatesOnCalendar=function(){this.config.minDate&&(this.minDate=this.formattedDateFromString(this.config.minDate,null),this.minDate&&this.currentDate<this.minDate&&(this.currentDate=this.minDate)),this.config.maxDate&&(this.maxDate=this.formattedDateFromString(this.config.maxDate,null),this.maxDate&&this.currentDate>this.maxDate&&(this.currentDate=this.maxDate))},a.prototype.setExcludedDates=function(){this.config.excludedDates&&(this.excludedDates=this.config.excludedDates.replace(/\s+/," ").split(" ").map((t=>t.includes("-")?this.parseDateRangeString(t):this.formattedDateFromString(t))).flat().filter((t=>t)))},a.prototype.parseDateRangeString=function(t){const e=[],[o,n]=t.split("-").map((t=>this.formattedDateFromString(t,null)));if(o&&n){const t=new Date(o.getTime());for(;t<=n;)e.push(new Date(t)),t.setDate(t.getDate()+1)}return e},a.prototype.setExcludedDays=function(){if(this.config.excludedDays){const t=this.dayLabels.map((t=>t.toLowerCase()));"monday"===this.config.weekStartDay&&t.unshift(t.pop()),this.excludedDays=this.config.excludedDays.replace(/\s+/," ").toLowerCase().split(" ").map((e=>t.indexOf(e))).filter((t=>-1!==t))}},a.prototype.setLeadingZeros=function(){if("boolean"!=typeof this.config.leadingZeros){if("true"===this.config.leadingZeros.toLowerCase())return void(this.config.leadingZeros=!0);"false"===this.config.leadingZeros.toLowerCase()&&(this.config.leadingZeros=!1)}},a.prototype.setWeekStartDay=function(){const t=this.config.weekStartDay;t&&"sunday"===t.toLowerCase()?(this.config.weekStartDay="sunday",this.dayLabels.unshift(this.dayLabels.pop())):this.config.weekStartDay="monday"},a.prototype.isExcludedDate=function(t){if(this.minDate&&this.minDate>t)return!0;if(this.maxDate&&this.maxDate<t)return!0;for(const e of this.excludedDates)if(t.toDateString()===e.toDateString())return!0;return!!this.excludedDays.includes(t.getDay())},a.prototype.formattedDateFromString=function(t,e=new Date){let o=null;const n=/(\d{1,2})([-/,. ])(\d{1,2})\2(\d{4})/;if(!n.test(t))return e;const i=t.match(n),s=i[1],a=i[3],r=i[4];return o=new Date(`${r}-${a}-${s}`),o instanceof Date&&!isNaN(o)?o:e},a.prototype.formattedDateFromDate=function(t){return this.config.leadingZeros?`${this.leadingZeros(t.getDate())}/${this.leadingZeros(t.getMonth()+1)}/${t.getFullYear()}`:`${t.getDate()}/${t.getMonth()+1}/${t.getFullYear()}`},a.prototype.formattedDateHuman=function(t){return`${this.dayLabels[(t.getDay()+6)%7]} ${t.getDate()} ${this.monthLabels[t.getMonth()]} ${t.getFullYear()}`},a.prototype.backgroundClick=function(t){!this.isOpen()||this.$dialog.contains(t.target)||this.$input.contains(t.target)||this.$calendarButton.contains(t.target)||(t.preventDefault(),this.closeDialog())},a.prototype.firstButtonKeydown=function(t){"Tab"===t.key&&t.shiftKey&&(this.$lastButtonInDialog.focus(),t.preventDefault())},a.prototype.lastButtonKeydown=function(t){"Tab"!==t.key||t.shiftKey||(this.$firstButtonInDialog.focus(),t.preventDefault())},a.prototype.updateCalendar=function(){this.$dialogTitle.innerHTML=`${this.monthLabels[this.currentDate.getMonth()]} ${this.currentDate.getFullYear()}`;const t=this.currentDate,e=new Date(t.getFullYear(),t.getMonth(),1);let o;o="monday"===this.config.weekStartDay?0===e.getDay()?6:e.getDay()-1:e.getDay(),e.setDate(e.getDate()-o);const n=new Date(e);for(let i=0;i<this.calendarDays.length;i++){const e=n.getMonth()!==t.getMonth(),o=this.isExcludedDate(n);this.calendarDays[i].update(n,e,o),n.setDate(n.getDate()+1)}},a.prototype.setCurrentDate=function(t=!0){const{currentDate:e}=this;if(this.calendarDays.forEach((o=>{o.button.classList.add("moj-datepicker__button"),o.button.classList.add("moj-datepicker__calendar-day"),o.button.setAttribute("tabindex",-1),o.button.classList.remove(this.selectedDayButtonClass);const n=o.date;n.setHours(0,0,0,0);const i=new Date;i.setHours(0,0,0,0),n.getTime()===e.getTime()&&t&&(o.button.setAttribute("tabindex",0),o.button.focus(),o.button.classList.add(this.selectedDayButtonClass)),this.inputDate&&n.getTime()===this.inputDate.getTime()?(o.button.classList.add(this.currentDayButtonClass),o.button.setAttribute("aria-current","date")):(o.button.classList.remove(this.currentDayButtonClass),o.button.removeAttribute("aria-current")),n.getTime()===i.getTime()?o.button.classList.add(this.todayButtonClass):o.button.classList.remove(this.todayButtonClass)})),!t){const t=this.calendarDays.filter((t=>"block"===window.getComputedStyle(t.button).display&&!t.button.disabled));t[0].button.setAttribute("tabindex",0),this.currentDate=t[0].date}},a.prototype.selectDate=function(t){if(this.isExcludedDate(t))return;this.$calendarButton.querySelector("span").innerText=`Choose date. Selected date is ${this.formattedDateHuman(t)}`,this.$input.value=this.formattedDateFromDate(t);const e=new Event("change",{bubbles:!0,cancelable:!0});this.$input.dispatchEvent(e),this.closeDialog()},a.prototype.isOpen=function(){return this.$dialog.classList.contains("moj-datepicker__dialog--open")},a.prototype.toggleDialog=function(t){t.preventDefault(),this.isOpen()?this.closeDialog():(this.setMinAndMaxDatesOnCalendar(),this.openDialog())},a.prototype.openDialog=function(){this.$dialog.hidden=!1,this.$dialog.classList.add("moj-datepicker__dialog--open"),this.$calendarButton.setAttribute("aria-expanded","true"),this.$input.offsetWidth>this.$dialog.offsetWidth&&(this.$dialog.style.right="0px"),this.$dialog.style.top=`${this.$input.offsetHeight+3}px`,this.inputDate=this.formattedDateFromString(this.$input.value),this.currentDate=this.inputDate,this.currentDate.setHours(0,0,0,0),this.updateCalendar(),this.setCurrentDate()},a.prototype.closeDialog=function(){this.$dialog.hidden=!0,this.$dialog.classList.remove("moj-datepicker__dialog--open"),this.$calendarButton.setAttribute("aria-expanded","false"),this.$calendarButton.focus()},a.prototype.goToDate=function(t,e){const o=this.currentDate;this.currentDate=t,o.getMonth()===this.currentDate.getMonth()&&o.getFullYear()===this.currentDate.getFullYear()||this.updateCalendar(),this.setCurrentDate(e)},a.prototype.focusNextDay=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()+1),this.goToDate(t)},a.prototype.focusPreviousDay=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()-1),this.goToDate(t)},a.prototype.focusNextWeek=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()+7),this.goToDate(t)},a.prototype.focusPreviousWeek=function(){const t=new Date(this.currentDate);t.setDate(t.getDate()-7),this.goToDate(t)},a.prototype.focusFirstDayOfWeek=function(){const t=new Date(this.currentDate),e="sunday"===this.config.weekStartDay?0:1,o=t.getDay(),n=o>=e?o-e:6-o;t.setDate(t.getDate()-n),t.setHours(0,0,0,0),this.goToDate(t)},a.prototype.focusLastDayOfWeek=function(){const t=new Date(this.currentDate),e="sunday"===this.config.weekStartDay?6:0,o=t.getDay(),n=o<=e?e-o:7-o;t.setDate(t.getDate()+n),t.setHours(0,0,0,0),this.goToDate(t)},a.prototype.focusNextMonth=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setMonth(o.getMonth()+1,1),this.goToDate(o,e)},a.prototype.focusPreviousMonth=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setMonth(o.getMonth()-1,1),this.goToDate(o,e)},a.prototype.focusNextYear=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setFullYear(o.getFullYear()+1,o.getMonth(),1),this.goToDate(o,e)},a.prototype.focusPreviousYear=function(t,e=!0){t.preventDefault();const o=new Date(this.currentDate);o.setFullYear(o.getFullYear()-1,o.getMonth(),1),this.goToDate(o,e)},a.prototype.parseDataset=function(t,e){const o={};for(const[n,,]of Object.entries(t.properties))n in e&&(o[n]=e[n]);return o},a.prototype.mergeConfigs=function(...t){const e={};for(const o of t)for(const t of Object.keys(o)){const n=e[t],i=o[t];e[t]="object"==typeof n&&"object"==typeof i?this.mergeConfigs(n,i):i}return e},r.prototype.init=function(){this.button.addEventListener("keydown",this.keyPress.bind(this)),this.button.addEventListener("click",this.click.bind(this))},r.prototype.update=function(t,e,o){const n=t.getDate();let i=this.picker.formattedDateHuman(t);o?(this.button.setAttribute("aria-disabled",!0),i=`Excluded date, ${i}`):this.button.removeAttribute("aria-disabled"),this.button.style.display=e?"none":"block",this.button.setAttribute("data-testid",this.picker.formattedDateFromDate(t)),this.button.innerHTML=`<span class="govuk-visually-hidden">${i}</span><span aria-hidden="true">${n}</span>`,this.date=new Date(t)},r.prototype.click=function(t){this.picker.goToDate(this.date),this.picker.selectDate(this.date),t.stopPropagation(),t.preventDefault()},r.prototype.keyPress=function(t){let e=!0;switch(t.key){case"ArrowLeft":this.picker.focusPreviousDay();break;case"ArrowRight":this.picker.focusNextDay();break;case"ArrowUp":this.picker.focusPreviousWeek();break;case"ArrowDown":this.picker.focusNextWeek();break;case"Home":this.picker.focusFirstDayOfWeek();break;case"End":this.picker.focusLastDayOfWeek();break;case"PageUp":t.shiftKey?this.picker.focusPreviousYear(t):this.picker.focusPreviousMonth(t);break;case"PageDown":t.shiftKey?this.picker.focusNextYear(t):this.picker.focusNextMonth(t);break;default:e=!1}e&&(t.preventDefault(),t.stopPropagation())},l.prototype.setupResponsiveChecks=function(){this.mq=window.matchMedia(this.options.bigModeMediaQuery),this.mq.addListener($.proxy(this,"checkMode")),this.checkMode(this.mq)},l.prototype.createToggleButton=function(){this.menuButton=$(`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`),this.menuButton.on("click",$.proxy(this,"onMenuButtonClick")),this.container.append(this.menuButton)},l.prototype.checkMode=function(t){t.matches?this.enableBigMode():this.enableSmallMode()},l.prototype.enableBigMode=function(){this.showMenu(),this.removeCloseButton()},l.prototype.enableSmallMode=function(){this.hideMenu(),this.addCloseButton()},l.prototype.addCloseButton=function(){this.options.closeButton&&(this.closeButton=$(`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`),this.closeButton.on("click",$.proxy(this,"onCloseClick")),$(this.options.closeButton.container).append(this.closeButton))},l.prototype.onCloseClick=function(){this.hideMenu(),this.menuButton.focus()},l.prototype.removeCloseButton=function(){this.closeButton&&(this.closeButton.remove(),this.closeButton=null)},l.prototype.hideMenu=function(){this.menuButton.attr("aria-expanded","false"),this.filterContainer.addClass("moj-js-hidden"),this.menuButton.text(this.options.toggleButton.showText)},l.prototype.showMenu=function(){this.menuButton.attr("aria-expanded","true"),this.filterContainer.removeClass("moj-js-hidden"),this.menuButton.text(this.options.toggleButton.hideText)},l.prototype.onMenuButtonClick=function(){this.toggle()},l.prototype.toggle=function(){"false"===this.menuButton.attr("aria-expanded")?(this.showMenu(),this.filterContainer.get(0).focus()):this.hideMenu()},u.prototype.setupDropzone=function(){this.fileInput.wrap('<div class="moj-multi-file-upload__dropzone" />'),this.dropzone=this.container.find(".moj-multi-file-upload__dropzone"),this.dropzone.on("dragover",$.proxy(this,"onDragOver")),this.dropzone.on("dragleave",$.proxy(this,"onDragLeave")),this.dropzone.on("drop",$.proxy(this,"onDrop"))},u.prototype.setupLabel=function(){this.label=$(`<label for="${this.fileInput[0].id}" class="govuk-button govuk-button--secondary">${this.params.dropzoneButtonText}</label>`),this.dropzone.append(`<p class="govuk-body">${this.params.dropzoneHintText}</p>`),this.dropzone.append(this.label)},u.prototype.setupFileInput=function(){this.fileInput=this.container.find(".moj-multi-file-upload__input"),this.fileInput.on("change",$.proxy(this,"onFileChange")),this.fileInput.on("focus",$.proxy(this,"onFileFocus")),this.fileInput.on("blur",$.proxy(this,"onFileBlur"))},u.prototype.setupStatusBox=function(){this.status=$('<div aria-live="polite" role="status" class="govuk-visually-hidden" />'),this.dropzone.append(this.status)},u.prototype.onDragOver=function(t){t.preventDefault(),this.dropzone.addClass("moj-multi-file-upload--dragover")},u.prototype.onDragLeave=function(){this.dropzone.removeClass("moj-multi-file-upload--dragover")},u.prototype.onDrop=function(t){t.preventDefault(),this.dropzone.removeClass("moj-multi-file-upload--dragover"),this.feedbackContainer.removeClass("moj-hidden"),this.status.html(this.params.uploadStatusText),this.uploadFiles(t.originalEvent.dataTransfer.files)},u.prototype.uploadFiles=function(t){for(let e=0;e<t.length;e++)this.uploadFile(t[e])},u.prototype.onFileChange=function(t){this.feedbackContainer.removeClass("moj-hidden"),this.status.html(this.params.uploadStatusText),this.uploadFiles(t.currentTarget.files),this.fileInput.replaceWith($(t.currentTarget).val("").clone(!0)),this.setupFileInput(),this.fileInput.get(0).focus()},u.prototype.onFileFocus=function(t){this.label.addClass("moj-multi-file-upload--focused")},u.prototype.onFileBlur=function(t){this.label.removeClass("moj-multi-file-upload--focused")},u.prototype.getSuccessHtml=function(t){return`<span class="moj-multi-file-upload__success"> <svg class="moj-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25"><path d="M25,6.2L8.7,23.2L0,14.1l4-4.2l4.7,4.9L21,2L25,6.2z"/></svg>${t.messageHtml}</span>`},u.prototype.getErrorHtml=function(t){return`<span class="moj-multi-file-upload__error"> <svg class="moj-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25"><path d="M13.6,15.4h-2.3v-4.5h2.3V15.4z M13.6,19.8h-2.3v-2.2h2.3V19.8z M0,23.2h25L12.5,2L0,23.2z"/></svg>${t.message}</span>`},u.prototype.getFileRowHtml=function(t){return`\n <div class="govuk-summary-list__row moj-multi-file-upload__row">;\n <div class="govuk-summary-list__value moj-multi-file-upload__message">;\n <span class="moj-multi-file-upload__filename">${t.name}</span>;\n <span class="moj-multi-file-upload__progress">0%</span>;\n </div>';\n <div class="govuk-summary-list__actions moj-multi-file-upload__actions"></div>;\n </div>`},u.prototype.getDeleteButtonHtml=function(t){return`<button class="moj-multi-file-upload__delete govuk-button govuk-button--secondary govuk-!-margin-bottom-0" type="button" name="delete" value="${t.filename}">\n Delete <span class="govuk-visually-hidden">${t.originalname}</span>\n </button>`},u.prototype.uploadFile=function(t){this.params.uploadFileEntryHook(this,t);const e=$(this.getFileRowHtml(t)),o=new FormData;o.append("documents",t),this.feedbackContainer.find(".moj-multi-file-upload__list").append(e),$.ajax({url:this.params.uploadUrl,type:"post",data:o,processData:!1,contentType:!1,success:$.proxy((function(o){o.error?(e.find(".moj-multi-file-upload__message").html(this.getErrorHtml(o.error)),this.status.html(o.error.message)):(e.find(".moj-multi-file-upload__message").html(this.getSuccessHtml(o.success)),this.status.html(o.success.messageText)),e.find(".moj-multi-file-upload__actions").append(this.getDeleteButtonHtml(o.file)),this.params.uploadFileExitHook(this,t,o)}),this),error:$.proxy((function(e,o,n){this.params.uploadFileErrorHook(this,t,e,o,n)}),this),xhr:function(){const t=new XMLHttpRequest;return t.upload.addEventListener("progress",(function(t){if(t.lengthComputable){let o=t.loaded/t.total;o=parseInt(100*o,10),e.find(".moj-multi-file-upload__progress").text(` ${o}%`)}}),!1),t}})},u.prototype.onFileDeleteClick=function(t){t.preventDefault();const e=$(t.currentTarget),o={};o[e[0].name]=e[0].value,$.ajax({url:this.params.deleteUrl,type:"post",dataType:"json",data:o,success:$.proxy((function(t){t.error||(e.parents(".moj-multi-file-upload__row").remove(),0===this.feedbackContainer.find(".moj-multi-file-upload__row").length&&this.feedbackContainer.addClass("moj-hidden")),this.params.fileDeleteHook(this,t)}),this)})},c.prototype.getToggleHtml=function(t){let e="";return e+='<div class="govuk-checkboxes__item govuk-checkboxes--small moj-multi-select__checkbox">',e+=` <input type="checkbox" class="govuk-checkboxes__input" id="${t}">`,e+=` <label class="govuk-label govuk-checkboxes__label moj-multi-select__toggle-label" for="${t}">`,e+=' <span class="govuk-visually-hidden">Select all</span>',e+=" </label>",e+="</div>",e},c.prototype.onButtonClick=function(t){this.checked?(this.uncheckAll(),this.toggleButton[0].checked=!1):(this.checkAll(),this.toggleButton[0].checked=!0)},c.prototype.checkAll=function(){this.checkboxes.each($.proxy((function(t,e){e.checked=!0}),this)),this.checked=!0},c.prototype.uncheckAll=function(){this.checkboxes.each($.proxy((function(t,e){e.checked=!1}),this)),this.checked=!1},c.prototype.onCheckboxClick=function(t){t.target.checked?this.checkboxes.filter(":checked").length===this.checkboxes.length&&(this.toggleButton[0].checked=!0,this.checked=!0):(this.toggleButton[0].checked=!1,this.checked=!1)},d.prototype.createButton=function(){this.button=$('<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'),this.container.append(this.button),this.button.on("click",$.proxy(this,"onButtonClick"))},d.prototype.onButtonClick=function(){"password"===this.el.type?(this.el.type="text",this.button.html('Hide <span class="govuk-visually-hidden">password</span>')):(this.el.type="password",this.button.html('Show <span class="govuk-visually-hidden">password</span>'))},h.prototype.onToolbarKeydown=function(t){let e;switch(t.keyCode){case this.keys.right:case this.keys.down:{e=this.toolbar.find("button[tabindex=0]");const t=e.next("button");t[0]&&(t.focus(),e.attr("tabindex","-1"),t.attr("tabindex","0"));break}case this.keys.left:case this.keys.up:{e=this.toolbar.find("button[tabindex=0]");const t=e.prev("button");t[0]&&(t.focus(),e.attr("tabindex","-1"),t.attr("tabindex","0"));break}}},h.prototype.getToolbarHtml=function(){let t="";return t+='<div class="moj-rich-text-editor__toolbar" role="toolbar">',this.options.toolbar.bold&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>'),this.options.toolbar.italic&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>'),this.options.toolbar.underline&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>'),this.options.toolbar.bullets&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>'),this.options.toolbar.numbers&&(t+='<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>'),t+="</div>",t},h.prototype.getEnhancedHtml=function(t){return`${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`},h.prototype.hideDefault=function(){this.textarea=this.container.find("textarea"),this.textarea.addClass("govuk-visually-hidden"),this.textarea.attr("aria-hidden",!0),this.textarea.attr("tabindex","-1")},h.prototype.createToolbar=function(){this.toolbar=document.createElement("div"),this.toolbar.className="moj-rich-text-editor",this.toolbar.innerHTML=this.getEnhancedHtml(),this.container.append(this.toolbar),this.toolbar=this.container.find(".moj-rich-text-editor__toolbar"),this.container.find(".moj-rich-text-editor__content").html(this.textarea.val())},h.prototype.configureToolbar=function(){this.buttons=this.container.find(".moj-rich-text-editor__toolbar-button"),this.buttons.prop("tabindex","-1");this.buttons.first().prop("tabindex","0")},h.prototype.onButtonClick=function(t){document.execCommand($(t.currentTarget).data("command"),!1,null)},h.prototype.getContent=function(){return this.container.find(".moj-rich-text-editor__content").html()},h.prototype.onEditorInput=function(t){this.updateTextarea()},h.prototype.updateTextarea=function(){document.execCommand("defaultParagraphSeparator",!1,"p"),this.textarea.val(this.getContent())},h.prototype.onLabelClick=function(t){t.preventDefault(),this.container.find(".moj-rich-text-editor__content").focus()},p.prototype.showMenu=function(){this.toggleButton.attr("aria-expanded","true"),this.container.removeClass("moj-js-hidden"),this.container.find("input").first().get(0).focus()},p.prototype.hideMenu=function(){this.container.addClass("moj-js-hidden"),this.toggleButton.attr("aria-expanded","false")},p.prototype.onToggleButtonClick=function(){"false"===this.toggleButton.attr("aria-expanded")?this.showMenu():this.hideMenu()},p.prototype.onDocumentClick=function(t){$.contains(this.toggleButtonContainer[0],t.target)||$.contains(this.container[0],t.target)||this.hideMenu()},f.prototype.setupOptions=function(t){t=t||{},this.statusMessage=t.statusMessage||"Sort by %heading% (%direction%)",this.ascendingText=t.ascendingText||"ascending",this.descendingText=t.descendingText||"descending"},f.prototype.createHeadingButtons=function(){const t=this.table.find("thead th");let e;for(let o=0;o<t.length;o++)e=$(t[o]),e.attr("aria-sort")&&this.createHeadingButton(e,o)},f.prototype.createHeadingButton=function(t,e){const o=t.text(),n=$(`<button type="button" data-index="${e}">${o}</button>`);t.text(""),t.append(n)},f.prototype.createStatusBox=function(){this.status=$('<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'),this.table.parent().append(this.status)},f.prototype.initialiseSortedColumn=function(){const t=this.getTableRowsArray();this.table.find("th").filter('[aria-sort="ascending"], [aria-sort="descending"]').first().each(((e,o)=>{const n=$(o).attr("aria-sort"),i=$(o).find("button").attr("data-index"),s=this.sort(t,i,n);this.addRows(s)}))},f.prototype.onSortButtonClick=function(t){const e=t.currentTarget.getAttribute("data-index"),o=$(t.currentTarget).parent().attr("aria-sort");let n;n="none"===o||"descending"===o?"ascending":"descending";const i=this.getTableRowsArray(),s=this.sort(i,e,n);this.addRows(s),this.removeButtonStates(),this.updateButtonState($(t.currentTarget),n)},f.prototype.updateButtonState=function(t,e){t.parent().attr("aria-sort",e);let o=this.statusMessage;o=o.replace(/%heading%/,t.text()),o=o.replace(/%direction%/,this[`${e}Text`]),this.status.text(o)},f.prototype.removeButtonStates=function(){this.table.find("thead th").attr("aria-sort","none")},f.prototype.addRows=function(t){for(let e=0;e<t.length;e++)this.body.append(t[e])},f.prototype.getTableRowsArray=function(){const t=[],e=this.body.find("tr");for(let o=0;o<e.length;o++)t.push(e[o]);return t},f.prototype.sort=function(t,e,o){return t.sort(function(t,n){const i=$(t).find("td,th").eq(e),s=$(n).find("td,th").eq(e),a="ascending"===o?this.getCellValue(i):this.getCellValue(s),r="ascending"===o?this.getCellValue(s):this.getCellValue(i);return"string"==typeof a||"string"==typeof r?a.toString().localeCompare(r.toString()):a-r}.bind(this))},f.prototype.getCellValue=function(t){const e=t.attr("data-sort-value")||t.html(),o=Number(e);return isNaN(o)?e:o};t.AddAnother=e,t.Alert=i,t.ButtonMenu=s,t.DatePicker=a,t.FilterToggleButton=l,t.MultiFileUpload=u,t.MultiSelect=c,t.PasswordReveal=d,t.RichTextEditor=h,t.SearchToggle=p,t.SortableTable=f,t.initAll=function(t){const n=void 0!==(t=void 0!==t?t:{}).scope?t.scope:document;o(n.querySelectorAll('[data-module="moj-add-another"]'),(function(t){new e(t)})),o(n.querySelectorAll('[data-module="moj-multi-select"]'),(function(t){new c({container:t.querySelector(t.getAttribute("data-multi-select-checkbox")),checkboxes:t.querySelectorAll("tbody .govuk-checkboxes__input"),id_prefix:t.getAttribute("data-multi-select-idprefix")})})),o(n.querySelectorAll('[data-module="moj-password-reveal"]'),(function(t){new d(t)})),o(n.querySelectorAll('[data-module="moj-rich-text-editor"]'),(function(t){const e={textarea:$(t)},o=t.getAttribute("data-moj-rich-text-editor-toolbar");if(o){const t=o.split(",");e.toolbar={};for(const o in t)e.toolbar[t[o]]=!0}new h(e)})),o(n.querySelectorAll('[data-module="moj-search-toggle"]'),(function(t){new p({toggleButton:{container:$(t.querySelector(".moj-search-toggle__toggle")),text:t.getAttribute("data-moj-search-toggle-text")},search:{container:$(t.querySelector(".moj-search"))}})})),o(n.querySelectorAll('[data-module="moj-sortable-table"]'),(function(t){new f({table:t})})),o(n.querySelectorAll('[data-module="moj-date-picker"]'),(function(t){new a(t,{}).init()})),o(n.querySelectorAll('[data-module="moj-button-menu"]'),(function(t){new s(t,{}).init()})),o(n.querySelectorAll('[data-module="moj-alert"]'),(function(t){new i(t,{}).init()}))},t.version="0.0.0-development"}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/frontend",
|
|
3
3
|
"description": "The MOJ Frontend contains the code you need to start building user interfaces for UK Ministry of Justice government services.",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.2",
|
|
5
5
|
"main": "moj/all.js",
|
|
6
6
|
"module": "moj/all.mjs",
|
|
7
7
|
"sass": "moj/all.scss",
|