@ministryofjustice/frontend 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) 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 +2523 -0
  5. package/moj/all.bundle.js.map +1 -0
  6. package/moj/all.bundle.mjs +2502 -0
  7. package/moj/all.bundle.mjs.map +1 -0
  8. package/moj/all.mjs +59 -69
  9. package/moj/all.mjs.map +1 -1
  10. package/moj/all.scss +2 -0
  11. package/moj/all.scss.map +1 -0
  12. package/moj/components/_all.scss +2 -0
  13. package/moj/components/_all.scss.map +1 -0
  14. package/moj/components/action-bar/_action-bar.scss +2 -0
  15. package/moj/components/action-bar/_action-bar.scss.map +1 -0
  16. package/moj/components/add-another/_add-another.scss +2 -0
  17. package/moj/components/add-another/_add-another.scss.map +1 -0
  18. package/moj/components/add-another/add-another.bundle.js +128 -0
  19. package/moj/components/add-another/add-another.bundle.js.map +1 -0
  20. package/moj/components/add-another/add-another.bundle.mjs +120 -0
  21. package/moj/components/add-another/add-another.bundle.mjs.map +1 -0
  22. package/moj/components/add-another/add-another.mjs +112 -99
  23. package/moj/components/add-another/add-another.mjs.map +1 -1
  24. package/moj/components/alert/_alert.scss +4 -0
  25. package/moj/components/alert/_alert.scss.map +1 -0
  26. package/moj/components/alert/alert.bundle.js +330 -0
  27. package/moj/components/alert/alert.bundle.js.map +1 -0
  28. package/moj/components/alert/alert.bundle.mjs +322 -0
  29. package/moj/components/alert/alert.bundle.mjs.map +1 -0
  30. package/moj/components/alert/alert.mjs +181 -217
  31. package/moj/components/alert/alert.mjs.map +1 -1
  32. package/moj/components/alert/{alert.spec.helper.js → alert.spec.helper.bundle.js} +1 -1
  33. package/moj/components/alert/alert.spec.helper.bundle.js.map +1 -0
  34. package/moj/components/alert/alert.spec.helper.bundle.mjs +67 -0
  35. package/moj/components/alert/alert.spec.helper.bundle.mjs.map +1 -0
  36. package/moj/components/alert/alert.spec.helper.mjs.map +1 -1
  37. package/moj/components/badge/_badge.scss +2 -0
  38. package/moj/components/badge/_badge.scss.map +1 -0
  39. package/moj/components/banner/_banner.scss +2 -0
  40. package/moj/components/banner/_banner.scss.map +1 -0
  41. package/moj/components/button-menu/README.md +10 -6
  42. package/moj/components/button-menu/_button-menu.scss +10 -3
  43. package/moj/components/button-menu/_button-menu.scss.map +1 -0
  44. package/moj/components/button-menu/button-menu.bundle.js +299 -0
  45. package/moj/components/button-menu/button-menu.bundle.js.map +1 -0
  46. package/moj/components/button-menu/{button-menu.js → button-menu.bundle.mjs} +74 -121
  47. package/moj/components/button-menu/button-menu.bundle.mjs.map +1 -0
  48. package/moj/components/button-menu/button-menu.mjs +246 -285
  49. package/moj/components/button-menu/button-menu.mjs.map +1 -1
  50. package/moj/components/cookie-banner/_cookie-banner.scss +2 -0
  51. package/moj/components/cookie-banner/_cookie-banner.scss.map +1 -0
  52. package/moj/components/currency-input/_currency-input.scss +2 -0
  53. package/moj/components/currency-input/_currency-input.scss.map +1 -0
  54. package/moj/components/date-picker/_date-picker.scss +2 -0
  55. package/moj/components/date-picker/_date-picker.scss.map +1 -0
  56. package/moj/components/date-picker/date-picker.bundle.js +784 -0
  57. package/moj/components/date-picker/date-picker.bundle.js.map +1 -0
  58. package/moj/components/date-picker/{date-picker.js → date-picker.bundle.mjs} +245 -439
  59. package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -0
  60. package/moj/components/date-picker/date-picker.mjs +654 -840
  61. package/moj/components/date-picker/date-picker.mjs.map +1 -1
  62. package/moj/components/filter/_filter.scss +2 -0
  63. package/moj/components/filter/_filter.scss.map +1 -0
  64. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js +96 -0
  65. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js.map +1 -0
  66. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs +88 -0
  67. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs.map +1 -0
  68. package/moj/components/filter-toggle-button/filter-toggle-button.mjs +78 -84
  69. package/moj/components/filter-toggle-button/filter-toggle-button.mjs.map +1 -1
  70. package/moj/components/form-validator/form-validator.bundle.js +198 -0
  71. package/moj/components/form-validator/form-validator.bundle.js.map +1 -0
  72. package/moj/components/form-validator/form-validator.bundle.mjs +190 -0
  73. package/moj/components/form-validator/form-validator.bundle.mjs.map +1 -0
  74. package/moj/components/form-validator/form-validator.mjs +149 -152
  75. package/moj/components/form-validator/form-validator.mjs.map +1 -1
  76. package/moj/components/header/_header.scss +2 -0
  77. package/moj/components/header/_header.scss.map +1 -0
  78. package/moj/components/identity-bar/_identity-bar.scss +2 -0
  79. package/moj/components/identity-bar/_identity-bar.scss.map +1 -0
  80. package/moj/components/interruption-card/_interruption-card.scss +2 -0
  81. package/moj/components/interruption-card/_interruption-card.scss.map +1 -0
  82. package/moj/components/messages/_messages.scss +2 -0
  83. package/moj/components/messages/_messages.scss.map +1 -0
  84. package/moj/components/multi-file-upload/_multi-file-upload.scss +2 -0
  85. package/moj/components/multi-file-upload/_multi-file-upload.scss.map +1 -0
  86. package/moj/components/multi-file-upload/multi-file-upload.bundle.js +223 -0
  87. package/moj/components/multi-file-upload/multi-file-upload.bundle.js.map +1 -0
  88. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs +215 -0
  89. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs.map +1 -0
  90. package/moj/components/multi-file-upload/multi-file-upload.mjs +193 -209
  91. package/moj/components/multi-file-upload/multi-file-upload.mjs.map +1 -1
  92. package/moj/components/multi-select/_multi-select.scss +2 -0
  93. package/moj/components/multi-select/_multi-select.scss.map +1 -0
  94. package/moj/components/multi-select/multi-select.bundle.js +78 -0
  95. package/moj/components/multi-select/multi-select.bundle.js.map +1 -0
  96. package/moj/components/multi-select/multi-select.bundle.mjs +70 -0
  97. package/moj/components/multi-select/multi-select.bundle.mjs.map +1 -0
  98. package/moj/components/multi-select/multi-select.mjs +59 -67
  99. package/moj/components/multi-select/multi-select.mjs.map +1 -1
  100. package/moj/components/notification-badge/_notification-badge.scss +2 -0
  101. package/moj/components/notification-badge/_notification-badge.scss.map +1 -0
  102. package/moj/components/organisation-switcher/_organisation-switcher.scss +2 -0
  103. package/moj/components/organisation-switcher/_organisation-switcher.scss.map +1 -0
  104. package/moj/components/page-header-actions/_page-header-actions.scss +2 -0
  105. package/moj/components/page-header-actions/_page-header-actions.scss.map +1 -0
  106. package/moj/components/page-header-actions/template.njk +1 -1
  107. package/moj/components/pagination/_pagination.scss +2 -2
  108. package/moj/components/pagination/_pagination.scss.map +1 -0
  109. package/moj/components/password-reveal/_password-reveal.scss +2 -0
  110. package/moj/components/password-reveal/_password-reveal.scss.map +1 -0
  111. package/moj/components/password-reveal/password-reveal.bundle.js +49 -0
  112. package/moj/components/password-reveal/password-reveal.bundle.js.map +1 -0
  113. package/moj/components/password-reveal/password-reveal.bundle.mjs +41 -0
  114. package/moj/components/password-reveal/password-reveal.bundle.mjs.map +1 -0
  115. package/moj/components/password-reveal/password-reveal.mjs +36 -31
  116. package/moj/components/password-reveal/password-reveal.mjs.map +1 -1
  117. package/moj/components/primary-navigation/_primary-navigation.scss +2 -0
  118. package/moj/components/primary-navigation/_primary-navigation.scss.map +1 -0
  119. package/moj/components/progress-bar/_progress-bar.scss +2 -0
  120. package/moj/components/progress-bar/_progress-bar.scss.map +1 -0
  121. package/moj/components/rich-text-editor/README.md +15 -9
  122. package/moj/components/rich-text-editor/_rich-text-editor.scss +2 -0
  123. package/moj/components/rich-text-editor/_rich-text-editor.scss.map +1 -0
  124. package/moj/components/rich-text-editor/rich-text-editor.bundle.js +145 -0
  125. package/moj/components/rich-text-editor/rich-text-editor.bundle.js.map +1 -0
  126. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs +137 -0
  127. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs.map +1 -0
  128. package/moj/components/rich-text-editor/rich-text-editor.mjs +124 -145
  129. package/moj/components/rich-text-editor/rich-text-editor.mjs.map +1 -1
  130. package/moj/components/search/_search.scss +2 -0
  131. package/moj/components/search/_search.scss.map +1 -0
  132. package/moj/components/search-toggle/{search-toggle.scss → _search-toggle.scss} +2 -0
  133. package/moj/components/search-toggle/_search-toggle.scss.map +1 -0
  134. package/moj/components/search-toggle/search-toggle.bundle.js +54 -0
  135. package/moj/components/search-toggle/search-toggle.bundle.js.map +1 -0
  136. package/moj/components/search-toggle/search-toggle.bundle.mjs +46 -0
  137. package/moj/components/search-toggle/search-toggle.bundle.mjs.map +1 -0
  138. package/moj/components/search-toggle/search-toggle.mjs +40 -49
  139. package/moj/components/search-toggle/search-toggle.mjs.map +1 -1
  140. package/moj/components/side-navigation/_side-navigation.scss +2 -0
  141. package/moj/components/side-navigation/_side-navigation.scss.map +1 -0
  142. package/moj/components/sortable-table/_sortable-table.scss +2 -2
  143. package/moj/components/sortable-table/_sortable-table.scss.map +1 -0
  144. package/moj/components/sortable-table/sortable-table.bundle.js +134 -0
  145. package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -0
  146. package/moj/components/sortable-table/sortable-table.bundle.mjs +126 -0
  147. package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -0
  148. package/moj/components/sortable-table/sortable-table.mjs +117 -130
  149. package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
  150. package/moj/components/sub-navigation/_sub-navigation.scss +2 -0
  151. package/moj/components/sub-navigation/_sub-navigation.scss.map +1 -0
  152. package/moj/components/tag/_tag.scss +2 -0
  153. package/moj/components/tag/_tag.scss.map +1 -0
  154. package/moj/components/task-list/_task-list.scss +2 -0
  155. package/moj/components/task-list/_task-list.scss.map +1 -0
  156. package/moj/components/ticket-panel/_ticket-panel.scss +2 -0
  157. package/moj/components/ticket-panel/_ticket-panel.scss.map +1 -0
  158. package/moj/components/timeline/_timeline.scss +2 -0
  159. package/moj/components/timeline/_timeline.scss.map +1 -0
  160. package/moj/filters/all.js +44 -22
  161. package/moj/helpers/_all.scss +2 -0
  162. package/moj/helpers/_all.scss.map +1 -0
  163. package/moj/helpers/_hidden.scss +2 -0
  164. package/moj/helpers/_hidden.scss.map +1 -0
  165. package/moj/helpers/_links.scss +2 -0
  166. package/moj/helpers/_links.scss.map +1 -0
  167. package/moj/{helpers.js → helpers.bundle.js} +37 -42
  168. package/moj/helpers.bundle.js.map +1 -0
  169. package/moj/helpers.bundle.mjs +179 -0
  170. package/moj/helpers.bundle.mjs.map +1 -0
  171. package/moj/helpers.mjs +52 -28
  172. package/moj/helpers.mjs.map +1 -1
  173. package/moj/init.js +11 -2
  174. package/moj/moj-frontend.min.css +1 -1
  175. package/moj/moj-frontend.min.css.map +1 -1
  176. package/moj/moj-frontend.min.js +1 -1
  177. package/moj/moj-frontend.min.js.map +1 -1
  178. package/moj/objects/_all.scss +2 -0
  179. package/moj/objects/_all.scss.map +1 -0
  180. package/moj/objects/_button-group.scss +17 -1
  181. package/moj/objects/_button-group.scss.map +1 -0
  182. package/moj/objects/_filter-layout.scss +2 -0
  183. package/moj/objects/_filter-layout.scss.map +1 -0
  184. package/moj/objects/_scrollable-pane.scss +2 -0
  185. package/moj/objects/_scrollable-pane.scss.map +1 -0
  186. package/moj/objects/_width-container.scss +2 -0
  187. package/moj/objects/_width-container.scss.map +1 -0
  188. package/moj/settings/_all.scss +2 -0
  189. package/moj/settings/_all.scss.map +1 -0
  190. package/moj/settings/_assets.scss +2 -0
  191. package/moj/settings/_assets.scss.map +1 -0
  192. package/moj/settings/_colours.scss +2 -0
  193. package/moj/settings/_colours.scss.map +1 -0
  194. package/moj/settings/_measurements.scss +2 -0
  195. package/moj/settings/_measurements.scss.map +1 -0
  196. package/moj/settings/_typography.scss +2 -0
  197. package/moj/settings/_typography.scss.map +1 -0
  198. package/moj/template.njk +13 -0
  199. package/moj/utilities/_all.scss +2 -0
  200. package/moj/utilities/_all.scss.map +1 -0
  201. package/moj/utilities/_hidden.scss +2 -0
  202. package/moj/utilities/_hidden.scss.map +1 -0
  203. package/moj/utilities/_width-container.scss +2 -0
  204. package/moj/utilities/_width-container.scss.map +1 -0
  205. package/moj/vendor/govuk-frontend/_base.scss +2 -0
  206. package/moj/vendor/govuk-frontend/_base.scss.map +1 -0
  207. package/moj/vendor/govuk-frontend/_index.scss +2 -0
  208. package/moj/vendor/govuk-frontend/_index.scss.map +1 -0
  209. package/moj/{version.js → version.bundle.js} +1 -1
  210. package/moj/version.bundle.js.map +1 -0
  211. package/moj/version.bundle.mjs +4 -0
  212. package/moj/version.bundle.mjs.map +1 -0
  213. package/moj/version.mjs.map +1 -1
  214. package/package.json +5 -6
  215. package/moj/all.jquery.min.js +0 -1
  216. package/moj/all.jquery.min.js.map +0 -1
  217. package/moj/all.js +0 -2662
  218. package/moj/all.js.map +0 -1
  219. package/moj/components/add-another/add-another.js +0 -115
  220. package/moj/components/add-another/add-another.js.map +0 -1
  221. package/moj/components/alert/alert.js +0 -356
  222. package/moj/components/alert/alert.js.map +0 -1
  223. package/moj/components/alert/alert.spec.helper.js.map +0 -1
  224. package/moj/components/button-menu/button-menu.js.map +0 -1
  225. package/moj/components/date-picker/date-picker.js.map +0 -1
  226. package/moj/components/filter-toggle-button/filter-toggle-button.js +0 -102
  227. package/moj/components/filter-toggle-button/filter-toggle-button.js.map +0 -1
  228. package/moj/components/form-validator/form-validator.js +0 -205
  229. package/moj/components/form-validator/form-validator.js.map +0 -1
  230. package/moj/components/multi-file-upload/multi-file-upload.js +0 -241
  231. package/moj/components/multi-file-upload/multi-file-upload.js.map +0 -1
  232. package/moj/components/multi-select/multi-select.js +0 -86
  233. package/moj/components/multi-select/multi-select.js.map +0 -1
  234. package/moj/components/password-reveal/password-reveal.js +0 -44
  235. package/moj/components/password-reveal/password-reveal.js.map +0 -1
  236. package/moj/components/rich-text-editor/rich-text-editor.js +0 -166
  237. package/moj/components/rich-text-editor/rich-text-editor.js.map +0 -1
  238. package/moj/components/search-toggle/search-toggle.js +0 -63
  239. package/moj/components/search-toggle/search-toggle.js.map +0 -1
  240. package/moj/components/sortable-table/sortable-table.js +0 -147
  241. package/moj/components/sortable-table/sortable-table.js.map +0 -1
  242. package/moj/helpers.js.map +0 -1
  243. package/moj/vendor/html5shiv.js +0 -326
  244. package/moj/vendor/jquery.js +0 -9300
  245. package/moj/version.js.map +0 -1
@@ -1,251 +1,215 @@
1
1
  import { setFocus, getPreviousSibling, findNearestMatchingElement } from '../../helpers.mjs';
2
2
 
3
- /**
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
9
- */
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 () {
3
+ class Alert {
47
4
  /**
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.
5
+ * @param {Element | null} $module - HTML element to use for alert
6
+ * @param {AlertConfig} [config] - Alert config
57
7
  */
58
- if (
59
- this.$module.getAttribute('role') === 'alert' &&
60
- !this.config.disableAutoFocus
61
- ) {
62
- setFocus(this.$module);
63
- }
64
-
65
- this.$dismissButton = this.$module.querySelector('.moj-alert__dismiss');
66
-
67
- if (this.config.dismissible && this.$dismissButton) {
68
- this.$dismissButton.innerHTML = this.config.dismissText;
69
- this.$dismissButton.removeAttribute('hidden');
70
-
71
- this.$module.addEventListener('click', (event) => {
72
- if (this.$dismissButton.contains(event.target)) {
73
- this.dimiss();
8
+ constructor($module, config = {}) {
9
+ if (!$module || !($module instanceof HTMLElement)) {
10
+ return this;
11
+ }
12
+ const schema = Object.freeze({
13
+ properties: {
14
+ dismissible: {
15
+ type: 'boolean'
16
+ },
17
+ dismissText: {
18
+ type: 'string'
19
+ },
20
+ disableAutoFocus: {
21
+ type: 'boolean'
22
+ },
23
+ focusOnDismissSelector: {
24
+ type: 'string'
25
+ }
74
26
  }
75
27
  });
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;
28
+ const defaults = {
29
+ dismissible: false,
30
+ dismissText: 'Dismiss',
31
+ disableAutoFocus: false
32
+ };
33
+
34
+ // data attributes override JS config, which overrides defaults
35
+ this.config = this.mergeConfigs(defaults, config, this.parseDataset(schema, $module.dataset));
36
+ this.$module = $module;
37
+
38
+ /**
39
+ * Focus the alert
40
+ *
41
+ * If `role="alert"` is set, focus the element to help some assistive
42
+ * technologies prioritise announcing it.
43
+ *
44
+ * You can turn off the auto-focus functionality by setting
45
+ * `data-disable-auto-focus="true"` in the component HTML. You might wish to
46
+ * do this based on user research findings, or to avoid a clash with another
47
+ * element which should be focused when the page loads.
48
+ */
49
+ if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
50
+ setFocus(this.$module);
51
+ }
52
+ this.$dismissButton = this.$module.querySelector('.moj-alert__dismiss');
53
+ if (this.config.dismissible && this.$dismissButton) {
54
+ this.$dismissButton.innerHTML = this.config.dismissText;
55
+ this.$dismissButton.removeAttribute('hidden');
56
+ this.$module.addEventListener('click', event => {
57
+ if (event.target instanceof Node && this.$dismissButton.contains(event.target)) {
58
+ this.dimiss();
59
+ }
60
+ });
97
61
  }
98
62
  }
99
63
 
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() : '';
64
+ /**
65
+ * Handle dismissing the alert
66
+ */
67
+ dimiss() {
68
+ let $elementToRecieveFocus;
144
69
 
145
- let output;
146
- let outputType;
147
- if (property && property.type) {
148
- outputType = property.type;
149
- }
70
+ // If a selector has been provided, attempt to find that element
71
+ if (this.config.focusOnDismissSelector) {
72
+ $elementToRecieveFocus = document.querySelector(this.config.focusOnDismissSelector);
73
+ }
150
74
 
151
- // No schema type set? Determine automatically
152
- if (!outputType) {
153
- if (['true', 'false'].includes(trimmedValue)) {
154
- outputType = 'boolean';
75
+ // Is the next sibling another alert
76
+ if (!$elementToRecieveFocus) {
77
+ const $nextSibling = this.$module.nextElementSibling;
78
+ if ($nextSibling && $nextSibling.matches('.moj-alert')) {
79
+ $elementToRecieveFocus = $nextSibling;
80
+ }
155
81
  }
156
82
 
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';
83
+ // Else try to find any preceding sibling alert or heading
84
+ if (!$elementToRecieveFocus) {
85
+ $elementToRecieveFocus = getPreviousSibling(this.$module, '.moj-alert, h1, h2, h3, h4, h5, h6');
161
86
  }
162
- }
163
87
 
164
- switch (outputType) {
165
- case 'boolean':
166
- output = trimmedValue === 'true';
167
- break
88
+ // Else find the closest ancestor heading, or fallback to main, or last resort
89
+ // use the body element
90
+ if (!$elementToRecieveFocus) {
91
+ $elementToRecieveFocus = findNearestMatchingElement(this.$module, 'h1, h2, h3, h4, h5, h6, main, body');
92
+ }
168
93
 
169
- case 'number':
170
- output = Number(trimmedValue);
171
- break
94
+ // If we have an element, place focus on it
95
+ if ($elementToRecieveFocus instanceof HTMLElement) {
96
+ setFocus($elementToRecieveFocus);
97
+ }
172
98
 
173
- default:
174
- output = value;
99
+ // Remove the alert
100
+ this.$module.remove();
175
101
  }
176
102
 
177
- return output
178
- };
103
+ /**
104
+ * Normalise string
105
+ *
106
+ * 'If it looks like a duck, and it quacks like a duck…' 🦆
107
+ *
108
+ * If the passed value looks like a boolean or a number, convert it to a boolean
109
+ * or number.
110
+ *
111
+ * Designed to be used to convert config passed via data attributes (which are
112
+ * always strings) into something sensible.
113
+ *
114
+ * @internal
115
+ * @param {DOMStringMap[string]} value - The value to normalise
116
+ * @param {SchemaProperty} [property] - Component schema property
117
+ * @returns {string | boolean | number | undefined} Normalised data
118
+ */
119
+ normaliseString(value, property) {
120
+ const trimmedValue = value ? value.trim() : '';
121
+ let output;
122
+ let outputType;
123
+ if (property && property.type) {
124
+ outputType = property.type;
125
+ }
179
126
 
180
- /**
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
189
- */
190
- Alert.prototype.parseDataset = function (schema, dataset) {
191
- const parsed = {};
127
+ // No schema type set? Determine automatically
128
+ if (!outputType) {
129
+ if (['true', 'false'].includes(trimmedValue)) {
130
+ outputType = 'boolean';
131
+ }
192
132
 
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);
133
+ // Empty / whitespace-only strings are considered finite so we need to check
134
+ // the length of the trimmed string as well
135
+ if (trimmedValue.length > 0 && Number.isFinite(Number(trimmedValue))) {
136
+ outputType = 'number';
197
137
  }
198
138
  }
139
+ switch (outputType) {
140
+ case 'boolean':
141
+ output = trimmedValue === 'true';
142
+ break;
143
+ case 'number':
144
+ output = Number(trimmedValue);
145
+ break;
146
+ default:
147
+ output = value;
148
+ }
149
+ return output;
199
150
  }
200
151
 
201
- return parsed
202
- };
203
-
204
- /**
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
212
- */
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;
152
+ /**
153
+ * Parse dataset
154
+ *
155
+ * Loop over an object and normalise each value using {@link normaliseString},
156
+ * optionally expanding nested `i18n.field`
157
+ *
158
+ * @param {Schema} schema - component schema
159
+ * @param {DOMStringMap} dataset - HTML element dataset
160
+ * @returns {object} Normalised dataset
161
+ */
162
+ parseDataset(schema, dataset) {
163
+ const parsed = {};
164
+ for (const [field, property] of Object.entries(schema.properties)) {
165
+ if (field in dataset) {
166
+ if (dataset[field]) {
167
+ parsed[field] = this.normaliseString(dataset[field], property);
168
+ }
230
169
  }
231
170
  }
171
+ return parsed;
232
172
  }
233
173
 
234
- return formattedConfigObject
235
- };
236
-
237
- /**
238
- * Schema for component config
239
- *
240
- * @typedef {object} Schema
241
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
242
- */
174
+ /**
175
+ * Config merging function
176
+ *
177
+ * Takes any number of objects and combines them together, with
178
+ * greatest priority on the LAST item passed in.
179
+ *
180
+ * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge
181
+ * @returns {{ [key: string]: unknown }} A merged config object
182
+ */
183
+ mergeConfigs(...configObjects) {
184
+ const formattedConfigObject = {};
185
+
186
+ // Loop through each of the passed objects
187
+ for (const configObject of configObjects) {
188
+ for (const key of Object.keys(configObject)) {
189
+ const option = formattedConfigObject[key];
190
+ const override = configObject[key];
191
+
192
+ // Push their keys one-by-one into formattedConfigObject. Any duplicate
193
+ // keys with object values will be merged, otherwise the new value will
194
+ // override the existing value.
195
+ if (typeof option === 'object' && typeof override === 'object') {
196
+ // @ts-expect-error Index signature for type 'string' is missing
197
+ formattedConfigObject[key] = this.mergeConfigs(option, override);
198
+ } else {
199
+ formattedConfigObject[key] = override;
200
+ }
201
+ }
202
+ }
203
+ return formattedConfigObject;
204
+ }
205
+ }
243
206
 
244
207
  /**
245
- * Schema property for component config
246
- *
247
- * @typedef {object} SchemaProperty
248
- * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
208
+ * @typedef {object} AlertConfig
209
+ * @property {boolean} [dismissible=false] - Can the alert be dismissed by the user
210
+ * @property {string} [dismissText=Dismiss] - the label text for the dismiss button
211
+ * @property {boolean} [disableAutoFocus=false] - whether the alert will be autofocused
212
+ * @property {string} [focusOnDismissSelector] - CSS Selector for element to be focused on dismiss
249
213
  */
250
214
 
251
215
  export { Alert };
@@ -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,C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ACA;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 {\n findNearestMatchingElement,\n getPreviousSibling,\n setFocus\n} from '../../helpers.mjs'\n\nexport class Alert {\n /**\n * @param {Element | null} $module - HTML element to use for alert\n * @param {AlertConfig} [config] - Alert config\n */\n constructor($module, config = {}) {\n if (!$module || !($module instanceof HTMLElement)) {\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 /**\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 (\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.$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 instanceof HTMLElement) {\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 */\n normaliseString(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 && Number.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 */\n parseDataset(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 */\n mergeConfigs(...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/**\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"],"names":["Alert","constructor","$module","config","HTMLElement","schema","Object","freeze","properties","dismissible","type","dismissText","disableAutoFocus","focusOnDismissSelector","defaults","mergeConfigs","parseDataset","dataset","getAttribute","setFocus","$dismissButton","querySelector","innerHTML","removeAttribute","addEventListener","event","target","Node","contains","dimiss","$elementToRecieveFocus","document","$nextSibling","nextElementSibling","matches","getPreviousSibling","findNearestMatchingElement","remove","normaliseString","value","property","trimmedValue","trim","output","outputType","includes","length","Number","isFinite","parsed","field","entries","configObjects","formattedConfigObject","configObject","key","keys","option","override"],"mappings":";;AAMO,MAAMA,KAAK,CAAC;AACjB;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,OAAO,EAAEC,MAAM,GAAG,EAAE,EAAE;IAChC,IAAI,CAACD,OAAO,IAAI,EAAEA,OAAO,YAAYE,WAAW,CAAC,EAAE;AACjD,MAAA,OAAO,IAAI;AACb;AAEA,IAAA,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC3BC,MAAAA,UAAU,EAAE;AACVC,QAAAA,WAAW,EAAE;AAAEC,UAAAA,IAAI,EAAE;SAAW;AAChCC,QAAAA,WAAW,EAAE;AAAED,UAAAA,IAAI,EAAE;SAAU;AAC/BE,QAAAA,gBAAgB,EAAE;AAAEF,UAAAA,IAAI,EAAE;SAAW;AACrCG,QAAAA,sBAAsB,EAAE;AAAEH,UAAAA,IAAI,EAAE;AAAS;AAC3C;AACF,KAAC,CAAC;AAEF,IAAA,MAAMI,QAAQ,GAAG;AACfL,MAAAA,WAAW,EAAE,KAAK;AAClBE,MAAAA,WAAW,EAAE,SAAS;AACtBC,MAAAA,gBAAgB,EAAE;KACnB;;AAED;IACA,IAAI,CAACT,MAAM,GAAG,IAAI,CAACY,YAAY,CAC7BD,QAAQ,EACRX,MAAM,EACN,IAAI,CAACa,YAAY,CAACX,MAAM,EAAEH,OAAO,CAACe,OAAO,CAC3C,CAAC;IAED,IAAI,CAACf,OAAO,GAAGA,OAAO;;AAEtB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,IAAA,IACE,IAAI,CAACA,OAAO,CAACgB,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,IAC7C,CAAC,IAAI,CAACf,MAAM,CAACS,gBAAgB,EAC7B;AACAO,MAAAA,QAAQ,CAAC,IAAI,CAACjB,OAAO,CAAC;AACxB;IAEA,IAAI,CAACkB,cAAc,GAAG,IAAI,CAAClB,OAAO,CAACmB,aAAa,CAA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KAAK,MAAM,CAACC,KAAK,EAAEV,QAAQ,CAAC,IAAIlC,MAAM,CAAC6C,OAAO,CAAC9C,MAAM,CAACG,UAAU,CAAC,EAAE;MACjE,IAAI0C,KAAK,IAAIjC,OAAO,EAAE;AACpB,QAAA,IAAIA,OAAO,CAACiC,KAAK,CAAC,EAAE;AAClBD,UAAAA,MAAM,CAACC,KAAK,CAAC,GAAG,IAAI,CAACZ,eAAe,CAACrB,OAAO,CAACiC,KAAK,CAAC,EAAEV,QAAQ,CAAC;AAChE;AACF;AACF;AAEA,IAAA,OAAOS,MAAM;AACf;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACElC,YAAYA,CAAC,GAAGqC,aAAa,EAAE;IAC7B,MAAMC,qBAAqB,GAAG,EAAE;;AAEhC;AACA,IAAA,KAAK,MAAMC,YAAY,IAAIF,aAAa,EAAE;MACxC,KAAK,MAAMG,GAAG,IAAIjD,MAAM,CAACkD,IAAI,CAACF,YAAY,CAAC,EAAE;AAC3C,QAAA,MAAMG,MAAM,GAAGJ,qBAAqB,CAACE,GAAG,CAAC;AACzC,QAAA,MAAMG,QAAQ,GAAGJ,YAAY,CAACC,GAAG,CAAC;;AAElC;AACA;AACA;QACA,IAAI,OAAOE,MAAM,KAAK,QAAQ,IAAI,OAAOC,QAAQ,KAAK,QAAQ,EAAE;AAC9D;UACAL,qBAAqB,CAACE,GAAG,CAAC,GAAG,IAAI,CAACxC,YAAY,CAAC0C,MAAM,EAAEC,QAAQ,CAAC;AAClE,SAAC,MAAM;AACLL,UAAAA,qBAAqB,CAACE,GAAG,CAAC,GAAGG,QAAQ;AACvC;AACF;AACF;AAEA,IAAA,OAAOL,qBAAqB;AAC9B;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
@@ -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;;;;"}