@ministryofjustice/frontend 3.3.1 → 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.
Files changed (83) hide show
  1. package/README.md +4 -10
  2. package/govuk-prototype-kit.config.json +5 -16
  3. package/moj/all.jquery.min.js +15 -4
  4. package/moj/all.js +2856 -2280
  5. package/moj/all.scss +2 -0
  6. package/moj/components/_all.scss +1 -0
  7. package/moj/components/action-bar/_action-bar.scss +4 -6
  8. package/moj/components/add-another/_add-another.scss +9 -7
  9. package/moj/components/add-another/add-another.js +128 -76
  10. package/moj/components/alert/README.md +0 -0
  11. package/moj/components/alert/_alert.scss +142 -0
  12. package/moj/components/alert/alert.js +482 -0
  13. package/moj/components/alert/alert.spec.helper.js +92 -0
  14. package/moj/components/alert/macro.njk +3 -0
  15. package/moj/components/alert/template.njk +83 -0
  16. package/moj/components/badge/_badge.scss +3 -4
  17. package/moj/components/banner/_banner.scss +5 -10
  18. package/moj/components/button-menu/_button-menu.scss +10 -9
  19. package/moj/components/button-menu/button-menu.js +348 -318
  20. package/moj/components/cookie-banner/_cookie-banner.scss +6 -5
  21. package/moj/components/currency-input/_currency-input.scss +4 -4
  22. package/moj/components/date-picker/README.md +14 -17
  23. package/moj/components/date-picker/_date-picker.scss +122 -106
  24. package/moj/components/date-picker/date-picker.js +927 -900
  25. package/moj/components/filter/README.md +1 -1
  26. package/moj/components/filter/_filter.scss +53 -75
  27. package/moj/components/filter-toggle-button/filter-toggle-button.js +122 -87
  28. package/moj/components/form-validator/form-validator.js +399 -156
  29. package/moj/components/header/_header.scss +17 -19
  30. package/moj/components/identity-bar/_identity-bar.scss +5 -5
  31. package/moj/components/interruption-card/_interruption-card.scss +2 -2
  32. package/moj/components/messages/_messages.scss +12 -19
  33. package/moj/components/multi-file-upload/README.md +1 -1
  34. package/moj/components/multi-file-upload/_multi-file-upload.scss +34 -30
  35. package/moj/components/multi-file-upload/multi-file-upload.js +454 -183
  36. package/moj/components/multi-select/_multi-select.scss +4 -3
  37. package/moj/components/multi-select/multi-select.js +106 -70
  38. package/moj/components/notification-badge/_notification-badge.scss +12 -12
  39. package/moj/components/organisation-switcher/_organisation-switcher.scss +1 -1
  40. package/moj/components/page-header-actions/_page-header-actions.scss +3 -2
  41. package/moj/components/pagination/_pagination.scss +26 -31
  42. package/moj/components/password-reveal/_password-reveal.scss +1 -2
  43. package/moj/components/password-reveal/password-reveal.js +63 -31
  44. package/moj/components/primary-navigation/_primary-navigation.scss +26 -29
  45. package/moj/components/progress-bar/_progress-bar.scss +21 -26
  46. package/moj/components/rich-text-editor/_rich-text-editor.scss +17 -16
  47. package/moj/components/rich-text-editor/rich-text-editor.js +186 -139
  48. package/moj/components/search/_search.scss +6 -4
  49. package/moj/components/search-toggle/search-toggle.js +83 -53
  50. package/moj/components/search-toggle/search-toggle.scss +21 -15
  51. package/moj/components/side-navigation/_side-navigation.scss +12 -21
  52. package/moj/components/sortable-table/_sortable-table.scss +25 -23
  53. package/moj/components/sortable-table/sortable-table.js +162 -119
  54. package/moj/components/sub-navigation/_sub-navigation.scss +24 -28
  55. package/moj/components/tag/_tag.scss +8 -9
  56. package/moj/components/task-list/_task-list.scss +8 -7
  57. package/moj/components/ticket-panel/_ticket-panel.scss +14 -6
  58. package/moj/components/timeline/_timeline.scss +18 -20
  59. package/moj/filters/all.js +28 -30
  60. package/moj/filters/prototype-kit-13-filters.js +2 -1
  61. package/moj/helpers/_all.scss +1 -0
  62. package/moj/helpers/_hidden.scss +1 -1
  63. package/moj/helpers/_links.scss +20 -0
  64. package/moj/helpers.js +218 -51
  65. package/moj/init.js +2 -2
  66. package/moj/moj-frontend.min.css +2 -2
  67. package/moj/moj-frontend.min.js +15 -4
  68. package/moj/objects/_filter-layout.scss +11 -10
  69. package/moj/objects/_scrollable-pane.scss +11 -14
  70. package/moj/settings/_colours.scss +5 -0
  71. package/moj/settings/_measurements.scss +0 -2
  72. package/moj/utilities/_hidden.scss +3 -3
  73. package/moj/utilities/_width-container.scss +1 -1
  74. package/moj/version.js +28 -1
  75. package/package.json +1 -1
  76. package/moj/all.spec.js +0 -22
  77. package/moj/components/button-menu/button-menu.spec.js +0 -361
  78. package/moj/components/date-picker/date-picker.spec.js +0 -1130
  79. package/moj/components/filter-toggle-button/filter-toggle-button.spec.js +0 -304
  80. package/moj/components/multi-select/multi-select.spec.js +0 -135
  81. package/moj/components/password-reveal/password-reveal.spec.js +0 -55
  82. package/moj/components/search-toggle/search-toggle.spec.js +0 -134
  83. package/moj/namespace.js +0 -1
package/moj/all.scss CHANGED
@@ -1,3 +1,5 @@
1
+ $govuk-suppressed-warnings: ("govuk-typography-scale-14");
2
+
1
3
  @import "node_modules/govuk-frontend/dist/govuk/base";
2
4
 
3
5
  @import "settings/all";
@@ -1,5 +1,6 @@
1
1
  @import "action-bar/action-bar";
2
2
  @import "add-another/add-another";
3
+ @import "alert/alert";
3
4
  @import "badge/badge";
4
5
  @import "banner/banner";
5
6
  @import "button-menu/button-menu";
@@ -14,14 +14,14 @@
14
14
  margin-right: govuk-spacing(2);
15
15
  padding-right: govuk-spacing(2) + 2px; // Takes into account divider width
16
16
 
17
- &:after {
17
+ &::after {
18
18
  content: "";
19
- background-color: govuk-colour("light-grey");
20
- height: 40px;
21
19
  position: absolute;
22
- right: 0;
23
20
  top: 0;
21
+ right: 0;
24
22
  width: 2px;
23
+ height: 40px;
24
+ background-color: govuk-colour("light-grey");
25
25
  }
26
26
  }
27
27
 
@@ -29,5 +29,3 @@
29
29
  vertical-align: baseline;
30
30
  }
31
31
  }
32
-
33
-
@@ -4,10 +4,10 @@
4
4
 
5
5
  .moj-add-another {
6
6
  &__item {
7
+ position: relative;
7
8
  margin: 0;
8
9
  margin-top: govuk-spacing(6);
9
10
  padding: 0;
10
- position: relative;
11
11
 
12
12
  &:first-of-type {
13
13
  margin-top: 0;
@@ -15,9 +15,9 @@
15
15
  }
16
16
 
17
17
  &__title {
18
- float: left;
19
- padding: 4px 100px 4px 0;
20
18
  width: 100%;
19
+ padding: 4px 100px 4px 0;
20
+ float: left;
21
21
 
22
22
  & + .govuk-form-group {
23
23
  clear: left;
@@ -26,8 +26,8 @@
26
26
 
27
27
  &__remove-button {
28
28
  position: absolute;
29
- right: 0;
30
29
  top: 0;
30
+ right: 0;
31
31
  width: auto;
32
32
  }
33
33
 
@@ -37,8 +37,10 @@
37
37
  }
38
38
 
39
39
  .moj-add-another__heading:focus {
40
- background-color: $govuk-focus-colour;
41
- color: $govuk-focus-text-colour;
42
- box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
43
40
  outline: none;
41
+ color: $govuk-focus-text-colour;
42
+ background-color: $govuk-focus-colour;
43
+ box-shadow:
44
+ 0 -2px $govuk-focus-colour,
45
+ 0 4px $govuk-focus-text-colour;
44
46
  }
@@ -1,83 +1,135 @@
1
- MOJFrontend.AddAnother = function(container) {
2
- this.container = $(container);
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';
3
6
 
4
- if (this.container.data('moj-add-another-initialised')) {
5
- return
7
+ function getDefaultExportFromCjs (x) {
8
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6
9
  }
7
10
 
8
- this.container.data('moj-add-another-initialised', true);
11
+ var _global_window_jQuery = window.jQuery;
9
12
 
10
- this.container.on('click', '.moj-add-another__remove-button', $.proxy(this, 'onRemoveButtonClick'));
11
- this.container.on('click', '.moj-add-another__add-button', $.proxy(this, 'onAddButtonClick'));
12
- this.container.find('.moj-add-another__add-button, moj-add-another__remove-button').prop('type', 'button');
13
- };
13
+ var addAnother$1;
14
+ var hasRequiredAddAnother;
14
15
 
15
- MOJFrontend.AddAnother.prototype.onAddButtonClick = function(e) {
16
- var item = this.getNewItem();
17
- this.updateAttributes(this.getItems().length, item);
18
- this.resetItem(item);
19
- var firstItem = this.getItems().first();
20
- if(!this.hasRemoveButton(firstItem)) {
21
- this.createRemoveButton(firstItem);
22
- }
23
- this.getItems().last().after(item);
24
- item.find('input, textarea, select').first().focus();
25
- };
26
-
27
- MOJFrontend.AddAnother.prototype.hasRemoveButton = function(item) {
28
- return item.find('.moj-add-another__remove-button').length;
29
- };
30
-
31
- MOJFrontend.AddAnother.prototype.getItems = function() {
32
- return this.container.find('.moj-add-another__item');
33
- };
34
-
35
- MOJFrontend.AddAnother.prototype.getNewItem = function() {
36
- var item = this.getItems().first().clone();
37
- if(!this.hasRemoveButton(item)) {
38
- this.createRemoveButton(item);
39
- }
40
- return item;
41
- };
42
-
43
- MOJFrontend.AddAnother.prototype.updateAttributes = function(index, item) {
44
- item.find('[data-name]').each(function(i, el) {
45
- var originalId = el.id
46
-
47
- el.name = $(el).attr('data-name').replace(/%index%/, index);
48
- el.id = $(el).attr('data-id').replace(/%index%/, index);
49
-
50
- var label = $(el).siblings('label')[0] || $(el).parents('label')[0] || item.find('[for="' + originalId + '"]')[0];
51
- label.htmlFor = el.id;
52
- });
53
- };
54
-
55
- MOJFrontend.AddAnother.prototype.createRemoveButton = function(item) {
56
- item.append('<button type="button" class="govuk-button govuk-button--secondary moj-add-another__remove-button">Remove</button>');
57
- };
58
-
59
- MOJFrontend.AddAnother.prototype.resetItem = function(item) {
60
- item.find('[data-name], [data-id]').each(function(index, el) {
61
- if(el.type == 'checkbox' || el.type == 'radio') {
62
- el.checked = false;
63
- } else {
64
- el.value = '';
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');
65
43
  }
66
- });
67
- };
68
-
69
- MOJFrontend.AddAnother.prototype.onRemoveButtonClick = function(e) {
70
- $(e.currentTarget).parents('.moj-add-another__item').remove();
71
- var items = this.getItems();
72
- if(items.length === 1) {
73
- items.find('.moj-add-another__remove-button').remove();
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;
74
128
  }
75
- items.each($.proxy(function(index, el) {
76
- this.updateAttributes(index, $(el));
77
- }, this));
78
- this.focusHeading();
79
- };
80
-
81
- MOJFrontend.AddAnother.prototype.focusHeading = function() {
82
- this.container.find('.moj-add-another__heading').focus();
83
- };
129
+
130
+ var addAnotherExports = requireAddAnother();
131
+ var addAnother = /*@__PURE__*/getDefaultExportFromCjs(addAnotherExports);
132
+
133
+ return addAnother;
134
+
135
+ }));
File without changes
@@ -0,0 +1,142 @@
1
+ .moj-alert {
2
+ @include govuk-font($size: false);
3
+ display: -ms-grid;
4
+ display: grid;
5
+ margin-bottom: govuk-spacing(6);
6
+ padding: govuk-spacing(2);
7
+ border: 5px solid transparent;
8
+ background: govuk-colour("white");
9
+ -ms-grid-columns: min-content fit-content(960px);
10
+ grid-template-columns: min-content fit-content(960px);
11
+
12
+ gap: govuk-spacing(2);
13
+
14
+ &:focus {
15
+ outline: $govuk-focus-width solid $govuk-focus-colour;
16
+ }
17
+ }
18
+
19
+ .moj-alert[data-dismissible] {
20
+ @include govuk-media-query($from: tablet) {
21
+ grid-template-columns: min-content fit-content(920px) auto;
22
+ }
23
+ }
24
+
25
+ .moj-alert__icon {
26
+ display: block;
27
+ width: govuk-px-to-rem(30px);
28
+ height: govuk-px-to-rem(30px);
29
+ fill: currentcolor;
30
+ }
31
+
32
+ .moj-alert__content {
33
+ @include govuk-font-size($size: 19);
34
+ display: block;
35
+ // Padding to align text with icon
36
+ padding-top: govuk-px-to-rem(5px);
37
+ overflow: hidden;
38
+ color: govuk-colour("black");
39
+
40
+ @include govuk-media-query($from: tablet) {
41
+ padding-top: govuk-px-to-rem(2px);
42
+ }
43
+ }
44
+
45
+ .moj-alert__action {
46
+ grid-column-start: 2;
47
+ grid-column-end: -1;
48
+
49
+ @include govuk-media-query($from: tablet) {
50
+ grid-column-start: 3;
51
+ justify-self: right;
52
+ }
53
+ }
54
+
55
+ .moj-alert__dismiss {
56
+ // Give the button link styling
57
+ margin-bottom: 0;
58
+ padding: 0;
59
+ border: none;
60
+ color: unset;
61
+ background-color: transparent;
62
+ -webkit-appearance: none;
63
+ cursor: pointer;
64
+ appearance: none;
65
+ @include govuk-font-size($size: 19);
66
+ @include govuk-link-common;
67
+ @include govuk-link-style-default;
68
+ @include govuk-link-print-friendly;
69
+ }
70
+
71
+ .moj-alert__content h2,
72
+ .moj-alert__content h3,
73
+ .moj-alert__content h4 {
74
+ margin-bottom: 2px;
75
+ line-height: 30px;
76
+ }
77
+
78
+ .moj-alert--with-heading .moj-alert__content {
79
+ // No padding needed when there is a heading
80
+ padding-top: 0;
81
+
82
+ @include govuk-media-query($from: tablet) {
83
+ padding-top: 0;
84
+ }
85
+ }
86
+
87
+ .moj-alert__content *:last-child {
88
+ margin-bottom: 0;
89
+ }
90
+
91
+ /* Style variants
92
+ ========================================================================== */
93
+ .moj-alert--information {
94
+ border-color: $govuk-brand-colour;
95
+ color: $govuk-brand-colour;
96
+
97
+ .moj-alert__dismiss,
98
+ .moj-alert__content a {
99
+ @include govuk-link-common;
100
+ @include govuk-link-style-default;
101
+ }
102
+ }
103
+
104
+ .moj-alert--success {
105
+ border-color: govuk-colour("green");
106
+ color: govuk-colour("green");
107
+
108
+ .moj-alert__dismiss,
109
+ .moj-alert__content a,
110
+ .moj-alert__content .govuk-link {
111
+ @include govuk-link-common;
112
+ @include govuk-link-style-success;
113
+ }
114
+ }
115
+
116
+ .moj-alert--warning {
117
+ border-color: $moj-warning-colour;
118
+ color: $moj-warning-colour;
119
+
120
+ .moj-alert__dismiss {
121
+ color: $moj-warning-link-colour;
122
+ }
123
+
124
+ .moj-alert__dismiss,
125
+ .moj-alert__content a,
126
+ .moj-alert__content .govuk-link {
127
+ @include govuk-link-common;
128
+ @include moj-link-style-warning;
129
+ }
130
+ }
131
+
132
+ .moj-alert--error {
133
+ border-color: govuk-colour("red");
134
+ color: govuk-colour("red");
135
+
136
+ .moj-alert__dismiss,
137
+ .moj-alert__content a,
138
+ .moj-alert__content .govuk-link {
139
+ @include govuk-link-common;
140
+ @include govuk-link-style-error;
141
+ }
142
+ }