@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
@@ -1,53 +1,83 @@
1
- MOJFrontend.SearchToggle = function (options) {
2
- this.options = options;
3
- this.container = $(this.options.search.container);
4
- this.toggleButtonContainer = $(this.options.toggleButton.container);
5
-
6
- if (this.container.data("moj-search-toggle-initialised")) {
7
- return;
8
- }
9
-
10
- this.container.data("moj-search-toggle-initialised", true);
11
-
12
- const svg =
13
- '<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>';
14
-
15
- this.toggleButton = $(
16
- '<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">' +
17
- this.options.toggleButton.text +
18
- svg +
19
- "</button>"
20
- );
21
- this.toggleButton.on("click", $.proxy(this, "onToggleButtonClick"));
22
- this.toggleButtonContainer.append(this.toggleButton);
23
- $(document).on("click", this.onDocumentClick.bind(this));
24
- $(document).on("focusin", this.onDocumentClick.bind(this));
25
- };
26
-
27
- MOJFrontend.SearchToggle.prototype.showMenu = function () {
28
- this.toggleButton.attr("aria-expanded", "true");
29
- this.container.removeClass("moj-js-hidden");
30
- this.container.find("input").first().get(0).focus();
31
- };
32
-
33
- MOJFrontend.SearchToggle.prototype.hideMenu = function () {
34
- this.container.addClass("moj-js-hidden");
35
- this.toggleButton.attr("aria-expanded", "false");
36
- };
37
-
38
- MOJFrontend.SearchToggle.prototype.onToggleButtonClick = function () {
39
- if (this.toggleButton.attr("aria-expanded") == "false") {
40
- this.showMenu();
41
- } else {
42
- this.hideMenu();
43
- }
44
- };
45
-
46
- MOJFrontend.SearchToggle.prototype.onDocumentClick = function (e) {
47
- if (
48
- !$.contains(this.toggleButtonContainer[0], e.target) &&
49
- !$.contains(this.container[0], e.target)
50
- ) {
51
- this.hideMenu();
52
- }
53
- };
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 searchToggle$1;
14
+ var hasRequiredSearchToggle;
15
+
16
+ function requireSearchToggle () {
17
+ if (hasRequiredSearchToggle) return searchToggle$1;
18
+ hasRequiredSearchToggle = 1;
19
+ const $ = _global_window_jQuery;
20
+
21
+ function SearchToggle(options) {
22
+ this.options = options;
23
+ this.container = $(this.options.search.container);
24
+ this.toggleButtonContainer = $(this.options.toggleButton.container);
25
+
26
+ if (this.container.data('moj-search-toggle-initialised')) {
27
+ return
28
+ }
29
+
30
+ this.container.data('moj-search-toggle-initialised', true);
31
+
32
+ const svg =
33
+ '<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>';
34
+
35
+ this.toggleButton = $(
36
+ `<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
37
+ ${this.options.toggleButton.text} ${svg}
38
+ </button>`
39
+ );
40
+ this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'));
41
+ this.toggleButtonContainer.append(this.toggleButton);
42
+ $(document).on('click', this.onDocumentClick.bind(this));
43
+ $(document).on('focusin', this.onDocumentClick.bind(this));
44
+ }
45
+
46
+ SearchToggle.prototype.showMenu = function () {
47
+ this.toggleButton.attr('aria-expanded', 'true');
48
+ this.container.removeClass('moj-js-hidden');
49
+ this.container.find('input').first().get(0).focus();
50
+ };
51
+
52
+ SearchToggle.prototype.hideMenu = function () {
53
+ this.container.addClass('moj-js-hidden');
54
+ this.toggleButton.attr('aria-expanded', 'false');
55
+ };
56
+
57
+ SearchToggle.prototype.onToggleButtonClick = function () {
58
+ if (this.toggleButton.attr('aria-expanded') === 'false') {
59
+ this.showMenu();
60
+ } else {
61
+ this.hideMenu();
62
+ }
63
+ };
64
+
65
+ SearchToggle.prototype.onDocumentClick = function (e) {
66
+ if (
67
+ !$.contains(this.toggleButtonContainer[0], e.target) &&
68
+ !$.contains(this.container[0], e.target)
69
+ ) {
70
+ this.hideMenu();
71
+ }
72
+ };
73
+
74
+ searchToggle$1 = { SearchToggle };
75
+ return searchToggle$1;
76
+ }
77
+
78
+ var searchToggleExports = requireSearchToggle();
79
+ var searchToggle = /*@__PURE__*/getDefaultExportFromCjs(searchToggleExports);
80
+
81
+ return searchToggle;
82
+
83
+ }));
@@ -1,24 +1,25 @@
1
1
  .moj-search-toggle__button {
2
2
  @include govuk-font($size: 19, $weight: bold);
3
- background-color: transparent;
4
- border: none;
5
- color: $govuk-link-colour;
6
- cursor: pointer;
7
3
  display: inline-block;
8
4
  padding-top: 12px;
5
+ padding-right: 0;
9
6
  padding-bottom: 13px;
10
7
  padding-left: 0;
11
- padding-right: 0;
8
+ border: none;
9
+ color: $govuk-link-colour;
10
+ background-color: transparent;
11
+ cursor: pointer;
12
12
  -webkit-font-smoothing: antialiased;
13
13
  -webkit-appearance: none;
14
+ appearance: none;
14
15
 
15
16
  &__icon {
16
17
  display: inline-block;
18
+ width: 20px;
17
19
  height: 20px;
18
20
  margin-left: govuk-spacing(2);
21
+ fill: currentcolor;
19
22
  vertical-align: middle;
20
- width: 20px;
21
- fill: currentColor;
22
23
 
23
24
  @media screen and (forced-colors: active) {
24
25
  fill: windowText;
@@ -26,12 +27,14 @@
26
27
  }
27
28
 
28
29
  &:focus {
29
- background-color: $govuk-focus-colour;
30
- color: $govuk-focus-text-colour;
31
- box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
32
- outline: none;
33
30
  position: relative;
34
31
  z-index: 1;
32
+ outline: none;
33
+ color: $govuk-focus-text-colour;
34
+ background-color: $govuk-focus-colour;
35
+ box-shadow:
36
+ 0 -2px $govuk-focus-colour,
37
+ 0 4px $govuk-focus-text-colour;
35
38
  }
36
39
  }
37
40
 
@@ -39,14 +42,17 @@
39
42
  padding: govuk-spacing(3);
40
43
 
41
44
  @include govuk-media-query($until: desktop) {
42
- padding-left: 0 !important;
45
+ // stylelint-disable-next-line declaration-no-important
43
46
  padding-right: 0 !important;
47
+ // stylelint-disable-next-line declaration-no-important
48
+ padding-left: 0 !important;
44
49
  }
45
50
  }
46
51
 
47
52
  // JS enabled
48
53
  .js-enabled .moj-search--toggle {
49
54
  @include govuk-media-query($until: desktop) {
55
+ // stylelint-disable-next-line declaration-no-important
50
56
  padding-top: 0 !important;
51
57
  }
52
58
  }
@@ -59,11 +65,11 @@
59
65
  background-color: govuk-colour("light-grey");
60
66
 
61
67
  @include govuk-media-query($from: desktop) {
62
- max-width: 450px;
63
68
  position: absolute;
64
- right: -15px;
69
+ z-index: 10;
65
70
  top: 50px; // Height of nav bar
71
+ right: -15px;
66
72
  width: 450px;
67
- z-index: 10;
73
+ max-width: 450px;
68
74
  }
69
75
  }
@@ -14,27 +14,25 @@
14
14
  display: block;
15
15
  padding: govuk-spacing(4) 0 0;
16
16
  }
17
-
18
17
  }
19
18
 
20
19
  .moj-side-navigation__title {
21
20
  @include govuk-font($size: 19);
22
- color: govuk-colour("dark-grey");
23
- font-weight: normal;
24
21
  margin: 0;
25
22
  padding: govuk-spacing(2);
26
23
  padding-left: govuk-spacing(2) + 4px;
24
+ color: govuk-colour("dark-grey");
25
+ font-weight: normal;
27
26
 
28
27
  @include govuk-media-query($until: tablet) {
29
28
  display: none;
30
29
  }
31
-
32
30
  }
33
31
 
34
32
  .moj-side-navigation__list {
35
- list-style: none;
36
33
  margin: 0;
37
34
  padding: 0;
35
+ list-style: none;
38
36
 
39
37
  @include govuk-media-query($until: tablet) {
40
38
  display: flex;
@@ -48,7 +46,6 @@
48
46
  }
49
47
 
50
48
  .moj-side-navigation__item {
51
-
52
49
  @include govuk-media-query($until: tablet) {
53
50
  display: flex;
54
51
  }
@@ -56,24 +53,22 @@
56
53
  a,
57
54
  a:link,
58
55
  a:visited {
59
- background-color: inherit;
60
- color: $govuk-link-colour;
61
56
  display: block;
57
+ color: $govuk-link-colour;
58
+ background-color: inherit;
62
59
  text-decoration: none;
63
60
 
64
61
  @include govuk-media-query($until: tablet) {
65
- border-bottom: 4px solid transparent;
66
62
  padding: govuk-spacing(3);
67
63
  padding-bottom: govuk-spacing(3) - 4px; // Compensate for 4px border
64
+ border-bottom: 4px solid transparent;
68
65
  }
69
66
 
70
67
  @include govuk-media-query($from: tablet) {
71
- background-color: inherit;
72
- border-left: 4px solid transparent;
73
68
  padding: govuk-spacing(2);
69
+ border-left: 4px solid transparent;
70
+ background-color: inherit;
74
71
  }
75
-
76
-
77
72
  }
78
73
 
79
74
  a:hover {
@@ -81,16 +76,14 @@
81
76
  }
82
77
 
83
78
  a:focus {
79
+ position: relative;
80
+ border-color: $govuk-focus-text-colour;
84
81
  color: $govuk-focus-text-colour;
85
82
  background-color: $govuk-focus-colour;
86
- border-color: $govuk-focus-text-colour;
87
- position: relative;
88
83
  }
89
-
90
84
  }
91
85
 
92
86
  .moj-side-navigation__item--active {
93
-
94
87
  a:link,
95
88
  a:visited {
96
89
  border-color: $govuk-link-colour;
@@ -99,14 +92,14 @@
99
92
  }
100
93
 
101
94
  a:hover {
102
- color: $govuk-link-hover-colour;
103
95
  border-color: $govuk-link-hover-colour;
96
+ color: $govuk-link-hover-colour;
104
97
  }
105
98
 
106
99
  a:focus {
100
+ border-color: $govuk-focus-text-colour;
107
101
  color: $govuk-focus-text-colour;
108
102
  background-color: $govuk-focus-colour;
109
- border-color: $govuk-focus-text-colour;
110
103
  }
111
104
 
112
105
  @include govuk-media-query($from: tablet) {
@@ -120,6 +113,4 @@
120
113
  background-color: $govuk-focus-colour;
121
114
  }
122
115
  }
123
-
124
-
125
116
  }
@@ -1,66 +1,68 @@
1
1
  [aria-sort] button,
2
2
  [aria-sort] button:hover {
3
- background-color: transparent;
3
+ position: relative;
4
+ margin: 0;
5
+ padding: 0 10px 0 0;
4
6
  border-width: 0;
7
+ color: #005ea5;
8
+ background-color: transparent;
5
9
  -webkit-box-shadow: 0 0 0 0;
6
10
  -moz-box-shadow: 0 0 0 0;
7
11
  box-shadow: 0 0 0 0;
8
- color: #005ea5;
9
- cursor: pointer;
10
12
  font-family: inherit;
11
13
  font-size: inherit;
14
+ font-size: 1em;
12
15
  font-weight: inherit;
13
- padding: 0 10px 0 0;
14
- position: relative;
15
16
  text-align: inherit;
16
- font-size: 1em;
17
- margin: 0;
17
+ cursor: pointer;
18
18
  }
19
19
 
20
20
  [aria-sort] button:focus {
21
- background-color: $govuk-focus-colour;
22
- color: $govuk-focus-text-colour;
23
- box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
24
21
  outline: none;
22
+ color: $govuk-focus-text-colour;
23
+ background-color: $govuk-focus-colour;
24
+ box-shadow:
25
+ 0 -2px $govuk-focus-colour,
26
+ 0 4px $govuk-focus-text-colour;
25
27
  }
26
28
 
27
29
  [aria-sort]:first-child button {
28
30
  right: auto;
29
31
  }
30
32
 
31
- [aria-sort] button:before {
33
+ [aria-sort] button::before {
32
34
  content: " \25bc";
33
35
  position: absolute;
34
- right: -1px;
35
36
  top: 9px;
37
+ right: -1px;
36
38
  font-size: 0.5em;
37
39
  }
38
40
 
39
- [aria-sort] button:after {
41
+ [aria-sort] button::after {
40
42
  content: " \25b2";
41
43
  position: absolute;
42
- right: -1px;
43
44
  top: 1px;
45
+ right: -1px;
44
46
  font-size: 0.5em;
45
47
  }
46
48
 
47
- [aria-sort="ascending"] button:before,
48
- [aria-sort="descending"] button:before {
49
+ [aria-sort="ascending"] button::before,
50
+ [aria-sort="descending"] button::before {
49
51
  content: none;
50
52
  }
51
53
 
52
- [aria-sort="ascending"] button:after {
54
+ [aria-sort="ascending"] button::after {
53
55
  content: " \25b2";
54
- font-size: .8em;
55
56
  position: absolute;
56
- right: -5px;
57
57
  top: 2px;
58
+ right: -5px;
59
+ font-size: 0.8em;
58
60
  }
59
61
 
60
- [aria-sort="descending"] button:after {
62
+ [aria-sort="descending"] button::after {
61
63
  content: " \25bc";
62
- font-size: .8em;
63
64
  position: absolute;
64
- right: -5px;
65
65
  top: 2px;
66
- }
66
+ right: -5px;
67
+ font-size: 0.8em;
68
+ }