@ministryofjustice/frontend 4.0.1 → 5.1.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 (256) hide show
  1. package/govuk-prototype-kit.config.json +19 -4
  2. package/moj/_base.scss +2 -0
  3. package/moj/_base.scss.map +1 -0
  4. package/moj/all.bundle.js +3010 -0
  5. package/moj/all.bundle.js.map +1 -0
  6. package/moj/all.bundle.mjs +3293 -0
  7. package/moj/all.bundle.mjs.map +1 -0
  8. package/moj/all.mjs +17 -110
  9. package/moj/all.mjs.map +1 -1
  10. package/moj/all.scss +3 -0
  11. package/moj/all.scss.map +1 -0
  12. package/moj/common/index.mjs +57 -0
  13. package/moj/common/index.mjs.map +1 -0
  14. package/moj/common/moj-frontend-version.mjs +14 -0
  15. package/moj/common/moj-frontend-version.mjs.map +1 -0
  16. package/moj/components/_all.scss +2 -0
  17. package/moj/components/_all.scss.map +1 -0
  18. package/moj/components/action-bar/_action-bar.scss +2 -0
  19. package/moj/components/action-bar/_action-bar.scss.map +1 -0
  20. package/moj/components/add-another/_add-another.scss +2 -0
  21. package/moj/components/add-another/_add-another.scss.map +1 -0
  22. package/moj/components/add-another/add-another.bundle.js +157 -0
  23. package/moj/components/add-another/add-another.bundle.js.map +1 -0
  24. package/moj/components/add-another/add-another.bundle.mjs +271 -0
  25. package/moj/components/add-another/add-another.bundle.mjs.map +1 -0
  26. package/moj/components/add-another/add-another.mjs +135 -91
  27. package/moj/components/add-another/add-another.mjs.map +1 -1
  28. package/moj/components/alert/_alert.scss +4 -0
  29. package/moj/components/alert/_alert.scss.map +1 -0
  30. package/moj/components/alert/alert.bundle.js +254 -0
  31. package/moj/components/alert/alert.bundle.js.map +1 -0
  32. package/moj/components/alert/alert.bundle.mjs +490 -0
  33. package/moj/components/alert/alert.bundle.mjs.map +1 -0
  34. package/moj/components/alert/alert.mjs +97 -218
  35. package/moj/components/alert/alert.mjs.map +1 -1
  36. package/moj/components/alert/{alert.spec.helper.js → alert.spec.helper.bundle.js} +1 -1
  37. package/moj/components/alert/alert.spec.helper.bundle.js.map +1 -0
  38. package/moj/components/alert/alert.spec.helper.bundle.mjs +67 -0
  39. package/moj/components/alert/alert.spec.helper.bundle.mjs.map +1 -0
  40. package/moj/components/alert/alert.spec.helper.mjs.map +1 -1
  41. package/moj/components/badge/_badge.scss +2 -0
  42. package/moj/components/badge/_badge.scss.map +1 -0
  43. package/moj/components/banner/_banner.scss +2 -0
  44. package/moj/components/banner/_banner.scss.map +1 -0
  45. package/moj/components/button-menu/README.md +12 -6
  46. package/moj/components/button-menu/_button-menu.scss +4 -1
  47. package/moj/components/button-menu/_button-menu.scss.map +1 -0
  48. package/moj/components/button-menu/button-menu.bundle.js +270 -0
  49. package/moj/components/button-menu/button-menu.bundle.js.map +1 -0
  50. package/moj/components/button-menu/button-menu.bundle.mjs +506 -0
  51. package/moj/components/button-menu/button-menu.bundle.mjs.map +1 -0
  52. package/moj/components/button-menu/button-menu.mjs +214 -280
  53. package/moj/components/button-menu/button-menu.mjs.map +1 -1
  54. package/moj/components/cookie-banner/_cookie-banner.scss +2 -0
  55. package/moj/components/cookie-banner/_cookie-banner.scss.map +1 -0
  56. package/moj/components/currency-input/_currency-input.scss +2 -0
  57. package/moj/components/currency-input/_currency-input.scss.map +1 -0
  58. package/moj/components/date-picker/_date-picker.scss +2 -0
  59. package/moj/components/date-picker/_date-picker.scss.map +1 -0
  60. package/moj/components/date-picker/date-picker.bundle.js +804 -0
  61. package/moj/components/date-picker/date-picker.bundle.js.map +1 -0
  62. package/moj/components/date-picker/date-picker.bundle.mjs +1040 -0
  63. package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -0
  64. package/moj/components/date-picker/date-picker.mjs +663 -827
  65. package/moj/components/date-picker/date-picker.mjs.map +1 -1
  66. package/moj/components/filter/_filter.scss +2 -0
  67. package/moj/components/filter/_filter.scss.map +1 -0
  68. package/moj/components/filter/template.njk +1 -1
  69. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js +185 -0
  70. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js.map +1 -0
  71. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs +421 -0
  72. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs.map +1 -0
  73. package/moj/components/filter-toggle-button/filter-toggle-button.mjs +166 -81
  74. package/moj/components/filter-toggle-button/filter-toggle-button.mjs.map +1 -1
  75. package/moj/components/form-validator/form-validator.bundle.js +288 -0
  76. package/moj/components/form-validator/form-validator.bundle.js.map +1 -0
  77. package/moj/components/form-validator/form-validator.bundle.mjs +524 -0
  78. package/moj/components/form-validator/form-validator.bundle.mjs.map +1 -0
  79. package/moj/components/form-validator/form-validator.mjs +226 -149
  80. package/moj/components/form-validator/form-validator.mjs.map +1 -1
  81. package/moj/components/header/_header.scss +2 -0
  82. package/moj/components/header/_header.scss.map +1 -0
  83. package/moj/components/identity-bar/_identity-bar.scss +2 -0
  84. package/moj/components/identity-bar/_identity-bar.scss.map +1 -0
  85. package/moj/components/interruption-card/_interruption-card.scss +2 -0
  86. package/moj/components/interruption-card/_interruption-card.scss.map +1 -0
  87. package/moj/components/messages/_messages.scss +2 -0
  88. package/moj/components/messages/_messages.scss.map +1 -0
  89. package/moj/components/multi-file-upload/_multi-file-upload.scss +2 -0
  90. package/moj/components/multi-file-upload/_multi-file-upload.scss.map +1 -0
  91. package/moj/components/multi-file-upload/multi-file-upload.bundle.js +397 -0
  92. package/moj/components/multi-file-upload/multi-file-upload.bundle.js.map +1 -0
  93. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs +633 -0
  94. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs.map +1 -0
  95. package/moj/components/multi-file-upload/multi-file-upload.mjs +384 -213
  96. package/moj/components/multi-file-upload/multi-file-upload.mjs.map +1 -1
  97. package/moj/components/multi-file-upload/template.njk +1 -1
  98. package/moj/components/multi-select/_multi-select.scss +2 -0
  99. package/moj/components/multi-select/_multi-select.scss.map +1 -0
  100. package/moj/components/multi-select/multi-select.bundle.js +143 -0
  101. package/moj/components/multi-select/multi-select.bundle.js.map +1 -0
  102. package/moj/components/multi-select/multi-select.bundle.mjs +379 -0
  103. package/moj/components/multi-select/multi-select.bundle.mjs.map +1 -0
  104. package/moj/components/multi-select/multi-select.mjs +123 -64
  105. package/moj/components/multi-select/multi-select.mjs.map +1 -1
  106. package/moj/components/notification-badge/_notification-badge.scss +2 -0
  107. package/moj/components/notification-badge/_notification-badge.scss.map +1 -0
  108. package/moj/components/organisation-switcher/_organisation-switcher.scss +2 -0
  109. package/moj/components/organisation-switcher/_organisation-switcher.scss.map +1 -0
  110. package/moj/components/page-header-actions/_page-header-actions.scss +2 -0
  111. package/moj/components/page-header-actions/_page-header-actions.scss.map +1 -0
  112. package/moj/components/pagination/_pagination.scss +2 -2
  113. package/moj/components/pagination/_pagination.scss.map +1 -0
  114. package/moj/components/password-reveal/_password-reveal.scss +5 -1
  115. package/moj/components/password-reveal/_password-reveal.scss.map +1 -0
  116. package/moj/components/password-reveal/password-reveal.bundle.js +52 -0
  117. package/moj/components/password-reveal/password-reveal.bundle.js.map +1 -0
  118. package/moj/components/password-reveal/password-reveal.bundle.mjs +166 -0
  119. package/moj/components/password-reveal/password-reveal.bundle.mjs.map +1 -0
  120. package/moj/components/password-reveal/password-reveal.mjs +39 -29
  121. package/moj/components/password-reveal/password-reveal.mjs.map +1 -1
  122. package/moj/components/primary-navigation/_primary-navigation.scss +2 -0
  123. package/moj/components/primary-navigation/_primary-navigation.scss.map +1 -0
  124. package/moj/components/progress-bar/_progress-bar.scss +2 -0
  125. package/moj/components/progress-bar/_progress-bar.scss.map +1 -0
  126. package/moj/components/rich-text-editor/README.md +16 -9
  127. package/moj/components/rich-text-editor/_rich-text-editor.scss +2 -0
  128. package/moj/components/rich-text-editor/_rich-text-editor.scss.map +1 -0
  129. package/moj/components/rich-text-editor/rich-text-editor.bundle.js +210 -0
  130. package/moj/components/rich-text-editor/rich-text-editor.bundle.js.map +1 -0
  131. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs +446 -0
  132. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs.map +1 -0
  133. package/moj/components/rich-text-editor/rich-text-editor.mjs +186 -140
  134. package/moj/components/rich-text-editor/rich-text-editor.mjs.map +1 -1
  135. package/moj/components/search/_search.scss +2 -0
  136. package/moj/components/search/_search.scss.map +1 -0
  137. package/moj/components/search-toggle/{search-toggle.scss → _search-toggle.scss} +2 -0
  138. package/moj/components/search-toggle/_search-toggle.scss.map +1 -0
  139. package/moj/components/search-toggle/search-toggle.bundle.js +122 -0
  140. package/moj/components/search-toggle/search-toggle.bundle.js.map +1 -0
  141. package/moj/components/search-toggle/search-toggle.bundle.mjs +358 -0
  142. package/moj/components/search-toggle/search-toggle.bundle.mjs.map +1 -0
  143. package/moj/components/search-toggle/search-toggle.mjs +104 -43
  144. package/moj/components/search-toggle/search-toggle.mjs.map +1 -1
  145. package/moj/components/side-navigation/_side-navigation.scss +2 -0
  146. package/moj/components/side-navigation/_side-navigation.scss.map +1 -0
  147. package/moj/components/sortable-table/_sortable-table.scss +2 -2
  148. package/moj/components/sortable-table/_sortable-table.scss.map +1 -0
  149. package/moj/components/sortable-table/sortable-table.bundle.js +202 -0
  150. package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -0
  151. package/moj/components/sortable-table/sortable-table.bundle.mjs +438 -0
  152. package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -0
  153. package/moj/components/sortable-table/sortable-table.mjs +179 -122
  154. package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
  155. package/moj/components/sub-navigation/_sub-navigation.scss +2 -0
  156. package/moj/components/sub-navigation/_sub-navigation.scss.map +1 -0
  157. package/moj/components/tag/_tag.scss +2 -0
  158. package/moj/components/tag/_tag.scss.map +1 -0
  159. package/moj/components/task-list/_task-list.scss +2 -0
  160. package/moj/components/task-list/_task-list.scss.map +1 -0
  161. package/moj/components/ticket-panel/_ticket-panel.scss +2 -0
  162. package/moj/components/ticket-panel/_ticket-panel.scss.map +1 -0
  163. package/moj/components/timeline/_timeline.scss +2 -0
  164. package/moj/components/timeline/_timeline.scss.map +1 -0
  165. package/moj/core/_all.scss +3 -0
  166. package/moj/core/_all.scss.map +1 -0
  167. package/moj/core/_moj-frontend-properties.scss +7 -0
  168. package/moj/core/_moj-frontend-properties.scss.map +1 -0
  169. package/moj/filters/all.js +44 -22
  170. package/moj/filters/prototype-kit-13-filters.js +4 -3
  171. package/moj/helpers/_all.scss +2 -0
  172. package/moj/helpers/_all.scss.map +1 -0
  173. package/moj/helpers/_hidden.scss +2 -0
  174. package/moj/helpers/_hidden.scss.map +1 -0
  175. package/moj/helpers/_links.scss +2 -0
  176. package/moj/helpers/_links.scss.map +1 -0
  177. package/moj/helpers.bundle.js +140 -0
  178. package/moj/helpers.bundle.js.map +1 -0
  179. package/moj/helpers.bundle.mjs +128 -0
  180. package/moj/helpers.bundle.mjs.map +1 -0
  181. package/moj/helpers.mjs +50 -77
  182. package/moj/helpers.mjs.map +1 -1
  183. package/moj/init.js +11 -2
  184. package/moj/moj-frontend.min.css +1 -1
  185. package/moj/moj-frontend.min.css.map +1 -1
  186. package/moj/moj-frontend.min.js +1 -1
  187. package/moj/moj-frontend.min.js.map +1 -1
  188. package/moj/objects/_all.scss +2 -0
  189. package/moj/objects/_all.scss.map +1 -0
  190. package/moj/objects/_button-group.scss +2 -0
  191. package/moj/objects/_button-group.scss.map +1 -0
  192. package/moj/objects/_filter-layout.scss +2 -0
  193. package/moj/objects/_filter-layout.scss.map +1 -0
  194. package/moj/objects/_scrollable-pane.scss +2 -0
  195. package/moj/objects/_scrollable-pane.scss.map +1 -0
  196. package/moj/objects/_width-container.scss +2 -0
  197. package/moj/objects/_width-container.scss.map +1 -0
  198. package/moj/settings/_all.scss +2 -0
  199. package/moj/settings/_all.scss.map +1 -0
  200. package/moj/settings/_assets.scss +2 -0
  201. package/moj/settings/_assets.scss.map +1 -0
  202. package/moj/settings/_colours.scss +2 -0
  203. package/moj/settings/_colours.scss.map +1 -0
  204. package/moj/settings/_measurements.scss +2 -0
  205. package/moj/settings/_measurements.scss.map +1 -0
  206. package/moj/settings/_typography.scss +2 -0
  207. package/moj/settings/_typography.scss.map +1 -0
  208. package/moj/template.njk +13 -0
  209. package/moj/utilities/_all.scss +2 -0
  210. package/moj/utilities/_all.scss.map +1 -0
  211. package/moj/utilities/_hidden.scss +2 -0
  212. package/moj/utilities/_hidden.scss.map +1 -0
  213. package/moj/utilities/_width-container.scss +2 -0
  214. package/moj/utilities/_width-container.scss.map +1 -0
  215. package/moj/vendor/govuk-frontend/_base.scss +2 -0
  216. package/moj/vendor/govuk-frontend/_base.scss.map +1 -0
  217. package/moj/vendor/govuk-frontend/_index.scss +2 -0
  218. package/moj/vendor/govuk-frontend/_index.scss.map +1 -0
  219. package/package.json +5 -6
  220. package/moj/all.jquery.min.js +0 -1
  221. package/moj/all.jquery.min.js.map +0 -1
  222. package/moj/all.js +0 -2662
  223. package/moj/all.js.map +0 -1
  224. package/moj/components/add-another/add-another.js +0 -115
  225. package/moj/components/add-another/add-another.js.map +0 -1
  226. package/moj/components/alert/alert.js +0 -356
  227. package/moj/components/alert/alert.js.map +0 -1
  228. package/moj/components/alert/alert.spec.helper.js.map +0 -1
  229. package/moj/components/button-menu/button-menu.js +0 -338
  230. package/moj/components/button-menu/button-menu.js.map +0 -1
  231. package/moj/components/date-picker/date-picker.js +0 -970
  232. package/moj/components/date-picker/date-picker.js.map +0 -1
  233. package/moj/components/filter-toggle-button/filter-toggle-button.js +0 -102
  234. package/moj/components/filter-toggle-button/filter-toggle-button.js.map +0 -1
  235. package/moj/components/form-validator/form-validator.js +0 -205
  236. package/moj/components/form-validator/form-validator.js.map +0 -1
  237. package/moj/components/multi-file-upload/multi-file-upload.js +0 -241
  238. package/moj/components/multi-file-upload/multi-file-upload.js.map +0 -1
  239. package/moj/components/multi-select/multi-select.js +0 -86
  240. package/moj/components/multi-select/multi-select.js.map +0 -1
  241. package/moj/components/password-reveal/password-reveal.js +0 -44
  242. package/moj/components/password-reveal/password-reveal.js.map +0 -1
  243. package/moj/components/rich-text-editor/rich-text-editor.js +0 -166
  244. package/moj/components/rich-text-editor/rich-text-editor.js.map +0 -1
  245. package/moj/components/search-toggle/search-toggle.js +0 -63
  246. package/moj/components/search-toggle/search-toggle.js.map +0 -1
  247. package/moj/components/sortable-table/sortable-table.js +0 -147
  248. package/moj/components/sortable-table/sortable-table.js.map +0 -1
  249. package/moj/helpers.js +0 -200
  250. package/moj/helpers.js.map +0 -1
  251. package/moj/vendor/html5shiv.js +0 -326
  252. package/moj/vendor/jquery.js +0 -9300
  253. package/moj/version.js +0 -12
  254. package/moj/version.js.map +0 -1
  255. package/moj/version.mjs +0 -4
  256. package/moj/version.mjs.map +0 -1
@@ -1,252 +1,131 @@
1
- import { setFocus, getPreviousSibling, findNearestMatchingElement } from '../../helpers.mjs';
1
+ import { ConfigurableComponent } from 'govuk-frontend';
2
+ import { setFocus } from '../../common/index.mjs';
3
+ import { getPreviousSibling, findNearestMatchingElement } from '../../helpers.mjs';
2
4
 
3
5
  /**
4
- * @typedef {object} AlertConfig
5
- * @property {boolean} [dismissible=false] - Can the alert be dismissed by the user
6
- * @property {string} [dismissText=Dismiss] - the label text for the dismiss button
7
- * @property {boolean} [disableAutoFocus=false] - whether the alert will be autofocused
8
- * @property {string} [focusOnDismissSelector] - CSS Selector for element to be focused on dismiss
6
+ * @augments {ConfigurableComponent<AlertConfig>}
9
7
  */
10
-
11
- /**
12
- * @param {HTMLElement} $module - the Alert element
13
- * @param {AlertConfig} config - configuration options
14
- * @class
15
- */
16
- function Alert($module, config = {}) {
17
- if (!$module) {
18
- return this
19
- }
20
-
21
- const schema = Object.freeze({
22
- properties: {
23
- dismissible: { type: 'boolean' },
24
- dismissText: { type: 'string' },
25
- disableAutoFocus: { type: 'boolean' },
26
- focusOnDismissSelector: { type: 'string' }
27
- }
28
- });
29
-
30
- const defaults = {
31
- dismissible: false,
32
- dismissText: 'Dismiss',
33
- disableAutoFocus: false
34
- };
35
-
36
- // data attributes override JS config, which overrides defaults
37
- this.config = this.mergeConfigs(
38
- defaults,
39
- config,
40
- this.parseDataset(schema, $module.dataset)
41
- );
42
-
43
- this.$module = $module;
44
- }
45
-
46
- Alert.prototype.init = function () {
8
+ class Alert extends ConfigurableComponent {
47
9
  /**
48
- * Focus the alert
49
- *
50
- * If `role="alert"` is set, focus the element to help some assistive
51
- * technologies prioritise announcing it.
52
- *
53
- * You can turn off the auto-focus functionality by setting
54
- * `data-disable-auto-focus="true"` in the component HTML. You might wish to
55
- * do this based on user research findings, or to avoid a clash with another
56
- * element which should be focused when the page loads.
10
+ * @param {Element | null} $root - HTML element to use for alert
11
+ * @param {AlertConfig} [config] - Alert config
57
12
  */
58
- if (
59
- this.$module.getAttribute('role') === 'alert' &&
60
- !this.config.disableAutoFocus
61
- ) {
62
- setFocus(this.$module);
13
+ constructor($root, config = {}) {
14
+ super($root, config);
15
+
16
+ /**
17
+ * Focus the alert
18
+ *
19
+ * If `role="alert"` is set, focus the element to help some assistive
20
+ * technologies prioritise announcing it.
21
+ *
22
+ * You can turn off the auto-focus functionality by setting
23
+ * `data-disable-auto-focus="true"` in the component HTML. You might wish to
24
+ * do this based on user research findings, or to avoid a clash with another
25
+ * element which should be focused when the page loads.
26
+ */
27
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
28
+ setFocus(this.$root);
29
+ }
30
+ this.$dismissButton = this.$root.querySelector('.moj-alert__dismiss');
31
+ if (this.config.dismissible && this.$dismissButton) {
32
+ this.$dismissButton.innerHTML = this.config.dismissText;
33
+ this.$dismissButton.removeAttribute('hidden');
34
+ this.$root.addEventListener('click', event => {
35
+ if (event.target instanceof Node && this.$dismissButton.contains(event.target)) {
36
+ this.dimiss();
37
+ }
38
+ });
39
+ }
63
40
  }
64
41
 
65
- this.$dismissButton = this.$module.querySelector('.moj-alert__dismiss');
42
+ /**
43
+ * Handle dismissing the alert
44
+ */
45
+ dimiss() {
46
+ let $elementToRecieveFocus;
66
47
 
67
- if (this.config.dismissible && this.$dismissButton) {
68
- this.$dismissButton.innerHTML = this.config.dismissText;
69
- this.$dismissButton.removeAttribute('hidden');
48
+ // If a selector has been provided, attempt to find that element
49
+ if (this.config.focusOnDismissSelector) {
50
+ $elementToRecieveFocus = document.querySelector(this.config.focusOnDismissSelector);
51
+ }
70
52
 
71
- this.$module.addEventListener('click', (event) => {
72
- if (this.$dismissButton.contains(event.target)) {
73
- this.dimiss();
53
+ // Is the next sibling another alert
54
+ if (!$elementToRecieveFocus) {
55
+ const $nextSibling = this.$root.nextElementSibling;
56
+ if ($nextSibling && $nextSibling.matches('.moj-alert')) {
57
+ $elementToRecieveFocus = $nextSibling;
74
58
  }
75
- });
76
- }
77
- };
78
-
79
- /**
80
- * Handle dismissing the alert
81
- */
82
- Alert.prototype.dimiss = function () {
83
- let $elementToRecieveFocus;
84
-
85
- // If a selector has been provided, attempt to find that element
86
- if (this.config.focusOnDismissSelector) {
87
- $elementToRecieveFocus = document.querySelector(
88
- this.config.focusOnDismissSelector
89
- );
90
- }
91
-
92
- // Is the next sibling another alert
93
- if (!$elementToRecieveFocus) {
94
- const $nextSibling = this.$module.nextElementSibling;
95
- if ($nextSibling && $nextSibling.matches('.moj-alert')) {
96
- $elementToRecieveFocus = $nextSibling;
97
59
  }
98
- }
99
60
 
100
- // Else try to find any preceding sibling alert or heading
101
- if (!$elementToRecieveFocus) {
102
- $elementToRecieveFocus = getPreviousSibling(
103
- this.$module,
104
- '.moj-alert, h1, h2, h3, h4, h5, h6'
105
- );
106
- }
107
-
108
- // Else find the closest ancestor heading, or fallback to main, or last resort
109
- // use the body element
110
- if (!$elementToRecieveFocus) {
111
- $elementToRecieveFocus = findNearestMatchingElement(
112
- this.$module,
113
- 'h1, h2, h3, h4, h5, h6, main, body'
114
- );
115
- }
116
-
117
- // If we have an element, place focus on it
118
- if ($elementToRecieveFocus) {
119
- setFocus($elementToRecieveFocus);
120
- }
121
-
122
- // Remove the alert
123
- this.$module.remove();
124
- };
125
-
126
- /**
127
- * Normalise string
128
- *
129
- * 'If it looks like a duck, and it quacks like a duck…' 🦆
130
- *
131
- * If the passed value looks like a boolean or a number, convert it to a boolean
132
- * or number.
133
- *
134
- * Designed to be used to convert config passed via data attributes (which are
135
- * always strings) into something sensible.
136
- *
137
- * @internal
138
- * @param {DOMStringMap[string]} value - The value to normalise
139
- * @param {SchemaProperty} [property] - Component schema property
140
- * @returns {string | boolean | number | undefined} Normalised data
141
- */
142
- Alert.prototype.normaliseString = function (value, property) {
143
- const trimmedValue = value ? value.trim() : '';
144
-
145
- let output;
146
- let outputType;
147
- if (property && property.type) {
148
- outputType = property.type;
149
- }
150
-
151
- // No schema type set? Determine automatically
152
- if (!outputType) {
153
- if (['true', 'false'].includes(trimmedValue)) {
154
- outputType = 'boolean';
61
+ // Else try to find any preceding sibling alert or heading
62
+ if (!$elementToRecieveFocus) {
63
+ $elementToRecieveFocus = getPreviousSibling(this.$root, '.moj-alert, h1, h2, h3, h4, h5, h6');
155
64
  }
156
65
 
157
- // Empty / whitespace-only strings are considered finite so we need to check
158
- // the length of the trimmed string as well
159
- if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
160
- outputType = 'number';
66
+ // Else find the closest ancestor heading, or fallback to main, or last resort
67
+ // use the body element
68
+ if (!$elementToRecieveFocus) {
69
+ $elementToRecieveFocus = findNearestMatchingElement(this.$root, 'h1, h2, h3, h4, h5, h6, main, body');
161
70
  }
162
- }
163
71
 
164
- switch (outputType) {
165
- case 'boolean':
166
- output = trimmedValue === 'true';
167
- break
168
-
169
- case 'number':
170
- output = Number(trimmedValue);
171
- break
72
+ // If we have an element, place focus on it
73
+ if ($elementToRecieveFocus instanceof HTMLElement) {
74
+ setFocus($elementToRecieveFocus);
75
+ }
172
76
 
173
- default:
174
- output = value;
77
+ // Remove the alert
78
+ this.$root.remove();
175
79
  }
176
80
 
177
- return output
178
- };
81
+ /**
82
+ * Name for the component used when initialising using data-module attributes.
83
+ */
84
+ }
179
85
 
180
86
  /**
181
- * Parse dataset
182
- *
183
- * Loop over an object and normalise each value using {@link normaliseString},
184
- * optionally expanding nested `i18n.field`
185
- *
186
- * @param {Schema} schema - component schema
187
- * @param {DOMStringMap} dataset - HTML element dataset
188
- * @returns {object} Normalised dataset
87
+ * @typedef {object} AlertConfig
88
+ * @property {boolean} [dismissible=false] - Can the alert be dismissed by the user
89
+ * @property {string} [dismissText=Dismiss] - the label text for the dismiss button
90
+ * @property {boolean} [disableAutoFocus=false] - whether the alert will be autofocused
91
+ * @property {string} [focusOnDismissSelector] - CSS Selector for element to be focused on dismiss
189
92
  */
190
- Alert.prototype.parseDataset = function (schema, dataset) {
191
- const parsed = {};
192
-
193
- for (const [field, property] of Object.entries(schema.properties)) {
194
- if (field in dataset) {
195
- if (dataset[field]) {
196
- parsed[field] = this.normaliseString(dataset[field], property);
197
- }
198
- }
199
- }
200
-
201
- return parsed
202
- };
203
93
 
204
94
  /**
205
- * Config merging function
206
- *
207
- * Takes any number of objects and combines them together, with
208
- * greatest priority on the LAST item passed in.
209
- *
210
- * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge
211
- * @returns {{ [key: string]: unknown }} A merged config object
95
+ * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'
212
96
  */
213
- Alert.prototype.mergeConfigs = function (...configObjects) {
214
- const formattedConfigObject = {};
215
-
216
- // Loop through each of the passed objects
217
- for (const configObject of configObjects) {
218
- for (const key of Object.keys(configObject)) {
219
- const option = formattedConfigObject[key];
220
- const override = configObject[key];
221
-
222
- // Push their keys one-by-one into formattedConfigObject. Any duplicate
223
- // keys with object values will be merged, otherwise the new value will
224
- // override the existing value.
225
- if (typeof option === 'object' && typeof override === 'object') {
226
- // @ts-expect-error Index signature for type 'string' is missing
227
- formattedConfigObject[key] = this.mergeConfigs(option, override);
228
- } else {
229
- formattedConfigObject[key] = override;
230
- }
231
- }
232
- }
233
-
234
- return formattedConfigObject
235
- };
236
-
97
+ Alert.moduleName = 'moj-alert';
237
98
  /**
238
- * Schema for component config
99
+ * Alert default config
239
100
  *
240
- * @typedef {object} Schema
241
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
101
+ * @type {AlertConfig}
242
102
  */
243
-
103
+ Alert.defaults = Object.freeze({
104
+ dismissible: false,
105
+ dismissText: 'Dismiss',
106
+ disableAutoFocus: false
107
+ });
244
108
  /**
245
- * Schema property for component config
109
+ * Alert config schema
246
110
  *
247
- * @typedef {object} SchemaProperty
248
- * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
111
+ * @satisfies {Schema<AlertConfig>}
249
112
  */
113
+ Alert.schema = Object.freeze(/** @type {const} */{
114
+ properties: {
115
+ dismissible: {
116
+ type: 'boolean'
117
+ },
118
+ dismissText: {
119
+ type: 'string'
120
+ },
121
+ disableAutoFocus: {
122
+ type: 'boolean'
123
+ },
124
+ focusOnDismissSelector: {
125
+ type: 'string'
126
+ }
127
+ }
128
+ });
250
129
 
251
130
  export { Alert };
252
131
  //# sourceMappingURL=alert.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.mjs","sources":["../../../../src/moj/components/alert/alert.mjs"],"sourcesContent":["import {\n findNearestMatchingElement,\n getPreviousSibling,\n setFocus\n} from '../../helpers.mjs'\n\n/**\n * @typedef {object} AlertConfig\n * @property {boolean} [dismissible=false] - Can the alert be dismissed by the user\n * @property {string} [dismissText=Dismiss] - the label text for the dismiss button\n * @property {boolean} [disableAutoFocus=false] - whether the alert will be autofocused\n * @property {string} [focusOnDismissSelector] - CSS Selector for element to be focused on dismiss\n */\n\n/**\n * @param {HTMLElement} $module - the Alert element\n * @param {AlertConfig} config - configuration options\n * @class\n */\nexport function Alert($module, config = {}) {\n if (!$module) {\n return this\n }\n\n const schema = Object.freeze({\n properties: {\n dismissible: { type: 'boolean' },\n dismissText: { type: 'string' },\n disableAutoFocus: { type: 'boolean' },\n focusOnDismissSelector: { type: 'string' }\n }\n })\n\n const defaults = {\n dismissible: false,\n dismissText: 'Dismiss',\n disableAutoFocus: false\n }\n\n // data attributes override JS config, which overrides defaults\n this.config = this.mergeConfigs(\n defaults,\n config,\n this.parseDataset(schema, $module.dataset)\n )\n\n this.$module = $module\n}\n\nAlert.prototype.init = function () {\n /**\n * Focus the alert\n *\n * If `role=\"alert\"` is set, focus the element to help some assistive\n * technologies prioritise announcing it.\n *\n * You can turn off the auto-focus functionality by setting\n * `data-disable-auto-focus=\"true\"` in the component HTML. You might wish to\n * do this based on user research findings, or to avoid a clash with another\n * element which should be focused when the page loads.\n */\n if (\n this.$module.getAttribute('role') === 'alert' &&\n !this.config.disableAutoFocus\n ) {\n setFocus(this.$module)\n }\n\n this.$dismissButton = this.$module.querySelector('.moj-alert__dismiss')\n\n if (this.config.dismissible && this.$dismissButton) {\n this.$dismissButton.innerHTML = this.config.dismissText\n this.$dismissButton.removeAttribute('hidden')\n\n this.$module.addEventListener('click', (event) => {\n if (this.$dismissButton.contains(event.target)) {\n this.dimiss()\n }\n })\n }\n}\n\n/**\n * Handle dismissing the alert\n */\nAlert.prototype.dimiss = function () {\n let $elementToRecieveFocus\n\n // If a selector has been provided, attempt to find that element\n if (this.config.focusOnDismissSelector) {\n $elementToRecieveFocus = document.querySelector(\n this.config.focusOnDismissSelector\n )\n }\n\n // Is the next sibling another alert\n if (!$elementToRecieveFocus) {\n const $nextSibling = this.$module.nextElementSibling\n if ($nextSibling && $nextSibling.matches('.moj-alert')) {\n $elementToRecieveFocus = $nextSibling\n }\n }\n\n // Else try to find any preceding sibling alert or heading\n if (!$elementToRecieveFocus) {\n $elementToRecieveFocus = getPreviousSibling(\n this.$module,\n '.moj-alert, h1, h2, h3, h4, h5, h6'\n )\n }\n\n // Else find the closest ancestor heading, or fallback to main, or last resort\n // use the body element\n if (!$elementToRecieveFocus) {\n $elementToRecieveFocus = findNearestMatchingElement(\n this.$module,\n 'h1, h2, h3, h4, h5, h6, main, body'\n )\n }\n\n // If we have an element, place focus on it\n if ($elementToRecieveFocus) {\n setFocus($elementToRecieveFocus)\n }\n\n // Remove the alert\n this.$module.remove()\n}\n\n/**\n * Normalise string\n *\n * 'If it looks like a duck, and it quacks like a duck…' 🦆\n *\n * If the passed value looks like a boolean or a number, convert it to a boolean\n * or number.\n *\n * Designed to be used to convert config passed via data attributes (which are\n * always strings) into something sensible.\n *\n * @internal\n * @param {DOMStringMap[string]} value - The value to normalise\n * @param {SchemaProperty} [property] - Component schema property\n * @returns {string | boolean | number | undefined} Normalised data\n */\nAlert.prototype.normaliseString = function (value, property) {\n const trimmedValue = value ? value.trim() : ''\n\n let output\n let outputType\n if (property && property.type) {\n outputType = property.type\n }\n\n // No schema type set? Determine automatically\n if (!outputType) {\n if (['true', 'false'].includes(trimmedValue)) {\n outputType = 'boolean'\n }\n\n // Empty / whitespace-only strings are considered finite so we need to check\n // the length of the trimmed string as well\n if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {\n outputType = 'number'\n }\n }\n\n switch (outputType) {\n case 'boolean':\n output = trimmedValue === 'true'\n break\n\n case 'number':\n output = Number(trimmedValue)\n break\n\n default:\n output = value\n }\n\n return output\n}\n\n/**\n * Parse dataset\n *\n * Loop over an object and normalise each value using {@link normaliseString},\n * optionally expanding nested `i18n.field`\n *\n * @param {Schema} schema - component schema\n * @param {DOMStringMap} dataset - HTML element dataset\n * @returns {object} Normalised dataset\n */\nAlert.prototype.parseDataset = function (schema, dataset) {\n const parsed = {}\n\n for (const [field, property] of Object.entries(schema.properties)) {\n if (field in dataset) {\n if (dataset[field]) {\n parsed[field] = this.normaliseString(dataset[field], property)\n }\n }\n }\n\n return parsed\n}\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nAlert.prototype.mergeConfigs = function (...configObjects) {\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (typeof option === 'object' && typeof override === 'object') {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = this.mergeConfigs(option, override)\n } else {\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,EAAE;AAC5C,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,OAAO;AACX;;AAEA,EAAE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC/B,IAAI,UAAU,EAAE;AAChB,MAAM,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;AACtC,MAAM,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;AACrC,MAAM,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;AAC3C,MAAM,sBAAsB,EAAE,EAAE,IAAI,EAAE,QAAQ;AAC9C;AACA,GAAG;;AAEH,EAAE,MAAM,QAAQ,GAAG;AACnB,IAAI,WAAW,EAAE,KAAK;AACtB,IAAI,WAAW,EAAE,SAAS;AAC1B,IAAI,gBAAgB,EAAE;AACtB;;AAEA;AACA,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY;AACjC,IAAI,QAAQ;AACZ,IAAI,MAAM;AACV,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO;AAC7C;;AAEA,EAAE,IAAI,CAAC,OAAO,GAAG;AACjB;;AAEA,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,YAAY;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO;AACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;AACjB,IAAI;AACJ,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO;AACzB;;AAEA,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,qBAAqB;;AAExE,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,cAAc,EAAE;AACtD,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;AAChD,IAAI,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,QAAQ;;AAEhD,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,KAAK;AACtD,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACtD,QAAQ,IAAI,CAAC,MAAM;AACnB;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY;AACrC,EAAE,IAAI;;AAEN;AACA,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE;AAC1C,IAAI,sBAAsB,GAAG,QAAQ,CAAC,aAAa;AACnD,MAAM,IAAI,CAAC,MAAM,CAAC;AAClB;AACA;;AAEA;AACA,EAAE,IAAI,CAAC,sBAAsB,EAAE;AAC/B,IAAI,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;AACtC,IAAI,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AAC5D,MAAM,sBAAsB,GAAG;AAC/B;AACA;;AAEA;AACA,EAAE,IAAI,CAAC,sBAAsB,EAAE;AAC/B,IAAI,sBAAsB,GAAG,kBAAkB;AAC/C,MAAM,IAAI,CAAC,OAAO;AAClB,MAAM;AACN;AACA;;AAEA;AACA;AACA,EAAE,IAAI,CAAC,sBAAsB,EAAE;AAC/B,IAAI,sBAAsB,GAAG,0BAA0B;AACvD,MAAM,IAAI,CAAC,OAAO;AAClB,MAAM;AACN;AACA;;AAEA;AACA,EAAE,IAAI,sBAAsB,EAAE;AAC9B,IAAI,QAAQ,CAAC,sBAAsB;AACnC;;AAEA;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,KAAK,EAAE,QAAQ,EAAE;AAC7D,EAAE,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG;;AAE9C,EAAE,IAAI;AACN,EAAE,IAAI;AACN,EAAE,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE;AACjC,IAAI,UAAU,GAAG,QAAQ,CAAC;AAC1B;;AAEA;AACA,EAAE,IAAI,CAAC,UAAU,EAAE;AACnB,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;AAClD,MAAM,UAAU,GAAG;AACnB;;AAEA;AACA;AACA,IAAI,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE;AACnE,MAAM,UAAU,GAAG;AACnB;AACA;;AAEA,EAAE,QAAQ,UAAU;AACpB,IAAI,KAAK,SAAS;AAClB,MAAM,MAAM,GAAG,YAAY,KAAK;AAChC,MAAM;;AAEN,IAAI,KAAK,QAAQ;AACjB,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY;AAClC,MAAM;;AAEN,IAAI;AACJ,MAAM,MAAM,GAAG;AACf;;AAEA,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,MAAM,EAAE,OAAO,EAAE;AAC1D,EAAE,MAAM,MAAM,GAAG;;AAEjB,EAAE,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;AACrE,IAAI,IAAI,KAAK,IAAI,OAAO,EAAE;AAC1B,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;AAC1B,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ;AACrE;AACA;AACA;;AAEA,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,GAAG,aAAa,EAAE;AAC3D,EAAE,MAAM,qBAAqB,GAAG;;AAEhC;AACA,EAAE,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;AAC5C,IAAI,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;AACjD,MAAM,MAAM,MAAM,GAAG,qBAAqB,CAAC,GAAG;AAC9C,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG;;AAEvC;AACA;AACA;AACA,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AACtE;AACA,QAAQ,qBAAqB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ;AACvE,OAAO,MAAM;AACb,QAAQ,qBAAqB,CAAC,GAAG,CAAC,GAAG;AACrC;AACA;AACA;;AAEA,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"alert.mjs","sources":["../../../../src/moj/components/alert/alert.mjs"],"sourcesContent":["import { ConfigurableComponent } from 'govuk-frontend'\n\nimport { setFocus } from '../../common/index.mjs'\nimport {\n findNearestMatchingElement,\n getPreviousSibling\n} from '../../helpers.mjs'\n\n/**\n * @augments {ConfigurableComponent<AlertConfig>}\n */\nexport class Alert extends ConfigurableComponent {\n /**\n * @param {Element | null} $root - HTML element to use for alert\n * @param {AlertConfig} [config] - Alert config\n */\n constructor($root, config = {}) {\n super($root, config)\n\n /**\n * Focus the alert\n *\n * If `role=\"alert\"` is set, focus the element to help some assistive\n * technologies prioritise announcing it.\n *\n * You can turn off the auto-focus functionality by setting\n * `data-disable-auto-focus=\"true\"` in the component HTML. You might wish to\n * do this based on user research findings, or to avoid a clash with another\n * element which should be focused when the page loads.\n */\n if (\n this.$root.getAttribute('role') === 'alert' &&\n !this.config.disableAutoFocus\n ) {\n setFocus(this.$root)\n }\n\n this.$dismissButton = this.$root.querySelector('.moj-alert__dismiss')\n\n if (this.config.dismissible && this.$dismissButton) {\n this.$dismissButton.innerHTML = this.config.dismissText\n this.$dismissButton.removeAttribute('hidden')\n\n this.$root.addEventListener('click', (event) => {\n if (\n event.target instanceof Node &&\n this.$dismissButton.contains(event.target)\n ) {\n this.dimiss()\n }\n })\n }\n }\n\n /**\n * Handle dismissing the alert\n */\n dimiss() {\n let $elementToRecieveFocus\n\n // If a selector has been provided, attempt to find that element\n if (this.config.focusOnDismissSelector) {\n $elementToRecieveFocus = document.querySelector(\n this.config.focusOnDismissSelector\n )\n }\n\n // Is the next sibling another alert\n if (!$elementToRecieveFocus) {\n const $nextSibling = this.$root.nextElementSibling\n if ($nextSibling && $nextSibling.matches('.moj-alert')) {\n $elementToRecieveFocus = $nextSibling\n }\n }\n\n // Else try to find any preceding sibling alert or heading\n if (!$elementToRecieveFocus) {\n $elementToRecieveFocus = getPreviousSibling(\n this.$root,\n '.moj-alert, h1, h2, h3, h4, h5, h6'\n )\n }\n\n // Else find the closest ancestor heading, or fallback to main, or last resort\n // use the body element\n if (!$elementToRecieveFocus) {\n $elementToRecieveFocus = findNearestMatchingElement(\n this.$root,\n 'h1, h2, h3, h4, h5, h6, main, body'\n )\n }\n\n // If we have an element, place focus on it\n if ($elementToRecieveFocus instanceof HTMLElement) {\n setFocus($elementToRecieveFocus)\n }\n\n // Remove the alert\n this.$root.remove()\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-alert'\n\n /**\n * Alert default config\n *\n * @type {AlertConfig}\n */\n static defaults = Object.freeze({\n dismissible: false,\n dismissText: 'Dismiss',\n disableAutoFocus: false\n })\n\n /**\n * Alert config schema\n *\n * @satisfies {Schema<AlertConfig>}\n */\n static schema = Object.freeze(\n /** @type {const} */ ({\n properties: {\n dismissible: { type: 'boolean' },\n dismissText: { type: 'string' },\n disableAutoFocus: { type: 'boolean' },\n focusOnDismissSelector: { type: 'string' }\n }\n })\n )\n}\n\n/**\n * @typedef {object} AlertConfig\n * @property {boolean} [dismissible=false] - Can the alert be dismissed by the user\n * @property {string} [dismissText=Dismiss] - the label text for the dismiss button\n * @property {boolean} [disableAutoFocus=false] - whether the alert will be autofocused\n * @property {string} [focusOnDismissSelector] - CSS Selector for element to be focused on dismiss\n */\n\n/**\n * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'\n */\n"],"names":["Alert","ConfigurableComponent","constructor","$root","config","getAttribute","disableAutoFocus","setFocus","$dismissButton","querySelector","dismissible","innerHTML","dismissText","removeAttribute","addEventListener","event","target","Node","contains","dimiss","$elementToRecieveFocus","focusOnDismissSelector","document","$nextSibling","nextElementSibling","matches","getPreviousSibling","findNearestMatchingElement","HTMLElement","remove","moduleName","defaults","Object","freeze","schema","properties","type"],"mappings":"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"}
@@ -72,4 +72,4 @@
72
72
  exports.pageTemplate = pageTemplate;
73
73
 
74
74
  }));
75
- //# sourceMappingURL=alert.spec.helper.js.map
75
+ //# sourceMappingURL=alert.spec.helper.bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.spec.helper.bundle.js","sources":["../../../../src/moj/components/alert/alert.spec.helper.mjs"],"sourcesContent":["export const pageTemplate = `\n <main>\n <div id=\"alert-1\" role=\"region\" class=\"moj-alert moj-alert--information moj-alert--with-heading\" aria-label=\"information: This contains information\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">\n <h2 class=\"govuk-heading-m\">This contains information</h2>\n Content that informs you of a thing. It really is so very informative, that&#39;s why it needs so much content and is really, exceedingly verbose.\n </div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <h1 id=\"h1\">Heading 1</h1>\n <section>\n <h2 id=\"h2\">heading 2</h2>\n <div id=\"alert-2\" role=\"region\" class=\"moj-alert moj-alert--information\" aria-label=\"information: You might like to know\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Content that informs you of a thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n\n <div id=\"alert-3\"role=\"region\" class=\"moj-alert moj-alert--success\" aria-label=\"success: Woohoo!\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path d=\"M11.2869 24.6726L2.00415 15.3899L4.62189 12.7722L11.2869 19.4186L25.3781 5.32739L27.9958 7.96369L11.2869 24.6726Z\" fill=\"currentColor\"/>\n </svg>\n </div>\n <div class=\"moj-alert__content\">That thing just successfully occurred. <a href=\"#\">Celebrate here</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-4\" role=\"region\" class=\"moj-alert moj-alert--warning\" aria-label=\"warning: Something&#39;s not quite right\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M15 2.44922L28.75 26.1992H1.25L15 2.44922ZM13.5107 9.49579H16.4697L16.2431 17.7678H13.7461L13.5107 9.49579ZM13.1299 21.82C13.1299 21.5661 13.1787 21.3285 13.2764 21.1071C13.374 20.8793 13.5075 20.6807 13.6768 20.5114C13.8525 20.3421 14.0544 20.2087 14.2822 20.111C14.5101 20.0134 14.7542 19.9645 15.0146 19.9645C15.2686 19.9645 15.5062 20.0134 15.7275 20.111C15.9554 20.2087 16.154 20.3421 16.3232 20.5114C16.4925 20.6807 16.626 20.8793 16.7236 21.1071C16.8213 21.3285 16.8701 21.5661 16.8701 21.82C16.8701 22.0804 16.8213 22.3246 16.7236 22.5524C16.626 22.7803 16.4925 22.9789 16.3232 23.1481C16.154 23.3174 15.9554 23.4509 15.7275 23.5485C15.5062 23.6462 15.2686 23.695 15.0146 23.695C14.7542 23.695 14.5101 23.6462 14.2822 23.5485C14.0544 23.4509 13.8525 23.3174 13.6768 23.1481C13.5075 22.9789 13.374 22.7803 13.2764 22.5524C13.1787 22.3246 13.1299 22.0804 13.1299 21.82Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">You should be aware of this thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-5\" role=\"region\" class=\"moj-alert moj-alert--error\" aria-label=\"error: Woah, hold up!\" data-module=\"moj-alert\" data-dismissible=\"true\" data-dismissible=\"true\" data-focus-on-dismiss-selector=\"#focusOnMe\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20.1777 2.5H9.82233L2.5 9.82233V20.1777L9.82233 27.5H20.1777L27.5 20.1777V9.82233L20.1777 2.5ZM10.9155 8.87769L15.0001 12.9623L19.0847 8.87771L21.1224 10.9154L17.0378 15L21.1224 19.0846L19.0847 21.1222L15.0001 17.0376L10.9155 21.1223L8.87782 19.0846L12.9624 15L8.87783 10.9153L10.9155 8.87769Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Bad things happened. <a href=\"#\">Contact us</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"focusOnMe\">I will receive focus</div>\n </section>\n</main>\n`\n"],"names":["pageTemplate"],"mappings":";;;;;;AAAO,QAAMA,YAAY,GAAG;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;"}
@@ -0,0 +1,67 @@
1
+ const pageTemplate = `
2
+ <main>
3
+ <div id="alert-1" role="region" class="moj-alert moj-alert--information moj-alert--with-heading" aria-label="information: This contains information" data-module="moj-alert" data-dismissible="true">
4
+ <div>
5
+ <svg class="moj-alert__icon" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" height="30" width="30"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z" fill="currentColor"/></svg>
6
+ </div>
7
+ <div class="moj-alert__content">
8
+ <h2 class="govuk-heading-m">This contains information</h2>
9
+ Content that informs you of a thing. It really is so very informative, that&#39;s why it needs so much content and is really, exceedingly verbose.
10
+ </div>
11
+ <div class="moj-alert__action">
12
+ <button class="moj-alert__dismiss" hidden>Dismiss</button>
13
+ </div>
14
+ </div>
15
+
16
+ <h1 id="h1">Heading 1</h1>
17
+ <section>
18
+ <h2 id="h2">heading 2</h2>
19
+ <div id="alert-2" role="region" class="moj-alert moj-alert--information" aria-label="information: You might like to know" data-module="moj-alert" data-dismissible="true">
20
+ <div>
21
+ <svg class="moj-alert__icon" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" height="30" width="30"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z" fill="currentColor"/></svg>
22
+ </div>
23
+ <div class="moj-alert__content">Content that informs you of a thing. <a href="#">More information</a></div>
24
+ <div class="moj-alert__action">
25
+ <button class="moj-alert__dismiss" hidden>Dismiss</button>
26
+ </div>
27
+ </div>
28
+
29
+
30
+ <div id="alert-3"role="region" class="moj-alert moj-alert--success" aria-label="success: Woohoo!" data-module="moj-alert" data-dismissible="true">
31
+ <div>
32
+ <svg class="moj-alert__icon" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" height="30" width="30"><path d="M11.2869 24.6726L2.00415 15.3899L4.62189 12.7722L11.2869 19.4186L25.3781 5.32739L27.9958 7.96369L11.2869 24.6726Z" fill="currentColor"/>
33
+ </svg>
34
+ </div>
35
+ <div class="moj-alert__content">That thing just successfully occurred. <a href="#">Celebrate here</a></div>
36
+ <div class="moj-alert__action">
37
+ <button class="moj-alert__dismiss" hidden>Dismiss</button>
38
+ </div>
39
+ </div>
40
+
41
+ <div id="alert-4" role="region" class="moj-alert moj-alert--warning" aria-label="warning: Something&#39;s not quite right" data-module="moj-alert" data-dismissible="true">
42
+ <div>
43
+ <svg class="moj-alert__icon" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" height="30" width="30"><path fill-rule="evenodd" clip-rule="evenodd" d="M15 2.44922L28.75 26.1992H1.25L15 2.44922ZM13.5107 9.49579H16.4697L16.2431 17.7678H13.7461L13.5107 9.49579ZM13.1299 21.82C13.1299 21.5661 13.1787 21.3285 13.2764 21.1071C13.374 20.8793 13.5075 20.6807 13.6768 20.5114C13.8525 20.3421 14.0544 20.2087 14.2822 20.111C14.5101 20.0134 14.7542 19.9645 15.0146 19.9645C15.2686 19.9645 15.5062 20.0134 15.7275 20.111C15.9554 20.2087 16.154 20.3421 16.3232 20.5114C16.4925 20.6807 16.626 20.8793 16.7236 21.1071C16.8213 21.3285 16.8701 21.5661 16.8701 21.82C16.8701 22.0804 16.8213 22.3246 16.7236 22.5524C16.626 22.7803 16.4925 22.9789 16.3232 23.1481C16.154 23.3174 15.9554 23.4509 15.7275 23.5485C15.5062 23.6462 15.2686 23.695 15.0146 23.695C14.7542 23.695 14.5101 23.6462 14.2822 23.5485C14.0544 23.4509 13.8525 23.3174 13.6768 23.1481C13.5075 22.9789 13.374 22.7803 13.2764 22.5524C13.1787 22.3246 13.1299 22.0804 13.1299 21.82Z" fill="currentColor"/></svg>
44
+ </div>
45
+ <div class="moj-alert__content">You should be aware of this thing. <a href="#">More information</a></div>
46
+ <div class="moj-alert__action">
47
+ <button class="moj-alert__dismiss" hidden>Dismiss</button>
48
+ </div>
49
+ </div>
50
+
51
+ <div id="alert-5" role="region" class="moj-alert moj-alert--error" aria-label="error: Woah, hold up!" data-module="moj-alert" data-dismissible="true" data-dismissible="true" data-focus-on-dismiss-selector="#focusOnMe">
52
+ <div>
53
+ <svg class="moj-alert__icon" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" height="30" width="30"><path fill-rule="evenodd" clip-rule="evenodd" d="M20.1777 2.5H9.82233L2.5 9.82233V20.1777L9.82233 27.5H20.1777L27.5 20.1777V9.82233L20.1777 2.5ZM10.9155 8.87769L15.0001 12.9623L19.0847 8.87771L21.1224 10.9154L17.0378 15L21.1224 19.0846L19.0847 21.1222L15.0001 17.0376L10.9155 21.1223L8.87782 19.0846L12.9624 15L8.87783 10.9153L10.9155 8.87769Z" fill="currentColor"/></svg>
54
+ </div>
55
+ <div class="moj-alert__content">Bad things happened. <a href="#">Contact us</a></div>
56
+ <div class="moj-alert__action">
57
+ <button class="moj-alert__dismiss" hidden>Dismiss</button>
58
+ </div>
59
+ </div>
60
+
61
+ <div id="focusOnMe">I will receive focus</div>
62
+ </section>
63
+ </main>
64
+ `;
65
+
66
+ export { pageTemplate };
67
+ //# sourceMappingURL=alert.spec.helper.bundle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.spec.helper.bundle.mjs","sources":["../../../../src/moj/components/alert/alert.spec.helper.mjs"],"sourcesContent":["export const pageTemplate = `\n <main>\n <div id=\"alert-1\" role=\"region\" class=\"moj-alert moj-alert--information moj-alert--with-heading\" aria-label=\"information: This contains information\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">\n <h2 class=\"govuk-heading-m\">This contains information</h2>\n Content that informs you of a thing. It really is so very informative, that&#39;s why it needs so much content and is really, exceedingly verbose.\n </div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <h1 id=\"h1\">Heading 1</h1>\n <section>\n <h2 id=\"h2\">heading 2</h2>\n <div id=\"alert-2\" role=\"region\" class=\"moj-alert moj-alert--information\" aria-label=\"information: You might like to know\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Content that informs you of a thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n\n <div id=\"alert-3\"role=\"region\" class=\"moj-alert moj-alert--success\" aria-label=\"success: Woohoo!\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path d=\"M11.2869 24.6726L2.00415 15.3899L4.62189 12.7722L11.2869 19.4186L25.3781 5.32739L27.9958 7.96369L11.2869 24.6726Z\" fill=\"currentColor\"/>\n </svg>\n </div>\n <div class=\"moj-alert__content\">That thing just successfully occurred. <a href=\"#\">Celebrate here</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-4\" role=\"region\" class=\"moj-alert moj-alert--warning\" aria-label=\"warning: Something&#39;s not quite right\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M15 2.44922L28.75 26.1992H1.25L15 2.44922ZM13.5107 9.49579H16.4697L16.2431 17.7678H13.7461L13.5107 9.49579ZM13.1299 21.82C13.1299 21.5661 13.1787 21.3285 13.2764 21.1071C13.374 20.8793 13.5075 20.6807 13.6768 20.5114C13.8525 20.3421 14.0544 20.2087 14.2822 20.111C14.5101 20.0134 14.7542 19.9645 15.0146 19.9645C15.2686 19.9645 15.5062 20.0134 15.7275 20.111C15.9554 20.2087 16.154 20.3421 16.3232 20.5114C16.4925 20.6807 16.626 20.8793 16.7236 21.1071C16.8213 21.3285 16.8701 21.5661 16.8701 21.82C16.8701 22.0804 16.8213 22.3246 16.7236 22.5524C16.626 22.7803 16.4925 22.9789 16.3232 23.1481C16.154 23.3174 15.9554 23.4509 15.7275 23.5485C15.5062 23.6462 15.2686 23.695 15.0146 23.695C14.7542 23.695 14.5101 23.6462 14.2822 23.5485C14.0544 23.4509 13.8525 23.3174 13.6768 23.1481C13.5075 22.9789 13.374 22.7803 13.2764 22.5524C13.1787 22.3246 13.1299 22.0804 13.1299 21.82Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">You should be aware of this thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-5\" role=\"region\" class=\"moj-alert moj-alert--error\" aria-label=\"error: Woah, hold up!\" data-module=\"moj-alert\" data-dismissible=\"true\" data-dismissible=\"true\" data-focus-on-dismiss-selector=\"#focusOnMe\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20.1777 2.5H9.82233L2.5 9.82233V20.1777L9.82233 27.5H20.1777L27.5 20.1777V9.82233L20.1777 2.5ZM10.9155 8.87769L15.0001 12.9623L19.0847 8.87771L21.1224 10.9154L17.0378 15L21.1224 19.0846L19.0847 21.1222L15.0001 17.0376L10.9155 21.1223L8.87782 19.0846L12.9624 15L8.87783 10.9153L10.9155 8.87769Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Bad things happened. <a href=\"#\">Contact us</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"focusOnMe\">I will receive focus</div>\n </section>\n</main>\n`\n"],"names":["pageTemplate"],"mappings":"AAAO,MAAMA,YAAY,GAAG;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"alert.spec.helper.mjs","sources":["../../../../src/moj/components/alert/alert.spec.helper.mjs"],"sourcesContent":["export const pageTemplate = `\n <main>\n <div id=\"alert-1\" role=\"region\" class=\"moj-alert moj-alert--information moj-alert--with-heading\" aria-label=\"information: This contains information\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">\n <h2 class=\"govuk-heading-m\">This contains information</h2>\n Content that informs you of a thing. It really is so very informative, that&#39;s why it needs so much content and is really, exceedingly verbose.\n </div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <h1 id=\"h1\">Heading 1</h1>\n <section>\n <h2 id=\"h2\">heading 2</h2>\n <div id=\"alert-2\" role=\"region\" class=\"moj-alert moj-alert--information\" aria-label=\"information: You might like to know\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Content that informs you of a thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n\n <div id=\"alert-3\"role=\"region\" class=\"moj-alert moj-alert--success\" aria-label=\"success: Woohoo!\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path d=\"M11.2869 24.6726L2.00415 15.3899L4.62189 12.7722L11.2869 19.4186L25.3781 5.32739L27.9958 7.96369L11.2869 24.6726Z\" fill=\"currentColor\"/>\n </svg>\n </div>\n <div class=\"moj-alert__content\">That thing just successfully occurred. <a href=\"#\">Celebrate here</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-4\" role=\"region\" class=\"moj-alert moj-alert--warning\" aria-label=\"warning: Something&#39;s not quite right\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M15 2.44922L28.75 26.1992H1.25L15 2.44922ZM13.5107 9.49579H16.4697L16.2431 17.7678H13.7461L13.5107 9.49579ZM13.1299 21.82C13.1299 21.5661 13.1787 21.3285 13.2764 21.1071C13.374 20.8793 13.5075 20.6807 13.6768 20.5114C13.8525 20.3421 14.0544 20.2087 14.2822 20.111C14.5101 20.0134 14.7542 19.9645 15.0146 19.9645C15.2686 19.9645 15.5062 20.0134 15.7275 20.111C15.9554 20.2087 16.154 20.3421 16.3232 20.5114C16.4925 20.6807 16.626 20.8793 16.7236 21.1071C16.8213 21.3285 16.8701 21.5661 16.8701 21.82C16.8701 22.0804 16.8213 22.3246 16.7236 22.5524C16.626 22.7803 16.4925 22.9789 16.3232 23.1481C16.154 23.3174 15.9554 23.4509 15.7275 23.5485C15.5062 23.6462 15.2686 23.695 15.0146 23.695C14.7542 23.695 14.5101 23.6462 14.2822 23.5485C14.0544 23.4509 13.8525 23.3174 13.6768 23.1481C13.5075 22.9789 13.374 22.7803 13.2764 22.5524C13.1787 22.3246 13.1299 22.0804 13.1299 21.82Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">You should be aware of this thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-5\" role=\"region\" class=\"moj-alert moj-alert--error\" aria-label=\"error: Woah, hold up!\" data-module=\"moj-alert\" data-dismissible=\"true\" data-dismissible=\"true\" data-focus-on-dismiss-selector=\"#focusOnMe\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20.1777 2.5H9.82233L2.5 9.82233V20.1777L9.82233 27.5H20.1777L27.5 20.1777V9.82233L20.1777 2.5ZM10.9155 8.87769L15.0001 12.9623L19.0847 8.87771L21.1224 10.9154L17.0378 15L21.1224 19.0846L19.0847 21.1222L15.0001 17.0376L10.9155 21.1223L8.87782 19.0846L12.9624 15L8.87783 10.9153L10.9155 8.87769Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Bad things happened. <a href=\"#\">Contact us</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"focusOnMe\">I will receive focus</div>\n </section>\n</main>\n`\n"],"names":[],"mappings":"AAAY,MAAC,YAAY,GAAG;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"alert.spec.helper.mjs","sources":["../../../../src/moj/components/alert/alert.spec.helper.mjs"],"sourcesContent":["export const pageTemplate = `\n <main>\n <div id=\"alert-1\" role=\"region\" class=\"moj-alert moj-alert--information moj-alert--with-heading\" aria-label=\"information: This contains information\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">\n <h2 class=\"govuk-heading-m\">This contains information</h2>\n Content that informs you of a thing. It really is so very informative, that&#39;s why it needs so much content and is really, exceedingly verbose.\n </div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <h1 id=\"h1\">Heading 1</h1>\n <section>\n <h2 id=\"h2\">heading 2</h2>\n <div id=\"alert-2\" role=\"region\" class=\"moj-alert moj-alert--information\" aria-label=\"information: You might like to know\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.2165 3.45151C11.733 2.82332 13.3585 2.5 15 2.5C16.6415 2.5 18.267 2.82332 19.7835 3.45151C21.3001 4.07969 22.6781 5.00043 23.8388 6.16117C24.9996 7.3219 25.9203 8.69989 26.5485 10.2165C27.1767 11.733 27.5 13.3585 27.5 15C27.5 18.3152 26.183 21.4946 23.8388 23.8388C21.4946 26.183 18.3152 27.5 15 27.5C13.3585 27.5 11.733 27.1767 10.2165 26.5485C8.69989 25.9203 7.3219 24.9996 6.16117 23.8388C3.81696 21.4946 2.5 18.3152 2.5 15C2.5 11.6848 3.81696 8.50537 6.16117 6.16117C7.3219 5.00043 8.69989 4.07969 10.2165 3.45151ZM16.3574 22.4121H13.6621V12.95H16.3574V22.4121ZM13.3789 9.20898C13.3789 8.98763 13.4212 8.7793 13.5059 8.58398C13.5905 8.38216 13.7044 8.20964 13.8477 8.06641C13.9974 7.91667 14.1699 7.79948 14.3652 7.71484C14.5605 7.63021 14.7721 7.58789 15 7.58789C15.2214 7.58789 15.4297 7.63021 15.625 7.71484C15.8268 7.79948 15.9993 7.91667 16.1426 8.06641C16.2923 8.20964 16.4095 8.38216 16.4941 8.58398C16.5788 8.7793 16.6211 8.98763 16.6211 9.20898C16.6211 9.43685 16.5788 9.64844 16.4941 9.84375C16.4095 10.0391 16.2923 10.2116 16.1426 10.3613C15.9993 10.5046 15.8268 10.6185 15.625 10.7031C15.4297 10.7878 15.2214 10.8301 15 10.8301C14.7721 10.8301 14.5605 10.7878 14.3652 10.7031C14.1699 10.6185 13.9974 10.5046 13.8477 10.3613C13.7044 10.2116 13.5905 10.0391 13.5059 9.84375C13.4212 9.64844 13.3789 9.43685 13.3789 9.20898Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Content that informs you of a thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n\n <div id=\"alert-3\"role=\"region\" class=\"moj-alert moj-alert--success\" aria-label=\"success: Woohoo!\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path d=\"M11.2869 24.6726L2.00415 15.3899L4.62189 12.7722L11.2869 19.4186L25.3781 5.32739L27.9958 7.96369L11.2869 24.6726Z\" fill=\"currentColor\"/>\n </svg>\n </div>\n <div class=\"moj-alert__content\">That thing just successfully occurred. <a href=\"#\">Celebrate here</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-4\" role=\"region\" class=\"moj-alert moj-alert--warning\" aria-label=\"warning: Something&#39;s not quite right\" data-module=\"moj-alert\" data-dismissible=\"true\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M15 2.44922L28.75 26.1992H1.25L15 2.44922ZM13.5107 9.49579H16.4697L16.2431 17.7678H13.7461L13.5107 9.49579ZM13.1299 21.82C13.1299 21.5661 13.1787 21.3285 13.2764 21.1071C13.374 20.8793 13.5075 20.6807 13.6768 20.5114C13.8525 20.3421 14.0544 20.2087 14.2822 20.111C14.5101 20.0134 14.7542 19.9645 15.0146 19.9645C15.2686 19.9645 15.5062 20.0134 15.7275 20.111C15.9554 20.2087 16.154 20.3421 16.3232 20.5114C16.4925 20.6807 16.626 20.8793 16.7236 21.1071C16.8213 21.3285 16.8701 21.5661 16.8701 21.82C16.8701 22.0804 16.8213 22.3246 16.7236 22.5524C16.626 22.7803 16.4925 22.9789 16.3232 23.1481C16.154 23.3174 15.9554 23.4509 15.7275 23.5485C15.5062 23.6462 15.2686 23.695 15.0146 23.695C14.7542 23.695 14.5101 23.6462 14.2822 23.5485C14.0544 23.4509 13.8525 23.3174 13.6768 23.1481C13.5075 22.9789 13.374 22.7803 13.2764 22.5524C13.1787 22.3246 13.1299 22.0804 13.1299 21.82Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">You should be aware of this thing. <a href=\"#\">More information</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"alert-5\" role=\"region\" class=\"moj-alert moj-alert--error\" aria-label=\"error: Woah, hold up!\" data-module=\"moj-alert\" data-dismissible=\"true\" data-dismissible=\"true\" data-focus-on-dismiss-selector=\"#focusOnMe\">\n <div>\n <svg class=\"moj-alert__icon\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\" height=\"30\" width=\"30\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20.1777 2.5H9.82233L2.5 9.82233V20.1777L9.82233 27.5H20.1777L27.5 20.1777V9.82233L20.1777 2.5ZM10.9155 8.87769L15.0001 12.9623L19.0847 8.87771L21.1224 10.9154L17.0378 15L21.1224 19.0846L19.0847 21.1222L15.0001 17.0376L10.9155 21.1223L8.87782 19.0846L12.9624 15L8.87783 10.9153L10.9155 8.87769Z\" fill=\"currentColor\"/></svg>\n </div>\n <div class=\"moj-alert__content\">Bad things happened. <a href=\"#\">Contact us</a></div>\n <div class=\"moj-alert__action\">\n <button class=\"moj-alert__dismiss\" hidden>Dismiss</button>\n </div>\n </div>\n\n <div id=\"focusOnMe\">I will receive focus</div>\n </section>\n</main>\n`\n"],"names":["pageTemplate"],"mappings":"AAAO,MAAMA,YAAY,GAAG;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;"}
@@ -54,3 +54,5 @@
54
54
  @include govuk-font($size: 16, $weight: "bold");
55
55
  }
56
56
  }
57
+
58
+ /*# sourceMappingURL=_badge.scss.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/moj/components/badge/_badge.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,qBAAqB;EACrB,2BAA2B;EAC3B,qCAAqC;EACrC,8BAA8B;EAC9B,oBAAoB;EACpB,0BAA0B;EAC1B,yBAAyB;EACzB,sBAAsB;EACtB,+CAA+C;;EAE/C;IACE,oCAAoC;IACpC,6BAA6B;EAC/B;;EAEA;IACE,2CAA2C;IAC3C,oCAAoC;EACtC;;EAEA;IACE,iCAAiC;IACjC,0BAA0B;EAC5B;;EAEA;IACE,mCAAmC;IACnC,4BAA4B;EAC9B;;EAEA;IACE,kCAAkC;IAClC,2BAA2B;EAC7B;;EAEA;IACE,mCAAmC;IACnC,4BAA4B;EAC9B;;EAEA;IACE,uCAAuC;IACvC,gCAAgC;EAClC;;EAEA;IACE,+CAA+C;EACjD;AACF","file":"_badge.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #BADGE\n ========================================================================== */\n\n.moj-badge {\n display: inline-block;\n padding: 0 govuk-spacing(1);\n border: 2px solid $govuk-brand-colour;\n outline: 2px solid transparent;\n outline-offset: -2px;\n color: $govuk-brand-colour;\n text-transform: uppercase;\n vertical-align: middle;\n @include govuk-font($size: 14, $weight: \"bold\");\n\n &--purple {\n border-color: govuk-colour(\"purple\");\n color: govuk-colour(\"purple\");\n }\n\n &--bright-purple {\n border-color: govuk-colour(\"bright-purple\");\n color: govuk-colour(\"bright-purple\");\n }\n\n &--red {\n border-color: govuk-colour(\"red\");\n color: govuk-colour(\"red\");\n }\n\n &--green {\n border-color: govuk-colour(\"green\");\n color: govuk-colour(\"green\");\n }\n\n &--blue {\n border-color: govuk-colour(\"blue\");\n color: govuk-colour(\"blue\");\n }\n\n &--black {\n border-color: govuk-colour(\"black\");\n color: govuk-colour(\"black\");\n }\n\n &--grey {\n border-color: govuk-colour(\"dark-grey\");\n color: govuk-colour(\"dark-grey\");\n }\n\n &--large {\n @include govuk-font($size: 16, $weight: \"bold\");\n }\n}\n"]}
@@ -50,3 +50,5 @@
50
50
  border-color: govuk-colour("red");
51
51
  color: govuk-colour("red");
52
52
  }
53
+
54
+ /*# sourceMappingURL=_banner.scss.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/moj/components/banner/_banner.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,+BAA+B;EAC/B,yBAAyB;EACzB,qCAAqC;EACrC,0BAA0B;EAC1B,YAAY,EAAE,+DAA+D;AAC/E;;AAEA;EACE,8BAA8B;EAC9B,WAAW;EACX,kBAAkB;AACpB;;AAEA;EACE,cAAc;EACd,gBAAgB;EAChB,4BAA4B;EAC5B,8BAA8B;AAChC;;AAEA;EACE,+BAA+B;AACjC;;AAEA;;EAEE,gBAAgB;AAClB;;AAEA;EACE,8BAA8B;AAChC;;AAEA;+EAC+E;;AAE/E;EACE,mCAAmC;EACnC,4BAA4B;AAC9B;;AAEA;EACE,iCAAiC;EACjC,0BAA0B;AAC5B","file":"_banner.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #BANNER\n ========================================================================== */\n\n.moj-banner {\n margin-bottom: govuk-spacing(6);\n padding: govuk-spacing(2);\n border: 5px solid $govuk-brand-colour;\n color: $govuk-brand-colour;\n font-size: 0; // Removes white space when using inline-block on child element.\n}\n\n.moj-banner__icon {\n margin-right: govuk-spacing(2);\n float: left;\n fill: currentcolor;\n}\n\n.moj-banner__message {\n display: block;\n overflow: hidden;\n color: govuk-colour(\"black\");\n @include govuk-font($size: 19);\n}\n\n.moj-banner__message h2 {\n margin-bottom: govuk-spacing(2);\n}\n\n.moj-banner__message h2:last-child,\n.moj-banner__message p:last-child {\n margin-bottom: 0;\n}\n\n.moj-banner__assistive {\n @include govuk-visually-hidden;\n}\n\n/* Style variants\n ========================================================================== */\n\n.moj-banner--success {\n border-color: govuk-colour(\"green\");\n color: govuk-colour(\"green\");\n}\n\n.moj-banner--warning {\n border-color: govuk-colour(\"red\");\n color: govuk-colour(\"red\");\n}\n"]}
@@ -28,12 +28,18 @@ The macro
28
28
 
29
29
  The JavaScript
30
30
 
31
- ```js
32
- new MOJFrontend.ButtonGroup({
33
- container: $('.moj-button-group'),
34
- mq: '(min-width: 45em)',
35
- buttonText: 'Actions'
36
- });
31
+ ```mjs
32
+ import { ButtonMenu } from '@ministryofjustice/frontend'
33
+
34
+ const $buttonMenu = document.querySelector(
35
+ '[data-module="moj-button-menu"]'
36
+ )
37
+
38
+ new ButtonMenu($buttonMenu, {
39
+ alignMenu: 'right',
40
+ buttonText: 'Menu title',
41
+ buttonClasses: 'govuk-button--secondary'
42
+ })
37
43
  ```
38
44
 
39
45
  ## Arguments