@ministryofjustice/frontend 3.5.0 → 3.6.1
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 -81
- package/moj/all.js +2577 -2853
- package/moj/all.mjs +126 -0
- package/moj/all.scss +1 -1
- package/moj/components/add-another/add-another.js +111 -132
- package/moj/components/add-another/add-another.mjs +106 -0
- package/moj/components/alert/alert.js +352 -479
- package/moj/components/alert/alert.mjs +251 -0
- package/moj/components/alert/alert.spec.helper.js +6 -24
- package/moj/components/alert/alert.spec.helper.mjs +66 -0
- package/moj/components/button-menu/button-menu.js +326 -343
- package/moj/components/button-menu/button-menu.mjs +329 -0
- package/moj/components/cookie-banner/_cookie-banner.scss +1 -1
- package/moj/components/date-picker/date-picker.js +905 -922
- package/moj/components/date-picker/date-picker.mjs +961 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.js +98 -119
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs +93 -0
- package/moj/components/form-validator/form-validator.js +201 -396
- package/moj/components/form-validator/form-validator.mjs +168 -0
- package/moj/components/multi-file-upload/multi-file-upload.js +227 -441
- package/moj/components/multi-file-upload/multi-file-upload.mjs +219 -0
- package/moj/components/multi-select/multi-select.js +82 -103
- package/moj/components/multi-select/multi-select.mjs +77 -0
- package/moj/components/password-reveal/password-reveal.js +40 -61
- package/moj/components/password-reveal/password-reveal.mjs +35 -0
- package/moj/components/rich-text-editor/rich-text-editor.js +162 -183
- package/moj/components/rich-text-editor/rich-text-editor.mjs +157 -0
- package/moj/components/search-toggle/search-toggle.js +52 -73
- package/moj/components/search-toggle/search-toggle.mjs +54 -0
- package/moj/components/sortable-table/sortable-table.js +143 -164
- package/moj/components/sortable-table/sortable-table.mjs +138 -0
- package/moj/helpers.js +196 -215
- package/moj/helpers.mjs +123 -0
- package/moj/moj-frontend.min.js +1 -81
- package/moj/version.js +6 -23
- package/moj/version.mjs +3 -0
- package/package.json +24 -6
|
@@ -1,122 +1,101 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(this, (function () { 'use strict';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
FilterToggleButton.prototype.onMenuButtonClick = function () {
|
|
101
|
-
this.toggle();
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
FilterToggleButton.prototype.toggle = function () {
|
|
105
|
-
if (this.menuButton.attr('aria-expanded') === 'false') {
|
|
106
|
-
this.showMenu();
|
|
107
|
-
this.filterContainer.get(0).focus();
|
|
108
|
-
} else {
|
|
109
|
-
this.hideMenu();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
filterToggleButton$1 = { FilterToggleButton };
|
|
114
|
-
return filterToggleButton$1;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
var filterToggleButtonExports = requireFilterToggleButton();
|
|
118
|
-
var filterToggleButton = /*@__PURE__*/getDefaultExportFromCjs(filterToggleButtonExports);
|
|
119
|
-
|
|
120
|
-
return filterToggleButton;
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function FilterToggleButton(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.container = window.jQuery(this.options.toggleButton.container);
|
|
10
|
+
this.filterContainer = window.jQuery(this.options.filter.container);
|
|
11
|
+
|
|
12
|
+
this.createToggleButton();
|
|
13
|
+
this.setupResponsiveChecks();
|
|
14
|
+
this.filterContainer.attr('tabindex', '-1');
|
|
15
|
+
if (this.options.startHidden) {
|
|
16
|
+
this.hideMenu();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
FilterToggleButton.prototype.setupResponsiveChecks = function () {
|
|
21
|
+
this.mq = window.matchMedia(this.options.bigModeMediaQuery);
|
|
22
|
+
this.mq.addListener(window.jQuery.proxy(this, 'checkMode'));
|
|
23
|
+
this.checkMode(this.mq);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
FilterToggleButton.prototype.createToggleButton = function () {
|
|
27
|
+
this.menuButton = window.jQuery(
|
|
28
|
+
`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`
|
|
29
|
+
);
|
|
30
|
+
this.menuButton.on('click', window.jQuery.proxy(this, 'onMenuButtonClick'));
|
|
31
|
+
this.container.append(this.menuButton);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
FilterToggleButton.prototype.checkMode = function (mq) {
|
|
35
|
+
if (mq.matches) {
|
|
36
|
+
this.enableBigMode();
|
|
37
|
+
} else {
|
|
38
|
+
this.enableSmallMode();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
FilterToggleButton.prototype.enableBigMode = function () {
|
|
43
|
+
this.showMenu();
|
|
44
|
+
this.removeCloseButton();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
FilterToggleButton.prototype.enableSmallMode = function () {
|
|
48
|
+
this.hideMenu();
|
|
49
|
+
this.addCloseButton();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
FilterToggleButton.prototype.addCloseButton = function () {
|
|
53
|
+
if (this.options.closeButton) {
|
|
54
|
+
this.closeButton = window.jQuery(
|
|
55
|
+
`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`
|
|
56
|
+
);
|
|
57
|
+
this.closeButton.on('click', window.jQuery.proxy(this, 'onCloseClick'));
|
|
58
|
+
window.jQuery(this.options.closeButton.container).append(this.closeButton);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
FilterToggleButton.prototype.onCloseClick = function () {
|
|
63
|
+
this.hideMenu();
|
|
64
|
+
this.menuButton.focus();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
FilterToggleButton.prototype.removeCloseButton = function () {
|
|
68
|
+
if (this.closeButton) {
|
|
69
|
+
this.closeButton.remove();
|
|
70
|
+
this.closeButton = null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
FilterToggleButton.prototype.hideMenu = function () {
|
|
75
|
+
this.menuButton.attr('aria-expanded', 'false');
|
|
76
|
+
this.filterContainer.addClass('moj-js-hidden');
|
|
77
|
+
this.menuButton.text(this.options.toggleButton.showText);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
FilterToggleButton.prototype.showMenu = function () {
|
|
81
|
+
this.menuButton.attr('aria-expanded', 'true');
|
|
82
|
+
this.filterContainer.removeClass('moj-js-hidden');
|
|
83
|
+
this.menuButton.text(this.options.toggleButton.hideText);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
FilterToggleButton.prototype.onMenuButtonClick = function () {
|
|
87
|
+
this.toggle();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
FilterToggleButton.prototype.toggle = function () {
|
|
91
|
+
if (this.menuButton.attr('aria-expanded') === 'false') {
|
|
92
|
+
this.showMenu();
|
|
93
|
+
this.filterContainer.get(0).focus();
|
|
94
|
+
} else {
|
|
95
|
+
this.hideMenu();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.FilterToggleButton = FilterToggleButton;
|
|
121
100
|
|
|
122
101
|
}));
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function FilterToggleButton(options) {
|
|
2
|
+
this.options = options;
|
|
3
|
+
this.container = window.jQuery(this.options.toggleButton.container);
|
|
4
|
+
this.filterContainer = window.jQuery(this.options.filter.container);
|
|
5
|
+
|
|
6
|
+
this.createToggleButton();
|
|
7
|
+
this.setupResponsiveChecks();
|
|
8
|
+
this.filterContainer.attr('tabindex', '-1');
|
|
9
|
+
if (this.options.startHidden) {
|
|
10
|
+
this.hideMenu();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
FilterToggleButton.prototype.setupResponsiveChecks = function () {
|
|
15
|
+
this.mq = window.matchMedia(this.options.bigModeMediaQuery);
|
|
16
|
+
this.mq.addListener(window.jQuery.proxy(this, 'checkMode'));
|
|
17
|
+
this.checkMode(this.mq);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
FilterToggleButton.prototype.createToggleButton = function () {
|
|
21
|
+
this.menuButton = window.jQuery(
|
|
22
|
+
`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`
|
|
23
|
+
);
|
|
24
|
+
this.menuButton.on('click', window.jQuery.proxy(this, 'onMenuButtonClick'));
|
|
25
|
+
this.container.append(this.menuButton);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
FilterToggleButton.prototype.checkMode = function (mq) {
|
|
29
|
+
if (mq.matches) {
|
|
30
|
+
this.enableBigMode();
|
|
31
|
+
} else {
|
|
32
|
+
this.enableSmallMode();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
FilterToggleButton.prototype.enableBigMode = function () {
|
|
37
|
+
this.showMenu();
|
|
38
|
+
this.removeCloseButton();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
FilterToggleButton.prototype.enableSmallMode = function () {
|
|
42
|
+
this.hideMenu();
|
|
43
|
+
this.addCloseButton();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
FilterToggleButton.prototype.addCloseButton = function () {
|
|
47
|
+
if (this.options.closeButton) {
|
|
48
|
+
this.closeButton = window.jQuery(
|
|
49
|
+
`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`
|
|
50
|
+
);
|
|
51
|
+
this.closeButton.on('click', window.jQuery.proxy(this, 'onCloseClick'));
|
|
52
|
+
window.jQuery(this.options.closeButton.container).append(this.closeButton);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
FilterToggleButton.prototype.onCloseClick = function () {
|
|
57
|
+
this.hideMenu();
|
|
58
|
+
this.menuButton.focus();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
FilterToggleButton.prototype.removeCloseButton = function () {
|
|
62
|
+
if (this.closeButton) {
|
|
63
|
+
this.closeButton.remove();
|
|
64
|
+
this.closeButton = null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
FilterToggleButton.prototype.hideMenu = function () {
|
|
69
|
+
this.menuButton.attr('aria-expanded', 'false');
|
|
70
|
+
this.filterContainer.addClass('moj-js-hidden');
|
|
71
|
+
this.menuButton.text(this.options.toggleButton.showText);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
FilterToggleButton.prototype.showMenu = function () {
|
|
75
|
+
this.menuButton.attr('aria-expanded', 'true');
|
|
76
|
+
this.filterContainer.removeClass('moj-js-hidden');
|
|
77
|
+
this.menuButton.text(this.options.toggleButton.hideText);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
FilterToggleButton.prototype.onMenuButtonClick = function () {
|
|
81
|
+
this.toggle();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
FilterToggleButton.prototype.toggle = function () {
|
|
85
|
+
if (this.menuButton.attr('aria-expanded') === 'false') {
|
|
86
|
+
this.showMenu();
|
|
87
|
+
this.filterContainer.get(0).focus();
|
|
88
|
+
} else {
|
|
89
|
+
this.hideMenu();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { FilterToggleButton };
|