@ministryofjustice/frontend 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/moj/all.jquery.min.js +7 -70
- package/moj/all.js +2856 -2865
- package/moj/components/add-another/add-another.js +135 -104
- package/moj/components/alert/alert.js +482 -247
- package/moj/components/alert/alert.spec.helper.js +30 -5
- package/moj/components/button-menu/button-menu.js +346 -319
- package/moj/components/date-picker/date-picker.js +925 -900
- package/moj/components/filter-toggle-button/filter-toggle-button.js +122 -91
- package/moj/components/form-validator/form-validator.js +399 -164
- package/moj/components/multi-file-upload/multi-file-upload.js +445 -210
- package/moj/components/multi-select/multi-select.js +106 -75
- package/moj/components/password-reveal/password-reveal.js +64 -33
- package/moj/components/rich-text-editor/rich-text-editor.js +186 -153
- package/moj/components/search-toggle/search-toggle.js +77 -46
- package/moj/components/sortable-table/sortable-table.js +167 -146
- package/moj/helpers/_links.scss +1 -1
- package/moj/helpers.js +218 -180
- package/moj/moj-frontend.min.js +7 -70
- package/moj/version.js +28 -1
- package/package.json +1 -1
- package/moj/all.spec.js +0 -24
- package/moj/components/add-another/add-another.spec.js +0 -165
- package/moj/components/alert/alert.spec.js +0 -229
- package/moj/components/button-menu/button-menu.spec.js +0 -360
- package/moj/components/date-picker/date-picker.spec.js +0 -1178
- package/moj/components/filter-toggle-button/filter-toggle-button.spec.js +0 -302
- package/moj/components/multi-file-upload/multi-file-upload.spec.js +0 -510
- package/moj/components/multi-select/multi-select.spec.js +0 -128
- package/moj/components/password-reveal/password-reveal.spec.js +0 -57
- package/moj/components/search-toggle/search-toggle.spec.js +0 -129
- package/moj/components/sortable-table/sortable-table.spec.js +0 -362
- package/moj/helpers.spec.js +0 -235
- package/moj/namespace.js +0 -2
|
@@ -1,104 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MOJFrontend = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromCjs (x) {
|
|
8
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var _global_window_jQuery = window.jQuery;
|
|
12
|
+
|
|
13
|
+
var addAnother$1;
|
|
14
|
+
var hasRequiredAddAnother;
|
|
15
|
+
|
|
16
|
+
function requireAddAnother () {
|
|
17
|
+
if (hasRequiredAddAnother) return addAnother$1;
|
|
18
|
+
hasRequiredAddAnother = 1;
|
|
19
|
+
const $ = _global_window_jQuery;
|
|
20
|
+
|
|
21
|
+
function AddAnother(container) {
|
|
22
|
+
this.container = $(container);
|
|
23
|
+
|
|
24
|
+
if (this.container.data('moj-add-another-initialised')) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.container.data('moj-add-another-initialised', true);
|
|
29
|
+
|
|
30
|
+
this.container.on(
|
|
31
|
+
'click',
|
|
32
|
+
'.moj-add-another__remove-button',
|
|
33
|
+
$.proxy(this, 'onRemoveButtonClick')
|
|
34
|
+
);
|
|
35
|
+
this.container.on(
|
|
36
|
+
'click',
|
|
37
|
+
'.moj-add-another__add-button',
|
|
38
|
+
$.proxy(this, 'onAddButtonClick')
|
|
39
|
+
);
|
|
40
|
+
this.container
|
|
41
|
+
.find('.moj-add-another__add-button, moj-add-another__remove-button')
|
|
42
|
+
.prop('type', 'button');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
AddAnother.prototype.onAddButtonClick = function (e) {
|
|
46
|
+
const item = this.getNewItem();
|
|
47
|
+
this.updateAttributes(this.getItems().length, item);
|
|
48
|
+
this.resetItem(item);
|
|
49
|
+
const firstItem = this.getItems().first();
|
|
50
|
+
if (!this.hasRemoveButton(firstItem)) {
|
|
51
|
+
this.createRemoveButton(firstItem);
|
|
52
|
+
}
|
|
53
|
+
this.getItems().last().after(item);
|
|
54
|
+
item.find('input, textarea, select').first().focus();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
AddAnother.prototype.hasRemoveButton = function (item) {
|
|
58
|
+
return item.find('.moj-add-another__remove-button').length
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
AddAnother.prototype.getItems = function () {
|
|
62
|
+
return this.container.find('.moj-add-another__item')
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
AddAnother.prototype.getNewItem = function () {
|
|
66
|
+
const item = this.getItems().first().clone();
|
|
67
|
+
if (!this.hasRemoveButton(item)) {
|
|
68
|
+
this.createRemoveButton(item);
|
|
69
|
+
}
|
|
70
|
+
return item
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
AddAnother.prototype.updateAttributes = function (index, item) {
|
|
74
|
+
item.find('[data-name]').each(function (i, el) {
|
|
75
|
+
const originalId = el.id;
|
|
76
|
+
|
|
77
|
+
el.name = $(el)
|
|
78
|
+
.attr('data-name')
|
|
79
|
+
.replace(/%index%/, index);
|
|
80
|
+
el.id = $(el)
|
|
81
|
+
.attr('data-id')
|
|
82
|
+
.replace(/%index%/, index);
|
|
83
|
+
|
|
84
|
+
const label =
|
|
85
|
+
$(el).siblings('label')[0] ||
|
|
86
|
+
$(el).parents('label')[0] ||
|
|
87
|
+
item.find(`[for="${originalId}"]`)[0];
|
|
88
|
+
label.htmlFor = el.id;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
AddAnother.prototype.createRemoveButton = function (item) {
|
|
93
|
+
item.append(
|
|
94
|
+
'<button type="button" class="govuk-button govuk-button--secondary moj-add-another__remove-button">Remove</button>'
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
AddAnother.prototype.resetItem = function (item) {
|
|
99
|
+
item.find('[data-name], [data-id]').each(function (index, el) {
|
|
100
|
+
if (el.type === 'checkbox' || el.type === 'radio') {
|
|
101
|
+
el.checked = false;
|
|
102
|
+
} else {
|
|
103
|
+
el.value = '';
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
AddAnother.prototype.onRemoveButtonClick = function (e) {
|
|
109
|
+
$(e.currentTarget).parents('.moj-add-another__item').remove();
|
|
110
|
+
const items = this.getItems();
|
|
111
|
+
if (items.length === 1) {
|
|
112
|
+
items.find('.moj-add-another__remove-button').remove();
|
|
113
|
+
}
|
|
114
|
+
items.each(
|
|
115
|
+
$.proxy(function (index, el) {
|
|
116
|
+
this.updateAttributes(index, $(el));
|
|
117
|
+
}, this)
|
|
118
|
+
);
|
|
119
|
+
this.focusHeading();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
AddAnother.prototype.focusHeading = function () {
|
|
123
|
+
this.container.find('.moj-add-another__heading').get(0).focus();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
addAnother$1 = { AddAnother };
|
|
127
|
+
return addAnother$1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var addAnotherExports = requireAddAnother();
|
|
131
|
+
var addAnother = /*@__PURE__*/getDefaultExportFromCjs(addAnotherExports);
|
|
132
|
+
|
|
133
|
+
return addAnother;
|
|
134
|
+
|
|
135
|
+
}));
|