@ministryofjustice/frontend 4.0.0 → 5.0.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/govuk-prototype-kit.config.json +19 -4
- package/moj/_base.scss +2 -0
- package/moj/_base.scss.map +1 -0
- package/moj/all.bundle.js +2523 -0
- package/moj/all.bundle.js.map +1 -0
- package/moj/all.bundle.mjs +2502 -0
- package/moj/all.bundle.mjs.map +1 -0
- package/moj/all.mjs +59 -69
- package/moj/all.mjs.map +1 -1
- package/moj/all.scss +2 -0
- package/moj/all.scss.map +1 -0
- package/moj/components/_all.scss +2 -0
- package/moj/components/_all.scss.map +1 -0
- package/moj/components/action-bar/_action-bar.scss +2 -0
- package/moj/components/action-bar/_action-bar.scss.map +1 -0
- package/moj/components/add-another/_add-another.scss +2 -0
- package/moj/components/add-another/_add-another.scss.map +1 -0
- package/moj/components/add-another/add-another.bundle.js +128 -0
- package/moj/components/add-another/add-another.bundle.js.map +1 -0
- package/moj/components/add-another/add-another.bundle.mjs +120 -0
- package/moj/components/add-another/add-another.bundle.mjs.map +1 -0
- package/moj/components/add-another/add-another.mjs +112 -99
- package/moj/components/add-another/add-another.mjs.map +1 -1
- package/moj/components/alert/_alert.scss +4 -0
- package/moj/components/alert/_alert.scss.map +1 -0
- package/moj/components/alert/alert.bundle.js +330 -0
- package/moj/components/alert/alert.bundle.js.map +1 -0
- package/moj/components/alert/alert.bundle.mjs +322 -0
- package/moj/components/alert/alert.bundle.mjs.map +1 -0
- package/moj/components/alert/alert.mjs +181 -217
- package/moj/components/alert/alert.mjs.map +1 -1
- package/moj/components/alert/{alert.spec.helper.js → alert.spec.helper.bundle.js} +1 -1
- package/moj/components/alert/alert.spec.helper.bundle.js.map +1 -0
- package/moj/components/alert/alert.spec.helper.bundle.mjs +67 -0
- package/moj/components/alert/alert.spec.helper.bundle.mjs.map +1 -0
- package/moj/components/alert/alert.spec.helper.mjs.map +1 -1
- package/moj/components/badge/_badge.scss +2 -0
- package/moj/components/badge/_badge.scss.map +1 -0
- package/moj/components/banner/_banner.scss +2 -0
- package/moj/components/banner/_banner.scss.map +1 -0
- package/moj/components/button-menu/README.md +10 -6
- package/moj/components/button-menu/_button-menu.scss +10 -3
- package/moj/components/button-menu/_button-menu.scss.map +1 -0
- package/moj/components/button-menu/button-menu.bundle.js +299 -0
- package/moj/components/button-menu/button-menu.bundle.js.map +1 -0
- package/moj/components/button-menu/{button-menu.js → button-menu.bundle.mjs} +74 -121
- package/moj/components/button-menu/button-menu.bundle.mjs.map +1 -0
- package/moj/components/button-menu/button-menu.mjs +246 -285
- package/moj/components/button-menu/button-menu.mjs.map +1 -1
- package/moj/components/cookie-banner/_cookie-banner.scss +2 -0
- package/moj/components/cookie-banner/_cookie-banner.scss.map +1 -0
- package/moj/components/currency-input/_currency-input.scss +2 -0
- package/moj/components/currency-input/_currency-input.scss.map +1 -0
- package/moj/components/date-picker/_date-picker.scss +2 -0
- package/moj/components/date-picker/_date-picker.scss.map +1 -0
- package/moj/components/date-picker/date-picker.bundle.js +784 -0
- package/moj/components/date-picker/date-picker.bundle.js.map +1 -0
- package/moj/components/date-picker/{date-picker.js → date-picker.bundle.mjs} +245 -439
- package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -0
- package/moj/components/date-picker/date-picker.mjs +654 -840
- package/moj/components/date-picker/date-picker.mjs.map +1 -1
- package/moj/components/filter/_filter.scss +2 -0
- package/moj/components/filter/_filter.scss.map +1 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js +96 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js.map +1 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs +88 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs.map +1 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs +78 -84
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs.map +1 -1
- package/moj/components/form-validator/form-validator.bundle.js +198 -0
- package/moj/components/form-validator/form-validator.bundle.js.map +1 -0
- package/moj/components/form-validator/form-validator.bundle.mjs +190 -0
- package/moj/components/form-validator/form-validator.bundle.mjs.map +1 -0
- package/moj/components/form-validator/form-validator.mjs +149 -152
- package/moj/components/form-validator/form-validator.mjs.map +1 -1
- package/moj/components/header/_header.scss +2 -0
- package/moj/components/header/_header.scss.map +1 -0
- package/moj/components/identity-bar/_identity-bar.scss +2 -0
- package/moj/components/identity-bar/_identity-bar.scss.map +1 -0
- package/moj/components/interruption-card/_interruption-card.scss +2 -0
- package/moj/components/interruption-card/_interruption-card.scss.map +1 -0
- package/moj/components/messages/_messages.scss +2 -0
- package/moj/components/messages/_messages.scss.map +1 -0
- package/moj/components/multi-file-upload/_multi-file-upload.scss +2 -0
- package/moj/components/multi-file-upload/_multi-file-upload.scss.map +1 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.js +223 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.js.map +1 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs +215 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs.map +1 -0
- package/moj/components/multi-file-upload/multi-file-upload.mjs +193 -209
- package/moj/components/multi-file-upload/multi-file-upload.mjs.map +1 -1
- package/moj/components/multi-select/_multi-select.scss +2 -0
- package/moj/components/multi-select/_multi-select.scss.map +1 -0
- package/moj/components/multi-select/multi-select.bundle.js +78 -0
- package/moj/components/multi-select/multi-select.bundle.js.map +1 -0
- package/moj/components/multi-select/multi-select.bundle.mjs +70 -0
- package/moj/components/multi-select/multi-select.bundle.mjs.map +1 -0
- package/moj/components/multi-select/multi-select.mjs +59 -67
- package/moj/components/multi-select/multi-select.mjs.map +1 -1
- package/moj/components/notification-badge/_notification-badge.scss +2 -0
- package/moj/components/notification-badge/_notification-badge.scss.map +1 -0
- package/moj/components/organisation-switcher/_organisation-switcher.scss +2 -0
- package/moj/components/organisation-switcher/_organisation-switcher.scss.map +1 -0
- package/moj/components/page-header-actions/_page-header-actions.scss +2 -0
- package/moj/components/page-header-actions/_page-header-actions.scss.map +1 -0
- package/moj/components/page-header-actions/template.njk +1 -1
- package/moj/components/pagination/_pagination.scss +2 -2
- package/moj/components/pagination/_pagination.scss.map +1 -0
- package/moj/components/password-reveal/_password-reveal.scss +2 -0
- package/moj/components/password-reveal/_password-reveal.scss.map +1 -0
- package/moj/components/password-reveal/password-reveal.bundle.js +49 -0
- package/moj/components/password-reveal/password-reveal.bundle.js.map +1 -0
- package/moj/components/password-reveal/password-reveal.bundle.mjs +41 -0
- package/moj/components/password-reveal/password-reveal.bundle.mjs.map +1 -0
- package/moj/components/password-reveal/password-reveal.mjs +36 -31
- package/moj/components/password-reveal/password-reveal.mjs.map +1 -1
- package/moj/components/primary-navigation/_primary-navigation.scss +2 -0
- package/moj/components/primary-navigation/_primary-navigation.scss.map +1 -0
- package/moj/components/progress-bar/_progress-bar.scss +2 -0
- package/moj/components/progress-bar/_progress-bar.scss.map +1 -0
- package/moj/components/rich-text-editor/README.md +15 -9
- package/moj/components/rich-text-editor/_rich-text-editor.scss +2 -0
- package/moj/components/rich-text-editor/_rich-text-editor.scss.map +1 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.js +145 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.js.map +1 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs +137 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs.map +1 -0
- package/moj/components/rich-text-editor/rich-text-editor.mjs +124 -145
- package/moj/components/rich-text-editor/rich-text-editor.mjs.map +1 -1
- package/moj/components/search/_search.scss +2 -0
- package/moj/components/search/_search.scss.map +1 -0
- package/moj/components/search-toggle/{search-toggle.scss → _search-toggle.scss} +2 -0
- package/moj/components/search-toggle/_search-toggle.scss.map +1 -0
- package/moj/components/search-toggle/search-toggle.bundle.js +54 -0
- package/moj/components/search-toggle/search-toggle.bundle.js.map +1 -0
- package/moj/components/search-toggle/search-toggle.bundle.mjs +46 -0
- package/moj/components/search-toggle/search-toggle.bundle.mjs.map +1 -0
- package/moj/components/search-toggle/search-toggle.mjs +40 -49
- package/moj/components/search-toggle/search-toggle.mjs.map +1 -1
- package/moj/components/side-navigation/_side-navigation.scss +2 -0
- package/moj/components/side-navigation/_side-navigation.scss.map +1 -0
- package/moj/components/sortable-table/_sortable-table.scss +2 -2
- package/moj/components/sortable-table/_sortable-table.scss.map +1 -0
- package/moj/components/sortable-table/sortable-table.bundle.js +134 -0
- package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -0
- package/moj/components/sortable-table/sortable-table.bundle.mjs +126 -0
- package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -0
- package/moj/components/sortable-table/sortable-table.mjs +117 -130
- package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
- package/moj/components/sub-navigation/_sub-navigation.scss +2 -0
- package/moj/components/sub-navigation/_sub-navigation.scss.map +1 -0
- package/moj/components/tag/_tag.scss +2 -0
- package/moj/components/tag/_tag.scss.map +1 -0
- package/moj/components/task-list/_task-list.scss +2 -0
- package/moj/components/task-list/_task-list.scss.map +1 -0
- package/moj/components/ticket-panel/_ticket-panel.scss +2 -0
- package/moj/components/ticket-panel/_ticket-panel.scss.map +1 -0
- package/moj/components/timeline/_timeline.scss +2 -0
- package/moj/components/timeline/_timeline.scss.map +1 -0
- package/moj/filters/all.js +44 -22
- package/moj/helpers/_all.scss +2 -0
- package/moj/helpers/_all.scss.map +1 -0
- package/moj/helpers/_hidden.scss +2 -0
- package/moj/helpers/_hidden.scss.map +1 -0
- package/moj/helpers/_links.scss +2 -0
- package/moj/helpers/_links.scss.map +1 -0
- package/moj/{helpers.js → helpers.bundle.js} +37 -42
- package/moj/helpers.bundle.js.map +1 -0
- package/moj/helpers.bundle.mjs +179 -0
- package/moj/helpers.bundle.mjs.map +1 -0
- package/moj/helpers.mjs +52 -28
- package/moj/helpers.mjs.map +1 -1
- package/moj/init.js +11 -2
- package/moj/moj-frontend.min.css +1 -1
- package/moj/moj-frontend.min.css.map +1 -1
- package/moj/moj-frontend.min.js +1 -1
- package/moj/moj-frontend.min.js.map +1 -1
- package/moj/objects/_all.scss +2 -0
- package/moj/objects/_all.scss.map +1 -0
- package/moj/objects/_button-group.scss +17 -1
- package/moj/objects/_button-group.scss.map +1 -0
- package/moj/objects/_filter-layout.scss +2 -0
- package/moj/objects/_filter-layout.scss.map +1 -0
- package/moj/objects/_scrollable-pane.scss +2 -0
- package/moj/objects/_scrollable-pane.scss.map +1 -0
- package/moj/objects/_width-container.scss +2 -0
- package/moj/objects/_width-container.scss.map +1 -0
- package/moj/settings/_all.scss +2 -0
- package/moj/settings/_all.scss.map +1 -0
- package/moj/settings/_assets.scss +2 -0
- package/moj/settings/_assets.scss.map +1 -0
- package/moj/settings/_colours.scss +2 -0
- package/moj/settings/_colours.scss.map +1 -0
- package/moj/settings/_measurements.scss +2 -0
- package/moj/settings/_measurements.scss.map +1 -0
- package/moj/settings/_typography.scss +2 -0
- package/moj/settings/_typography.scss.map +1 -0
- package/moj/template.njk +13 -0
- package/moj/utilities/_all.scss +2 -0
- package/moj/utilities/_all.scss.map +1 -0
- package/moj/utilities/_hidden.scss +2 -0
- package/moj/utilities/_hidden.scss.map +1 -0
- package/moj/utilities/_width-container.scss +2 -0
- package/moj/utilities/_width-container.scss.map +1 -0
- package/moj/vendor/govuk-frontend/_base.scss +2 -0
- package/moj/vendor/govuk-frontend/_base.scss.map +1 -0
- package/moj/vendor/govuk-frontend/_index.scss +2 -0
- package/moj/vendor/govuk-frontend/_index.scss.map +1 -0
- package/moj/{version.js → version.bundle.js} +1 -1
- package/moj/version.bundle.js.map +1 -0
- package/moj/version.bundle.mjs +4 -0
- package/moj/version.bundle.mjs.map +1 -0
- package/moj/version.mjs.map +1 -1
- package/package.json +5 -6
- package/moj/all.jquery.min.js +0 -1
- package/moj/all.jquery.min.js.map +0 -1
- package/moj/all.js +0 -2662
- package/moj/all.js.map +0 -1
- package/moj/components/add-another/add-another.js +0 -115
- package/moj/components/add-another/add-another.js.map +0 -1
- package/moj/components/alert/alert.js +0 -356
- package/moj/components/alert/alert.js.map +0 -1
- package/moj/components/alert/alert.spec.helper.js.map +0 -1
- package/moj/components/button-menu/button-menu.js.map +0 -1
- package/moj/components/date-picker/date-picker.js.map +0 -1
- package/moj/components/filter-toggle-button/filter-toggle-button.js +0 -102
- package/moj/components/filter-toggle-button/filter-toggle-button.js.map +0 -1
- package/moj/components/form-validator/form-validator.js +0 -205
- package/moj/components/form-validator/form-validator.js.map +0 -1
- package/moj/components/multi-file-upload/multi-file-upload.js +0 -241
- package/moj/components/multi-file-upload/multi-file-upload.js.map +0 -1
- package/moj/components/multi-select/multi-select.js +0 -86
- package/moj/components/multi-select/multi-select.js.map +0 -1
- package/moj/components/password-reveal/password-reveal.js +0 -44
- package/moj/components/password-reveal/password-reveal.js.map +0 -1
- package/moj/components/rich-text-editor/rich-text-editor.js +0 -166
- package/moj/components/rich-text-editor/rich-text-editor.js.map +0 -1
- package/moj/components/search-toggle/search-toggle.js +0 -63
- package/moj/components/search-toggle/search-toggle.js.map +0 -1
- package/moj/components/sortable-table/sortable-table.js +0 -147
- package/moj/components/sortable-table/sortable-table.js.map +0 -1
- package/moj/helpers.js.map +0 -1
- package/moj/vendor/html5shiv.js +0 -326
- package/moj/vendor/jquery.js +0 -9300
- package/moj/version.js.map +0 -1
|
@@ -1,139 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
class SortableTable {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
const table = params.table;
|
|
4
|
+
const head = table == null ? void 0 : table.querySelector('thead');
|
|
5
|
+
const body = table == null ? void 0 : table.querySelector('tbody');
|
|
6
|
+
if (!table || !(table instanceof HTMLElement) || !head || !body) {
|
|
7
|
+
return this;
|
|
8
|
+
}
|
|
9
|
+
this.table = table;
|
|
10
|
+
this.head = head;
|
|
11
|
+
this.body = body;
|
|
12
|
+
if (this.table.hasAttribute('data-moj-sortable-table-init')) {
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
this.table.setAttribute('data-moj-sortable-table-init', '');
|
|
16
|
+
this.headings = this.head ? Array.from(this.head.querySelectorAll('th')) : [];
|
|
17
|
+
this.setupOptions(params);
|
|
18
|
+
this.createHeadingButtons();
|
|
19
|
+
this.createStatusBox();
|
|
20
|
+
this.initialiseSortedColumn();
|
|
21
|
+
this.head.addEventListener('click', this.onSortButtonClick.bind(this));
|
|
6
22
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
SortableTable.prototype.setupOptions = function (params) {
|
|
19
|
-
params = params || {};
|
|
20
|
-
this.statusMessage = params.statusMessage || 'Sort by %heading% (%direction%)';
|
|
21
|
-
this.ascendingText = params.ascendingText || 'ascending';
|
|
22
|
-
this.descendingText = params.descendingText || 'descending';
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
SortableTable.prototype.createHeadingButtons = function () {
|
|
26
|
-
const headings = this.table.find('thead th');
|
|
27
|
-
let heading;
|
|
28
|
-
for (let i = 0; i < headings.length; i++) {
|
|
29
|
-
heading = $(headings[i]);
|
|
30
|
-
if (heading.attr('aria-sort')) {
|
|
31
|
-
this.createHeadingButton(heading, i);
|
|
23
|
+
setupOptions(params) {
|
|
24
|
+
params = params || {};
|
|
25
|
+
this.statusMessage = params.statusMessage || 'Sort by %heading% (%direction%)';
|
|
26
|
+
this.ascendingText = params.ascendingText || 'ascending';
|
|
27
|
+
this.descendingText = params.descendingText || 'descending';
|
|
28
|
+
}
|
|
29
|
+
createHeadingButtons() {
|
|
30
|
+
for (const heading of this.headings) {
|
|
31
|
+
if (heading.hasAttribute('aria-sort')) {
|
|
32
|
+
this.createHeadingButton(heading);
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
SortableTable.prototype.createStatusBox = function () {
|
|
44
|
-
this.status = $(
|
|
45
|
-
'<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'
|
|
46
|
-
);
|
|
47
|
-
this.table.parent().append(this.status);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
SortableTable.prototype.initialiseSortedColumn = function () {
|
|
51
|
-
const rows = this.getTableRowsArray();
|
|
52
|
-
|
|
53
|
-
this.table
|
|
54
|
-
.find('th')
|
|
55
|
-
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
|
|
56
|
-
.first()
|
|
57
|
-
.each((index, el) => {
|
|
58
|
-
const sortDirection = $(el).attr('aria-sort');
|
|
59
|
-
const columnNumber = $(el).find('button').attr('data-index');
|
|
60
|
-
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
61
|
-
this.addRows(sortedRows);
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
66
|
-
const columnNumber = e.currentTarget.getAttribute('data-index');
|
|
67
|
-
const sortDirection = $(e.currentTarget).parent().attr('aria-sort');
|
|
68
|
-
let newSortDirection;
|
|
69
|
-
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
70
|
-
newSortDirection = 'ascending';
|
|
71
|
-
} else {
|
|
72
|
-
newSortDirection = 'descending';
|
|
36
|
+
createHeadingButton(heading) {
|
|
37
|
+
const index = this.headings.indexOf(heading);
|
|
38
|
+
const button = document.createElement('button');
|
|
39
|
+
button.setAttribute('type', 'button');
|
|
40
|
+
button.setAttribute('data-index', `${index}`);
|
|
41
|
+
button.textContent = heading.textContent;
|
|
42
|
+
heading.textContent = '';
|
|
43
|
+
heading.appendChild(button);
|
|
73
44
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
82
|
-
button.parent().attr('aria-sort', direction);
|
|
83
|
-
let message = this.statusMessage;
|
|
84
|
-
message = message.replace(/%heading%/, button.text());
|
|
85
|
-
message = message.replace(/%direction%/, this[`${direction}Text`]);
|
|
86
|
-
this.status.text(message);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
SortableTable.prototype.removeButtonStates = function () {
|
|
90
|
-
this.table.find('thead th').attr('aria-sort', 'none');
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
SortableTable.prototype.addRows = function (rows) {
|
|
94
|
-
for (let i = 0; i < rows.length; i++) {
|
|
95
|
-
this.body.append(rows[i]);
|
|
45
|
+
createStatusBox() {
|
|
46
|
+
this.status = document.createElement('div');
|
|
47
|
+
this.status.setAttribute('aria-atomic', 'true');
|
|
48
|
+
this.status.setAttribute('aria-live', 'polite');
|
|
49
|
+
this.status.setAttribute('class', 'govuk-visually-hidden');
|
|
50
|
+
this.status.setAttribute('role', 'status');
|
|
51
|
+
this.table.insertAdjacentElement('afterend', this.status);
|
|
96
52
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
53
|
+
initialiseSortedColumn() {
|
|
54
|
+
var _sortButton$getAttrib;
|
|
55
|
+
const rows = this.getTableRowsArray();
|
|
56
|
+
const heading = this.table.querySelector('th[aria-sort]');
|
|
57
|
+
const sortButton = heading == null ? void 0 : heading.querySelector('button');
|
|
58
|
+
const sortDirection = heading == null ? void 0 : heading.getAttribute('aria-sort');
|
|
59
|
+
const columnNumber = Number.parseInt((_sortButton$getAttrib = sortButton == null ? void 0 : sortButton.getAttribute('data-index')) != null ? _sortButton$getAttrib : '0', 10);
|
|
60
|
+
if (!heading || !sortButton || !(sortDirection === 'ascending' || sortDirection === 'descending')) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
64
|
+
this.addRows(sortedRows);
|
|
104
65
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
66
|
+
onSortButtonClick(event) {
|
|
67
|
+
var _button$getAttribute;
|
|
68
|
+
const button = event.target;
|
|
69
|
+
if (!button || !(button instanceof HTMLButtonElement) || !button.parentElement) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const heading = button.parentElement;
|
|
73
|
+
const sortDirection = heading.getAttribute('aria-sort');
|
|
74
|
+
const columnNumber = Number.parseInt((_button$getAttribute = button == null ? void 0 : button.getAttribute('data-index')) != null ? _button$getAttribute : '0', 10);
|
|
75
|
+
const newSortDirection = sortDirection === 'none' || sortDirection === 'descending' ? 'ascending' : 'descending';
|
|
76
|
+
const rows = this.getTableRowsArray();
|
|
77
|
+
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
78
|
+
this.addRows(sortedRows);
|
|
79
|
+
this.removeButtonStates();
|
|
80
|
+
this.updateButtonState(button, newSortDirection);
|
|
81
|
+
}
|
|
82
|
+
updateButtonState(button, direction) {
|
|
83
|
+
if (!(direction === 'ascending' || direction === 'descending')) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
button.parentElement.setAttribute('aria-sort', direction);
|
|
87
|
+
let message = this.statusMessage;
|
|
88
|
+
message = message.replace(/%heading%/, button.textContent);
|
|
89
|
+
message = message.replace(/%direction%/, this[`${direction}Text`]);
|
|
90
|
+
this.status.textContent = message;
|
|
91
|
+
}
|
|
92
|
+
removeButtonStates() {
|
|
93
|
+
for (const heading of this.headings) {
|
|
94
|
+
heading.setAttribute('aria-sort', 'none');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
addRows(rows) {
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
this.body.append(row);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
getTableRowsArray() {
|
|
103
|
+
return Array.from(this.body.querySelectorAll('tr'));
|
|
104
|
+
}
|
|
105
|
+
sort(rows, columnNumber, sortDirection) {
|
|
106
|
+
return rows.sort((rowA, rowB) => {
|
|
107
|
+
const tdA = rowA.querySelectorAll('td, th')[columnNumber];
|
|
108
|
+
const tdB = rowB.querySelectorAll('td, th')[columnNumber];
|
|
109
|
+
if (!tdA || !tdB || !(tdA instanceof HTMLElement) || !(tdB instanceof HTMLElement)) {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
const valueA = sortDirection === 'ascending' ? this.getCellValue(tdA) : this.getCellValue(tdB);
|
|
113
|
+
const valueB = sortDirection === 'ascending' ? this.getCellValue(tdB) : this.getCellValue(tdA);
|
|
114
|
+
return !(typeof valueA === 'number' && typeof valueB === 'number') ? valueA.toString().localeCompare(valueB.toString()) : valueA - valueB;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
getCellValue(cell) {
|
|
118
|
+
const val = cell.getAttribute('data-sort-value') || cell.innerHTML;
|
|
119
|
+
const valAsNumber = Number(val);
|
|
120
|
+
return Number.isFinite(valAsNumber) ? valAsNumber // Exclude invalid numbers, infinity etc
|
|
121
|
+
: val;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
137
124
|
|
|
138
125
|
export { SortableTable };
|
|
139
126
|
//# sourceMappingURL=sortable-table.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortable-table.mjs","sources":["../../../../src/moj/components/sortable-table/sortable-table.mjs"],"sourcesContent":["import $ from 'jquery'\n\nexport function SortableTable(params) {\n this.table = $(params.table)\n\n if (this.table.data('moj-search-toggle-initialised')) {\n return\n }\n\n this.table.data('moj-search-toggle-initialised', true)\n\n this.setupOptions(params)\n this.body = this.table.find('tbody')\n this.createHeadingButtons()\n this.createStatusBox()\n this.initialiseSortedColumn()\n this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'))\n}\n\nSortableTable.prototype.setupOptions = function (params) {\n params = params || {}\n this.statusMessage = params.statusMessage || 'Sort by %heading% (%direction%)'\n this.ascendingText = params.ascendingText || 'ascending'\n this.descendingText = params.descendingText || 'descending'\n}\n\nSortableTable.prototype.createHeadingButtons = function () {\n const headings = this.table.find('thead th')\n let heading\n for (let i = 0; i < headings.length; i++) {\n heading = $(headings[i])\n if (heading.attr('aria-sort')) {\n this.createHeadingButton(heading, i)\n }\n }\n}\n\nSortableTable.prototype.createHeadingButton = function (heading, i) {\n const text = heading.text()\n const button = $(`<button type=\"button\" data-index=\"${i}\">${text}</button>`)\n heading.text('')\n heading.append(button)\n}\n\nSortableTable.prototype.createStatusBox = function () {\n this.status = $(\n '<div aria-live=\"polite\" role=\"status\" aria-atomic=\"true\" class=\"govuk-visually-hidden\" />'\n )\n this.table.parent().append(this.status)\n}\n\nSortableTable.prototype.initialiseSortedColumn = function () {\n const rows = this.getTableRowsArray()\n\n this.table\n .find('th')\n .filter('[aria-sort=\"ascending\"], [aria-sort=\"descending\"]')\n .first()\n .each((index, el) => {\n const sortDirection = $(el).attr('aria-sort')\n const columnNumber = $(el).find('button').attr('data-index')\n const sortedRows = this.sort(rows, columnNumber, sortDirection)\n this.addRows(sortedRows)\n })\n}\n\nSortableTable.prototype.onSortButtonClick = function (e) {\n const columnNumber = e.currentTarget.getAttribute('data-index')\n const sortDirection = $(e.currentTarget).parent().attr('aria-sort')\n let newSortDirection\n if (sortDirection === 'none' || sortDirection === 'descending') {\n newSortDirection = 'ascending'\n } else {\n newSortDirection = 'descending'\n }\n const rows = this.getTableRowsArray()\n const sortedRows = this.sort(rows, columnNumber, newSortDirection)\n this.addRows(sortedRows)\n this.removeButtonStates()\n this.updateButtonState($(e.currentTarget), newSortDirection)\n}\n\nSortableTable.prototype.updateButtonState = function (button, direction) {\n button.parent().attr('aria-sort', direction)\n let message = this.statusMessage\n message = message.replace(/%heading%/, button.text())\n message = message.replace(/%direction%/, this[`${direction}Text`])\n this.status.text(message)\n}\n\nSortableTable.prototype.removeButtonStates = function () {\n this.table.find('thead th').attr('aria-sort', 'none')\n}\n\nSortableTable.prototype.addRows = function (rows) {\n for (let i = 0; i < rows.length; i++) {\n this.body.append(rows[i])\n }\n}\n\nSortableTable.prototype.getTableRowsArray = function () {\n const rows = []\n const trs = this.body.find('tr')\n for (let i = 0; i < trs.length; i++) {\n rows.push(trs[i])\n }\n return rows\n}\n\nSortableTable.prototype.sort = function (rows, columnNumber, sortDirection) {\n const newRows = rows.sort(\n function (rowA, rowB) {\n const tdA = $(rowA).find('td,th').eq(columnNumber)\n const tdB = $(rowB).find('td,th').eq(columnNumber)\n\n const valueA =\n sortDirection === 'ascending'\n ? this.getCellValue(tdA)\n : this.getCellValue(tdB)\n const valueB =\n sortDirection === 'ascending'\n ? this.getCellValue(tdB)\n : this.getCellValue(tdA)\n\n if (typeof valueA === 'string' || typeof valueB === 'string')\n return valueA.toString().localeCompare(valueB.toString())\n return valueA - valueB\n }.bind(this)\n )\n return newRows\n}\n\nSortableTable.prototype.getCellValue = function (cell) {\n const val = cell.attr('data-sort-value') || cell.html()\n\n const valAsNumber = Number(val)\n return isNaN(valAsNumber) ? val : valAsNumber\n}\n"],"names":[],"mappings":"AAEA,SAAA,aAAA,CAAA,MAAA,EAAA;AACA,EAAA,IAAA,CAAA,KAAA,GAAA,CAAA,CAAA,MAAA,CAAA,KAAA;;AAEA,EAAA,IAAA,IAAA,CAAA,KAAA,CAAA,IA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,KAAA,CAAA,IAAA,CAAA,IAAA;AACA;AACA,EAAA,OAAA;AACA;;AAEA,aAAA,CAAA,SAAA,CAAA,YAAA,GAAA,UAAA,IAAA,EAAA;AACA,EAAA,MAAA,GAAA,GAAA,IAAA,CAAA,IAAA,CAAA,iBAAA,CAAA,IAAA,IAAA,CAAA,IAAA;;AAEA,EAAA,MAAA,WAAA,GAAA,MAAA,CAAA,GAAA;AACA,EAAA,OAAA,KAAA,CAAA,WAAA,CAAA,GAAA,GAAA,GAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"sortable-table.mjs","sources":["../../../../src/moj/components/sortable-table/sortable-table.mjs"],"sourcesContent":["export class SortableTable {\n constructor(params) {\n const table = params.table\n const head = table?.querySelector('thead')\n const body = table?.querySelector('tbody')\n\n if (!table || !(table instanceof HTMLElement) || !head || !body) {\n return this\n }\n\n this.table = table\n this.head = head\n this.body = body\n\n if (this.table.hasAttribute('data-moj-sortable-table-init')) {\n return this\n }\n\n this.table.setAttribute('data-moj-sortable-table-init', '')\n\n this.headings = this.head\n ? Array.from(this.head.querySelectorAll('th'))\n : []\n\n this.setupOptions(params)\n this.createHeadingButtons()\n this.createStatusBox()\n this.initialiseSortedColumn()\n\n this.head.addEventListener('click', this.onSortButtonClick.bind(this))\n }\n\n setupOptions(params) {\n params = params || {}\n this.statusMessage =\n params.statusMessage || 'Sort by %heading% (%direction%)'\n this.ascendingText = params.ascendingText || 'ascending'\n this.descendingText = params.descendingText || 'descending'\n }\n\n createHeadingButtons() {\n for (const heading of this.headings) {\n if (heading.hasAttribute('aria-sort')) {\n this.createHeadingButton(heading)\n }\n }\n }\n\n createHeadingButton(heading) {\n const index = this.headings.indexOf(heading)\n const button = document.createElement('button')\n\n button.setAttribute('type', 'button')\n button.setAttribute('data-index', `${index}`)\n button.textContent = heading.textContent\n\n heading.textContent = ''\n heading.appendChild(button)\n }\n\n createStatusBox() {\n this.status = document.createElement('div')\n\n this.status.setAttribute('aria-atomic', 'true')\n this.status.setAttribute('aria-live', 'polite')\n this.status.setAttribute('class', 'govuk-visually-hidden')\n this.status.setAttribute('role', 'status')\n\n this.table.insertAdjacentElement('afterend', this.status)\n }\n\n initialiseSortedColumn() {\n const rows = this.getTableRowsArray()\n\n const heading = this.table.querySelector('th[aria-sort]')\n const sortButton = heading?.querySelector('button')\n const sortDirection = heading?.getAttribute('aria-sort')\n const columnNumber = Number.parseInt(\n sortButton?.getAttribute('data-index') ?? '0',\n 10\n )\n\n if (\n !heading ||\n !sortButton ||\n !(sortDirection === 'ascending' || sortDirection === 'descending')\n ) {\n return\n }\n\n const sortedRows = this.sort(rows, columnNumber, sortDirection)\n this.addRows(sortedRows)\n }\n\n onSortButtonClick(event) {\n const button = event.target\n\n if (\n !button ||\n !(button instanceof HTMLButtonElement) ||\n !button.parentElement\n ) {\n return\n }\n\n const heading = button.parentElement\n const sortDirection = heading.getAttribute('aria-sort')\n const columnNumber = Number.parseInt(\n button?.getAttribute('data-index') ?? '0',\n 10\n )\n\n const newSortDirection =\n sortDirection === 'none' || sortDirection === 'descending'\n ? 'ascending'\n : 'descending'\n\n const rows = this.getTableRowsArray()\n const sortedRows = this.sort(rows, columnNumber, newSortDirection)\n\n this.addRows(sortedRows)\n this.removeButtonStates()\n this.updateButtonState(button, newSortDirection)\n }\n\n updateButtonState(button, direction) {\n if (!(direction === 'ascending' || direction === 'descending')) {\n return\n }\n\n button.parentElement.setAttribute('aria-sort', direction)\n let message = this.statusMessage\n message = message.replace(/%heading%/, button.textContent)\n message = message.replace(/%direction%/, this[`${direction}Text`])\n this.status.textContent = message\n }\n\n removeButtonStates() {\n for (const heading of this.headings) {\n heading.setAttribute('aria-sort', 'none')\n }\n }\n\n addRows(rows) {\n for (const row of rows) {\n this.body.append(row)\n }\n }\n\n getTableRowsArray() {\n return Array.from(this.body.querySelectorAll('tr'))\n }\n\n sort(rows, columnNumber, sortDirection) {\n return rows.sort((rowA, rowB) => {\n const tdA = rowA.querySelectorAll('td, th')[columnNumber]\n const tdB = rowB.querySelectorAll('td, th')[columnNumber]\n\n if (\n !tdA ||\n !tdB ||\n !(tdA instanceof HTMLElement) ||\n !(tdB instanceof HTMLElement)\n ) {\n return 0\n }\n\n const valueA =\n sortDirection === 'ascending'\n ? this.getCellValue(tdA)\n : this.getCellValue(tdB)\n\n const valueB =\n sortDirection === 'ascending'\n ? this.getCellValue(tdB)\n : this.getCellValue(tdA)\n\n return !(typeof valueA === 'number' && typeof valueB === 'number')\n ? valueA.toString().localeCompare(valueB.toString())\n : valueA - valueB\n })\n }\n\n getCellValue(cell) {\n const val = cell.getAttribute('data-sort-value') || cell.innerHTML\n const valAsNumber = Number(val)\n\n return Number.isFinite(valAsNumber)\n ? valAsNumber // Exclude invalid numbers, infinity etc\n : val\n }\n}\n"],"names":["SortableTable","constructor","params","table","head","querySelector","body","HTMLElement","hasAttribute","setAttribute","headings","Array","from","querySelectorAll","setupOptions","createHeadingButtons","createStatusBox","initialiseSortedColumn","addEventListener","onSortButtonClick","bind","statusMessage","ascendingText","descendingText","heading","createHeadingButton","index","indexOf","button","document","createElement","textContent","appendChild","status","insertAdjacentElement","_sortButton$getAttrib","rows","getTableRowsArray","sortButton","sortDirection","getAttribute","columnNumber","Number","parseInt","sortedRows","sort","addRows","event","_button$getAttribute","target","HTMLButtonElement","parentElement","newSortDirection","removeButtonStates","updateButtonState","direction","message","replace","row","append","rowA","rowB","tdA","tdB","valueA","getCellValue","valueB","toString","localeCompare","cell","val","innerHTML","valAsNumber","isFinite"],"mappings":"AAAO,MAAMA,aAAa,CAAC;EACzBC,WAAWA,CAACC,MAAM,EAAE;AAClB,IAAA,MAAMC,KAAK,GAAGD,MAAM,CAACC,KAAK;IAC1B,MAAMC,IAAI,GAAGD,KAAK,IAAA,IAAA,GAAA,MAAA,GAALA,KAAK,CAAEE,aAAa,CAAC,OAAO,CAAC;IAC1C,MAAMC,IAAI,GAAGH,KAAK,IAAA,IAAA,GAAA,MAAA,GAALA,KAAK,CAAEE,aAAa,CAAC,OA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AAM,GAAGE,MAAM;AACrB,KAAC,CAAC;AACJ;EAEAD,YAAYA,CAACI,IAAI,EAAE;IACjB,MAAMC,GAAG,GAAGD,IAAI,CAAC7B,YAAY,CAAC,iBAAiB,CAAC,IAAI6B,IAAI,CAACE,SAAS;AAClE,IAAA,MAAMC,WAAW,GAAG9B,MAAM,CAAC4B,GAAG,CAAC;IAE/B,OAAO5B,MAAM,CAAC+B,QAAQ,CAACD,WAAW,CAAC,GAC/BA,WAAW;AAAC,MACZF,GAAG;AACT;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/sub-navigation/_sub-navigation.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,+BAA+B;AACjC;;AAEA;EACE,SAAS;EACT,UAAU;EACV,YAAY,EAAE,+DAA+D;EAC7E,gBAAgB;;EAEhB;IACE,WAAW;IACX,+CAA+C;EACjD;AACF;;AAEA;EACE,cAAc;EACd,gBAAgB;EAChB,+CAA+C;EAC/C,uBAAuB;;EAEvB;IACE,gBAAgB;EAClB;;EAEA;IACE,qBAAqB;IACrB,aAAa;IACb,8BAA8B;IAC9B,gBAAgB;EAClB;AACF;;AAEA;EACE,cAAc;EACd,kBAAkB;EAClB,iBAAiB;EACjB,oBAAoB;EACpB,8BAA8B;EAC9B,0BAA0B;EAC1B,iCAAiC;;EAEjC;IACE,eAAe;EACjB;;EAEA;;;;IAIE,qBAAqB;EACvB;;EAEA;;IAEE,yBAAyB;EAC3B;;EAEA;IACE,+BAA+B;EACjC;;EAEA;IACE,kBAAkB,EAAE,0CAA0C;IAC9D,4BAA4B,EAAE,gDAAgD;IAC9E,gBAAgB;EAClB;;EAEA;IACE,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,SAAS;IACT,OAAO;IACP,UAAU;IACV,YAAY;IACZ,uCAAuC;;IAEvC;MACE,WAAW;MACX,WAAW;IACb;EACF;AACF;;AAEA;EACE,kBAAkB;EAClB,gCAAgC;EAChC,qBAAqB;;EAErB;IACE,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,SAAS;IACT,OAAO;IACP,UAAU;IACV,YAAY;IACZ,oCAAoC;;IAEpC;MACE,WAAW;MACX,WAAW;IACb;EACF;;EAEA;IACE,+BAA+B;EACjC;;EAEA;IACE,uCAAuC;EACzC;AACF","file":"_sub-navigation.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #SECONDARY NAV\n ========================================================================== */\n\n.moj-sub-navigation {\n margin-bottom: govuk-spacing(7);\n}\n\n.moj-sub-navigation__list {\n margin: 0;\n padding: 0;\n font-size: 0; // Removes white space when using inline-block on child element.\n list-style: none;\n\n @include govuk-media-query($from: tablet) {\n width: 100%;\n box-shadow: inset 0 -1px 0 $govuk-border-colour;\n }\n}\n\n.moj-sub-navigation__item {\n display: block;\n margin-top: -1px;\n box-shadow: inset 0 -1px 0 $govuk-border-colour;\n @include govuk-font(19);\n\n &:last-child {\n box-shadow: none;\n }\n\n @include govuk-media-query($from: tablet) {\n display: inline-block;\n margin-top: 0;\n margin-right: govuk-spacing(4);\n box-shadow: none;\n }\n}\n\n.moj-sub-navigation__link {\n display: block;\n position: relative;\n padding-top: 12px;\n padding-bottom: 12px;\n padding-left: govuk-spacing(3);\n @include govuk-link-common;\n @include govuk-link-style-default;\n\n @include govuk-media-query($from: tablet) {\n padding-left: 0;\n }\n\n &:link,\n &:visited,\n &:hover,\n &:active {\n text-decoration: none;\n }\n\n &:link,\n &:visited {\n color: $govuk-link-colour;\n }\n\n &:hover {\n color: $govuk-link-hover-colour;\n }\n\n &:focus {\n position: relative; // Ensure focus sits above everything else.\n color: govuk-colour(\"black\"); // Focus colour on yellow should really be black.\n box-shadow: none;\n }\n\n &:focus::before {\n content: \"\";\n display: block;\n position: absolute;\n bottom: 0;\n left: 0;\n width: 5px;\n height: 100%;\n background-color: govuk-colour(\"black\");\n\n @include govuk-media-query($from: tablet) {\n width: 100%;\n height: 5px;\n }\n }\n}\n\n.moj-sub-navigation__link[aria-current=\"page\"] {\n position: relative;\n color: $govuk-link-active-colour;\n text-decoration: none;\n\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n bottom: 0;\n left: 0;\n width: 5px;\n height: 100%;\n background-color: $govuk-link-colour;\n\n @include govuk-media-query($from: tablet) {\n width: 100%;\n height: 5px;\n }\n }\n\n &:hover {\n color: $govuk-link-hover-colour;\n }\n\n &:focus::before {\n background-color: govuk-colour(\"black\");\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/tag/_tag.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,qCAAqC;EACrC,4BAA4B;EAC5B,qCAAqC;;EAErC;IACE,wCAAwC;IACxC,4BAA4B;IAC5B,wCAAwC;EAC1C;;EAEA;IACE,+CAA+C;IAC/C,4BAA4B;IAC5B,+CAA+C;EACjD;;EAEA;;IAEE,qCAAqC;IACrC,4BAA4B;IAC5B,qCAAqC;EACvC;;EAEA;;IAEE,uCAAuC;IACvC,4BAA4B;IAC5B,uCAAuC;EACzC;;EAEA;;IAEE,sCAAsC;IACtC,4BAA4B;IAC5B,sCAAsC;EACxC;;EAEA;IACE,uCAAuC;IACvC,4BAA4B;IAC5B,uCAAuC;EACzC;;EAEA;IACE,2CAA2C;IAC3C,4BAA4B;IAC5B,2CAA2C;EAC7C;AACF","file":"_tag.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #TAG\n ========================================================================== */\n\n.moj-tag {\n border: 2px solid $govuk-brand-colour;\n color: govuk-colour(\"white\");\n background-color: $govuk-brand-colour;\n\n &--purple {\n border: 2px solid govuk-colour(\"purple\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"purple\");\n }\n\n &--bright-purple {\n border: 2px solid govuk-colour(\"bright-purple\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"bright-purple\");\n }\n\n &--red,\n &--error {\n border: 2px solid govuk-colour(\"red\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"red\");\n }\n\n &--green,\n &--success {\n border: 2px solid govuk-colour(\"green\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"green\");\n }\n\n &--blue,\n &--information {\n border: 2px solid govuk-colour(\"blue\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"blue\");\n }\n\n &--black {\n border: 2px solid govuk-colour(\"black\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"black\");\n }\n\n &--grey {\n border: 2px solid govuk-colour(\"dark-grey\");\n color: govuk-colour(\"white\");\n background-color: govuk-colour(\"dark-grey\");\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/task-list/_task-list.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,aAAa;EACb,gBAAgB;EAChB,eAAe;EACf,qBAAqB;EACrB;IACE,gBAAgB;EAClB;AACF;;AAEA;EACE,cAAc;EACd,6CAA6C;AAC/C;;AAEA;EACE,mBAAmB;;EAEnB;IACE,2BAA2B;IAC3B,gBAAgB;EAClB;AACF;;AAEA;EACE,eAAe;EACf,gBAAgB;EAChB,8BAA8B;EAC9B,6CAA6C;EAC7C;IACE,8BAA8B;EAChC;AACF;;AAEA;EACE,sDAAsD;EACtD,2BAA2B;EAC3B,6BAA6B;EAC7B,gCAAgC;EAChC,6CAA6C;EAC7C,uBAAuB;AACzB;;AAEA;EACE,0CAA0C;AAC5C;;AAEA;EACE,cAAc;EACd;IACE,UAAU;IACV,WAAW;EACb;AACF;;AAEA;EACE,4BAA4B;EAC5B,+BAA+B;;EAE/B;IACE,aAAa;IACb,gBAAgB;IAChB,YAAY;EACd;AACF","file":"_task-list.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #TASK LIST\n ========================================================================== */\n\n.moj-task-list {\n margin-top: 0;\n margin-bottom: 0;\n padding-left: 0;\n list-style-type: none;\n @include govuk-media-query($from: tablet) {\n min-width: 550px;\n }\n}\n\n.moj-task-list__section {\n display: table;\n @include govuk-font($size: 24, $weight: bold);\n}\n\n.moj-task-list__section-number {\n display: table-cell;\n\n @include govuk-media-query($from: tablet) {\n min-width: govuk-spacing(6);\n padding-right: 0;\n }\n}\n\n.moj-task-list__items {\n padding-left: 0;\n list-style: none;\n @include govuk-font($size: 19);\n @include govuk-responsive-margin(9, \"bottom\");\n @include govuk-media-query($from: tablet) {\n padding-left: govuk-spacing(6);\n }\n}\n\n.moj-task-list__item {\n // stylelint-disable-next-line declaration-no-important\n margin-bottom: 0 !important;\n padding-top: govuk-spacing(2);\n padding-bottom: govuk-spacing(2);\n border-bottom: 1px solid $govuk-border-colour;\n @include govuk-clearfix;\n}\n\n.moj-task-list__item:first-child {\n border-top: 1px solid $govuk-border-colour;\n}\n\n.moj-task-list__task-name {\n display: block;\n @include govuk-media-query($from: 450px) {\n width: 75%;\n float: left;\n }\n}\n\n.moj-task-list__task-completed {\n margin-top: govuk-spacing(2);\n margin-bottom: govuk-spacing(1);\n\n @include govuk-media-query($from: 450px) {\n margin-top: 0;\n margin-bottom: 0;\n float: right;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/ticket-panel/_ticket-panel.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,cAAc;EACd,8BAA8B;EAC9B,eAAe;;EAEf;IACE;MACE,aAAa;MACb,iBAAiB;IACnB;EACF;;EAEA;IACE;MACE,6BAA6B;IAC/B;EACF;;EAEA;IACE,+BAA+B;EACjC;;EAEA;IACE,cAAc;IACd,kBAAkB;IAClB,+BAA+B;IAC/B,yBAAyB;IACzB,kCAAkC;IAClC,4CAA4C;IAC5C,YAAY;;IAEZ;MACE,uCAAuC;IACzC;;IAEA;MACE,uCAAuC;IACzC;;IAEA;MACE,sCAAsC;IACxC;;IAEA;MACE,yCAAyC;IAC3C;;IAEA;MACE,wCAAwC;IAC1C;;IAEA;MACE,yCAAyC;IAC3C;;IAEA;MACE,yCAAyC;IAC3C;EACF;AACF","file":"_ticket-panel.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #TICKET PANEL\n ========================================================================== */\n\n.moj-ticket-panel {\n display: block;\n margin-right: govuk-spacing(0);\n flex-wrap: wrap;\n\n &--inline {\n @include govuk-media-query($from: desktop) {\n display: flex;\n flex-wrap: nowrap;\n }\n }\n\n &--inline > * + * {\n @include govuk-media-query($from: desktop) {\n margin-left: govuk-spacing(3);\n }\n }\n\n &__content *:last-child {\n margin-bottom: govuk-spacing(0);\n }\n\n &__content {\n display: block;\n position: relative;\n margin-bottom: govuk-spacing(3);\n padding: govuk-spacing(4);\n border-left: 4px solid transparent;\n background-color: govuk-colour(\"light-grey\");\n flex-grow: 1;\n\n &--grey {\n border-left-color: $govuk-border-colour;\n }\n\n &--blue {\n border-left-color: govuk-colour(\"blue\");\n }\n\n &--red {\n border-left-color: govuk-colour(\"red\");\n }\n\n &--yellow {\n border-left-color: govuk-colour(\"yellow\");\n }\n\n &--green {\n border-left-color: govuk-colour(\"green\");\n }\n\n &--purple {\n border-left-color: govuk-colour(\"purple\");\n }\n\n &--orange {\n border-left-color: govuk-colour(\"orange\");\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/timeline/_timeline.scss"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,kBAAkB;EAClB,+BAA+B;EAC/B,gBAAgB;;EAEhB;IACE,WAAW;IACX,kBAAkB;IAClB,qBAAqB;IACrB,OAAO;IACP,UAAU;IACV,YAAY;IACZ,qCAAqC;EACvC;AACF;;AAEA;EACE,gBAAgB;;EAEhB;IACE,yBAAyB;EAC3B;AACF;;AAEA;EACE,kBAAkB;EAClB,gCAAgC;EAChC,8BAA8B;;EAE9B;IACE,WAAW;IACX,kBAAkB;IAClB,qBAAqB;IACrB,OAAO;IACP,WAAW;IACX,WAAW;IACX,qCAAqC;EACvC;AACF;;AAEA;EACE,eAAe;EACf,6CAA6C;AAC/C;;AAEA;EACE,eAAe;EACf,SAAS;EACT,mCAAmC;EACnC,8BAA8B;AAChC;;AAEA;EACE,4BAA4B;EAC5B,gBAAgB;EAChB,8BAA8B;AAChC;;AAEA;EACE,4BAA4B;EAC5B,8BAA8B;AAChC;;AAEA;;+EAE+E;;AAE/E;EACE,gBAAgB;EAChB,eAAe;EACf,gBAAgB;AAClB;;AAEA;EACE,+BAA+B;;EAE/B;IACE,gBAAgB;EAClB;AACF;;AAEA;EACE,eAAe;EACf,iBAAiB;EACjB,WAAW;EACX,kBAAkB;;EAElB;IACE,cAAc;EAChB;AACF;;AAEA;EACE,8BAA8B;EAC9B,2DAA2D;EAC3D,4BAA4B;EAC5B,0BAA0B;EAC1B,0BAA0B;;EAE1B;IACE,4BAA4B,EAAE,gDAAgD;EAChF;AACF","file":"_timeline.scss","sourcesContent":["@use \"../../settings/assets\" as *;\n@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #TIMELINE\n ========================================================================== */\n\n.moj-timeline {\n position: relative;\n margin-bottom: govuk-spacing(4);\n overflow: hidden;\n\n &::before {\n content: \"\";\n position: absolute;\n top: govuk-spacing(2);\n left: 0;\n width: 5px;\n height: 100%;\n background-color: $govuk-brand-colour;\n }\n}\n\n.moj-timeline--full {\n margin-bottom: 0;\n\n &::before {\n height: calc(100% - 75px);\n }\n}\n\n.moj-timeline__item {\n position: relative;\n padding-bottom: govuk-spacing(6);\n padding-left: govuk-spacing(4);\n\n &::before {\n content: \"\";\n position: absolute;\n top: govuk-spacing(2);\n left: 0;\n width: 15px;\n height: 5px;\n background-color: $govuk-brand-colour;\n }\n}\n\n.moj-timeline__title {\n display: inline;\n @include govuk-font($size: 19, $weight: bold);\n}\n\n.moj-timeline__byline {\n display: inline;\n margin: 0;\n color: $govuk-secondary-text-colour;\n @include govuk-font($size: 19);\n}\n\n.moj-timeline__date {\n margin-top: govuk-spacing(1);\n margin-bottom: 0;\n @include govuk-font($size: 16);\n}\n\n.moj-timeline__description {\n margin-top: govuk-spacing(4);\n @include govuk-font($size: 19);\n}\n\n/* ==========================================================================\n #TIMELINE DOCUMENT STYLES – FOR BACKWARDS COMPATIBILITY\n ========================================================================== */\n\n.moj-timeline__documents {\n margin-bottom: 0;\n padding-left: 0;\n list-style: none;\n}\n\n.moj-timeline__document-item {\n margin-bottom: govuk-spacing(1);\n\n &:last-child {\n margin-bottom: 0;\n }\n}\n\n.moj-timeline__document-icon {\n margin-top: 4px;\n margin-right: 4px;\n float: left;\n fill: currentcolor;\n\n @media screen and (forced-colors: active) {\n fill: linkText;\n }\n}\n\n.moj-timeline__document-link {\n padding-left: govuk-spacing(5);\n background-image: url(#{$moj-images-path}icon-document.svg);\n background-repeat: no-repeat;\n background-position: 0 50%;\n background-size: 20px 16px;\n\n &:focus {\n color: govuk-colour(\"black\"); // Focus colour on yellow should really be black.\n }\n}\n"]}
|
package/moj/filters/all.js
CHANGED
|
@@ -2,34 +2,41 @@ const moment = require('moment')
|
|
|
2
2
|
|
|
3
3
|
module.exports = function () {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* gov.uk core filters by creating filter methods of the same name.
|
|
5
|
+
* Date filter for use in Nunjucks
|
|
6
|
+
* Outputs: 01/01/1970
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @example
|
|
9
|
+
* ```njk
|
|
10
|
+
* {{ params.date | date("DD/MM/YYYY") }}
|
|
11
|
+
* ```
|
|
12
|
+
* @param {MomentInput} timestamp
|
|
13
|
+
* @param {string} format
|
|
10
14
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/* ------------------------------------------------------------------
|
|
14
|
-
date filter for use in Nunjucks
|
|
15
|
-
example: {{ params.date | date("DD/MM/YYYY") }}
|
|
16
|
-
outputs: 01/01/1970
|
|
17
|
-
------------------------------------------------------------------ */
|
|
18
|
-
filters.date = function (timestamp, format) {
|
|
15
|
+
function date(timestamp, format) {
|
|
19
16
|
return moment(timestamp).format(format)
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
/* ------------------------------------------------------------------
|
|
23
20
|
utility functions for use in mojDate function/filter
|
|
24
21
|
------------------------------------------------------------------ */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {MomentInput} timestamp
|
|
25
|
+
*/
|
|
25
26
|
function govDate(timestamp) {
|
|
26
27
|
return moment(timestamp).format('D MMMM YYYY')
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @param {MomentInput} timestamp
|
|
32
|
+
*/
|
|
29
33
|
function govShortDate(timestamp) {
|
|
30
34
|
return moment(timestamp).format('D MMM YYYY')
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @param {MomentInput} timestamp
|
|
39
|
+
*/
|
|
33
40
|
function govTime(timestamp) {
|
|
34
41
|
const t = moment(timestamp)
|
|
35
42
|
if (t.minutes() > 0) {
|
|
@@ -38,12 +45,18 @@ module.exports = function () {
|
|
|
38
45
|
return t.format('ha')
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Standard dates for use in Nunjucks
|
|
50
|
+
* Outputs: 1 Jan 1970 at 1:32pm
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```njk
|
|
54
|
+
* {{ params.date | mojDate("datetime") }}
|
|
55
|
+
* ```
|
|
56
|
+
* @param {MomentInput} timestamp
|
|
57
|
+
* @param {'datetime' | 'shortdatetime' | 'date' | 'shortdate' | 'time'} [type]
|
|
58
|
+
*/
|
|
59
|
+
function mojDate(timestamp, type) {
|
|
47
60
|
switch (type) {
|
|
48
61
|
case 'datetime':
|
|
49
62
|
return `${govDate(timestamp)} at ${govTime(timestamp)}`
|
|
@@ -60,8 +73,17 @@ module.exports = function () {
|
|
|
60
73
|
}
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Returns an object used to store the methods registered as a
|
|
78
|
+
* 'filter' (of the same name) within nunjucks. You can override
|
|
79
|
+
* gov.uk core filters by creating filter methods of the same name.
|
|
80
|
+
*/
|
|
81
|
+
return {
|
|
82
|
+
date,
|
|
83
|
+
mojDate
|
|
84
|
+
}
|
|
67
85
|
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @import { MomentInput } from 'moment'
|
|
89
|
+
*/
|
package/moj/helpers/_all.scss
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/moj/helpers/_all.scss"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,gBAAgB","file":"_all.scss","sourcesContent":["@forward \"hidden\";\n@forward \"links\";\n"]}
|
package/moj/helpers/_hidden.scss
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/moj/helpers/_hidden.scss"],"names":[],"mappings":"AAAA;EACE,aAAa;AACf","file":"_hidden.scss","sourcesContent":["@mixin moj-hidden() {\n display: none;\n}\n"]}
|
package/moj/helpers/_links.scss
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/moj/helpers/_links.scss"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,+BAA+B;AAC/B,oCAAoC;;AAEpC;EACE;;IAEE,+BAA+B;EACjC;;EAEA;IACE,8DAA8D;EAChE;;EAEA;IACE,0BAA0B;EAC5B;;EAEA;IACE,+BAA+B;EACjC;AACF","file":"_links.scss","sourcesContent":["@use \"sass:color\";\n@use \"../settings/colours\" as *;\n@use \"../vendor/govuk-frontend\" as *;\n\n@mixin moj-link-style-warning {\n &:link,\n &:visited {\n color: $moj-warning-link-colour;\n }\n\n &:hover {\n color: color.scale($moj-warning-link-colour, $lightness: -30%);\n }\n\n &:active {\n color: $moj-warning-colour;\n }\n\n &:focus {\n color: $govuk-focus-text-colour;\n }\n}\n"]}
|